Skip to content
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

Dryrun: Return EvalDeltas for failed executions in Dryrun #3929

Merged
merged 15 commits into from
May 13, 2022

Conversation

algochoi
Copy link
Contributor

@algochoi algochoi commented Apr 27, 2022

Summary

This PR returns the EvalDelta for stateful evaluation, regardless of whether it succeeds or not. This allows users to check the EvalDelta even for failed dryrun execution.

Closes #2687 .

Test Plan

Added unit tests for dryrun:

  • Check global deltas match the expected deltas when dryrun fails
  • Check local deltas match the expected deltas when dryrun fails

@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2022

Codecov Report

Merging #3929 (a6518ae) into master (bd18d04) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3929   +/-   ##
=======================================
  Coverage   49.79%   49.79%           
=======================================
  Files         409      409           
  Lines       69145    69147    +2     
=======================================
+ Hits        34429    34430    +1     
+ Misses      30997    30996    -1     
- Partials     3719     3721    +2     
Impacted Files Coverage Δ
daemon/algod/api/server/v2/dryrun.go 70.31% <100.00%> (+0.18%) ⬆️
ledger/blockqueue.go 82.18% <0.00%> (-2.88%) ⬇️
data/transactions/verify/txn.go 44.15% <0.00%> (-0.87%) ⬇️
ledger/acctupdates.go 68.77% <0.00%> (-0.66%) ⬇️
ledger/tracker.go 74.45% <0.00%> (+1.29%) ⬆️
network/wsPeer.go 68.05% <0.00%> (+2.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd18d04...a6518ae. Read the comment docs.

Copy link
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how strongly I feel about my objexction. The patch is so small, I really like that. I don't actually see the work being done - is that because it just naturally falls out that if the eval delta is built, it gets serialized out to caller?

daemon/algod/api/server/v2/dryrun_test.go Outdated Show resolved Hide resolved
ledger/internal/appcow.go Outdated Show resolved Hide resolved
@algochoi algochoi marked this pull request as ready for review April 28, 2022 22:17
@algochoi algochoi requested a review from jasonpaulos April 28, 2022 22:17
Copy link
Contributor

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good improvement to me, I only have minor comments about some test semantics.

Higher level question: have you considered comparing the msgpack or json encoded deltas instead of diving into the individual fields? That might be a way to get nearly the same equality confidence without as much code.

daemon/algod/api/server/v2/dryrun_test.go Outdated Show resolved Hide resolved
daemon/algod/api/server/v2/dryrun_test.go Outdated Show resolved Hide resolved
jasonpaulos
jasonpaulos previously approved these changes Apr 29, 2022
Copy link
Contributor

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good but please fix the exceed license header

daemon/algod/api/server/v2/dryrun_test.go Outdated Show resolved Hide resolved
@jannotti
Copy link
Contributor

jannotti commented May 5, 2022 via email

@algoidurovic
Copy link
Contributor

In many cases it's to distinguish 0 from "empty" so the REST api can marshall it properly.

On Thu, May 5, 2022 at 11:08 AM algoidurovic @.> wrote: @.* commented on this pull request. ------------------------------ In daemon/algod/api/server/v2/dryrun_test.go <#3929 (comment)>: > @@ -1634,3 +1656,148 @@ int 1`) logResponse(t, &response) } } + +func checkStateDelta(t *testing.T, + response *generated.StateDelta, + expectedDelta *generated.StateDelta, +) { + for i, vd := range *response { + assert.Equal(t, (*expectedDelta)[i].Key, vd.Key) + + // Pointer checks: make sure we don't try to derefence a nil. + if (*expectedDelta)[i].Value.Bytes == nil { + assert.Nil(t, vd.Value.Bytes) + } else { + assert.NotNil(t, vd.Value.Bytes) + assert.Equal(t, (expectedDelta)[i].Value.Bytes, vd.Value.Bytes) This seems to be appear consistently in this file -- so I don't necessarily have a problem with you following the same convention -- but I don't understand why we're using pointers everywhere. Afaict, most uses don't need to be pointers, especially with slice types like generated.StateDelta. — Reply to this email directly, view it on GitHub <#3929 (review)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADL7T2TTMCVVBSSYOW6MQLVIPP6LANCNFSM5UQNQM6Q . You are receiving this because you commented.Message ID: @.>

Makes sense. I think this doesn't apply to all the uses of pointers in this PR but the pattern is prevalent enough that I don't take issue with it. I just generally try to avoid syntax like *(*ptr)[i]... if it isn't necessary but this is optional and shouldn't hold up the PR.

algoidurovic
algoidurovic previously approved these changes May 5, 2022
Copy link
Contributor

@algoidurovic algoidurovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@algochoi algochoi requested a review from jannotti May 9, 2022 20:29
Comment on lines 1663 to 1664
assert.Equal(t, len(ld.Delta), len(expectedLocalDelta.Delta))
assert.Equal(t, ld.Delta, expectedLocalDelta.Delta)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably confused the issue by mentioning length, but now that you use assert.Equal, you don't need the length check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching, should be deleted in the latest commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return EvalDelta info for rejected app calls during dryrun
6 participants