ChainSafe / forest

🌲 Rust Filecoin Node Implementation
https://forest.chainsafe.io
Apache License 2.0
623 stars 149 forks source link

feat(rpc): improve failure messages for `Filecoin.EthEstimateGas` #4554

Open hanabi1224 opened 1 month ago

hanabi1224 commented 1 month ago

Issue summary

Lotus uses some Filecoin.EthCall functionalities that have yet to be implemented in forest to make the failure messages more user-friendly for Filecoin.EthEstimateGas. We should close the gap once Filecoin.EthCall is implemented e.g.

2024-07-17T14:53:44.6298673Z | Filecoin.EthEstimateGas                           | Rejected("Message has no gas limit set")                                                            | Rejected("failed to estimate gas: message execution failed: exit 33, revert reason: 0x5416eb985904247900000000000000000000000000000000000000000000000000000000, vm error: message failed with backtrace:\n00: f0131541 (method 3844450837) -- contract reverted (33)\n (RetCode=33)") |
2024-07-17T14:53:44.6304762Z | Filecoin.EthEstimateGas                           | Rejected("Message has no gas limit set")                                                            | Rejected("failed to estimate gas: message execution failed: exit 33, revert reason: none, vm error: message failed with backtrace:\n00: f0120962 (method 3844450837) -- contract reverted (33)\n (RetCode=33)")                                                                       |
2024-07-17T14:53:44.6310764Z | Filecoin.EthEstimateGas (3)                       | Rejected("Message has no gas limit set")                                                            | Rejected("failed to estimate gas: message execution failed: exit ErrUnhandledMessage(22), revert reason: none, vm error: message failed with backtrace:\n00: f017387 (method 3844450837) -- invalid method: 3844450837 (22)\n (RetCode=22)")                                          |

Other information and links

LesnyRumcajs commented 1 month ago

There's also an interesting case where Forest fails with deserialisation error:

❯ curl -s -X POST 127.0.0.1:2345/rpc/v1 \
           -H 'Content-Type: application/json' \
        --data '{"id": 4, "jsonrpc": "2.0", "method": "eth_estimateGas", "params": [{"accessList": [], "data": "somedata", "from": "someaddress", "maxFeePerGas": "0x186a0", "maxPriorityFeePerGas": "0x186a0", "nonce": "0x25e2", "to": "someaddress", "type": "0x02"}]}'

{"jsonrpc":"2.0","id":4,"error":{"code":-32602,"message":"error deserializing parameter","data":{"error":"missing field `gas`","index":0,"name":"tx","type":"forest_filecoin::lotus_json::LotusJson<forest_filecoin::rpc::methods::eth::types::EthCallMessage>"}}}⏎

while Lotus fails on something else:

❯ curl -s -X POST 127.0.0.1:1234/rpc/v1 \
           -H 'Content-Type: application/json' \
        --data '{"id": 4, "jsonrpc": "2.0", "method": "eth_estimateGas", "params": [{"accessList": [], "data": "somedata", "from": "someaddress", "maxFeePerGas": "0x186a0", "maxPriorityFeePerGas": "0x186a0", "nonce": "0x25e2", "to": "someaddress", "type": "0x02"}]}'

{"error":{"code":1,"message":"failed to estimate gas: message execution failed: exit 33, revert reason: 0xdd88982f, vm error: message failed with backtrace:\n00: f0134698 (method 3844450837) -- contract reverted (33)\n01: f0134698 (method 6) -- contract reverted (33)\n (RetCode=33)"},"id":4,"jsonrpc":"2.0"}

This might be related to the fact that this structure in Lotus gets deserialised first with some non-trivial logic behind it.

Note that the request might be malformed in some way.