Skip to content

Commit 2b13047

Browse files
gzeonethgodzillaba
andauthored
refactor: move hardcoded value to config (#270)
* refactor: move hardcoded value to config * refactor: minimumAssertionPeriod and validatorAfkBlocks in bold upgrade setting * perf: remove onchain verification * chore: update sigs * refactor: remove hardcode in rollup initialize * chore: update example * test: new config param * fix: format test * test: fix config * Apply suggestions from code review Co-authored-by: Henry <[email protected]> --------- Co-authored-by: Henry <[email protected]>
1 parent 2c72296 commit 2b13047

16 files changed

+60
-29
lines changed

scripts/boldUpgradeCommon.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ export interface Config {
7676
stakeAmt: BigNumber
7777
miniStakeAmounts: BigNumber[]
7878
chainId: number
79+
minimumAssertionPeriod: number
80+
validatorAfkBlocks: number
7981
disableValidatorWhitelist: boolean
8082
maxDataSize: number
8183
blockLeafSize: number

scripts/config.ts.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const config = {
1717
owner: '0x1234123412341234123412341234123412341234',
1818
loserStakeEscrow: ethers.constants.AddressZero,
1919
chainId: ethers.BigNumber.from('13331370'),
20+
minimumAssertionPeriod: 75,
21+
validatorAfkBlocks: 201600,
2022
chainConfig:
2123
'{"chainId":13331370,"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":10,"InitialChainOwner":"0x1234123412341234123412341234123412341234","GenesisBlockNum":0}}',
2224
genesisBlockNum: ethers.BigNumber.from('0'),

scripts/files/configs/arb1.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const arb1: Config = {
2929
stakeAmt: parseEther('3600'),
3030
miniStakeAmounts: [parseEther('0'), parseEther('555'), parseEther('79')],
3131
chainId: 42161,
32+
minimumAssertionPeriod: 75,
33+
validatorAfkBlocks: 201600,
3234
disableValidatorWhitelist: true,
3335
blockLeafSize: 2 ** 26,
3436
bigStepLeafSize: 2 ** 19,

scripts/files/configs/local.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export const local: Config = {
3535
parseEther('1'),
3636
],
3737
chainId: 412346,
38+
minimumAssertionPeriod: 0,
39+
validatorAfkBlocks: 201600,
3840
disableValidatorWhitelist: true,
3941
blockLeafSize: 1048576,
4042
bigStepLeafSize: 512,

scripts/files/configs/nova.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export const nova: Config = {
3030
stakeAmt: parseEther('1'),
3131
miniStakeAmounts: [parseEther('0'), parseEther('1'), parseEther('1')],
3232
chainId: 42170,
33+
minimumAssertionPeriod: 75,
34+
validatorAfkBlocks: 201600,
3335
disableValidatorWhitelist: false,
3436
blockLeafSize: 2 ** 26, // leaf sizes same as arb1
3537
bigStepLeafSize: 2 ** 19,

scripts/files/configs/sepolia.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export const sepolia: Config = {
2828
stakeAmt: parseEther('36'), // 1/100th of arb1, same for mini stakes
2929
miniStakeAmounts: [parseEther('0'), parseEther('5.5'), parseEther('0.79')],
3030
chainId: 421614,
31+
minimumAssertionPeriod: 75,
32+
validatorAfkBlocks: 201600,
3133
disableValidatorWhitelist: false,
3234
blockLeafSize: 2 ** 26, // leaf sizes same as arb1
3335
bigStepLeafSize: 2 ** 19,

scripts/rollupCreation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ async function _getDevRollupConfig(
303303
loserStakeEscrow: ethers.constants.AddressZero,
304304
chainId: JSON.parse(chainConfig)['chainId'],
305305
chainConfig: chainConfig,
306+
minimumAssertionPeriod: 75,
307+
validatorAfkBlocks: 201600,
306308
genesisAssertionState: {}, // AssertionState
307309
genesisInboxCount: 0,
308310
miniStakeValues: [

src/rollup/BOLDUpgradeAction.sol

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ contract BOLDUpgradeAction {
185185
address public immutable STAKE_TOKEN;
186186
uint256 public immutable STAKE_AMOUNT;
187187
uint256 public immutable CHAIN_ID;
188+
uint256 public immutable MINIMUM_ASSERTION_PERIOD;
189+
uint64 public immutable VALIDATOR_AFK_BLOCKS;
190+
188191
bool public immutable DISABLE_VALIDATOR_WHITELIST;
189192
uint64 public immutable CHALLENGE_GRACE_PERIOD_BLOCKS;
190193
address public immutable MINI_STAKE_AMOUNTS_STORAGE;
@@ -223,6 +226,8 @@ contract BOLDUpgradeAction {
223226
uint256 stakeAmt;
224227
uint256[] miniStakeAmounts;
225228
uint256 chainId;
229+
uint256 minimumAssertionPeriod;
230+
uint64 validatorAfkBlocks;
226231
bool disableValidatorWhitelist;
227232
uint256 blockLeafSize;
228233
uint256 bigStepLeafSize;
@@ -296,6 +301,8 @@ contract BOLDUpgradeAction {
296301
IMPL_CHALLENGE_MANAGER = implementations.challengeManager;
297302

298303
CHAIN_ID = settings.chainId;
304+
MINIMUM_ASSERTION_PERIOD = settings.minimumAssertionPeriod;
305+
VALIDATOR_AFK_BLOCKS = settings.validatorAfkBlocks;
299306
CONFIRM_PERIOD_BLOCKS = settings.confirmPeriodBlocks;
300307
CHALLENGE_PERIOD_BLOCKS = settings.challengePeriodBlocks;
301308
STAKE_TOKEN = settings.stakeToken;
@@ -373,6 +380,8 @@ contract BOLDUpgradeAction {
373380
loserStakeEscrow: EXCESS_STAKE_RECEIVER, // additional funds get sent to the l1 timelock
374381
chainId: CHAIN_ID,
375382
chainConfig: "", // we can use an empty chain config it wont be used in the rollup initialization because we check if the rei is already connected there
383+
minimumAssertionPeriod: MINIMUM_ASSERTION_PERIOD,
384+
validatorAfkBlocks: VALIDATOR_AFK_BLOCKS,
376385
miniStakeValues: ConstantArrayStorage(MINI_STAKE_AMOUNTS_STORAGE).array(),
377386
sequencerInboxMaxTimeVariation: maxTimeVariation,
378387
layerZeroBlockEdgeHeight: BLOCK_LEAF_SIZE,
@@ -433,17 +442,6 @@ contract BOLDUpgradeAction {
433442
PROXY_ADMIN_SEQUENCER_INBOX.upgrade(sequencerInbox, IMPL_SEQUENCER_INBOX);
434443
}
435444

436-
// verify
437-
require(
438-
PROXY_ADMIN_SEQUENCER_INBOX.getProxyImplementation(sequencerInbox)
439-
== IMPL_SEQUENCER_INBOX,
440-
"DelayBuffer: new seq inbox implementation not set"
441-
);
442-
require(
443-
ISequencerInbox(SEQ_INBOX).isDelayBufferable() == IS_DELAY_BUFFERABLE,
444-
"DelayBuffer: isDelayBufferable not set"
445-
);
446-
447445
(uint256 delayBlocks, uint256 futureBlocks, uint256 delaySeconds, uint256 futureSeconds) =
448446
ISequencerInbox(SEQ_INBOX).maxTimeVariation();
449447

@@ -465,14 +463,6 @@ contract BOLDUpgradeAction {
465463
})
466464
);
467465

468-
// verify
469-
(uint256 _delayBlocks, uint256 _futureBlocks, uint256 _delaySeconds, uint256 _futureSeconds)
470-
= ISequencerInbox(SEQ_INBOX).maxTimeVariation();
471-
require(_delayBlocks == delayBlocks, "DelayBuffer: delayBlocks");
472-
require(_delaySeconds == delaySeconds, "DelayBuffer: delaySeconds");
473-
require(_futureBlocks == futureBlocks, "DelayBuffer: futureBlocks");
474-
require(_futureSeconds == futureSeconds, "DelayBuffer: futureSeconds");
475-
476466
ISequencerInbox(SEQ_INBOX).updateRollupAddress();
477467
}
478468

src/rollup/Config.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ struct Config {
2323
address loserStakeEscrow;
2424
uint256 chainId;
2525
string chainConfig;
26+
uint256 minimumAssertionPeriod;
27+
uint64 validatorAfkBlocks;
2628
uint256[] miniStakeValues;
2729
ISequencerInbox.MaxTimeVariation sequencerInboxMaxTimeVariation;
2830
uint256 layerZeroBlockEdgeHeight;

src/rollup/RollupAdminLogic.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ contract RollupAdminLogic is RollupCore, IRollupAdmin, DoubleLogicUUPSUpgradeabl
5353
chainId = config.chainId;
5454
baseStake = config.baseStake;
5555
wasmModuleRoot = config.wasmModuleRoot;
56-
// A little over 15 minutes
57-
minimumAssertionPeriod = 75;
58-
// ValidatorAfkBlocks is defaulted to 28 days assuming a 12 seconds block time.
56+
// minimumAssertionPeriod was defaulted to 75 which is a little over 15 minutes
57+
minimumAssertionPeriod = config.minimumAssertionPeriod;
58+
// ValidatorAfkBlocks was defaulted to 201600 which is 28 days assuming a 12 seconds block time.
5959
// Since it can take 14 days under normal circumstances to confirm an assertion, this means
6060
// the validators will have been inactive for a further 14 days before the whitelist is removed.
61-
validatorAfkBlocks = 201600;
61+
validatorAfkBlocks = config.validatorAfkBlocks;
6262
challengeGracePeriodBlocks = config.challengeGracePeriodBlocks;
6363

6464
// loser stake is now sent directly to loserStakeEscrow, it must not

0 commit comments

Comments
 (0)