Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeddes committed Dec 4, 2024
1 parent d6b8f46 commit e153114
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
8 changes: 2 additions & 6 deletions relayer/cmd/sync_beefy_commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func syncBeefyCommitmentCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "sync-latest-beefy-commitment",
Use: "sync-beefy-commitment",
Short: "Sync beefy commitment on demand",
Args: cobra.ExactArgs(0),
RunE: SyncBeefyCommitmentFn,
Expand All @@ -22,9 +22,6 @@ func syncBeefyCommitmentCmd() *cobra.Command {
cmd.Flags().String("private-key", "", "Ethereum private key")
cmd.Flags().String("private-key-file", "", "The file from which to read the private key")
cmd.Flags().String("private-key-id", "", "The secret id to lookup the private key in AWS Secrets Manager")

cmd.Flags().Uint64P("block-number", "b", 0, "Relay block number which contains a Parachain message")
cmd.MarkFlagRequired("block-number")
return cmd
}

Expand Down Expand Up @@ -57,7 +54,6 @@ func SyncBeefyCommitmentFn(cmd *cobra.Command, _ []string) error {
if err != nil {
return err
}
blockNumber, _ := cmd.Flags().GetUint64("block-number")
err = relay.OneShotSync(ctx, blockNumber)
err = relay.RateLimitedSync(ctx)
return err
}
22 changes: 15 additions & 7 deletions relayer/relays/beefy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (relay *Relay) RateLimitedSync(ctx context.Context) error {
var tokens atomic.Uint64
tokens.Store(1)

go refiller(ctx, &tokens, 1, 1, time.Minute*30)
go refiller(ctx, &tokens, 1, 1, time.Minute*60)

for {
log.Info("Starting check")
Expand Down Expand Up @@ -237,14 +237,22 @@ func (relay *Relay) RateLimitedSync(ctx context.Context) error {
}

log.Info("Sync completed")
}

// Sleep for 5 minute
select {
case <-ctx.Done():
return nil
case <-time.After(time.Second * 300):
// Sleep for 5 minute to allow message relayer to sync nonces
select {
case <-ctx.Done():
return nil
case <-time.After(time.Second * 300):
}
} else {
// Sleep for 1 minute
select {
case <-ctx.Done():
return nil
case <-time.After(time.Second * 60):
}
}

}
}

Expand Down

0 comments on commit e153114

Please sign in to comment.