@aztec/ethereum 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client.d.ts +16 -2
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +27 -7
- package/dest/config.d.ts +24 -32
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +63 -62
- package/dest/contracts/chain_state_override.d.ts +78 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +137 -0
- package/dest/contracts/fee_asset_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +11 -9
- package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +656 -0
- package/dest/contracts/governance.d.ts +110 -33
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +207 -16
- package/dest/contracts/governance_proposer.d.ts +33 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +438 -10
- package/dest/contracts/inbox.d.ts +22 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +42 -2
- package/dest/contracts/index.d.ts +6 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +5 -2
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/multicall.d.ts +127 -12
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +201 -93
- package/dest/contracts/outbox.d.ts +58 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +109 -0
- package/dest/contracts/registry.d.ts +3 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +30 -1
- package/dest/contracts/rollup.d.ts +5409 -115
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +1027 -189
- package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +18 -13
- package/dest/deploy_aztec_l1_contracts.d.ts +20 -9
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +113 -37
- package/dest/deploy_l1_contract.js +3 -3
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +18360 -16454
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +9 -24
- package/dest/l1_contract_addresses.d.ts +61 -65
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +101 -82
- package/dest/l1_reader.d.ts +5 -5
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +9 -7
- package/dest/l1_tx_utils/config.d.ts +7 -1
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +14 -1
- package/dest/l1_tx_utils/constants.d.ts +1 -1
- package/dest/l1_tx_utils/constants.js +2 -2
- package/dest/l1_tx_utils/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +3 -2
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/index.js +2 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +2 -12
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +36 -18
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +2 -11
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +37 -19
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +14 -27
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/types.js +0 -21
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/index-blobs.js +2 -2
- package/dest/l1_tx_utils/index.d.ts +2 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +2 -2
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.js +3 -3
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +26 -7
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +101 -66
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -5
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +25 -58
- package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +67 -37
- package/dest/publisher_manager.d.ts +21 -6
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +81 -7
- package/dest/queries.d.ts +14 -3
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +74 -7
- package/dest/test/chain_monitor.d.ts +23 -3
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +39 -4
- package/dest/test/eth_cheat_codes.d.ts +24 -4
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +17 -4
- package/dest/test/index.d.ts +1 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -2
- package/dest/test/rollup_cheat_codes.d.ts +34 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +75 -6
- package/dest/test/start_anvil.d.ts +23 -3
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +143 -29
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/utils.d.ts +9 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +81 -12
- package/package.json +9 -10
- package/src/client.ts +28 -2
- package/src/config.ts +81 -63
- package/src/contracts/README.md +157 -0
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/fee_asset_handler.ts +10 -7
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/governance.ts +279 -13
- package/src/contracts/governance_proposer.ts +58 -2
- package/src/contracts/inbox.ts +62 -2
- package/src/contracts/index.ts +5 -2
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +243 -102
- package/src/contracts/outbox.ts +128 -0
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +728 -148
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +16 -14
- package/src/deploy_aztec_l1_contracts.ts +137 -47
- package/src/deploy_l1_contract.ts +3 -3
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +120 -94
- package/src/l1_reader.ts +17 -10
- package/src/l1_tx_utils/config.ts +20 -0
- package/src/l1_tx_utils/constants.ts +2 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/index.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +46 -42
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +49 -45
- package/src/l1_tx_utils/fee-strategies/types.ts +14 -46
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
- package/src/l1_tx_utils/index-blobs.ts +2 -2
- package/src/l1_tx_utils/index.ts +1 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +2 -3
- package/src/l1_tx_utils/l1_tx_utils.ts +99 -48
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +31 -66
- package/src/{test → l1_tx_utils}/tx_delayer.ts +93 -56
- package/src/publisher_manager.ts +107 -10
- package/src/queries.ts +81 -7
- package/src/test/chain_monitor.ts +66 -4
- package/src/test/eth_cheat_codes.ts +16 -4
- package/src/test/index.ts +0 -2
- package/src/test/rollup_cheat_codes.ts +82 -6
- package/src/test/start_anvil.ts +177 -29
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +88 -14
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -209
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/contracts/empire_slashing_proposer.ts +0 -270
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
package/src/config.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
|
-
// type NetworkNames,
|
|
4
3
|
bigintConfigHelper,
|
|
5
4
|
booleanConfigHelper,
|
|
6
|
-
enumConfigHelper,
|
|
7
5
|
getConfigFromMappings,
|
|
6
|
+
getDefaultConfig,
|
|
8
7
|
numberConfigHelper,
|
|
8
|
+
omitConfigMappings,
|
|
9
9
|
optionalNumberConfigHelper,
|
|
10
10
|
} from '@aztec/foundation/config';
|
|
11
11
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
12
|
|
|
13
|
+
import { l1ContractsDefaultEnv } from './generated/l1-contracts-defaults.js';
|
|
13
14
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils/config.js';
|
|
14
15
|
|
|
15
16
|
export type GenesisStateConfig = {
|
|
@@ -17,6 +18,8 @@ export type GenesisStateConfig = {
|
|
|
17
18
|
testAccounts: boolean;
|
|
18
19
|
/** Whether to populate the genesis state with initial fee juice for the sponsored FPC */
|
|
19
20
|
sponsoredFPC: boolean;
|
|
21
|
+
/** Additional addresses to prefund with fee juice at genesis */
|
|
22
|
+
prefundAddresses: string[];
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export type L1ContractsConfig = {
|
|
@@ -32,6 +35,8 @@ export type L1ContractsConfig = {
|
|
|
32
35
|
lagInEpochsForValidatorSet: number;
|
|
33
36
|
/** The number of epochs to lag behind the current epoch for randao selection. */
|
|
34
37
|
lagInEpochsForRandao: number;
|
|
38
|
+
/** The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks). */
|
|
39
|
+
inboxLag: number;
|
|
35
40
|
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
36
41
|
aztecProofSubmissionEpochs: number;
|
|
37
42
|
/** The deposit amount for a validator */
|
|
@@ -54,130 +59,117 @@ export type L1ContractsConfig = {
|
|
|
54
59
|
slashingOffsetInRounds: number;
|
|
55
60
|
/** How long slashing can be disabled for in seconds when vetoer disables it */
|
|
56
61
|
slashingDisableDuration: number;
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
/** Minimum amount that can be slashed
|
|
62
|
+
/** Whether to deploy a slasher proposer */
|
|
63
|
+
slasherEnabled: boolean;
|
|
64
|
+
/** Minimum amount that can be slashed */
|
|
60
65
|
slashAmountSmall: bigint;
|
|
61
|
-
/** Medium amount to slash
|
|
66
|
+
/** Medium amount to slash */
|
|
62
67
|
slashAmountMedium: bigint;
|
|
63
|
-
/** Largest amount that can be slashed per round
|
|
68
|
+
/** Largest amount that can be slashed per round */
|
|
64
69
|
slashAmountLarge: bigint;
|
|
65
70
|
/** Governance proposing quorum (defaults to roundSize/2 + 1) */
|
|
66
71
|
governanceProposerQuorum?: number;
|
|
67
72
|
/** Governance proposing round size */
|
|
68
73
|
governanceProposerRoundSize: number;
|
|
74
|
+
/** Governance voting duration in seconds (only for local/devnet/next-net, default 3600) */
|
|
75
|
+
governanceVotingDuration?: number;
|
|
69
76
|
/** The mana target for the rollup */
|
|
70
77
|
manaTarget: bigint;
|
|
71
78
|
/** The proving cost per mana */
|
|
72
79
|
provingCostPerMana: bigint;
|
|
80
|
+
/** The initial ETH per fee asset price (with 1e12 precision) */
|
|
81
|
+
initialEthPerFeeAsset: bigint;
|
|
73
82
|
/** The number of seconds to wait for an exit */
|
|
74
83
|
exitDelaySeconds: number;
|
|
75
84
|
} & L1TxUtilsConfig;
|
|
76
85
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
lagInEpochsForValidatorSet: 2,
|
|
83
|
-
lagInEpochsForRandao: 2, // For PROD, this value should be > lagInEpochsForValidatorSet
|
|
84
|
-
aztecProofSubmissionEpochs: 1, // you have a full epoch to submit a proof after the epoch to prove ends
|
|
85
|
-
activationThreshold: 100n * 10n ** 18n,
|
|
86
|
-
ejectionThreshold: 50n * 10n ** 18n,
|
|
87
|
-
localEjectionThreshold: 98n * 10n ** 18n,
|
|
88
|
-
slashAmountSmall: 10n * 10n ** 18n,
|
|
89
|
-
slashAmountMedium: 20n * 10n ** 18n,
|
|
90
|
-
slashAmountLarge: 50n * 10n ** 18n,
|
|
91
|
-
slashingRoundSizeInEpochs: 4,
|
|
92
|
-
slashingLifetimeInRounds: 5,
|
|
93
|
-
slashingExecutionDelayInRounds: 0, // round N may be submitted in round N + 1
|
|
94
|
-
slashingVetoer: EthAddress.ZERO,
|
|
95
|
-
governanceProposerRoundSize: 300,
|
|
96
|
-
manaTarget: BigInt(100e6),
|
|
97
|
-
provingCostPerMana: BigInt(100),
|
|
98
|
-
exitDelaySeconds: 2 * 24 * 60 * 60,
|
|
99
|
-
slasherFlavor: 'tally' as const,
|
|
100
|
-
slashingOffsetInRounds: 2,
|
|
101
|
-
slashingDisableDuration: 5 * 24 * 60 * 60, // 5 days in seconds
|
|
102
|
-
} satisfies L1ContractsConfig;
|
|
103
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Config mappings for L1ContractsConfig.
|
|
88
|
+
* Default values come from generated l1-contracts-defaults.json (source: defaults.yml).
|
|
89
|
+
* Real deployments use forge scripts which require explicit env vars (vm.envUint).
|
|
90
|
+
*/
|
|
104
91
|
export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> = {
|
|
105
92
|
ethereumSlotDuration: {
|
|
106
93
|
env: 'ETHEREUM_SLOT_DURATION',
|
|
107
94
|
description: 'How many seconds an L1 slot lasts.',
|
|
108
|
-
...numberConfigHelper(
|
|
95
|
+
...numberConfigHelper(l1ContractsDefaultEnv.ETHEREUM_SLOT_DURATION),
|
|
109
96
|
},
|
|
110
97
|
aztecSlotDuration: {
|
|
111
98
|
env: 'AZTEC_SLOT_DURATION',
|
|
112
99
|
description: 'How many seconds an L2 slots lasts (must be multiple of ethereum slot duration).',
|
|
113
|
-
...numberConfigHelper(
|
|
100
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLOT_DURATION),
|
|
114
101
|
},
|
|
115
102
|
aztecEpochDuration: {
|
|
116
103
|
env: 'AZTEC_EPOCH_DURATION',
|
|
117
|
-
description: `How many L2 slots an epoch lasts (maximum
|
|
118
|
-
...numberConfigHelper(
|
|
104
|
+
description: `How many L2 slots an epoch lasts (maximum MAX_CHECKPOINTS_PER_EPOCH).`,
|
|
105
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EPOCH_DURATION),
|
|
119
106
|
},
|
|
120
107
|
aztecTargetCommitteeSize: {
|
|
121
108
|
env: 'AZTEC_TARGET_COMMITTEE_SIZE',
|
|
122
109
|
description: 'The target validator committee size.',
|
|
123
|
-
...numberConfigHelper(
|
|
110
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_TARGET_COMMITTEE_SIZE),
|
|
124
111
|
},
|
|
125
112
|
lagInEpochsForValidatorSet: {
|
|
126
113
|
env: 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
|
|
127
114
|
description: 'The number of epochs to lag behind the current epoch for validator selection.',
|
|
128
|
-
...numberConfigHelper(
|
|
115
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET),
|
|
129
116
|
},
|
|
130
117
|
lagInEpochsForRandao: {
|
|
131
118
|
env: 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO',
|
|
132
119
|
description: 'The number of epochs to lag behind the current epoch for randao selection.',
|
|
133
|
-
...numberConfigHelper(
|
|
120
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_RANDAO),
|
|
121
|
+
},
|
|
122
|
+
inboxLag: {
|
|
123
|
+
env: 'AZTEC_INBOX_LAG',
|
|
124
|
+
description: 'The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks).',
|
|
125
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_INBOX_LAG),
|
|
134
126
|
},
|
|
135
127
|
aztecProofSubmissionEpochs: {
|
|
136
128
|
env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
|
|
137
129
|
description: 'The number of epochs after an epoch ends that proofs are still accepted.',
|
|
138
|
-
...numberConfigHelper(
|
|
130
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_PROOF_SUBMISSION_EPOCHS),
|
|
139
131
|
},
|
|
140
132
|
activationThreshold: {
|
|
141
133
|
env: 'AZTEC_ACTIVATION_THRESHOLD',
|
|
142
134
|
description: 'The deposit amount for a validator',
|
|
143
|
-
...bigintConfigHelper(
|
|
135
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_ACTIVATION_THRESHOLD)),
|
|
144
136
|
},
|
|
145
137
|
ejectionThreshold: {
|
|
146
138
|
env: 'AZTEC_EJECTION_THRESHOLD',
|
|
147
139
|
description: 'The minimum stake for a validator.',
|
|
148
|
-
...bigintConfigHelper(
|
|
140
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_EJECTION_THRESHOLD)),
|
|
149
141
|
},
|
|
150
142
|
localEjectionThreshold: {
|
|
151
143
|
env: 'AZTEC_LOCAL_EJECTION_THRESHOLD',
|
|
152
144
|
description:
|
|
153
145
|
'The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup',
|
|
154
|
-
...bigintConfigHelper(
|
|
146
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_LOCAL_EJECTION_THRESHOLD)),
|
|
155
147
|
},
|
|
156
148
|
slashingOffsetInRounds: {
|
|
157
149
|
env: 'AZTEC_SLASHING_OFFSET_IN_ROUNDS',
|
|
158
150
|
description:
|
|
159
151
|
'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
|
|
160
|
-
...numberConfigHelper(
|
|
152
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
|
|
161
153
|
},
|
|
162
|
-
|
|
163
|
-
env: '
|
|
164
|
-
description: '
|
|
165
|
-
...
|
|
154
|
+
slasherEnabled: {
|
|
155
|
+
env: 'AZTEC_SLASHER_ENABLED',
|
|
156
|
+
description: 'Whether to deploy a slasher proposer',
|
|
157
|
+
...booleanConfigHelper(true),
|
|
166
158
|
},
|
|
167
159
|
slashAmountSmall: {
|
|
168
160
|
env: 'AZTEC_SLASH_AMOUNT_SMALL',
|
|
169
161
|
description: 'Small slashing amount for light offenses',
|
|
170
|
-
...bigintConfigHelper(
|
|
162
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_SMALL)),
|
|
171
163
|
},
|
|
172
164
|
slashAmountMedium: {
|
|
173
165
|
env: 'AZTEC_SLASH_AMOUNT_MEDIUM',
|
|
174
166
|
description: 'Medium slashing amount for moderate offenses',
|
|
175
|
-
...bigintConfigHelper(
|
|
167
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_MEDIUM)),
|
|
176
168
|
},
|
|
177
169
|
slashAmountLarge: {
|
|
178
170
|
env: 'AZTEC_SLASH_AMOUNT_LARGE',
|
|
179
171
|
description: 'Large slashing amount for severe offenses',
|
|
180
|
-
...bigintConfigHelper(
|
|
172
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_LARGE)),
|
|
181
173
|
},
|
|
182
174
|
slashingQuorum: {
|
|
183
175
|
env: 'AZTEC_SLASHING_QUORUM',
|
|
@@ -187,28 +179,28 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
187
179
|
slashingRoundSizeInEpochs: {
|
|
188
180
|
env: 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS',
|
|
189
181
|
description: 'The slashing round size',
|
|
190
|
-
...numberConfigHelper(
|
|
182
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS),
|
|
191
183
|
},
|
|
192
184
|
slashingLifetimeInRounds: {
|
|
193
185
|
env: 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS',
|
|
194
186
|
description: 'The slashing lifetime in rounds',
|
|
195
|
-
...numberConfigHelper(
|
|
187
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_LIFETIME_IN_ROUNDS),
|
|
196
188
|
},
|
|
197
189
|
slashingExecutionDelayInRounds: {
|
|
198
190
|
env: 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS',
|
|
199
191
|
description: 'The slashing execution delay in rounds',
|
|
200
|
-
...numberConfigHelper(
|
|
192
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS),
|
|
201
193
|
},
|
|
202
194
|
slashingVetoer: {
|
|
203
195
|
env: 'AZTEC_SLASHING_VETOER',
|
|
204
196
|
description: 'The slashing vetoer',
|
|
205
197
|
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
206
|
-
defaultValue:
|
|
198
|
+
defaultValue: EthAddress.fromString(l1ContractsDefaultEnv.AZTEC_SLASHING_VETOER),
|
|
207
199
|
},
|
|
208
200
|
slashingDisableDuration: {
|
|
209
201
|
env: 'AZTEC_SLASHING_DISABLE_DURATION',
|
|
210
202
|
description: 'How long slashing can be disabled for in seconds when vetoer disables it',
|
|
211
|
-
...numberConfigHelper(
|
|
203
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_DISABLE_DURATION),
|
|
212
204
|
},
|
|
213
205
|
governanceProposerQuorum: {
|
|
214
206
|
env: 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
|
|
@@ -218,26 +210,42 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
218
210
|
governanceProposerRoundSize: {
|
|
219
211
|
env: 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
|
|
220
212
|
description: 'The governance proposing round size',
|
|
221
|
-
...numberConfigHelper(
|
|
213
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE),
|
|
214
|
+
},
|
|
215
|
+
governanceVotingDuration: {
|
|
216
|
+
env: 'AZTEC_GOVERNANCE_VOTING_DURATION',
|
|
217
|
+
description: 'Governance voting duration in seconds (only for local/devnet/next-net)',
|
|
218
|
+
...numberConfigHelper(3600), // 1 hour default, not in generated defaults as it's deployment-time only
|
|
222
219
|
},
|
|
223
220
|
manaTarget: {
|
|
224
221
|
env: 'AZTEC_MANA_TARGET',
|
|
225
222
|
description: 'The mana target for the rollup',
|
|
226
|
-
...bigintConfigHelper(
|
|
223
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_MANA_TARGET)),
|
|
227
224
|
},
|
|
228
225
|
provingCostPerMana: {
|
|
229
226
|
env: 'AZTEC_PROVING_COST_PER_MANA',
|
|
230
227
|
description: 'The proving cost per mana',
|
|
231
|
-
...bigintConfigHelper(
|
|
228
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_PROVING_COST_PER_MANA)),
|
|
229
|
+
},
|
|
230
|
+
initialEthPerFeeAsset: {
|
|
231
|
+
env: 'AZTEC_INITIAL_ETH_PER_FEE_ASSET',
|
|
232
|
+
description: 'The initial ETH per fee asset price (with 1e12 precision)',
|
|
233
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_INITIAL_ETH_PER_FEE_ASSET)),
|
|
232
234
|
},
|
|
233
235
|
exitDelaySeconds: {
|
|
234
236
|
env: 'AZTEC_EXIT_DELAY_SECONDS',
|
|
235
237
|
description: 'The delay before a validator can exit the set',
|
|
236
|
-
...numberConfigHelper(
|
|
238
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
|
|
237
239
|
},
|
|
238
|
-
...l1TxUtilsConfigMappings,
|
|
240
|
+
...omitConfigMappings(l1TxUtilsConfigMappings, ['ethereumSlotDuration']),
|
|
239
241
|
};
|
|
240
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Default L1 contracts configuration derived from l1ContractsConfigMappings.
|
|
245
|
+
* Source of truth: spartan/environments/defaults.yml -> defaults.l1-contracts
|
|
246
|
+
*/
|
|
247
|
+
export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
|
|
248
|
+
|
|
241
249
|
export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
|
|
242
250
|
testAccounts: {
|
|
243
251
|
env: 'TEST_ACCOUNTS',
|
|
@@ -249,6 +257,16 @@ export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig>
|
|
|
249
257
|
description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
|
|
250
258
|
...booleanConfigHelper(false),
|
|
251
259
|
},
|
|
260
|
+
prefundAddresses: {
|
|
261
|
+
env: 'PREFUND_ADDRESSES',
|
|
262
|
+
description: 'Comma-separated list of Aztec addresses to prefund with fee juice at genesis (local network only).',
|
|
263
|
+
parseEnv: (val: string) =>
|
|
264
|
+
val
|
|
265
|
+
.split(',')
|
|
266
|
+
.map(a => a.trim())
|
|
267
|
+
.filter(a => a.length > 0),
|
|
268
|
+
defaultValue: [],
|
|
269
|
+
},
|
|
252
270
|
};
|
|
253
271
|
|
|
254
272
|
export function getL1ContractsConfigEnvVars(): L1ContractsConfig {
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# L1 Contract Wrappers
|
|
2
|
+
|
|
3
|
+
This folder contains TypeScript wrappers for L1 contracts defined in `l1-contracts/`. These wrappers are used by the node client to interact with the rollup and related contracts on Ethereum.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
The goal of wrapping is to shield consumers from L1-specific and viem-specific details. Clients using these wrappers interact with domain types and branded types native to the Aztec codebase, without needing to understand viem's ABI type system or deal with raw types like `Hex` and `bigint`.
|
|
8
|
+
|
|
9
|
+
## Type Safety
|
|
10
|
+
|
|
11
|
+
### Explicit Return Types
|
|
12
|
+
|
|
13
|
+
Every function in the contract wrappers must declare its return type explicitly. This is critical because viem's type inference over ABI types is slow and significantly impacts IDE performance.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// Good: Explicit return type
|
|
17
|
+
async getSlotNumber(): Promise<SlotNumber> {
|
|
18
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Bad: Inferred return type (slow)
|
|
22
|
+
async getSlotNumber() {
|
|
23
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Branded and Domain Types
|
|
28
|
+
|
|
29
|
+
Use branded types and domain-specific types instead of viem's autogenerated types for both arguments and return values:
|
|
30
|
+
|
|
31
|
+
- `CheckpointNumber`, `EpochNumber`, `SlotNumber` instead of `bigint`
|
|
32
|
+
- `EthAddress` instead of `` `0x${string}` `` or `Hex`
|
|
33
|
+
- `Fr`, `Buffer32` instead of `Hex` for hashes and field elements
|
|
34
|
+
- Custom domain types (e.g., `CheckpointLog`, `AttesterView`) instead of raw tuples
|
|
35
|
+
|
|
36
|
+
Type conversions happen inside wrapper methods, not at the call site:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
async getCheckpoint(checkpointNumber: CheckpointNumber): Promise<CheckpointLog> {
|
|
40
|
+
const result = await this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
|
|
41
|
+
return {
|
|
42
|
+
archive: Fr.fromString(result.archive),
|
|
43
|
+
headerHash: Buffer32.fromString(result.headerHash),
|
|
44
|
+
blockCount: result.blockCount,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Wrapper Pattern
|
|
50
|
+
|
|
51
|
+
### Basic Structure
|
|
52
|
+
|
|
53
|
+
Each wrapper follows a consistent structure:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
export class FooContract {
|
|
57
|
+
private readonly foo: GetContractReturnType<typeof FooAbi, ViemClient>;
|
|
58
|
+
|
|
59
|
+
constructor(
|
|
60
|
+
public readonly client: ViemClient,
|
|
61
|
+
address: Hex | EthAddress,
|
|
62
|
+
) {
|
|
63
|
+
if (address instanceof EthAddress) {
|
|
64
|
+
address = address.toString();
|
|
65
|
+
}
|
|
66
|
+
this.foo = getContract({ address, abi: FooAbi, client });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public get address(): Hex {
|
|
70
|
+
return this.foo.address;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public getContract(): GetContractReturnType<typeof FooAbi, ViemClient> {
|
|
74
|
+
return this.foo;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The raw contract is exposed via `getContract()` for cases where direct access is needed, but most consumers should use the typed wrapper methods. Relying on `getContract()` is a code smell and should be avoided.
|
|
80
|
+
|
|
81
|
+
### Static Factory Methods
|
|
82
|
+
|
|
83
|
+
Wrappers may provide static factory methods for common initialization patterns:
|
|
84
|
+
|
|
85
|
+
- `getFromConfig(config)` - construct from configuration object
|
|
86
|
+
- `getFromL1ContractsValues(deployResult)` - construct from deployment result
|
|
87
|
+
|
|
88
|
+
### Wallet Assertions
|
|
89
|
+
|
|
90
|
+
For write operations that require a wallet, use an assertion helper:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
private assertWallet(): GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient> {
|
|
94
|
+
if (!isExtendedClient(this.client)) {
|
|
95
|
+
throw new Error('Wallet client is required for this operation');
|
|
96
|
+
}
|
|
97
|
+
return this.foo as GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient>;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Event Handling
|
|
102
|
+
|
|
103
|
+
### Event Log Types
|
|
104
|
+
|
|
105
|
+
Event logs are wrapped in `L1EventLog<T>` to include L1 block context:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
type L1EventLog<T> = {
|
|
109
|
+
l1BlockNumber: bigint;
|
|
110
|
+
l1BlockHash: Buffer32;
|
|
111
|
+
l1TransactionHash: Hex;
|
|
112
|
+
args: T;
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Event Fetching
|
|
117
|
+
|
|
118
|
+
Methods that fetch events convert viem's raw logs to domain types:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
async getCheckpointProposedEvents(fromBlock: bigint, toBlock: bigint): Promise<CheckpointProposedLog[]> {
|
|
122
|
+
const logs = await this.rollup.getEvents.CheckpointProposed({}, { fromBlock, toBlock });
|
|
123
|
+
return logs.map(log => ({
|
|
124
|
+
l1BlockNumber: log.blockNumber!,
|
|
125
|
+
l1BlockHash: Buffer32.fromString(log.blockHash!),
|
|
126
|
+
l1TransactionHash: log.transactionHash!,
|
|
127
|
+
args: {
|
|
128
|
+
checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber!),
|
|
129
|
+
// ... convert other fields
|
|
130
|
+
},
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Event Listeners
|
|
136
|
+
|
|
137
|
+
For reactive event handling, wrapper methods convert arguments before invoking callbacks:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
public listenToCheckpointInvalidated(
|
|
141
|
+
callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
|
|
142
|
+
): WatchContractEventReturnType {
|
|
143
|
+
return this.rollup.watchEvent.CheckpointInvalidated({}, {
|
|
144
|
+
onLogs: logs => {
|
|
145
|
+
for (const log of logs) {
|
|
146
|
+
if (log.args.checkpointNumber !== undefined) {
|
|
147
|
+
callback({ checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber) });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Error Handling
|
|
156
|
+
|
|
157
|
+
Custom error classes in `errors.ts` extend `Error` and set `this.name` for proper error identification. Include relevant context as public readonly properties.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
|
|
2
|
+
import type { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Buffer32 } from '@aztec/foundation/buffer';
|
|
4
|
+
import { merge } from '@aztec/foundation/collection';
|
|
5
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
+
|
|
7
|
+
import type { StateOverride } from 'viem';
|
|
8
|
+
|
|
9
|
+
import { type FeeHeader, RollupContract } from './rollup.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Override values for the pending checkpoint that the simulation should treat as already applied.
|
|
13
|
+
* Every field is optional at plan-building time so callers can populate them incrementally; whatever
|
|
14
|
+
* is present at translation time is forwarded to the partial `tempCheckpointLogs` helper so the
|
|
15
|
+
* load-bearing `slotNumber` can land even if other fields could not be derived locally.
|
|
16
|
+
*/
|
|
17
|
+
export type PendingCheckpointOverrideState = {
|
|
18
|
+
archive?: Fr;
|
|
19
|
+
feeHeader?: FeeHeader;
|
|
20
|
+
headerHash?: Fr;
|
|
21
|
+
outHash?: Fr;
|
|
22
|
+
payloadDigest?: Buffer32;
|
|
23
|
+
slotNumber?: SlotNumber;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type ChainTipsOverride = {
|
|
27
|
+
pending?: CheckpointNumber;
|
|
28
|
+
proven?: CheckpointNumber;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Describes the simulated L1 rollup state that downstream calls should observe. */
|
|
32
|
+
export type SimulationOverridesPlan = {
|
|
33
|
+
chainTipsOverride?: ChainTipsOverride;
|
|
34
|
+
pendingCheckpointState?: PendingCheckpointOverrideState;
|
|
35
|
+
disableBlobCheck?: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Builds a single-checkpoint simulation plan before it is translated into a viem state override. */
|
|
39
|
+
export class SimulationOverridesBuilder {
|
|
40
|
+
private chainTipsOverride?: ChainTipsOverride;
|
|
41
|
+
private pendingCheckpointState?: PendingCheckpointOverrideState;
|
|
42
|
+
private disableBlobCheck = false;
|
|
43
|
+
|
|
44
|
+
/** Starts from an existing plan so callers can extend or specialize it. */
|
|
45
|
+
public static from(plan: SimulationOverridesPlan | undefined): SimulationOverridesBuilder {
|
|
46
|
+
return new SimulationOverridesBuilder().merge(plan);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Merges another plan into this builder. Later values win on a per-half basis for chain tips,
|
|
51
|
+
* but explicit `undefined` fields in the incoming plan are ignored so they cannot erase a
|
|
52
|
+
* previously-set value.
|
|
53
|
+
*/
|
|
54
|
+
public merge(plan: SimulationOverridesPlan | undefined): this {
|
|
55
|
+
if (!plan) {
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (plan.chainTipsOverride) {
|
|
60
|
+
this.chainTipsOverride = merge(this.chainTipsOverride ?? {}, plan.chainTipsOverride);
|
|
61
|
+
}
|
|
62
|
+
if (plan.pendingCheckpointState) {
|
|
63
|
+
this.pendingCheckpointState = merge(this.pendingCheckpointState ?? {}, plan.pendingCheckpointState);
|
|
64
|
+
}
|
|
65
|
+
this.disableBlobCheck = this.disableBlobCheck || (plan.disableBlobCheck ?? false);
|
|
66
|
+
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Sets the pending and/or proven checkpoint number overrides. Subsequent calls merge into the existing
|
|
72
|
+
* override on a per-half basis, so callers can set pending in one call and proven in another without
|
|
73
|
+
* clobbering each other.
|
|
74
|
+
*/
|
|
75
|
+
public withChainTips(override: ChainTipsOverride): this {
|
|
76
|
+
this.chainTipsOverride = { ...(this.chainTipsOverride ?? {}), ...override };
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Overrides the archive root for the configured pending checkpoint. */
|
|
81
|
+
public withPendingArchive(archive: Fr): this {
|
|
82
|
+
this.assertPendingCheckpointNumber();
|
|
83
|
+
this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), archive };
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Overrides the fee header for the configured pending checkpoint. */
|
|
88
|
+
public withPendingFeeHeader(feeHeader: FeeHeader): this {
|
|
89
|
+
this.assertPendingCheckpointNumber();
|
|
90
|
+
this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), feeHeader };
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Overrides one or more `tempCheckpointLogs` cell fields for the configured pending checkpoint.
|
|
96
|
+
* Fields are independent: any subset can be provided. The translator (`makeTempCheckpointLogOverride`)
|
|
97
|
+
* emits a stateDiff entry per field actually set, so unspecified fields stay at their on-chain
|
|
98
|
+
* values.
|
|
99
|
+
*
|
|
100
|
+
* `slotNumber` is load-bearing for `STFLib.canPruneAtTime`: when the simulation overrides `pending`
|
|
101
|
+
* to a checkpoint that has no on-chain `tempCheckpointLogs` entry yet, the missing slotNumber falls
|
|
102
|
+
* back to 0 and the contract treats the pending tip as belonging to epoch 0, triggering a phantom
|
|
103
|
+
* prune that silently undoes the `pending` override.
|
|
104
|
+
*/
|
|
105
|
+
public withPendingTempCheckpointLogFields(fields: {
|
|
106
|
+
headerHash?: Fr;
|
|
107
|
+
outHash?: Fr;
|
|
108
|
+
payloadDigest?: Buffer32;
|
|
109
|
+
slotNumber?: SlotNumber;
|
|
110
|
+
}): this {
|
|
111
|
+
this.assertPendingCheckpointNumber();
|
|
112
|
+
this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), ...fields };
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Disables blob checking for simulations that cannot provide DA inputs. */
|
|
117
|
+
public withoutBlobCheck(): this {
|
|
118
|
+
this.disableBlobCheck = true;
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Builds the final plan, or `undefined` when no overrides were configured. */
|
|
123
|
+
public build(): SimulationOverridesPlan | undefined {
|
|
124
|
+
if (!this.pendingCheckpointState && !this.chainTipsOverride && !this.disableBlobCheck) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
chainTipsOverride: this.chainTipsOverride,
|
|
130
|
+
pendingCheckpointState: this.pendingCheckpointState,
|
|
131
|
+
disableBlobCheck: this.disableBlobCheck || undefined,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private assertPendingCheckpointNumber(): void {
|
|
136
|
+
if (this.chainTipsOverride?.pending === undefined) {
|
|
137
|
+
throw new Error('withChainTips({ pending }) must be called before attaching archive or fee header overrides');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Translates a simulation plan into the viem state override shape expected by rollup calls. */
|
|
143
|
+
export async function buildSimulationOverridesStateOverride(
|
|
144
|
+
rollup: RollupContract,
|
|
145
|
+
plan: SimulationOverridesPlan | undefined,
|
|
146
|
+
): Promise<StateOverride> {
|
|
147
|
+
if (!plan) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const rollupStateDiff: NonNullable<StateOverride[number]['stateDiff']> = [];
|
|
152
|
+
|
|
153
|
+
if (plan.chainTipsOverride) {
|
|
154
|
+
rollupStateDiff.push(...extractRollupStateDiff(await rollup.makeChainTipsOverride(plan.chainTipsOverride)));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (plan.pendingCheckpointState && plan.chainTipsOverride?.pending === undefined) {
|
|
158
|
+
throw new Error('pendingCheckpointState requires chainTipsOverride.pending to be set');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (plan.pendingCheckpointState?.archive) {
|
|
162
|
+
rollupStateDiff.push(
|
|
163
|
+
...extractRollupStateDiff(
|
|
164
|
+
rollup.makeArchiveOverride(plan.chainTipsOverride!.pending!, plan.pendingCheckpointState.archive),
|
|
165
|
+
),
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (plan.pendingCheckpointState) {
|
|
170
|
+
rollupStateDiff.push(
|
|
171
|
+
...extractRollupStateDiff(
|
|
172
|
+
await rollup.makeTempCheckpointLogOverride(plan.chainTipsOverride!.pending!, {
|
|
173
|
+
headerHash: plan.pendingCheckpointState.headerHash,
|
|
174
|
+
outHash: plan.pendingCheckpointState.outHash,
|
|
175
|
+
payloadDigest: plan.pendingCheckpointState.payloadDigest,
|
|
176
|
+
slotNumber: plan.pendingCheckpointState.slotNumber,
|
|
177
|
+
feeHeader: plan.pendingCheckpointState.feeHeader,
|
|
178
|
+
}),
|
|
179
|
+
),
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (plan.disableBlobCheck) {
|
|
184
|
+
rollupStateDiff.push({
|
|
185
|
+
slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
|
|
186
|
+
value: toPaddedHex(0n, true),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (rollupStateDiff.length === 0) {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return [{ address: rollup.address, stateDiff: rollupStateDiff }];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function extractRollupStateDiff(override: StateOverride | StateOverride[number] | undefined) {
|
|
198
|
+
const entries = Array.isArray(override) ? override : override ? [override] : [];
|
|
199
|
+
return entries.flatMap(entry => entry.stateDiff ?? []);
|
|
200
|
+
}
|