forked from OffchainLabs/orbit-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add action contracts for migrating live orbit chains to espresso #1
Merged
Merged
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
4ebee9a
Add migration contract and test.
zacshowa 7b31c80
add espresso ArbOS upgrade contract
zacshowa 38ec00d
commit example .env files for upgrades.
zacshowa 944af15
commit yarn.lock and package.json for new dependencies.
zacshowa 5f1a716
add nitro-contracts submodule.
zacshowa a79bb05
Add license identifier to contracts
zacshowa 7098927
Update the EspressoArbOSUpgrade.sol contract to import the UpgradeArb…
zacshowa 3c35709
address PR feedback
zacshowa 3440e75
add nitro-contracts submodule to .gitmodules
zacshowa 9004894
remove unused nitro-contracts submodule
zacshowa 637f8ef
forge install: nitro-contracts.git
zacshowa 0ef9057
forge install: nitro-contracts
zacshowa 8e72997
Deployment scripts and foundry remappings
zacshowa 261b147
fix broken submodule from forge install
zacshowa 15b00f0
Updates to action upgrade contracts.
zacshowa 3a798bd
Commit with current progress: updates to contracts
zacshowa 853faad
Update the rollup address
ImJeremyHe c9a1eeb
Set adresses and module roots via env vars
sveitser 1123bb5
move migration scripts to their own folder
zacshowa 0677dca
Add WIP README.md for the migration
zacshowa 313d834
Update ArbOS action upgrade to take a timestamp parameter.
zacshowa fb31130
update .example-env for reference in the README.md
zacshowa 1fe92a4
Update README.md to explain the full migration process.
zacshowa 5df09a9
update Migration solidity test to point to relocated migration action…
zacshowa fcb0ff9
Update migration/README.md
zacshowa dc57c2c
run forge fmt
zacshowa c993b69
Update README.md to reflect PR feedback
zacshowa b914e97
Merge branch 'espresso-migration' of github.com:EspressoSystems/orbit…
zacshowa 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 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
17 changes: 17 additions & 0 deletions
17
contracts/child-chain/arbos-upgrade/DeployArbOSUpgradeAction.s.sol
This file contains 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,17 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
|
||
import "forge-std/Script.sol"; | ||
import "./EspressoArbOSUpgrade.sol"; | ||
|
||
contract DeployArbOSUpgradeAction is Script{ | ||
function run() external{ | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
uint64 upgradeTimestamp = uint64(vm.envUint("UPGRADE_TIMESTAMP")); | ||
vm.startBroadcast(deployerPrivateKey); | ||
EspressoArbOSUpgrade arbOSUpgrade = new EspressoArbOSUpgrade( | ||
upgradeTimestamp | ||
); | ||
vm.stopBroadcast(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
contracts/child-chain/arbos-upgrade/EspressoArbOSUpgrade.sol
This file contains 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,16 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.16; | ||
|
||
import "forge-std/Script.sol"; | ||
import "./UpgradeArbOSVersionAtTimestampAction.sol"; | ||
|
||
contract EspressoArbOSUpgrade is UpgradeArbOSVersionAtTimestampAction, Script { | ||
constructor( | ||
uint64 upgradeTimestamp | ||
) | ||
UpgradeArbOSVersionAtTimestampAction( | ||
35, | ||
upgradeTimestamp | ||
) | ||
{} | ||
} |
6 changes: 6 additions & 0 deletions
6
contracts/parent-chain/contract-upgrades/example-env/.env-espresso-osp-migration.example
This file contains 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 @@ | ||
export NEW_OSP_ENTRY="0x7B5F0B437EE68A22992DdD629AA22525Fc5dfa9A" | ||
export NEW_WASM_MODULE_ROOT="0x43683fe4e619e9ee7c0d959259d10ff2a38f4325a2b8936c47d9162704fe072a" | ||
export CURRENT_OSP_ENTRY="0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97" | ||
export CURRENT_WASM_MODULE_ROOT="0xbc1026ff45c20ea97e9e6057224a5668ea78d8f885c9b14fc849238e8ef5c5dc" | ||
export ROLLUP_ADDRESS="0xF2099c4783921f44Ac988B67e743DAeFd4A00efd" | ||
export PROXY_ADMIN="0x94e2090Fb86906C799A67263e6beAe528b81B3D6" |
1 change: 1 addition & 0 deletions
1
contracts/parent-chain/contract-upgrades/example-env/.env-schedule-arbos-upgrade.example
This file contains 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 @@ | ||
export UPGRADE_TIMESTAMP = "1723664126" | ||
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. same here |
25 changes: 25 additions & 0 deletions
25
contracts/parent-chain/espresso-migration/DeployEspressoOsp.s.sol
This file contains 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 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
|
||
import "forge-std/Script.sol"; | ||
import "nitro-contracts/osp/OneStepProverMemory.sol"; | ||
import "nitro-contracts/osp/OneStepProverMath.sol"; | ||
import "nitro-contracts/osp/OneStepProverHostIo.sol"; | ||
import "nitro-contracts/osp/OneStepProver0.sol"; | ||
import "nitro-contracts/osp/OneStepProofEntry.sol"; | ||
|
||
|
||
contract DeployEspressoOsp is Script{ | ||
function run() external{ | ||
address hotshotAddr = vm.envAddress("HOTSHOT_ADDRESS"); | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
vm.startBroadcast(deployerPrivateKey); | ||
OneStepProofEntry newOSP = new OneStepProofEntry( | ||
new OneStepProver0(), | ||
new OneStepProverMemory(), | ||
new OneStepProverMath(), | ||
new OneStepProverHostIo(hotshotAddr) | ||
); | ||
vm.stopBroadcast(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
contracts/parent-chain/espresso-migration/DeployEspressoOspMigrationAction.s.sol
This file contains 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 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
|
||
import "forge-std/Script.sol"; | ||
import "./EspressoOspMigrationAction.sol"; | ||
|
||
contract DeployEspressoOspMigrationAction is Script{ | ||
function run() external{ | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
address newOspEntry = vm.envAddress("NEW_OSP_ENTRY"); | ||
bytes32 newWasmModuleRoot = vm.envBytes32("NEW_WASM_MODULE_ROOT"); | ||
address currentOspEntry = vm.envAddress("CURRENT_OSP_ENTRY"); | ||
bytes32 currentWasmModuleRoot = vm.envBytes32("CURRENT_WASM_MODULE_ROOT"); | ||
address rollup = vm.envAddress("ROLLUP_ADDRESS"); | ||
address proxyAdmin = vm.envAddress("PROXY_ADMIN"); | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
OspMigrationAction migrationAction = new OspMigrationAction( | ||
newOspEntry, | ||
newWasmModuleRoot, | ||
currentOspEntry, | ||
currentWasmModuleRoot, | ||
rollup, | ||
proxyAdmin | ||
); | ||
vm.stopBroadcast(); | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
contracts/parent-chain/espresso-migration/EspressoOspMigrationAction.sol
This file contains 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,102 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.9; | ||
|
||
import "forge-std/Script.sol"; | ||
import "@arbitrum/nitro-contracts/src/challenge/IChallengeManager.sol"; | ||
import "@arbitrum/nitro-contracts/src/rollup/IRollupCore.sol"; | ||
import "@arbitrum/nitro-contracts/src/rollup/IRollupAdmin.sol"; | ||
|
||
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; | ||
import "@openzeppelin/contracts/utils/Address.sol"; | ||
|
||
contract OspMigrationAction{ | ||
|
||
error IncorrectWasmModuleRoot(bytes32 incorrectAddr); | ||
|
||
error AddressIsNotContract(address incorrectAddr); | ||
|
||
error ChallengeManagerUpdated(address newChallengeManagerAddr); | ||
|
||
error OspNotUpgraded(address oldOspAddress); | ||
|
||
error WasmModuleRootNotUpdated(bytes32 oldWasmModuleRoot); | ||
|
||
address public immutable newOspEntry; | ||
bytes32 public immutable newWasmModuleRoot; | ||
bytes32 public immutable currentWasmModuleRoot; | ||
address public immutable currentOspEntry; | ||
address public immutable rollup; | ||
address public immutable proxyAdmin; | ||
|
||
|
||
constructor( | ||
address _newOspEntry, | ||
bytes32 _newWasmModuleRoot, | ||
address _currentOspEntry, | ||
bytes32 _currentWasmModuleRoot, | ||
address _rollup, | ||
address _proxyAdmin | ||
){ | ||
if(_newWasmModuleRoot == bytes32(0)){ | ||
revert IncorrectWasmModuleRoot(_newWasmModuleRoot); | ||
} | ||
|
||
if(_currentWasmModuleRoot == bytes32(0)){ | ||
revert IncorrectWasmModuleRoot(_currentWasmModuleRoot); | ||
} | ||
|
||
if(!Address.isContract(_newOspEntry)){ | ||
revert AddressIsNotContract(_newOspEntry); | ||
} | ||
|
||
if(!Address.isContract(_currentOspEntry)){ | ||
revert AddressIsNotContract(_currentOspEntry); | ||
} | ||
|
||
if(!Address.isContract(_proxyAdmin)){ | ||
revert AddressIsNotContract(_proxyAdmin); | ||
} | ||
|
||
if(!Address.isContract(_rollup)){ | ||
revert AddressIsNotContract(_rollup); | ||
} | ||
newOspEntry = _newOspEntry; | ||
newWasmModuleRoot = _newWasmModuleRoot; | ||
currentOspEntry = _currentOspEntry; | ||
currentWasmModuleRoot = _currentWasmModuleRoot; | ||
rollup = _rollup; | ||
proxyAdmin = _proxyAdmin; | ||
} | ||
|
||
function perform() external{ | ||
//Handle assertions in the perform function as we shouldn't be storing local state for delegated calls. | ||
|
||
// set the new challenge manager impl | ||
TransparentUpgradeableProxy challengeManager = | ||
TransparentUpgradeableProxy(payable(address(IRollupCore(rollup).challengeManager()))); | ||
address chalManImpl = ProxyAdmin(proxyAdmin).getProxyImplementation(challengeManager); | ||
ProxyAdmin(proxyAdmin).upgradeAndCall( | ||
challengeManager, | ||
chalManImpl, // Use the rollups current challenge manager as we only need to upgrade the OSP | ||
abi.encodeWithSelector(IChallengeManager.postUpgradeInit.selector, IOneStepProofEntry(newOspEntry), currentWasmModuleRoot, IOneStepProofEntry(currentOspEntry)) | ||
); | ||
address postUpgradeChalManAddr = ProxyAdmin(proxyAdmin).getProxyImplementation(challengeManager); | ||
|
||
if(postUpgradeChalManAddr != chalManImpl){ | ||
revert ChallengeManagerUpdated(postUpgradeChalManAddr); | ||
} | ||
IOneStepProofEntry newOsp = IChallengeManager(address(challengeManager)).osp(); | ||
|
||
if(newOsp != IOneStepProofEntry(newOspEntry) ){ | ||
Sneh1999 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
revert OspNotUpgraded(address(newOsp)); | ||
} | ||
|
||
IRollupAdmin(rollup).setWasmModuleRoot(newWasmModuleRoot); | ||
|
||
bytes32 postUpgradeWasmModuleRoot = IRollupCore(rollup).wasmModuleRoot(); | ||
|
||
if(postUpgradeWasmModuleRoot != newWasmModuleRoot){ | ||
revert WasmModuleRootNotUpdated(postUpgradeWasmModuleRoot); | ||
} | ||
} | ||
} |
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.
Nit: I dont think you need
export
in front of the environment variables ( example here)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.
This might just be from my lack of familiarity with forge and foundry. I couldn't get the env vars to be visible to the tests unless I exported them. Sourcing the file without exporting them doesn't propagate the vars to any child processes, e.g.
forge test
.If there is a different way I'm supposed to supply forge with the env vars I would love to know about it!
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.
If the file is called .env exactly it is special and automatically picked up by foundry and many other tools. Unfortunately it has to be exactly .env in the case of foundry.
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.
you can do
source .env-espresso-osp-migration && forge test <>
to be able to have a foundry script pick up env variables that's not in the expected.env
file.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.
That's true but then breaks the ability of being able to override with env vars. So this can get messy when used in scripts if one expects environment variable that are already set to take precedence.
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.
that's true. we aren't using the .env file for secrets anymore but only for config (since that's how it's been set up historically). So should this go into the .env file?
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.
It seems to be how existing orbit upgrades are configured in the orbit-actions repo. I think it's a good idea to stick to how things are done in that repo unless it really gets in our way.