Skip to content

Commit 701deb3

Browse files
authored
fix: deploy scripts (#329)
* chore: also verify with sourcify * chore: update example * fix: better typing * ci: bump action versions * test: workaround delay proof * format: yarn format * ci: fix slither db using new version
1 parent 50cbad0 commit 701deb3

File tree

7 files changed

+133
-80
lines changed

7 files changed

+133
-80
lines changed

.github/workflows/contract-tests.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
name: Test unit
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
with:
1919
submodules: recursive
2020

@@ -44,7 +44,7 @@ jobs:
4444
shell: bash
4545
steps:
4646
- name: Checkout
47-
uses: actions/checkout@v2
47+
uses: actions/checkout@v4
4848
with:
4949
submodules: recursive
5050

@@ -55,7 +55,7 @@ jobs:
5555
cache: false
5656

5757
- name: Setup nodejs
58-
uses: actions/setup-node@v2
58+
uses: actions/setup-node@v3
5959
with:
6060
node-version: '18'
6161
cache: 'yarn'
@@ -124,7 +124,7 @@ jobs:
124124
name: 4844 tests
125125
runs-on: ubuntu-latest
126126
steps:
127-
- uses: actions/checkout@v3
127+
- uses: actions/checkout@v4
128128
with:
129129
submodules: recursive
130130

@@ -140,7 +140,7 @@ jobs:
140140
no-token-bridge: true
141141

142142
- name: Setup nodejs
143-
uses: actions/setup-node@v2
143+
uses: actions/setup-node@v3
144144
with:
145145
node-version: 18
146146
cache: 'yarn'
@@ -159,7 +159,7 @@ jobs:
159159
name: Test e2e
160160
runs-on: ubuntu-latest
161161
steps:
162-
- uses: actions/checkout@v3
162+
- uses: actions/checkout@v4
163163
with:
164164
submodules: recursive
165165

@@ -191,7 +191,7 @@ jobs:
191191
name: Test e2e custom fee token
192192
runs-on: ubuntu-latest
193193
steps:
194-
- uses: actions/checkout@v3
194+
- uses: actions/checkout@v4
195195
with:
196196
submodules: recursive
197197

@@ -224,7 +224,7 @@ jobs:
224224
name: Test e2e fee token with 6 decimals and pricer
225225
runs-on: ubuntu-latest
226226
steps:
227-
- uses: actions/checkout@v3
227+
- uses: actions/checkout@v4
228228
with:
229229
submodules: recursive
230230

@@ -257,7 +257,7 @@ jobs:
257257
# name: BOLD upgrade test
258258
# runs-on: ubuntu-latest
259259
# steps:
260-
# - uses: actions/checkout@v3
260+
# - uses: actions/checkout@v4
261261
# with:
262262
# submodules: recursive
263263

hardhat.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,7 @@ module.exports = {
262262
contractSizer: {
263263
strict: true,
264264
},
265+
sourcify: {
266+
enabled: true,
267+
},
265268
}

scripts/config.example.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { ethers } from 'ethers'
2+
import {
3+
AssertionStateStruct,
4+
RollupCreator,
5+
} from '../build/types/src/rollup/RollupCreator'
6+
7+
type PartialRollupParams = Pick<
8+
RollupCreator.RollupDeploymentParamsStruct,
9+
'config' | 'validators' | 'batchPosterManager' | 'batchPosters'
10+
>
11+
12+
// 90% of Geth's 128KB tx size limit, leaving ~13KB for proving
13+
// This need to be adjusted for Orbit chains
14+
export const maxDataSize = 117964
15+
export const isUsingFeeToken = false
16+
const chainId = ethers.BigNumber.from('13331370')
17+
18+
const genesisAssertionState: AssertionStateStruct = {
19+
globalState: {
20+
bytes32Vals: [ethers.constants.HashZero, ethers.constants.HashZero],
21+
u64Vals: [ethers.BigNumber.from('0'), ethers.BigNumber.from('0')],
22+
},
23+
machineStatus: 1, // FINISHED
24+
endHistoryRoot: ethers.constants.HashZero,
25+
}
26+
27+
export const config: PartialRollupParams = {
28+
config: {
29+
confirmPeriodBlocks: ethers.BigNumber.from('45818'),
30+
stakeToken: process.env.STAKE_TOKEN_ADDRESS!,
31+
baseStake: ethers.utils.parseEther('1'),
32+
wasmModuleRoot:
33+
'0x184884e1eb9fefdc158f6c8ac912bb183bf3cf83f0090317e0bc4ac5860baa39', // Arbitrum Nitro Consensus v32
34+
owner: '0x1234123412341234123412341234123412341234',
35+
loserStakeEscrow: '0x1234123412341234123412341234123412341234', // Cannot be address(0)
36+
chainId: chainId,
37+
chainConfig: `{"chainId":${chainId.toString()},"homesteadBlock":0,"daoForkBlock":null,"daoForkSupport":true,"eip150Block":0,"eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000","eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"berlinBlock":0,"londonBlock":0,"clique":{"period":0,"epoch":0},"arbitrum":{"EnableArbOS":true,"AllowDebugPrecompiles":false,"DataAvailabilityCommittee":false,"InitialArbOSVersion":32,"InitialChainOwner":"0x1234123412341234123412341234123412341234","GenesisBlockNum":0}}`,
38+
minimumAssertionPeriod: 75,
39+
validatorAfkBlocks: 201600,
40+
genesisAssertionState: genesisAssertionState,
41+
genesisInboxCount: 0,
42+
miniStakeValues: [
43+
0,
44+
ethers.utils.parseEther('0.5'),
45+
ethers.utils.parseEther('0.25'),
46+
],
47+
layerZeroBlockEdgeHeight: 2 ** 26,
48+
layerZeroBigStepEdgeHeight: 2 ** 19,
49+
layerZeroSmallStepEdgeHeight: 2 ** 23,
50+
numBigStepLevel: 1,
51+
challengeGracePeriodBlocks: 10,
52+
bufferConfig: {
53+
threshold: ethers.BigNumber.from('600'), // Set this to 0 to disable delay buffer
54+
max: ethers.BigNumber.from('14400'),
55+
replenishRateInBasis: ethers.BigNumber.from('833'),
56+
},
57+
sequencerInboxMaxTimeVariation: {
58+
delayBlocks: ethers.BigNumber.from('7200'),
59+
futureBlocks: ethers.BigNumber.from('12'),
60+
delaySeconds: ethers.BigNumber.from('86400'),
61+
futureSeconds: ethers.BigNumber.from('3600'),
62+
},
63+
anyTrustFastConfirmer: ethers.constants.AddressZero,
64+
},
65+
validators: [
66+
'0x1234123412341234123412341234123412341234',
67+
'0x1234512345123451234512345123451234512345',
68+
],
69+
batchPosterManager: '0x1234123412341234123412341234123412341234',
70+
batchPosters: ['0x1234123412341234123412341234123412341234'],
71+
}
72+
73+
// These value should be defined in the env
74+
// TODO: Consolidate configs to a single file, these env vars are used in nitro-testnode
75+
console.log('ROLLUP_CREATOR_ADDRESS :', process.env.ROLLUP_CREATOR_ADDRESS)
76+
console.log('STAKE_TOKEN_ADDRESS :', process.env.STAKE_TOKEN_ADDRESS)
77+
if (config.config.stakeToken !== process.env.STAKE_TOKEN_ADDRESS) {
78+
throw new Error('STAKE_TOKEN_ADDRESS mismatch')
79+
}
80+
console.log('FEE_TOKEN_ADDRESS :', process.env.FEE_TOKEN_ADDRESS)
81+
console.log('FEE_TOKEN_PRICER_ADDRESS:', process.env.FEE_TOKEN_PRICER_ADDRESS)
82+
83+
console.log(config.config.chainConfig)

scripts/config.ts.example

Lines changed: 0 additions & 45 deletions
This file was deleted.

scripts/rollupCreation.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,25 @@ export async function createRollup(
106106

107107
// Call the createRollup function
108108
console.log('Calling createRollup to generate a new rollup ...')
109-
const deployParams = isDevDeployment
110-
? await _getDevRollupConfig(
111-
feeToken,
112-
feeTokenPricer,
113-
validatorWalletCreator,
114-
stakeToken
115-
)
116-
: {
117-
config: config.rollupConfig,
118-
validators: config.validators,
119-
maxDataSize: ethers.BigNumber.from(maxDataSize),
120-
nativeToken: feeToken,
121-
deployFactoriesToL2: true,
122-
maxFeePerGasForRetryables: MAX_FER_PER_GAS,
123-
batchPosters: config.batchPosters,
124-
batchPosterManager: config.batchPosterManager,
125-
feeTokenPricer: feeTokenPricer,
126-
}
109+
const deployParams: RollupCreator.RollupDeploymentParamsStruct =
110+
isDevDeployment
111+
? await _getDevRollupConfig(
112+
feeToken,
113+
feeTokenPricer,
114+
validatorWalletCreator,
115+
stakeToken
116+
)
117+
: {
118+
config: config.config,
119+
validators: config.validators,
120+
maxDataSize: ethers.BigNumber.from(maxDataSize),
121+
nativeToken: feeToken,
122+
deployFactoriesToL2: true,
123+
maxFeePerGasForRetryables: MAX_FER_PER_GAS,
124+
batchPosters: config.batchPosters,
125+
batchPosterManager: config.batchPosterManager,
126+
feeTokenPricer: feeTokenPricer,
127+
}
127128

128129
const createRollupTx = await rollupCreator.createRollup(deployParams, {
129130
value: feeCost,
@@ -212,7 +213,7 @@ export async function createRollup(
212213
'secondary-feed-url': '',
213214
'das-index-url': '',
214215
'has-genesis-state': false,
215-
'chain-config': JSON.parse(deployParams.config.chainConfig),
216+
'chain-config': JSON.parse(await deployParams.config.chainConfig),
216217
rollup: rollupCreationResult,
217218
}
218219

slither.db.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test/e2e/customFeeRollup.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,23 @@ describe('Custom fee token orbit rollup', () => {
208208
const txData = (
209209
await l2Provider.getTransaction(batchSpendingReportEvent.transactionHash)
210210
).data
211-
const batchtxData = seqInbox.interface.decodeFunctionData(
212-
seqInbox.interface.functions[
213-
'addSequencerL2BatchFromOriginDelayProof(uint256,bytes,uint256,address,uint256,uint256,(bytes32,(uint8,address,uint64,uint64,uint256,uint256,bytes32)))'
214-
],
215-
txData
216-
)
211+
let batchtxData
212+
// TODO: disable delay buffer here or use 4 bytes to determine if delay proof is used
213+
try {
214+
batchtxData = seqInbox.interface.decodeFunctionData(
215+
seqInbox.interface.functions[
216+
'addSequencerL2BatchFromOriginDelayProof(uint256,bytes,uint256,address,uint256,uint256,(bytes32,(uint8,address,uint64,uint64,uint256,uint256,bytes32)))'
217+
],
218+
txData
219+
)
220+
} catch (e) {
221+
batchtxData = seqInbox.interface.decodeFunctionData(
222+
seqInbox.interface.functions[
223+
'addSequencerL2BatchFromOrigin(uint256,bytes,uint256,address,uint256,uint256)'
224+
],
225+
txData
226+
)
227+
}
217228
const computeBatchCost = (batchData: string) => {
218229
const zeroBytes = batchData
219230
.substring(2)

0 commit comments

Comments
 (0)