Skip to content

Commit

Permalink
Ignore submit when authorities not change
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed May 28, 2024
1 parent 5eba01b commit 482e8a2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
13 changes: 12 additions & 1 deletion relayer/relays/beefy/ethereum-writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ func (wr *EthereumWriter) submit(ctx context.Context, task Request) error {
return err
}
if uint32(latestBeefyBlock) >= task.SignedCommitment.Commitment.BlockNumber {
log.WithFields(logrus.Fields{
"blockNumber": task.SignedCommitment.Commitment.BlockNumber,
"IsHandover": task.IsHandover,
"ValidatorSetID": task.SignedCommitment.Commitment.ValidatorSetID,
}).Warn("Ignore outdated commitment")
return nil
}

currentValidatorSet, err := wr.contract.CurrentValidatorSet(&callOpts)
if err != nil {
return err
Expand All @@ -103,6 +107,13 @@ func (wr *EthereumWriter) submit(ctx context.Context, task Request) error {
task.ValidatorsRoot = currentValidatorSet.Root
if task.IsHandover {
task.ValidatorsRoot = nextValidatorSet.Root
if task.nextAuthoritiesRoot == task.ValidatorsRoot {
log.WithFields(logrus.Fields{
"blockNumber": task.SignedCommitment.Commitment.BlockNumber,
"ValidatorSetID": task.SignedCommitment.Commitment.ValidatorSetID,
}).Warn("Ignore mandatory commitment authorities not change")
return nil
}
}

// Initial submission
Expand Down
1 change: 1 addition & 0 deletions relayer/relays/beefy/polkadot-listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (li *PolkadotListener) scanCommitments(
continue
}
task.IsHandover = true
task.nextAuthoritiesRoot = nextAuthoritySet.Root
select {
case <-ctx.Done():
return ctx.Err()
Expand Down
11 changes: 6 additions & 5 deletions relayer/relays/beefy/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
)

type Request struct {
Validators []substrate.Authority
ValidatorsRoot [32]byte
SignedCommitment types.SignedCommitment
Proof merkle.SimplifiedMMRProof
IsHandover bool
Validators []substrate.Authority
ValidatorsRoot [32]byte
nextAuthoritiesRoot [32]byte
SignedCommitment types.SignedCommitment
Proof merkle.SimplifiedMMRProof
IsHandover bool
}

0 comments on commit 482e8a2

Please sign in to comment.