-
Notifications
You must be signed in to change notification settings - Fork 184
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
[EVM] Handle EVM errors #5216
[EVM] Handle EVM errors #5216
Conversation
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!
|
||
func (e EVMError) IsUserError() {} |
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.
So is this the missing part ?
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.
Basically, this makes it conform to the type of Cadence User Error which doesn't contain the stack and is handled gracefully.
Now we could maybe even go further and adding an EVM error type in Cadence handling which I think could be even nicer way to go, but this solves it for now and we can add it to the todo if you think so?
I think we need 3 tests
|
Ok, will add these tests as well. |
In the basement where the EVM is 😆 |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5216 +/- ##
==========================================
- Coverage 56.55% 56.35% -0.21%
==========================================
Files 988 994 +6
Lines 94422 94810 +388
==========================================
+ Hits 53403 53427 +24
- Misses 37054 37408 +354
- Partials 3965 3975 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
fvm/fvm_test.go
Outdated
// evmErrorSnapshot will return an error once it gets to reading the EVM | ||
// registers for address allocator, that way we can at that point return a provided | ||
// error, that error type is then checked against the provider checker. | ||
type evmErrorSnapshot struct { | ||
snapshotTree snapshot.SnapshotTree | ||
err error | ||
errChecker func(error) bool | ||
} | ||
|
||
func (s evmErrorSnapshot) Get( | ||
id flow.RegisterID, | ||
) ( | ||
flow.RegisterValue, | ||
error, | ||
) { | ||
if id.Key == "AddressAllocator" { | ||
return nil, s.err | ||
} | ||
|
||
return s.snapshotTree.Get(id) |
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.
hmm, I guess there should be a MockedSnapshot somewhere either created by mockery or implemented with func methods, If it doesn't exist we should create it in my view, that way we have more clear tests that are not dependent on a logic outside of the test.
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.
@janezpodhostnik do you know if we have one ?
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.
I agree on the approach. I've checked before for existing ones but only found, one in accounts that is just an implementation for tests here
Line 22 in f17e073
type errorOnAddressSnapshotWrapper struct { |
flow-go/cmd/util/ledger/util/util.go
Line 67 in 0596ab0
type PayloadSnapshot struct { |
So will generate one with mockery for now.
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.
@ramtinms fixed
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!
Closes: #5149
This PR adds a type of EVMError that satisfies the UserError which is handled by Cadence at the same time embedding the CodedError.
The error output now looks like: