@aztec/ethereum 0.0.1-commit.d431d1c → 0.0.1-commit.d939eb5aa

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.
Files changed (166) hide show
  1. package/dest/client.d.ts +10 -2
  2. package/dest/client.d.ts.map +1 -1
  3. package/dest/client.js +13 -7
  4. package/dest/config.d.ts +10 -6
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +20 -11
  7. package/dest/contracts/chain_state_override.d.ts +38 -0
  8. package/dest/contracts/chain_state_override.d.ts.map +1 -0
  9. package/dest/contracts/chain_state_override.js +100 -0
  10. package/dest/contracts/empire_base.d.ts +3 -1
  11. package/dest/contracts/empire_base.d.ts.map +1 -1
  12. package/dest/contracts/fee_asset_handler.d.ts +1 -1
  13. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  14. package/dest/contracts/fee_asset_handler.js +2 -0
  15. package/dest/contracts/fee_asset_price_oracle.d.ts +101 -0
  16. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  17. package/dest/contracts/fee_asset_price_oracle.js +651 -0
  18. package/dest/contracts/governance.d.ts +3 -1
  19. package/dest/contracts/governance.d.ts.map +1 -1
  20. package/dest/contracts/governance.js +14 -4
  21. package/dest/contracts/governance_proposer.d.ts +3 -1
  22. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  23. package/dest/contracts/governance_proposer.js +13 -1
  24. package/dest/contracts/inbox.d.ts +3 -3
  25. package/dest/contracts/inbox.d.ts.map +1 -1
  26. package/dest/contracts/inbox.js +5 -6
  27. package/dest/contracts/index.d.ts +4 -3
  28. package/dest/contracts/index.d.ts.map +1 -1
  29. package/dest/contracts/index.js +3 -2
  30. package/dest/contracts/multicall.d.ts +51 -2
  31. package/dest/contracts/multicall.d.ts.map +1 -1
  32. package/dest/contracts/multicall.js +87 -1
  33. package/dest/contracts/registry.d.ts +3 -1
  34. package/dest/contracts/registry.d.ts.map +1 -1
  35. package/dest/contracts/registry.js +30 -1
  36. package/dest/contracts/rollup.d.ts +90 -26
  37. package/dest/contracts/rollup.d.ts.map +1 -1
  38. package/dest/contracts/rollup.js +309 -63
  39. package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
  40. package/dest/contracts/slashing_proposer.d.ts.map +1 -0
  41. package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +18 -13
  42. package/dest/deploy_aztec_l1_contracts.d.ts +6 -8
  43. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
  44. package/dest/deploy_aztec_l1_contracts.js +40 -26
  45. package/dest/deploy_l1_contract.js +3 -3
  46. package/dest/generated/l1-contracts-defaults.d.ts +4 -3
  47. package/dest/generated/l1-contracts-defaults.d.ts.map +1 -1
  48. package/dest/generated/l1-contracts-defaults.js +3 -2
  49. package/dest/l1_artifacts.d.ts +10148 -15682
  50. package/dest/l1_artifacts.d.ts.map +1 -1
  51. package/dest/l1_artifacts.js +9 -24
  52. package/dest/l1_contract_addresses.d.ts +1 -5
  53. package/dest/l1_contract_addresses.d.ts.map +1 -1
  54. package/dest/l1_contract_addresses.js +0 -6
  55. package/dest/l1_reader.d.ts +3 -1
  56. package/dest/l1_reader.d.ts.map +1 -1
  57. package/dest/l1_reader.js +6 -1
  58. package/dest/l1_tx_utils/config.d.ts +7 -1
  59. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  60. package/dest/l1_tx_utils/config.js +14 -1
  61. package/dest/l1_tx_utils/constants.d.ts +1 -1
  62. package/dest/l1_tx_utils/constants.js +2 -2
  63. package/dest/l1_tx_utils/factory.d.ts +18 -10
  64. package/dest/l1_tx_utils/factory.d.ts.map +1 -1
  65. package/dest/l1_tx_utils/factory.js +17 -7
  66. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +1 -1
  67. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +1 -1
  68. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
  69. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
  70. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
  71. package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
  72. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
  73. package/dest/l1_tx_utils/index-blobs.js +2 -2
  74. package/dest/l1_tx_utils/index.d.ts +2 -1
  75. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  76. package/dest/l1_tx_utils/index.js +1 -0
  77. package/dest/l1_tx_utils/l1_tx_utils.d.ts +20 -7
  78. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  79. package/dest/l1_tx_utils/l1_tx_utils.js +81 -57
  80. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
  81. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  82. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +11 -7
  83. package/dest/l1_tx_utils/tx_delayer.d.ts +56 -0
  84. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  85. package/dest/{test → l1_tx_utils}/tx_delayer.js +62 -34
  86. package/dest/publisher_manager.d.ts +21 -6
  87. package/dest/publisher_manager.d.ts.map +1 -1
  88. package/dest/publisher_manager.js +81 -7
  89. package/dest/queries.d.ts +1 -1
  90. package/dest/queries.d.ts.map +1 -1
  91. package/dest/queries.js +5 -4
  92. package/dest/test/chain_monitor.d.ts +22 -3
  93. package/dest/test/chain_monitor.d.ts.map +1 -1
  94. package/dest/test/chain_monitor.js +33 -2
  95. package/dest/test/eth_cheat_codes.d.ts +6 -4
  96. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  97. package/dest/test/eth_cheat_codes.js +6 -4
  98. package/dest/test/index.d.ts +1 -3
  99. package/dest/test/index.d.ts.map +1 -1
  100. package/dest/test/index.js +0 -2
  101. package/dest/test/rollup_cheat_codes.d.ts +8 -2
  102. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  103. package/dest/test/rollup_cheat_codes.js +19 -2
  104. package/dest/test/start_anvil.d.ts +23 -3
  105. package/dest/test/start_anvil.d.ts.map +1 -1
  106. package/dest/test/start_anvil.js +143 -29
  107. package/dest/test/upgrade_utils.js +2 -2
  108. package/dest/utils.d.ts +2 -1
  109. package/dest/utils.d.ts.map +1 -1
  110. package/dest/utils.js +62 -12
  111. package/package.json +5 -7
  112. package/src/client.ts +10 -2
  113. package/src/config.ts +31 -15
  114. package/src/contracts/chain_state_override.ts +147 -0
  115. package/src/contracts/empire_base.ts +2 -0
  116. package/src/contracts/fee_asset_handler.ts +2 -0
  117. package/src/contracts/fee_asset_price_oracle.ts +280 -0
  118. package/src/contracts/governance.ts +13 -4
  119. package/src/contracts/governance_proposer.ts +10 -1
  120. package/src/contracts/inbox.ts +4 -4
  121. package/src/contracts/index.ts +3 -2
  122. package/src/contracts/multicall.ts +70 -3
  123. package/src/contracts/registry.ts +31 -1
  124. package/src/contracts/rollup.ts +339 -63
  125. package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +16 -14
  126. package/src/deploy_aztec_l1_contracts.ts +62 -34
  127. package/src/deploy_l1_contract.ts +3 -3
  128. package/src/generated/l1-contracts-defaults.ts +3 -2
  129. package/src/l1_artifacts.ts +12 -35
  130. package/src/l1_contract_addresses.ts +0 -7
  131. package/src/l1_reader.ts +13 -1
  132. package/src/l1_tx_utils/config.ts +20 -0
  133. package/src/l1_tx_utils/constants.ts +2 -2
  134. package/src/l1_tx_utils/factory.ts +31 -31
  135. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +1 -1
  136. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +1 -1
  137. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
  138. package/src/l1_tx_utils/index-blobs.ts +2 -2
  139. package/src/l1_tx_utils/index.ts +1 -0
  140. package/src/l1_tx_utils/l1_tx_utils.ts +74 -36
  141. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +11 -7
  142. package/src/{test → l1_tx_utils}/tx_delayer.ts +78 -50
  143. package/src/publisher_manager.ts +107 -10
  144. package/src/queries.ts +4 -3
  145. package/src/test/chain_monitor.ts +60 -3
  146. package/src/test/eth_cheat_codes.ts +6 -4
  147. package/src/test/index.ts +0 -2
  148. package/src/test/rollup_cheat_codes.ts +22 -3
  149. package/src/test/start_anvil.ts +177 -29
  150. package/src/test/upgrade_utils.ts +2 -2
  151. package/src/utils.ts +70 -14
  152. package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
  153. package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
  154. package/dest/contracts/empire_slashing_proposer.js +0 -209
  155. package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
  156. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
  157. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
  158. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
  159. package/dest/test/delayed_tx_utils.d.ts +0 -13
  160. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  161. package/dest/test/delayed_tx_utils.js +0 -28
  162. package/dest/test/tx_delayer.d.ts +0 -36
  163. package/dest/test/tx_delayer.d.ts.map +0 -1
  164. package/src/contracts/empire_slashing_proposer.ts +0 -270
  165. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
  166. package/src/test/delayed_tx_utils.ts +0 -52
package/dest/utils.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
2
2
  import { BaseError, ContractFunctionRevertedError, decodeErrorResult, decodeEventLog } from 'viem';
3
+ import { formatAbiItem, formatAbiParams } from 'viem/utils';
3
4
  export class FormattedViemError extends Error {
4
5
  metaMessages;
5
6
  constructor(message, metaMessages){
@@ -46,6 +47,51 @@ export function prettyLogViemErrorMsg(err) {
46
47
  }
47
48
  return err?.message ?? err;
48
49
  }
50
+ export function mergeAbis(abis) {
51
+ let merged = [];
52
+ const seen = new Set();
53
+ for (const abi of abis){
54
+ for (const item of abi){
55
+ const key = getAbiItemKey(item);
56
+ if (!seen.has(key)) {
57
+ seen.add(key);
58
+ merged = [
59
+ ...merged,
60
+ item
61
+ ];
62
+ }
63
+ }
64
+ }
65
+ return merged;
66
+ }
67
+ function getAbiItemKey(item) {
68
+ if (item.type === 'function') {
69
+ const signature = formatAbiItem(item);
70
+ const outputs = formatAbiParams(item.outputs);
71
+ const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
72
+ return `function:${signature}:${outputs}:${stateMutability}`;
73
+ }
74
+ if (item.type === 'event') {
75
+ const signature = formatAbiItem(item);
76
+ const indexed = (item.inputs ?? []).map((input)=>input.indexed ? '1' : '0').join('');
77
+ const anonymous = item.anonymous ? 'anonymous' : 'not-anonymous';
78
+ return `event:${signature}:${indexed}:${anonymous}`;
79
+ }
80
+ if (item.type === 'error') {
81
+ const signature = formatAbiItem(item);
82
+ return `error:${signature}`;
83
+ }
84
+ if (item.type === 'constructor') {
85
+ const inputs = formatAbiParams(item.inputs);
86
+ const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
87
+ return `constructor::${inputs}:${stateMutability}`;
88
+ }
89
+ if (item.type === 'fallback' || item.type === 'receive') {
90
+ const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
91
+ return `${item.type}:::${stateMutability}`;
92
+ }
93
+ return 'unknown';
94
+ }
49
95
  function getNestedErrorData(error) {
50
96
  // If nothing, bail
51
97
  if (!error) {
@@ -66,6 +112,19 @@ function getNestedErrorData(error) {
66
112
  // Not found
67
113
  return undefined;
68
114
  }
115
+ /**
116
+ * Truncates an error message to a safe length for log renderers.
117
+ * LogExplorer can only render up to 2500 characters in its summary view.
118
+ * We cap at 2000 to leave room for decorating context added by callers.
119
+ */ function truncateErrorMessage(message) {
120
+ const MAX = 2000;
121
+ const CHUNK = 950;
122
+ if (message.length <= MAX) {
123
+ return message;
124
+ }
125
+ const truncated = message.length - 2 * CHUNK;
126
+ return message.slice(0, CHUNK) + `...${truncated} characters truncated...` + message.slice(-CHUNK);
127
+ }
69
128
  /**
70
129
  * Formats a Viem error into a FormattedViemError instance.
71
130
  * @param error - The error to format.
@@ -116,18 +175,9 @@ function getNestedErrorData(error) {
116
175
  }
117
176
  // If it's a regular Error instance, return it with its message
118
177
  if (error instanceof Error) {
119
- return new FormattedViemError(error.message, error?.metaMessages);
120
- }
121
- const body = String(error);
122
- const length = body.length;
123
- // LogExplorer can only render up to 2500 characters in it's summary view. Try to keep the whole message below this number
124
- // Limit the error to 2000 chacaters in order to allow code higher up to decorate this error with extra details (up to 500 characters)
125
- if (length > 2000) {
126
- const chunk = 950;
127
- const truncated = length - 2 * chunk;
128
- return new FormattedViemError(body.slice(0, chunk) + `...${truncated} characters truncated...` + body.slice(-1 * chunk));
129
- }
130
- return new FormattedViemError(body);
178
+ return new FormattedViemError(truncateErrorMessage(error.message), error?.metaMessages);
179
+ }
180
+ return new FormattedViemError(truncateErrorMessage(String(error)));
131
181
  }
132
182
  function stripAbis(obj) {
133
183
  if (!obj || typeof obj !== 'object') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/ethereum",
3
- "version": "0.0.1-commit.d431d1c",
3
+ "version": "0.0.1-commit.d939eb5aa",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./account": "./dest/account.js",
@@ -50,11 +50,10 @@
50
50
  "../package.common.json"
51
51
  ],
52
52
  "dependencies": {
53
- "@aztec/blob-lib": "0.0.1-commit.d431d1c",
54
- "@aztec/constants": "0.0.1-commit.d431d1c",
55
- "@aztec/foundation": "0.0.1-commit.d431d1c",
56
- "@aztec/l1-artifacts": "0.0.1-commit.d431d1c",
57
- "@viem/anvil": "^0.0.10",
53
+ "@aztec/blob-lib": "0.0.1-commit.d939eb5aa",
54
+ "@aztec/constants": "0.0.1-commit.d939eb5aa",
55
+ "@aztec/foundation": "0.0.1-commit.d939eb5aa",
56
+ "@aztec/l1-artifacts": "0.0.1-commit.d939eb5aa",
58
57
  "dotenv": "^16.0.3",
59
58
  "lodash.chunk": "^4.2.0",
60
59
  "lodash.pickby": "^4.5.0",
@@ -69,7 +68,6 @@
69
68
  "@types/lodash.pickby": "^4",
70
69
  "@types/node": "^22.15.17",
71
70
  "@typescript/native-preview": "7.0.0-dev.20260113.1",
72
- "@viem/anvil": "^0.0.10",
73
71
  "get-port": "^7.1.0",
74
72
  "jest": "^30.0.0",
75
73
  "jest-mock-extended": "^4.0.0",
package/src/client.ts CHANGED
@@ -25,10 +25,17 @@ 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
+
32
39
  // TODO: Use these methods to abstract the creation of viem clients.
33
40
 
34
41
  /** Returns a viem public client given the L1 config. */
@@ -36,7 +43,7 @@ export function getPublicClient(config: Config): ViemPublicClient {
36
43
  const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
37
44
  return createPublicClient({
38
45
  chain: chain.chainInfo,
39
- transport: fallback(config.l1RpcUrls.map(url => http(url, { batch: false }))),
46
+ transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
40
47
  pollingInterval: config.viemPollingIntervalMS,
41
48
  });
42
49
  }
@@ -77,6 +84,7 @@ export function createExtendedL1Client(
77
84
  chain: Chain = foundry,
78
85
  pollingIntervalMS?: number,
79
86
  addressIndex?: number,
87
+ opts?: { httpTimeoutMS?: number },
80
88
  ): ExtendedViemWalletClient {
81
89
  const hdAccount =
82
90
  typeof mnemonicOrPrivateKeyOrHdAccount === 'string'
@@ -88,7 +96,7 @@ export function createExtendedL1Client(
88
96
  const extendedClient = createWalletClient({
89
97
  account: hdAccount,
90
98
  chain,
91
- transport: fallback(rpcUrls.map(url => http(url, { batch: false }))),
99
+ transport: makeL1HttpTransport(rpcUrls, { timeout: opts?.httpTimeoutMS }),
92
100
  pollingInterval: pollingIntervalMS,
93
101
  }).extend(publicActions);
94
102
 
package/src/config.ts CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  type ConfigMappingsType,
3
3
  bigintConfigHelper,
4
4
  booleanConfigHelper,
5
- enumConfigHelper,
6
5
  getConfigFromMappings,
7
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';
@@ -18,6 +18,8 @@ export type GenesisStateConfig = {
18
18
  testAccounts: boolean;
19
19
  /** Whether to populate the genesis state with initial fee juice for the sponsored FPC */
20
20
  sponsoredFPC: boolean;
21
+ /** Additional addresses to prefund with fee juice at genesis */
22
+ prefundAddresses: string[];
21
23
  };
22
24
 
23
25
  export type L1ContractsConfig = {
@@ -57,13 +59,13 @@ export type L1ContractsConfig = {
57
59
  slashingOffsetInRounds: number;
58
60
  /** How long slashing can be disabled for in seconds when vetoer disables it */
59
61
  slashingDisableDuration: number;
60
- /** Type of slasher proposer */
61
- slasherFlavor: 'empire' | 'tally' | 'none';
62
- /** Minimum amount that can be slashed in tally slashing */
62
+ /** Whether to deploy a slasher proposer */
63
+ slasherEnabled: boolean;
64
+ /** Minimum amount that can be slashed */
63
65
  slashAmountSmall: bigint;
64
- /** Medium amount to slash in tally slashing */
66
+ /** Medium amount to slash */
65
67
  slashAmountMedium: bigint;
66
- /** Largest amount that can be slashed per round in tally slashing */
68
+ /** Largest amount that can be slashed per round */
67
69
  slashAmountLarge: bigint;
68
70
  /** Governance proposing quorum (defaults to roundSize/2 + 1) */
69
71
  governanceProposerQuorum?: number;
@@ -75,6 +77,8 @@ export type L1ContractsConfig = {
75
77
  manaTarget: bigint;
76
78
  /** The proving cost per mana */
77
79
  provingCostPerMana: bigint;
80
+ /** The initial ETH per fee asset price (with 1e12 precision) */
81
+ initialEthPerFeeAsset: bigint;
78
82
  /** The number of seconds to wait for an exit */
79
83
  exitDelaySeconds: number;
80
84
  } & L1TxUtilsConfig;
@@ -97,7 +101,7 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
97
101
  },
98
102
  aztecEpochDuration: {
99
103
  env: 'AZTEC_EPOCH_DURATION',
100
- description: `How many L2 slots an epoch lasts (maximum AZTEC_MAX_EPOCH_DURATION).`,
104
+ description: `How many L2 slots an epoch lasts (maximum MAX_CHECKPOINTS_PER_EPOCH).`,
101
105
  ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EPOCH_DURATION),
102
106
  },
103
107
  aztecTargetCommitteeSize: {
@@ -147,13 +151,10 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
147
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)',
148
152
  ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
149
153
  },
150
- slasherFlavor: {
151
- env: 'AZTEC_SLASHER_FLAVOR',
152
- description: 'Type of slasher proposer (empire, tally, or none)',
153
- ...enumConfigHelper(
154
- ['empire', 'tally', 'none'] as const,
155
- l1ContractsDefaultEnv.AZTEC_SLASHER_FLAVOR as 'empire' | 'tally' | 'none',
156
- ),
154
+ slasherEnabled: {
155
+ env: 'AZTEC_SLASHER_ENABLED',
156
+ description: 'Whether to deploy a slasher proposer',
157
+ ...booleanConfigHelper(true),
157
158
  },
158
159
  slashAmountSmall: {
159
160
  env: 'AZTEC_SLASH_AMOUNT_SMALL',
@@ -226,12 +227,17 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
226
227
  description: 'The proving cost per mana',
227
228
  ...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_PROVING_COST_PER_MANA)),
228
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)),
234
+ },
229
235
  exitDelaySeconds: {
230
236
  env: 'AZTEC_EXIT_DELAY_SECONDS',
231
237
  description: 'The delay before a validator can exit the set',
232
238
  ...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
233
239
  },
234
- ...l1TxUtilsConfigMappings,
240
+ ...omitConfigMappings(l1TxUtilsConfigMappings, ['ethereumSlotDuration']),
235
241
  };
236
242
 
237
243
  /**
@@ -251,6 +257,16 @@ export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig>
251
257
  description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
252
258
  ...booleanConfigHelper(false),
253
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
+ },
254
270
  };
255
271
 
256
272
  export function getL1ContractsConfigEnvVars(): L1ContractsConfig {
@@ -0,0 +1,147 @@
1
+ import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
2
+ import type { CheckpointNumber } from '@aztec/foundation/branded-types';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
4
+
5
+ import type { StateOverride } from 'viem';
6
+
7
+ import { type FeeHeader, RollupContract } from './rollup.js';
8
+
9
+ export type PendingCheckpointOverrideState = {
10
+ archive?: Fr;
11
+ feeHeader?: FeeHeader;
12
+ };
13
+
14
+ /** Describes the simulated L1 rollup state that downstream calls should observe. */
15
+ export type SimulationOverridesPlan = {
16
+ pendingCheckpointNumber?: CheckpointNumber;
17
+ pendingCheckpointState?: PendingCheckpointOverrideState;
18
+ disableBlobCheck?: boolean;
19
+ };
20
+
21
+ /** Builds a single-checkpoint simulation plan before it is translated into a viem state override. */
22
+ export class SimulationOverridesBuilder {
23
+ private pendingCheckpointNumber?: CheckpointNumber;
24
+ private pendingCheckpointState?: PendingCheckpointOverrideState;
25
+ private disableBlobCheck = false;
26
+
27
+ /** Starts from an existing plan so callers can extend or specialize it. */
28
+ public static from(plan: SimulationOverridesPlan | undefined): SimulationOverridesBuilder {
29
+ return new SimulationOverridesBuilder().merge(plan);
30
+ }
31
+
32
+ /** Merges another plan into this builder. Later values win. */
33
+ public merge(plan: SimulationOverridesPlan | undefined): this {
34
+ if (!plan) {
35
+ return this;
36
+ }
37
+
38
+ this.pendingCheckpointNumber = plan.pendingCheckpointNumber;
39
+ this.pendingCheckpointState = plan.pendingCheckpointState
40
+ ? { ...(this.pendingCheckpointState ?? {}), ...plan.pendingCheckpointState }
41
+ : this.pendingCheckpointState;
42
+ this.disableBlobCheck = this.disableBlobCheck || (plan.disableBlobCheck ?? false);
43
+
44
+ return this;
45
+ }
46
+
47
+ /** Sets the checkpoint number that archive and fee header overrides should attach to. */
48
+ public forPendingCheckpoint(pendingCheckpointNumber: CheckpointNumber | undefined): this {
49
+ this.pendingCheckpointNumber = pendingCheckpointNumber;
50
+ return this;
51
+ }
52
+
53
+ /** Overrides the archive root for the configured pending checkpoint. */
54
+ public withPendingArchive(archive: Fr): this {
55
+ this.assertPendingCheckpointNumber();
56
+ this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), archive };
57
+ return this;
58
+ }
59
+
60
+ /** Overrides the fee header for the configured pending checkpoint. */
61
+ public withPendingFeeHeader(feeHeader: FeeHeader): this {
62
+ this.assertPendingCheckpointNumber();
63
+ this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), feeHeader };
64
+ return this;
65
+ }
66
+
67
+ /** Disables blob checking for simulations that cannot provide DA inputs. */
68
+ public withoutBlobCheck(): this {
69
+ this.disableBlobCheck = true;
70
+ return this;
71
+ }
72
+
73
+ /** Builds the final plan, or `undefined` when no overrides were configured. */
74
+ public build(): SimulationOverridesPlan | undefined {
75
+ if (!this.pendingCheckpointState && this.pendingCheckpointNumber === undefined && !this.disableBlobCheck) {
76
+ return undefined;
77
+ }
78
+
79
+ return {
80
+ pendingCheckpointNumber: this.pendingCheckpointNumber,
81
+ pendingCheckpointState: this.pendingCheckpointState,
82
+ disableBlobCheck: this.disableBlobCheck || undefined,
83
+ };
84
+ }
85
+
86
+ private assertPendingCheckpointNumber(): void {
87
+ if (this.pendingCheckpointNumber === undefined) {
88
+ throw new Error('pendingCheckpointNumber must be set before attaching archive or fee header overrides');
89
+ }
90
+ }
91
+ }
92
+
93
+ /** Translates a simulation plan into the viem state override shape expected by rollup calls. */
94
+ export async function buildSimulationOverridesStateOverride(
95
+ rollup: RollupContract,
96
+ plan: SimulationOverridesPlan | undefined,
97
+ ): Promise<StateOverride> {
98
+ if (!plan) {
99
+ return [];
100
+ }
101
+
102
+ const rollupStateDiff: NonNullable<StateOverride[number]['stateDiff']> = [];
103
+
104
+ if (plan.pendingCheckpointNumber !== undefined) {
105
+ rollupStateDiff.push(
106
+ ...extractRollupStateDiff(await rollup.makePendingCheckpointNumberOverride(plan.pendingCheckpointNumber)),
107
+ );
108
+ }
109
+
110
+ if (plan.pendingCheckpointState && plan.pendingCheckpointNumber === undefined) {
111
+ throw new Error('pendingCheckpointState requires pendingCheckpointNumber to be set');
112
+ }
113
+
114
+ if (plan.pendingCheckpointState?.archive) {
115
+ rollupStateDiff.push(
116
+ ...extractRollupStateDiff(
117
+ rollup.makeArchiveOverride(plan.pendingCheckpointNumber!, plan.pendingCheckpointState.archive),
118
+ ),
119
+ );
120
+ }
121
+
122
+ if (plan.pendingCheckpointState?.feeHeader) {
123
+ rollupStateDiff.push(
124
+ ...extractRollupStateDiff(
125
+ await rollup.makeFeeHeaderOverride(plan.pendingCheckpointNumber!, plan.pendingCheckpointState.feeHeader),
126
+ ),
127
+ );
128
+ }
129
+
130
+ if (plan.disableBlobCheck) {
131
+ rollupStateDiff.push({
132
+ slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
133
+ value: toPaddedHex(0n, true),
134
+ });
135
+ }
136
+
137
+ if (rollupStateDiff.length === 0) {
138
+ return [];
139
+ }
140
+
141
+ return [{ address: rollup.address, stateDiff: rollupStateDiff }];
142
+ }
143
+
144
+ function extractRollupStateDiff(override: StateOverride | StateOverride[number] | undefined) {
145
+ const entries = Array.isArray(override) ? override : override ? [override] : [];
146
+ return entries.flatMap(entry => entry.stateDiff ?? []);
147
+ }
@@ -22,6 +22,8 @@ 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>;
25
27
  }
26
28
 
27
29
  export function encodeSignal(payload: Hex): Hex {
@@ -43,6 +43,7 @@ export class FeeAssetHandlerContract {
43
43
  }
44
44
  return txUtils.sendAndMonitorTransaction({
45
45
  to: this.address.toString(),
46
+ abi: FeeAssetHandlerAbi,
46
47
  data: encodeFunctionData({
47
48
  abi: FeeAssetHandlerAbi,
48
49
  functionName: 'mint',
@@ -54,6 +55,7 @@ export class FeeAssetHandlerContract {
54
55
  public setMintAmount(txUtils: L1TxUtils, amount: bigint) {
55
56
  return txUtils.sendAndMonitorTransaction({
56
57
  to: this.address.toString(),
58
+ abi: FeeAssetHandlerAbi,
57
59
  data: encodeFunctionData({
58
60
  abi: FeeAssetHandlerAbi,
59
61
  functionName: 'setMintAmount',