From 88bee140be2c7a30304db29d81fe7dd09de95580 Mon Sep 17 00:00:00 2001 From: Jonathan Cubides Date: Thu, 16 Apr 2026 10:38:39 -0500 Subject: [PATCH] refactor: rename IS_TEST_DEPLOYMENT to DETERMINISTIC_DEPLOYMENT and flip semantics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old name `IS_TEST_DEPLOYMENT` (and Solidity param `isTestDeployment`) was misleading — it implied a test vs. production environment distinction, but the flag actually controls whether the contract is deployed deterministically via CREATE2 with a version-derived salt. Changes: - contracts/script/DeployProtocolAdapter.s.sol: rename param `isTestDeployment` → `deterministic`, swap if/else branches so `if (deterministic)` performs the CREATE2 deploy, update NatSpec accordingly. - contracts/test/DeployProtocolAdapter.t.sol: update named arguments at all call sites (`isTestDeployment: true` → `deterministic: false`, `isTestDeployment: false` → `deterministic: true`); rename test functions to reflect the new semantics (`test_deployment` → `regular_deployment`, `prod_deployment` → `deterministic_deployment`). - contracts/README.md: replace `` placeholder with ``. - justfile: replace `$IS_TEST_DEPLOYMENT` with `$DETERMINISTIC_DEPLOYMENT` in the `contracts-simulate` and `contracts-deploy` recipes. - RELEASE_CHECKLIST.md: replace both occurrences of `export IS_TEST_DEPLOYMENT=false` with `export DETERMINISTIC_DEPLOYMENT=true` and update the surrounding description text. Note: other smart contract projects that adopted the same `IS_TEST_DEPLOYMENT` convention should apply equivalent updates — rename the env var to `DETERMINISTIC_DEPLOYMENT`, flip its boolean value, and update the deployment script so `if (deterministic)` triggers the CREATE2 path. --- RELEASE_CHECKLIST.md | 8 +++--- contracts/README.md | 2 +- contracts/script/DeployProtocolAdapter.s.sol | 28 ++++++++++---------- contracts/test/DeployProtocolAdapter.t.sol | 8 +++--- justfile | 6 ++--- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/RELEASE_CHECKLIST.md b/RELEASE_CHECKLIST.md index 5e481e4e..069a631d 100644 --- a/RELEASE_CHECKLIST.md +++ b/RELEASE_CHECKLIST.md @@ -47,10 +47,10 @@ We distinguish between three release cases: cast wallet import deployer --mnemonic ``` -- [ ] Set `IS_TEST_DEPLOYMENT` to `false` to deterministically deploy the protocol adapter. +- [ ] Set `DETERMINISTIC_DEPLOYMENT` to `true` to deploy the protocol adapter deterministically. ```sh - export IS_TEST_DEPLOYMENT=false + export DETERMINISTIC_DEPLOYMENT=true ``` - [ ] Check that the emergency caller address is set up correctly and export it with @@ -210,10 +210,10 @@ For each chain, you want to deploy to, do the following: cast wallet import deployer --mnemonic ``` -- [ ] Set `IS_TEST_DEPLOYMENT` to `false` to deterministically deploy the protocol adapter. +- [ ] Set `DETERMINISTIC_DEPLOYMENT` to `true` to deploy the protocol adapter deterministically. ```sh - export IS_TEST_DEPLOYMENT=false + export DETERMINISTIC_DEPLOYMENT=true ``` - [ ] Check that the emergency caller address is set up correctly and export it with diff --git a/contracts/README.md b/contracts/README.md index 455fe5e1..80c7596a 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -110,7 +110,7 @@ To simulate deployment on sepolia, run ```sh forge script script/DeployProtocolAdapter.s.sol:DeployProtocolAdapter \ - --sig "run(bool,address)" \ + --sig "run(bool,address)" \ --rpc-url sepolia ``` diff --git a/contracts/script/DeployProtocolAdapter.s.sol b/contracts/script/DeployProtocolAdapter.s.sol index 94dd4553..1bba015a 100644 --- a/contracts/script/DeployProtocolAdapter.s.sol +++ b/contracts/script/DeployProtocolAdapter.s.sol @@ -66,12 +66,12 @@ contract DeployProtocolAdapter is Script { _supportNetwork({name: "bsc", chainId: 56, riscZeroVerifierRouter: 0x7C1B7b8fEB636eA9Ecd32152Bce2744a0EEf39C7}); } - /// @notice Deploys the protocol adapter contract on supported networks and allows for test deployments. - /// @param isTestDeployment Whether the deployment is a test deployment or not. If set to `false`, the protocol - /// adapter is deployed deterministically. + /// @notice Deploys the protocol adapter contract on supported networks. + /// @param deterministic Whether to deploy the protocol adapter deterministically using CREATE2 with a salt. /// @param emergencyStopCaller The emergency stop caller that can stop the protocol adapter in an emergency. - /// @dev If `isTestDeployment` is set to `false`, the protocol adapter is deployed deterministically. - function run(bool isTestDeployment, address emergencyStopCaller) public returns (address protocolAdapter) { + /// @dev If `deterministic` is set to `true`, the protocol adapter is deployed using CREATE2 with a version-derived + /// salt, producing a predictable address. If set to `false`, the contract is deployed regularly. + function run(bool deterministic, address emergencyStopCaller) public returns (address protocolAdapter) { // Lookup the RISC Zero router address from the supported networks. RiscZeroVerifierRouter riscZeroVerifierRouter = _riscZeroVerifierRouters[_supportedNetworks[block.chainid]]; @@ -81,23 +81,23 @@ contract DeployProtocolAdapter is Script { vm.startBroadcast(); - if (isTestDeployment) { - // Deploy regularly. + if (deterministic) { + // Deploy deterministically. protocolAdapter = address( - new ProtocolAdapter({ + new ProtocolAdapter{ + salt: keccak256( + bytes(string.concat("ProtocolAdapter", Versioning._PROTOCOL_ADAPTER_VERSION.fromSmallString())) + ) + }({ riscZeroVerifierRouter: riscZeroVerifierRouter, riscZeroVerifierSelector: Versioning._RISC_ZERO_VERIFIER_SELECTOR, emergencyStopCaller: emergencyStopCaller }) ); } else { - // Deploy deterministically. + // Deploy regularly. protocolAdapter = address( - new ProtocolAdapter{ - salt: keccak256( - bytes(string.concat("ProtocolAdapter", Versioning._PROTOCOL_ADAPTER_VERSION.fromSmallString())) - ) - }({ + new ProtocolAdapter({ riscZeroVerifierRouter: riscZeroVerifierRouter, riscZeroVerifierSelector: Versioning._RISC_ZERO_VERIFIER_SELECTOR, emergencyStopCaller: emergencyStopCaller diff --git a/contracts/test/DeployProtocolAdapter.t.sol b/contracts/test/DeployProtocolAdapter.t.sol index 54020f69..74788c21 100644 --- a/contracts/test/DeployProtocolAdapter.t.sol +++ b/contracts/test/DeployProtocolAdapter.t.sol @@ -11,21 +11,21 @@ contract DeployProtocolAdapterTest is Test { } // forge-lint: disable-next-line(mixed-case-function) - function tableNetworksTest_DeployProtocolAdapter_test_deployment_succeeds_on_all_supported_networks(TestCase memory network) + function tableNetworksTest_DeployProtocolAdapter_regular_deployment_succeeds_on_all_supported_networks(TestCase memory network) public { vm.selectFork(vm.createFork(network.name)); - new DeployProtocolAdapter().run({isTestDeployment: true, emergencyStopCaller: msg.sender}); + new DeployProtocolAdapter().run({deterministic: false, emergencyStopCaller: msg.sender}); } // forge-lint: disable-next-line(mixed-case-function) - function tableNetworksTest_DeployProtocolAdapter_prod_deployment_succeeds_on_all_supported_networks(TestCase memory network) + function tableNetworksTest_DeployProtocolAdapter_deterministic_deployment_succeeds_on_all_supported_networks(TestCase memory network) public { vm.selectFork(vm.createFork(network.name)); - new DeployProtocolAdapter().run({isTestDeployment: false, emergencyStopCaller: msg.sender}); + new DeployProtocolAdapter().run({deterministic: true, emergencyStopCaller: msg.sender}); } function fixtureNetwork() public pure returns (TestCase[] memory network) { diff --git a/justfile b/justfile index 0e877df7..8e48e008 100644 --- a/justfile +++ b/justfile @@ -59,16 +59,16 @@ contracts-gen-bindings: # Simulate deployment (dry-run) contracts-simulate chain *args: - @echo "IS_TEST_DEPLOYMENT: $IS_TEST_DEPLOYMENT" + @echo "DETERMINISTIC_DEPLOYMENT: $DETERMINISTIC_DEPLOYMENT" @echo "EMERGENCY_STOP_CALLER: $EMERGENCY_STOP_CALLER" cd contracts && forge script script/DeployProtocolAdapter.s.sol:DeployProtocolAdapter \ - --sig "run(bool,address)" $IS_TEST_DEPLOYMENT $EMERGENCY_STOP_CALLER \ + --sig "run(bool,address)" $DETERMINISTIC_DEPLOYMENT $EMERGENCY_STOP_CALLER \ --rpc-url {{chain}} {{ args }} # Deploy protocol adapter contracts-deploy deployer chain *args: cd contracts && forge script script/DeployProtocolAdapter.s.sol:DeployProtocolAdapter \ - --sig "run(bool,address)" $IS_TEST_DEPLOYMENT $EMERGENCY_STOP_CALLER \ + --sig "run(bool,address)" $DETERMINISTIC_DEPLOYMENT $EMERGENCY_STOP_CALLER \ --broadcast --rpc-url {{chain}} --account {{deployer}} {{ args }} # Execute a transaction binary on a deployed protocol adapter