From b703ce0b0712ce532dc723868f12cbc9d2519c79 Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Tue, 25 Nov 2025 13:48:41 -0700 Subject: [PATCH 1/7] Implement SendExpressLaneTransactionSync --- arbitrum/apibackend.go | 17 +++++++++-------- arbitrum/backend.go | 11 +++++++---- arbitrum/receipt.go | 19 +++++++++++++++++++ common/types.go | 7 ++----- eth/backend.go | 2 +- eth/filters/api.go | 2 +- internal/ethapi/api.go | 8 ++++---- internal/ethapi/backend.go | 7 ++++--- 8 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 arbitrum/receipt.go diff --git a/arbitrum/apibackend.go b/arbitrum/apibackend.go index 50ad7802ad..59a6188ba0 100644 --- a/arbitrum/apibackend.go +++ b/arbitrum/apibackend.go @@ -132,16 +132,16 @@ type SyncProgressBackend interface { BlockMetadataByNumber(ctx context.Context, blockNum uint64) (common.BlockMetadata, error) } -func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fallbackClientUrl string, fallbackClientTimeout time.Duration, archiveRedirects []BlockRedirectConfig) (*filters.FilterSystem, error) { +func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fallbackClientUrl string, fallbackClientTimeout time.Duration, archiveRedirects []BlockRedirectConfig) (*filters.FilterSystem, ReceiptFetcher, error) { fallbackClient, err := CreateFallbackClient(fallbackClientUrl, fallbackClientTimeout, false) if err != nil { - return nil, err + return nil, nil, err } var archiveClientsManager *archiveFallbackClientsManager if len(archiveRedirects) != 0 { archiveClientsManager, err = newArchiveFallbackClientsManager(archiveRedirects) if err != nil { - return nil, err + return nil, nil, err } } backend.apiBackend = &APIBackend{ @@ -150,8 +150,9 @@ func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fal archiveClientsManager: archiveClientsManager, } filterSystem := filters.NewFilterSystem(backend.apiBackend, filterConfig) - backend.stack.RegisterAPIs(backend.apiBackend.GetAPIs(filterSystem)) - return filterSystem, nil + apis, receiptFetcher := backend.apiBackend.GetAPIs(filterSystem) + backend.stack.RegisterAPIs(apis) + return filterSystem, receiptFetcher, nil } func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error { @@ -162,8 +163,8 @@ func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error { return nil } -func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) []rpc.API { - apis := ethapi.GetAPIs(a) +func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) ([]rpc.API, ReceiptFetcher) { + apis, transactionAPI := ethapi.GetAPIs(a) apis = append(apis, rpc.API{ Namespace: "eth", @@ -195,7 +196,7 @@ func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) []rpc.API { apis = append(apis, tracers.APIs(a)...) - return apis + return apis, transactionAPI } func (a *APIBackend) BlockChain() *core.BlockChain { diff --git a/arbitrum/backend.go b/arbitrum/backend.go index 06df137739..1107d6ae74 100644 --- a/arbitrum/backend.go +++ b/arbitrum/backend.go @@ -17,7 +17,6 @@ import ( "github.com/ethereum/go-ethereum/internal/shutdowncheck" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/rpc" ) type Backend struct { @@ -30,7 +29,8 @@ type Backend struct { txFeed event.Feed scope event.SubscriptionScope - filterMaps *filtermaps.FilterMaps + filterMaps *filtermaps.FilterMaps + receiptFetcher ReceiptFetcher shutdownTracker *shutdowncheck.ShutdownTracker @@ -84,13 +84,15 @@ func NewBackend(stack *node.Node, config *Config, chainDb ethdb.Database, publis backend.stack.ApplyAPIFilter(rpcFilter) } - filterSystem, err := createRegisterAPIBackend(backend, filterConfig, config.ClassicRedirect, config.ClassicRedirectTimeout, config.BlockRedirects) + filterSystem, receiptFetcher, err := createRegisterAPIBackend(backend, filterConfig, config.ClassicRedirect, config.ClassicRedirectTimeout, config.BlockRedirects) if err != nil { return nil, nil, err } backend.filterSystem = filterSystem + backend.receiptFetcher = receiptFetcher return backend, filterSystem, nil } + func (b *Backend) newChainView(head *types.Header) *filtermaps.ChainView { if head == nil { return nil @@ -100,11 +102,12 @@ func (b *Backend) newChainView(head *types.Header) *filtermaps.ChainView { func (b *Backend) AccountManager() *accounts.Manager { return b.stack.AccountManager() } func (b *Backend) APIBackend() *APIBackend { return b.apiBackend } -func (b *Backend) APIs() []rpc.API { return b.apiBackend.GetAPIs(b.filterSystem) } func (b *Backend) ArbInterface() ArbInterface { return b.arb } func (b *Backend) BlockChain() *core.BlockChain { return b.arb.BlockChain() } func (b *Backend) ChainDb() ethdb.Database { return b.chainDb } +func (b *Backend) Config() *Config { return b.config } func (b *Backend) Engine() consensus.Engine { return b.arb.BlockChain().Engine() } +func (b *Backend) ReceiptFetcher() ReceiptFetcher { return b.receiptFetcher } func (b *Backend) Stack() *node.Node { return b.stack } func (b *Backend) ResetWithGenesisBlock(gb *types.Block) { diff --git a/arbitrum/receipt.go b/arbitrum/receipt.go new file mode 100644 index 0000000000..4ad47ca6c3 --- /dev/null +++ b/arbitrum/receipt.go @@ -0,0 +1,19 @@ +package arbitrum + +import ( + "context" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/internal/ethapi" + "github.com/ethereum/go-ethereum/params" +) + +type ReceiptFetcher interface { + GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) +} + +// Exposing the internal function, this should make maintaining the upstream code easier +func MarshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex uint64, chainConfig *params.ChainConfig, header *types.Header, blockMetadata common.BlockMetadata) map[string]interface{} { + return ethapi.MarshalReceipt(receipt, blockHash, blockNumber, signer, tx, txIndex, chainConfig, header, blockMetadata) +} diff --git a/common/types.go b/common/types.go index b6185dc59b..7c6a027a72 100644 --- a/common/types.go +++ b/common/types.go @@ -495,14 +495,11 @@ type BlockMetadata []byte // starting from the second byte, (N)th bit would represent if (N)th tx is timeboosted or not, 1 means yes and 0 means no // blockMetadata[index / 8 + 1] & (1 << (index % 8)) != 0; where index = (N - 1), implies whether (N)th tx in a block is timeboosted // note that number of txs in a block will always lag behind (len(blockMetadata) - 1) * 8 but it wont lag more than a value of 7 -func (b BlockMetadata) IsTxTimeboosted(txIndex int) (bool, error) { +func (b BlockMetadata) IsTxTimeboosted(txIndex uint64) (bool, error) { if len(b) == 0 { return false, errors.New("blockMetadata is not set") } - if txIndex < 0 { - return false, fmt.Errorf("invalid transaction index- %d, should be positive", txIndex) - } - maxTxCount := (len(b) - 1) * 8 + maxTxCount := (uint64(len(b)) - 1) * 8 if txIndex >= maxTxCount { return false, nil } diff --git a/eth/backend.go b/eth/backend.go index 6fded60a78..a95884b68a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -394,7 +394,7 @@ func makeExtraData(extra []byte) []byte { // APIs return the collection of RPC services the ethereum package offers. // NOTE, some of these services probably need to be moved to somewhere else. func (s *Ethereum) APIs() []rpc.API { - apis := ethapi.GetAPIs(s.APIBackend) + apis, _ := ethapi.GetAPIs(s.APIBackend) // Append all the local APIs and return return append(apis, []rpc.API{ diff --git a/eth/filters/api.go b/eth/filters/api.go index 9b418bd151..0c0a0e23fb 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -370,7 +370,7 @@ func (api *FilterAPI) TransactionReceipts(ctx context.Context, filter *Transacti receiptWithTx.Receipt.BlockNumber.Uint64(), signer, receiptWithTx.Transaction, - int(receiptWithTx.Receipt.TransactionIndex), + uint64(receiptWithTx.Receipt.TransactionIndex), api.events.backend.ChainConfig(), header, blockMetadata, diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 632e2e579b..82c5aa8fa9 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -657,7 +657,7 @@ func (api *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rp if err != nil { return nil, err } - result[i] = MarshalReceipt(receipt, block.Hash(), block.NumberU64(), signer, txs[i], i, api.b.ChainConfig(), header, blockMetadata) + result[i] = MarshalReceipt(receipt, block.Hash(), block.NumberU64(), signer, txs[i], uint64(i), api.b.ChainConfig(), header, blockMetadata) } return result, nil } @@ -1758,11 +1758,11 @@ func (api *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash commo if err != nil { return nil, err } - return MarshalReceipt(receipt, blockHash, blockNumber, signer, tx, int(index), api.b.ChainConfig(), header, blockMetadata), nil + return MarshalReceipt(receipt, blockHash, blockNumber, signer, tx, index, api.b.ChainConfig(), header, blockMetadata), nil } // MarshalReceipt marshals a transaction receipt into a JSON object. -func MarshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex int, chainConfig *params.ChainConfig, header *types.Header, blockMetadata common.BlockMetadata) map[string]interface{} { +func MarshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex uint64, chainConfig *params.ChainConfig, header *types.Header, blockMetadata common.BlockMetadata) map[string]interface{} { from, _ := types.Sender(signer, tx) fields := map[string]interface{}{ @@ -2062,7 +2062,7 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex rs[i].BlockNumber.Uint64(), signer, txs[i], - int(rs[i].TransactionIndex), + uint64(rs[i].TransactionIndex), api.b.ChainConfig(), header, blockMetadata, diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 62f6dacb3e..2c4e463db2 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -108,8 +108,9 @@ type Backend interface { NewMatcherBackend() filtermaps.MatcherBackend } -func GetAPIs(apiBackend Backend) []rpc.API { +func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { nonceLock := new(AddrLocker) + transactionAPI := NewTransactionAPI(apiBackend, nonceLock) return []rpc.API{ { Namespace: "eth", @@ -119,7 +120,7 @@ func GetAPIs(apiBackend Backend) []rpc.API { Service: NewBlockChainAPI(apiBackend), }, { Namespace: "eth", - Service: NewTransactionAPI(apiBackend, nonceLock), + Service: transactionAPI, }, { Namespace: "txpool", Service: NewTxPoolAPI(apiBackend), @@ -130,5 +131,5 @@ func GetAPIs(apiBackend Backend) []rpc.API { Namespace: "eth", Service: NewEthereumAccountAPI(apiBackend.AccountManager()), }, - } + }, transactionAPI } From 6f67293e917da6b15102ae3a4deb771d0475774a Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Wed, 26 Nov 2025 10:27:33 -0700 Subject: [PATCH 2/7] Remove func MarshalReceipt --- arbitrum/receipt.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/arbitrum/receipt.go b/arbitrum/receipt.go index 4ad47ca6c3..80f3c9c2a8 100644 --- a/arbitrum/receipt.go +++ b/arbitrum/receipt.go @@ -4,16 +4,8 @@ import ( "context" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/internal/ethapi" - "github.com/ethereum/go-ethereum/params" ) type ReceiptFetcher interface { GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) } - -// Exposing the internal function, this should make maintaining the upstream code easier -func MarshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex uint64, chainConfig *params.ChainConfig, header *types.Header, blockMetadata common.BlockMetadata) map[string]interface{} { - return ethapi.MarshalReceipt(receipt, blockHash, blockNumber, signer, tx, txIndex, chainConfig, header, blockMetadata) -} From b1982d586f893478416f949d1f12cef248086b49 Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:18:53 -0700 Subject: [PATCH 3/7] Attempt to resolve @pmikolajczyk41 and @ganeshvanahalli concerns --- arbitrum/apibackend.go | 15 ++++++++++----- eth/backend.go | 5 ++++- internal/ethapi/backend.go | 12 ++++++------ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/arbitrum/apibackend.go b/arbitrum/apibackend.go index 59a6188ba0..b5c78bc9a5 100644 --- a/arbitrum/apibackend.go +++ b/arbitrum/apibackend.go @@ -150,9 +150,14 @@ func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fal archiveClientsManager: archiveClientsManager, } filterSystem := filters.NewFilterSystem(backend.apiBackend, filterConfig) - apis, receiptFetcher := backend.apiBackend.GetAPIs(filterSystem) + apis := backend.apiBackend.GetAPIs(filterSystem) + transactionAPI := ethapi.GetTransactionAPI(backend.apiBackend) + apis = append(apis, rpc.API{ + Namespace: "eth", + Service: transactionAPI, + }) backend.stack.RegisterAPIs(apis) - return filterSystem, receiptFetcher, nil + return filterSystem, transactionAPI, nil } func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error { @@ -163,8 +168,8 @@ func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error { return nil } -func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) ([]rpc.API, ReceiptFetcher) { - apis, transactionAPI := ethapi.GetAPIs(a) +func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) []rpc.API { + apis := ethapi.GetAPIs(a) apis = append(apis, rpc.API{ Namespace: "eth", @@ -196,7 +201,7 @@ func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) ([]rpc.API, Rec apis = append(apis, tracers.APIs(a)...) - return apis, transactionAPI + return apis } func (a *APIBackend) BlockChain() *core.BlockChain { diff --git a/eth/backend.go b/eth/backend.go index a95884b68a..654be6ebc9 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -394,7 +394,7 @@ func makeExtraData(extra []byte) []byte { // APIs return the collection of RPC services the ethereum package offers. // NOTE, some of these services probably need to be moved to somewhere else. func (s *Ethereum) APIs() []rpc.API { - apis, _ := ethapi.GetAPIs(s.APIBackend) + apis := ethapi.GetAPIs(s.APIBackend) // Append all the local APIs and return return append(apis, []rpc.API{ @@ -404,6 +404,9 @@ func (s *Ethereum) APIs() []rpc.API { }, { Namespace: "eth", Service: downloader.NewDownloaderAPI(s.handler.downloader, s.blockchain, s.eventMux), + }, { + Namespace: "eth", + Service: ethapi.GetTransactionAPI(s.APIBackend), }, { Namespace: "admin", Service: NewAdminAPI(s), diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 2c4e463db2..6003d4fd08 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -108,9 +108,12 @@ type Backend interface { NewMatcherBackend() filtermaps.MatcherBackend } -func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { +func GetTransactionAPI(apiBackend Backend) *TransactionAPI { nonceLock := new(AddrLocker) - transactionAPI := NewTransactionAPI(apiBackend, nonceLock) + return NewTransactionAPI(apiBackend, nonceLock) +} + +func GetAPIs(apiBackend Backend) []rpc.API { return []rpc.API{ { Namespace: "eth", @@ -118,9 +121,6 @@ func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { }, { Namespace: "eth", Service: NewBlockChainAPI(apiBackend), - }, { - Namespace: "eth", - Service: transactionAPI, }, { Namespace: "txpool", Service: NewTxPoolAPI(apiBackend), @@ -131,5 +131,5 @@ func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { Namespace: "eth", Service: NewEthereumAccountAPI(apiBackend.AccountManager()), }, - }, transactionAPI + } } From f857ede8c3335cfd2db6577bbfdb248779ebb104 Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Thu, 27 Nov 2025 07:38:34 -0700 Subject: [PATCH 4/7] Revert "Attempt to resolve @pmikolajczyk41 and @ganeshvanahalli concerns" This reverts commit 94cbe8d3944258c834c375d39942e0f307bdf771. --- arbitrum/apibackend.go | 15 +++++---------- eth/backend.go | 5 +---- internal/ethapi/backend.go | 12 ++++++------ 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/arbitrum/apibackend.go b/arbitrum/apibackend.go index b5c78bc9a5..59a6188ba0 100644 --- a/arbitrum/apibackend.go +++ b/arbitrum/apibackend.go @@ -150,14 +150,9 @@ func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fal archiveClientsManager: archiveClientsManager, } filterSystem := filters.NewFilterSystem(backend.apiBackend, filterConfig) - apis := backend.apiBackend.GetAPIs(filterSystem) - transactionAPI := ethapi.GetTransactionAPI(backend.apiBackend) - apis = append(apis, rpc.API{ - Namespace: "eth", - Service: transactionAPI, - }) + apis, receiptFetcher := backend.apiBackend.GetAPIs(filterSystem) backend.stack.RegisterAPIs(apis) - return filterSystem, transactionAPI, nil + return filterSystem, receiptFetcher, nil } func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error { @@ -168,8 +163,8 @@ func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error { return nil } -func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) []rpc.API { - apis := ethapi.GetAPIs(a) +func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) ([]rpc.API, ReceiptFetcher) { + apis, transactionAPI := ethapi.GetAPIs(a) apis = append(apis, rpc.API{ Namespace: "eth", @@ -201,7 +196,7 @@ func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) []rpc.API { apis = append(apis, tracers.APIs(a)...) - return apis + return apis, transactionAPI } func (a *APIBackend) BlockChain() *core.BlockChain { diff --git a/eth/backend.go b/eth/backend.go index 654be6ebc9..a95884b68a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -394,7 +394,7 @@ func makeExtraData(extra []byte) []byte { // APIs return the collection of RPC services the ethereum package offers. // NOTE, some of these services probably need to be moved to somewhere else. func (s *Ethereum) APIs() []rpc.API { - apis := ethapi.GetAPIs(s.APIBackend) + apis, _ := ethapi.GetAPIs(s.APIBackend) // Append all the local APIs and return return append(apis, []rpc.API{ @@ -404,9 +404,6 @@ func (s *Ethereum) APIs() []rpc.API { }, { Namespace: "eth", Service: downloader.NewDownloaderAPI(s.handler.downloader, s.blockchain, s.eventMux), - }, { - Namespace: "eth", - Service: ethapi.GetTransactionAPI(s.APIBackend), }, { Namespace: "admin", Service: NewAdminAPI(s), diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 6003d4fd08..2c4e463db2 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -108,12 +108,9 @@ type Backend interface { NewMatcherBackend() filtermaps.MatcherBackend } -func GetTransactionAPI(apiBackend Backend) *TransactionAPI { +func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { nonceLock := new(AddrLocker) - return NewTransactionAPI(apiBackend, nonceLock) -} - -func GetAPIs(apiBackend Backend) []rpc.API { + transactionAPI := NewTransactionAPI(apiBackend, nonceLock) return []rpc.API{ { Namespace: "eth", @@ -121,6 +118,9 @@ func GetAPIs(apiBackend Backend) []rpc.API { }, { Namespace: "eth", Service: NewBlockChainAPI(apiBackend), + }, { + Namespace: "eth", + Service: transactionAPI, }, { Namespace: "txpool", Service: NewTxPoolAPI(apiBackend), @@ -131,5 +131,5 @@ func GetAPIs(apiBackend Backend) []rpc.API { Namespace: "eth", Service: NewEthereumAccountAPI(apiBackend.AccountManager()), }, - } + }, transactionAPI } From 861b83f010d728aef952941f5bac93cdd56483db Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Thu, 27 Nov 2025 09:46:34 -0700 Subject: [PATCH 5/7] New attempt --- arbitrum/apibackend.go | 73 +++++++++++++++++++------------------- arbitrum/apis.go | 28 +++++++++++++++ eth/backend.go | 2 +- internal/ethapi/backend.go | 46 ++++++++++++++++++------ 4 files changed, 101 insertions(+), 48 deletions(-) create mode 100644 arbitrum/apis.go diff --git a/arbitrum/apibackend.go b/arbitrum/apibackend.go index 59a6188ba0..3878511da5 100644 --- a/arbitrum/apibackend.go +++ b/arbitrum/apibackend.go @@ -150,8 +150,14 @@ func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fal archiveClientsManager: archiveClientsManager, } filterSystem := filters.NewFilterSystem(backend.apiBackend, filterConfig) - apis, receiptFetcher := backend.apiBackend.GetAPIs(filterSystem) - backend.stack.RegisterAPIs(apis) + apis := backend.apiBackend.GetAPIs(filterSystem) + backend.stack.RegisterAPIs(apis.Slice()) + + service := apis.EthAPIs.TransactionAPI.Service + receiptFetcher, ok := service.(ReceiptFetcher) + if !ok { + return nil, nil, fmt.Errorf("TransactionAPI.Service does not implement ReceiptFetcher") + } return filterSystem, receiptFetcher, nil } @@ -163,40 +169,35 @@ func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error { return nil } -func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) ([]rpc.API, ReceiptFetcher) { - apis, transactionAPI := ethapi.GetAPIs(a) - - apis = append(apis, rpc.API{ - Namespace: "eth", - Version: "1.0", - Service: filters.NewFilterAPI(filterSystem), - Public: true, - }) - - apis = append(apis, rpc.API{ - Namespace: "eth", - Version: "1.0", - Service: NewArbTransactionAPI(a), - Public: true, - }) - - apis = append(apis, rpc.API{ - Namespace: "net", - Version: "1.0", - Service: NewPublicNetAPI(a.ChainConfig().ChainID.Uint64()), - Public: true, - }) - - apis = append(apis, rpc.API{ - Namespace: "txpool", - Version: "1.0", - Service: NewPublicTxPoolAPI(), - Public: true, - }) - - apis = append(apis, tracers.APIs(a)...) - - return apis, transactionAPI +func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) APIs { + return APIs{ + EthAPIs: ethapi.GetAPIs(a), + FilterAPI: rpc.API{ + Namespace: "eth", + Version: "1.0", + Service: filters.NewFilterAPI(filterSystem), + Public: true, + }, + ArbTransactionAPI: rpc.API{ + Namespace: "eth", + Version: "1.0", + Service: NewArbTransactionAPI(a), + Public: true, + }, + PublicNetAPI: rpc.API{ + Namespace: "net", + Version: "1.0", + Service: NewPublicNetAPI(a.ChainConfig().ChainID.Uint64()), + Public: true, + }, + PublicTxPoolAPI: rpc.API{ + Namespace: "txpool", + Version: "1.0", + Service: NewPublicTxPoolAPI(), + Public: true, + }, + TracersAPIs: tracers.APIs(a), + } } func (a *APIBackend) BlockChain() *core.BlockChain { diff --git a/arbitrum/apis.go b/arbitrum/apis.go new file mode 100644 index 0000000000..0408e9fb3e --- /dev/null +++ b/arbitrum/apis.go @@ -0,0 +1,28 @@ +package arbitrum + +import ( + "github.com/ethereum/go-ethereum/internal/ethapi" + "github.com/ethereum/go-ethereum/rpc" +) + +type APIs struct { + EthAPIs ethapi.APIs + FilterAPI rpc.API + ArbTransactionAPI rpc.API + PublicNetAPI rpc.API + PublicTxPoolAPI rpc.API + TracersAPIs []rpc.API +} + +func (a APIs) Slice() []rpc.API { + var apis []rpc.API + + apis = append(apis, a.EthAPIs.Slice()...) + apis = append(apis, a.FilterAPI) + apis = append(apis, a.ArbTransactionAPI) + apis = append(apis, a.PublicNetAPI) + apis = append(apis, a.PublicTxPoolAPI) + apis = append(apis, a.TracersAPIs...) + + return apis +} diff --git a/eth/backend.go b/eth/backend.go index a95884b68a..d30a6a8165 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -394,7 +394,7 @@ func makeExtraData(extra []byte) []byte { // APIs return the collection of RPC services the ethereum package offers. // NOTE, some of these services probably need to be moved to somewhere else. func (s *Ethereum) APIs() []rpc.API { - apis, _ := ethapi.GetAPIs(s.APIBackend) + apis := ethapi.GetAPIs(s.APIBackend).Slice() // Append all the local APIs and return return append(apis, []rpc.API{ diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 2c4e463db2..394cf0a855 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -108,28 +108,52 @@ type Backend interface { NewMatcherBackend() filtermaps.MatcherBackend } -func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { +func GetAPIs(apiBackend Backend) APIs { nonceLock := new(AddrLocker) - transactionAPI := NewTransactionAPI(apiBackend, nonceLock) - return []rpc.API{ - { + return APIs{ + EthereumAPI: rpc.API{ Namespace: "eth", Service: NewEthereumAPI(apiBackend), - }, { + }, + BlockChainAPI: rpc.API{ Namespace: "eth", Service: NewBlockChainAPI(apiBackend), - }, { + }, + TransactionAPI: rpc.API{ Namespace: "eth", - Service: transactionAPI, - }, { + Service: NewTransactionAPI(apiBackend, nonceLock), + }, + TxPoolAPI: rpc.API{ Namespace: "txpool", Service: NewTxPoolAPI(apiBackend), - }, { + }, + DebugAPI: rpc.API{ Namespace: "debug", Service: NewDebugAPI(apiBackend), - }, { + }, + EthereumAccountAPI: rpc.API{ Namespace: "eth", Service: NewEthereumAccountAPI(apiBackend.AccountManager()), }, - }, transactionAPI + } +} + +type APIs struct { + EthereumAPI rpc.API + BlockChainAPI rpc.API + TransactionAPI rpc.API + TxPoolAPI rpc.API + DebugAPI rpc.API + EthereumAccountAPI rpc.API +} + +func (a APIs) Slice() []rpc.API { + return []rpc.API{ + a.EthereumAPI, + a.BlockChainAPI, + a.TransactionAPI, + a.TxPoolAPI, + a.DebugAPI, + a.EthereumAccountAPI, + } } From e86bf10d6a4422851df5efc6d75a10f32ce2276a Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Mon, 1 Dec 2025 11:14:17 -0700 Subject: [PATCH 6/7] Revert "New attempt" This reverts commit d85332795e490d4d63d40db6595b8ea876d78847. --- arbitrum/apibackend.go | 73 +++++++++++++++++++------------------- arbitrum/apis.go | 28 --------------- eth/backend.go | 2 +- internal/ethapi/backend.go | 46 ++++++------------------ 4 files changed, 48 insertions(+), 101 deletions(-) delete mode 100644 arbitrum/apis.go diff --git a/arbitrum/apibackend.go b/arbitrum/apibackend.go index 3878511da5..59a6188ba0 100644 --- a/arbitrum/apibackend.go +++ b/arbitrum/apibackend.go @@ -150,14 +150,8 @@ func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fal archiveClientsManager: archiveClientsManager, } filterSystem := filters.NewFilterSystem(backend.apiBackend, filterConfig) - apis := backend.apiBackend.GetAPIs(filterSystem) - backend.stack.RegisterAPIs(apis.Slice()) - - service := apis.EthAPIs.TransactionAPI.Service - receiptFetcher, ok := service.(ReceiptFetcher) - if !ok { - return nil, nil, fmt.Errorf("TransactionAPI.Service does not implement ReceiptFetcher") - } + apis, receiptFetcher := backend.apiBackend.GetAPIs(filterSystem) + backend.stack.RegisterAPIs(apis) return filterSystem, receiptFetcher, nil } @@ -169,35 +163,40 @@ func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error { return nil } -func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) APIs { - return APIs{ - EthAPIs: ethapi.GetAPIs(a), - FilterAPI: rpc.API{ - Namespace: "eth", - Version: "1.0", - Service: filters.NewFilterAPI(filterSystem), - Public: true, - }, - ArbTransactionAPI: rpc.API{ - Namespace: "eth", - Version: "1.0", - Service: NewArbTransactionAPI(a), - Public: true, - }, - PublicNetAPI: rpc.API{ - Namespace: "net", - Version: "1.0", - Service: NewPublicNetAPI(a.ChainConfig().ChainID.Uint64()), - Public: true, - }, - PublicTxPoolAPI: rpc.API{ - Namespace: "txpool", - Version: "1.0", - Service: NewPublicTxPoolAPI(), - Public: true, - }, - TracersAPIs: tracers.APIs(a), - } +func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) ([]rpc.API, ReceiptFetcher) { + apis, transactionAPI := ethapi.GetAPIs(a) + + apis = append(apis, rpc.API{ + Namespace: "eth", + Version: "1.0", + Service: filters.NewFilterAPI(filterSystem), + Public: true, + }) + + apis = append(apis, rpc.API{ + Namespace: "eth", + Version: "1.0", + Service: NewArbTransactionAPI(a), + Public: true, + }) + + apis = append(apis, rpc.API{ + Namespace: "net", + Version: "1.0", + Service: NewPublicNetAPI(a.ChainConfig().ChainID.Uint64()), + Public: true, + }) + + apis = append(apis, rpc.API{ + Namespace: "txpool", + Version: "1.0", + Service: NewPublicTxPoolAPI(), + Public: true, + }) + + apis = append(apis, tracers.APIs(a)...) + + return apis, transactionAPI } func (a *APIBackend) BlockChain() *core.BlockChain { diff --git a/arbitrum/apis.go b/arbitrum/apis.go deleted file mode 100644 index 0408e9fb3e..0000000000 --- a/arbitrum/apis.go +++ /dev/null @@ -1,28 +0,0 @@ -package arbitrum - -import ( - "github.com/ethereum/go-ethereum/internal/ethapi" - "github.com/ethereum/go-ethereum/rpc" -) - -type APIs struct { - EthAPIs ethapi.APIs - FilterAPI rpc.API - ArbTransactionAPI rpc.API - PublicNetAPI rpc.API - PublicTxPoolAPI rpc.API - TracersAPIs []rpc.API -} - -func (a APIs) Slice() []rpc.API { - var apis []rpc.API - - apis = append(apis, a.EthAPIs.Slice()...) - apis = append(apis, a.FilterAPI) - apis = append(apis, a.ArbTransactionAPI) - apis = append(apis, a.PublicNetAPI) - apis = append(apis, a.PublicTxPoolAPI) - apis = append(apis, a.TracersAPIs...) - - return apis -} diff --git a/eth/backend.go b/eth/backend.go index d30a6a8165..a95884b68a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -394,7 +394,7 @@ func makeExtraData(extra []byte) []byte { // APIs return the collection of RPC services the ethereum package offers. // NOTE, some of these services probably need to be moved to somewhere else. func (s *Ethereum) APIs() []rpc.API { - apis := ethapi.GetAPIs(s.APIBackend).Slice() + apis, _ := ethapi.GetAPIs(s.APIBackend) // Append all the local APIs and return return append(apis, []rpc.API{ diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 394cf0a855..2c4e463db2 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -108,52 +108,28 @@ type Backend interface { NewMatcherBackend() filtermaps.MatcherBackend } -func GetAPIs(apiBackend Backend) APIs { +func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { nonceLock := new(AddrLocker) - return APIs{ - EthereumAPI: rpc.API{ + transactionAPI := NewTransactionAPI(apiBackend, nonceLock) + return []rpc.API{ + { Namespace: "eth", Service: NewEthereumAPI(apiBackend), - }, - BlockChainAPI: rpc.API{ + }, { Namespace: "eth", Service: NewBlockChainAPI(apiBackend), - }, - TransactionAPI: rpc.API{ + }, { Namespace: "eth", - Service: NewTransactionAPI(apiBackend, nonceLock), - }, - TxPoolAPI: rpc.API{ + Service: transactionAPI, + }, { Namespace: "txpool", Service: NewTxPoolAPI(apiBackend), - }, - DebugAPI: rpc.API{ + }, { Namespace: "debug", Service: NewDebugAPI(apiBackend), - }, - EthereumAccountAPI: rpc.API{ + }, { Namespace: "eth", Service: NewEthereumAccountAPI(apiBackend.AccountManager()), }, - } -} - -type APIs struct { - EthereumAPI rpc.API - BlockChainAPI rpc.API - TransactionAPI rpc.API - TxPoolAPI rpc.API - DebugAPI rpc.API - EthereumAccountAPI rpc.API -} - -func (a APIs) Slice() []rpc.API { - return []rpc.API{ - a.EthereumAPI, - a.BlockChainAPI, - a.TransactionAPI, - a.TxPoolAPI, - a.DebugAPI, - a.EthereumAccountAPI, - } + }, transactionAPI } From 28c1fbd1d2319b4885dea51e0857a5b6ca5cf238 Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Mon, 1 Dec 2025 12:00:49 -0700 Subject: [PATCH 7/7] Try to resolve concerns --- arbitrum/apibackend.go | 19 +++++++++++++++---- common/types.go | 7 +++++-- eth/backend.go | 2 +- eth/filters/api.go | 2 +- internal/ethapi/api.go | 8 ++++---- internal/ethapi/backend.go | 7 +++---- 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/arbitrum/apibackend.go b/arbitrum/apibackend.go index 59a6188ba0..6c1c765b29 100644 --- a/arbitrum/apibackend.go +++ b/arbitrum/apibackend.go @@ -150,7 +150,18 @@ func createRegisterAPIBackend(backend *Backend, filterConfig filters.Config, fal archiveClientsManager: archiveClientsManager, } filterSystem := filters.NewFilterSystem(backend.apiBackend, filterConfig) - apis, receiptFetcher := backend.apiBackend.GetAPIs(filterSystem) + apis := backend.apiBackend.GetAPIs(filterSystem) + var receiptFetcher ReceiptFetcher + for _, api := range apis { + var ok bool + receiptFetcher, ok = api.Service.(ReceiptFetcher) + if ok { + break + } + } + if receiptFetcher == nil { + return nil, nil, errors.New("no receipt fetcher found in APIs") + } backend.stack.RegisterAPIs(apis) return filterSystem, receiptFetcher, nil } @@ -163,8 +174,8 @@ func (a *APIBackend) SetSyncBackend(sync SyncProgressBackend) error { return nil } -func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) ([]rpc.API, ReceiptFetcher) { - apis, transactionAPI := ethapi.GetAPIs(a) +func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) []rpc.API { + apis := ethapi.GetAPIs(a) apis = append(apis, rpc.API{ Namespace: "eth", @@ -196,7 +207,7 @@ func (a *APIBackend) GetAPIs(filterSystem *filters.FilterSystem) ([]rpc.API, Rec apis = append(apis, tracers.APIs(a)...) - return apis, transactionAPI + return apis } func (a *APIBackend) BlockChain() *core.BlockChain { diff --git a/common/types.go b/common/types.go index 7c6a027a72..b6185dc59b 100644 --- a/common/types.go +++ b/common/types.go @@ -495,11 +495,14 @@ type BlockMetadata []byte // starting from the second byte, (N)th bit would represent if (N)th tx is timeboosted or not, 1 means yes and 0 means no // blockMetadata[index / 8 + 1] & (1 << (index % 8)) != 0; where index = (N - 1), implies whether (N)th tx in a block is timeboosted // note that number of txs in a block will always lag behind (len(blockMetadata) - 1) * 8 but it wont lag more than a value of 7 -func (b BlockMetadata) IsTxTimeboosted(txIndex uint64) (bool, error) { +func (b BlockMetadata) IsTxTimeboosted(txIndex int) (bool, error) { if len(b) == 0 { return false, errors.New("blockMetadata is not set") } - maxTxCount := (uint64(len(b)) - 1) * 8 + if txIndex < 0 { + return false, fmt.Errorf("invalid transaction index- %d, should be positive", txIndex) + } + maxTxCount := (len(b) - 1) * 8 if txIndex >= maxTxCount { return false, nil } diff --git a/eth/backend.go b/eth/backend.go index a95884b68a..6fded60a78 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -394,7 +394,7 @@ func makeExtraData(extra []byte) []byte { // APIs return the collection of RPC services the ethereum package offers. // NOTE, some of these services probably need to be moved to somewhere else. func (s *Ethereum) APIs() []rpc.API { - apis, _ := ethapi.GetAPIs(s.APIBackend) + apis := ethapi.GetAPIs(s.APIBackend) // Append all the local APIs and return return append(apis, []rpc.API{ diff --git a/eth/filters/api.go b/eth/filters/api.go index 0c0a0e23fb..9b418bd151 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -370,7 +370,7 @@ func (api *FilterAPI) TransactionReceipts(ctx context.Context, filter *Transacti receiptWithTx.Receipt.BlockNumber.Uint64(), signer, receiptWithTx.Transaction, - uint64(receiptWithTx.Receipt.TransactionIndex), + int(receiptWithTx.Receipt.TransactionIndex), api.events.backend.ChainConfig(), header, blockMetadata, diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 82c5aa8fa9..632e2e579b 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -657,7 +657,7 @@ func (api *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rp if err != nil { return nil, err } - result[i] = MarshalReceipt(receipt, block.Hash(), block.NumberU64(), signer, txs[i], uint64(i), api.b.ChainConfig(), header, blockMetadata) + result[i] = MarshalReceipt(receipt, block.Hash(), block.NumberU64(), signer, txs[i], i, api.b.ChainConfig(), header, blockMetadata) } return result, nil } @@ -1758,11 +1758,11 @@ func (api *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash commo if err != nil { return nil, err } - return MarshalReceipt(receipt, blockHash, blockNumber, signer, tx, index, api.b.ChainConfig(), header, blockMetadata), nil + return MarshalReceipt(receipt, blockHash, blockNumber, signer, tx, int(index), api.b.ChainConfig(), header, blockMetadata), nil } // MarshalReceipt marshals a transaction receipt into a JSON object. -func MarshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex uint64, chainConfig *params.ChainConfig, header *types.Header, blockMetadata common.BlockMetadata) map[string]interface{} { +func MarshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex int, chainConfig *params.ChainConfig, header *types.Header, blockMetadata common.BlockMetadata) map[string]interface{} { from, _ := types.Sender(signer, tx) fields := map[string]interface{}{ @@ -2062,7 +2062,7 @@ func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hex rs[i].BlockNumber.Uint64(), signer, txs[i], - uint64(rs[i].TransactionIndex), + int(rs[i].TransactionIndex), api.b.ChainConfig(), header, blockMetadata, diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 2c4e463db2..62f6dacb3e 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -108,9 +108,8 @@ type Backend interface { NewMatcherBackend() filtermaps.MatcherBackend } -func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { +func GetAPIs(apiBackend Backend) []rpc.API { nonceLock := new(AddrLocker) - transactionAPI := NewTransactionAPI(apiBackend, nonceLock) return []rpc.API{ { Namespace: "eth", @@ -120,7 +119,7 @@ func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { Service: NewBlockChainAPI(apiBackend), }, { Namespace: "eth", - Service: transactionAPI, + Service: NewTransactionAPI(apiBackend, nonceLock), }, { Namespace: "txpool", Service: NewTxPoolAPI(apiBackend), @@ -131,5 +130,5 @@ func GetAPIs(apiBackend Backend) ([]rpc.API, *TransactionAPI) { Namespace: "eth", Service: NewEthereumAccountAPI(apiBackend.AccountManager()), }, - }, transactionAPI + } }