From 6c3d362e5c0204429ef69d2bab227e5b07b038e3 Mon Sep 17 00:00:00 2001 From: Matus Kysel Date: Wed, 7 Jan 2026 10:56:38 +0100 Subject: [PATCH] fix(api): use correct value for LastBlockIDByBatchID --- core/rawdb/taiko_l1_origin.go | 5 +++-- eth/taiko_api_backend.go | 6 +++--- ethclient/taiko_api.go | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/rawdb/taiko_l1_origin.go b/core/rawdb/taiko_l1_origin.go index 891f732743fa..879e086468a5 100644 --- a/core/rawdb/taiko_l1_origin.go +++ b/core/rawdb/taiko_l1_origin.go @@ -6,6 +6,7 @@ import ( "math/big" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" @@ -140,7 +141,7 @@ func WriteBatchToLastBlockID(db ethdb.KeyValueWriter, batch *big.Int, blockID *b } // ReadBatchToLastBlockID retrieves the block ID corresponding to the last block ID in this batch. -func ReadBatchToLastBlockID(db ethdb.KeyValueReader, batch *big.Int) (*big.Int, error) { +func ReadBatchToLastBlockID(db ethdb.KeyValueReader, batch *big.Int) (*hexutil.Big, error) { data, _ := db.Get(batchToLastBlockKey(batch)) if len(data) == 0 { return nil, nil @@ -152,5 +153,5 @@ func ReadBatchToLastBlockID(db ethdb.KeyValueReader, batch *big.Int) (*big.Int, return nil, fmt.Errorf("invalid batch to block unmarshal: %w", err) } - return (*big.Int)(blockID), nil + return (*hexutil.Big)(blockID), nil } diff --git a/eth/taiko_api_backend.go b/eth/taiko_api_backend.go index 98310bde0990..fc227409f2b9 100644 --- a/eth/taiko_api_backend.go +++ b/eth/taiko_api_backend.go @@ -82,7 +82,7 @@ func (s *TaikoAPIBackend) LastL1OriginByBatchID(batchID *math.HexOrDecimal256) ( } // LastBlockIDByBatchID returns the ID of the last block for the given batch. -func (s *TaikoAPIBackend) LastBlockIDByBatchID(batchID *math.HexOrDecimal256) (*big.Int, error) { +func (s *TaikoAPIBackend) LastBlockIDByBatchID(batchID *math.HexOrDecimal256) (*hexutil.Big, error) { blockID, err := rawdb.ReadBatchToLastBlockID(s.eth.ChainDb(), (*big.Int)(batchID)) if err != nil { return nil, err @@ -100,7 +100,7 @@ func (s *TaikoAPIBackend) GetSyncMode() (string, error) { } // getLastBlockByBatchId traverses the blockchain backwards to find the last Shasta block of the given Shasta batch ID. -func (s *TaikoAPIBackend) getLastBlockByBatchId(batchID *big.Int) (*big.Int, error) { +func (s *TaikoAPIBackend) getLastBlockByBatchId(batchID *big.Int) (*hexutil.Big, error) { currentBlock := s.eth.BlockChain().GetBlockByNumber(s.eth.blockchain.CurrentHeader().Number.Uint64()) for currentBlock != nil && @@ -114,7 +114,7 @@ func (s *TaikoAPIBackend) getLastBlockByBatchId(batchID *big.Int) (*big.Int, err return nil, err } if proposalID.Cmp(batchID) == 0 { - return currentBlock.Number(), nil + return (*hexutil.Big)(currentBlock.Number()), nil } currentBlock = s.eth.BlockChain().GetBlockByNumber(currentBlock.NumberU64() - 1) diff --git a/ethclient/taiko_api.go b/ethclient/taiko_api.go index 399d8b6661c3..5eadaab62771 100644 --- a/ethclient/taiko_api.go +++ b/ethclient/taiko_api.go @@ -42,8 +42,8 @@ func (ec *Client) LastL1OriginByBatchID(ctx context.Context, batchID *big.Int) ( } // LastBlockIDByBatchID returns the ID of the last block for the given batch. -func (ec *Client) LastBlockIDByBatchID(ctx context.Context, batchID *big.Int) (*big.Int, error) { - var res *big.Int +func (ec *Client) LastBlockIDByBatchID(ctx context.Context, batchID *big.Int) (*hexutil.Big, error) { + var res *hexutil.Big if err := ec.c.CallContext(ctx, &res, "taiko_lastBlockIDByBatchID", hexutil.EncodeBig(batchID)); err != nil { return nil, err