-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat[contracts, l2geth]: backend mechanics for OVM self-upgrades #793
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
Closed
Closed
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
7a46a73
feat: Add ChugSplash config parsing via Handlebars (#739)
smartcontracts 77f7253
feat[contracts]: Add storage slot parsing functions for chugsplash (#…
smartcontracts 1e4b42e
feat[contracts]: ChugSplash action bundling logic (#719)
smartcontracts d5e15f8
refactor[contracts]: Turn ExecutionManagerWrapper into a predeployed …
smartcontracts 7dc15c8
maintenance[contracts]: use dashes in chain container names (#819)
smartcontracts e02ff12
feat[contracts]: ChugSplash tooling to generate complete action bundl…
smartcontracts 45032d2
feat[contracts]: Add L2ChugSplashDeployer contract to manage L2 deplo…
smartcontracts d2c7489
feat[contracts]: temporarily disable EOA upgrades (#857)
smartcontracts 07427ae
feat[contracts]: Update Lib_AddressManager.AddressSet event to speed …
smartcontracts 138063b
feat[contracts]: enable initiating L2 upgrade via L1 to L2 message (…
smartcontracts 245892b
Reduce gas costs of deposits (#667)
elenadimitrova bf28648
optimism: bump gaslimit to 10 million #870 (#871)
tynes cfa757a
fix: use correct contract name in tests (#921)
smartcontracts 8d477be
fix[contracts]: remove upgrade cancellation functions (#904)
smartcontracts b9c5e81
fix: disable upgradability from ECDSA Account (#885)
karlfloersch 64e8d28
l2geth: remove `SignatureHashType` (#752)
tynes b496ff7
feat[contracts]: introduce OVM_GasPriceOracle (#912)
smartcontracts b3fba19
fix: configure max gas limit to 11m (#928)
gakonst 466827d
feat[contracts]: add ability to pause EM during upgrades (#892)
smartcontracts bf47ff3
feat: add OVM Upgrade Functions with stub executor
ben-chain 8ecec48
test: smocked unit tests for upgrade paths
ben-chain cf7feb6
feat(l2geth): support putAccountCode
ben-chain 79f41ca
test: integration test unathenticated executor
ben-chain 58485e1
chore: lint
ben-chain 3b569ab
chore: address PR feedback
ben-chain 8a14a07
chore: remove duplicate fn definition
gakonst 87bf27d
replace UpgradeExecutor with ChugSplashDeployer
smartcontracts c6660ac
remove test focus
smartcontracts bce9676
lint: fix
smartcontracts 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@eth-optimism/contracts': minor | ||
| --- | ||
|
|
||
| Disables EOA contract upgrades until further notice |
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,5 @@ | ||
| --- | ||
| '@eth-optimism/contracts': patch | ||
| --- | ||
|
|
||
| Add L2ChugSplashDeployer contract and tests |
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,6 @@ | ||
| --- | ||
| '@eth-optimism/batch-submitter': patch | ||
| '@eth-optimism/contracts': patch | ||
| --- | ||
|
|
||
| Use dashes instead of colons in contract names |
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,6 @@ | ||
| --- | ||
| '@eth-optimism/contracts': minor | ||
| '@eth-optimism/data-transport-layer': minor | ||
| --- | ||
|
|
||
| Update AddressSet event to speed search up a bit. Breaks AddressSet API. |
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,5 @@ | ||
| --- | ||
| '@eth-optimism/contracts': patch | ||
| --- | ||
|
|
||
| enables l2 upgrades to be initiated by an l1 to l2 message |
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,5 @@ | ||
| --- | ||
| '@eth-optimism/contracts': patch | ||
| --- | ||
|
|
||
| Removed upgrade cancellation functions |
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,5 @@ | ||
| --- | ||
| '@eth-optimism/contracts': patch | ||
| --- | ||
|
|
||
| Introduces the congestion price oracle contract |
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,5 @@ | ||
| --- | ||
| '@eth-optimism/contracts': patch | ||
| --- | ||
|
|
||
| Disable upgradability from the ECDSA account instead of the EOA proxy. |
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,5 @@ | ||
| --- | ||
| '@eth-optimism/l2geth': patch | ||
| --- | ||
|
|
||
| Removes the SignatureHashType from l2geth as it is deprecated and no longer required. |
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,9 @@ | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity >=0.7.0; | ||
|
|
||
| contract ReturnOne { | ||
| function get() external pure returns(uint256) { | ||
| return 1; | ||
| } | ||
| } |
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,9 @@ | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity >=0.7.0; | ||
|
|
||
| contract ReturnTwo { | ||
| function get() external pure returns(uint256) { | ||
| return 2; | ||
| } | ||
| } |
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,158 @@ | ||
| import { expect } from 'chai' | ||
|
|
||
| /* Imports: External */ | ||
| import hre, { ethers } from 'hardhat' | ||
| import { Wallet, Contract, ContractFactory } from 'ethers' | ||
| import { | ||
| getContractInterface, | ||
| predeploys, | ||
| ChugSplashAction, | ||
| getChugSplashActionBundle, | ||
| isSetStorageAction, | ||
| } from '@eth-optimism/contracts' | ||
| import { getRandomAddress } from '@eth-optimism/core-utils' | ||
|
|
||
| /* Imports: Internal */ | ||
| import { OptimismEnv } from './shared/env' | ||
| import { fundUser, l2Provider, OVM_ETH_ADDRESS } from './shared/utils' | ||
|
|
||
| const applyAndVerifyUpgrade = async ( | ||
| L2ChugSplashDeployer: Contract, | ||
| actions: ChugSplashAction[] | ||
| ) => { | ||
| const bundle = getChugSplashActionBundle(actions) | ||
|
|
||
| const tx1 = await L2ChugSplashDeployer.approveTransactionBundle( | ||
| bundle.root, | ||
| bundle.actions.length | ||
| ) | ||
| await tx1.wait() | ||
|
|
||
| for (const action of bundle.actions) { | ||
| const tx2 = await L2ChugSplashDeployer.executeAction( | ||
| action.action, | ||
| action.proof | ||
| ) | ||
| await tx2.wait() | ||
| } | ||
|
|
||
| for (const action of actions) { | ||
| if (isSetStorageAction(action)) { | ||
| expect( | ||
| await l2Provider.getStorageAt(action.target, action.key) | ||
| ).to.deep.equal(action.value) | ||
| } else { | ||
| expect(await l2Provider.getCode(action.target)).to.deep.equal(action.code) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| describe('OVM Self-Upgrades', async () => { | ||
| let l2Wallet: Wallet | ||
| before(async () => { | ||
| const env = await OptimismEnv.new() | ||
| // For simplicity, this is the default wallet that (at least for now) controls upgrades when | ||
| // running the system locally. | ||
| l2Wallet = new ethers.Wallet('0x' + 'FF'.repeat(64), l2Provider) | ||
| await fundUser( | ||
| env.watcher, | ||
| env.gateway, | ||
| hre.ethers.utils.parseEther('10'), | ||
| l2Wallet.address | ||
| ) | ||
| }) | ||
|
|
||
| let L2ChugSplashDeployer: Contract | ||
| before(async () => { | ||
| L2ChugSplashDeployer = new Contract( | ||
| predeploys.L2ChugSplashDeployer, | ||
| getContractInterface('L2ChugSplashDeployer'), | ||
| l2Wallet | ||
| ) | ||
| }) | ||
|
|
||
| describe('setStorage and setCode are correctly applied according to geth RPC', () => { | ||
| it('Should execute a basic storage upgrade', async () => { | ||
| await applyAndVerifyUpgrade(L2ChugSplashDeployer, [ | ||
| { | ||
| target: OVM_ETH_ADDRESS, | ||
| key: | ||
| '0x1234123412341234123412341234123412341234123412341234123412341234', | ||
| value: | ||
| '0x6789123412341234123412341234123412341234123412341234678967896789', | ||
| }, | ||
| ]) | ||
| }) | ||
|
|
||
| it('Should execute a basic upgrade overwriting existing deployed code', async () => { | ||
| // Deploy a dummy contract to overwrite. | ||
| const factory = await hre.ethers.getContractFactory('SimpleStorage') | ||
| const contract = await factory.connect(l2Wallet).deploy() | ||
| await contract.deployTransaction.wait() | ||
|
|
||
| await applyAndVerifyUpgrade(L2ChugSplashDeployer, [ | ||
| { | ||
| target: contract.address, | ||
| code: | ||
| '0x1234123412341234123412341234123412341234123412341234123412341234', | ||
| }, | ||
| ]) | ||
| }) | ||
|
|
||
| it('Should execute a basic code upgrade which is not overwriting an existing account', async () => { | ||
| await applyAndVerifyUpgrade(L2ChugSplashDeployer, [ | ||
| { | ||
| target: getRandomAddress(), | ||
| code: | ||
| '0x1234123412341234123412341234123412341234123412341234123412341234', | ||
| }, | ||
| ]) | ||
| }) | ||
| }) | ||
|
|
||
| describe('Contracts upgraded with setStorage and setCode behave as expected', () => { | ||
| it('code with updated storage returns the new storage', async () => { | ||
| const factory = await hre.ethers.getContractFactory('SimpleStorage') | ||
| const contract = await factory.connect(l2Wallet).deploy() | ||
| await contract.deployTransaction.wait() | ||
|
|
||
| expect(await contract.value()).to.eq(ethers.constants.HashZero) | ||
|
|
||
| const newValue = '0x' + '00'.repeat(31) + '01' | ||
|
|
||
| await applyAndVerifyUpgrade(L2ChugSplashDeployer, [ | ||
| { | ||
| target: contract.address, | ||
| key: ethers.constants.HashZero, | ||
| value: newValue, | ||
| }, | ||
| ]) | ||
|
|
||
| const valueAfter = await contract.value() | ||
| expect(valueAfter).to.eq(newValue) | ||
| }) | ||
|
|
||
| it('code with an updated constant returns the new constant', async () => { | ||
smartcontracts marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const factory1 = await hre.ethers.getContractFactory('ReturnOne') | ||
| const contract1 = await factory1.connect(l2Wallet).deploy() | ||
| await contract1.deployTransaction.wait() | ||
|
|
||
| const factory2 = await hre.ethers.getContractFactory('ReturnTwo') | ||
| const contract2 = await factory2.connect(l2Wallet).deploy() | ||
| await contract2.deployTransaction.wait() | ||
|
|
||
| const one = await contract1.get() | ||
| expect(one.toNumber()).to.eq(1) | ||
|
|
||
| await applyAndVerifyUpgrade(L2ChugSplashDeployer, [ | ||
| { | ||
| target: contract1.address, | ||
| code: await l2Provider.getCode(contract2.address), | ||
| }, | ||
| ]) | ||
|
|
||
| const two = await contract1.get() | ||
| expect(two.toNumber()).to.eq(2) | ||
| }) | ||
| }) | ||
| }) | ||
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
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
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
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.