diff --git a/chains/evm/listener/handlers/deposit.go b/chains/evm/listener/handlers/deposit.go index df1ac3e..cf51deb 100644 --- a/chains/evm/listener/handlers/deposit.go +++ b/chains/evm/listener/handlers/deposit.go @@ -10,7 +10,6 @@ import ( "math/big" "slices" "strings" - "sync" ethereumABI "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -56,7 +55,6 @@ type DepositEventHandler struct { slotIndex uint8 genericResources []string msgChan chan []*message.Message - lock sync.Mutex } func NewDepositEventHandler( @@ -76,14 +74,10 @@ func NewDepositEventHandler( genericResources: genericResources, msgChan: msgChan, domainID: domainID, - lock: sync.Mutex{}, } } func (h *DepositEventHandler) HandleEvents(destination uint8, startBlock *big.Int, endBlock *big.Int, slot *big.Int) error { - h.lock.Lock() - defer h.lock.Unlock() - deposits, err := h.fetchDeposits(destination, startBlock, endBlock) if err != nil { return err diff --git a/chains/evm/listener/handlers/hashi.go b/chains/evm/listener/handlers/hashi.go index 431f31f..e0c5ab5 100644 --- a/chains/evm/listener/handlers/hashi.go +++ b/chains/evm/listener/handlers/hashi.go @@ -8,7 +8,6 @@ import ( "fmt" "math/big" "strings" - "sync" "github.com/attestantio/go-eth2-client/api" apiv1 "github.com/attestantio/go-eth2-client/api/v1" @@ -54,7 +53,6 @@ type HashiEventHandler struct { beaconClient BeaconClient client Client chainIDS map[uint8]uint64 - lock sync.Mutex } func NewHashiEventHandler( @@ -78,14 +76,10 @@ func NewHashiEventHandler( rootProver: rootProver, chainIDS: chainIDS, msgChan: msgChan, - lock: sync.Mutex{}, } } func (h *HashiEventHandler) HandleEvents(destination uint8, startBlock *big.Int, endBlock *big.Int, slot *big.Int) error { - h.lock.Lock() - defer h.lock.Unlock() - logs, err := h.fetchMessages(startBlock, endBlock) if err != nil { return err diff --git a/chains/evm/message/stateRoot.go b/chains/evm/message/stateRoot.go index 42cd10c..bbd80f4 100644 --- a/chains/evm/message/stateRoot.go +++ b/chains/evm/message/stateRoot.go @@ -7,6 +7,7 @@ import ( "context" "encoding/hex" "math/big" + "sync" "github.com/attestantio/go-eth2-client/api" "github.com/attestantio/go-eth2-client/spec" @@ -54,6 +55,7 @@ type StateRootHandler struct { eventHandlers []EventHandler startBlock *big.Int domainID uint8 + lock sync.Mutex } func NewStateRootHandler( @@ -69,12 +71,16 @@ func NewStateRootHandler( domainID: domainID, startBlock: startBlock, eventHandlers: eventHandlers, + lock: sync.Mutex{}, } } // HandleMessage fetches deposits for the given state root and submits a transfer message // with execution state proofs per transfer func (h *StateRootHandler) HandleMessage(m *message.Message) (*proposal.Proposal, error) { + h.lock.Lock() + defer h.lock.Unlock() + stateRoot := m.Data.(StateRootData) log.Debug().Uint8( "domainID", m.Destination).Str(