This example on mainnet demonstrates FPS being utilized to simulate proposals for the ENS Governor on mainnet. The proposal involves setting up a new DNSSEC on the ENS root. It entails deploying a new DNSSEC contract named UPGRADE_DNSSEC_SUPPORT. Subsequently, the timelock sets the newly deployed DNSSEC contract as the controller for the ENS Root.
The contract for this proposal is located in the mocks folder.
description(): Provides a detailed description of the proposal.
functiondescription()publicpureoverridereturns(stringmemory){return"Call setController on the Root contract at root.ens.eth, passing in the address of the new DNS registrar";}
deploy(): Deploys any necessary contracts. This example demonstrates the deployment of a new dnsSec contract (only a mock for this proposal). Once the contracts are deployed, they are added to the Addresses contract by calling addAddress().
functiondeploy()publicoverride{// Deploy a mock upgrade contract to set controller if not already deployedif(!addresses.isAddressSet("ENS_DNSSEC")){// In a real case, this function would be responsible for// deploying the DNSSEC contract instead of using a mockaddress dnsSec =address(newMockUpgrade()); addresses.addAddress("ENS_DNSSEC", dnsSec,true);}}
Since these changes do not persist from runs themselves, after the contracts are deployed, the user must update the Addresses.json file with the newly deployed contract addresses.
build(): Add actions to the proposal contract. In this example, the newly deployed dnsSec contract is set as the controller for the root contract. Any calls (except to the Addresses object) will be recorded and stored as actions to execute in the run function. The caller address that will call actions is passed into buildModifier. In this example, it is the OZ Governor's timelock. The buildModifier is a necessary modifier for the build function and will not function without it. For further reading, see the build function.
functionbuild()publicoverridebuildModifier(addresses.getAddress("ENS_TIMELOCK")){/// STATICCALL -- non-mutative and hence not recorded for the run stage// Get ENS root address IControllable control =IControllable(addresses.getAddress("ENS_ROOT"));// Get deployed dnsSec addressaddress dnsSec = addresses.getAddress("ENS_DNSSEC");/// CALLS -- mutative and recorded// Set controller to newly deployed dnsSec contract control.setController(dnsSec,true);}
run(): Sets up the environment for running the proposal, and executes all proposal actions. This sets addresses, primaryForkId, and governor, and then calls super.run() to run the entire proposal. In this example, primaryForkId is set to mainnet, selecting the fork for running the proposal. Next, the addresses object is set by reading the addresses.json file. The OZ Governor contract to test is set using setGovernor. This will be used to check onchain calldata and simulate the proposal. For further reading, see the run function.
functionrun()publicoverride{// Create and select the mainnet fork for proposal execution.setPrimaryForkId(vm.createFork("mainnet")); vm.selectFork(primaryForkId);uint256[]memory chainIds =newuint256[](1); chainIds[0]=1;// Set the addresses object by reading addresses from the JSON file.setAddresses(newAddresses( vm.envOr("ADDRESSES_PATH",string("./addresses")), chainIds));// Set Governor Bravo. This address is used for proposal simulation and checking the on-chain proposal state.setGovernor(addresses.getAddress("ENS_GOVERNOR"));// Call the run function of the parent contract 'Proposal.sol'.super.run();}
validate(): This final step validates the system in its post-execution state. It ensures that the dnsSec contract is set as the controller for the root contract.
functionvalidate()publicviewoverride{// Get ENS root address IControllable control =IControllable(addresses.getAddress("ENS_ROOT"));// Get deployed dnsSec addressaddress dnsSec = addresses.getAddress("ENS_DNSSEC");// Ensure dnsSec is set as the controller for the ENS root contractassertEq(control.controllers(dnsSec),true);}
Running the Proposal
All required addresses should be in the Addresses.json file, including the DEPLOYER_EOA address, which will deploy the new contracts. If these do not align, the script execution will fail.