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

feat(cli): add cannon trace command #455

Merged
merged 9 commits into from
Sep 16, 2023
Merged

feat(cli): add cannon trace command #455

merged 9 commits into from
Sep 16, 2023

Conversation

dbeal-eth
Copy link
Contributor

implements cannon trace, which allows for the generation of a stack
trace
of any transaction on chain, or a specified transaction code
offchain.

the cannon trace command works similar to the cannon decode command.
Simply supply a package name and hex string.

can be used to decode any transaction already on chain by submitting the
transaction has as the hex string. The exact parameters under which the
original transaction executed will be accomodated in the simulation to
ensure that the result is exactly the same as its original circumstance
(individual fields, such as from or block, can be overridden if
desired)

alternatively, if the transaction isnt submitted on-chain or you want to
trace a read-only call, supply the exact call data of the transaction
you want to execute. Cannon will auto-detect the contract to send the
call to and submit the transaction automatically. To override the
destination contract (as well as other options such as value or
from), those values can be supplied as needed.

implements `cannon trace`, which allows for the generation of a **stack
trace** of *any* transaction on chain, or a specified transaction code
offchain.

the cannon trace command works similar to the `cannon decode` command.
Simply supply a package name and hex string.

can be used to decode any transaction already on chain by submitting the
transaction has as the hex string. The exact parameters under which the
original transaction executed will be accomodated in the simulation to
ensure that the result is exactly the same as its original circumstance
(individual fields, such as `from` or `block`, can be overridden if
desired)

alternatively, if the transaction isnt submitted on-chain or you want to
trace a *read-only* call, supply the exact call data of the transaction
you want to execute. Cannon will auto-detect the contract to send the
call to and submit the transaction automatically. To override the
destination contract (as well as other options such as `value` or
`from`), those values can be supplied as needed.
@dbeal-eth dbeal-eth self-assigned this Sep 14, 2023
@dbeal-eth dbeal-eth changed the title add cannon trace command feat(cli): add cannon trace command Sep 14, 2023
@nx-cloud
Copy link

nx-cloud bot commented Sep 14, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 6c4664d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@dbeal-eth
Copy link
Contributor Author

a good sample transaction is $CANNON trace --chain-id 10 synthetix-omnibus:3.2.0 0x82f57c8019d760ddca14f1c69bb3fbeb21ba09c7fcd01a13d84a686524ef1e0f

image

@dbeal-eth
Copy link
Contributor Author

a good example of simulating a transaction which is not on chain (ex. a view function call) is node packages/cli/dist/bin/cannon.js trace --chain-id 10 synthetix-omnibus 0x2fb8ff2400000000000000000000000000000000000000000000000000000000000000010000000000000000000000008700daec35af8ff88c16bdf0418774cb3d7599b4 -t 0xffffffaEff0B96Ea8e4f94b2253f31abdD875847

image

@dbeal-eth
Copy link
Contributor Author

@noahlitvin wondering if it would be better to make the transaction output look more colorful?

@@ -410,7 +410,6 @@ program
.option('-c --chain-id <chainId>', 'Chain ID of the variant to inspect', '13370')
.option('-p --preset <preset>', 'Preset of the variant to inspect', 'main')
.option('-j --json', 'Output as JSON')
.option('--registry-priority <registry>', 'Priority of the registry to use')
Copy link
Member

Choose a reason for hiding this comment

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

Is this not being used by the inspect?

Copy link
Member

@mjlescano mjlescano left a comment

Choose a reason for hiding this comment

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

super nice

@dbeal-eth dbeal-eth enabled auto-merge (squash) September 16, 2023 01:56
@dbeal-eth dbeal-eth merged commit 177cdbf into main Sep 16, 2023
@dbeal-eth dbeal-eth deleted the cannon-trace branch September 16, 2023 02:00
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.

3 participants