Skip to content

Commit b9c822d

Browse files
godzillabagzeoneth
andauthored
v2.1.2 decimals patch version (OffchainLabs#36)
* chore: update v3.0.0 meta * feat: add any * docs: comments * chore: add rei hashes * fix: type * feat: check fee token * feat: v3 upgrade check * docs: bold upgrade draft * add version path * fmt * add action * fix * snapshot * add tests * readme * deployment script * execution script * format * Revert "format" This reverts commit 6fc72a0. * reformat * tight broadcast * Update README.md * misc * fix * postUpgradeInit * main readme * Update scripts/foundry/contract-upgrades/3.0.0/README.md Co-authored-by: gzeon <[email protected]> * readme tweak * note * Update scripts/foundry/contract-upgrades/3.0.0/README.md * add 2.1.2 to 3.0.0 allowed versions * typo * fix: disable custom fee token chain support for v3 for now * replace npm package * metadata hashes * chore: no bold upgrade * chore: also remove v3 hashes * ci: use foundry stable * fix: lint * test: remove pretty flag from inspect * test: commit new format * chore: deployments --------- Co-authored-by: gzeon <[email protected]> Co-authored-by: gzeon <[email protected]>
1 parent 6f40634 commit b9c822d

29 files changed

+763
-123
lines changed

.gas-snapshot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
NitroContracts2Point1Point2UpgradeActionTest:testShouldRevertOnEth() (gas: 61684)
2+
NitroContracts2Point1Point2UpgradeActionTest:testShouldRevertOnV2() (gas: 65683)
3+
NitroContracts2Point1Point2UpgradeActionTest:testShouldUpgradeAndSetDecimals() (gas: 91928)
14
UpgradeArbOSVersionAtTimestampActionTest:test_1() (gas: 165)

.github/workflows/audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Foundry
2121
uses: foundry-rs/foundry-toolchain@v1
2222
with:
23-
version: nightly
23+
version: stable
2424

2525
- run: yarn minimal-install
2626
- run: yarn audit:ci

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Foundry
2121
uses: foundry-rs/foundry-toolchain@v1
2222
with:
23-
version: nightly
23+
version: stable
2424

2525
- run: yarn && yarn build
2626
- run: yarn lint

.github/workflows/test-e2e.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install Foundry
2626
uses: foundry-rs/foundry-toolchain@v1
2727
with:
28-
version: nightly
28+
version: stable
2929

3030
- run: yarn
3131
- run: cp .env.example .env && yarn test:e2e
@@ -52,7 +52,7 @@ jobs:
5252
# - name: Install Foundry
5353
# uses: foundry-rs/foundry-toolchain@v1
5454
# with:
55-
# version: nightly
55+
# version: stable
5656

5757
# - run: yarn
5858
# - run: cp .env.example .env && yarn test:e2e
@@ -80,7 +80,7 @@ jobs:
8080
# - name: Install Foundry
8181
# uses: foundry-rs/foundry-toolchain@v1
8282
# with:
83-
# version: nightly
83+
# version: stable
8484

8585
# - run: yarn
8686
# - run: cp .env.example .env && yarn test:e2e

.github/workflows/test-fork.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Foundry
2121
uses: foundry-rs/foundry-toolchain@v1
2222
with:
23-
version: nightly
23+
version: stable
2424

2525
- run: yarn minimal-install
2626
- run: ETH_FORK_URL=${{ secrets.ETH_FORK_URL }} ARB_FORK_URL=${{ secrets.ARB_FORK_URL }} yarn test:fork

.github/workflows/test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Foundry
2121
uses: foundry-rs/foundry-toolchain@v1
2222
with:
23-
version: nightly
23+
version: stable
2424

2525
- run: yarn minimal-install
2626
- run: yarn test:unit
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install Foundry
3636
uses: foundry-rs/foundry-toolchain@v1
3737
with:
38-
version: nightly
38+
version: stable
3939

4040
- run: yarn minimal-install
4141
- run: yarn test:sizes
@@ -50,7 +50,7 @@ jobs:
5050
- name: Install Foundry
5151
uses: foundry-rs/foundry-toolchain@v1
5252
with:
53-
version: nightly
53+
version: stable
5454

5555
- run: yarn minimal-install
5656
- run: yarn test:gas-check
@@ -65,7 +65,7 @@ jobs:
6565
- name: Install Foundry
6666
uses: foundry-rs/foundry-toolchain@v1
6767
with:
68-
version: nightly
68+
version: stable
6969

7070
- run: yarn minimal-install
7171
- run: yarn test:sigs
@@ -80,7 +80,7 @@ jobs:
8080
- name: Install Foundry
8181
uses: foundry-rs/foundry-toolchain@v1
8282
with:
83-
version: nightly
83+
version: stable
8484

8585
- run: yarn minimal-install
8686
- run: yarn test:storage

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ _This section is also referenced in the documentation on ["How to upgrade ArbOS
5050

5151
For ArbOS upgrades, a common pre-requisite is to deploy new Nitro contracts to the parent chain of your Orbit chain before scheduling the ArbOS upgrade. These contracts include the rollup logic, fraud proof contracts, and interfaces for interacting with Nitro precompiles. The scripts and instructions in this repository are meant for Orbit chain owners to upgrade the aforementioned contracts, set the new WASM module root, and then schedule the ArbOS upgrade.
5252

53+
### Nitro contracts 2.1.2
54+
55+
The [`nitro-contracts 2.1.2` upgrade guide](scripts/foundry/contract-upgrades/2.1.2) will patch the `ERC20Bridge` with a storage layout fix.
56+
57+
This upgrade is only required if:
58+
59+
1. The chain has a custom native token; AND
60+
1. The chain was originally deployed before `v2.0.0`; AND
61+
1. The chain wishes to upgrade to `v3.0.0`
62+
63+
Do not perform this upgrade if the above requirements aren't met.
64+
5365
### Nitro contracts 2.1.0 (for [ArbOS 32 Bianca](https://docs.arbitrum.io/run-arbitrum-node/arbos-releases/arbos32))
5466

5567
The [`nitro-contracts 2.1.0` upgrade action](scripts/foundry/contract-upgrades/2.1.0) will deploy `nitro-contracts v2.1.0` contracts to your Orbit's parent chain. Note that this action will only work for chains with `nitro-contracts v1.2.1` or `nitro-contracts v1.3.0`.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity 0.8.16;
3+
4+
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
5+
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
6+
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
7+
8+
interface IERC20Bridge {
9+
function nativeToken() external view returns (address);
10+
}
11+
12+
interface IERC20Bridge_v2 {
13+
function nativeTokenDecimals() external view returns (uint8);
14+
}
15+
16+
interface IERC20Bridge_v2_patch {
17+
function postUpgradeInit() external;
18+
}
19+
20+
/**
21+
* @title NitroContracts2Point1Point2UpgradeAction
22+
* @notice Upgrade the bridge to ERC20Bridge v2.1.2 and force it to set nativeTokenDecimals to 18.
23+
* Will revert if the bridge is not an ERC20Bridge.
24+
* Will revert if ERC20Bridge is not v1.x.x
25+
*/
26+
contract NitroContracts2Point1Point2UpgradeAction {
27+
address public immutable newBridgeImpl;
28+
29+
constructor(address _newBridgeImpl) {
30+
require(
31+
Address.isContract(_newBridgeImpl),
32+
"NitroContracts2Point1Point2UpgradeAction: _newBridgeImpl is not a contract"
33+
);
34+
35+
newBridgeImpl = _newBridgeImpl;
36+
}
37+
38+
function perform(address bridge, ProxyAdmin proxyAdmin) external {
39+
// ensure the bridge is an ERC20Bridge
40+
try IERC20Bridge(bridge).nativeToken() returns (address) {}
41+
catch {
42+
// nativeToken() reverted, so it's not an ERC20Bridge
43+
revert("NitroContracts2Point1Point2UpgradeAction: bridge is not an ERC20Bridge");
44+
}
45+
46+
// ensure the bridge is v1.x.x
47+
try IERC20Bridge_v2(address(bridge)).nativeTokenDecimals() returns (uint8) {
48+
// nativeTokenDecimals() didn't revert, so it must be v2.x.x
49+
revert("NitroContracts2Point1Point2UpgradeAction: bridge is not v1.x.x");
50+
} catch {}
51+
52+
// upgrade to the new implementation and call forceEighteenDecimalsPatch
53+
proxyAdmin.upgradeAndCall({
54+
proxy: TransparentUpgradeableProxy(payable((bridge))),
55+
implementation: newBridgeImpl,
56+
data: abi.encodeCall(IERC20Bridge_v2_patch.postUpgradeInit, ())
57+
});
58+
59+
// ensure decimals were set to 18
60+
require(IERC20Bridge_v2((bridge)).nativeTokenDecimals() == 18, "decimals not set to 18");
61+
}
62+
}

foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ test = 'test'
66
cache_path = 'cache_forge'
77
solc_version = '0.8.16'
88
optimizer_runs = 2000
9-
fs_permissions = [{ access = "read", path = "node_modules/@arbitrum/"}, { access = "read", path = "node_modules/@openzeppelin/"},{ access = "read-write", path = "./scripts/foundry"}]
9+
fs_permissions = [{ access = "read", path = "node_modules/@offchainlabs/"},{ access = "read", path = "node_modules/@arbitrum/"}, { access = "read", path = "node_modules/@openzeppelin/"},{ access = "read-write", path = "./scripts/foundry"}]
1010
script = 'scripts'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@arbitrum/nitro-contracts-1.2.1": "npm:@arbitrum/[email protected]",
2929
"@arbitrum/nitro-contracts-1.3.0": "npm:@arbitrum/[email protected]",
3030
"@arbitrum/nitro-contracts-2.1.0": "npm:@arbitrum/[email protected]",
31+
"@arbitrum/nitro-contracts-2.1.2": "npm:@arbitrum/[email protected]",
3132
"@arbitrum/token-bridge-1.2.2": "npm:@arbitrum/[email protected]",
3233
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
3334
"@nomicfoundation/hardhat-ethers": "^3.0.0",

0 commit comments

Comments
 (0)