From deff673da16baf0441bdf316c9e546ef7f34fb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Sch=C3=B6ll?= Date: Mon, 18 Dec 2023 17:08:55 +0100 Subject: [PATCH] add workaround for missing finalized query on eos evm (#110) --- cmd/fireantelope/poller.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/fireantelope/poller.go b/cmd/fireantelope/poller.go index 807e233..65051ef 100644 --- a/cmd/fireantelope/poller.go +++ b/cmd/fireantelope/poller.go @@ -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) }