stateroot: handle ErrStateMismatch internally

It's a local problem and returning error from here leads to peer disconnect
that isn't solving anything.
This commit is contained in:
Roman Khimov 2021-03-27 00:32:15 +03:00
parent 216513e14f
commit 3b4dde05c3

View file

@ -9,6 +9,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer" "github.com/nspcc-dev/neo-go/pkg/core/blockchainer"
"github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/stateroot"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/network/payload" "github.com/nspcc-dev/neo-go/pkg/network/payload"
@ -107,7 +108,12 @@ func (s *service) OnPayload(ep *payload.Extensible) error {
if sr.Index == 0 { if sr.Index == 0 {
return nil return nil
} }
return s.AddStateRoot(sr) err := s.AddStateRoot(sr)
if errors.Is(err, stateroot.ErrStateMismatch) {
s.log.Error("can't add SV-signed state root", zap.Error(err))
return nil
}
return err
case VoteT: case VoteT:
v := m.Payload.(*Vote) v := m.Payload.(*Vote)
return s.AddSignature(v.Height, v.ValidatorIndex, v.Signature) return s.AddSignature(v.Height, v.ValidatorIndex, v.Signature)