Skip to content

Commit 50cbad0

Browse files
authored
Merge pull request #252 from OffchainLabs/custom-fee-rollup
Support for rollup mode when using fee token
2 parents 6ea9d8d + 9d0e90e commit 50cbad0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2215
-231
lines changed

.github/workflows/contract-tests.yml

+83-80
Original file line numberDiff line numberDiff line change
@@ -154,101 +154,104 @@ jobs:
154154

155155
- name: Test 4844
156156
run: yarn test:4844
157-
# test-e2e:
158-
# name: Test e2e
159-
# runs-on: ubuntu-latest
160-
# steps:
161-
# - uses: actions/checkout@v3
162-
# with:
163-
# submodules: recursive
164157

165-
# - uses: OffchainLabs/actions/run-nitro-test-node@main
166-
# with:
167-
# l3-node: true
168-
# no-token-bridge: true
169-
# no-l3-token-bridge: true
170-
# nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
171-
# nitro-testnode-ref: node-18
158+
test-e2e:
159+
name: Test e2e
160+
runs-on: ubuntu-latest
161+
steps:
162+
- uses: actions/checkout@v3
163+
with:
164+
submodules: recursive
172165

173-
# - name: Setup node/yarn
174-
# uses: actions/setup-node@v3
175-
# with:
176-
# node-version: 18
177-
# cache: 'yarn'
178-
# cache-dependency-path: '**/yarn.lock'
166+
- uses: OffchainLabs/actions/run-nitro-test-node@main
167+
with:
168+
l3-node: true
169+
no-token-bridge: true
170+
no-l3-token-bridge: true
171+
nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
172+
nitro-testnode-ref: v3-support
179173

180-
# - name: Install packages
181-
# run: yarn
174+
- name: Setup node/yarn
175+
uses: actions/setup-node@v3
176+
with:
177+
node-version: 18
178+
cache: 'yarn'
179+
cache-dependency-path: '**/yarn.lock'
182180

183-
# - name: Compile contracts
184-
# run: yarn build
181+
- name: Install packages
182+
run: yarn
185183

186-
# - name: Run e2e tests
187-
# run: yarn test:e2e
188-
# test-e2e-custom-fee-token:
189-
# name: Test e2e custom fee token
190-
# runs-on: ubuntu-latest
191-
# steps:
192-
# - uses: actions/checkout@v3
193-
# with:
194-
# submodules: recursive
184+
- name: Compile contracts
185+
run: yarn build
195186

196-
# - uses: OffchainLabs/actions/run-nitro-test-node@main
197-
# with:
198-
# l3-node: true
199-
# args: --l3-fee-token
200-
# no-token-bridge: true
201-
# no-l3-token-bridge: true
202-
# nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
203-
# nitro-testnode-ref: node-18
187+
- name: Run e2e tests
188+
run: yarn test:e2e
204189

205-
# - name: Setup node/yarn
206-
# uses: actions/setup-node@v3
207-
# with:
208-
# node-version: 18
209-
# cache: 'yarn'
210-
# cache-dependency-path: '**/yarn.lock'
190+
test-e2e-custom-fee-token:
191+
name: Test e2e custom fee token
192+
runs-on: ubuntu-latest
193+
steps:
194+
- uses: actions/checkout@v3
195+
with:
196+
submodules: recursive
211197

212-
# - name: Install packages
213-
# run: yarn
198+
- uses: OffchainLabs/actions/run-nitro-test-node@main
199+
with:
200+
l3-node: true
201+
args: --l3-fee-token
202+
no-token-bridge: true
203+
no-l3-token-bridge: true
204+
nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
205+
nitro-testnode-ref: v3-support
214206

215-
# - name: Compile contracts
216-
# run: yarn build
207+
- name: Setup node/yarn
208+
uses: actions/setup-node@v3
209+
with:
210+
node-version: 18
211+
cache: 'yarn'
212+
cache-dependency-path: '**/yarn.lock'
217213

218-
# - name: Run e2e tests
219-
# run: yarn test:e2e
220-
# test-e2e-fee-token-6-decimals:
221-
# name: Test e2e fee token with 6 decimals
222-
# runs-on: ubuntu-latest
223-
# steps:
224-
# - uses: actions/checkout@v3
225-
# with:
226-
# submodules: recursive
214+
- name: Install packages
215+
run: yarn
227216

228-
# - uses: OffchainLabs/actions/run-nitro-test-node@main
229-
# with:
230-
# l3-node: true
231-
# args: --l3-fee-token --l3-fee-token-decimals 6
232-
# no-token-bridge: true
233-
# no-l3-token-bridge: true
234-
# nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
235-
# nitro-testnode-ref: 'non18-decimal-token-node-18'
217+
- name: Compile contracts
218+
run: yarn build
236219

237-
# - name: Setup node/yarn
238-
# uses: actions/setup-node@v3
239-
# with:
240-
# node-version: 18
241-
# cache: 'yarn'
242-
# cache-dependency-path: '**/yarn.lock'
220+
- name: Run e2e tests
221+
run: yarn test:e2e
243222

244-
# - name: Install packages
245-
# run: yarn
223+
test-e2e-fee-token-6-decimals:
224+
name: Test e2e fee token with 6 decimals and pricer
225+
runs-on: ubuntu-latest
226+
steps:
227+
- uses: actions/checkout@v3
228+
with:
229+
submodules: recursive
246230

247-
# - name: Compile contracts
248-
# run: yarn build
231+
- uses: OffchainLabs/actions/run-nitro-test-node@main
232+
with:
233+
l3-node: true
234+
args: --l3-fee-token --l3-fee-token-pricer --l3-fee-token-decimals 6
235+
no-token-bridge: true
236+
no-l3-token-bridge: true
237+
nitro-testnode-ref: v3-support
238+
nitro-contracts-branch: '${{ github.event.pull_request.head.sha || github.sha }}'
239+
240+
- name: Setup node/yarn
241+
uses: actions/setup-node@v3
242+
with:
243+
node-version: 18
244+
cache: 'yarn'
245+
cache-dependency-path: '**/yarn.lock'
246+
247+
- name: Install packages
248+
run: yarn
249+
250+
- name: Compile contracts
251+
run: yarn build
249252

250-
# - name: Run e2e tests
251-
# run: yarn test:e2e
253+
- name: Run e2e tests
254+
run: yarn test:e2e
252255

253256
# bold-upgrade:
254257
# name: BOLD upgrade test

foundry.toml

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
src = 'src'
33
out = 'out'
44
libs = ['node_modules', 'lib']
5-
cache_path = 'forge-cache/sol'
5+
test = 'test/foundry'
6+
cache_path = 'forge-cache/sol'
67
optimizer = true
78
optimizer_runs = 2000
89
via_ir = false
@@ -11,14 +12,16 @@ remappings = ['ds-test/=lib/forge-std/lib/ds-test/src/',
1112
'forge-std/=lib/forge-std/src/',
1213
'@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/',
1314
'@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/',
14-
'@offchainlabs/upgrade-executor/=node_modules/@offchainlabs/upgrade-executor/']
15+
'@offchainlabs/upgrade-executor/=node_modules/@offchainlabs/upgrade-executor/',
16+
'@uniswap/v2-core/=node_modules/@uniswap/v2-core/contracts',
17+
'@uniswap/lib/=node_modules/@uniswap/lib/contracts']
1518
fs_permissions = [{ access = "read", path = "./"}]
1619

1720
[profile.yul]
1821
src = 'yul'
1922
out = 'out/yul'
2023
libs = ['node_modules', 'lib']
21-
cache_path = 'forge-cache/yul'
24+
cache_path = 'forge-cache/yul'
2225
remappings = []
2326
auto_detect_remappings = false
2427

@@ -38,4 +41,7 @@ ignore = []
3841
contract_new_lines = false
3942
sort_imports = false
4043

41-
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
44+
[fuzz]
45+
runs = 1000
46+
47+
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@arbitrum/nitro-contracts",
3-
"version": "3.0.1",
3+
"version": "3.1.0",
44
"description": "Layer 2 precompiles and rollup for Arbitrum Nitro",
55
"author": "Offchain Labs, Inc.",
66
"license": "BUSL-1.1",
@@ -39,6 +39,8 @@
3939
"test:compatibility": "yarn run build:0.6 && yarn run build:0.7",
4040
"test:storage": "./test/storage/test.bash",
4141
"test:signatures": "./test/signatures/test-sigs.bash",
42+
"test:e2e:orbit": "hardhat test test/e2e/orbitChain.ts",
43+
"test:e2e:orbit-fee-token-rollup": "hardhat test test/e2e/customFeeRollup.ts",
4244
"test:e2e": "hardhat test test/e2e/*.ts",
4345
"test:e2e:stylus": "hardhat test test/e2e/stylusDeployer.ts",
4446
"test:upgrade": "./scripts/testUpgrade.bash",
@@ -51,6 +53,7 @@
5153
"deploy-eth-rollup": "hardhat run scripts/createEthRollup.ts",
5254
"deploy-erc20-rollup": "hardhat run scripts/createERC20Rollup.ts",
5355
"create-rollup-testnode": "hardhat run scripts/local-deployment/deployCreatorAndCreateRollup.ts",
56+
"slither-triage": "slither . --skip-assembly --triage-mode",
5457
"script:bold-prepare": "hardhat run ./scripts/prepareBoldUpgrade.ts",
5558
"script:bold-populate-lookup": "hardhat run ./scripts/populateLookup.ts",
5659
"script:bold-local-execute": "hardhat run ./scripts/executeBoldUpgrade.ts",
@@ -78,6 +81,8 @@
7881
"@typescript-eslint/eslint-plugin": "^5.62.0",
7982
"@typescript-eslint/eslint-plugin-tslint": "^5.62.0",
8083
"@typescript-eslint/parser": "^5.62.0",
84+
"@uniswap/lib": "^4.0.1-alpha",
85+
"@uniswap/v2-core": "^1.0.1",
8186
"audit-ci": "^6.6.1",
8287
"chai": "^4.5.0",
8388
"dotenv": "^16.4.7",

scripts/createERC20Rollup.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,24 @@ async function main() {
3838
throw new Error('STAKE_TOKEN_ADDRESS not set')
3939
}
4040

41-
console.log('Creating new rollup with', customFeeTokenAddress, 'as fee token')
41+
let feeTokenPricer = process.env.FEE_TOKEN_PRICER_ADDRESS
42+
if (!feeTokenPricer) {
43+
feeTokenPricer = ethers.constants.AddressZero
44+
}
45+
46+
console.log(
47+
'Creating new rollup with',
48+
customFeeTokenAddress,
49+
'as fee token and',
50+
feeTokenPricer,
51+
'as fee token pricer'
52+
)
4253
await createRollup(
4354
deployer,
4455
false,
4556
rollupCreatorAddress,
4657
customFeeTokenAddress,
58+
feeTokenPricer,
4759
stakeTokenAddress
4860
)
4961
}

scripts/createEthRollup.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createRollup } from './rollupCreation'
44

55
async function main() {
66
const feeToken = ethers.constants.AddressZero
7+
const feeTokenPricer = ethers.constants.AddressZero
78
const rollupCreatorAddress = process.env.ROLLUP_CREATOR_ADDRESS
89
if (!rollupCreatorAddress) {
910
throw new Error('ROLLUP_CREATOR_ADDRESS not set')
@@ -21,6 +22,7 @@ async function main() {
2122
false,
2223
rollupCreatorAddress,
2324
feeToken,
25+
feeTokenPricer,
2426
stakeTokenAddress
2527
)
2628
}

scripts/local-deployment/deployCreatorAndCreateRollup.ts

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ async function main() {
4141
if (!feeToken) {
4242
feeToken = ethers.constants.AddressZero
4343
}
44+
let feeTokenPricer = process.env.FEE_TOKEN_PRICER_ADDRESS as string
45+
if (!feeTokenPricer) {
46+
feeTokenPricer = ethers.constants.AddressZero
47+
}
4448

4549
/// get stake token address, if undefined deploy WETH and set it as stake token
4650
let stakeToken = process.env.STAKE_TOKEN_ADDRESS as string
@@ -88,6 +92,7 @@ async function main() {
8892
true,
8993
contracts.rollupCreator.address,
9094
feeToken,
95+
feeTokenPricer,
9196
stakeToken
9297
)
9398

scripts/rollupCreation.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import '@nomiclabs/hardhat-ethers'
33
import { run } from 'hardhat'
44
import { abi as rollupCreatorAbi } from '../build/contracts/src/rollup/RollupCreator.sol/RollupCreator.json'
55
import { config, maxDataSize } from './config'
6-
import { BigNumber, Signer } from 'ethers'
6+
import { BigNumber, Event, Signer } from 'ethers'
77
import { ERC20, ERC20__factory, IERC20__factory } from '../build/types'
88
import { sleep } from './testSetup'
99
import { promises as fs } from 'fs'
@@ -66,6 +66,7 @@ export async function createRollup(
6666
isDevDeployment: boolean,
6767
rollupCreatorAddress: string,
6868
feeToken: string,
69+
feeTokenPricer: string,
6970
stakeToken: string
7071
): Promise<{
7172
rollupCreationResult: RollupCreationResult
@@ -81,7 +82,7 @@ export async function createRollup(
8182
rollupCreatorAddress,
8283
rollupCreatorAbi,
8384
signer
84-
)
85+
) as RollupCreator
8586
const validatorWalletCreator = await rollupCreator.validatorWalletCreator()
8687

8788
try {
@@ -106,7 +107,12 @@ export async function createRollup(
106107
// Call the createRollup function
107108
console.log('Calling createRollup to generate a new rollup ...')
108109
const deployParams = isDevDeployment
109-
? await _getDevRollupConfig(feeToken, validatorWalletCreator, stakeToken)
110+
? await _getDevRollupConfig(
111+
feeToken,
112+
feeTokenPricer,
113+
validatorWalletCreator,
114+
stakeToken
115+
)
110116
: {
111117
config: config.rollupConfig,
112118
validators: config.validators,
@@ -116,6 +122,7 @@ export async function createRollup(
116122
maxFeePerGasForRetryables: MAX_FER_PER_GAS,
117123
batchPosters: config.batchPosters,
118124
batchPosterManager: config.batchPosterManager,
125+
feeTokenPricer: feeTokenPricer,
119126
}
120127

121128
const createRollupTx = await rollupCreator.createRollup(deployParams, {
@@ -124,7 +131,7 @@ export async function createRollup(
124131
const createRollupReceipt = await createRollupTx.wait()
125132

126133
const rollupCreatedEvent = createRollupReceipt.events?.find(
127-
(event: RollupCreatedEvent) =>
134+
(event: Event): event is Event =>
128135
event.event === 'RollupCreated' &&
129136
event.address.toLowerCase() === rollupCreatorAddress.toLowerCase()
130137
)
@@ -225,6 +232,7 @@ export async function createRollup(
225232

226233
async function _getDevRollupConfig(
227234
feeToken: string,
235+
feeTokenPricer: string,
228236
validatorWalletCreator: string,
229237
stakeToken: string
230238
): Promise<RollupCreator.RollupDeploymentParamsStruct> {
@@ -347,6 +355,7 @@ async function _getDevRollupConfig(
347355
maxFeePerGasForRetryables: MAX_FER_PER_GAS,
348356
batchPosters: batchPosters,
349357
batchPosterManager: batchPosterManager,
358+
feeTokenPricer: feeTokenPricer,
350359
}
351360

352361
function _createValidatorAddress(

slither.db.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)