diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index a469a8c0e0..9cb7131d31 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -29,6 +29,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/tyler-smith/go-bip39" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/accounts/scwallet" @@ -704,7 +705,10 @@ func (api *BlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, blo var txHash common.Hash - borReceipt := rawdb.ReadBorReceipt(api.b.ChainDb(), block.Hash(), block.NumberU64(), api.b.ChainConfig()) + borReceipt, err := api.b.GetBorBlockReceipt(ctx, block.Hash()) + if err != nil && err != ethereum.NotFound { + return nil, err + } if borReceipt != nil { receipts = append(receipts, borReceipt) @@ -1115,7 +1119,10 @@ func (api *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rp result[i] = marshalReceipt(receipt, block.Hash(), block.NumberU64(), signer, txs[i], i, false) } - stateSyncReceipt := rawdb.ReadBorReceipt(api.b.ChainDb(), block.Hash(), block.NumberU64(), api.b.ChainConfig()) + stateSyncReceipt, err := api.b.GetBorBlockReceipt(ctx, block.Hash()) + if err != nil && err != ethereum.NotFound { + return nil, err + } if stateSyncReceipt != nil { tx, _, _, _ := rawdb.ReadBorTransaction(api.b.ChainDb(), stateSyncReceipt.TxHash) result = append(result, marshalReceipt(stateSyncReceipt, block.Hash(), block.NumberU64(), signer, tx, len(result), true)) @@ -1901,7 +1908,7 @@ func (api *TransactionAPI) getAllBlockTransactions(ctx context.Context, block *t stateSyncPresent := false - borReceipt := rawdb.ReadBorReceipt(api.b.ChainDb(), block.Hash(), block.NumberU64(), api.b.ChainConfig()) + borReceipt, _ := api.b.GetBorBlockReceipt(ctx, block.Hash()) if borReceipt != nil { txHash := types.GetDerivedBorTxHash(types.BorReceiptKey(block.Number().Uint64(), block.Hash())) if txHash != (common.Hash{}) { @@ -2074,7 +2081,10 @@ func (api *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash commo } if !found { - tx, blockHash, blockNumber, index = rawdb.ReadBorTransaction(api.b.ChainDb(), hash) + tx, blockHash, blockNumber, index, err = api.b.GetBorBlockTransaction(ctx, hash) + if err != nil { + return nil, err + } borTx = true } @@ -2086,7 +2096,10 @@ func (api *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash commo if borTx { // Fetch bor block receipt - receipt = rawdb.ReadBorReceipt(api.b.ChainDb(), blockHash, blockNumber, api.b.ChainConfig()) + receipt, err = api.b.GetBorBlockReceipt(ctx, blockHash) + if err != nil && err != ethereum.NotFound { + return nil, err + } } else { receipts, err := api.b.GetReceipts(ctx, blockHash) if err != nil { diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index a6d620b330..7d1d8519f0 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -587,10 +587,16 @@ func (b testBackend) SendTx(ctx context.Context, signedTx *types.Transaction) er } func (b testBackend) GetTransaction(ctx context.Context, txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64, error) { tx, blockHash, blockNumber, index := rawdb.ReadTransaction(b.db, txHash) - return true, tx, blockHash, blockNumber, index, nil + found := true + if tx == nil { + found = false + } + return found, tx, blockHash, blockNumber, index, nil +} +func (b testBackend) GetPoolTransactions() (types.Transactions, error) { panic("implement me") } +func (b testBackend) GetPoolTransaction(txHash common.Hash) *types.Transaction { + return nil } -func (b testBackend) GetPoolTransactions() (types.Transactions, error) { panic("implement me") } -func (b testBackend) GetPoolTransaction(txHash common.Hash) *types.Transaction { panic("implement me") } func (b testBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) { return 0, nil } @@ -625,7 +631,8 @@ func (b testBackend) ServiceFilter(ctx context.Context, session *bloombits.Match // GetBorBlockTransaction returns bor block tx func (b testBackend) GetBorBlockTransaction(ctx context.Context, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) { - panic("implement me") + tx, blockHash, blockNumber, index := rawdb.ReadBorTransaction(b.ChainDb(), hash) + return tx, blockHash, blockNumber, index, nil } func (b testBackend) GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) { @@ -683,14 +690,9 @@ func (b testBackend) GetBorBlockLogs(ctx context.Context, hash common.Hash) ([]* } func (b testBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) { - number := rawdb.ReadHeaderNumber(b.db, hash) - if number == nil { - return nil, nil - } - - receipt := rawdb.ReadRawBorReceipt(b.db, hash, *number) + receipt := b.chain.GetBorReceiptByHash(hash) if receipt == nil { - return nil, nil + return nil, ethereum.NotFound } return receipt, nil @@ -1902,9 +1904,12 @@ func TestRPCGetBlockOrHeader(t *testing.T) { } } -func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Hash) { +func setupTransactionsToApiTest(t *testing.T) (*TransactionAPI, []common.Hash, []struct { + txHash common.Hash + file string +}) { config := *params.TestChainConfig - + genBlocks := 5 config.ShanghaiBlock = big.NewInt(0) config.CancunBlock = big.NewInt(0) @@ -1935,7 +1940,7 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha }, } signer = types.LatestSignerForChainID(params.TestChainConfig.ChainID) - txHashes = make([]common.Hash, genBlocks) + txHashes = make([]common.Hash, genBlocks+1) ) // Set the terminal total difficulty in the config @@ -1974,20 +1979,6 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha StorageKeys: []common.Hash{{0}}, }} tx, err = types.SignTx(types.NewTx(&types.AccessListTx{Nonce: uint64(i), To: nil, Gas: 58100, GasPrice: b.BaseFee(), Data: common.FromHex("0x60806040"), AccessList: accessList}), signer, acc1Key) - case 5: - // blob tx - fee := big.NewInt(500) - fee.Add(fee, b.BaseFee()) - tx, err = types.SignTx(types.NewTx(&types.BlobTx{ - Nonce: uint64(i), - GasTipCap: uint256.NewInt(1), - GasFeeCap: uint256.MustFromBig(fee), - Gas: params.TxGas, - To: acc2Addr, - BlobFeeCap: uint256.NewInt(1), - BlobHashes: []common.Hash{{1}}, - Value: new(uint256.Int), - }), signer, acc1Key) } if err != nil { t.Errorf("failed to sign tx: %v", err) @@ -1997,16 +1988,8 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha txHashes[i] = tx.Hash() } }) - return backend, txHashes -} -func TestRPCGetTransactionReceipt(t *testing.T) { - t.Parallel() - - var ( - backend, txHashes = setupReceiptBackend(t, 6) - api = NewTransactionAPI(backend, new(AddrLocker)) - ) + txHashes[genBlocks] = mockStateSyncTxOnCurrentBlock(t, backend) var testSuite = []struct { txHash common.Hash @@ -2047,12 +2030,45 @@ func TestRPCGetTransactionReceipt(t *testing.T) { txHash: common.HexToHash("deadbeef"), file: "txhash-notfound", }, - // 7. blob tx + // 7. state sync tx found { txHash: txHashes[5], - file: "blob-tx", + file: "state-sync-tx", }, } + // map sprint 0 to block 6 + backend.ChainConfig().Bor.Sprint["0"] = uint64(genBlocks) + + api := NewTransactionAPI(backend, new(AddrLocker)) + + return api, txHashes, testSuite +} + +func mockStateSyncTxOnCurrentBlock(t *testing.T, backend *testBackend) common.Hash { + // State Sync Tx Setup + var stateSyncLogs []*types.Log + block, err := backend.BlockByHash(context.Background(), backend.CurrentBlock().Hash()) + if err != nil { + t.Errorf("failed to get current block: %v", err) + } + + types.DeriveFieldsForBorLogs(stateSyncLogs, block.Hash(), block.NumberU64(), 0, 0) + + // Write bor receipt + rawdb.WriteBorReceipt(backend.ChainDb(), block.Hash(), block.NumberU64(), &types.ReceiptForStorage{ + Status: types.ReceiptStatusSuccessful, // make receipt status successful + Logs: stateSyncLogs, + }) + + // Write bor tx reverse lookup + rawdb.WriteBorTxLookupEntry(backend.ChainDb(), block.Hash(), block.NumberU64()) + return types.GetDerivedBorTxHash(types.BorReceiptKey(block.NumberU64(), block.Hash())) +} + +func TestRPCGetTransactionReceipt(t *testing.T) { + var ( + api, _, testSuite = setupTransactionsToApiTest(t) + ) for i, tt := range testSuite { var ( @@ -2067,6 +2083,48 @@ func TestRPCGetTransactionReceipt(t *testing.T) { testRPCResponseWithFile(t, i, result, "eth_getTransactionReceipt", tt.file) } } +func TestRPCGetTransactionByHash(t *testing.T) { + var ( + api, _, testSuite = setupTransactionsToApiTest(t) + ) + + for i, tt := range testSuite { + var ( + result interface{} + err error + ) + result, err = api.GetTransactionByHash(context.Background(), tt.txHash) + if err != nil { + t.Errorf("test %d: want no error, have %v", i, err) + continue + } + testRPCResponseWithFile(t, i, result, "eth_getTransactionByHash", tt.file) + } +} + +func TestRPCGetBlockTransactionCountByHash(t *testing.T) { + var ( + api, _, _ = setupTransactionsToApiTest(t) + ) + + cnt := api.GetBlockTransactionCountByHash(context.Background(), api.b.CurrentBlock().Hash()) + + // 2 txs: create-contract-with-access-list + state sync tx + expected := hexutil.Uint(2) + require.Equal(t, expected, *cnt) +} + +func TestRPCGetTransactionByBlockHashAndIndex(t *testing.T) { + var ( + api, _, _ = setupTransactionsToApiTest(t) + ) + + createContractWithAccessList := api.GetTransactionByBlockHashAndIndex(context.Background(), api.b.CurrentBlock().Hash(), 0) + stateSyncTx := api.GetTransactionByBlockHashAndIndex(context.Background(), api.b.CurrentBlock().Hash(), 1) + + testRPCResponseWithFile(t, 0, createContractWithAccessList, "eth_getTransactionByBlockHashAndIndex", "create-contract-with-access-list") + testRPCResponseWithFile(t, 1, stateSyncTx, "eth_getTransactionByBlockHashAndIndex", "state-sync-tx") +} func testRPCResponseWithFile(t *testing.T, testid int, result interface{}, rpc string, file string) { data, err := json.MarshalIndent(result, "", " ") @@ -2086,8 +2144,47 @@ func testRPCResponseWithFile(t *testing.T, testid int, result interface{}, rpc s } func TestRPCGetTransactionReceiptsByBlock(t *testing.T) { - t.Parallel() + api, blockNrOrHash, testSuite := setupBlocksToApiTest(t) + receipts, err := api.GetTransactionReceiptsByBlock(context.Background(), blockNrOrHash) + if err != nil { + t.Fatal("api error") + } + + for i, tt := range testSuite { + data, err := json.Marshal(receipts[i]) + if err != nil { + t.Errorf("test %d: json marshal error", i) + continue + } + want, have := tt.want, string(data) + require.JSONEqf(t, want, have, "test %d: json not match, want: %s, have: %s", i, want, have) + } +} + +func TestRPCGetBlockReceipts(t *testing.T) { + api, blockNrOrHash, testSuite := setupBlocksToApiTest(t) + + receipts, err := api.GetBlockReceipts(context.Background(), blockNrOrHash) + if err != nil { + t.Fatal("api error") + } + + for i, tt := range testSuite { + data, err := json.Marshal(receipts[i]) + if err != nil { + t.Errorf("test %d: json marshal error", i) + continue + } + want, have := tt.want, string(data) + require.JSONEqf(t, want, have, "test %d: json not match, want: %s, have: %s", i, want, have) + } +} + +func setupBlocksToApiTest(t *testing.T) (*BlockChainAPI, rpc.BlockNumberOrHash, []struct { + txHash common.Hash + want string +}) { // Initialize test accounts var ( acc1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a") @@ -2103,7 +2200,7 @@ func TestRPCGetTransactionReceiptsByBlock(t *testing.T) { contract: {Balance: big.NewInt(params.Ether), Code: common.FromHex("0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a9059cbb14610030575b600080fd5b61004a6004803603810190610045919061016a565b610060565b60405161005791906101c5565b60405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516100bf91906101ef565b60405180910390a36001905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610101826100d6565b9050919050565b610111816100f6565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b6000819050919050565b61014781610134565b811461015257600080fd5b50565b6000813590506101648161013e565b92915050565b60008060408385031215610181576101806100d1565b5b600061018f8582860161011f565b92505060206101a085828601610155565b9150509250929050565b60008115159050919050565b6101bf816101aa565b82525050565b60006020820190506101da60008301846101b6565b92915050565b6101e981610134565b82525050565b600060208201905061020460008301846101e0565b9291505056fea2646970667358221220b469033f4b77b9565ee84e0a2f04d496b18160d26034d54f9487e57788fd36d564736f6c63430008120033")}, }, } - genTxs = 5 + genTxs = 6 genBlocks = 1 signer = types.LatestSignerForChainID(params.TestChainConfig.ChainID) txHashes = make([]common.Hash, 0, genTxs) @@ -2149,6 +2246,11 @@ func TestRPCGetTransactionReceiptsByBlock(t *testing.T) { } }) + txHashes = append(txHashes, mockStateSyncTxOnCurrentBlock(t, backend)) + + // map sprint 0 to block 1 + backend.ChainConfig().Bor.Sprint["0"] = 1 + api := NewBlockChainAPI(backend) blockHashes := make([]common.Hash, genBlocks+1) ctx := context.Background() @@ -2315,20 +2417,27 @@ func TestRPCGetTransactionReceiptsByBlock(t *testing.T) { "type": "0x1" }`, }, + // 5. state sync tx + { + txHash: txHashes[5], + want: `{ + "blockHash": "0x1728b788dfe51e507d25f14f01414b5a17f807953c13833811d2afae1982b53b", + "blockNumber": "0x1", + "contractAddress": null, + "cumulativeGasUsed": "0x0", + "effectiveGasPrice": "0x0", + "from": "0x0000000000000000000000000000000000000000", + "gasUsed": "0x0", + "logs": [], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "status": "0x1", + "to": "0x0000000000000000000000000000000000000000", + "transactionHash": "0xba46f68d5c3729ac3fb672fec579fc2cad543bc9edf5b2d47d7c6636ac2fbec9", + "transactionIndex": "0x5", + "type": "0x0" + }`, + }, } - receipts, err := api.GetTransactionReceiptsByBlock(context.Background(), blockNrOrHash) - if err != nil { - t.Fatal("api error") - } - - for i, tt := range testSuite { - data, err := json.Marshal(receipts[i]) - if err != nil { - t.Errorf("test %d: json marshal error", i) - continue - } - want, have := tt.want, string(data) - require.JSONEqf(t, want, have, "test %d: json not match, want: %s, have: %s", i, want, have) - } + return api, blockNrOrHash, testSuite } diff --git a/internal/ethapi/testdata/eth_getBlockReceipts-block-with-blob-tx.json b/internal/ethapi/testdata/eth_getBlockReceipts-block-with-blob-tx.json deleted file mode 100644 index 65c485f09b..0000000000 --- a/internal/ethapi/testdata/eth_getBlockReceipts-block-with-blob-tx.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "blobGasPrice": null, - "blobGasUsed": "0x20000", - "blockHash": "0x4446b1498499cab37cfec330097fadf285c703444d431756940528d32fe0e97b", - "blockNumber": "0x6", - "contractAddress": null, - "cumulativeGasUsed": "0x5208", - "effectiveGasPrice": "0x1b09d63b", - "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", - "gasUsed": "0x5208", - "logs": [{"address": "0x0000000000000000000000000000000000001010", "blockHash": "0x4446b1498499cab37cfec330097fadf285c703444d431756940528d32fe0e97b", "blockNumber": "0x6", "data": "0x00000000000000000000000000000000000000000000000000000000000052080000000000000000000000000000000000000000000000000de04bce435b746d0000000000000000000000000000000000000000000000000000000000a32f640000000000000000000000000000000000000000000000000de04bce435b22650000000000000000000000000000000000000000000000000000000000a3816c", "logIndex": "0x0", "removed": false, "topics": ["0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", "0x0000000000000000000000000000000000000000000000000000000000001010", "0x000000000000000000000000703c4b2bd70c169f5717101caee543299fc946c7", "0x0000000000000000000000000000000000000000000000000000000000000000"], "transactionHash": "0xb51ee3d2a89ba5d5623c73133c8d7a6ba9fb41194c17f4302c21b30994a1180f", "transactionIndex": "0x0"}], - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000020000000000000020000000000000000000800000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001800000000000000000000000000000100000000020000000000000000000000000000000000000000020000000000000000000100000", - "status": "0x1", - "to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e", - "transactionHash": "0xb51ee3d2a89ba5d5623c73133c8d7a6ba9fb41194c17f4302c21b30994a1180f", - "transactionIndex": "0x0", - "type": "0x3" - } -] diff --git a/internal/ethapi/testdata/eth_getBlockReceipts-tag-latest.json b/internal/ethapi/testdata/eth_getBlockReceipts-tag-latest.json index 65c485f09b..0ae57519ff 100644 --- a/internal/ethapi/testdata/eth_getBlockReceipts-tag-latest.json +++ b/internal/ethapi/testdata/eth_getBlockReceipts-tag-latest.json @@ -2,14 +2,14 @@ { "blobGasPrice": null, "blobGasUsed": "0x20000", - "blockHash": "0x4446b1498499cab37cfec330097fadf285c703444d431756940528d32fe0e97b", + "blockHash": "0x4d780246cde52e535f40603d47af8fa1aea807dd3065e1acd97127bea0922b3e", "blockNumber": "0x6", "contractAddress": null, "cumulativeGasUsed": "0x5208", "effectiveGasPrice": "0x1b09d63b", "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", "gasUsed": "0x5208", - "logs": [{"address": "0x0000000000000000000000000000000000001010", "blockHash": "0x4446b1498499cab37cfec330097fadf285c703444d431756940528d32fe0e97b", "blockNumber": "0x6", "data": "0x00000000000000000000000000000000000000000000000000000000000052080000000000000000000000000000000000000000000000000de04bce435b746d0000000000000000000000000000000000000000000000000000000000a32f640000000000000000000000000000000000000000000000000de04bce435b22650000000000000000000000000000000000000000000000000000000000a3816c", "logIndex": "0x0", "removed": false, "topics": ["0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", "0x0000000000000000000000000000000000000000000000000000000000001010", "0x000000000000000000000000703c4b2bd70c169f5717101caee543299fc946c7", "0x0000000000000000000000000000000000000000000000000000000000000000"], "transactionHash": "0xb51ee3d2a89ba5d5623c73133c8d7a6ba9fb41194c17f4302c21b30994a1180f", "transactionIndex": "0x0"}], + "logs": [{"address": "0x0000000000000000000000000000000000001010", "blockHash": "0x4d780246cde52e535f40603d47af8fa1aea807dd3065e1acd97127bea0922b3e", "blockNumber": "0x6", "data": "0x00000000000000000000000000000000000000000000000000000000000052080000000000000000000000000000000000000000000000000de04bce435b746d0000000000000000000000000000000000000000000000000000000000a32f640000000000000000000000000000000000000000000000000de04bce435b22650000000000000000000000000000000000000000000000000000000000a3816c", "logIndex": "0x0", "removed": false, "topics": ["0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", "0x0000000000000000000000000000000000000000000000000000000000001010", "0x000000000000000000000000703c4b2bd70c169f5717101caee543299fc946c7", "0x0000000000000000000000000000000000000000000000000000000000000000"], "transactionHash": "0xb51ee3d2a89ba5d5623c73133c8d7a6ba9fb41194c17f4302c21b30994a1180f", "transactionIndex": "0x0"}], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000020000000000000020000000000000000000800000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001800000000000000000000000000000100000000020000000000000000000000000000000000000000020000000000000000000100000", "status": "0x1", "to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e", diff --git a/internal/ethapi/testdata/eth_getTransactionByBlockHashAndIndex-create-contract-with-access-list.json b/internal/ethapi/testdata/eth_getTransactionByBlockHashAndIndex-create-contract-with-access-list.json new file mode 100644 index 0000000000..6a8f8f1804 --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByBlockHashAndIndex-create-contract-with-access-list.json @@ -0,0 +1,27 @@ +{ + "blockHash": "0x4d780246cde52e535f40603d47af8fa1aea807dd3065e1acd97127bea0922b3e", + "blockNumber": "0x5", + "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", + "gas": "0xe2f4", + "gasPrice": "0x1ecb3fb4", + "hash": "0xb5a1148819cfdfff9bfe70035524fec940eb735d89b76960b97751d01ae2a9f2", + "input": "0x60806040", + "nonce": "0x4", + "to": null, + "transactionIndex": "0x0", + "value": "0x0", + "type": "0x1", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000031ec7", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "chainId": "0x1", + "v": "0x0", + "r": "0xb4f6dc1e9c3c5904b7b3969e84dd3eefe68cf1b1951039ccf1848f471660671c", + "s": "0x77137b10f51515bcf3268f969a8bee4cb6d0d9521f402b058927071a9cc7e3d8", + "yParity": "0x0" +} \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionByBlockHashAndIndex-state-sync-tx.json b/internal/ethapi/testdata/eth_getTransactionByBlockHashAndIndex-state-sync-tx.json new file mode 100644 index 0000000000..e1e290b0ff --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByBlockHashAndIndex-state-sync-tx.json @@ -0,0 +1,17 @@ +{ + "blockHash": "0x4d780246cde52e535f40603d47af8fa1aea807dd3065e1acd97127bea0922b3e", + "blockNumber": "0x5", + "from": "0x0000000000000000000000000000000000000000", + "gas": "0x0", + "gasPrice": "0x0", + "hash": "0x08ce9234678f85834bdf3ebed2d580dbac00a3899f9e7020e36c9a93fd1a610a", + "input": "0x", + "nonce": "0x0", + "to": "0x0000000000000000000000000000000000000000", + "transactionIndex": "0x1", + "value": "0x0", + "type": "0x0", + "v": "0x0", + "r": "0x0", + "s": "0x0" +} \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionByHash-create-contract-tx.json b/internal/ethapi/testdata/eth_getTransactionByHash-create-contract-tx.json new file mode 100644 index 0000000000..b4107154ae --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByHash-create-contract-tx.json @@ -0,0 +1,18 @@ +{ + "blockHash": "0xc594f1b119b071d288cd11371da2de73d67986a717974a85cac4ce634eba3015", + "blockNumber": "0x2", + "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", + "gas": "0xcf6c", + "gasPrice": "0x2db16291", + "hash": "0x340e58cda5086495010b571fe25067fecc9954dc4ee3cedece00691fa3f5904a", + "input": "0x60806040", + "nonce": "0x1", + "to": null, + "transactionIndex": "0x0", + "value": "0x0", + "type": "0x0", + "chainId": "0x1", + "v": "0x26", + "r": "0xfa210b09f8a13ea096b3a005a5feb0270121ab259555898bf03826e993ec14f4", + "s": "0x7173d180059852006668647a793207d488723b89acdd6c484273f16beb9aaa3" +} \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionByHash-create-contract-with-access-list.json b/internal/ethapi/testdata/eth_getTransactionByHash-create-contract-with-access-list.json new file mode 100644 index 0000000000..6a8f8f1804 --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByHash-create-contract-with-access-list.json @@ -0,0 +1,27 @@ +{ + "blockHash": "0x4d780246cde52e535f40603d47af8fa1aea807dd3065e1acd97127bea0922b3e", + "blockNumber": "0x5", + "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", + "gas": "0xe2f4", + "gasPrice": "0x1ecb3fb4", + "hash": "0xb5a1148819cfdfff9bfe70035524fec940eb735d89b76960b97751d01ae2a9f2", + "input": "0x60806040", + "nonce": "0x4", + "to": null, + "transactionIndex": "0x0", + "value": "0x0", + "type": "0x1", + "accessList": [ + { + "address": "0x0000000000000000000000000000000000031ec7", + "storageKeys": [ + "0x0000000000000000000000000000000000000000000000000000000000000000" + ] + } + ], + "chainId": "0x1", + "v": "0x0", + "r": "0xb4f6dc1e9c3c5904b7b3969e84dd3eefe68cf1b1951039ccf1848f471660671c", + "s": "0x77137b10f51515bcf3268f969a8bee4cb6d0d9521f402b058927071a9cc7e3d8", + "yParity": "0x0" +} \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionByHash-dynamic-tx-with-logs.json b/internal/ethapi/testdata/eth_getTransactionByHash-dynamic-tx-with-logs.json new file mode 100644 index 0000000000..d40f81aa75 --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByHash-dynamic-tx-with-logs.json @@ -0,0 +1,22 @@ +{ + "blockHash": "0x15158c4fb0661a38967dbf81b1592c54999b44a4580153b3469b29724903fc95", + "blockNumber": "0x4", + "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", + "gas": "0xea60", + "gasPrice": "0x2325c42f", + "maxFeePerGas": "0x2325c42f", + "maxPriorityFeePerGas": "0x1f4", + "hash": "0xdcde2574628c9d7dff22b9afa19f235959a924ceec65a9df903a517ae91f5c84", + "input": "0xa9059cbb0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e", + "nonce": "0x3", + "to": "0x0000000000000000000000000000000000031ec7", + "transactionIndex": "0x0", + "value": "0x1", + "type": "0x2", + "accessList": [], + "chainId": "0x1", + "v": "0x1", + "r": "0x41fa5d541e9081c6f636e6cb6c5dc0c4369c7d65df9b17f8ac47834f1eba4a6a", + "s": "0x6f811df916d0ec44e108740d6d307fd203273c26f9f52a785cb5fc551c5802f9", + "yParity": "0x1" +} \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionByHash-normal-transfer-tx.json b/internal/ethapi/testdata/eth_getTransactionByHash-normal-transfer-tx.json new file mode 100644 index 0000000000..54b5d3eeda --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByHash-normal-transfer-tx.json @@ -0,0 +1,17 @@ +{ + "blockHash": "0xfddc403b2acdace77774a35cbad7b68d50ce258fafaac399e21533a3b77ad94a", + "blockNumber": "0x1", + "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", + "gas": "0x5208", + "gasPrice": "0x342770c0", + "hash": "0x644a31c354391520d00e95b9affbbb010fc79ac268144ab8e28207f4cf51097e", + "input": "0x", + "nonce": "0x0", + "to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e", + "transactionIndex": "0x0", + "value": "0x3e8", + "type": "0x0", + "v": "0x1b", + "r": "0xcd190747077598c3b9c5f21ea06f8487d6ab1e23358fbe0e0e0c4e64651b68f3", + "s": "0x467ebcb2186b332969991e2e25244959dcdb3feb7652ff6b81ce96e646d86abd" +} \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionByHash-state-sync-tx.json b/internal/ethapi/testdata/eth_getTransactionByHash-state-sync-tx.json new file mode 100644 index 0000000000..e1e290b0ff --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByHash-state-sync-tx.json @@ -0,0 +1,17 @@ +{ + "blockHash": "0x4d780246cde52e535f40603d47af8fa1aea807dd3065e1acd97127bea0922b3e", + "blockNumber": "0x5", + "from": "0x0000000000000000000000000000000000000000", + "gas": "0x0", + "gasPrice": "0x0", + "hash": "0x08ce9234678f85834bdf3ebed2d580dbac00a3899f9e7020e36c9a93fd1a610a", + "input": "0x", + "nonce": "0x0", + "to": "0x0000000000000000000000000000000000000000", + "transactionIndex": "0x1", + "value": "0x0", + "type": "0x0", + "v": "0x0", + "r": "0x0", + "s": "0x0" +} \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionByHash-txhash-empty.json b/internal/ethapi/testdata/eth_getTransactionByHash-txhash-empty.json new file mode 100644 index 0000000000..ec747fa47d --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByHash-txhash-empty.json @@ -0,0 +1 @@ +null \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionByHash-txhash-notfound.json b/internal/ethapi/testdata/eth_getTransactionByHash-txhash-notfound.json new file mode 100644 index 0000000000..ec747fa47d --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByHash-txhash-notfound.json @@ -0,0 +1 @@ +null \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionByHash-with-logs.json b/internal/ethapi/testdata/eth_getTransactionByHash-with-logs.json new file mode 100644 index 0000000000..a9a8f9a472 --- /dev/null +++ b/internal/ethapi/testdata/eth_getTransactionByHash-with-logs.json @@ -0,0 +1,18 @@ +{ + "blockHash": "0x12db9de067ca71d47e360ab4eb9bf7bc80824f5edd39c7576e253f37a1a22782", + "blockNumber": "0x3", + "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", + "gas": "0xea60", + "gasPrice": "0x281c2585", + "hash": "0xeaf3921cbf03ba45bad4e6ab807b196ce3b2a0b5bacc355b6272fa96b11b4287", + "input": "0xa9059cbb0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000d", + "nonce": "0x2", + "to": "0x0000000000000000000000000000000000031ec7", + "transactionIndex": "0x0", + "value": "0x0", + "type": "0x0", + "chainId": "0x1", + "v": "0x25", + "r": "0xabecc8622990867d3889d6abb094e9247b5af59978c23d95b7020da6efa2c834", + "s": "0x31267ff2ffba8d2ff70d908feb98584872c3b3df47454cc3d04f342eb6c68b77" +} \ No newline at end of file diff --git a/internal/ethapi/testdata/eth_getTransactionReceipt-blob-tx.json b/internal/ethapi/testdata/eth_getTransactionReceipt-blob-tx.json deleted file mode 100644 index 610cd2c821..0000000000 --- a/internal/ethapi/testdata/eth_getTransactionReceipt-blob-tx.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "blobGasPrice": null, - "blobGasUsed": "0x20000", - "blockHash": "0x4446b1498499cab37cfec330097fadf285c703444d431756940528d32fe0e97b", - "blockNumber": "0x6", - "contractAddress": null, - "cumulativeGasUsed": "0x5208", - "effectiveGasPrice": "0x1b09d63b", - "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", - "gasUsed": "0x5208", - "logs": [{"address": "0x0000000000000000000000000000000000001010", "blockHash": "0x4446b1498499cab37cfec330097fadf285c703444d431756940528d32fe0e97b", "blockNumber": "0x6", "data": "0x00000000000000000000000000000000000000000000000000000000000052080000000000000000000000000000000000000000000000000de04bce435b746d0000000000000000000000000000000000000000000000000000000000a32f640000000000000000000000000000000000000000000000000de04bce435b22650000000000000000000000000000000000000000000000000000000000a3816c", "logIndex": "0x0", "removed": false, "topics": ["0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", "0x0000000000000000000000000000000000000000000000000000000000001010", "0x000000000000000000000000703c4b2bd70c169f5717101caee543299fc946c7", "0x0000000000000000000000000000000000000000000000000000000000000000"], "transactionHash": "0xb51ee3d2a89ba5d5623c73133c8d7a6ba9fb41194c17f4302c21b30994a1180f", "transactionIndex": "0x0"}], - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000800000000000000000000100000020000000000000020000000000000000000800000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001800000000000000000000000000000100000000020000000000000000000000000000000000000000020000000000000000000100000", - "status": "0x1", - "to": "0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e", - "transactionHash": "0xb51ee3d2a89ba5d5623c73133c8d7a6ba9fb41194c17f4302c21b30994a1180f", - "transactionIndex": "0x0", - "type": "0x3" -} diff --git a/internal/ethapi/testdata/eth_getTransactionReceipt-state-sync-tx.json b/internal/ethapi/testdata/eth_getTransactionReceipt-state-sync-tx.json index 2fb229ce2f..a40d454741 100644 --- a/internal/ethapi/testdata/eth_getTransactionReceipt-state-sync-tx.json +++ b/internal/ethapi/testdata/eth_getTransactionReceipt-state-sync-tx.json @@ -1,17 +1,16 @@ { - "blockHash": "0x4d780246cde52e535f40603d47af8fa1aea807dd3065e1acd97127bea0922b3e", - "blockNumber": "0x6", - "contractAddress": null, - "cumulativeGasUsed": "0xe01c", - "effectiveGasPrice": "0x1ecb3fb4", - "from": "0x703c4b2bd70c169f5717101caee543299fc946c7", - "gasUsed": "0xe01c", - "logs": [], - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "status": "0x1", - "to": null, - "transactionHash": "0xb5a1148819cfdfff9bfe70035524fec940eb735d89b76960b97751d01ae2a9f2", - "transactionIndex": "0x0", - "type": "0x1" - } - \ No newline at end of file + "blockHash": "0x4d780246cde52e535f40603d47af8fa1aea807dd3065e1acd97127bea0922b3e", + "blockNumber": "0x5", + "contractAddress": null, + "cumulativeGasUsed": "0x0", + "effectiveGasPrice": "0x0", + "from": "0x0000000000000000000000000000000000000000", + "gasUsed": "0x0", + "logs": [], + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "status": "0x1", + "to": "0x0000000000000000000000000000000000000000", + "transactionHash": "0x08ce9234678f85834bdf3ebed2d580dbac00a3899f9e7020e36c9a93fd1a610a", + "transactionIndex": "0x1", + "type": "0x0" +} \ No newline at end of file