@aztec/ethereum 0.0.1-commit.7b97ef96e → 0.0.1-commit.7cbc774
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 +8 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -9
- 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/empire_base.d.ts +1 -3
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/fee_asset_price_oracle.d.ts +6 -2
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -1
- package/dest/contracts/fee_asset_price_oracle.js +11 -6
- package/dest/contracts/governance.d.ts +108 -33
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +193 -12
- package/dest/contracts/governance_proposer.d.ts +33 -3
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +51 -9
- package/dest/contracts/inbox.d.ts +3 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +12 -7
- package/dest/contracts/index.d.ts +3 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +2 -2
- package/dest/contracts/multicall.d.ts +127 -12
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +201 -94
- package/dest/contracts/outbox.d.ts +21 -4
- package/dest/contracts/outbox.d.ts.map +1 -1
- package/dest/contracts/outbox.js +29 -6
- 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 +5258 -29
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +362 -69
- 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} +13 -15
- package/dest/deploy_aztec_l1_contracts.d.ts +3 -6
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +2 -4
- package/dest/generated/l1-contracts-defaults.d.ts +2 -2
- package/dest/generated/l1-contracts-defaults.js +2 -2
- package/dest/l1_artifacts.d.ts +13409 -15883
- 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/l1_tx_utils.d.ts +12 -3
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +61 -60
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +8 -4
- package/dest/l1_tx_utils/tx_delayer.d.ts +5 -3
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -1
- package/dest/l1_tx_utils/tx_delayer.js +7 -5
- package/dest/publisher_manager.d.ts +21 -7
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +81 -7
- package/dest/queries.d.ts +13 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +62 -3
- 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 +38 -2
- package/dest/test/eth_cheat_codes.d.ts +12 -4
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +17 -4
- package/dest/test/rollup_cheat_codes.d.ts +31 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +59 -7
- 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/utils.d.ts +8 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +35 -12
- package/package.json +6 -8
- package/src/client.ts +28 -2
- package/src/config.ts +21 -13
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/empire_base.ts +0 -2
- package/src/contracts/fee_asset_price_oracle.ts +10 -5
- package/src/contracts/governance.ts +266 -9
- package/src/contracts/governance_proposer.ts +52 -5
- package/src/contracts/inbox.ts +13 -5
- package/src/contracts/index.ts +2 -2
- package/src/contracts/multicall.ts +243 -105
- package/src/contracts/outbox.ts +38 -8
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +411 -79
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +14 -16
- package/src/deploy_aztec_l1_contracts.ts +1 -5
- package/src/generated/l1-contracts-defaults.ts +2 -2
- 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/l1_tx_utils.ts +58 -42
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +8 -4
- package/src/l1_tx_utils/tx_delayer.ts +16 -7
- package/src/publisher_manager.ts +105 -10
- package/src/queries.ts +70 -4
- package/src/test/chain_monitor.ts +65 -3
- package/src/test/eth_cheat_codes.ts +16 -4
- package/src/test/rollup_cheat_codes.ts +64 -6
- package/src/test/start_anvil.ts +177 -29
- package/src/utils.ts +35 -14
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -69
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -216
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/src/contracts/empire_slashing_proposer.ts +0 -265
package/src/client.ts
CHANGED
|
@@ -25,10 +25,35 @@ type Config = {
|
|
|
25
25
|
l1ChainId: number;
|
|
26
26
|
/** The polling interval viem uses in ms */
|
|
27
27
|
viemPollingIntervalMS?: number;
|
|
28
|
+
/** Timeout for HTTP requests to the L1 RPC node in ms. */
|
|
29
|
+
l1HttpTimeoutMS?: number;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
export type { Config as EthereumClientConfig };
|
|
31
33
|
|
|
34
|
+
/** Creates a viem fallback HTTP transport for the given L1 RPC URLs. */
|
|
35
|
+
export function makeL1HttpTransport(rpcUrls: string[], opts?: { timeout?: number }) {
|
|
36
|
+
return fallback(rpcUrls.map(url => http(url, { batch: false, timeout: opts?.timeout })));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Returns the individual RPC URLs underlying a viem public client that was constructed with a
|
|
41
|
+
* fallback HTTP transport (see {@link makeL1HttpTransport}). Returns an empty array if the
|
|
42
|
+
* transport shape is not recognized (e.g. mock clients in tests, or non-fallback transports).
|
|
43
|
+
*/
|
|
44
|
+
export function getRpcUrlsFromClient(client: ViemPublicClient): string[] {
|
|
45
|
+
const transport = client.transport as unknown as {
|
|
46
|
+
transports?: { value?: { url?: string } }[];
|
|
47
|
+
value?: { url?: string };
|
|
48
|
+
url?: string;
|
|
49
|
+
};
|
|
50
|
+
if (Array.isArray(transport?.transports)) {
|
|
51
|
+
return transport.transports.map(t => t?.value?.url).filter((url): url is string => typeof url === 'string');
|
|
52
|
+
}
|
|
53
|
+
const singleUrl = transport?.value?.url ?? transport?.url;
|
|
54
|
+
return typeof singleUrl === 'string' ? [singleUrl] : [];
|
|
55
|
+
}
|
|
56
|
+
|
|
32
57
|
// TODO: Use these methods to abstract the creation of viem clients.
|
|
33
58
|
|
|
34
59
|
/** Returns a viem public client given the L1 config. */
|
|
@@ -36,7 +61,7 @@ export function getPublicClient(config: Config): ViemPublicClient {
|
|
|
36
61
|
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
37
62
|
return createPublicClient({
|
|
38
63
|
chain: chain.chainInfo,
|
|
39
|
-
transport:
|
|
64
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
40
65
|
pollingInterval: config.viemPollingIntervalMS,
|
|
41
66
|
});
|
|
42
67
|
}
|
|
@@ -77,6 +102,7 @@ export function createExtendedL1Client(
|
|
|
77
102
|
chain: Chain = foundry,
|
|
78
103
|
pollingIntervalMS?: number,
|
|
79
104
|
addressIndex?: number,
|
|
105
|
+
opts?: { httpTimeoutMS?: number },
|
|
80
106
|
): ExtendedViemWalletClient {
|
|
81
107
|
const hdAccount =
|
|
82
108
|
typeof mnemonicOrPrivateKeyOrHdAccount === 'string'
|
|
@@ -88,7 +114,7 @@ export function createExtendedL1Client(
|
|
|
88
114
|
const extendedClient = createWalletClient({
|
|
89
115
|
account: hdAccount,
|
|
90
116
|
chain,
|
|
91
|
-
transport:
|
|
117
|
+
transport: makeL1HttpTransport(rpcUrls, { timeout: opts?.httpTimeoutMS }),
|
|
92
118
|
pollingInterval: pollingIntervalMS,
|
|
93
119
|
}).extend(publicActions);
|
|
94
120
|
|
package/src/config.ts
CHANGED
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
bigintConfigHelper,
|
|
4
4
|
booleanConfigHelper,
|
|
5
|
-
enumConfigHelper,
|
|
6
5
|
getConfigFromMappings,
|
|
7
6
|
getDefaultConfig,
|
|
8
7
|
numberConfigHelper,
|
|
@@ -19,6 +18,8 @@ export type GenesisStateConfig = {
|
|
|
19
18
|
testAccounts: boolean;
|
|
20
19
|
/** Whether to populate the genesis state with initial fee juice for the sponsored FPC */
|
|
21
20
|
sponsoredFPC: boolean;
|
|
21
|
+
/** Additional addresses to prefund with fee juice at genesis */
|
|
22
|
+
prefundAddresses: string[];
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
export type L1ContractsConfig = {
|
|
@@ -58,13 +59,13 @@ export type L1ContractsConfig = {
|
|
|
58
59
|
slashingOffsetInRounds: number;
|
|
59
60
|
/** How long slashing can be disabled for in seconds when vetoer disables it */
|
|
60
61
|
slashingDisableDuration: number;
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
/** Minimum amount that can be slashed
|
|
62
|
+
/** Whether to deploy a slasher proposer */
|
|
63
|
+
slasherEnabled: boolean;
|
|
64
|
+
/** Minimum amount that can be slashed */
|
|
64
65
|
slashAmountSmall: bigint;
|
|
65
|
-
/** Medium amount to slash
|
|
66
|
+
/** Medium amount to slash */
|
|
66
67
|
slashAmountMedium: bigint;
|
|
67
|
-
/** Largest amount that can be slashed per round
|
|
68
|
+
/** Largest amount that can be slashed per round */
|
|
68
69
|
slashAmountLarge: bigint;
|
|
69
70
|
/** Governance proposing quorum (defaults to roundSize/2 + 1) */
|
|
70
71
|
governanceProposerQuorum?: number;
|
|
@@ -150,13 +151,10 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
150
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)',
|
|
151
152
|
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
|
|
152
153
|
},
|
|
153
|
-
|
|
154
|
-
env: '
|
|
155
|
-
description: '
|
|
156
|
-
...
|
|
157
|
-
['empire', 'tally', 'none'] as const,
|
|
158
|
-
l1ContractsDefaultEnv.AZTEC_SLASHER_FLAVOR as 'empire' | 'tally' | 'none',
|
|
159
|
-
),
|
|
154
|
+
slasherEnabled: {
|
|
155
|
+
env: 'AZTEC_SLASHER_ENABLED',
|
|
156
|
+
description: 'Whether to deploy a slasher proposer',
|
|
157
|
+
...booleanConfigHelper(true),
|
|
160
158
|
},
|
|
161
159
|
slashAmountSmall: {
|
|
162
160
|
env: 'AZTEC_SLASH_AMOUNT_SMALL',
|
|
@@ -259,6 +257,16 @@ export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig>
|
|
|
259
257
|
description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
|
|
260
258
|
...booleanConfigHelper(false),
|
|
261
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
|
+
},
|
|
262
270
|
};
|
|
263
271
|
|
|
264
272
|
export function getL1ContractsConfigEnvVars(): L1ContractsConfig {
|
|
@@ -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
|
+
}
|
|
@@ -22,8 +22,6 @@ export interface IEmpireBase {
|
|
|
22
22
|
signerAddress: Hex,
|
|
23
23
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
24
24
|
): Promise<L1TxRequest>;
|
|
25
|
-
/** Checks if a payload was ever submitted to governance via submitRoundWinner. */
|
|
26
|
-
hasPayloadBeenProposed(payload: Hex, fromBlock: bigint): Promise<boolean>;
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export function encodeSignal(payload: Hex): Hex {
|
|
@@ -63,28 +63,33 @@ export class FeeAssetPriceOracle {
|
|
|
63
63
|
*
|
|
64
64
|
* Returns 0 if not on mainnet or if the oracle query fails.
|
|
65
65
|
*
|
|
66
|
+
* @param currentPriceE12 - Optional override for the parent checkpoint's eth-per-fee-asset
|
|
67
|
+
* (E12 scale). When omitted, the latest published value is read from L1. Pipelined
|
|
68
|
+
* proposers should supply the predicted parent value so the modifier they emit aligns
|
|
69
|
+
* with the parent fee header L1 will see when the previous pipelined checkpoint lands.
|
|
66
70
|
* @returns The price modifier in basis points (positive to increase price, negative to decrease)
|
|
67
71
|
*/
|
|
68
|
-
async computePriceModifier(): Promise<bigint> {
|
|
72
|
+
async computePriceModifier(currentPriceE12?: bigint): Promise<bigint> {
|
|
69
73
|
const uniswapOracle = await this.getUniswapOracle();
|
|
70
74
|
if (!uniswapOracle) {
|
|
71
75
|
return 0n;
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
try {
|
|
75
|
-
// Get current on-chain price (ETH per fee asset, E12)
|
|
76
|
-
const
|
|
79
|
+
// Get current on-chain price (ETH per fee asset, E12), preferring the caller-supplied value.
|
|
80
|
+
const resolvedCurrentPriceE12 = currentPriceE12 ?? (await this.rollupContract.getEthPerFeeAsset());
|
|
77
81
|
|
|
78
82
|
// Get oracle price (median of last N blocks, ETH per fee asset, E12)
|
|
79
83
|
const oraclePriceE12 = await uniswapOracle.getMeanEthPerFeeAssetE12();
|
|
80
84
|
|
|
81
85
|
// Compute modifier in basis points
|
|
82
|
-
const modifier = this.computePriceModifierBps(
|
|
86
|
+
const modifier = this.computePriceModifierBps(resolvedCurrentPriceE12, oraclePriceE12);
|
|
83
87
|
|
|
84
88
|
this.log.debug('Computed price modifier', {
|
|
85
|
-
currentPriceE12:
|
|
89
|
+
currentPriceE12: resolvedCurrentPriceE12.toString(),
|
|
86
90
|
oraclePriceE12: oraclePriceE12.toString(),
|
|
87
91
|
modifierBps: modifier.toString(),
|
|
92
|
+
currentPriceFromCaller: currentPriceE12 !== undefined,
|
|
88
93
|
});
|
|
89
94
|
|
|
90
95
|
return modifier;
|