Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/rawdb/taiko_l1_origin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
}
6 changes: 3 additions & 3 deletions eth/taiko_api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 &&
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions ethclient/taiko_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down