build(deps): Bump cosmossdk.io/store from 1.0.0 to 1.0.1 (#18582)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
github-actions
Julien Robert
parent
0c633a59f3
commit
cc85702956
+2
-15
@@ -2,7 +2,6 @@ package baseapp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -127,28 +126,16 @@ func (app *BaseApp) InitChain(req *abci.RequestInitChain) (*abci.ResponseInitCha
|
||||
}
|
||||
}
|
||||
|
||||
// In the case of a new chain, AppHash will be the hash of an empty string.
|
||||
// During an upgrade, it'll be the hash of the last committed block.
|
||||
var appHash []byte
|
||||
if !app.LastCommitID().IsZero() {
|
||||
appHash = app.LastCommitID().Hash
|
||||
} else {
|
||||
// $ echo -n '' | sha256sum
|
||||
// e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
emptyHash := sha256.Sum256([]byte{})
|
||||
appHash = emptyHash[:]
|
||||
}
|
||||
|
||||
// NOTE: We don't commit, but FinalizeBlock for block InitialHeight starts from
|
||||
// this FinalizeBlockState.
|
||||
return &abci.ResponseInitChain{
|
||||
ConsensusParams: res.ConsensusParams,
|
||||
Validators: res.Validators,
|
||||
AppHash: appHash,
|
||||
AppHash: app.LastCommitID().Hash,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (app *BaseApp) Info(req *abci.RequestInfo) (*abci.ResponseInfo, error) {
|
||||
func (app *BaseApp) Info(_ *abci.RequestInfo) (*abci.ResponseInfo, error) {
|
||||
lastCommitID := app.cms.LastCommitID()
|
||||
appVersion := InitialAppVersion
|
||||
if lastCommitID.Version > 0 {
|
||||
|
||||
@@ -3,6 +3,7 @@ package baseapp_test
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
@@ -59,10 +60,12 @@ func TestABCI_Info(t *testing.T) {
|
||||
res, err := suite.baseApp.Info(&reqInfo)
|
||||
require.NoError(t, err)
|
||||
|
||||
emptyHash := sha256.Sum256([]byte{})
|
||||
appHash := emptyHash[:]
|
||||
require.Equal(t, "", res.Version)
|
||||
require.Equal(t, t.Name(), res.GetData())
|
||||
require.Equal(t, int64(0), res.LastBlockHeight)
|
||||
require.Equal(t, []uint8(nil), res.LastBlockAppHash)
|
||||
require.Equal(t, appHash, res.LastBlockAppHash)
|
||||
appVersion, err := suite.baseApp.AppVersion(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, appVersion, res.AppVersion)
|
||||
@@ -145,12 +148,10 @@ func TestABCI_InitChain(t *testing.T) {
|
||||
// e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
apphash, err := hex.DecodeString("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
|
||||
require.NoError(t, err)
|
||||
emptyHash := sha256.Sum256([]byte{})
|
||||
require.Equal(t, emptyHash[:], apphash)
|
||||
|
||||
require.Equal(
|
||||
t,
|
||||
apphash,
|
||||
initChainRes.AppHash,
|
||||
)
|
||||
require.Equal(t, apphash, initChainRes.AppHash)
|
||||
|
||||
// assert that chainID is set correctly in InitChain
|
||||
chainID := getFinalizeBlockStateCtx(app).ChainID()
|
||||
|
||||
@@ -2,6 +2,7 @@ package baseapp_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"testing"
|
||||
@@ -202,7 +203,9 @@ func TestLoadVersion(t *testing.T) {
|
||||
err := app.LoadLatestVersion() // needed to make stores non-nil
|
||||
require.Nil(t, err)
|
||||
|
||||
emptyCommitID := storetypes.CommitID{}
|
||||
emptyHash := sha256.Sum256([]byte{})
|
||||
appHash := emptyHash[:]
|
||||
emptyCommitID := storetypes.CommitID{Hash: appHash}
|
||||
|
||||
// fresh store has zero/empty last commit
|
||||
lastHeight := app.LastBlockHeight()
|
||||
@@ -746,7 +749,10 @@ func TestLoadVersionPruning(t *testing.T) {
|
||||
err := app.LoadLatestVersion() // needed to make stores non-nil
|
||||
require.Nil(t, err)
|
||||
|
||||
emptyCommitID := storetypes.CommitID{}
|
||||
emptyHash := sha256.Sum256([]byte{})
|
||||
emptyCommitID := storetypes.CommitID{
|
||||
Hash: emptyHash[:],
|
||||
}
|
||||
|
||||
// fresh store has zero/empty last commit
|
||||
lastHeight := app.LastBlockHeight()
|
||||
|
||||
Reference in New Issue
Block a user