diff --git a/crates/l2/contracts/src/l1/OnChainProposer.sol b/crates/l2/contracts/src/l1/OnChainProposer.sol index 8a6f952f0b..4a2d8ef711 100644 --- a/crates/l2/contracts/src/l1/OnChainProposer.sol +++ b/crates/l2/contracts/src/l1/OnChainProposer.sol @@ -179,6 +179,18 @@ contract OnChainProposer is BRIDGE = bridge; } + /// @inheritdoc IOnChainProposer + function upgradeSP1VerificationKey(bytes32 new_vk) public onlyOwner { + SP1_VERIFICATION_KEY = new_vk; + emit VerificationKeyUpgraded("SP1", new_vk); + } + + /// @inheritdoc IOnChainProposer + function upgradeRISC0VerificationKey(bytes32 new_vk) public onlyOwner { + RISC0_VERIFICATION_KEY = new_vk; + emit VerificationKeyUpgraded("RISC0", new_vk); + } + /// @inheritdoc IOnChainProposer function commitBatch( uint256 batchNumber, diff --git a/crates/l2/contracts/src/l1/based/OnChainProposer.sol b/crates/l2/contracts/src/l1/based/OnChainProposer.sol index 98242be151..c2f9522e95 100644 --- a/crates/l2/contracts/src/l1/based/OnChainProposer.sol +++ b/crates/l2/contracts/src/l1/based/OnChainProposer.sol @@ -227,6 +227,18 @@ contract OnChainProposer is BRIDGE = bridge; } + /// @inheritdoc IOnChainProposer + function upgradeSP1VerificationKey(bytes32 new_vk) public onlyOwner { + SP1_VERIFICATION_KEY = new_vk; + emit VerificationKeyUpgraded("SP1", new_vk); + } + + /// @inheritdoc IOnChainProposer + function upgradeRISC0VerificationKey(bytes32 new_vk) public onlyOwner { + RISC0_VERIFICATION_KEY = new_vk; + emit VerificationKeyUpgraded("RISC0", new_vk); + } + /// @inheritdoc IOnChainProposer function commitBatch( uint256 batchNumber, diff --git a/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol b/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol index ee99942dac..07abc3bd9a 100644 --- a/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol +++ b/crates/l2/contracts/src/l1/based/interfaces/IOnChainProposer.sol @@ -23,6 +23,12 @@ interface IOnChainProposer { /// @dev Event emitted when a batch is verified. event BatchVerified(uint256 indexed lastVerifiedBatch); + /// @notice A verification key has been upgraded. + /// @dev Event emitted when a verification key is upgraded. + /// @param verifier The name of the verifier whose key was upgraded. + /// @param newVerificationKey The new verification key. + event VerificationKeyUpgraded(string verifier, bytes32 newVerificationKey); + /// @notice Set the bridge address for the first time. /// @dev This method is separated from initialize because both the CommonBridge /// and the OnChainProposer need to know the address of the other. This solves @@ -30,6 +36,14 @@ interface IOnChainProposer { /// @param bridge the address of the bridge contract. function initializeBridgeAddress(address bridge) external; + /// @notice Upgrades the SP1 verification key that represents the sequencer's code. + /// @param new_vk new verification key for SP1 verifier + function upgradeSP1VerificationKey(bytes32 new_vk) external; + + /// @notice Upgrades the RISC0 verification key that represents the sequencer's code. + /// @param new_vk new verification key for RISC0 verifier + function upgradeRISC0VerificationKey(bytes32 new_vk) external; + /// @notice Commits to a batch of L2 blocks. /// @dev Committing to an L2 batch means to store the batch's commitment /// and to publish withdrawals if any. @@ -75,6 +89,7 @@ interface IOnChainProposer { bytes calldata tdxPublicValues, bytes memory tdxSignature ) external; + // TODO: imageid, programvkey and riscvvkey should be constants // TODO: organize each zkvm proof arguments in their own structs diff --git a/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol b/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol index 149e2ad004..be6696c86d 100644 --- a/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol +++ b/crates/l2/contracts/src/l1/interfaces/IOnChainProposer.sol @@ -27,6 +27,12 @@ interface IOnChainProposer { /// @dev Event emitted when a batch is reverted. event BatchReverted(bytes32 indexed newStateRoot); + /// @notice A verification key has been upgraded. + /// @dev Event emitted when a verification key is upgraded. + /// @param verifier The name of the verifier whose key was upgraded. + /// @param newVerificationKey The new verification key. + event VerificationKeyUpgraded(string verifier, bytes32 newVerificationKey); + /// @notice Set the bridge address for the first time. /// @dev This method is separated from initialize because both the CommonBridge /// and the OnChainProposer need to know the address of the other. This solves @@ -34,6 +40,14 @@ interface IOnChainProposer { /// @param bridge the address of the bridge contract. function initializeBridgeAddress(address bridge) external; + /// @notice Upgrades the SP1 verification key that represents the sequencer's code. + /// @param new_vk new verification key for SP1 verifier + function upgradeSP1VerificationKey(bytes32 new_vk) external; + + /// @notice Upgrades the RISC0 verification key that represents the sequencer's code. + /// @param new_vk new verification key for RISC0 verifier + function upgradeRISC0VerificationKey(bytes32 new_vk) external; + /// @notice Commits to a batch of L2 blocks. /// @dev Committing to an L2 batch means to store the batch's commitment /// and to publish withdrawals if any. @@ -77,6 +91,7 @@ interface IOnChainProposer { bytes calldata tdxPublicValues, bytes memory tdxSignature ) external; + // TODO: imageid, programvkey and riscvvkey should be constants // TODO: organize each zkvm proof arguments in their own structs