From adffefc674f5cd74fffc70007b3ae7551c253349 Mon Sep 17 00:00:00 2001 From: Andrea V <1577639+karimodm@users.noreply.github.com> Date: Tue, 28 Nov 2023 10:01:16 +0100 Subject: [PATCH] Fix race in notarization vs attestations --- pkg/protocol/engine/notarization/slotnotarization/manager.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/protocol/engine/notarization/slotnotarization/manager.go b/pkg/protocol/engine/notarization/slotnotarization/manager.go index 3b3c3c3a9..b894794b3 100644 --- a/pkg/protocol/engine/notarization/slotnotarization/manager.go +++ b/pkg/protocol/engine/notarization/slotnotarization/manager.go @@ -42,7 +42,7 @@ type Manager struct { acceptedTimeFunc func() time.Time apiProvider iotago.APIProvider - commitmentMutex syncutils.Mutex + commitmentMutex syncutils.RWMutex module.Module } @@ -156,6 +156,9 @@ func (m *Manager) IsBootstrapped() bool { } func (m *Manager) notarizeAcceptedBlock(block *blocks.Block) (err error) { + m.commitmentMutex.RLock() + defer m.commitmentMutex.RUnlock() + if err = m.slotMutations.AddAcceptedBlock(block); err != nil { return ierrors.Wrap(err, "failed to add accepted block to slot mutations") }