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

Add verify_preflight_check for script sequences #6372

Merged
merged 4 commits into from
Nov 28, 2023

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Nov 20, 2023

Motivation

Closes #6368

Solution

Adds ScriptSequence::verify_preflight_check method which is being called between on-chain simulation and actual transactions broadcasting in cases when self.verify == true.

The same naming is used in forge create CreateArgs::verify_preflight_check so it might make sense to change it, but I didn't figure out another suitable name for it.

This might break some scenarios when --verify flag is used for multichain deployments when only subset of chains support etherscan verification.

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

this now only deploys with --verify and all used chains have a valid etherscan API key.

I think this is reasonable.

wdyt @mds1

crates/forge/bin/cmd/script/sequence.rs Outdated Show resolved Hide resolved
@klkvr
Copy link
Member Author

klkvr commented Nov 21, 2023

@mattsse did CI failed because of my code? I don't understand what exactly have happened there

upd: rebased

@mds1
Copy link
Collaborator

mds1 commented Nov 21, 2023

Previous behavior: If no etherscan API key was set but user specified to verify, verification was silently skipped and everything else proceeds as normal

New behavior: If no etherscan API key was set but user specified to verify, forge will exit with an error after the simulation but before broadcasting.

Is that correct? If so sgtm, but may be better UX to fail fast before simulation?

@klkvr
Copy link
Member Author

klkvr commented Nov 21, 2023

@mds1 Yes, that's correct

To make it fail before simulation the implementation would have to be less cleaner, because the logic will be different for newly created and resumed scripts. I would be happy to improve it that way, but considering that on-chain simulation usually doesn't take much time (usually less than script execution which will run anyway) it may not be really needed.

btw I have been testing it for multichain scripts and #5047 seems to be the case. Is there any working example of --resume --multi? I am always getting panic to have been filled with a proper rpc

@klkvr
Copy link
Member Author

klkvr commented Nov 22, 2023

Also, in case when script fails because of missing etherscan key, transactions are getting saved into ./broadcast and can be restarted via --resume, thus skipping both simulation and execution which wouldn't be possible if it failed before simulation.

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

lgtm—i think it's reasonable to include this. cc @mattsse for merging unless we haven't settled on the ux discussion on when to fail?

@mds1
Copy link
Collaborator

mds1 commented Nov 27, 2023

To make it fail before simulation the implementation would have to be less cleaner, because the logic will be different for newly created and resumed scripts. I would be happy to improve it that way, but considering that on-chain simulation usually doesn't take much time (usually less than script execution which will run anyway) it may not be really needed.

Got it, this seems ok to me then. @Evalir @mattsse if scripting ever gets refactored moving this to fail earlier is a nice UX change to implement if you want to track that somewhere (I've definitely had some scripts that can take 30+ seconds to simulate due to lots of RPC calls)

@mattsse mattsse merged commit 4a5785a into foundry-rs:master Nov 28, 2023
19 checks passed
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.

forge script --verify skips verification silently if etherscan API key is not provided
4 participants