Skip to content

Commit 0edf861

Browse files
godzillabagzeoneth
andauthored
feat: use create2 for factory deployment (#358)
* wip: use create2 for factory deployment * remove key from config * fmt * fix signatures * inline up exec deployment * salt length check * update tests * fmt * remove SetTemplatesArgs struct * remove ownership from bridge creator * add CREATE2_FACTORY env and deployment instructions * fix signatures * factory owner as deployAllContracts arg * set deployer as owner in local deployment * chore: disable metahash and align hardhat foundry (#363) * disable CBOR * chore: remove entries for removed files * refactor: commonSetting * feat: foundry override * fix: test * chore: default profile * format: yarn format * ci: comapre bytecodes * fix: slither db --------- Co-authored-by: gzeon <im@gzeon.dev> * fix: deploy create2 factory for local deployment * fix: wait for funding * ci: use geth-allow-pre155 * fix: _uint256ToAddress helper * fix: deploy4844 script * fix: apply review comments --------- Co-authored-by: gzeon <im@gzeon.dev>
1 parent 0a69aeb commit 0edf861

18 files changed

+503
-218
lines changed

.env-sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ L1_PRIV_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
22
CONFIG_NETWORK_NAME="custom"
33
DEPLOYED_CONTRACTS_DIR="./scripts/files/"
44
DISABLE_VERIFICATION=true
5+
FACTORY_OWNER=0x000000000000000000000000000000000000dead
6+
7+
CREATE2_FACTORY=0x4e59b44847b379578588920cA78FbF26c0B4956C
58

69
# to use the 'custom' hardhat network, set the following variables
710
CUSTOM_RPC_URL="http://127.0.0.1:8545"

.github/workflows/contract-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ jobs:
7979
- name: Lint Test Scripts
8080
run: yarn lint:test
8181

82+
- name: Compare bytecodes
83+
run: yarn test:bytecodes
84+
8285
- name: Build
8386
run: yarn build:all
8487

@@ -169,7 +172,7 @@ jobs:
169172
no-token-bridge: true
170173
no-l3-token-bridge: true
171174
nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
172-
nitro-testnode-ref: release
175+
nitro-testnode-ref: geth-allow-pre155
173176

174177
- name: Setup node/yarn
175178
uses: actions/setup-node@v3
@@ -202,7 +205,7 @@ jobs:
202205
no-token-bridge: true
203206
no-l3-token-bridge: true
204207
nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
205-
nitro-testnode-ref: release
208+
nitro-testnode-ref: geth-allow-pre155
206209

207210
- name: Setup node/yarn
208211
uses: actions/setup-node@v3
@@ -234,7 +237,7 @@ jobs:
234237
args: --l3-fee-token --l3-fee-token-pricer --l3-fee-token-decimals 6
235238
no-token-bridge: true
236239
no-l3-token-bridge: true
237-
nitro-testnode-ref: release
240+
nitro-testnode-ref: geth-allow-pre155
238241
nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
239242

240243
- name: Setup node/yarn

foundry.toml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ cache_path = 'forge-cache/sol'
77
optimizer = true
88
optimizer_runs = 2000
99
via_ir = false
10-
evm_version = 'cancun'
10+
evm_version = 'london'
11+
solc_version = '0.8.17'
12+
bytecode_hash = 'none'
1113
remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/',
1214
'forge-std/=lib/forge-std/src/',
1315
'@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/',
@@ -16,14 +18,33 @@ remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/',
1618
'@uniswap/v2-core/=node_modules/@uniswap/v2-core/contracts',
1719
'@uniswap/lib/=node_modules/@uniswap/lib/contracts']
1820
fs_permissions = [{ access = "read", path = "./"}]
21+
additional_compiler_profiles = [
22+
{ name = "20_runs", optimizer_runs = 20 },
23+
{ name = "200_runs", optimizer_runs = 200 },
24+
{ name = "default", optimizer_runs = 2000 }
25+
]
26+
compilation_restrictions = [
27+
{ paths = "src/rollup/RollupUserLogic.sol", optimizer_runs = 20 },
28+
{ paths = "src/challengeV2/EdgeChallengeManager.sol", optimizer_runs = 200 },
29+
]
30+
skip = ['test/*']
31+
32+
[profile.test]
33+
inherit = "default"
34+
optimizer = false
35+
additional_compiler_profiles = []
36+
compilation_restrictions = []
37+
skip = []
1938

2039
[profile.yul]
40+
inherit = "default"
2141
src = 'yul'
2242
out = 'out/yul'
2343
libs = ['node_modules', 'lib']
2444
cache_path = 'forge-cache/yul'
2545
remappings = []
2646
auto_detect_remappings = false
47+
skip = ['*.sol', 'test/*']
2748

2849
[fmt]
2950
line_length = 100

hardhat.config.ts

Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,51 @@ import 'hardhat-gas-reporter'
88
import 'hardhat-contract-sizer'
99
import 'hardhat-ignore-warnings'
1010
import dotenv from 'dotenv'
11+
import { SolidityConfig } from 'hardhat/types'
1112

1213
dotenv.config()
1314

14-
const solidity = {
15+
const commonSetting = {
16+
metadata: {
17+
bytecodeHash: 'none',
18+
},
19+
optimizer: {
20+
enabled: true,
21+
runs: 2000, // default value, can be overridden
22+
},
23+
evmVersion: 'london',
24+
}
25+
26+
const solidity: SolidityConfig = {
1527
compilers: [
1628
{
1729
version: '0.8.17',
18-
settings: {
19-
optimizer: {
20-
enabled: true,
21-
runs: 2000,
22-
},
23-
},
30+
settings: { ...commonSetting },
2431
},
2532
],
2633
overrides: {
2734
'src/rollup/RollupUserLogic.sol': {
2835
version: '0.8.17',
2936
settings: {
30-
optimizer: {
31-
enabled: true,
32-
runs: 20,
33-
},
37+
...commonSetting,
38+
optimizer: { ...commonSetting.optimizer, runs: 20 },
3439
},
3540
},
3641
'src/challengeV2/EdgeChallengeManager.sol': {
3742
version: '0.8.17',
3843
settings: {
39-
optimizer: {
40-
enabled: true,
41-
runs: 200,
42-
},
43-
},
44-
},
45-
'src/mocks/HostioTest.sol': {
46-
version: '0.8.24',
47-
settings: {
48-
optimizer: {
49-
enabled: true,
50-
runs: 100,
51-
},
52-
evmVersion: 'cancun',
53-
},
54-
},
55-
'src/mocks/ArbOS11To32UpgradeTest.sol': {
56-
version: '0.8.24',
57-
settings: {
58-
optimizer: {
59-
enabled: true,
60-
runs: 100,
61-
},
62-
evmVersion: 'cancun',
44+
...commonSetting,
45+
optimizer: { ...commonSetting.optimizer, runs: 200 },
6346
},
6447
},
6548
},
6649
}
6750

6851
if (process.env['INTERFACE_TESTER_SOLC_VERSION']) {
52+
console.log(
53+
'Running in interface tester mode with solc version',
54+
process.env['INTERFACE_TESTER_SOLC_VERSION']
55+
)
6956
solidity.compilers.push({
7057
version: process.env['INTERFACE_TESTER_SOLC_VERSION'],
7158
settings: {
@@ -88,26 +75,6 @@ if (process.env['INTERFACE_TESTER_SOLC_VERSION']) {
8875
},
8976
},
9077
},
91-
'src/mocks/HostioTest.sol': {
92-
version: '0.8.24',
93-
settings: {
94-
optimizer: {
95-
enabled: true,
96-
runs: 100,
97-
},
98-
evmVersion: 'cancun',
99-
},
100-
},
101-
'src/mocks/ArbOS11To32UpgradeTest.sol': {
102-
version: '0.8.24',
103-
settings: {
104-
optimizer: {
105-
enabled: true,
106-
runs: 100,
107-
},
108-
evmVersion: 'cancun',
109-
},
110-
},
11178
}
11279
}
11380

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
"audit:ci": "audit-ci --config ./audit-ci.jsonc",
2222
"audit:fix": "yarn-audit-fix",
2323
"prepublishOnly": "hardhat clean && forge clean && hardhat compile && yarn build:forge:yul",
24-
"coverage": "forge coverage --report lcov --ir-minimum && lcov --remove lcov.info 'node_modules/*' 'test/*' 'script/*' 'src/test-helpers/*' 'challenge/*' --ignore-errors unused -o lcov.info && genhtml lcov.info --branch-coverage --output-dir coverage",
24+
"coverage": "FOUNDRY_PROFILE=test forge coverage --report lcov --ir-minimum && lcov --remove lcov.info 'node_modules/*' 'test/*' 'script/*' 'src/test-helpers/*' 'challenge/*' --ignore-errors unused -o lcov.info && genhtml lcov.info --branch-coverage --output-dir coverage",
2525
"build:all": "yarn build && yarn build:forge",
2626
"build": "hardhat compile",
2727
"build:forge:sol": "forge build --skip *.yul",
28-
"build:forge:yul": "FOUNDRY_PROFILE=yul forge build --skip *.sol",
28+
"build:forge:yul": "FOUNDRY_PROFILE=yul forge build",
2929
"build:forge": "yarn build:forge:sol && yarn build:forge:yul",
3030
"contract:size": "hardhat size-contracts",
3131
"lint:test": "eslint ./test",
@@ -44,8 +44,9 @@
4444
"test:e2e": "hardhat test test/e2e/*.ts",
4545
"test:e2e:stylus": "hardhat test test/e2e/stylusDeployer.ts",
4646
"test:upgrade": "./scripts/testUpgrade.bash",
47-
"test:foundry": "forge test --gas-limit 10000000000",
47+
"test:foundry": "FOUNDRY_PROFILE=test forge test --gas-limit 10000000000",
4848
"test:update": "yarn run test:signatures || yarn run test:storage",
49+
"test:bytecodes": "hardhat clean && forge clean && hardhat run scripts/compareBytecodes.ts",
4950
"metadatahash": "yarn build:all && hardhat run scripts/printMetadataHashes.ts",
5051
"upload-4bytes": "forge build && find ./out -type f -name \"*.json\" -exec cast upload-signature {} + | grep -v Duplicated:",
5152
"postinstall": "patch-package",

0 commit comments

Comments
 (0)