diff --git a/contracts/script/deploy/v3.0.0-rc4/SP1VerifierGroth16.s.sol b/contracts/script/deploy/v3.0.0-rc4/SP1VerifierGroth16.s.sol new file mode 100644 index 0000000..5878026 --- /dev/null +++ b/contracts/script/deploy/v3.0.0-rc4/SP1VerifierGroth16.s.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import {BaseScript} from "../../utils/Base.s.sol"; +import {SP1Verifier} from "../../../src/v3.0.0-rc4/SP1VerifierGroth16.sol"; +import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol"; +import {ISP1VerifierWithHash} from "../../../src/ISP1Verifier.sol"; + +contract SP1VerifierScript is BaseScript { + string internal constant KEY = "V3_0_0_RC4_SP1_VERIFIER_GROTH16"; + + function run() external multichain(KEY) broadcaster { + // Read config + bytes32 CREATE2_SALT = readBytes32("CREATE2_SALT"); + address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY"); + + // Deploy contract + address verifier = address(new SP1Verifier{salt: CREATE2_SALT}()); + + // Add the verifier to the gateway + SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY); + gateway.addRoute(verifier); + + // Write address + writeAddress(KEY, verifier); + } + + function freeze() external multichain(KEY) broadcaster { + // Read config + address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY"); + address SP1_VERIFIER = readAddress(KEY); + + // Freeze the verifier on the gateway + SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY); + bytes4 selector = bytes4(ISP1VerifierWithHash(SP1_VERIFIER).VERIFIER_HASH()); + gateway.freezeRoute(selector); + } +} diff --git a/contracts/script/deploy/v3.0.0-rc4/SP1VerifierPlonk.s.sol b/contracts/script/deploy/v3.0.0-rc4/SP1VerifierPlonk.s.sol new file mode 100644 index 0000000..cc37bdf --- /dev/null +++ b/contracts/script/deploy/v3.0.0-rc4/SP1VerifierPlonk.s.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import {BaseScript} from "../../utils/Base.s.sol"; +import {SP1Verifier} from "../../../src/v3.0.0-rc4/SP1VerifierPlonk.sol"; +import {SP1VerifierGateway} from "../../../src/SP1VerifierGateway.sol"; +import {ISP1VerifierWithHash} from "../../../src/ISP1Verifier.sol"; + +contract SP1VerifierScript is BaseScript { + string internal constant KEY = "V3_0_0_RC4_SP1_VERIFIER_PLONK"; + + function run() external multichain(KEY) broadcaster { + // Read config + bytes32 CREATE2_SALT = readBytes32("CREATE2_SALT"); + address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY"); + + // Deploy contract + address verifier = address(new SP1Verifier{salt: CREATE2_SALT}()); + + // Add the verifier to the gateway + SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY); + gateway.addRoute(verifier); + + // Write address + writeAddress(KEY, verifier); + } + + function freeze() external multichain(KEY) broadcaster { + // Read config + address SP1_VERIFIER_GATEWAY = readAddress("SP1_VERIFIER_GATEWAY"); + address SP1_VERIFIER = readAddress(KEY); + + // Freeze the verifier on the gateway + SP1VerifierGateway gateway = SP1VerifierGateway(SP1_VERIFIER_GATEWAY); + bytes4 selector = bytes4(ISP1VerifierWithHash(SP1_VERIFIER).VERIFIER_HASH()); + gateway.freezeRoute(selector); + } +} diff --git a/src/bin/artifacts.rs b/src/bin/artifacts.rs index ca0ee32..f48feb0 100644 --- a/src/bin/artifacts.rs +++ b/src/bin/artifacts.rs @@ -44,5 +44,53 @@ fn main() -> Result<()> { contracts_src_dir.display() ); + // Copy deployment scripts from v2.0.0 to {SP1_CIRCUIT_VERSION} + let source_deploy_dir = PathBuf::from("contracts/script/deploy/v2.0.0"); + let target_deploy_dir = PathBuf::from(format!("contracts/script/deploy/{}", SP1_CIRCUIT_VERSION)); + create_dir_all(&target_deploy_dir)?; + + for entry in read_dir(source_deploy_dir)? { + let entry = entry?; + let source_path = entry.path(); + if source_path.is_file() { + let file_name = source_path.file_name().unwrap(); + let target_path = target_deploy_dir.join(file_name); + std::fs::copy(&source_path, &target_path)?; + + // Modify SP1VerifierGroth16.s.sol + if file_name == "SP1VerifierGroth16.s.sol" { + let mut content = String::from_utf8(read(&target_path)?)?; + content = content.replace( + "import {SP1Verifier} from \"../../../src/v2.0.0/SP1VerifierGroth16.sol\";", + &format!("import {{SP1Verifier}} from \"../../../src/{}/SP1VerifierGroth16.sol\";", SP1_CIRCUIT_VERSION) + ); + content = content.replace( + "string internal constant KEY = \"V2_0_0_SP1_VERIFIER_GROTH16\";", + &format!("string internal constant KEY = \"{}_SP1_VERIFIER_GROTH16\";", SP1_CIRCUIT_VERSION.replace(".", "_").replace("-", "_").to_uppercase()) + ); + write(&target_path, content)?; + } + + // Modify SP1VerifierPlonk.s.sol + if file_name == "SP1VerifierPlonk.s.sol" { + let mut content = String::from_utf8(read(&target_path)?)?; + content = content.replace( + "import {SP1Verifier} from \"../../../src/v2.0.0/SP1VerifierPlonk.sol\";", + &format!("import {{SP1Verifier}} from \"../../../src/{}/SP1VerifierPlonk.sol\";", SP1_CIRCUIT_VERSION) + ); + content = content.replace( + "string internal constant KEY = \"V2_0_0_SP1_VERIFIER_PLONK\";", + &format!("string internal constant KEY = \"{}_SP1_VERIFIER_PLONK\";", SP1_CIRCUIT_VERSION.replace(".", "_").replace("-", "_").to_uppercase()) + ); + write(&target_path, content)?; + } + } + } + + println!( + "Copied and updated deployment scripts to {}", + target_deploy_dir.display() + ); + Ok(()) }