okx / xlayer-erigon

Ethereum implementation on the efficiency frontier
GNU Lesser General Public License v3.0
16 stars 3 forks source link

Return Safe block info (eth_getBlockByNumber, eth_getTransactionByBlockNumberAndIndex, etc.) #10

Closed andreclaro closed 3 months ago

andreclaro commented 4 months ago

We would like xlayer-erigon to return information about the safe block.

I have reported this to the cdk-erigon since xlayer-erigon is a fork of it: https://github.com/0xPolygonHermez/cdk-erigon/issues/388

Rationale

Currently, xlayer-erigon returns an error with message "Unknown block" when trying to get information about the safe block.

Example using the method eth_getBlockByNumber.

curl -s http://localhost:8545/ -X POST -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["safe",false],"id":1,"jsonrpc":"2.0"}'
{"jsonrpc":"2.0","id":1,"error":{"code":-39001,"message":"Unknown block"}}

I also tried other methods like eth_getTransactionByBlockNumberAndIndex but I got the same result: "Unknown block":

curl http://localhost:8545 \
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"eth_getTransactionByBlockNumberAndIndex","params":["safe", "0x0"],"id":1,"jsonrpc":"2.0"}'
{"jsonrpc":"2.0","id":1,"error":{"code":-39001,"message":"Unknown block"}}

The clients using the node requires access to both finalized and safe block information.

Implementation

xlayer-erigon should be able to return information about the safe block.

giskook commented 4 months ago

https://github.com/okx/xlayer-erigon/pull/11

giskook commented 4 months ago

https://github.com/0xPolygonHermez/cdk-erigon/pull/392

andreclaro commented 4 months ago

Tested successfully using curl request and also with our client:

curl -s http://localhost:8545 -X POST -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["safe",false],"id":1,"jsonrpc":"2.0"}'

{"jsonrpc":"2.0","id":1,"result":{"difficulty":"0x0","extraData":"0x","gasLimit":"0x4000000000000","gasUsed":"0x3611f","hash":"0x9fb73fac12e6b5cc9b469c13e211957d2cc8dc3b08aeea77547a188111f27460","logsBloom":"0x00000000000000000000000000000400000100000000000002020000000000000000000000002000000000000000000000000000080040000000000000200000000000000000004000000008000000800000000000000000000000000000000000000000000040000000000000000000000000000000000000000010000800000000000000000000000001000000000000000000000000801000000000000000020000200000000000000840000000000000000008000000000000000000000000000002000004000000000000000000000000000018000000000000000000000010000000000000000000000000000400000000000000000400000000000800","miner":"0xd6dda5aa7749142b7fda3fe4662c9f346101b8a6","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","number":"0xd6bbaf","parentHash":"0xb56fd669aa420fcc305f5d7cb287f525eaf79ff7b401ae5383b63c5173d500d1","receiptsRoot":"0x6e8307eb22b5797a0454890b9972c0434dfeccb670c43d1e195cdbb52bf63f66","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x44a","stateRoot":"0x06b29f1606c35717abb9e003e7d9018908ac469be54eb801c1e41a6f49a59d66","timestamp":"0x663e24da","totalDifficulty":"0x0","transactions":["0x8457956b863edcba920aa0e00bfd3c8afcd58ecf6c27131cb6b0596cf076c319","0xc45c5025cf6b519847d604e197b403d3e8e6aebcfb0b3e12da8d50df8304b17f"],"transactionsRoot":"0x1623ba8d1734d081ff17973ab5d042b08d19931407066692daf51fa5aabf18c7","uncles":[]}}
Igor-rockawayx commented 3 months ago

Works on our end as well:

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["safe",false],"id":83}' http://localhost:8545/

{"jsonrpc":"2.0","id":83,"result":{"difficulty":"0x0","extraData":"0x","gasLimit":"0x0","gasUsed":"0x0","hash":"0x11f32f605beb94a1acb783cb3b6da6d7975461ce3addf441e7ad60c2ec95e88f","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","number":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x1f9","stateRoot":"0xe3a7d8bae497945ba8ddc51c69564f60ad4c1a990b9c7bdbd27f7929bfa8f272","timestamp":"0x6607c71b","totalDifficulty":"0x0","transactions":[],"transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","uncles":[]}}
andreclaro commented 3 months ago

We are now seeing a new issue in X Layer mainnet network. The safe block reported by the node is always 0x0: https://github.com/okx/xlayer-erigon/issues/14