From fc800dcbc1ceabd4165315d404a1956366eee522 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 6 May 2021 21:53:34 +0300 Subject: [PATCH] stateroot: protect incomplete root manipulations in signAndSend We're modifying it here, so there can be a race between this method and AddSignature(). --- pkg/services/stateroot/validators.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/services/stateroot/validators.go b/pkg/services/stateroot/validators.go index ed0895ae0..819966db4 100644 --- a/pkg/services/stateroot/validators.go +++ b/pkg/services/stateroot/validators.go @@ -60,9 +60,11 @@ func (s *service) signAndSend(r *state.MPTRoot) error { sig := acc.PrivateKey().SignHashable(uint32(s.Network), r) incRoot := s.getIncompleteRoot(r.Index) + incRoot.Lock() incRoot.root = r incRoot.addSignature(acc.PrivateKey().PublicKey(), sig) incRoot.reverify(s.Network) + incRoot.Unlock() s.accMtx.RLock() myIndex := s.myIndex