Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra checks for completed messages #71

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading