diff --git a/arbitrum/apibackend.go b/arbitrum/apibackend.go index 3e90a3738c..2536b0b434 100644 --- a/arbitrum/apibackend.go +++ b/arbitrum/apibackend.go @@ -95,6 +95,7 @@ type SyncProgressBackend interface { SyncProgressMap() map[string]interface{} SafeBlockNumber(ctx context.Context) (uint64, error) FinalizedBlockNumber(ctx context.Context) (uint64, error) + BlockMetadataByNumber(blockNum uint64) (common.BlockMetadata, error) } func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fallbackClientUrl string, fallbackClientTimeout time.Duration) (*filters.FilterSystem, error) { @@ -451,6 +452,10 @@ func (a *APIBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc. return nil, errors.New("invalid arguments; neither block nor hash specified") } +func (a *APIBackend) BlockMetadataByNumber(blockNum uint64) (common.BlockMetadata, error) { + return a.sync.BlockMetadataByNumber(blockNum) +} + func StateAndHeaderFromHeader(ctx context.Context, chainDb ethdb.Database, bc *core.BlockChain, maxRecreateStateDepth int64, header *types.Header, err error) (*state.StateDB, *types.Header, error) { if err != nil { return nil, header, err diff --git a/common/types.go b/common/types.go index aadca87f82..8c3a137876 100644 --- a/common/types.go +++ b/common/types.go @@ -475,3 +475,14 @@ func (d *Decimal) UnmarshalJSON(input []byte) error { return err } } + +type BlockMetadata []byte + +// IsTxTimeboosted given a tx's index in the block returns whether the tx was timeboosted or not +func (b BlockMetadata) IsTxTimeboosted(txIndex int) bool { + maxTxCount := (len(b) - 1) * 8 + if txIndex >= maxTxCount { + return false + } + return b[1+(txIndex/8)]&(1<<(txIndex%8)) != 0 +} diff --git a/eth/api_backend.go b/eth/api_backend.go index b366527395..98b220de79 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -182,6 +182,10 @@ func (b *EthAPIBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash r return nil, errors.New("invalid arguments; neither block nor hash specified") } +func (b *EthAPIBackend) BlockMetadataByNumber(blockNum uint64) (common.BlockMetadata, error) { + return nil, nil +} + func (b *EthAPIBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts) { return b.eth.miner.PendingBlockAndReceipts() } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index f745c193d6..b9740d9d45 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1963,6 +1963,14 @@ func marshalReceipt(ctx context.Context, receipt *types.Receipt, blockHash commo fields["l1BlockNumber"] = hexutil.Uint64(arbTx.L1BlockNumber) } } + + blockMetadata, err := backend.BlockMetadataByNumber(blockNumber) + if err != nil { + return nil, err + } + if blockMetadata != nil { + fields["timeboosted"] = blockMetadata.IsTxTimeboosted(txIndex) + } } return fields, nil } diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index d84c846bfd..794efff48c 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -525,6 +525,9 @@ func (b testBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc. } panic("unknown type rpc.BlockNumberOrHash") } +func (b testBackend) BlockMetadataByNumber(blockNum uint64) (common.BlockMetadata, error) { + return nil, nil +} func (b testBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) { return b.chain.GetBlock(hash, uint64(number.Int64())).Body(), nil } diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index f911a01cd5..ab9837ea10 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -66,6 +66,7 @@ type Backend interface { BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error) + BlockMetadataByNumber(blockNum uint64) (common.BlockMetadata, error) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error) PendingBlockAndReceipts() (*types.Block, types.Receipts) diff --git a/internal/ethapi/transaction_args_test.go b/internal/ethapi/transaction_args_test.go index 667f7b3068..3178b92ae3 100644 --- a/internal/ethapi/transaction_args_test.go +++ b/internal/ethapi/transaction_args_test.go @@ -349,6 +349,9 @@ func (b *backendMock) BlockByHash(ctx context.Context, hash common.Hash) (*types func (b *backendMock) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error) { return nil, nil } +func (b *backendMock) BlockMetadataByNumber(blockNum uint64) (common.BlockMetadata, error) { + return nil, nil +} func (b *backendMock) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) { return nil, nil }