Skip to content

Commit

Permalink
Add extra checks for completed messages (#71)
Browse files Browse the repository at this point in the history
* remove extra print statements

* add checks for complete
  • Loading branch information
boojamya authored Mar 26, 2024
1 parent d74f654 commit 642daeb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
10 changes: 5 additions & 5 deletions ethereum/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions ethereum/contract_backend_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ethereum

import (
"context"
"fmt"

"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
Expand All @@ -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)
}
5 changes: 5 additions & 0 deletions noble/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 0 additions & 2 deletions noble/message_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 642daeb

Please sign in to comment.