-
Notifications
You must be signed in to change notification settings - Fork 10
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
Crasher on validation of args for eth_estimateGas
#527
Conversation
WalkthroughThe changes enhance the validation logic in the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 3
"create empty contract (nil value)": { | ||
txArgs: TransactionArgs{ | ||
Nonce: (*hexutil.Uint64)(&nonce), | ||
To: nil, | ||
Value: nil, | ||
Gas: (*hexutil.Uint64)(&gasLimit), | ||
GasPrice: (*hexutil.Big)(big.NewInt(0)), | ||
Data: &hexutil.Bytes{}, | ||
}, | ||
valid: false, | ||
errMsg: "transaction will create a contract with empty code", | ||
}, |
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.
Test case for nil value handling is well-implemented.
The test case "create empty contract (nil value)" is correctly set up to validate the handling of transactions with nil
values for the To
field. This aligns with the PR objectives to enhance stability by preventing nil pointer dereferences.
Consider adding more test cases to cover different scenarios where other fields might also be nil
to ensure comprehensive validation coverage.
Would you like me to help draft additional test cases?
@@ -63,7 +63,7 @@ func (txArgs TransactionArgs) Validate() error { | |||
// e.g. https://github.com/onflow/go-ethereum/issues/16106. | |||
if txDataLen == 0 { | |||
// Prevent sending ether into black hole (show stopper) | |||
if txArgs.Value.ToInt().Cmp(big.NewInt(0)) > 0 { | |||
if txArgs.Value != nil && txArgs.Value.ToInt().Cmp(big.NewInt(0)) > 0 { |
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.
Critical nil check added to prevent runtime errors.
The addition of a nil check before comparing the transaction value is a crucial improvement. This change effectively prevents a potential nil pointer dereference, enhancing the robustness of the validation logic.
Consider adding a specific unit test to verify this new validation logic under various scenarios where Value
might be nil or not nil.
Would you like me to help draft this unit test?
"create empty contract (nil value)": { | ||
tx: gethTypes.NewTx( | ||
&gethTypes.LegacyTx{ | ||
Nonce: 1, | ||
To: nil, | ||
Value: nil, | ||
Gas: 53_000, | ||
GasPrice: big.NewInt(0), | ||
Data: []byte{}, | ||
}, | ||
), | ||
valid: false, | ||
errMsg: "transaction will create a contract with empty code", | ||
}, |
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.
Test case for nil value handling is well-implemented.
The test case "create empty contract (nil value)" is correctly set up to validate the handling of transactions with nil
values for the To
field. This aligns with the PR objectives to enhance stability by preventing nil pointer dereferences.
Consider adding more test cases to cover different scenarios where other fields might also be nil
to ensure comprehensive validation coverage.
Would you like me to help draft additional test cases?
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.
Nice work
Closes: #525
Description
Add
nil
check for transactionValue
field.For contributor use:
master
branchFiles changed
in the Github PR explorerSummary by CodeRabbit
New Features
Bug Fixes
Tests