Skip to content

Commit

Permalink
Merge pull request #39 from InjectiveLabs/increase-block-confirmations
Browse files Browse the repository at this point in the history
increase ethBlockConfirmationDelay
  • Loading branch information
mankenavenkatesh authored Jul 14, 2021
2 parents aaabc91 + e271073 commit dd5760b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions orchestrator/eth_event_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import (
wrappers "github.com/InjectiveLabs/peggo/solidity/wrappers/Peggy.sol"
)

// Considering blocktime=3s approx on injective-chain, and oracle loop duration = 1 minute, we can broadcast only 20 events in each iteration.
// So better to search only 20 blocks to ensure all the events gets broadcasted to injective chain without missing.
// Considering blocktime of up to 3 seconds approx on the Injective Chain and an oracle loop duration = 1 minute,
// we broadcast only 20 events in each iteration.
// So better to search only 20 blocks to ensure all the events are broadcast to Injective Chain without misses.
const defaultBlocksToSearch = 20

const ethBlockConfirmationDelay = 12

// CheckForEvents checks for events such as a deposit to the Peggy Ethereum contract or a validator set update
// or a transaction batch update. It then responds to these events by performing actions on the Cosmos chain if required
func (s *peggyOrchestrator) CheckForEvents(
Expand All @@ -27,8 +30,8 @@ func (s *peggyOrchestrator) CheckForEvents(
return 0, err
}

// add delay to ensure miminum confirmations are received and block is finalised
currentBlock = latestHeader.Number.Uint64() - uint64(6)
// add delay to ensure minimum confirmations are received and block is finalised
currentBlock = latestHeader.Number.Uint64() - uint64(ethBlockConfirmationDelay)

if currentBlock < startingBlock {
return currentBlock, nil
Expand Down Expand Up @@ -147,7 +150,7 @@ func (s *peggyOrchestrator) CheckForEvents(
// the possibility that the relayer was killed after relaying only one of multiple events in a single
// block, so we also need this routine so make sure we don't send in the first event in this hypothetical
// multi event block again. In theory we only send all events for every block and that will pass of fail
// atomicly but lets not take that risk.
// atomically but lets not take that risk.
lastClaimEvent, err := s.cosmosQueryClient.LastClaimEventByAddr(ctx, s.peggyBroadcastClient.AccFromAddress())
if err != nil {
err = errors.New("failed to query last claim event from backend")
Expand Down
2 changes: 1 addition & 1 deletion orchestrator/relayer/valset_relaying.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (s *peggyRelayer) RelayValsets(ctx context.Context) error {
for _, set := range latestValsets {
sigs, err := s.cosmosQueryClient.AllValsetConfirms(ctx, set.Nonce)
if err != nil {
err = errors.Wrapf(err, "failed to get valset confims at nonce %d", set.Nonce)
err = errors.Wrapf(err, "failed to get valset confirms at nonce %d", set.Nonce)
return err
} else if len(sigs) == 0 {
continue
Expand Down

0 comments on commit dd5760b

Please sign in to comment.