diff --git a/pkg/core/stateroot/store.go b/pkg/core/stateroot/store.go index ff3b1a6cb..9efcf7c5f 100644 --- a/pkg/core/stateroot/store.go +++ b/pkg/core/stateroot/store.go @@ -2,12 +2,20 @@ package stateroot import ( "encoding/binary" + "errors" + "fmt" "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/io" ) +var ( + // ErrStateMismatch means that local state root doesn't match the one + // signed by state validators. + ErrStateMismatch = errors.New("stateroot mismatch") +) + const ( prefixGC = 0x01 prefixLocal = 0x02 @@ -60,6 +68,9 @@ func (s *Module) AddStateRoot(sr *state.MPTRoot) error { if err != nil { return err } + if !local.Root.Equals(sr.Root) { + return fmt.Errorf("%w at block %d: %v vs %v", ErrStateMismatch, sr.Index, local.Root, sr.Root) + } if len(local.Witness) != 0 { return nil }