-
Notifications
You must be signed in to change notification settings - Fork 319
template for gas & elasticity increase #491
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
leopoldjoy
merged 12 commits into
base:main
from
leopoldjoy:feat/add-template-for-gas-and-elasticity-increase
Nov 17, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c266254
add WIP template for gas and elasticity increase
leopoldjoy dc2bc7c
add validations directory creation commands to Makefile
leopoldjoy b8d6d8a
update override function comments in IncreaseEip1559ElasticityAndIncr…
leopoldjoy 827bf87
update Makefile commands for rollback usage in Signer Tool
leopoldjoy c4c32a4
update to latest Signer Tool commit hash in Makefile
leopoldjoy a85c6e3
update usage instructions for gas limit + elasticity increase templat…
leopoldjoy cfd4803
Merge branch 'main' into feat/add-template-for-gas-and-elasticity-inc…
leopoldjoy f1b9bfc
add further usage instructions in README.md
leopoldjoy 5598598
add missing TODO instructions in .env
leopoldjoy b47e360
add process kill instructions to task's README.md
leopoldjoy 29f6e7d
fix formatting, improve override logic and read DENOMINATOR from Syst…
leopoldjoy 8b04939
make fixes / improvements from review
leopoldjoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| OP_COMMIT=TODO # Recommend using the version of https://github.com/ethereum-optimism/optimism that the current SystemConfig contract is on | ||
| BASE_CONTRACTS_COMMIT=TODO # Recommend using the latest version of https://github.com/base-org/contracts | ||
|
|
||
| # TODO: ensure that the `SYSTEM_CONFIG` / `OWNER_SAFE` below are set for the correct network | ||
|
|
||
| # Mainnet | ||
| SYSTEM_CONFIG=0x73a79Fab69143498Ed3712e519A88a918e1f4072 | ||
| OWNER_SAFE=0x14536667Cd30e52C0b458BaACcB9faDA7046E056 | ||
|
|
||
| # Sepolia | ||
| # SYSTEM_CONFIG=0xf272670eb55e895584501d564AfEB048bEd26194 | ||
| # OWNER_SAFE=0x0fe884546476dDd290eC46318785046ef68a0BA9 | ||
|
|
||
| # TODO: ensure the current and future gas limits are set properly | ||
| FROM_GAS_LIMIT=TODO | ||
| TO_GAS_LIMIT=TODO | ||
|
|
||
| # TODO: ensure the current and future elasticities are set properly | ||
| FROM_ELASTICITY=TODO | ||
| TO_ELASTICITY=TODO | ||
|
|
||
| # TODO: ensure `SENDER` is a signer for `OWNER_SAFE` on the given network | ||
| SENDER=0x1841CB3C2ce6870D0417844C817849da64E6e937 | ||
|
|
||
| RECORD_STATE_DIFF=true | ||
28 changes: 28 additions & 0 deletions
28
setup-templates/template-gas-and-elasticity-increase/FACILITATOR.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Facilitator Guide | ||
|
|
||
| Guide for facilitators after collecting signatures from signers. | ||
|
|
||
| ### 1. Update repo: | ||
|
|
||
| ```bash | ||
| cd contract-deployments | ||
| git pull | ||
| cd mainnet/TODO | ||
| make deps | ||
| ``` | ||
|
|
||
| ### 2. Execute upgrade | ||
|
|
||
| ```bash | ||
| SIGNATURES=AAABBBCCC make execute | ||
| ``` | ||
|
|
||
| ### 3. (**ONLY** if needed) Execute upgrade rollback | ||
|
|
||
| > [!IMPORTANT] | ||
| > | ||
| > THIS SHOULD ONLY BE PERFORMED IN THE EVENT THAT WE NEED TO ROLLBACK | ||
|
|
||
| ```bash | ||
| SIGNATURES=AAABBBCCC make execute-rollback | ||
| ``` |
61 changes: 61 additions & 0 deletions
61
setup-templates/template-gas-and-elasticity-increase/Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| include ../../Makefile | ||
| include ../../Multisig.mk | ||
| include ../.env | ||
| include .env | ||
|
|
||
| ifndef LEDGER_ACCOUNT | ||
| override LEDGER_ACCOUNT = 0 | ||
| endif | ||
|
|
||
| ifndef ROLLBACK_NONCE_OFFSET | ||
| override ROLLBACK_NONCE_OFFSET = 1 | ||
| endif | ||
|
|
||
| RPC_URL = $(L1_RPC_URL) | ||
| SCRIPT_NAME = IncreaseEip1559ElasticityAndIncreaseGasLimitScript | ||
|
|
||
| .PHONY: gen-validation | ||
| gen-validation: checkout-signer-tool run-script | ||
|
|
||
| .PHONY: run-script | ||
| run-script: | ||
| mkdir validations; \ | ||
| cd $(SIGNER_TOOL_PATH); \ | ||
| npm ci; \ | ||
| bun run scripts/genValidationFile.ts --rpc-url $(RPC_URL) \ | ||
| --workdir .. --forge-cmd 'NEW_GAS_LIMIT=$(TO_GAS_LIMIT) \ | ||
| OLD_GAS_LIMIT=$(FROM_GAS_LIMIT) NEW_ELASTICITY=$(TO_ELASTICITY) OLD_ELASTICITY=$(FROM_ELASTICITY) \ | ||
| forge script --rpc-url $(RPC_URL) \ | ||
| $(SCRIPT_NAME) --sig "sign(address[])" [] --sender $(SENDER)' --out ../validations/base-signer.json; | ||
|
|
||
| .PHONY: execute | ||
| execute: | ||
| NEW_GAS_LIMIT=$(TO_GAS_LIMIT) \ | ||
| OLD_GAS_LIMIT=$(FROM_GAS_LIMIT) \ | ||
| NEW_ELASTICITY=$(TO_ELASTICITY) \ | ||
| OLD_ELASTICITY=$(FROM_ELASTICITY) \ | ||
| $(call MULTISIG_EXECUTE,$(SIGNATURES)) | ||
leopoldjoy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .PHONY: gen-validation-rollback | ||
| gen-validation-rollback: checkout-signer-tool run-script-rollback | ||
|
|
||
| .PHONY: run-script-rollback | ||
| run-script-rollback: | ||
| cd $(SIGNER_TOOL_PATH); \ | ||
| npm ci; \ | ||
| bun run scripts/genValidationFile.ts --rpc-url $(RPC_URL) \ | ||
| --workdir .. --forge-cmd 'OLD_GAS_LIMIT=$(TO_GAS_LIMIT) \ | ||
| NEW_GAS_LIMIT=$(FROM_GAS_LIMIT) OLD_ELASTICITY=$(TO_ELASTICITY) NEW_ELASTICITY=$(FROM_ELASTICITY) \ | ||
| SAFE_NONCE=$(shell expr $$(cast call $(OWNER_SAFE) "nonce()" --rpc-url $(RPC_URL) | cast to-dec) + $(ROLLBACK_NONCE_OFFSET)) \ | ||
| forge script --rpc-url $(RPC_URL) \ | ||
| $(SCRIPT_NAME) --sig "sign(address[])" [] --sender $(SENDER)' --out ../validations/base-signer-rollback.json; | ||
|
|
||
| .PHONY: execute-rollback | ||
| execute-rollback: | ||
| OLD_GAS_LIMIT=$(TO_GAS_LIMIT) \ | ||
| NEW_GAS_LIMIT=$(FROM_GAS_LIMIT) \ | ||
| OLD_ELASTICITY=$(TO_ELASTICITY) \ | ||
| NEW_ELASTICITY=$(FROM_ELASTICITY) \ | ||
| SAFE_NONCE=$(shell expr $$(cast call $(OWNER_SAFE) "nonce()" --rpc-url $(RPC_URL) | cast to-dec) + $(ROLLBACK_NONCE_OFFSET)) \ | ||
| forge script --rpc-url $(RPC_URL) $(SCRIPT_NAME) \ | ||
| --sig "run(bytes)" $(SIGNATURES) --ledger --hd-paths "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0" --broadcast | ||
69 changes: 69 additions & 0 deletions
69
setup-templates/template-gas-and-elasticity-increase/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Update Gas Limit & Elasticity in L1 `SystemConfig` | ||
|
|
||
| Status: TODO[READY TO SIGN|DONE] | ||
|
|
||
| ## Description | ||
|
|
||
| We are updating the gas limit and elasticity to improve TPS and reduce gas fees. | ||
|
|
||
| This runbook invokes the following script which allows our signers to sign the same call with two different sets of parameters for our Incident Multisig, defined in the [base-org/contracts](https://github.com/base/contracts) repository: | ||
|
|
||
| `IncreaseEip1559ElasticityAndIncreaseGasLimitScript` -- This script will update the gas limit to our new limit of TODO gas and TODO elasticity if invoked as part of the "upgrade" process, or revert to the old limit of TODO gas and TODO elasticity if invoked as part of the "rollback" process. | ||
|
|
||
| The values we are sending are statically defined in the `.env` file. | ||
|
|
||
| > [!IMPORTANT] We have two transactions to sign. Please follow | ||
| > the flow for both "Approving the Update transaction" and | ||
| > "Approving the Rollback transaction". Hopefully we only need | ||
| > the former, but will have the latter available if needed. | ||
|
|
||
| ## Install dependencies | ||
|
|
||
| ### 1. Update foundry | ||
|
|
||
| ```bash | ||
| foundryup | ||
| ``` | ||
|
|
||
| ### 2. Install Node.js if needed | ||
|
|
||
| First, check if you have node installed | ||
|
|
||
| ```bash | ||
| node --version | ||
| ``` | ||
|
|
||
| If you see a version output from the above command, you can move on. Otherwise, install node | ||
|
|
||
| ```bash | ||
| brew install node | ||
| ``` | ||
|
|
||
| ## Approving the Update transaction | ||
|
|
||
| ### 1. Update repo: | ||
|
|
||
| ```bash | ||
| cd contract-deployments | ||
| git pull | ||
| ``` | ||
|
|
||
| ### 2. Run the signing tool (NOTE: do not enter the task directory. Run this command from the project's root). | ||
|
|
||
| ```bash | ||
| make sign-task | ||
| ``` | ||
|
|
||
| ### 3. Open the UI at [http://localhost:3000](http://localhost:3000) | ||
|
|
||
| Be sure to select the correct task from the list of available tasks to sign (**not** the "Base Signer Rollback" task). Copy the resulting signature and save it. | ||
|
|
||
| ### 4. Rollback signing | ||
|
|
||
| Now, click on the "Base Signer" selection and switch over to the rollback task (called "Base Signer Rollback"). Copy the resulting signature and save it. | ||
|
|
||
| ### 5. Send signature to facilitator | ||
|
|
||
| Send the two signatures to the facilitator and make sure to clearly note which one is the primary one and which one is the rollback. | ||
|
|
||
| You may now kill the Signer Tool process in your terminal window by running `Ctrl + C`. |
20 changes: 20 additions & 0 deletions
20
setup-templates/template-gas-and-elasticity-increase/foundry.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [profile.default] | ||
| src = 'src' | ||
| out = 'out' | ||
| libs = ['lib'] | ||
| broadcast = 'records' | ||
| fs_permissions = [ {access = "read-write", path = "./"} ] | ||
| optimizer = true | ||
| optimizer_runs = 999999 | ||
| solc_version = "0.8.15" | ||
| via-ir = false | ||
| remappings = [ | ||
| '@eth-optimism-bedrock/=lib/optimism/packages/contracts-bedrock/', | ||
| '@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts', | ||
| '@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts', | ||
| '@rari-capital/solmate/=lib/solmate/', | ||
| '@base-contracts/=lib/base-contracts', | ||
| '@solady/=lib/solady/src/' | ||
| ] | ||
|
|
||
| # See more config options https://github.com/foundry-rs/foundry/tree/master/config |
101 changes: 101 additions & 0 deletions
101
...ate-gas-and-elasticity-increase/script/IncreaseEip1559ElasticityAndIncreaseGasLimit.s.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.15; | ||
|
|
||
| import {Vm} from "forge-std/Vm.sol"; | ||
| import {Simulation} from "@base-contracts/script/universal/Simulation.sol"; | ||
| import {IMulticall3} from "forge-std/interfaces/IMulticall3.sol"; | ||
|
|
||
| import {MultisigScript} from "@base-contracts/script/universal/MultisigScript.sol"; | ||
|
|
||
| interface ISystemConfig { | ||
| function eip1559Elasticity() external view returns (uint32); | ||
| function eip1559Denominator() external view returns (uint32); | ||
| function setEIP1559Params(uint32 _denominator, uint32 _elasticity) external; | ||
| function gasLimit() external view returns (uint64); | ||
| function setGasLimit(uint64 _gasLimit) external; | ||
| } | ||
|
|
||
| contract IncreaseEip1559ElasticityAndIncreaseGasLimitScript is MultisigScript { | ||
| address internal immutable OWNER_SAFE; | ||
| address internal immutable SYSTEM_CONFIG; | ||
|
|
||
| uint32 internal immutable ELASTICITY; | ||
| uint32 internal immutable NEW_ELASTICITY; | ||
| uint64 internal immutable GAS_LIMIT; | ||
| uint64 internal immutable NEW_GAS_LIMIT; | ||
| uint32 internal immutable DENOMINATOR; | ||
|
|
||
| constructor() { | ||
| OWNER_SAFE = vm.envAddress("OWNER_SAFE"); | ||
| SYSTEM_CONFIG = vm.envAddress("SYSTEM_CONFIG"); | ||
|
|
||
| GAS_LIMIT = uint64(vm.envUint("OLD_GAS_LIMIT")); | ||
| NEW_GAS_LIMIT = uint64(vm.envUint("NEW_GAS_LIMIT")); | ||
|
|
||
| ELASTICITY = uint32(vm.envUint("OLD_ELASTICITY")); | ||
| NEW_ELASTICITY = uint32(vm.envUint("NEW_ELASTICITY")); | ||
|
|
||
| DENOMINATOR = ISystemConfig(SYSTEM_CONFIG).eip1559Denominator(); | ||
| } | ||
|
|
||
| function _postCheck(Vm.AccountAccess[] memory, Simulation.Payload memory) internal view override { | ||
| vm.assertEq(ISystemConfig(SYSTEM_CONFIG).eip1559Denominator(), DENOMINATOR, "Denominator mismatch"); | ||
| vm.assertEq(ISystemConfig(SYSTEM_CONFIG).eip1559Elasticity(), NEW_ELASTICITY, "Elasticity mismatch"); | ||
| vm.assertEq(ISystemConfig(SYSTEM_CONFIG).gasLimit(), NEW_GAS_LIMIT, "Gas Limit mismatch"); | ||
| } | ||
|
|
||
| function _simulationOverrides() internal view override returns (Simulation.StateOverride[] memory _stateOverrides) { | ||
| if ( | ||
| GAS_LIMIT != ISystemConfig(SYSTEM_CONFIG).gasLimit() | ||
| || ELASTICITY != ISystemConfig(SYSTEM_CONFIG).eip1559Elasticity() | ||
| ) { | ||
| // Override SystemConfig state to the expected "from" values so simulations succeeds even | ||
| // when the chain already reflects the post-change values (during rollback simulation). | ||
|
|
||
| // Prepare two storage overrides for SystemConfig | ||
| Simulation.StateOverride[] memory stateOverrides = new Simulation.StateOverride[](1); | ||
| Simulation.StorageOverride[] memory storageOverrides = new Simulation.StorageOverride[](2); | ||
|
|
||
| // Load current packed gas config (slot 0x68) and replace only the lower 64 bits with GAS_LIMIT | ||
| bytes32 gasConfigSlotKey = bytes32(uint256(0x68)); | ||
| uint256 gasConfigWord = uint256(vm.load(SYSTEM_CONFIG, gasConfigSlotKey)); | ||
| uint256 updatedGasConfigWord = (gasConfigWord & ~uint256(0xffffffffffffffff)) | uint256(GAS_LIMIT); | ||
| storageOverrides[0] = | ||
| Simulation.StorageOverride({key: gasConfigSlotKey, value: bytes32(updatedGasConfigWord)}); | ||
|
|
||
| // Deterministically set EIP-1559 params (slot 0x6a) to [ ... | elasticity (uint32) | denominator (uint32) ] | ||
| // Compose the full 256-bit word with only these two fields set to avoid unused high bits which can | ||
| // cause mismatches during validation. | ||
| bytes32 eip1559SlotKey = bytes32(uint256(0x6a)); | ||
| uint256 composedEip1559Word = (uint256(ELASTICITY) << 32) | uint256(DENOMINATOR); | ||
| storageOverrides[1] = Simulation.StorageOverride({key: eip1559SlotKey, value: bytes32(composedEip1559Word)}); | ||
|
|
||
| stateOverrides[0] = Simulation.StateOverride({contractAddress: SYSTEM_CONFIG, overrides: storageOverrides}); | ||
| return stateOverrides; | ||
| } | ||
| } | ||
|
|
||
| function _buildCalls() internal view override returns (IMulticall3.Call3Value[] memory) { | ||
| IMulticall3.Call3Value[] memory calls = new IMulticall3.Call3Value[](2); | ||
|
|
||
| calls[0] = IMulticall3.Call3Value({ | ||
| target: SYSTEM_CONFIG, | ||
| allowFailure: false, | ||
| callData: abi.encodeCall(ISystemConfig.setEIP1559Params, (DENOMINATOR, NEW_ELASTICITY)), | ||
| value: 0 | ||
| }); | ||
|
|
||
| calls[1] = IMulticall3.Call3Value({ | ||
| target: SYSTEM_CONFIG, | ||
| allowFailure: false, | ||
| callData: abi.encodeCall(ISystemConfig.setGasLimit, (NEW_GAS_LIMIT)), | ||
| value: 0 | ||
| }); | ||
|
|
||
| return calls; | ||
| } | ||
|
|
||
| function _ownerSafe() internal view override returns (address) { | ||
| return OWNER_SAFE; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.