-
Notifications
You must be signed in to change notification settings - Fork 492
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
AVM: Improve error handling and execution time #3612
Conversation
f6a0068
to
c24bb1f
Compare
Codecov Report
@@ Coverage Diff @@
## master #3612 +/- ##
==========================================
+ Coverage 49.76% 49.84% +0.08%
==========================================
Files 392 392
Lines 68766 68670 -96
==========================================
+ Hits 34219 34227 +8
+ Misses 30785 30690 -95
+ Partials 3762 3753 -9
Continue to review full report at Codecov.
|
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.
Looks good, couple suggestions/questions
@@ -656,7 +641,7 @@ func eval(program []byte, cx *EvalContext) (pass bool, err error) { | |||
defer func() { | |||
// Ensure we update the debugger before exiting | |||
if cx.Debugger != nil { | |||
errDbg := cx.Debugger.Complete(cx.refreshDebugState()) | |||
errDbg := cx.Debugger.Complete(cx.refreshDebugState(err)) |
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.
looks like this is the only where refreshDebugState receives non-nil err
, on other two cases below they are would not be even called if err != nil. So maybe
errDbg := cx.Debugger.Complete(cx.refreshDebugState(err)) | |
ds := cx.refreshDebugState() | |
ds.Error = err | |
errDbg := cx.Debugger.Complete(ds) |
last := len(cx.stack) - 1 // value | ||
prev := last - 1 // state key | ||
pprev := prev - 1 // account | ||
|
||
sv := cx.stack[last] | ||
key := string(cx.stack[prev].Bytes) | ||
|
||
if cx.Ledger == nil { |
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 understand this is a repetitive check... is it prereq 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.
Yes, EvalContract
does the check when first entering stateful evaluation, so it seems pointless to keep checking it in the stateful ops.
Also some benchmarks that show relative costs for the CPU part of processing transactions
cx.Ledger !=nil is checked in EvalContract(). There's no reason to check it again in stateful teal ops.
Tests more opcodes, including branches and others that have not return values. Automates handling of more opcodes by understanding immediate arguments. Fixes the ordering of return value testing.
a456fc5
to
47f54b2
Compare
…refactor Refactor TestReturnTypes to generate a test case for each opcode
Co-authored-by: Michael Diamant <[email protected]>
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.
@jannotti I'm leaving approval with the following notes:
- I most closely reviewed renames and changes to
data/transactions/logic/evalStateful_test.go
. - I scanned other changes, but didn't scrutinize all of them. Since I'm new to the codebase, I leave it at your discretion if you believe a 2nd approval is warranted prior to merging.
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.
Changes look good to me, I did another scan of eval.go and didn't find anything problematic
This reworks the opcode function interface to return errors directly instead of setting cx.err which was error-prone.
It also makes a couple small optimizations.