onflow / flow-evm-gateway

FlowEVM Gateway implements an Ethereum-equivalent JSON-RPC API for EVM clients to use
https://developers.flow.com/evm/about
Apache License 2.0
11 stars 9 forks source link

Internal error when querying certain blocks #495

Closed infsaulo closed 4 weeks ago

infsaulo commented 1 month ago

Problem

Whether this is intermittent or not, there are blocks that cannot be retrieved from testnet endpoint. E.g. block with height 813 cannot be retrieved using eth_getBlockByNumber RPC endpoint.

Steps to Reproduce

m-Peter commented 1 month ago

This seems to be some kind of regression, I get this error for non-empty blocks:

curl -s https://testnet.evm.nodes.onflow.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x9d7", false],"id":1}' | jq
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32000,
    "message": "internal error"
  }
}

But for empty blocks:

curl -s https://testnet.evm.nodes.onflow.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x9d6", false],"id":1}' | jq
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "number": "0x9d6",
    "hash": "0x05aa4a6edbcf6fa81178566596be1c7fff7b721615c8b3bbd14ff76d9c81ec9b",
    "parentHash": "0x3394183ed4d19641348d58df45652c310465cccab5b6c6af41ca929c24d8a8ab",
    "nonce": "0x0100000000000000",
    "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
    "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
    "miner": "0x0000000000000000000000030000000000000000",
    "difficulty": "0x0",
    "totalDifficulty": "0x0",
    "extraData": "0x",
    "size": "0x9f",
    "gasLimit": "0xe4e1c0",
    "gasUsed": "0x0",
    "timestamp": "0x66bd00f9",
    "transactions": [],
    "uncles": [],
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "baseFeePerGas": "0x0"
  }
}

It seems to work.

@sideninja Most likely related to the removal of https://github.com/onflow/flow-evm-gateway/pull/485. I checked by connecting a local EVM Gateway instance to testnet, but I don't get the same error. Could you check the logs?

sideninja commented 4 weeks ago

I believe there's a single block (would have to double-check but the one specified above) that is corrupted due to type migration. I do plan to reindex and it should fix it.

sideninja commented 4 weeks ago

@infsaulo the problem should be resolved now. Thank you for flagging.

Closing the issue.

Example:

curl https://testnet.evm.nodes.onflow.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x32D", true],"id":1}

Response:

curl https://testnet.evm.nodes.onflow.org -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x32D", true],"id":1}'
{"jsonrpc":"2.0","id":1,"result":{"number":"0x32d","hash":"0xeb191543781648213ff4cf03616683acbb2ce4bae2c484b5e8a1e4943aeeb1ac","parentHash":"0x24e21fd14b2395ddd47a9aa3a40e91f118f87a159c245bdfb7137359336b45ca","nonce":"0x0100000000000000","sha3Uncles":"0x0000000000000000000000000000000000000000000000000000000000000000","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x1645d3e102378ccb44d419d1618cfe6c17c85604ab42623d0a5ad9e8d84880a2","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","receiptsRoot":"0x403b510d1f39d48887770a2e38705885380a9758780cf557e7d6c1c5c0e6d6a1","miner":"0x0000000000000000000000030000000000000000","difficulty":"0x0","totalDifficulty":"0x0","extraData":"0x","size":"0xf33","gasLimit":"0xe4e1c0","gasUsed":"0xb0ac7","timestamp":"0x66bcfb7b","transactions":[{"blockHash":"0xeb191543781648213ff4cf03616683acbb2ce4bae2c484b5e8a1e4943aeeb1ac","blockNumber":"0x32d","from":"0x0000000000000000000000020000000000000000","gas":"0xb0838","gasPrice":"0x0","hash":"0xc149feb14a3981a5749c25e5844d3d894a0d24a26693ddcfa6dd27d8d2531f8f","input":"0x608060405234801561000f575f80fd5b50610db98061001d5f395ff3fe608060405260043610610072575f3560e01c80631626ba7e1161004d5780631626ba7e1461011d578063bc197c8114610159578063d0d250bd14610195578063f23a6e61146101bf57610079565b806223de291461007d57806301ffc9a7146100a5578063150b7a02146100e157610079565b3661007957005b5f80fd5b348015610088575f80fd5b506100a3600480360381019061009e9190610641565b6101fb565b005b3480156100b0575f80fd5b506100cb60048036038101906100c69190610760565b610205565b6040516100d891906107a5565b60405180910390f35b3480156100ec575f80fd5b50610107600480360381019061010291906107be565b6103a5565b6040516101149190610851565b60405180910390f35b348015610128575f80fd5b50610143600480360381019061013e91906109d5565b6103b9565b6040516101509190610851565b60405180910390f35b348015610164575f80fd5b5061017f600480360381019061017a9190610a84565b610509565b60405161018c9190610851565b60405180910390f35b3480156101a0575f80fd5b506101a9610520565b6040516101b69190610b6a565b60405180910390f35b3480156101ca575f80fd5b506101e560048036038101906101e09190610b83565b61052d565b6040516101f29190610851565b60405180910390f35b5050505050505050565b5f7f4e2312e0000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806102cf57507f150b7a02000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061033657507e23de29000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061039e57507f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b5f63150b7a0260e01b905095945050505050565b5f805f6801000000000000000173ffffffffffffffffffffffffffffffffffffffff163086866040516024016103f193929190610ca2565b6040516020818303038152906040527f5ee837e7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161047b9190610d18565b5f60405180830381855afa9150503d805f81146104b3576040519150601f19603f3d011682016040523d82523d5f602084013e6104b8565b606091505b5091509150816104c6575f80fd5b5f818060200190518101906104db9190610d58565b905080156104f557631626ba7e60e01b9350505050610503565b63ffffffff60e01b93505050505b92915050565b5f63bc197c8160e01b905098975050505050505050565b6801000000000000000181565b5f63f23a6e6160e01b90509695505050505050565b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61057c82610553565b9050919050565b61058c81610572565b8114610596575f80fd5b50565b5f813590506105a781610583565b92915050565b5f819050919050565b6105bf816105ad565b81146105c9575f80fd5b50565b5f813590506105da816105b6565b92915050565b5f80fd5b5f80fd5b5f80fd5b5f8083601f840112610601576106006105e0565b5b8235905067ffffffffffffffff81111561061e5761061d6105e4565b5b60208301915083600182028301111561063a576106396105e8565b5b9250929050565b5f805f805f805f8060c0898b03121561065d5761065c61054b565b5b5f61066a8b828c01610599565b985050602061067b8b828c01610599565b975050604061068c8b828c01610599565b965050606061069d8b828c016105cc565b955050608089013567ffffffffffffffff8111156106be576106bd61054f565b5b6106ca8b828c016105ec565b945094505060a089013567ffffffffffffffff8111156106ed576106ec61054f565b5b6106f98b828c016105ec565b92509250509295985092959890939650565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61073f8161070b565b8114610749575f80fd5b50565b5f8135905061075a81610736565b92915050565b5f602082840312156107755761077461054b565b5b5f6107828482850161074c565b91505092915050565b5f8115159050919050565b61079f8161078b565b82525050565b5f6020820190506107b85f830184610796565b92915050565b5f805f805f608086880312156107d7576107d661054b565b5b5f6107e488828901610599565b95505060206107f588828901610599565b9450506040610806888289016105cc565b935050606086013567ffffffffffffffff8111156108275761082661054f565b5b610833888289016105ec565b92509250509295509295909350565b61084b8161070b565b82525050565b5f6020820190506108645f830184610842565b92915050565b5f819050919050565b61087c8161086a565b8114610886575f80fd5b50565b5f8135905061089781610873565b92915050565b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6108e7826108a1565b810181811067ffffffffffffffff82111715610906576109056108b1565b5b80604052505050565b5f610918610542565b905061092482826108de565b919050565b5f67ffffffffffffffff821115610943576109426108b1565b5b61094c826108a1565b9050602081019050919050565b828183375f83830152505050565b5f61097961097484610929565b61090f565b9050828152602081018484840111156109955761099461089d565b5b6109a0848285610959565b509392505050565b5f82601f8301126109bc576109bb6105e0565b5b81356109cc848260208601610967565b91505092915050565b5f80604083850312156109eb576109ea61054b565b5b5f6109f885828601610889565b925050602083013567ffffffffffffffff811115610a1957610a1861054f565b5b610a25858286016109a8565b9150509250929050565b5f8083601f840112610a4457610a436105e0565b5b8235905067ffffffffffffffff811115610a6157610a606105e4565b5b602083019150836020820283011115610a7d57610a7c6105e8565b5b9250929050565b5f805f805f805f8060a0898b031215610aa057610a9f61054b565b5b5f610aad8b828c01610599565b9850506020610abe8b828c01610599565b975050604089013567ffffffffffffffff811115610adf57610ade61054f565b5b610aeb8b828c01610a2f565b9650965050606089013567ffffffffffffffff811115610b0e57610b0d61054f565b5b610b1a8b828c01610a2f565b9450945050608089013567ffffffffffffffff811115610b3d57610b3c61054f565b5b610b498b828c016105ec565b92509250509295985092959890939650565b610b6481610572565b82525050565b5f602082019050610b7d5f830184610b5b565b92915050565b5f805f805f8060a08789031215610b9d57610b9c61054b565b5b5f610baa89828a01610599565b9650506020610bbb89828a01610599565b9550506040610bcc89828a016105cc565b9450506060610bdd89828a016105cc565b935050608087013567ffffffffffffffff811115610bfe57610bfd61054f565b5b610c0a89828a016105ec565b92509250509295509295509295565b610c228161086a565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015610c5f578082015181840152602081019050610c44565b5f8484015250505050565b5f610c7482610c28565b610c7e8185610c32565b9350610c8e818560208601610c42565b610c97816108a1565b840191505092915050565b5f606082019050610cb55f830186610b5b565b610cc26020830185610c19565b8181036040830152610cd48184610c6a565b9050949350505050565b5f81905092915050565b5f610cf282610c28565b610cfc8185610cde565b9350610d0c818560208601610c42565b80840191505092915050565b5f610d238284610ce8565b915081905092915050565b610d378161078b565b8114610d41575f80fd5b50565b5f81519050610d5281610d2e565b92915050565b5f60208284031215610d6d57610d6c61054b565b5b5f610d7a84828501610d44565b9150509291505056fea264697066735822122079a2b495dc3da197ff64bc2f601bc2ea89b1704c035aaebb9e4a19d8e71f691064736f6c63430008160033","nonce":"0x0","to":"0x0000000000000000000000021169100EeCB7c1a6","transactionIndex":"0x0","value":"0x0","type":"0x0","chainId":"0x221","v":"0xff","r":"0x20000000000000000","s":"0x4"},{"blockHash":"0xeb191543781648213ff4cf03616683acbb2ce4bae2c484b5e8a1e4943aeeb1ac","blockNumber":"0x32d","from":"0x0000000000000000000000010000000000000000","gas":"0x5b04","gasPrice":"0x0","hash":"0xa3f874f915db6a32a4d60f5a99f2b43503f62f7f6df73d9c21c2881e178ffe2a","input":"0x","nonce":"0x0","to":"0x0000000000000000000000021169100EeCB7c1a6","transactionIndex":"0x1","value":"0x2540be400","type":"0x0","chainId":"0x221","v":"0xff","r":"0x10000000000000000","s":"0x1"}],"uncles":[],"mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","baseFeePerGas":"0x0"}}
infsaulo commented 3 weeks ago

Thank you @sideninja