diff --git a/baseapp/abci.go b/baseapp/abci.go index a77a5021c3ce..37fce2cf6289 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -281,7 +281,7 @@ func (app *BaseApp) VerifyFraudProof(req abci.RequestVerifyFraudProof) (res abci appFromFraudProof.InitChain(abci.RequestInitChain{}) appHash := appFromFraudProof.GetAppHash(abci.RequestGetAppHash{}).AppHash - if !bytes.Equal(fraudProof.appHash, appHash) { + if !bytes.Equal(fraudProof.preStateAppHash, appHash) { return abci.ResponseVerifyFraudProof{ Success: false, } @@ -304,7 +304,7 @@ func (app *BaseApp) VerifyFraudProof(req abci.RequestVerifyFraudProof) (res abci } appHash = appFromFraudProof.GetAppHash(abci.RequestGetAppHash{}).AppHash - success = bytes.Equal(appHash, req.ExpectedAppHash) + success = bytes.Equal(appHash, req.ExpectedValidAppHash) } res = abci.ResponseVerifyFraudProof{ Success: success, diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 1a27b973feb4..49d2708deeb2 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -858,7 +858,7 @@ func (app *BaseApp) getFraudProof(storeKeyToWitnessData map[string][]iavltree.Wi if err != nil { return FraudProof{}, err } - fraudProof.appHash = appHash + fraudProof.preStateAppHash = appHash for storeKeyName := range storeKeyToWitnessData { iavlStore, err := cms.GetIAVLStore(storeKeyName) if err != nil { diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index e70506bbecf9..272260dda774 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -2362,7 +2362,7 @@ func TestGenerateAndLoadFraudProof(t *testing.T) { fraudProof := FraudProof{} err = fraudProof.fromABCI(*resp.FraudProof) require.Nil(t, err) - require.Equal(t, appHashB1, fraudProof.appHash) + require.Equal(t, appHashB1, fraudProof.preStateAppHash) fraudProofVerified, err := fraudProof.verifyFraudProof() require.Nil(t, err) require.True(t, fraudProofVerified) @@ -2448,8 +2448,8 @@ func TestABCIEndToEndFraudProof(t *testing.T) { // Light Client verifyResp := appB1.VerifyFraudProof( abci.RequestVerifyFraudProof{ - FraudProof: generateResp.FraudProof, - ExpectedAppHash: appHashAfterFraud, + FraudProof: generateResp.FraudProof, + ExpectedValidAppHash: appHashAfterFraud, }, ) require.True(t, verifyResp.Success) diff --git a/baseapp/fraudproof.go b/baseapp/fraudproof.go index f8a0d6036cee..5a4fd354429d 100644 --- a/baseapp/fraudproof.go +++ b/baseapp/fraudproof.go @@ -22,7 +22,8 @@ type FraudProof struct { // TODO: Add Proof that appHash is inside merklized ISRs in block header at block height - appHash []byte + preStateAppHash []byte + expectedValidAppHash []byte // A map from module name to state witness stateWitness map[string]StateWitness @@ -162,8 +163,8 @@ func (fraudProof *FraudProof) verifyFraudProof() (bool, error) { if err != nil { return false, err } - if !bytes.Equal(appHash[0], fraudProof.appHash) { - return false, fmt.Errorf("got appHash: %s, expected: %s", string(fraudProof.appHash), string(fraudProof.appHash)) + if !bytes.Equal(appHash[0], fraudProof.preStateAppHash) { + return false, fmt.Errorf("got appHash: %s, expected: %s", string(fraudProof.preStateAppHash), string(fraudProof.preStateAppHash)) } // Fraudproof verification on a substore level @@ -238,7 +239,8 @@ func (fraudProof *FraudProof) toABCI() (*abci.FraudProof, error) { } return &abci.FraudProof{ BlockHeight: fraudProof.blockHeight, - AppHash: fraudProof.appHash, + PreStateAppHash: fraudProof.preStateAppHash, + ExpectedValidAppHash: fraudProof.expectedValidAppHash, StateWitness: abciStateWitness, FraudulentBeginBlock: fraudProof.fraudulentBeginBlock, FraudulentDeliverTx: fraudProof.fraudulentDeliverTx, @@ -270,7 +272,8 @@ func (fraudProof *FraudProof) fromABCI(abciFraudProof abci.FraudProof) error { } } fraudProof.blockHeight = abciFraudProof.BlockHeight - fraudProof.appHash = abciFraudProof.AppHash + fraudProof.preStateAppHash = abciFraudProof.PreStateAppHash + fraudProof.expectedValidAppHash = abciFraudProof.ExpectedValidAppHash fraudProof.stateWitness = stateWitness fraudProof.fraudulentBeginBlock = abciFraudProof.FraudulentBeginBlock fraudProof.fraudulentDeliverTx = abciFraudProof.FraudulentDeliverTx diff --git a/go.mod b/go.mod index 538a51efeb88..abca23fba75f 100644 --- a/go.mod +++ b/go.mod @@ -256,7 +256,7 @@ replace ( // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - github.com/tendermint/tendermint => github.com/celestiaorg/tendermint v0.34.22-0.20221129185527-17adf5012374 + github.com/tendermint/tendermint => github.com/celestiaorg/tendermint v0.34.22-0.20221202214355-3605c597500d ) retract v0.46.2 diff --git a/go.sum b/go.sum index f9749fdeb6c4..859a18ad8253 100644 --- a/go.sum +++ b/go.sum @@ -200,8 +200,8 @@ github.com/celestiaorg/rollmint v0.4.0 h1:+eu2m25ALhlHj9pbAElzq2pSg6WJ4Bn8/WqL2H github.com/celestiaorg/rollmint v0.4.0/go.mod h1:EBnqxgmcH0MIgNgiI8NyVa1sNSzCyCpvAlAHd9myhk4= github.com/celestiaorg/smt v0.3.0 h1:Hc6m8fIVRajrg/Saf8ivX4xw551LHzOs8kqeadd6h9s= github.com/celestiaorg/smt v0.3.0/go.mod h1:/sdYDakowo/XaxS2Fl7CBqtuf/O2uTqF2zmAUFAtAiw= -github.com/celestiaorg/tendermint v0.34.22-0.20221129185527-17adf5012374 h1:AoxKmsmDDZdbiP+0BtOa8cXaztA8BnD8mbcsfTksdeQ= -github.com/celestiaorg/tendermint v0.34.22-0.20221129185527-17adf5012374/go.mod h1:zoyyiiihvTW8DnOr63YLxhYn/WK/QmE74CeIpS++hBE= +github.com/celestiaorg/tendermint v0.34.22-0.20221202214355-3605c597500d h1:OH9dp6WWotp53aG58xSdLWd+F1Znf3DhA0BadyJO4Aw= +github.com/celestiaorg/tendermint v0.34.22-0.20221202214355-3605c597500d/go.mod h1:zoyyiiihvTW8DnOr63YLxhYn/WK/QmE74CeIpS++hBE= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=