@aztec/ethereum 0.0.1-commit.3100065 → 0.0.1-commit.330febf

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 (69) hide show
  1. package/dest/config.d.ts +13 -3
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +30 -3
  4. package/dest/contracts/governance.d.ts +36 -11
  5. package/dest/contracts/governance.d.ts.map +1 -1
  6. package/dest/contracts/governance.js +54 -24
  7. package/dest/contracts/governance_proposer.d.ts +7 -8
  8. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  9. package/dest/contracts/governance_proposer.js +7 -10
  10. package/dest/contracts/gse.d.ts +5 -1
  11. package/dest/contracts/gse.d.ts.map +1 -1
  12. package/dest/contracts/gse.js +9 -0
  13. package/dest/contracts/multicall.d.ts +5 -3
  14. package/dest/contracts/multicall.d.ts.map +1 -1
  15. package/dest/contracts/multicall.js +7 -5
  16. package/dest/contracts/rollup.d.ts +9 -1
  17. package/dest/contracts/rollup.d.ts.map +1 -1
  18. package/dest/contracts/rollup.js +8 -0
  19. package/dest/contracts/slashing_proposer.d.ts +37 -6
  20. package/dest/contracts/slashing_proposer.d.ts.map +1 -1
  21. package/dest/contracts/slashing_proposer.js +447 -17
  22. package/dest/deploy_aztec_l1_contracts.d.ts +15 -4
  23. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
  24. package/dest/deploy_aztec_l1_contracts.js +24 -13
  25. package/dest/foundry_binary.d.ts +13 -0
  26. package/dest/foundry_binary.d.ts.map +1 -0
  27. package/dest/foundry_binary.js +52 -0
  28. package/dest/l1_artifacts.d.ts +24 -19
  29. package/dest/l1_artifacts.d.ts.map +1 -1
  30. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +23 -4
  31. package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
  32. package/dest/l1_tx_utils/l1_fee_analyzer.js +65 -3
  33. package/dest/l1_tx_utils/l1_tx_utils.d.ts +1 -1
  34. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  35. package/dest/l1_tx_utils/l1_tx_utils.js +27 -7
  36. package/dest/l1_tx_utils/types.d.ts +27 -1
  37. package/dest/l1_tx_utils/types.d.ts.map +1 -1
  38. package/dest/l1_tx_utils/types.js +10 -0
  39. package/dest/queries.d.ts +1 -1
  40. package/dest/queries.d.ts.map +1 -1
  41. package/dest/queries.js +7 -1
  42. package/dest/test/eth_cheat_codes.d.ts +7 -1
  43. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  44. package/dest/test/eth_cheat_codes.js +29 -4
  45. package/dest/test/start_anvil.d.ts +1 -1
  46. package/dest/test/start_anvil.d.ts.map +1 -1
  47. package/dest/test/start_anvil.js +41 -5
  48. package/dest/utils.js +8 -11
  49. package/package.json +5 -6
  50. package/src/config.ts +38 -3
  51. package/src/contracts/governance.ts +63 -20
  52. package/src/contracts/governance_proposer.ts +11 -15
  53. package/src/contracts/gse.ts +12 -0
  54. package/src/contracts/multicall.ts +8 -5
  55. package/src/contracts/rollup.ts +10 -0
  56. package/src/contracts/slashing_proposer.ts +78 -15
  57. package/src/deploy_aztec_l1_contracts.ts +29 -12
  58. package/src/foundry_binary.ts +57 -0
  59. package/src/l1_tx_utils/l1_fee_analyzer.ts +75 -3
  60. package/src/l1_tx_utils/l1_tx_utils.ts +19 -2
  61. package/src/l1_tx_utils/types.ts +32 -0
  62. package/src/queries.ts +6 -0
  63. package/src/test/eth_cheat_codes.ts +23 -2
  64. package/src/test/start_anvil.ts +38 -6
  65. package/src/utils.ts +11 -11
  66. package/dest/generated/l1-contracts-defaults.d.ts +0 -30
  67. package/dest/generated/l1-contracts-defaults.d.ts.map +0 -1
  68. package/dest/generated/l1-contracts-defaults.js +0 -30
  69. package/src/generated/l1-contracts-defaults.ts +0 -32
@@ -4,10 +4,10 @@ import { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import { jsonStringify } from '@aztec/foundation/json-rpc';
5
5
  import { createLogger } from '@aztec/foundation/log';
6
6
  import { promiseWithResolvers } from '@aztec/foundation/promise';
7
- import { fileURLToPath } from '@aztec/foundation/url';
8
7
  import { bn254 } from '@noble/curves/bn254';
9
8
  import { spawn } from 'child_process';
10
9
  import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
10
+ import { createRequire } from 'node:module';
11
11
  import { tmpdir } from 'os';
12
12
  import { dirname, join, resolve } from 'path';
13
13
  import readline from 'readline';
@@ -17,7 +17,9 @@ import { createExtendedL1Client } from './client.js';
17
17
  import { assertValidSlotDurations } from './config.js';
18
18
  import { deployMulticall3 } from './contracts/multicall.js';
19
19
  import { RollupContract } from './contracts/rollup.js';
20
+ import { resolveFoundryBinary } from './foundry_binary.js';
20
21
  const logger = createLogger('ethereum:deploy_aztec_l1_contracts');
22
+ const require = createRequire(import.meta.url);
21
23
  const JSON_DEPLOY_RESULT_PREFIX = 'JSON DEPLOY RESULT:';
22
24
  /**
23
25
  * Runs a process and parses JSON deploy results from stdout.
@@ -82,11 +84,11 @@ const JSON_DEPLOY_RESULT_PREFIX = 'JSON DEPLOY RESULT:';
82
84
  }
83
85
  // Covers an edge where where we may have a cached BlobLib that is not meant for production.
84
86
  // Despite the profile apparently sometimes cached code remains (so says Lasse after his ignition-monorepo arc).
85
- async function maybeForgeForceProductionBuild(l1ContractsPath, script, chainId) {
87
+ async function maybeForgeForceProductionBuild(forgeBin, l1ContractsPath, script, chainId) {
86
88
  if (chainId === mainnet.id) {
87
89
  logger.info(`Recompiling ${script} with production profile for mainnet deployment`);
88
90
  logger.info('This may take a minute but ensures production BlobLib is used.');
89
- await runProcess('forge', [
91
+ await runProcess(forgeBin, [
90
92
  'build',
91
93
  script,
92
94
  '--force'
@@ -96,14 +98,12 @@ async function maybeForgeForceProductionBuild(l1ContractsPath, script, chainId)
96
98
  }
97
99
  }
98
100
  /**
99
- * Gets the path to the l1-contracts foundry artifacts directory.
100
- * These are copied from l1-contracts to yarn-project/l1-artifacts/l1-contracts
101
- * during build to make yarn-project self-contained.
101
+ * Gets the path to the l1-contracts foundry artifacts directory bundled inside @aztec/l1-artifacts.
102
+ * Resolved through the package (its "." export -> dest/index.js) so it works whether the package is
103
+ * linked via portal (monorepo) or installed under node_modules (published npm) — resolution follows
104
+ * the symlink in the portal case. The bundled foundry subtree sits alongside dest/, at <pkg>/l1-contracts.
102
105
  */ export function getL1ContractsPath() {
103
- const currentDir = dirname(fileURLToPath(import.meta.url));
104
- // Go up from yarn-project/ethereum/dest to yarn-project, then to l1-artifacts/l1-contracts
105
- const l1ContractsPath = resolve(currentDir, '..', '..', 'l1-artifacts', 'l1-contracts');
106
- return l1ContractsPath;
106
+ return resolve(dirname(require.resolve('@aztec/l1-artifacts')), '..', 'l1-contracts');
107
107
  }
108
108
  // Cached deployment directory
109
109
  let preparedDeployDir;
@@ -237,8 +237,9 @@ function cleanupDeployDir() {
237
237
  }
238
238
  // Use foundry-artifacts from l1-artifacts package
239
239
  const l1ContractsPath = prepareL1ContractsForDeployment();
240
+ const forgeBin = resolveFoundryBinary('forge');
240
241
  const FORGE_SCRIPT = 'script/deploy/DeployAztecL1Contracts.s.sol';
241
- await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
242
+ await maybeForgeForceProductionBuild(forgeBin, l1ContractsPath, FORGE_SCRIPT, chainId);
242
243
  // Verify contracts on Etherscan when on mainnet/sepolia and ETHERSCAN_API_KEY is available.
243
244
  const isVerifiableChain = chainId === mainnet.id || chainId === sepolia.id;
244
245
  const shouldVerify = isVerifiableChain && !!process.env.ETHERSCAN_API_KEY;
@@ -259,6 +260,8 @@ function cleanupDeployDir() {
259
260
  ] : []
260
261
  ];
261
262
  const forgeEnv = {
263
+ // Resolved forge binary picked up by forge_broadcast.js, so it works without forge on PATH.
264
+ FORGE_BIN: forgeBin,
262
265
  // Env vars required by l1-contracts/script/deploy/DeploymentConfiguration.sol.
263
266
  NETWORK: getActiveNetworkName(),
264
267
  FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
@@ -368,7 +371,12 @@ export function getDeployRollupForUpgradeEnvVars(args) {
368
371
  AZTEC_SLASHING_OFFSET_IN_ROUNDS: args.slashingOffsetInRounds.toString(),
369
372
  AZTEC_SLASH_AMOUNT_SMALL: args.slashAmountSmall.toString(),
370
373
  AZTEC_SLASH_AMOUNT_MEDIUM: args.slashAmountMedium.toString(),
371
- AZTEC_SLASH_AMOUNT_LARGE: args.slashAmountLarge.toString()
374
+ AZTEC_SLASH_AMOUNT_LARGE: args.slashAmountLarge.toString(),
375
+ AZTEC_ENTRY_QUEUE_BOOTSTRAP_VALIDATOR_SET_SIZE: args.entryQueueBootstrapValidatorSetSize.toString(),
376
+ AZTEC_ENTRY_QUEUE_BOOTSTRAP_FLUSH_SIZE: args.entryQueueBootstrapFlushSize.toString(),
377
+ AZTEC_ENTRY_QUEUE_FLUSH_SIZE_MIN: args.entryQueueFlushSizeMin.toString(),
378
+ AZTEC_ENTRY_QUEUE_FLUSH_SIZE_QUOTIENT: args.entryQueueFlushSizeQuotient.toString(),
379
+ AZTEC_ENTRY_QUEUE_MAX_FLUSH_SIZE: args.entryQueueMaxFlushSize.toString()
372
380
  };
373
381
  }
374
382
  /**
@@ -376,8 +384,9 @@ export function getDeployRollupForUpgradeEnvVars(args) {
376
384
  */ export const deployRollupForUpgrade = async (privateKey, rpcUrl, chainId, registryAddress, args)=>{
377
385
  // Use foundry-artifacts from l1-artifacts package
378
386
  const l1ContractsPath = prepareL1ContractsForDeployment();
387
+ const forgeBin = resolveFoundryBinary('forge');
379
388
  const FORGE_SCRIPT = 'script/deploy/DeployRollupForUpgrade.s.sol';
380
- await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
389
+ await maybeForgeForceProductionBuild(forgeBin, l1ContractsPath, FORGE_SCRIPT, chainId);
381
390
  const scriptPath = join(getL1ContractsPath(), 'scripts', 'forge_broadcast.js');
382
391
  const forgeArgs = [
383
392
  FORGE_SCRIPT,
@@ -389,6 +398,8 @@ export function getDeployRollupForUpgradeEnvVars(args) {
389
398
  rpcUrl
390
399
  ];
391
400
  const forgeEnv = {
401
+ // Resolved forge binary picked up by forge_broadcast.js, so it works without forge on PATH.
402
+ FORGE_BIN: forgeBin,
392
403
  FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
393
404
  // Env vars required by l1-contracts/script/deploy/RollupConfiguration.sol.
394
405
  REGISTRY_ADDRESS: registryAddress.toString(),
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Locate a Foundry binary (`anvil`, `forge`, ...) without relying on the caller's PATH. Order:
3
+ * 1. `$<NAME>_BIN` (e.g. `$ANVIL_BIN`, `$FORGE_BIN`) — explicit override, e.g. for CI with a pinned
4
+ * version. Throws if set but not pointing at an executable, instead of silently falling back.
5
+ * 2. `~/.aztec/current/internal-bin/<name>` — where aztec-up installs it.
6
+ * 3. `~/.aztec/current/bin/aztec-<name>` — the publicly-exposed symlink.
7
+ * 4. `~/.foundry/bin/<name>` — standalone foundryup install.
8
+ * 5. `command -v <name>` — anything else on PATH.
9
+ *
10
+ * Throws with a directive message if none work.
11
+ */
12
+ export declare function resolveFoundryBinary(name: string): string;
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm91bmRyeV9iaW5hcnkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9mb3VuZHJ5X2JpbmFyeS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFjQTs7Ozs7Ozs7OztHQVVHO0FBQ0gsd0JBQWdCLG9CQUFvQixDQUFDLElBQUksRUFBRSxNQUFNLEdBQUcsTUFBTSxDQStCekQifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundry_binary.d.ts","sourceRoot":"","sources":["../src/foundry_binary.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA+BzD"}
@@ -0,0 +1,52 @@
1
+ import { spawnSync } from 'child_process';
2
+ import { accessSync, constants } from 'fs';
3
+ import { homedir } from 'os';
4
+ import { join } from 'path';
5
+ function isExecutable(path) {
6
+ try {
7
+ accessSync(path, constants.X_OK);
8
+ return true;
9
+ } catch {
10
+ return false;
11
+ }
12
+ }
13
+ /**
14
+ * Locate a Foundry binary (`anvil`, `forge`, ...) without relying on the caller's PATH. Order:
15
+ * 1. `$<NAME>_BIN` (e.g. `$ANVIL_BIN`, `$FORGE_BIN`) — explicit override, e.g. for CI with a pinned
16
+ * version. Throws if set but not pointing at an executable, instead of silently falling back.
17
+ * 2. `~/.aztec/current/internal-bin/<name>` — where aztec-up installs it.
18
+ * 3. `~/.aztec/current/bin/aztec-<name>` — the publicly-exposed symlink.
19
+ * 4. `~/.foundry/bin/<name>` — standalone foundryup install.
20
+ * 5. `command -v <name>` — anything else on PATH.
21
+ *
22
+ * Throws with a directive message if none work.
23
+ */ export function resolveFoundryBinary(name) {
24
+ const envVar = `${name.toUpperCase()}_BIN`;
25
+ const envBin = process.env[envVar];
26
+ if (envBin) {
27
+ if (!isExecutable(envBin)) {
28
+ throw new Error(`$${envVar} is set to ${envBin}, which does not exist or is not executable.`);
29
+ }
30
+ return envBin;
31
+ }
32
+ const candidates = [
33
+ join(homedir(), '.aztec', 'current', 'internal-bin', name),
34
+ join(homedir(), '.aztec', 'current', 'bin', `aztec-${name}`),
35
+ join(homedir(), '.foundry', 'bin', name)
36
+ ];
37
+ for (const path of candidates){
38
+ if (isExecutable(path)) {
39
+ return path;
40
+ }
41
+ }
42
+ const which = spawnSync('sh', [
43
+ '-c',
44
+ `command -v ${name}`
45
+ ], {
46
+ encoding: 'utf8'
47
+ });
48
+ if (which.status === 0 && which.stdout.trim()) {
49
+ return which.stdout.trim();
50
+ }
51
+ throw new Error(`${name} binary not found. Tried $${envVar}, ~/.aztec/current/internal-bin/${name}, ` + `~/.aztec/current/bin/aztec-${name}, ~/.foundry/bin/${name}, and $PATH. ` + `Install via \`aztec-up\` or set ${envVar} to a working binary.`);
52
+ }