-
Notifications
You must be signed in to change notification settings - Fork 4k
feat[contracts]: Chugsplash integration #653
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 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4c7dbaf
wip: Starting chugsplash integration
smartcontracts 0362405
wip: Make chugsplash work for L2
smartcontracts a6ee0ca
wip: Update L2CrossDomainMessenger and tests
smartcontracts 37c7801
fix: minor compilation error fix
smartcontracts 2f9df7d
wip: Add proof logic to ChugSplashDeployer
smartcontracts 0fd174e
fix: build errors in deployer
smartcontracts b740580
Merge branch 'v0.4.0' into feat/chugsplash
smartcontracts 4d09af1
rename OVM_UpgradeExecutor
smartcontracts 20640bc
temporarily disable authentication
smartcontracts 3cfd9ac
revert to old L2CrossDomainMessenger
smartcontracts a33bf58
temporarily disable all authentication
smartcontracts 2ada3a1
fix: various minor bug fixes
smartcontracts a2d1d58
minor integration test cleanup
smartcontracts dcc1594
enable some auth and add more integration tests
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,54 @@ | ||
| { | ||
| "contracts": { | ||
| "OVM_L2ToL1MessagePasser": { | ||
| "address": "0x4200000000000000000000000000000000000000", | ||
| "source": "OVM_L2ToL1MessagePasser" | ||
| }, | ||
| "OVM_L1MessageSender": { | ||
| "address": "0x4200000000000000000000000000000000000001", | ||
| "source": "OVM_L1MessageSender" | ||
| }, | ||
| "OVM_DeployerWhitelist": { | ||
| "address": "0x4200000000000000000000000000000000000002", | ||
| "source": "OVM_DeployerWhitelist", | ||
| "variables": { | ||
| "owner": "{{ env.DEPLOYER_WHITELIST_OWNER }}" | ||
| } | ||
| }, | ||
| "OVM_ECDSAContractAccount": { | ||
| "address": "0x4200000000000000000000000000000000000003", | ||
| "source": "OVM_ECDSAContractAccount" | ||
| }, | ||
| "OVM_SequencerEntrypoint": { | ||
| "address": "0x4200000000000000000000000000000000000005", | ||
| "source": "OVM_SequencerEntrypoint" | ||
| }, | ||
| "OVM_ETH": { | ||
| "address": "0x4200000000000000000000000000000000000006", | ||
| "source": "OVM_ETH", | ||
| "variables": { | ||
| "l1TokenGateway": "{{ env.L1_ETH_GATEWAY_ADDRESS }}", | ||
| "messenger": "{{ contracts.OVM_L2CrossDomainMessenger }}", | ||
| "name": "Ether", | ||
| "symbol": "ETH" | ||
| } | ||
| }, | ||
| "OVM_L2CrossDomainMessenger": { | ||
| "address": "0x4200000000000000000000000000000000000007", | ||
| "source": "OVM_L2CrossDomainMessenger", | ||
| "variables": { | ||
| "ovmL2ToL1MessagePasser": "{{ contracts.OVM_L2ToL1MessagePasser }}", | ||
| "ovmL1MessageSender": "{{ contracts.OVM_L1MessageSender }}", | ||
| "ovmL1CrossDomainMessenger": "{{ env.L1_CROSS_DOMAIN_MESSENGER_ADDRESS }}" | ||
| } | ||
| }, | ||
| "OVM_ProxyEOA": { | ||
| "address": "0x4200000000000000000000000000000000000009", | ||
| "source": "OVM_ProxyEOA" | ||
| }, | ||
| "ERC1820Registry": { | ||
| "address": "0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24", | ||
| "source": "ERC1820Registry" | ||
| } | ||
| } | ||
| } |
198 changes: 198 additions & 0 deletions
198
packages/contracts/contracts/chugsplash/L2/ChugSplashDeployer.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,198 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| // @unsupported: evm | ||
| pragma solidity >0.5.0 <0.8.0; | ||
| pragma experimental ABIEncoderV2; | ||
|
|
||
| /* Library Imports */ | ||
| import { Lib_ExecutionManagerWrapper } from "../../optimistic-ethereum/libraries/wrappers/Lib_ExecutionManagerWrapper.sol"; | ||
| import { Lib_MerkleTree } from "../../optimistic-ethereum/libraries/utils/Lib_MerkleTree.sol"; | ||
|
|
||
| /** | ||
| * @title ChugSplashDeployer | ||
| */ | ||
| contract ChugSplashDeployer { | ||
|
|
||
| /********* | ||
| * Enums * | ||
| *********/ | ||
|
|
||
| enum ActionType { | ||
| SET_CODE, | ||
| SET_STORAGE | ||
| } | ||
|
|
||
|
|
||
| /*********** | ||
| * Structs * | ||
| ***********/ | ||
|
|
||
| struct ChugSplashAction { | ||
| ActionType actionType; | ||
| uint256 gasLimit; | ||
| address target; | ||
| bytes data; | ||
| } | ||
|
|
||
| struct ChugSplashActionProof { | ||
| uint256 actionIndex; | ||
| bytes32[] siblings; | ||
| } | ||
|
|
||
|
|
||
| /************* | ||
| * Variables * | ||
| *************/ | ||
|
|
||
| // Address that can approve new transaction bundles. | ||
| address public owner; | ||
| bytes32 public currentBundleHash; | ||
| uint256 public currentBundleSize; | ||
| uint256 public currentBundleTxsExecuted; | ||
|
|
||
|
|
||
| /*************** | ||
| * Constructor * | ||
| ***************/ | ||
|
|
||
| /** | ||
| * @param _owner Initial owner address. | ||
| */ | ||
| constructor( | ||
| address _owner | ||
| ) { | ||
| owner = _owner; | ||
| } | ||
|
|
||
|
|
||
| /********************** | ||
| * Function Modifiers * | ||
| **********************/ | ||
|
|
||
| /** | ||
| * Marks a function as only callable by the owner. | ||
| */ | ||
| modifier onlyOwner() { | ||
| require( | ||
| msg.sender == owner, | ||
| "ChugSplashDeployer: sender is not owner" | ||
| ); | ||
| _; | ||
| } | ||
|
|
||
|
|
||
| /******************** | ||
| * Public Functions * | ||
| ********************/ | ||
|
|
||
| /** | ||
| * Changes the owner. Only callable by the current owner. | ||
| * @param _owner New owner address. | ||
| */ | ||
| function setOwner( | ||
| address _owner | ||
| ) | ||
| public | ||
| onlyOwner | ||
| { | ||
| owner = _owner; | ||
| } | ||
|
|
||
| function hasActiveBundle() | ||
| public | ||
| view | ||
| returns ( | ||
| bool | ||
| ) | ||
| { | ||
| return ( | ||
| currentBundleHash != bytes32(0) | ||
| && currentBundleTxsExecuted < currentBundleSize | ||
| ); | ||
| } | ||
|
|
||
| function approveTransactionBundle( | ||
| bytes32 _bundleHash, | ||
| uint256 _bundleSize | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should also take in a version string I think which we can emit and thereby track the versions of each deployment. Or alternatively there is a version in the bundle |
||
| ) | ||
| public | ||
| onlyOwner | ||
| { | ||
| require( | ||
| hasActiveBundle() == false, | ||
| "ChugSplashDeployer: previous bundle has not yet been fully executed" | ||
| ); | ||
|
|
||
| currentBundleHash = _bundleHash; | ||
| currentBundleSize = _bundleSize; | ||
| currentBundleTxsExecuted = 0; | ||
|
|
||
| // TODO: Set system status to "upgrading". | ||
| } | ||
|
|
||
| function executeAction( | ||
| ChugSplashAction memory _action, | ||
| ChugSplashActionProof memory _proof | ||
| ) | ||
| public | ||
| { | ||
| // TODO: Do we need to validate enums or does solidity do it for us? | ||
|
|
||
| require( | ||
| hasActiveBundle() == true, | ||
| "ChugSplashDeployer: there is no active bundle" | ||
| ); | ||
|
|
||
| // Make sure the user has provided enough gas to perform this action successfully. | ||
| require( | ||
| gasleft() > _action.gasLimit, | ||
| "ChugSplashDeployer: sender didn't supply enough gas" | ||
| ); | ||
|
|
||
| // Make sure that the owner did actually sign off on this action. | ||
| require( | ||
| Lib_MerkleTree.verify( | ||
| currentBundleHash, | ||
| keccak256( | ||
| abi.encodePacked( | ||
| _action.actionType, | ||
| _action.gasLimit, | ||
| _action.target, | ||
| _action.data | ||
| ) | ||
| ), | ||
| _proof.actionIndex, | ||
| _proof.siblings, | ||
| currentBundleSize | ||
| ), | ||
| "ChugSplashDeployer: invalid action proof" | ||
| ); | ||
|
|
||
| if (_action.actionType == ActionType.SET_CODE) { | ||
| // When the action is SET_CODE, we expect that the data is exactly the bytecode that | ||
| // the user wants to set the code to. | ||
| Lib_ExecutionManagerWrapper.ovmSETCODE( | ||
| _action.target, | ||
| _action.data | ||
| ); | ||
| } else { | ||
| // When the action is SET_STORAGE, we expect that the data is actually an ABI encoded | ||
| // key/value pair. So we'll need to decode that first. | ||
| (bytes32 key, bytes32 value) = abi.decode( | ||
| _action.data, | ||
| (bytes32, bytes32) | ||
| ); | ||
|
|
||
| Lib_ExecutionManagerWrapper.ovmSETSTORAGE( | ||
| _action.target, | ||
| key, | ||
| value | ||
| ); | ||
| } | ||
|
|
||
| currentBundleTxsExecuted++; | ||
| if (currentBundleSize == currentBundleTxsExecuted) { | ||
| currentBundleHash = bytes32(0); | ||
| // TODO: Set system status to "done upgrading/active". | ||
| } | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw one high level bit of feedback here is I think that more 'deployment'-esque words could make the operation of this contract clearer. For instance
hasActiveBundleseems more implicit thanhasActiveDeployment.I feel like it's OK to have deploy-specific terminology here because the
ChugSplashDeployeris going to have to handle logic for things like shutting down the contracts to begin a deploy, and restarting them to end the deploy. So idk it seems like it's low value to make things more abstract than they need to be at least at first. Eventually we can break it out into aBundleExecutoror something like that, but in the meantime I just like reminding folks what they are reading