Skip to content

Commit

Permalink
add workaround for missing finalized query on eos evm (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
fschoell authored Dec 18, 2023
1 parent be58954 commit deff673
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/fireantelope/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,19 @@ func pollerRunE(logger *zap.Logger, tracer logging.Tracer) firecore.CommandExecu
handler := blockpoller.NewFireBlockHandler("type.googleapis.com/sf.ethereum.type.v2.Block")
poller := blockpoller.New(fetcher, handler, blockpoller.WithStoringState(stateDir), blockpoller.WithLogger(logger))

// there is currently no support for rpc.FinalizedBlock on eos evm, so we use the latest one
// there is currently no support for rpc.FinalizedBlock on eos evm, so query the latest one and then pass
// latest - 200 as the latest finalized block
latestBlock, err := rpcClient.GetBlockByNumber(ctx, rpc.LatestBlock)
if err != nil {
return fmt.Errorf("getting latest block: %w", err)
}

err = poller.Run(ctx, firstStreamableBlock, bstream.NewBlockRef(latestBlock.Hash.String(), uint64(latestBlock.Number)))
latestFinalizedBlock, err := rpcClient.GetBlockByNumber(ctx, rpc.BlockNumber(uint64(latestBlock.Number-200)))
if err != nil {
return fmt.Errorf("getting latest finalized block: %w", err)
}

err = poller.Run(ctx, firstStreamableBlock, bstream.NewBlockRef(latestFinalizedBlock.Hash.String(), uint64(latestFinalizedBlock.Number)))
if err != nil {
return fmt.Errorf("running poller: %w", err)
}
Expand Down

0 comments on commit deff673

Please sign in to comment.