From fbbe2740cd2e86251250337db2927ef7df70961c Mon Sep 17 00:00:00 2001 From: Cool Developer Date: Thu, 20 Jun 2024 09:52:50 -0400 Subject: [PATCH] update the interface --- runtime/v2/store.go | 1 + scripts/simapp-v2-init.sh | 3 --- server/v2/cometbft/abci.go | 2 +- server/v2/cometbft/types/store.go | 4 ++++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/runtime/v2/store.go b/runtime/v2/store.go index 8abd825c0b1f..a9f16fb3e788 100644 --- a/runtime/v2/store.go +++ b/runtime/v2/store.go @@ -26,6 +26,7 @@ type Store interface { // state. Must error when the version does not exist. StateAt(version uint64) (store.ReaderMap, error) + WorkingHash(changeset *store.Changeset) (store.Hash, error) Commit(changeset *store.Changeset) (store.Hash, error) // Query is a key/value query directly to the underlying database. This skips the appmanager diff --git a/scripts/simapp-v2-init.sh b/scripts/simapp-v2-init.sh index 6bdb51de7b57..0bd6c0106e4a 100755 --- a/scripts/simapp-v2-init.sh +++ b/scripts/simapp-v2-init.sh @@ -25,9 +25,6 @@ jq '.app_state.gov.voting_params.voting_period = "600s"' genesis.json > temp.jso # to change the inflation jq '.app_state.mint.minter.inflation = "0.300000000000000000"' genesis.json > temp.json && mv temp.json genesis.json -# change the initial height to 2 to work around store/v2 and iavl limitations with a genesis block -jq '.initial_height = 2' genesis.json > temp.json && mv temp.json genesis.json - $SIMD keys add test_validator --indiscreet VALIDATOR_ADDRESS=$($SIMD keys show test_validator -a --keyring-backend test) diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index a14a793a00ac..88bc61a55efb 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -289,7 +289,7 @@ func (c *Consensus[T]) InitChain(ctx context.Context, req *abciproto.InitChainRe cs := &store.Changeset{ Changes: stateChanges, } - stateRoot, err := c.store.Commit(cs) + stateRoot, err := c.store.WorkingHash(cs) if err != nil { return nil, fmt.Errorf("unable to commit the changeset: %w", err) } diff --git a/server/v2/cometbft/types/store.go b/server/v2/cometbft/types/store.go index dbbd8f313eff..e85d21da2560 100644 --- a/server/v2/cometbft/types/store.go +++ b/server/v2/cometbft/types/store.go @@ -14,6 +14,10 @@ type Store interface { // associated with it. StateLatest() (uint64, store.ReaderMap, error) + // WorkingHash writes the provided changeset to the state and returns + // the working hash of the state. + WorkingHash(*store.Changeset) (store.Hash, error) + // Commit commits the provided changeset and returns // the new state root of the state. Commit(*store.Changeset) (store.Hash, error)