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 response #283

Merged
merged 53 commits into from
Apr 14, 2022
Merged

Dryrun response #283

merged 53 commits into from
Apr 14, 2022

Conversation

barnjamin
Copy link
Contributor

@barnjamin barnjamin commented Jan 31, 2022

API should look something like:

    group = atc.gather_signatures()
    drr = create_dryrun(client, group)
    dr = DryrunResponse(client.dryrun(drr))
    for txn in dr.txns:
        print(txn.app_trace())

and output

#pragma version 6       []
intcblock 1 0 10        []
bytecblock 0xd87699ef   []
txn ApplicationID       [57]
intc_1 // 0             [57, 0]
==                      [0]
bnz label1              []
txn OnCompletion        [0]
pushint 5               [0, 5]
==                      [0]
bnz label2              []
txn OnCompletion        [0]
pushint 4               [0, 4]
...

@barnjamin barnjamin marked this pull request as ready for review January 31, 2022 19:01
@barnjamin barnjamin requested review from ahangsu and tzaffi January 31, 2022 19:02
algosdk/dryrun_results.py Outdated Show resolved Hide resolved
algosdk/dryrun_results.py Outdated Show resolved Hide resolved
algosdk/dryrun_results.py Outdated Show resolved Hide resolved
algosdk/dryrun_results.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

Looks very useful.

I have a couple of suggestions to shorten the code, and some nit-picks that aren't as crucial.

A general question that we should bring up at standup as well: How do we feel about SDK's getting out of sync? I don't believe that this sort of helper functionality exists in any of the other SDK's, and is that ok? I think it should be ok. We may need to signal that this is special to python by having it live in a directory such as extras or goodies ...

@barnjamin
Copy link
Contributor Author

@tzaffi thanks for the review!

I don't believe that this sort of helper functionality exists in any of the other SDK's, and is that ok?

I expect to add it to the rest of them. I like using python as a testing ground for these to see if it makes sense and find a good pattern.

algosdk/dryrun_results.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

LGTM

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 nice improvement, though it would be great if there were at least one unit test.

The code seems very testable, since it does not rely on any REST API calls

Copy link
Contributor

@ahangsu ahangsu left a comment

Choose a reason for hiding this comment

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

looks pretty neat to me (not sure if we want to ensure fields in DryrunTraceLine or DryrunStackValue), waiting on the test cases

@barnjamin
Copy link
Contributor Author

barnjamin commented Feb 5, 2022

Before merging, I want to raise a few more things that may be useful to include.

  1. Some indication in the trace for where the issue originated. Often when looking at a trace I try to find the first line the 0 that fails the program is put on the stack. If we can do that automatically and add a <-- This line G, it might help.
  2. Parsing out the deltas for each Transaction result. At the moment we don't have anything that does this automatically to b64 decode keys/values.
  3. A trivial succeeded type method on the Transaction result that can inspect the app-call-messages or logic-sig-messages for the relevant PASS or REJECT
  4. At the moment the disassembly is ambiguous and if an app call is signed by logic, the app call disassembly will be returned DryrunTransactionResult disassembly field ambiguous go-algorand#3563

@barnjamin
Copy link
Contributor Author

barnjamin commented Feb 5, 2022

I changed the formatting a bit, to add line number, unquote stack values/convert to hex for bytes, and if 0 is passed for spaces use the longest line length.

Curious to hear thoughts on this format instead

30  | store 0                                                                                             [99]
32  | load 0                                                                                              []
33  | pushint 97                                                                                          [99]
34  | >                                                                                                   [99, 97]
35  | bnz label7                                                                                          [1]
39  | load 0                                                                                              []
40  | callsub label8                                                                                      [99]
109 | store 1                                                                                             [99]
110 | load 1                                                                                              []
111 | callsub label14                                                                                     [99]
75  | store 2                                                                                             [99]
76  | load 2                                                                                              []
77  | intc_1 // 0                                                                                         [99]
78  | ==                                                                                                  [99, 0]
79  | bnz label10                                                                                         [0]
80  | load 2                                                                                              []
81  | intc_2 // 10                                                                                        [99]
82  | /                                                                                                   [99, 10]
83  | intc_1 // 0                                                                                         [9]
84  | >                                                                                                   [9, 0]
85  | bnz label11                                                                                         [1]

Makefile Outdated Show resolved Hide resolved
barnjamin and others added 10 commits March 23, 2022 08:22
Co-authored-by: Zeph Grunschlag <[email protected]>
Co-authored-by: Zeph Grunschlag <[email protected]>
Co-authored-by: Zeph Grunschlag <[email protected]>
Co-authored-by: Zeph Grunschlag <[email protected]>
Co-authored-by: Zeph Grunschlag <[email protected]>
Co-authored-by: Zeph Grunschlag <[email protected]>
Co-authored-by: Zeph Grunschlag <[email protected]>
Co-authored-by: Zeph Grunschlag <[email protected]>
Co-authored-by: Zeph Grunschlag <[email protected]>
@jasonpaulos
Copy link
Contributor

Question for @jasonpaulos . This PR (and #298 as well) adds a new package dependency tabulate. Should this be added to our setup.py here?

install_requires=["pynacl", "pycryptodomex>=3.6.0", "msgpack"],

Yes, @barnjamin did this correctly in 8ded7ec

@barnjamin barnjamin requested a review from jasonpaulos March 23, 2022 20:04
Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

LGTM again

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

Successfully merging this pull request may close these issues.

8 participants