-
Notifications
You must be signed in to change notification settings - Fork 14
Properly handle execution reverts in eth_call JSON-RPC endpoint
#297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
756a149
a1ee6d6
fc01c99
90d72ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 60806040526105395f819055506102ef806100195f395ff3fe608060405234801561000f575f80fd5b506004361061003f575f3560e01c80632e64cec1146100435780636057361d146100615780639967062d1461007d575b5f80fd5b61004b6100ad565b6040516100589190610140565b60405180910390f35b61007b60048036038101906100769190610187565b6100b5565b005b610097600480360381019061009291906101e5565b6100be565b6040516100a49190610232565b60405180910390f35b5f8054905090565b805f8190555050565b5f8082846100cc9190610278565b905082843373ffffffffffffffffffffffffffffffffffffffff167f76efea95e5da1fa661f235b2921ae1d89b99e457ec73fb88e34a1d150f95c64b846040516101169190610232565b60405180910390a48091505092915050565b5f819050919050565b61013a81610128565b82525050565b5f6020820190506101535f830184610131565b92915050565b5f80fd5b61016681610128565b8114610170575f80fd5b50565b5f813590506101818161015d565b92915050565b5f6020828403121561019c5761019b610159565b5b5f6101a984828501610173565b91505092915050565b5f819050919050565b6101c4816101b2565b81146101ce575f80fd5b50565b5f813590506101df816101bb565b92915050565b5f80604083850312156101fb576101fa610159565b5b5f610208858286016101d1565b9250506020610219858286016101d1565b9150509250929050565b61022c816101b2565b82525050565b5f6020820190506102455f830184610223565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610282826101b2565b915061028d836101b2565b92508282019050828112155f8312168382125f8412151617156102b3576102b261024b565b5b9291505056fea2646970667358221220779e5ebf0029c96ff1052d01469f01b453ddceda76901a9b6e730cabbb85be8264736f6c63430008190033 | ||
| 60806040526105395f819055506104c9806100195f395ff3fe608060405234801561000f575f80fd5b5060043610610055575f3560e01c80632e64cec1146100595780636057361d146100775780639967062d14610093578063cbaff5f9146100c3578063dda3a7bd146100cd575b5f80fd5b6100616100d7565b60405161006e91906101ea565b60405180910390f35b610091600480360381019061008c9190610231565b6100df565b005b6100ad60048036038101906100a8919061028f565b6100e8565b6040516100ba91906102dc565b60405180910390f35b6100cb610152565b005b6100d5610194565b005b5f8054905090565b805f8190555050565b5f8082846100f69190610322565b905082843373ffffffffffffffffffffffffffffffffffffffff167f76efea95e5da1fa661f235b2921ae1d89b99e457ec73fb88e34a1d150f95c64b8460405161014091906102dc565b60405180910390a48091505092915050565b5f610192576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610189906103bd565b60405180910390fd5b565b60056040517f9195785a0000000000000000000000000000000000000000000000000000000081526004016101c99190610467565b60405180910390fd5b5f819050919050565b6101e4816101d2565b82525050565b5f6020820190506101fd5f8301846101db565b92915050565b5f80fd5b610210816101d2565b811461021a575f80fd5b50565b5f8135905061022b81610207565b92915050565b5f6020828403121561024657610245610203565b5b5f6102538482850161021d565b91505092915050565b5f819050919050565b61026e8161025c565b8114610278575f80fd5b50565b5f8135905061028981610265565b92915050565b5f80604083850312156102a5576102a4610203565b5b5f6102b28582860161027b565b92505060206102c38582860161027b565b9150509250929050565b6102d68161025c565b82525050565b5f6020820190506102ef5f8301846102cd565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61032c8261025c565b91506103378361025c565b92508282019050828112155f8312168382125f84121516171561035d5761035c6102f5565b5b92915050565b5f82825260208201905092915050565b7f417373657274204572726f72204d6573736167650000000000000000000000005f82015250565b5f6103a7601483610363565b91506103b282610373565b602082019050919050565b5f6020820190508181035f8301526103d48161039b565b9050919050565b5f819050919050565b5f819050919050565b5f6104076104026103fd846103db565b6103e4565b6101d2565b9050919050565b610417816103ed565b82525050565b7f56616c756520697320746f6f206c6f77000000000000000000000000000000005f82015250565b5f610451601083610363565b915061045c8261041d565b602082019050919050565b5f60408201905061047a5f83018461040e565b818103602083015261048b81610445565b90509291505056fea26469706673582212206c2b15d7949b146ae0403a2d44e0ed089f2af31511d01e1126d557a83708e1c464736f6c634300081a0033 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification The verification process indicates that the bytecode in
To proceed, you should manually verify the bytecode by ensuring the Solidity compiler is installed in your environment and then re-running the compilation and comparison steps. Analysis chainPlease verify that the bytecode corresponds to the latest version of the smart contract source code, including the new functions and custom error handling. Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that the bytecode corresponds to the smart contract source code.
# Compile the smart contract source code and compare the bytecode.
echo "Compile the smart contract from 'storage.sol' and ensure the bytecode matches."
Length of output: 172 Script: #!/bin/bash
# Description: Verify that the bytecode corresponds to the smart contract source code.
# Step 1: Locate the storage.sol file
storage_sol=$(fd storage.sol)
# Step 2: Compile the storage.sol file to generate the bytecode
compiled_bytecode=$(solc --optimize --bin "$storage_sol" | tail -n 1)
# Step 3: Read the bytecode from tests/fixtures/storage.byte
fixture_bytecode=$(cat tests/fixtures/storage.byte)
# Step 4: Compare the generated bytecode with the bytecode in tests/fixtures/storage.byte
if [ "$compiled_bytecode" == "$fixture_bytecode" ]; then
echo "The bytecode matches the latest version of the smart contract source code."
else
echo "The bytecode does not match the latest version of the smart contract source code."
fi
Length of output: 5461 Script: #!/bin/bash
# Description: Verify that the bytecode corresponds to the smart contract source code.
# Step 1: Ensure the Solidity compiler is installed
if ! command -v solc &> /dev/null; then
echo "Solidity compiler not found. Installing..."
sudo apt-get update && sudo apt-get install -y solc
fi
# Step 2: Locate the storage.sol file
storage_sol=$(fd storage.sol)
# Step 3: Compile the storage.sol file to generate the bytecode
compiled_bytecode=$(solc --optimize --bin "$storage_sol" | tail -n 1)
# Step 4: Read the bytecode from tests/fixtures/storage.byte
fixture_bytecode=$(cat tests/fixtures/storage.byte)
# Step 5: Compare the generated bytecode with the bytecode in tests/fixtures/storage.byte
if [ "$compiled_bytecode" == "$fixture_bytecode" ]; then
echo "The bytecode matches the latest version of the smart contract source code."
else
echo "The bytecode does not match the latest version of the smart contract source code."
fi
Length of output: 5669 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
|
|
||
| pragma solidity >=0.8.2 <0.9.0; | ||
|
|
||
| contract Storage { | ||
| error MyCustomError(uint value, string message); | ||
| event Calculated(address indexed caller, int indexed numA, int indexed numB, int sum); | ||
| uint256 number; | ||
|
|
||
|
|
@@ -21,4 +24,12 @@ contract Storage { | |
| emit Calculated(msg.sender, A, B, s); | ||
| return s; | ||
| } | ||
|
|
||
| function assertError() public pure { | ||
| require(false, "Assert Error Message"); | ||
| } | ||
|
|
||
| function customError() public pure { | ||
| revert MyCustomError(5, "Value is too low"); | ||
| } | ||
|
Comment on lines
+28
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,88 +1,118 @@ | ||
| [ | ||
| { | ||
| "inputs": [], | ||
| "stateMutability": "payable", | ||
| "type": "constructor" | ||
| }, | ||
| { | ||
| "anonymous": false, | ||
| "inputs": [ | ||
| { | ||
| "indexed": true, | ||
| "internalType": "address", | ||
| "name": "caller", | ||
| "type": "address" | ||
| }, | ||
| { | ||
| "indexed": true, | ||
| "internalType": "int256", | ||
| "name": "numA", | ||
| "type": "int256" | ||
| }, | ||
| { | ||
| "indexed": true, | ||
| "internalType": "int256", | ||
| "name": "numB", | ||
| "type": "int256" | ||
| }, | ||
| { | ||
| "indexed": false, | ||
| "internalType": "int256", | ||
| "name": "sum", | ||
| "type": "int256" | ||
| } | ||
| ], | ||
| "name": "Calculated", | ||
| "type": "event" | ||
| }, | ||
| { | ||
| "inputs": [], | ||
| "name": "retrieve", | ||
| "outputs": [ | ||
| { | ||
| "internalType": "uint256", | ||
| "name": "", | ||
| "type": "uint256" | ||
| } | ||
| ], | ||
| "stateMutability": "view", | ||
| "type": "function" | ||
| }, | ||
| { | ||
| "inputs": [ | ||
| { | ||
| "internalType": "uint256", | ||
| "name": "num", | ||
| "type": "uint256" | ||
| } | ||
| ], | ||
| "name": "store", | ||
| "outputs": [], | ||
| "stateMutability": "nonpayable", | ||
| "type": "function" | ||
| }, | ||
| { | ||
| "inputs": [ | ||
| { | ||
| "internalType": "int256", | ||
| "name": "A", | ||
| "type": "int256" | ||
| }, | ||
| { | ||
| "internalType": "int256", | ||
| "name": "B", | ||
| "type": "int256" | ||
| } | ||
| ], | ||
| "name": "sum", | ||
| "outputs": [ | ||
| { | ||
| "internalType": "int256", | ||
| "name": "", | ||
| "type": "int256" | ||
| } | ||
| ], | ||
| "stateMutability": "nonpayable", | ||
| "type": "function" | ||
| } | ||
| { | ||
| "inputs": [], | ||
| "stateMutability": "payable", | ||
| "type": "constructor" | ||
| }, | ||
| { | ||
| "inputs": [ | ||
| { | ||
| "internalType": "uint256", | ||
| "name": "value", | ||
| "type": "uint256" | ||
| }, | ||
| { | ||
| "internalType": "string", | ||
| "name": "message", | ||
| "type": "string" | ||
| } | ||
| ], | ||
| "name": "MyCustomError", | ||
| "type": "error" | ||
| }, | ||
| { | ||
| "anonymous": false, | ||
| "inputs": [ | ||
| { | ||
| "indexed": true, | ||
| "internalType": "address", | ||
| "name": "caller", | ||
| "type": "address" | ||
| }, | ||
| { | ||
| "indexed": true, | ||
| "internalType": "int256", | ||
| "name": "numA", | ||
| "type": "int256" | ||
| }, | ||
| { | ||
| "indexed": true, | ||
| "internalType": "int256", | ||
| "name": "numB", | ||
| "type": "int256" | ||
| }, | ||
| { | ||
| "indexed": false, | ||
| "internalType": "int256", | ||
| "name": "sum", | ||
| "type": "int256" | ||
| } | ||
| ], | ||
| "name": "Calculated", | ||
| "type": "event" | ||
| }, | ||
| { | ||
| "inputs": [], | ||
| "name": "assertError", | ||
| "outputs": [], | ||
| "stateMutability": "pure", | ||
| "type": "function" | ||
| }, | ||
| { | ||
| "inputs": [], | ||
| "name": "customError", | ||
| "outputs": [], | ||
| "stateMutability": "pure", | ||
| "type": "function" | ||
| }, | ||
| { | ||
| "inputs": [], | ||
| "name": "retrieve", | ||
| "outputs": [ | ||
| { | ||
| "internalType": "uint256", | ||
| "name": "", | ||
| "type": "uint256" | ||
| } | ||
| ], | ||
| "stateMutability": "view", | ||
| "type": "function" | ||
| }, | ||
| { | ||
| "inputs": [ | ||
| { | ||
| "internalType": "uint256", | ||
| "name": "num", | ||
| "type": "uint256" | ||
| } | ||
| ], | ||
| "name": "store", | ||
| "outputs": [], | ||
| "stateMutability": "nonpayable", | ||
| "type": "function" | ||
| }, | ||
| { | ||
| "inputs": [ | ||
| { | ||
| "internalType": "int256", | ||
| "name": "A", | ||
| "type": "int256" | ||
| }, | ||
| { | ||
| "internalType": "int256", | ||
| "name": "B", | ||
| "type": "int256" | ||
| } | ||
| ], | ||
| "name": "sum", | ||
| "outputs": [ | ||
| { | ||
| "internalType": "int256", | ||
| "name": "", | ||
| "type": "int256" | ||
| } | ||
| ], | ||
| "stateMutability": "nonpayable", | ||
| "type": "function" | ||
| } | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
NewRevertErrorfunction should handle the case whereabi.UnpackRevertfails more explicitly.Committable suggestion