-
Notifications
You must be signed in to change notification settings - Fork 332
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
[api] fix revert custom errors and returns the correct revert message in eth_call #3920
Conversation
Kudos, SonarCloud Quality Gate passed!
|
Codecov Report
@@ Coverage Diff @@
## master #3920 +/- ##
==========================================
+ Coverage 75.38% 75.99% +0.61%
==========================================
Files 303 328 +25
Lines 25923 27847 +1924
==========================================
+ Hits 19541 21163 +1622
- Misses 5360 5592 +232
- Partials 1022 1092 +70
... and 8 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
if errUnpack != nil { | ||
reason = "execution reverted" | ||
} | ||
receipt.SetExecutionRevertMsg(reason) |
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.
will cause HF
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.
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.
-
here is only to capture custom errors while keeping the logic unchanged as before.
-
geth’s handling has been moved to the API layer, and making changes here would cause HF, necessitating significant code adjustments.
https://github.com/iotexproject/iotex-core/pull/3920/files#diff-6dc4e8a6418cb4f7e5b7da626b745fb04ff21d7c37b77d883b8c8b9ab7aacfcbR403
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.
geth code
typ, err := NewType("string", "", nil)
if err != nil {
return "", err
}
unpacked, err := (Arguments{{Type: typ}}).Unpack(data[4:])
if err != nil {
return "", err
}
return unpacked[0].(string), nil
I am not 100% sure, if that will be exactly same as our code
data := retval[4:]
msgLength := byteutil.BytesToUint64BigEndian(data[56:64])
revertMsg := string(data[64 : 64+msgLength])
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.
100% sure. if not, the check of ExecutionRevertMsg in tests will not passed
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.
inside L290:
if fCtx.CorrectCustomRevert {
your code in PR
} else if bytes.Equal(retval[:4], _revertSelector) {
current code
}
Description
Returns the correct json when the contract call contains a revert (custom) error
Fixes #3919 #3821
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: