From 37d5fbcdea768a6d3db6e1c7ba2e20e806659b41 Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Mon, 25 Mar 2024 17:22:01 -0700 Subject: [PATCH 1/2] remove extra print statements --- ethereum/contract_backend_wrapper.go | 6 ------ noble/message_state.go | 2 -- 2 files changed, 8 deletions(-) diff --git a/ethereum/contract_backend_wrapper.go b/ethereum/contract_backend_wrapper.go index 53f7908..7290372 100644 --- a/ethereum/contract_backend_wrapper.go +++ b/ethereum/contract_backend_wrapper.go @@ -2,7 +2,6 @@ package ethereum import ( "context" - "fmt" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" @@ -19,10 +18,5 @@ func NewContractBackendWrapper(client *ethclient.Client) *ContractBackendWrapper } func (c *ContractBackendWrapper) SendTransaction(ctx context.Context, tx *types.Transaction) error { - json, err := tx.MarshalJSON() - if err != nil { - return err - } - fmt.Printf("SendTransaction: %+v\n\nRAW: %s\n", tx, json) return c.Client.SendTransaction(ctx, tx) } diff --git a/noble/message_state.go b/noble/message_state.go index 5392834..aae4fb2 100644 --- a/noble/message_state.go +++ b/noble/message_state.go @@ -73,8 +73,6 @@ func txToMessageState(tx *ctypes.ResultTx) ([]*types.MessageState, error) { } messageStates = append(messageStates, messageState) - - fmt.Printf("Appended transfer from 4 to %d\n", msg.DestinationDomain) } } if !parsed { From 43c3f5d22654dec05f32119a0730b31196ad537c Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Mon, 25 Mar 2024 17:22:13 -0700 Subject: [PATCH 2/2] add checks for complete --- ethereum/broadcast.go | 10 +++++----- noble/broadcast.go | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ethereum/broadcast.go b/ethereum/broadcast.go index c69e83d..d77a05d 100644 --- a/ethereum/broadcast.go +++ b/ethereum/broadcast.go @@ -56,16 +56,17 @@ func (e *Ethereum) Broadcast( var broadcastErrors error MsgLoop: for _, msg := range msgs { - if msg.Status == types.Complete { - continue MsgLoop - } - attestationBytes, err := hex.DecodeString(msg.Attestation[2:]) if err != nil { return errors.New("unable to decode message attestation") } for attempt := 0; attempt <= e.maxRetries; attempt++ { + // check if another worker already broadcasted tx due to flush + if msg.Status == types.Complete { + continue MsgLoop + } + if err := e.attemptBroadcast( ctx, logger, @@ -139,7 +140,6 @@ func (e *Ethereum) attemptBroadcast( if nonceErr != nil { logger.Debug("Error querying whether nonce was used. Continuing...", "error:", nonceErr) } else { - fmt.Printf("received used nonce response: %d\n", response) if response.Uint64() == uint64(1) { // nonce has already been used, mark as complete logger.Debug(fmt.Sprintf("This source domain/nonce has already been used: %d %d", diff --git a/noble/broadcast.go b/noble/broadcast.go index fb760ab..d92f4e6 100644 --- a/noble/broadcast.go +++ b/noble/broadcast.go @@ -103,6 +103,11 @@ func (n *Noble) attemptBroadcast( continue } + // check if another worker already broadcasted tx due to flush + if msg.Status == types.Complete { + continue + } + attestationBytes, err := hex.DecodeString(msg.Attestation[2:]) if err != nil { return fmt.Errorf("unable to decode message attestation")