mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-19 21:56:22 +00:00
abci: Move app_hash parameter from Commit to FinalizeBlock (#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>
This commit is contained in:
co-authored by
Callum Waters
parent
9a8c334362
commit
56fc80d66d
+2
-2
@@ -210,6 +210,7 @@ func (app *Application) FinalizeBlock(_ context.Context, req *abci.RequestFinali
|
||||
return &abci.ResponseFinalizeBlock{
|
||||
TxResults: txs,
|
||||
ValidatorUpdates: valUpdates,
|
||||
AppHash: app.state.Finalize(),
|
||||
Events: []abci.Event{
|
||||
{
|
||||
Type: "val_updates",
|
||||
@@ -233,7 +234,7 @@ func (app *Application) Commit(_ context.Context) (*abci.ResponseCommit, error)
|
||||
app.mu.Lock()
|
||||
defer app.mu.Unlock()
|
||||
|
||||
height, hash, err := app.state.Commit()
|
||||
height, err := app.state.Commit()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -253,7 +254,6 @@ func (app *Application) Commit(_ context.Context) (*abci.ResponseCommit, error)
|
||||
retainHeight = int64(height - app.cfg.RetainBlocks + 1)
|
||||
}
|
||||
return &abci.ResponseCommit{
|
||||
Data: hash,
|
||||
RetainHeight: retainHeight,
|
||||
}, nil
|
||||
}
|
||||
|
||||
+11
-4
@@ -137,8 +137,8 @@ func (s *State) Set(key, value string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Commit commits the current state.
|
||||
func (s *State) Commit() (uint64, []byte, error) {
|
||||
// Finalize is called after applying a block, updating the height and returning the new app_hash
|
||||
func (s *State) Finalize() []byte {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
switch {
|
||||
@@ -150,13 +150,20 @@ func (s *State) Commit() (uint64, []byte, error) {
|
||||
s.Height = 1
|
||||
}
|
||||
s.Hash = hashItems(s.Values, s.Height)
|
||||
return s.Hash
|
||||
}
|
||||
|
||||
// Commit commits the current state.
|
||||
func (s *State) Commit() (uint64, error) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
if s.persistInterval > 0 && s.Height%s.persistInterval == 0 {
|
||||
err := s.save()
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return s.Height, s.Hash, nil
|
||||
return s.Height, nil
|
||||
}
|
||||
|
||||
func (s *State) Rollback() error {
|
||||
|
||||
Reference in New Issue
Block a user