Skip to content

Commit

Permalink
adds extra check before sending message
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden committed Oct 1, 2024
1 parent 69646d3 commit 450eea1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 0 additions & 4 deletions relayer/relays/beacon/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package config
import (
"errors"
"fmt"

log "github.com/sirupsen/logrus"
)

type Config struct {
Expand Down Expand Up @@ -92,14 +90,12 @@ func (b BeaconConfig) Validate() error {
}

func (p ParachainConfig) Validate() error {
log.Info("validating parachain settings")
if p.Endpoint == "" {
return errors.New("[endpoint] is not set")
}
if p.MaxWatchedExtrinsics == 0 {
return errors.New("[maxWatchedExtrinsics] is not set")
}
log.WithField("HeaderRedundancy", p.HeaderRedundancy).Info("p.HeaderRedundancy is")
if p.HeaderRedundancy == 0 {
return errors.New("[headerRedundancy] is not set")
}
Expand Down
11 changes: 10 additions & 1 deletion relayer/relays/execution/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,21 @@ func (r *Relay) doSubmit(ctx context.Context, ev *contracts.GatewayOutboundMessa
return fmt.Errorf("fetch execution header proof: %w", err)
}

paraNonce, err := r.fetchLatestParachainNonce()
if err != nil {
return fmt.Errorf("fetch latest parachain nonce: %w", err)
}
if ev.Nonce <= paraNonce {
log.WithField("nonce", paraNonce).Info("message picked up by another relayer, skipped")
return nil
}

err = r.writeToParachain(ctx, proof, inboundMsg)
if err != nil {
return fmt.Errorf("write to parachain: %w", err)
}

paraNonce, err := r.fetchLatestParachainNonce()
paraNonce, err = r.fetchLatestParachainNonce()
if err != nil {
return fmt.Errorf("fetch latest parachain nonce: %w", err)
}
Expand Down

0 comments on commit 450eea1

Please sign in to comment.