ava-labs / coreth

Code and wrapper to extract Ethereum blockchain functionalities without network/consensus, for building custom blockchain services.
Other
183 stars 140 forks source link

PVM Import type transactions are not included in block info #692

Open AntonieDavid opened 1 week ago

AntonieDavid commented 1 week ago

Context and scope

Feature request to support PVM import type transactions to be included in output from the following method eth_getBlockByNumber

Discussion and alternatives

PVM Import transaction HKaVqfZM5kdbu78Ab3WMdftD6eSzhJr4KbsxUWiSUn2RTT5T9 to be part of this block #43075777.

The main issue is that we expect this type of transactions to be included in blocks, for example the above tx hash is showed on avalanche explorer, however it's not shown when querying the specifc block to an avalanche mainnet endpoint.

`curl -s --request POST --url ........ --header 'accept: application/json' --header 'content-type: application/json' --data '{ "id":3340, "jsonrpc":"2.0", "method":"eth_getBlockByNumber", "params":[ "0x29148C1", false ] }' | jq .

{ "jsonrpc": "2.0", "id": 3340, "result": { "baseFeePerGas": "0x5d21dba00", "blockExtraData": "0x00000000000100000000000000010427d4b22a2a78bcddd456742caf91b56badbff985ee19aef14573e7343fd6520000000000000000000000000000000000000000000000000000000000000000000000011107248189dfa68f5188e6695be6bcbc0ce2c6983a5b5decc7e5485afe8190ac0000000121e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff0000000500002d794ca256000000000100000000000000015c7f517d8388e082863806ebbce1a6893d63e7d300002d794c9d31fc21e67317cbc4be2aeb00677ad6462778a8f52274b9d605df2591b23027a87dff00000001000000090000000194bf27f8b8e47234de0f85b3be84884eb6e707f6974a7eedd310d7fa0290b6cb3de7c93170007743cc410988f27e474299da9153ce3f86d8680edbc087d2c08100", "blockGasCost": "0x0", "difficulty": "0x1", "extDataGasUsed": "0x2bde", "extDataHash": "0x6c690ac1f71f23b86653b77ca60c0342f9035b390a1593466c9ae30e54d8b980", "extraData": "0x0000000000000000000000000007339000000000000edfcc00000000000000000000000000000000000000000028f9f80000000000000000000000000010a68600000000000000000000000000000000000000000000", "gasLimit": "0xe4e1c0", "gasUsed": "0xac00e", "hash": "0x139d2be8c9e6a00f460fe98502a6afa5ffe6bb33308b11346e254b8f57c1a894", "logsBloom": "0x00a000004000200080000001800000200000500000000000280040000008000010000000000020000040240811100000010000000020000004000000102000002040800008000000000000082100002000000000800000020800009400004800000400200200040000000050000808020000040000800000020000180000000000420000000000000000000020002010000000002800000a0000004000000080020000000000020002000004200000008000000200000000080000000000000080001002000028000000008000000000000000410000001008000004000020001010800000000400002010000000002810000000041004a00100000000480040", "miner": "0x0100000000000000000000000000000000000000", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0000000000000000", "number": "0x29148c1", "parentHash": "0x39c4191b008c3f6858ce4e181096197c372298daea1556186808685565c29f29", "receiptsRoot": "0x492d61a2cb994295c62a06f5b381c64a4ad714a131a68cdcbe5f8f9817eb1a7d", "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "size": "0xcb3", "stateRoot": "0x791fc7326272879b0ba7353cc08e87d60300b7bb2df6e82755e6e4e175cf35eb", "timestamp": "0x65f8b57b", "totalDifficulty": "0x29148c1", "transactions": [ "0x08ba9c96e2f2cad19deb1f412949c7b26a4659fbe7a01401dcf59bf356c61fdc", "0x56c456ca8b7957c49fc1bfe968e72d5a2e9fa86b49c7d3ecd566f62e7c49dc8b", "0x49ef6b39072334cb06dadef277ad43a69220f0b987fc8055f3cdb0ff9adb2779", "0xd3c18fe8cb159640b26324aca363ee5ee0d224d08ba9bf2ebc2fba7366a1f67c", "0x8c5b6470988b70a6d882b792c9a8bd9ccf36acbb62d3a32475fb3b0df9198ab2", "0xac75144efe2aa16ec5f5de495bfef2b5c2f7c3e059211b38a37a47ff3f319826" ], "transactionsRoot": "0xe46f7f5082d3567b788a4a2c1cbe191b1f01ea71e5a624a0583bbde2af20d014", "uncles": [] } }`

darioush commented 4 days ago

To find the import/export TXs, the caller should interpret the blockExtraData which contains these TXs. The reference implementation is available in ExtractAtomicTxs here which should be called with batch=true for post Apricot Phase 5 and with batch=false for pre apricot phase 5 blocks.

These are not included in the transactions or transactionsRoot outputs because they are not Ethereum transactions.