-
Notifications
You must be signed in to change notification settings - Fork 11
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
7702 patch - v2.1.3 #38
Draft
godzillaba
wants to merge
8
commits into
custom-fee-patch
Choose a base branch
from
7702-patch
base: custom-fee-patch
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c506b7c
2.1.3 upgrade path
godzillaba 6340a2c
Merge branch 'custom-fee-patch' into 7702-patch
godzillaba 932ac22
2.1.3 action + script
godzillaba da921f4
fix path
godzillaba 1c77e15
7702 patch readme
godzillaba 5a38ed4
remove todo
godzillaba 6a27c1b
fix
godzillaba f4f878e
fix with updated foundry
godzillaba 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
NitroContracts2Point1Point2UpgradeActionTest:testShouldRevertOnEth() (gas: 61684) | ||
NitroContracts2Point1Point2UpgradeActionTest:testShouldRevertOnV2() (gas: 65683) | ||
NitroContracts2Point1Point2UpgradeActionTest:testShouldUpgradeAndSetDecimals() (gas: 91928) | ||
NitroContracts2Point1Point2UpgradeActionTest:testShouldUpgradeAndSetDecimals() (gas: 92108) | ||
UpgradeArbOSVersionAtTimestampActionTest:test_1() (gas: 165) |
80 changes: 80 additions & 0 deletions
80
contracts/parent-chain/contract-upgrades/NitroContracts2Point1Point3UpgradeAction.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,80 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.16; | ||
|
||
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; | ||
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
import {Address} from "@openzeppelin/contracts/utils/Address.sol"; | ||
|
||
interface IInbox { | ||
function bridge() external view returns (address); | ||
function sequencerInbox() external view returns (address); | ||
} | ||
|
||
interface IERC20Bridge { | ||
function nativeToken() external view returns (address); | ||
} | ||
|
||
interface IERC20Bridge_v2 { | ||
function nativeTokenDecimals() external view returns (uint8); | ||
} | ||
|
||
/** | ||
* @title NitroContracts2Point1Point3UpgradeAction | ||
* @notice Upgrade the bridge to Inbox and SequencerInbox to v2.1.3 | ||
* Will revert if the bridge is an ERC20Bridge below v2.x.x | ||
*/ | ||
contract NitroContracts2Point1Point3UpgradeAction { | ||
address public immutable newEthInboxImpl; | ||
address public immutable newERC20InboxImpl; | ||
address public immutable newSequencerInboxImpl; | ||
|
||
constructor(address _newEthInboxImpl, address _newERC20InboxImpl, address _newSequencerInboxImpl) { | ||
require( | ||
Address.isContract(_newEthInboxImpl), | ||
"NitroContracts2Point1Point3UpgradeAction: _newEthInboxImpl is not a contract" | ||
); | ||
require( | ||
Address.isContract(_newERC20InboxImpl), | ||
"NitroContracts2Point1Point3UpgradeAction: _newERC20InboxImpl is not a contract" | ||
); | ||
require( | ||
Address.isContract(_newSequencerInboxImpl), | ||
"NitroContracts2Point1Point3UpgradeAction: _newSequencerInboxImpl is not a contract" | ||
); | ||
|
||
newEthInboxImpl = _newEthInboxImpl; | ||
newERC20InboxImpl = _newERC20InboxImpl; | ||
newSequencerInboxImpl = _newSequencerInboxImpl; | ||
} | ||
|
||
function perform(address inbox, ProxyAdmin proxyAdmin) external { | ||
address bridge = IInbox(inbox).bridge(); | ||
address sequencerInbox = IInbox(inbox).sequencerInbox(); | ||
|
||
bool isERC20 = false; | ||
|
||
// if the bridge is an ERC20Bridge below v2.x.x, revert | ||
try IERC20Bridge(bridge).nativeToken() returns (address) {} | ||
catch { | ||
isERC20 = true; | ||
// it is an ERC20Bridge, check if it is on v2.x.x | ||
try IERC20Bridge_v2(address(bridge)).nativeTokenDecimals() returns (uint8) {} | ||
catch { | ||
// it is not on v2.x.x, revert | ||
revert("NitroContracts2Point1Point3UpgradeAction: bridge is an ERC20Bridge below v2.x.x"); | ||
} | ||
} | ||
|
||
// upgrade the sequencer inbox | ||
proxyAdmin.upgrade({ | ||
proxy: TransparentUpgradeableProxy(payable((sequencerInbox))), | ||
implementation: newSequencerInboxImpl | ||
}); | ||
|
||
// upgrade the inbox | ||
proxyAdmin.upgrade({ | ||
proxy: TransparentUpgradeableProxy(payable((inbox))), | ||
implementation: isERC20 ? newERC20InboxImpl : newEthInboxImpl | ||
}); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
"@arbitrum/nitro-contracts-1.3.0": "npm:@arbitrum/[email protected]", | ||
"@arbitrum/nitro-contracts-2.1.0": "npm:@arbitrum/[email protected]", | ||
"@arbitrum/nitro-contracts-2.1.2": "npm:[email protected]", | ||
"@arbitrum/nitro-contracts-2.1.3": "npm:[email protected]", | ||
"@arbitrum/token-bridge-1.2.2": "npm:@arbitrum/[email protected]", | ||
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0", | ||
"@nomicfoundation/hardhat-ethers": "^3.0.0", | ||
|
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 @@ | ||
## These env vars are used for ExecuteNitroContracts2Point1Point2UpgradeScript | ||
|
||
UPGRADE_ACTION_ADDRESS= | ||
INBOX_ADDRESS= | ||
PROXY_ADMIN_ADDRESS= | ||
PARENT_UPGRADE_EXECUTOR_ADDRESS= |
34 changes: 34 additions & 0 deletions
34
scripts/foundry/contract-upgrades/2.1.3/DeployNitroContracts2Point1Point3UpgradeAction.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,34 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.16; | ||
|
||
import {DeploymentHelpersScript} from "../../helper/DeploymentHelpers.s.sol"; | ||
import {NitroContracts2Point1Point3UpgradeAction} from | ||
"../../../../contracts/parent-chain/contract-upgrades/NitroContracts2Point1Point3UpgradeAction.sol"; | ||
|
||
/** | ||
* @title DeployNitroContracts2Point1Point2UpgradeActionScript | ||
* @notice This script deploys the ERC20Bridge contract and NitroContracts2Point1Point2UpgradeAction contract. | ||
*/ | ||
contract DeployNitroContracts2Point1Point3UpgradeActionScript is DeploymentHelpersScript { | ||
function run() public { | ||
vm.startBroadcast(); | ||
|
||
// deploy new ERC20Inbox contract from v2.1.3 | ||
address newEthInboxImpl = deployBytecodeFromJSON( | ||
"/node_modules/@arbitrum/nitro-contracts-2.1.3/build/contracts/src/bridge/Inbox.sol/Inbox.json" | ||
); | ||
// deploy new ERC20Inbox contract from v2.1.3 | ||
address newERC20InboxImpl = deployBytecodeFromJSON( | ||
"/node_modules/@arbitrum/nitro-contracts-2.1.3/build/contracts/src/bridge/ERC20Inbox.sol/ERC20Inbox.json" | ||
); | ||
// deploy new ERC20Inbox contract from v2.1.3 | ||
address newSeqInboxImpl = deployBytecodeFromJSON( | ||
"/node_modules/@arbitrum/nitro-contracts-2.1.3/build/contracts/src/bridge/SequencerInbox.sol/SequencerInbox.json" | ||
); | ||
|
||
// deploy upgrade action | ||
new NitroContracts2Point1Point3UpgradeAction(newEthInboxImpl, newERC20InboxImpl, newSeqInboxImpl); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
scripts/foundry/contract-upgrades/2.1.3/ExecuteNitroContracts2Point1Point3Upgrade.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,36 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.16; | ||
|
||
import "forge-std/Script.sol"; | ||
import { | ||
NitroContracts2Point1Point3UpgradeAction, | ||
ProxyAdmin | ||
} from "../../../../contracts/parent-chain/contract-upgrades/NitroContracts2Point1Point3UpgradeAction.sol"; | ||
import {IInboxBase} from "@arbitrum/nitro-contracts-1.2.1/src/bridge/IInboxBase.sol"; | ||
import {IERC20Bridge} from "@arbitrum/nitro-contracts-2.1.2/src/bridge/IERC20Bridge.sol"; | ||
import {IUpgradeExecutor} from "@offchainlabs/upgrade-executor/src/IUpgradeExecutor.sol"; | ||
|
||
/** | ||
* @title ExecuteNitroContracts1Point2Point3UpgradeScript | ||
* @notice This script executes nitro contracts 2.1.3 upgrade through UpgradeExecutor | ||
*/ | ||
contract ExecuteNitroContracts2Point1Point3UpgradeScript is Script { | ||
function run() public { | ||
NitroContracts2Point1Point3UpgradeAction upgradeAction = | ||
NitroContracts2Point1Point3UpgradeAction(vm.envAddress("UPGRADE_ACTION_ADDRESS")); | ||
|
||
address inbox = (vm.envAddress("INBOX_ADDRESS")); | ||
|
||
// prepare upgrade calldata | ||
ProxyAdmin proxyAdmin = ProxyAdmin(vm.envAddress("PROXY_ADMIN_ADDRESS")); | ||
bytes memory upgradeCalldata = | ||
abi.encodeCall(NitroContracts2Point1Point3UpgradeAction.perform, (inbox, proxyAdmin)); | ||
|
||
// execute the upgrade | ||
// action checks prerequisites, and script will fail if the action reverts | ||
IUpgradeExecutor executor = IUpgradeExecutor(vm.envAddress("PARENT_UPGRADE_EXECUTOR_ADDRESS")); | ||
vm.startBroadcast(); | ||
executor.execute(address(upgradeAction), upgradeCalldata); | ||
vm.stopBroadcast(); | ||
} | ||
} |
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,84 @@ | ||
# Nitro contracts 2.1.3 upgrade | ||
|
||
> [!CAUTION] | ||
> This is a patch version and is only necessary for chains that aren't ready for v3.0.0 whose parent chains are upgrading to include EIP7702. | ||
> | ||
> v3.0.0 is also compatible with an EIP7702 enabled parent chain. | ||
|
||
These scripts deploy and execute the `NitroContracts2Point1Point3UpgradeAction` contract which allows Orbit chains to upgrade to [2.1.3 release](https://github.com/OffchainLabs/nitro-contracts/releases/tag/v2.1.3). Predeployed instances of the upgrade action exist on the chains listed in the following section. | ||
|
||
Upgrading to `v2.1.3` not required nor recommended if the chain aims to upgrade to v3.0.0 before the parent chain gets EIP7702. | ||
|
||
`NitroContracts2Point1Point3UpgradeAction` will perform the following action: | ||
|
||
1. Upgrade the `Inbox` or `ERC20Inbox` contract to `v2.1.3` | ||
1. Upgrade the `SequencerInbox` contract to `v2.1.3` | ||
|
||
## Requirements | ||
|
||
This upgrade only support upgrading from the following [nitro-contract release](https://github.com/OffchainLabs/nitro-contracts/releases): | ||
|
||
- Inbox: v1.1.0 - v2.1.0 inclusive | ||
- Outbox: v1.1.0 - v2.1.0 inclusive | ||
- SequencerInbox: v1.2.1 - v2.1.0 inclusive | ||
- Bridge: v1.1.0 - v2.1.0 inclusive (note this is not ERC20Bridge) | ||
- ERC20Bridge: v2.0.0 - v2.1.2 inclusive | ||
- RollupProxy: v1.1.0 - v2.1.0 inclusive | ||
- RollupAdminLogic: v2.0.0 - v2.1.0 inclusive | ||
- RollupUserLogic: v2.0.0 - v2.1.0 inclusive | ||
- ChallengeManager: v2.0.0 - v2.1.0 inclusive | ||
|
||
Please refer to the top [README](/README.md#check-version-and-upgrade-path) `Check Version and Upgrade Path` on how to determine your current nitro contracts version. | ||
|
||
## Deployed instances | ||
|
||
### Mainnets | ||
- L1 Mainnet: TODO | ||
- L2 Arb1: TODO | ||
- L2 Nova: TODO | ||
- L2 Base: TODO | ||
|
||
### Testnets | ||
- L1 Sepolia: TODO | ||
- L1 Holesky: TODO | ||
- L2 ArbSepolia: TODO | ||
- L2 BaseSepolia: TODO | ||
|
||
## How to use it | ||
|
||
1. Setup .env according to the example files, make sure you have everything correctly defined. The .env file must be in project root for recent foundry versions. | ||
|
||
> [!CAUTION] | ||
> The .env file must be in project root. | ||
|
||
2. (Skip this step if you can use the deployed instances of action contract) | ||
`DeployNitroContracts2Point1Point3UpgradeActionScript.s.sol` script deploys templates, and upgrade action itself. It can be executed in this directory like this: | ||
|
||
```bash | ||
forge script --sender $DEPLOYER --rpc-url $PARENT_CHAIN_RPC --broadcast --slow DeployNitroContracts2Point1Point3UpgradeActionScript -vvv --verify --skip-simulation | ||
# use --account XXX / --private-key XXX / --interactive / --ledger to set the account to send the transaction from | ||
``` | ||
|
||
As a result, all templates and upgrade action are deployed. Note the last deployed address - that's the upgrade action. | ||
|
||
3. `ExecuteNitroContracts2Point1Point3Upgrade.s.sol` script uses previously deployed upgrade action to execute the upgrade. It makes following assumptions - L1UpgradeExecutor is the rollup owner, and there is an EOA which has executor rights on the L1UpgradeExecutor. Proceed with upgrade using the owner account (the one with executor rights on L1UpgradeExecutor): | ||
|
||
```bash | ||
forge script --sender $EXECUTOR --rpc-url $PARENT_CHAIN_RPC --broadcast ExecuteNitroContracts2Point1Point3UpgradeScript -vvv | ||
# use --account XXX / --private-key XXX / --interactive / --ledger to set the account to send the transaction from | ||
``` | ||
|
||
If you have a multisig as executor, you can still run the above command without broadcasting to get the payload for the multisig transaction. | ||
|
||
4. That's it, upgrade has been performed. You can make sure it has successfully executed by checking the native token decimals. | ||
|
||
```bash | ||
# should return 18 | ||
cast call --rpc-url $PARENT_CHAIN_RPC $BRIDGE "nativeTokenDecimals()(uint8)" | ||
``` | ||
|
||
## FAQ | ||
|
||
### Q: intrinsic gas too low when running foundry script | ||
|
||
A: try to add -g 1000 to the command |
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,5 +0,0 @@ | ||
{ | ||
"perform()": "b147f40c", | ||
"targetArbOSVersion()": "fcb528a2", | ||
"wasmCachemanager()": "b6763099" | ||
} | ||
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 |
---|---|---|
@@ -1,6 +0,0 @@ | ||
{ | ||
"GNOSIS_COMPATIBILITY_FALLBACK_HANDLER()": "e9f250c1", | ||
"GNOSIS_SAFE_1_3_0()": "acbd7fb4", | ||
"GNOSIS_SAFE_PROXY_FACTORY()": "97ce5a2b", | ||
"perform(address,address[],uint256,uint256)": "6214cbd9" | ||
} | ||
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 |
---|---|---|
@@ -1,7 +0,0 @@ | ||
{ | ||
"newChallengeManagerImpl()": "924ef096", | ||
"newOsp()": "5c4bb63c", | ||
"newSequencerInboxImpl()": "d268538a", | ||
"newWasmModuleRoot()": "6741148c", | ||
"perform(address,address)": "857d1ab7" | ||
} | ||
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.
I think we should include some more comments here as to how this release relates to v2.1.1 and v2.1.2