diff --git a/op-node/sources/eth_client.go b/op-node/sources/eth_client.go index b5e30a897b..c36aa6d991 100644 --- a/op-node/sources/eth_client.go +++ b/op-node/sources/eth_client.go @@ -310,7 +310,7 @@ func (s *EthClient) InfoByLabel(ctx context.Context, label eth.BlockLabel) (eth. func (s *EthClient) BSCInfoByLabel(ctx context.Context, label eth.BlockLabel) (eth.BlockInfo, error) { // can't hit the cache when querying the head due to reorgs / changes. if label == eth.Finalized { - return s.headerCall(ctx, "eth_getFinalizedBlock", numberID(15)) + return s.bscFinalizedHeader(ctx, 21) } return s.headerCall(ctx, "eth_getBlockByNumber", label) } @@ -434,3 +434,20 @@ func (s *EthClient) ReadStorageAt(ctx context.Context, address common.Address, s func (s *EthClient) Close() { s.client.Close() } + +func (s *EthClient) bscFinalizedHeader(ctx context.Context, probabilisticFinalized int64) (eth.BlockInfo, error) { + var header *rpcHeader + err := s.client.CallContext(ctx, &header, "eth_getFinalizedHeader", probabilisticFinalized) // headers are just blocks without txs + if err != nil { + return nil, err + } + if header == nil { + return nil, ethereum.NotFound + } + info, err := header.Info(s.trustRPC, s.mustBePostMerge) + if err != nil { + return nil, err + } + s.headersCache.Add(info.Hash(), info) + return info, nil +} diff --git a/op-node/sources/l1_client.go b/op-node/sources/l1_client.go index 4942f6e0f2..c530fac1d4 100644 --- a/op-node/sources/l1_client.go +++ b/op-node/sources/l1_client.go @@ -87,7 +87,7 @@ func NewL1Client(client client.RPC, log log.Logger, metrics caching.Metrics, con // Notice, we cannot cache a block reference by label because labels are not guaranteed to be unique. func (s *L1Client) L1BlockRefByLabel(ctx context.Context, label eth.BlockLabel) (eth.L1BlockRef, error) { info, err := s.BSCInfoByLabel(ctx, label) - if label == eth.Finalized && err != nil && strings.Contains(err.Error(), "eth_getFinalizedBlock does not exist") { + if label == eth.Finalized && err != nil && strings.Contains(err.Error(), "eth_getFinalizedHeader does not exist") { // op-e2e not support bsc as L1 currently, so fallback to not use bsc specific method eth_getFinalizedBlock info, err = s.InfoByLabel(ctx, label) }