Skip to content

feat: added disable-code-size-limit flag in forge script #10661

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

Merged
Merged
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
21 changes: 21 additions & 0 deletions crates/script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ pub struct ScriptArgs {
#[arg(long)]
pub non_interactive: bool,

/// Disables the contract size limit during script execution.
#[arg(long)]
pub disable_code_size_limit: bool,

/// The Etherscan (or equivalent) API key
#[arg(long, env = "ETHERSCAN_API_KEY", value_name = "KEY")]
pub etherscan_api_key: Option<String>,
Expand Down Expand Up @@ -401,6 +405,11 @@ impl ScriptArgs {
known_contracts: &ContractsByArtifact,
create2_deployer: Address,
) -> Result<()> {
// If disable-code-size-limit flag is enabled then skip the size check
if self.disable_code_size_limit {
return Ok(())
}

// (name, &init, &deployed)[]
let mut bytecodes: Vec<(String, &[u8], &[u8])> = vec![];

Expand Down Expand Up @@ -709,6 +718,18 @@ mod tests {
assert_eq!(config.etherscan_api_key, Some("goerli".to_string()));
}

#[test]
fn can_disable_code_size_limit() {
let args =
ScriptArgs::parse_from(["foundry-cli", "Contract.sol", "--disable-code-size-limit"]);
assert!(args.disable_code_size_limit);

let result = ScriptResult::default();
let contracts = ContractsByArtifact::default();
let create = Address::ZERO;
assert!(args.check_contract_sizes(&result, &contracts, create).is_ok());
}

#[test]
fn can_parse_verifier_url() {
let args = ScriptArgs::parse_from([
Expand Down