Skip to content

Commit

Permalink
feat: bold configs (#223)
Browse files Browse the repository at this point in the history
* configs

* note

* note

* feat: safer hoursToBlocks util

* delay buffer

* chore: update configs

* fix: circular import

* chore: param update

* chore: remove debug

* fix: restore validators

* fix: typo

* fix: remove unused error

* chore: fix slither

* comment

---------

Co-authored-by: gzeon <[email protected]>
Co-authored-by: gzeon <[email protected]>
  • Loading branch information
3 people committed Aug 15, 2024
1 parent ad23b04 commit 5deee6d
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 61 deletions.
2 changes: 1 addition & 1 deletion scripts/boldUpgradeCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const validateConfig = async (
throw new Error('miniStakeAmts length is not numBigStepLevel + 2')
}

if (config.validators.length === 0) {
if (!config.settings.disableValidatorWhitelist && config.validators.length === 0) {
throw new Error('no validators')
}
}
41 changes: 16 additions & 25 deletions scripts/files/configs/arb1.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { parseEther } from 'ethers/lib/utils'
import { Config } from '../../boldUpgradeCommon'
import { hoursToBlocks } from './utils'

export const arb1: Config = {
contracts: {
// it both the excess stake receiver and loser stake escrow
// TODO: change this to a fee router before real deployment
excessStakeReceiver: '0xE6841D92B0C345144506576eC13ECf5103aC7f49',
excessStakeReceiver: '0x40Cd7D713D7ae463f95cE5d342Ea6E7F5cF7C999', // parent to child router
rollup: '0x5eF0D09d1E6204141B4d37530808eD19f60FBa35',
bridge: '0x8315177aB297bA92A06054cE80a67Ed4DBd7ed3a',
sequencerInbox: '0x1c479675ad559DC151F6Ec7ed3FbF8ceE79582B6',
Expand All @@ -22,39 +22,30 @@ export const arb1: Config = {
seqInbox: '0x554723262467f125ac9e1cdfa9ce15cc53822dbd',
},
settings: {
challengeGracePeriodBlocks: 14400, // 2 days
challengeGracePeriodBlocks: hoursToBlocks(48),
confirmPeriodBlocks: 45818, // same as old rollup, ~6.4 days
challengePeriodBlocks: 45818, // same as confirm period
stakeToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
stakeAmt: parseEther('3600'),
miniStakeAmounts: [parseEther('0'), parseEther('555'), parseEther('79')],
miniStakeAmounts: [
parseEther('0'),
parseEther('555'),
parseEther('79'),
],
chainId: 42161,
disableValidatorWhitelist: true,
blockLeafSize: 1048576, // todo below
bigStepLeafSize: 512,
smallStepLeafSize: 128,
blockLeafSize: 2**26,
bigStepLeafSize: 2**19,
smallStepLeafSize: 2**23,
numBigStepLevel: 1,
maxDataSize: 117964,
isDelayBufferable: true,
bufferConfig: {
max: 14400,
threshold: 300,
replenishRateInBasis: 500,
max: hoursToBlocks(48), // 2 days
threshold: hoursToBlocks(0.5), // well above typical posting frequency
replenishRateInBasis: 500, // 5% replenishment rate
},
},
validators: [
'0x0ff813f6bd577c3d1cdbe435bac0621be6ae34b4',
'0x54c0d3d6c101580db3be8763a2ae2c6bb9dc840c',
'0x56d83349c2b8dcf74d7e92d5b6b33d0badd52d78',
'0x610aa279989f440820e14248bd3879b148717974',
'0x6fb914de4653ec5592b7c15f4d9466cbd03f2104',
'0x758c6bb08b3ea5889b5cddbdef9a45b3a983c398',
'0x7cf3d537733f6ba4183a833c9b021265716ce9d0',
'0x83215480db2c6a7e56f9e99ef93ab9b36f8a3dd5',
'0xab1a39332e934300ebcc57b5f95ca90631a347ff',
'0xb0cb1384e3f4a9a9b2447e39b05e10631e1d34b0',
'0xddf2f71ab206c0138a8eceeb54386567d5abf01e',
'0xf59caf75e8a4bfba4e6e07ad86c7e498e4d2519b',
'0xf8d3e1cf58386c92b27710c6a0d8a54c76bc6ab5',
],
// validator whitelist will be disabled
validators: [],
}
1 change: 1 addition & 0 deletions scripts/files/configs/local.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { parseEther } from 'ethers/lib/utils'
import { Config } from '../../boldUpgradeCommon'
import { hoursToBlocks } from './utils'

export const local: Config = {
contracts: {
Expand Down
39 changes: 20 additions & 19 deletions scripts/files/configs/nova.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { parseEther } from 'ethers/lib/utils'
import { Config } from '../../boldUpgradeCommon'
import { hoursToBlocks } from './utils'

export const nova: Config = {
contracts: {
excessStakeReceiver: '0xE6841D92B0C345144506576eC13ECf5103aC7f49',
// it both the excess stake receiver and loser stake escrow
excessStakeReceiver: '0x40Cd7D713D7ae463f95cE5d342Ea6E7F5cF7C999', // parent to child router
rollup: '0xFb209827c58283535b744575e11953DCC4bEAD88',
bridge: '0xC1Ebd02f738644983b6C4B2d440b8e77DdE276Bd',
sequencerInbox: '0x211E1c4c7f1bF5351Ac850Ed10FD68CFfCF6c21b',
Expand All @@ -20,34 +22,33 @@ export const nova: Config = {
seqInbox: '0x71d78dc7ccc0e037e12de1e50f5470903ce37148',
},
settings: {
challengeGracePeriodBlocks: 14400,
confirmPeriodBlocks: 50400,
challengePeriodBlocks: 51600,
stakeToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
challengeGracePeriodBlocks: hoursToBlocks(48),
confirmPeriodBlocks: 45818, // same as old rollup, ~6.4 days
challengePeriodBlocks: 45818, // same as confirm period
stakeToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
// TODO: confirm stakes
stakeAmt: parseEther('1'),
miniStakeAmounts: [
parseEther('6'),
parseEther('5'),
parseEther('4'),
parseEther('3'),
parseEther('2'),
parseEther('0'),
parseEther('1'),
parseEther('1'),
],
chainId: 42161,
chainId: 42170,
disableValidatorWhitelist: false,
blockLeafSize: 1048576,
bigStepLeafSize: 512,
smallStepLeafSize: 128,
numBigStepLevel: 4,
blockLeafSize: 2**26, // leaf sizes same as arb1
bigStepLeafSize: 2**19,
smallStepLeafSize: 2**23,
numBigStepLevel: 1,
maxDataSize: 117964,
isDelayBufferable: true,
bufferConfig: {
max: 14400,
threshold: 300,
replenishRateInBasis: 500,
max: hoursToBlocks(48), // 2 days
threshold: hoursToBlocks(1), // well above typical posting frequency
replenishRateInBasis: 500, // 5% replenishment rate
},
},
validators: [
// these validators must still be validators on the old rollup during the upgrade, or the upgrade will fail
validators: [ // current validators
'0xE27d4Ed355e5273A3D4855c8e11BC4a8d3e39b87',
'0x57004b440Cc4eb2FEd8c4d1865FaC907F9150C76',
'0x24ca61c31c7f9af3ab104db6b9a444f28e9071e3',
Expand Down
18 changes: 10 additions & 8 deletions scripts/files/configs/sepolia.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { parseEther } from 'ethers/lib/utils'
import { Config } from '../../boldUpgradeCommon'
import { hoursToBlocks } from './utils'

export const sepolia: Config = {
contracts: {
excessStakeReceiver: '0x391611E7bba966000AC6c78aFc673C4AE46f8BCa',
excessStakeReceiver: '0x391611E7bba966000AC6c78aFc673C4AE46f8BCa', // chain owner multisig
rollup: '0xd80810638dbDF9081b72C1B33c65375e807281C8',
bridge: '0x38f918D0E9F1b721EDaA41302E399fa1B79333a9',
sequencerInbox: '0x6c97864CE4bEf387dE0b3310A44230f7E3F1be0D',
Expand All @@ -20,7 +21,7 @@ export const sepolia: Config = {
seqInbox: '0xdd63bcaa89d7c3199ef220c1dd59c49f821078b8',
},
settings: {
challengeGracePeriodBlocks: 20,
challengeGracePeriodBlocks: hoursToBlocks(48), // same as arb1
confirmPeriodBlocks: 20, // current is 20 blocks, 45818 is arb1 config
challengePeriodBlocks: 45818, // same as arb1
stakeToken: '0xefb383126640fe4a760010c6e59c397d2b6c7141', // WETH
Expand All @@ -37,14 +38,15 @@ export const sepolia: Config = {
smallStepLeafSize: 2**23,
numBigStepLevel: 1,
maxDataSize: 117964,
isDelayBufferable: false, // batch poster not yet ready
isDelayBufferable: true,
bufferConfig: {
max: 14400, // 48 hours
threshold: 300, // 1 hours
replenishRateInBasis: 500,
max: hoursToBlocks(24*365), // 365 days, effectively disableing and will be enabled later
threshold: hoursToBlocks(24*365), // 365 days, effectively disableing and will be enabled later
replenishRateInBasis: 500, // 5% replenishment rate
},
},
validators: [ // current validators
},
// these validators must still be validators on the old rollup during the upgrade, or the upgrade will fail
validators: [ // current validators
'0x8a8f0a24d7e58a76FC8F77bb68C7c902b91e182e',
'0x87630025E63A30eCf9Ca9d580d9D95922Fea6aF0',
'0xC32B93e581db6EBc50C08ce381143A259B92f1ED',
Expand Down
10 changes: 10 additions & 0 deletions scripts/files/configs/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function hoursToBlocks(hours: number, blockTime = 12) {
const x = hours * 3600 / blockTime
if (x !== Math.floor(x)) {
throw new Error('hours must be divisible by blockTime')
}
if (x === 0) {
throw new Error('hours must be greater than 0')
}
return x
}
2 changes: 1 addition & 1 deletion slither.db.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
DelayedBackwards,
DelayedTooFar,
ForceIncludeBlockTooSoon,
ForceIncludeTimeTooSoon,
IncorrectMessagePreimage,
NotBatchPoster,
BadSequencerNumber,
Expand Down
6 changes: 0 additions & 6 deletions src/libraries/Error.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ error CallNotAllowed();

// Inbox Errors

/// @dev The contract is paused
error Paused();

/// @dev msg.value sent to the inbox isn't high enough
error InsufficientValue(uint256 expected, uint256 actual);

Expand Down Expand Up @@ -152,9 +149,6 @@ error DelayedTooFar();
/// @dev Force include can only read messages more blocks old than the delay period
error ForceIncludeBlockTooSoon();

/// @dev Force include can only read messages more seconds old than the delay period
error ForceIncludeTimeTooSoon();

/// @dev The message provided did not match the hash in the delayed inbox
error IncorrectMessagePreimage();

Expand Down

0 comments on commit 5deee6d

Please sign in to comment.