abci: Move app_hash parameter from Commit to FinalizeBlock#8664
abci: Move app_hash parameter from Commit to FinalizeBlock#8664sergio-mena merged 14 commits intomasterfrom
app_hash parameter from Commit to FinalizeBlock#8664Conversation
app_hash parameter from Commit to FinalizeBlockapp_hash parameter from Commit to FinalizeBlock
abci/types/types.go
Outdated
| // IsErr returns true if Code is something other than OK. | ||
| func (r ResponseQuery) IsErr() bool { | ||
| return r.Code != CodeTypeOK | ||
|
|
There was a problem hiding this comment.
this is probably unintentional.
There was a problem hiding this comment.
yes, thanks for spotting
| txBytes := make([]byte, 8) | ||
| binary.BigEndian.PutUint64(txBytes, uint64(i)) | ||
| err := assertMempool(t, cs.txNotifier).CheckTx(ctx, txBytes, nil, mempool.TxInfo{}) | ||
| var rCode uint32 |
There was a problem hiding this comment.
this is always 0? maybe best to omit
There was a problem hiding this comment.
It is filled by the functor I added to the CheckTx call in line 141.
This was a problem in this test: CheckTx was returning "no error", but the Code field in the CheckTx response was being ignored by the test... so CheckTx was failing but the TC was thinking it was passing.
So I was chasing a problem, and it was really cumbersome before adding line 143.
There was a problem hiding this comment.
on line 141 you reference r.Code not rCode, so I still think this isn’t being used, though perhaps not intentionally.
There was a problem hiding this comment.
I'm setting rCode (captured by closure) to the value of r.Code
|
in your e2e command-line above, you only run 25% of the e2e tests. Is there a reason for this? |
cmwaters
left a comment
There was a problem hiding this comment.
Few comments but mostly looks good. This will definitely need a changelog and a note in UPGRADING.md (the latter can be done altogether at a separate time if that's more convenient)
internal/state/execution.go
Outdated
| "height", block.Height, | ||
| "num_txs", len(block.Txs), | ||
| "app_hash", fmt.Sprintf("%X", res.Data), | ||
| "app_hash", appHash, |
There was a problem hiding this comment.
We could probably remove that log here and just have it in FinalizeBlock
There was a problem hiding this comment.
Two things:
- I just realize I removed the formatting. That's probably bad. Will put it back
- To your question. I thought about it, and decided to pass the hash to this function just to print it here, under the assumption that this is an important log people are used to seeing when troubleshooting. So didn't want to split it to minimize disruption. On the other hand, it might lead people to think the
app_hashis still being returned at commit time.
So, I'm 50-50 on what to do... a little push from you in either direction and I will leave it or change it.
There was a problem hiding this comment.
I would try to put it around FinalizeBlock if we can - to illustrate that it's returned there. We could also return the blockHash here which is associated with that height.
There was a problem hiding this comment.
OK, will log on FinalizeBlock
| @@ -332,7 +331,6 @@ message ResponseFinalizeBlock { | |||
| repeated ValidatorUpdate validator_updates = 3 [(gogoproto.nullable) = false]; | |||
| tendermint.types.ConsensusParams consensus_param_updates = 4; | |||
| bytes app_hash = 5; | |||
There was a problem hiding this comment.
This is a subjective conversation about words so perhaps it won't mean anything, but do we want to change the terminology from app_hash to data. app_hash is probably what's more commonly used, but I like data because it doesn't assume a hash - but rather any arbitrary data that will be agreed upon
There was a problem hiding this comment.
I've always found data "hard to grasp" when working on the spec (had to think for 10 secs what "data" this was referring to).
How about app_data ?
There was a problem hiding this comment.
Honestly, I'm also happy with app_hash. I'll leave it up to your discretion
e2e tests take a long time on M1s, so just copy-pasted the e2e-nightly-master, and ran the "group (00)". Found it a reasonable tradeoff. |
| txBytes := make([]byte, 8) | ||
| binary.BigEndian.PutUint64(txBytes, uint64(i)) | ||
| err := assertMempool(t, cs.txNotifier).CheckTx(ctx, txBytes, nil, mempool.TxInfo{}) | ||
| var rCode uint32 |
There was a problem hiding this comment.
on line 141 you reference r.Code not rCode, so I still think this isn’t being used, though perhaps not intentionally.
you can run the nightly tests on your branch locally. I think its useful to run specific tests locally for debugging or smoke testing purposes, but it’s a better use of (everyone’s) time to run the nightly tests in CI for a branch in cases like this. The tests are sensitive enough to timing concerns that running them on a laptop may not be super useful. |
Co-authored-by: Callum Waters <cmwaters19@gmail.com>
Will do now. Please double-check once I push |
CHANGELOG_PENDING.md
Outdated
| - [config] \#8222 default indexer configuration to null. (@creachadair) | ||
| - [rpc] \#8570 rework timeouts to be per-method instead of global. (@creachadair) | ||
| - [rpc] \#8624 deprecate `broadcast_tx_commit` and `braodcast_tx_sync` and `broadcast_tx_async` in favor of `braodcast_tx`. (@tychoish) | ||
| - [abci] [ABCI++](https://github.com/orgs/tendermint/projects/9) is not backwards compatible with ABCI. (@sergio-mena) |
There was a problem hiding this comment.
I think this is not necessary. If you want to mention the non-backwards compatibility, I would do it in the upgrading document
| #### Moving the `app_hash` parameter | ||
|
|
||
| The Application's hash (or any data representing the Application's current | ||
| state) is known by the time `FinalizeBlock` finishes its execution. | ||
| Accordingly, the `app_hash` parameter has been moved from `ResponseCommit` to | ||
| `ResponseFinalizeBlock`, since it makes sense for the Application to return | ||
| this value as soon as is it known. |
There was a problem hiding this comment.
This in many ways should actually be covered by the ABCI++ spec and upgrade notes
There was a problem hiding this comment.
Yes. We need to expand/improve this section, with selected information from the spec that is important for App developers (in case they choose not to read the spec).
I'll leave it as is for the moment, if you agree, and will come back to it when tackling doc in a holistic way.
* [partial cherry-pick] abci: Move `app_hash` parameter from `Commit` to `FinalizeBlock` (tendermint#8664) * Removed from proto * make proto-gen * make build works * make some tests pass * Fix TestMempoolTxConcurrentWithCommit * Minor change * Update abci/types/types.go * Update internal/state/execution.go * Update test/e2e/app/state.go Co-authored-by: Callum Waters <cmwaters19@gmail.com> * Updated changelog and `UPGRADING.md` * Fixed abci-cli tests, and doc * Addressed @cmwaters' comments * Addressed @cmwaters' comments, part 2 Co-authored-by: Callum Waters <cmwaters19@gmail.com> * Levftover typo in spec --------- Co-authored-by: Callum Waters <cmwaters19@gmail.com>
|
@sergio-mena Instead of moving apphash from Commit to FinalizeBlock, why not still keep the appHash in the Commit Response, but just add that for FinalizeBlock response? We are using ABCI++ and we are pretty frustrated because the Commit interface doesn't really return the AppHash, so it forces us to implement the getWorkingHash to always return the finalized commit hash. In a case where people want to customize the state commit store, it is not very flexible and convenient than just using the hash returned from the Commit response. Is there any plan to add the app hash back to to the commit response in the future? cc @alexanderbez |
Closes #8632
This PR doesn't address the spec as there is a parallel, ongoing one dealing with
FinalizeBlock/Commitall over the spec (see #7659).All UTs are passing, except
TestRootConfig, which is failing also on the baselinee2e are passing: