cosmos-sdk/baseapp
Facundo Medica 6a03586074
fix: remove previous header in Prepare/Process Proposal + provide chain id in baseapp + fix context for verifying txs (#15303)
## Description

### Issue
Some values (like chain ID) were being leaked from the previous block/initialization into PrepareProposal and ProcessProposal, these values are only available if:
1. The node has never been stopped since the genesis block (as these values are set on `InitChain`)
2. The node has already commited a block (as the previous header was being used for the new state of prepare and process proposal).

So if a node is restarted, during the first prepare and process proposal these values won't be populated, and that will cause issues if they are being used.

### Solution

Remove any previous header information from a previous block in the prepare and process proposal contexts, making things consistent at every height.

- Added ChainID to baseapp
- Use an empty header in Commit() with only the chain id set
- Fix context for prepare and process proposal

Closes: #15269



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
2023-03-13 17:15:39 +00:00
..
testutil refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
abci_test.go fix: remove previous header in Prepare/Process Proposal + provide chain id in baseapp + fix context for verifying txs (#15303) 2023-03-13 17:15:39 +00:00
abci.go fix: remove previous header in Prepare/Process Proposal + provide chain id in baseapp + fix context for verifying txs (#15303) 2023-03-13 17:15:39 +00:00
baseapp_test.go refactor(log): associate test logger with testing.T instance (#15261) 2023-03-03 20:26:45 +00:00
baseapp.go fix: remove previous header in Prepare/Process Proposal + provide chain id in baseapp + fix context for verifying txs (#15303) 2023-03-13 17:15:39 +00:00
block_gas_test.go fix: correct path required proto testdata (#14991) 2023-02-11 16:59:16 +00:00
grpcrouter_helpers.go refactor!: migrate Cosmos SDK to CometBFT (#14897) 2023-02-05 14:51:33 +01:00
grpcrouter_test.go refactor(log): associate test logger with testing.T instance (#15261) 2023-03-03 20:26:45 +00:00
grpcrouter.go refactor!: migrate Cosmos SDK to CometBFT (#14897) 2023-02-05 14:51:33 +01:00
grpcserver.go refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
msg_service_router_test.go refactor(log): associate test logger with testing.T instance (#15261) 2023-03-03 20:26:45 +00:00
msg_service_router.go refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
options.go fix: remove previous header in Prepare/Process Proposal + provide chain id in baseapp + fix context for verifying txs (#15303) 2023-03-13 17:15:39 +00:00
params_legacy.go refactor: rename to CometBFT (#14914) 2023-02-06 18:11:14 +00:00
params.go refactor: rename to CometBFT (#14914) 2023-02-06 18:11:14 +00:00
recovery_test.go refactor: Revert middlewares to antehandlers (part 1/2: baseapp) (#11979) 2022-05-20 09:27:27 +00:00
recovery.go refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
state.go refactor: create go.mod for store (#14746) 2023-01-25 13:31:56 +00:00
test_helpers.go refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
utils_test.go refactor(log): associate test logger with testing.T instance (#15261) 2023-03-03 20:26:45 +00:00