@aztec/aztec-node 6.0.0-nightly.20260605 → 6.0.0-nightly.20260722

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 (52) hide show
  1. package/dest/aztec-node/config.d.ts +10 -1
  2. package/dest/aztec-node/config.d.ts.map +1 -1
  3. package/dest/aztec-node/config.js +10 -0
  4. package/dest/aztec-node/node_public_calls_simulator.d.ts +97 -0
  5. package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
  6. package/dest/aztec-node/node_public_calls_simulator.js +351 -0
  7. package/dest/aztec-node/register_node_rpc_handlers.d.ts +10 -0
  8. package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
  9. package/dest/aztec-node/register_node_rpc_handlers.js +31 -0
  10. package/dest/aztec-node/server.d.ts +92 -64
  11. package/dest/aztec-node/server.d.ts.map +1 -1
  12. package/dest/aztec-node/server.js +229 -1131
  13. package/dest/bin/index.js +15 -10
  14. package/dest/factory.d.ts +33 -0
  15. package/dest/factory.d.ts.map +1 -0
  16. package/dest/factory.js +523 -0
  17. package/dest/index.d.ts +3 -1
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +2 -0
  20. package/dest/modules/block_parameter.d.ts +25 -0
  21. package/dest/modules/block_parameter.d.ts.map +1 -0
  22. package/dest/modules/block_parameter.js +100 -0
  23. package/dest/modules/node_block_provider.d.ts +19 -0
  24. package/dest/modules/node_block_provider.d.ts.map +1 -0
  25. package/dest/modules/node_block_provider.js +112 -0
  26. package/dest/modules/node_tx_receipt.d.ts +24 -0
  27. package/dest/modules/node_tx_receipt.d.ts.map +1 -0
  28. package/dest/modules/node_tx_receipt.js +70 -0
  29. package/dest/modules/node_world_state_queries.d.ts +65 -0
  30. package/dest/modules/node_world_state_queries.d.ts.map +1 -0
  31. package/dest/modules/node_world_state_queries.js +272 -0
  32. package/dest/sentinel/factory.d.ts +3 -3
  33. package/dest/sentinel/factory.d.ts.map +1 -1
  34. package/dest/sentinel/factory.js +8 -1
  35. package/dest/sentinel/sentinel.d.ts +21 -21
  36. package/dest/sentinel/sentinel.d.ts.map +1 -1
  37. package/dest/sentinel/sentinel.js +27 -47
  38. package/package.json +28 -27
  39. package/src/aztec-node/config.ts +19 -0
  40. package/src/aztec-node/node_public_calls_simulator.ts +394 -0
  41. package/src/aztec-node/register_node_rpc_handlers.ts +29 -0
  42. package/src/aztec-node/server.ts +319 -1315
  43. package/src/bin/index.ts +19 -12
  44. package/src/factory.ts +688 -0
  45. package/src/index.ts +2 -0
  46. package/src/modules/block_parameter.ts +93 -0
  47. package/src/modules/node_block_provider.ts +149 -0
  48. package/src/modules/node_tx_receipt.ts +115 -0
  49. package/src/modules/node_world_state_queries.ts +374 -0
  50. package/src/sentinel/README.md +3 -3
  51. package/src/sentinel/factory.ts +15 -3
  52. package/src/sentinel/sentinel.ts +34 -72
@@ -26,12 +26,21 @@ export type AztecNodeConfig = ArchiverConfig & SequencerClientConfig & Validator
26
26
  debugForceTxProofVerification: boolean;
27
27
  /** Whether to enable the prover node as a subsystem. */
28
28
  enableProverNode: boolean;
29
+ /** Whether to run the slashing watchers to collect offenses even if not a validator. */
30
+ enableOffenseCollection: boolean;
29
31
  /**
30
32
  * Test-only: use the deterministic AutomineSequencer instead of the production Sequencer.
31
33
  * Requires `aztecTargetCommitteeSize === 0` on the deployed rollup and anvil-backed L1.
32
34
  * See `AUTOMINE_E2E_OPTS` in `end-to-end/src/fixtures/fixtures.ts`.
33
35
  */
34
36
  useAutomineSequencer?: boolean;
37
+ /**
38
+ * Test-only: have the AutomineSequencer automatically prove epochs (write epoch out hashes into
39
+ * the L1 Outbox and advance the proven tip) as checkpoints land, replacing the standalone
40
+ * `EpochTestSettler`. Set by the local network/sandbox; the e2e `AUTOMINE_E2E_OPTS` fixture leaves
41
+ * it off so tests drive proving manually via `prove` / `cheatCodes.rollup.markAsProven`.
42
+ */
43
+ automineEnableProveEpoch?: boolean;
35
44
  };
36
45
  export declare const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig>;
37
46
  /**
@@ -40,4 +49,4 @@ export declare const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig
40
49
  */
41
50
  export declare function getConfigEnvVars(): AztecNodeConfig;
42
51
  export declare function createKeyStoreForValidator(config: SequencerTxSenderConfig & SequencerClientConfig & SharedNodeConfig): KeyStore | undefined;
43
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXp0ZWMtbm9kZS9jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssY0FBYyxFQUEwQixNQUFNLHdCQUF3QixDQUFDO0FBQ3JGLE9BQU8sRUFBRSxLQUFLLGtCQUFrQixFQUE4QixNQUFNLHdCQUF3QixDQUFDO0FBQzdGLE9BQU8sRUFBRSxLQUFLLGtCQUFrQixFQUE4QyxNQUFNLDBCQUEwQixDQUFDO0FBRS9HLE9BQU8sRUFDTCxLQUFLLFFBQVEsRUFJZCxNQUFNLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUE0QixNQUFNLHdCQUF3QixDQUFDO0FBQ3pGLE9BQU8sRUFBRSxLQUFLLFNBQVMsRUFBcUIsTUFBTSxtQkFBbUIsQ0FBQztBQUN0RSxPQUFPLEVBQUUsS0FBSyxzQkFBc0IsRUFBOEIsTUFBTSw2QkFBNkIsQ0FBQztBQUN0RyxPQUFPLEVBQ0wsS0FBSyxnQkFBZ0IsRUFHdEIsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEVBQ0wsS0FBSyxxQkFBcUIsRUFDMUIsS0FBSyx1QkFBdUIsRUFDNUIsNkJBQTZCLEVBQzlCLE1BQU0sZ0NBQWdDLENBQUM7QUFHeEMsT0FBTyxFQUF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AAC,GAClF,SAAS,GACT,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,kBAAkB,GAClB,aAAa,GACb,aAAa,GACb,gBAAgB,GAAG;IACjB,sDAAsD;IACtD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iGAAiG;IACjG,uBAAuB,EAAE,OAAO,CAAC;IACjC,6EAA6E;IAC7E,6BAA6B,EAAE,OAAO,CAAC;IACvC,wDAAwD;IACxD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,wFAAwF;IACxF,uBAAuB,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAEJ,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,CAAC,eAAe,CAmDvE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,eAAe,CAElD;AAsED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,uBAAuB,GAAG,qBAAqB,GAAG,gBAAgB,GACzE,QAAQ,GAAG,SAAS,CAMtB"}
@@ -53,10 +53,20 @@ export const aztecNodeConfigMappings = {
53
53
  description: 'Whether to enable the prover node as a subsystem.',
54
54
  ...booleanConfigHelper(false)
55
55
  },
56
+ enableOffenseCollection: {
57
+ env: 'OFFENSE_COLLECTION_ENABLED',
58
+ description: 'Whether to run the slashing watchers to collect offenses even if not a validator.',
59
+ ...booleanConfigHelper(false)
60
+ },
56
61
  useAutomineSequencer: {
57
62
  env: 'USE_AUTOMINE_SEQUENCER',
58
63
  description: 'Test-only: use AutomineSequencer instead of the production Sequencer.',
59
64
  ...booleanConfigHelper(false)
65
+ },
66
+ automineEnableProveEpoch: {
67
+ env: 'AUTOMINE_ENABLE_PROVE_EPOCH',
68
+ description: 'Test-only: have the AutomineSequencer automatically prove epochs as checkpoints land.',
69
+ ...booleanConfigHelper(false)
60
70
  }
61
71
  };
62
72
  /**
@@ -0,0 +1,97 @@
1
+ import type { EpochCacheInterface } from '@aztec/epoch-cache';
2
+ import { type RollupContract } from '@aztec/ethereum/contracts';
3
+ import { type Logger } from '@aztec/foundation/log';
4
+ import { type AvmSimulator } from '@aztec/simulator/server';
5
+ import type { L2BlockSource } from '@aztec/stdlib/block';
6
+ import type { ContractDataSource } from '@aztec/stdlib/contract';
7
+ import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
8
+ import { type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
9
+ import type { CoordinationSignatureContext } from '@aztec/stdlib/p2p';
10
+ import { type GlobalVariableBuilder, PublicSimulationOutput, type SimulationOverrides, type Tx } from '@aztec/stdlib/tx';
11
+ import { type TelemetryClient } from '@aztec/telemetry-client';
12
+ /** Config fields the simulator needs — a narrow subset of `AztecNodeConfig`. */
13
+ export interface NodePublicCallsSimulatorConfig {
14
+ /** Maximum total gas limit accepted for an incoming simulation. */
15
+ rpcSimulatePublicMaxGasLimit: number;
16
+ /** Maximum number of debug-log memory reads collected during simulation. */
17
+ rpcSimulatePublicMaxDebugLogMemoryReads: number;
18
+ }
19
+ /** Dependencies required to build a {@link NodePublicCallsSimulator}. */
20
+ export interface NodePublicCallsSimulatorDeps {
21
+ blockSource: L2BlockSource;
22
+ worldStateSynchronizer: WorldStateSynchronizer;
23
+ l1ToL2MessageSource: L1ToL2MessageSource;
24
+ contractDataSource: ContractDataSource;
25
+ globalVariableBuilder: GlobalVariableBuilder;
26
+ /**
27
+ * Rollup contract used to build the fee-relevant L1 state overrides when opening a new checkpoint.
28
+ * Only needed when a proposed parent checkpoint exists (pipelining) or the pending chain is invalid;
29
+ * may be omitted in environments that never reach those states (e.g. TXE). When omitted, those paths
30
+ * degrade to a pinned-tips plan (non-pipelined fees) instead.
31
+ */
32
+ rollupContract?: RollupContract;
33
+ epochCache: EpochCacheInterface;
34
+ signatureContext: CoordinationSignatureContext;
35
+ config: NodePublicCallsSimulatorConfig;
36
+ /**
37
+ * AVM execution backend the public processor drives to run public calls. Optional because unit/TXE nodes
38
+ * that never call {@link simulate} are constructed without one; asserted at the simulation call site.
39
+ */
40
+ avmSimulator?: AvmSimulator;
41
+ telemetry?: TelemetryClient;
42
+ log?: Logger;
43
+ }
44
+ /**
45
+ * Simulates the public part of a transaction against a fresh world-state fork.
46
+ *
47
+ * Extracted from `AztecNodeService` so the slot/globals selection can be unit-tested without
48
+ * standing up the whole node, and to keep `server.ts` smaller.
49
+ *
50
+ * The simulator picks globals in one of two ways, mirroring how the sequencer builds the next block:
51
+ * - **When the next block continues an in-progress checkpoint** (the latest proposed block is ahead of
52
+ * the proposed-checkpoint frontier): every block in a checkpoint shares the same
53
+ * `CheckpointGlobalVariables`, so we copy the latest proposed block's globals verbatim and only
54
+ * bump the block number. No L1 calls, no L1-to-L2 message insertion.
55
+ * - **When the next block opens a new checkpoint** (the latest proposed block coincides with the
56
+ * proposed-checkpoint frontier): we compute fresh globals for the slot the next block will land in,
57
+ * applying the same `SimulationOverridesPlan` the sequencer applies so the simulated mana min fee
58
+ * matches what the sequencer will write into the block header.
59
+ */
60
+ export declare class NodePublicCallsSimulator {
61
+ private readonly blockSource;
62
+ private readonly worldStateSynchronizer;
63
+ private readonly l1ToL2MessageSource;
64
+ private readonly contractDataSource;
65
+ private readonly globalVariableBuilder;
66
+ private readonly rollupContract;
67
+ private readonly epochCache;
68
+ private readonly signatureContext;
69
+ private readonly config;
70
+ private readonly avmSimulator?;
71
+ private readonly telemetry;
72
+ private readonly log;
73
+ constructor(deps: NodePublicCallsSimulatorDeps);
74
+ /**
75
+ * Simulates the public part of a transaction with the current state.
76
+ * @param tx - The transaction to simulate.
77
+ * @param skipFeeEnforcement - If true, fee enforcement is skipped.
78
+ * @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
79
+ */
80
+ simulate(tx: Tx, skipFeeEnforcement?: boolean, overrides?: SimulationOverrides): Promise<PublicSimulationOutput>;
81
+ private getNextCheckpointMessages;
82
+ private copyGlobalVariablesFromLatestProposedBlock;
83
+ private buildGlobalVariablesForNewCheckpoint;
84
+ /**
85
+ * Slot the next block will land in. The first term is the sequencer's exact formula
86
+ * (`getEpochAndSlotInNextL1Slot().slot + PROPOSER_PIPELINING_SLOT_OFFSET`). The `max` with
87
+ * `proposedCheckpointSlot + 1` is an RPC-side approximation of the next build: when a proposed
88
+ * checkpoint is gossiped before its L1 slot starts, the next build (once its wall clock arrives)
89
+ * will target `parentSlot + 1`. The sequencer never advances its own target past wall clock — it
90
+ * just declines to build — so this is a prediction of inclusion globals, not literal sequencer
91
+ * behavior. The parent slot comes from the proposed checkpoint header so the slot and the
92
+ * overrides plan cannot derive from different snapshots.
93
+ */
94
+ private computeTargetSlot;
95
+ private buildSimulationOverridesPlan;
96
+ }
97
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9kZV9wdWJsaWNfY2FsbHNfc2ltdWxhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXp0ZWMtbm9kZS9ub2RlX3B1YmxpY19jYWxsc19zaW11bGF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUM5RCxPQUFPLEVBQ0wsS0FBSyxjQUFjLEVBR3BCLE1BQU0sMkJBQTJCLENBQUM7QUFNbkMsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBR2xFLE9BQU8sRUFBRSxLQUFLLFlBQVksRUFBNkMsTUFBTSx5QkFBeUIsQ0FBQztBQUd2RyxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQVUsTUFBTSxxQkFBcUIsQ0FBQztBQUVqRSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ2pFLE9BQU8sS0FBSyx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== null && value !== void 0) {
3
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
+ var dispose, inner;
5
+ if (async) {
6
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
+ dispose = value[Symbol.asyncDispose];
8
+ }
9
+ if (dispose === void 0) {
10
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
+ dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() {
16
+ try {
17
+ inner.call(this);
18
+ } catch (e) {
19
+ return Promise.reject(e);
20
+ }
21
+ };
22
+ env.stack.push({
23
+ value: value,
24
+ dispose: dispose,
25
+ async: async
26
+ });
27
+ } else if (async) {
28
+ env.stack.push({
29
+ async: true
30
+ });
31
+ }
32
+ return value;
33
+ }
34
+ function _ts_dispose_resources(env) {
35
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
36
+ var e = new Error(message);
37
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
38
+ };
39
+ return (_ts_dispose_resources = function _ts_dispose_resources(env) {
40
+ function fail(e) {
41
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
42
+ env.hasError = true;
43
+ }
44
+ var r, s = 0;
45
+ function next() {
46
+ while(r = env.stack.pop()){
47
+ try {
48
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
49
+ if (r.dispose) {
50
+ var result = r.dispose.call(r.value);
51
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
52
+ fail(e);
53
+ return next();
54
+ });
55
+ } else s |= 1;
56
+ } catch (e) {
57
+ fail(e);
58
+ }
59
+ }
60
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
61
+ if (env.hasError) throw env.error;
62
+ }
63
+ return next();
64
+ })(env);
65
+ }
66
+ import { L1ToL2MessagesNotReadyError } from '@aztec/archiver';
67
+ import { PROPOSER_PIPELINING_SLOT_OFFSET } from '@aztec/epoch-cache';
68
+ import { SimulationOverridesBuilder } from '@aztec/ethereum/contracts';
69
+ import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
70
+ import { compactArray } from '@aztec/foundation/collection';
71
+ import { EthAddress } from '@aztec/foundation/eth-address';
72
+ import { BadRequestError } from '@aztec/foundation/json-rpc';
73
+ import { createLogger } from '@aztec/foundation/log';
74
+ import { DateProvider } from '@aztec/foundation/timer';
75
+ import { isErrorClass } from '@aztec/foundation/types';
76
+ import { PublicContractsDB, PublicProcessorFactory } from '@aztec/simulator/server';
77
+ import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
78
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
79
+ import { buildCheckpointSimulationOverridesPlan } from '@aztec/stdlib/checkpoint';
80
+ import { appendL1ToL2MessagesToTree } from '@aztec/stdlib/messaging';
81
+ import { GlobalVariables, PublicSimulationOutput } from '@aztec/stdlib/tx';
82
+ import { getTelemetryClient } from '@aztec/telemetry-client';
83
+ import { applyPublicDataOverrides } from './public_data_overrides.js';
84
+ /**
85
+ * Simulates the public part of a transaction against a fresh world-state fork.
86
+ *
87
+ * Extracted from `AztecNodeService` so the slot/globals selection can be unit-tested without
88
+ * standing up the whole node, and to keep `server.ts` smaller.
89
+ *
90
+ * The simulator picks globals in one of two ways, mirroring how the sequencer builds the next block:
91
+ * - **When the next block continues an in-progress checkpoint** (the latest proposed block is ahead of
92
+ * the proposed-checkpoint frontier): every block in a checkpoint shares the same
93
+ * `CheckpointGlobalVariables`, so we copy the latest proposed block's globals verbatim and only
94
+ * bump the block number. No L1 calls, no L1-to-L2 message insertion.
95
+ * - **When the next block opens a new checkpoint** (the latest proposed block coincides with the
96
+ * proposed-checkpoint frontier): we compute fresh globals for the slot the next block will land in,
97
+ * applying the same `SimulationOverridesPlan` the sequencer applies so the simulated mana min fee
98
+ * matches what the sequencer will write into the block header.
99
+ */ export class NodePublicCallsSimulator {
100
+ blockSource;
101
+ worldStateSynchronizer;
102
+ l1ToL2MessageSource;
103
+ contractDataSource;
104
+ globalVariableBuilder;
105
+ rollupContract;
106
+ epochCache;
107
+ signatureContext;
108
+ config;
109
+ avmSimulator;
110
+ telemetry;
111
+ log;
112
+ constructor(deps){
113
+ this.blockSource = deps.blockSource;
114
+ this.worldStateSynchronizer = deps.worldStateSynchronizer;
115
+ this.l1ToL2MessageSource = deps.l1ToL2MessageSource;
116
+ this.contractDataSource = deps.contractDataSource;
117
+ this.globalVariableBuilder = deps.globalVariableBuilder;
118
+ this.rollupContract = deps.rollupContract;
119
+ this.epochCache = deps.epochCache;
120
+ this.signatureContext = deps.signatureContext;
121
+ this.config = deps.config;
122
+ this.avmSimulator = deps.avmSimulator;
123
+ this.telemetry = deps.telemetry ?? getTelemetryClient();
124
+ this.log = deps.log ?? createLogger('node:public-calls-simulator');
125
+ }
126
+ /**
127
+ * Simulates the public part of a transaction with the current state.
128
+ * @param tx - The transaction to simulate.
129
+ * @param skipFeeEnforcement - If true, fee enforcement is skipped.
130
+ * @param overrides - Optional pre-simulation overrides applied to the ephemeral fork and contract DB.
131
+ */ async simulate(tx, skipFeeEnforcement = false, overrides) {
132
+ const env = {
133
+ stack: [],
134
+ error: void 0,
135
+ hasError: false
136
+ };
137
+ try {
138
+ // Check total gas limit for simulation
139
+ const gasSettings = tx.data.constants.txContext.gasSettings;
140
+ const txGasLimit = gasSettings.gasLimits.l2Gas;
141
+ const teardownGasLimit = gasSettings.teardownGasLimits.l2Gas;
142
+ if (txGasLimit + teardownGasLimit > this.config.rpcSimulatePublicMaxGasLimit) {
143
+ throw new BadRequestError(`Transaction total gas limit ${txGasLimit + teardownGasLimit} (${txGasLimit} + ${teardownGasLimit}) exceeds maximum gas limit ${this.config.rpcSimulatePublicMaxGasLimit} for simulation`);
144
+ }
145
+ const txHash = tx.getTxHash();
146
+ const [l2Tips, proposedCheckpointData] = await Promise.all([
147
+ this.blockSource.getL2Tips(),
148
+ this.blockSource.getProposedCheckpointData()
149
+ ]);
150
+ const latestBlockNumber = l2Tips.proposed.number;
151
+ const blockNumber = BlockNumber.add(latestBlockNumber, 1);
152
+ // Terminating block of the proposed-checkpoint frontier. `getProposedCheckpointData()` returns the
153
+ // leading proposed (not-yet-L1-confirmed) checkpoint, whose last block is `startBlock + blockCount
154
+ // - 1`; with no proposed checkpoint the frontier coincides with the checkpointed tip.
155
+ const proposedCheckpointLastBlock = proposedCheckpointData ? BlockNumber.add(proposedCheckpointData.startBlock, proposedCheckpointData.blockCount - 1) : l2Tips.checkpointed.block.number;
156
+ // The next block continues the in-progress checkpoint when the latest proposed block is ahead of
157
+ // the proposed-checkpoint terminating block; it opens a new checkpoint when they coincide.
158
+ const atCheckpointBoundary = proposedCheckpointLastBlock === l2Tips.proposed.number;
159
+ // `targetCheckpoint` is the checkpoint whose L1-to-L2 messages must be inserted into the fork
160
+ // before simulation. Only set when opening a new checkpoint, where the next block is its first block.
161
+ const { globalVariables: newGlobalVariables, targetCheckpoint } = atCheckpointBoundary ? await this.buildGlobalVariablesForNewCheckpoint(l2Tips, proposedCheckpointData, blockNumber) : {
162
+ globalVariables: await this.copyGlobalVariablesFromLatestProposedBlock(latestBlockNumber, blockNumber)
163
+ };
164
+ if (!this.avmSimulator) {
165
+ throw new Error('NodePublicCallsSimulator.simulate requires an AVM simulator, but none was configured');
166
+ }
167
+ const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, this.avmSimulator, new DateProvider(), this.telemetry, this.log.getBindings());
168
+ this.log.verbose(`Simulating public calls for tx ${txHash}`, {
169
+ globalVariables: newGlobalVariables.toInspect(),
170
+ txHash,
171
+ blockNumber,
172
+ atCheckpointBoundary
173
+ });
174
+ // Ensure world-state has caught up with the latest block we loaded from the archiver
175
+ await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
176
+ const nextCheckpointMessages = await this.getNextCheckpointMessages(targetCheckpoint);
177
+ const merkleTreeFork = _ts_add_disposable_resource(env, await this.worldStateSynchronizer.fork(latestBlockNumber), true);
178
+ if (nextCheckpointMessages !== undefined) {
179
+ this.log.debug(`Appending ${nextCheckpointMessages.length} L1-to-L2 messages to the world state tree for the next checkpoint`, {
180
+ checkpointNumber: targetCheckpoint
181
+ });
182
+ await appendL1ToL2MessagesToTree(merkleTreeFork, nextCheckpointMessages);
183
+ }
184
+ await applyPublicDataOverrides(merkleTreeFork, overrides?.publicStorage);
185
+ const config = PublicSimulatorConfig.from({
186
+ skipFeeEnforcement,
187
+ collectDebugLogs: true,
188
+ collectHints: false,
189
+ collectCallMetadata: true,
190
+ collectStatistics: false,
191
+ collectionLimits: CollectionLimitsConfig.from({
192
+ maxDebugLogMemoryReads: this.config.rpcSimulatePublicMaxDebugLogMemoryReads
193
+ })
194
+ });
195
+ const contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
196
+ if (overrides?.contracts) {
197
+ contractsDB.addContracts(Object.values(overrides.contracts).map(({ instance })=>instance));
198
+ }
199
+ const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config, contractsDB);
200
+ // REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
201
+ const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([
202
+ tx
203
+ ]);
204
+ // REFACTOR: Consider returning the error rather than throwing
205
+ if (failedTxs.length) {
206
+ this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, {
207
+ txHash
208
+ });
209
+ throw failedTxs[0].error;
210
+ }
211
+ const [processedTx] = processedTxs;
212
+ return new PublicSimulationOutput(processedTx.revertReason, processedTx.globalVariables, processedTx.txEffect, returns, processedTx.gasUsed, debugLogs);
213
+ } catch (e) {
214
+ env.error = e;
215
+ env.hasError = true;
216
+ } finally{
217
+ const result = _ts_dispose_resources(env);
218
+ if (result) await result;
219
+ }
220
+ }
221
+ /**
222
+ * Fetches the next checkpoint's L1-to-L2 messages to insert into the fork before simulation. Only set
223
+ * when opening a new checkpoint; when continuing an in-progress checkpoint the ongoing checkpoint's
224
+ * messages were already applied when its first block synced, so inserting here would double-count them
225
+ * — which is why a missing header for the latest proposed block throws rather than falling through to
226
+ * this path. A not-ready or failed fetch degrades to simulating without the messages rather than
227
+ * failing the request.
228
+ */ async getNextCheckpointMessages(targetCheckpoint) {
229
+ if (targetCheckpoint === undefined) {
230
+ return undefined;
231
+ }
232
+ try {
233
+ return await this.l1ToL2MessageSource.getL1ToL2Messages(targetCheckpoint);
234
+ } catch (err) {
235
+ if (isErrorClass(err, L1ToL2MessagesNotReadyError)) {
236
+ this.log.warn(`L1-to-L2 messages for checkpoint ${targetCheckpoint} are not ready yet (simulating without them)`, {
237
+ checkpointNumber: targetCheckpoint
238
+ });
239
+ } else {
240
+ this.log.error(`Failed to get L1-to-L2 messages for checkpoint ${targetCheckpoint} (simulating without them)`, err, {
241
+ checkpointNumber: targetCheckpoint
242
+ });
243
+ }
244
+ return undefined;
245
+ }
246
+ }
247
+ /**
248
+ * Continues an in-progress checkpoint: the next block extends the checkpoint the latest proposed
249
+ * block belongs to. Every block in a checkpoint shares the same `CheckpointGlobalVariables`, so the
250
+ * next block's globals are the latest proposed block's globals with only the block number bumped —
251
+ * including the proposer's real coinbase/feeRecipient. No L1 reads and no L1-to-L2 message insertion
252
+ * happen here.
253
+ *
254
+ * A missing header means the archiver reported a proposed tip via `getL2Tips` but no longer has its
255
+ * data (a torn snapshot). We throw a transient/retryable error rather than treating the next block as
256
+ * opening a new checkpoint: the fork at `latestBlockNumber` already contains the ongoing checkpoint's
257
+ * L1-to-L2 messages, so inserting the next checkpoint's messages would append them a second time.
258
+ */ async copyGlobalVariablesFromLatestProposedBlock(latestBlockNumber, blockNumber) {
259
+ const latestBlockData = await this.blockSource.getBlockData({
260
+ number: latestBlockNumber
261
+ });
262
+ if (!latestBlockData) {
263
+ throw new Error(`Cannot simulate public calls: latest proposed block ${latestBlockNumber} has no header on this node ` + `(torn archiver snapshot); retry`);
264
+ }
265
+ return GlobalVariables.from({
266
+ ...latestBlockData.header.globalVariables,
267
+ blockNumber
268
+ });
269
+ }
270
+ /**
271
+ * Opens a new checkpoint: the next block is the first of a fresh checkpoint. Picks the slot the next
272
+ * block will land in, mirroring the sequencer, and builds the same `SimulationOverridesPlan` the
273
+ * sequencer applies so the simulated mana min fee matches what the sequencer will write into the
274
+ * block header. Coinbase and fee recipient stay zero (we cannot know the future proposer's payout
275
+ * addresses), unlike continuing an in-progress checkpoint which inherits the real ones from the
276
+ * proposed header. Returns the target checkpoint so the caller inserts that checkpoint's L1-to-L2
277
+ * messages into the fork.
278
+ */ async buildGlobalVariablesForNewCheckpoint(l2Tips, proposedCheckpointData, blockNumber) {
279
+ const checkpointedCheckpointNumber = l2Tips.checkpointed.checkpoint.number;
280
+ // The new checkpoint sits on top of the proposed one when pipelining, otherwise on the
281
+ // checkpointed tip. The target slot and the overrides plan both derive from the single
282
+ // `proposedCheckpointData` read, so they cannot disagree about the proposed parent.
283
+ const proposedCheckpointNumber = proposedCheckpointData?.checkpointNumber ?? checkpointedCheckpointNumber;
284
+ const targetSlot = this.computeTargetSlot(proposedCheckpointData);
285
+ const plan = await this.buildSimulationOverridesPlan(proposedCheckpointData, checkpointedCheckpointNumber);
286
+ const checkpointGlobalVariables = await this.globalVariableBuilder.buildCheckpointGlobalVariables(EthAddress.ZERO, AztecAddress.ZERO, targetSlot, plan);
287
+ return {
288
+ globalVariables: GlobalVariables.from({
289
+ blockNumber,
290
+ ...checkpointGlobalVariables
291
+ }),
292
+ targetCheckpoint: CheckpointNumber(proposedCheckpointNumber + 1)
293
+ };
294
+ }
295
+ /**
296
+ * Slot the next block will land in. The first term is the sequencer's exact formula
297
+ * (`getEpochAndSlotInNextL1Slot().slot + PROPOSER_PIPELINING_SLOT_OFFSET`). The `max` with
298
+ * `proposedCheckpointSlot + 1` is an RPC-side approximation of the next build: when a proposed
299
+ * checkpoint is gossiped before its L1 slot starts, the next build (once its wall clock arrives)
300
+ * will target `parentSlot + 1`. The sequencer never advances its own target past wall clock — it
301
+ * just declines to build — so this is a prediction of inclusion globals, not literal sequencer
302
+ * behavior. The parent slot comes from the proposed checkpoint header so the slot and the
303
+ * overrides plan cannot derive from different snapshots.
304
+ */ computeTargetSlot(proposedCheckpointData) {
305
+ const slotFromNextL1Timestamp = this.epochCache.getEpochAndSlotInNextL1Slot().slot + PROPOSER_PIPELINING_SLOT_OFFSET;
306
+ const slotAfterProposedCheckpoint = proposedCheckpointData ? proposedCheckpointData.header.slotNumber + 1 : undefined;
307
+ return SlotNumber(Math.max(...compactArray([
308
+ slotFromNextL1Timestamp,
309
+ slotAfterProposedCheckpoint
310
+ ])));
311
+ }
312
+ /**
313
+ * Builds the chain-state overrides plan the simulator passes to `buildCheckpointGlobalVariables`,
314
+ * mirroring the sequencer (which always pins tips to neutralize prunes). When pipelining, the plan
315
+ * carries the proposed parent's archive, temp-checkpoint-log cell, and locally-derived fee header.
316
+ *
317
+ * Both the pipelining and invalid-pending-chain paths need a rollup contract for the L1 fee reads.
318
+ * Environments that omit it (e.g. TXE, which never has a proposed checkpoint and whose pending chain
319
+ * is always valid) fall back to pinning both pending and proven tips to the checkpointed tip, which
320
+ * neutralizes prunes in fee computation at the cost of non-pipelined fees.
321
+ */ async buildSimulationOverridesPlan(proposedCheckpointData, checkpointedCheckpointNumber) {
322
+ const rollup = this.rollupContract;
323
+ if (rollup) {
324
+ if (proposedCheckpointData) {
325
+ return buildCheckpointSimulationOverridesPlan({
326
+ checkpointNumber: CheckpointNumber(proposedCheckpointData.checkpointNumber + 1),
327
+ proposedCheckpointData,
328
+ checkpointedCheckpointNumber,
329
+ rollup,
330
+ signatureContext: this.signatureContext,
331
+ log: this.log
332
+ });
333
+ }
334
+ const validationStatus = await this.blockSource.getPendingChainValidationStatus();
335
+ if (!validationStatus.valid) {
336
+ return buildCheckpointSimulationOverridesPlan({
337
+ checkpointNumber: CheckpointNumber(checkpointedCheckpointNumber + 1),
338
+ invalidateToPendingCheckpointNumber: CheckpointNumber(validationStatus.checkpoint.checkpointNumber - 1),
339
+ checkpointedCheckpointNumber,
340
+ rollup,
341
+ signatureContext: this.signatureContext,
342
+ log: this.log
343
+ });
344
+ }
345
+ }
346
+ return new SimulationOverridesBuilder().withChainTips({
347
+ pending: checkpointedCheckpointNumber,
348
+ proven: checkpointedCheckpointNumber
349
+ }).build();
350
+ }
351
+ }
@@ -0,0 +1,10 @@
1
+ import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
2
+ import type { AztecNodeService } from './server.js';
3
+ /**
4
+ * Registers the Aztec node RPC handlers (`aztec_*`, `aztecAdmin_*`, and optionally `aztecDebug_*`), along with the
5
+ * legacy pre-v5 namespaces (`node_*`, `nodeAdmin_*`, `nodeDebug_*`, `p2p_*`) for backwards compatibility.
6
+ */
7
+ export declare function registerAztecNodeRpcHandlers(node: AztecNodeService, services: NamespacedApiHandlers, adminServices?: NamespacedApiHandlers, options?: {
8
+ debug?: boolean;
9
+ }): void;
10
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVnaXN0ZXJfbm9kZV9ycGNfaGFuZGxlcnMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9henRlYy1ub2RlL3JlZ2lzdGVyX25vZGVfcnBjX2hhbmRsZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFJL0UsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFFcEQ7OztHQUdHO0FBRUgsd0JBQWdCLDRCQUE0QixDQUMxQyxJQUFJLEVBQUUsZ0JBQWdCLEVBQ3RCLFFBQVEsRUFBRSxxQkFBcUIsRUFDL0IsYUFBYSxDQUFDLEVBQUUscUJBQXFCLEVBQ3JDLE9BQU8sR0FBRTtJQUFFLEtBQUssQ0FBQyxFQUFFLE9BQU8sQ0FBQTtDQUFPLEdBQ2hDLElBQUksQ0FZTiJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register_node_rpc_handlers.d.ts","sourceRoot":"","sources":["../../src/aztec-node/register_node_rpc_handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;GAGG;AAEH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,gBAAgB,EACtB,QAAQ,EAAE,qBAAqB,EAC/B,aAAa,CAAC,EAAE,qBAAqB,EACrC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAChC,IAAI,CAYN"}
@@ -0,0 +1,31 @@
1
+ import { AztecNodeAdminApiSchema, AztecNodeApiSchema, AztecNodeDebugApiSchema } from '@aztec/stdlib/interfaces/client';
2
+ import { P2PApiSchema } from '@aztec/stdlib/interfaces/server';
3
+ /**
4
+ * Registers the Aztec node RPC handlers (`aztec_*`, `aztecAdmin_*`, and optionally `aztecDebug_*`), along with the
5
+ * legacy pre-v5 namespaces (`node_*`, `nodeAdmin_*`, `nodeDebug_*`, `p2p_*`) for backwards compatibility.
6
+ */ // TODO: Legacy support for node, nodeAdmin, nodeDebug, p2p namespaces. New namespaces introduced in v5. Remove on future release. A-1169
7
+ export function registerAztecNodeRpcHandlers(node, services, adminServices, options = {}) {
8
+ services.aztec = [
9
+ node,
10
+ AztecNodeApiSchema
11
+ ];
12
+ services.node = services.aztec;
13
+ services.p2p = [
14
+ node.getP2P(),
15
+ P2PApiSchema
16
+ ];
17
+ if (adminServices) {
18
+ adminServices.aztecAdmin = [
19
+ node,
20
+ AztecNodeAdminApiSchema
21
+ ];
22
+ adminServices.nodeAdmin = adminServices.aztecAdmin;
23
+ }
24
+ if (options.debug) {
25
+ services.aztecDebug = [
26
+ node,
27
+ AztecNodeDebugApiSchema
28
+ ];
29
+ services.nodeDebug = services.aztecDebug;
30
+ }
31
+ }