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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/forge/bin/cmd/script/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ impl ScriptArgs {
) -> Result<()> {
trace!(target: "script", "broadcasting single chain deployment");

if self.verify {
deployment_sequence.verify_preflight_check(&script_config.config, &verify)?;
}

let rpc = script_config.total_rpcs.into_iter().next().expect("exists; qed");

deployment_sequence.add_libraries(libraries);
Expand Down
4 changes: 4 additions & 0 deletions crates/forge/bin/cmd/script/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ impl ScriptArgs {
Err(err) => eyre::bail!(err),
};

if self.verify {
deployment_sequence.verify_preflight_check(&script_config.config, &verify)?;
}

receipts::wait_for_pending(provider, &mut deployment_sequence).await?;

if self.resume {
Expand Down
6 changes: 6 additions & 0 deletions crates/forge/bin/cmd/script/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ impl ScriptArgs {
eyre::bail!("Libraries are currently not supported on multi deployment setups.");
}

if self.verify {
for sequence in &deployments.deployments {
sequence.verify_preflight_check(config, &verify)?;
}
}

if self.resume {
trace!(target: "script", "resuming multi chain deployment");

Expand Down
14 changes: 14 additions & 0 deletions crates/forge/bin/cmd/script/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,20 @@ impl ScriptSequence {
Ok((broadcast, cache))
}

/// Checks that there is an Etherscan key for the chain id of this sequence.
pub fn verify_preflight_check(&self, config: &Config, verify: &VerifyBundle) -> Result<()> {
if config.get_etherscan_api_key(Some(self.chain.into())).is_none() &&
verify.verifier.verifier == VerificationProviderType::Etherscan
{
eyre::bail!(
"Etherscan API key wasn't found for chain id {}. On-chain execution aborted",
self.chain
)
}

Ok(())
}

/// Given the broadcast log, it matches transactions with receipts, and tries to verify any
/// created contract on etherscan.
pub async fn verify_contracts(
Expand Down