@aztec/aztec-node 0.0.0-test.1 → 0.0.1-commit.017a351

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 (57) hide show
  1. package/dest/aztec-node/block_response_helpers.d.ts +25 -0
  2. package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
  3. package/dest/aztec-node/block_response_helpers.js +112 -0
  4. package/dest/aztec-node/config.d.ts +25 -11
  5. package/dest/aztec-node/config.d.ts.map +1 -1
  6. package/dest/aztec-node/config.js +90 -15
  7. package/dest/aztec-node/node_metrics.d.ts +5 -1
  8. package/dest/aztec-node/node_metrics.d.ts.map +1 -1
  9. package/dest/aztec-node/node_metrics.js +20 -6
  10. package/dest/aztec-node/public_data_overrides.d.ts +13 -0
  11. package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
  12. package/dest/aztec-node/public_data_overrides.js +21 -0
  13. package/dest/aztec-node/server.d.ts +139 -189
  14. package/dest/aztec-node/server.d.ts.map +1 -1
  15. package/dest/aztec-node/server.js +1842 -438
  16. package/dest/bin/index.d.ts +1 -1
  17. package/dest/bin/index.js +4 -2
  18. package/dest/index.d.ts +1 -2
  19. package/dest/index.d.ts.map +1 -1
  20. package/dest/index.js +0 -1
  21. package/dest/sentinel/config.d.ts +9 -0
  22. package/dest/sentinel/config.d.ts.map +1 -0
  23. package/dest/sentinel/config.js +39 -0
  24. package/dest/sentinel/factory.d.ts +11 -0
  25. package/dest/sentinel/factory.d.ts.map +1 -0
  26. package/dest/sentinel/factory.js +17 -0
  27. package/dest/sentinel/index.d.ts +3 -0
  28. package/dest/sentinel/index.d.ts.map +1 -0
  29. package/dest/sentinel/index.js +1 -0
  30. package/dest/sentinel/sentinel.d.ts +217 -0
  31. package/dest/sentinel/sentinel.d.ts.map +1 -0
  32. package/dest/sentinel/sentinel.js +571 -0
  33. package/dest/sentinel/store.d.ts +35 -0
  34. package/dest/sentinel/store.d.ts.map +1 -0
  35. package/dest/sentinel/store.js +182 -0
  36. package/dest/test/index.d.ts +31 -0
  37. package/dest/test/index.d.ts.map +1 -0
  38. package/dest/test/index.js +1 -0
  39. package/package.json +48 -35
  40. package/src/aztec-node/block_response_helpers.ts +161 -0
  41. package/src/aztec-node/config.ts +153 -26
  42. package/src/aztec-node/node_metrics.ts +23 -6
  43. package/src/aztec-node/public_data_overrides.ts +35 -0
  44. package/src/aztec-node/server.ts +1724 -573
  45. package/src/bin/index.ts +4 -2
  46. package/src/index.ts +0 -1
  47. package/src/sentinel/README.md +103 -0
  48. package/src/sentinel/config.ts +49 -0
  49. package/src/sentinel/factory.ts +34 -0
  50. package/src/sentinel/index.ts +8 -0
  51. package/src/sentinel/sentinel.ts +728 -0
  52. package/src/sentinel/store.ts +193 -0
  53. package/src/test/index.ts +32 -0
  54. package/dest/aztec-node/http_rpc_server.d.ts +0 -8
  55. package/dest/aztec-node/http_rpc_server.d.ts.map +0 -1
  56. package/dest/aztec-node/http_rpc_server.js +0 -9
  57. package/src/aztec-node/http_rpc_server.ts +0 -11
@@ -1,15 +1,37 @@
1
1
  import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config';
2
+ import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethereum/config';
2
3
  import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
3
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
4
+ import { EthAddress } from '@aztec/foundation/eth-address';
5
+ import {
6
+ type KeyStore,
7
+ type ValidatorKeyStore,
8
+ ethPrivateKeySchema,
9
+ keyStoreConfigMappings,
10
+ } from '@aztec/node-keystore';
11
+ import { type SharedNodeConfig, sharedNodeConfigMappings } from '@aztec/node-lib/config';
4
12
  import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
5
- import { type ProverClientConfig, proverClientConfigMappings } from '@aztec/prover-client/config';
6
- import { type SequencerClientConfig, sequencerClientConfigMappings } from '@aztec/sequencer-client/config';
13
+ import { type ProverClientUserConfig, proverClientConfigMappings } from '@aztec/prover-client/config';
14
+ import {
15
+ type ProverNodeConfig,
16
+ proverNodeConfigMappings,
17
+ specificProverNodeConfigMappings,
18
+ } from '@aztec/prover-node/config';
19
+ import {
20
+ type SequencerClientConfig,
21
+ type SequencerTxSenderConfig,
22
+ sequencerClientConfigMappings,
23
+ } from '@aztec/sequencer-client/config';
24
+ import { slasherConfigMappings } from '@aztec/slasher';
25
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
26
+ import { type NodeRPCConfig, nodeRpcConfigMappings } from '@aztec/stdlib/config';
27
+ import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
28
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
7
29
  import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
8
30
  import { type WorldStateConfig, worldStateConfigMappings } from '@aztec/world-state/config';
9
31
 
10
- import { readFileSync } from 'fs';
11
- import { dirname, resolve } from 'path';
12
- import { fileURLToPath } from 'url';
32
+ import { privateKeyToAddress } from 'viem/accounts';
33
+
34
+ import { type SentinelConfig, sentinelConfigMappings } from '../sentinel/config.js';
13
35
 
14
36
  export { sequencerClientConfigMappings, type SequencerClientConfig };
15
37
 
@@ -19,34 +41,73 @@ export { sequencerClientConfigMappings, type SequencerClientConfig };
19
41
  export type AztecNodeConfig = ArchiverConfig &
20
42
  SequencerClientConfig &
21
43
  ValidatorClientConfig &
22
- ProverClientConfig &
44
+ ProverClientUserConfig &
23
45
  WorldStateConfig &
24
- Pick<ProverClientConfig, 'bbBinaryPath' | 'bbWorkingDirectory' | 'realProofs'> &
46
+ Pick<ProverClientUserConfig, 'bbBinaryPath' | 'bbWorkingDirectory' | 'realProofs'> &
25
47
  P2PConfig &
26
- DataStoreConfig & {
48
+ DataStoreConfig &
49
+ SentinelConfig &
50
+ SharedNodeConfig &
51
+ GenesisStateConfig &
52
+ NodeRPCConfig &
53
+ SlasherConfig &
54
+ ProverNodeConfig & {
27
55
  /** Whether the validator is disabled for this node */
28
56
  disableValidator: boolean;
29
- /** Whether to populate the genesis state with initial fee juice for the test accounts */
30
- testAccounts: boolean;
57
+ /** Whether to skip waiting for the archiver to be fully synced before starting other services */
58
+ skipArchiverInitialSync: boolean;
59
+ /** A flag to force verification of tx Chonk proofs. Only used for testnet */
60
+ debugForceTxProofVerification: boolean;
61
+ /** Whether to enable the prover node as a subsystem. */
62
+ enableProverNode: boolean;
63
+ /**
64
+ * Test-only: use the deterministic AutomineSequencer instead of the production Sequencer.
65
+ * Requires `aztecTargetCommitteeSize === 0` on the deployed rollup and anvil-backed L1.
66
+ * See `AUTOMINE_E2E_OPTS` in `end-to-end/src/fixtures/fixtures.ts`.
67
+ */
68
+ useAutomineSequencer?: boolean;
31
69
  };
32
70
 
33
71
  export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
72
+ ...dataConfigMappings,
73
+ ...keyStoreConfigMappings,
34
74
  ...archiverConfigMappings,
35
75
  ...sequencerClientConfigMappings,
76
+ ...proverNodeConfigMappings,
36
77
  ...validatorClientConfigMappings,
37
78
  ...proverClientConfigMappings,
38
79
  ...worldStateConfigMappings,
39
80
  ...p2pConfigMappings,
40
- ...dataConfigMappings,
81
+ ...sentinelConfigMappings,
82
+ ...sharedNodeConfigMappings,
83
+ ...genesisStateConfigMappings,
84
+ ...nodeRpcConfigMappings,
85
+ ...slasherConfigMappings,
86
+ ...specificProverNodeConfigMappings,
41
87
  disableValidator: {
42
88
  env: 'VALIDATOR_DISABLED',
43
89
  description: 'Whether the validator is disabled for this node.',
44
90
  ...booleanConfigHelper(),
45
91
  },
46
- testAccounts: {
47
- env: 'TEST_ACCOUNTS',
48
- description: 'Whether to populate the genesis state with initial fee juice for the test accounts.',
49
- ...booleanConfigHelper(),
92
+ skipArchiverInitialSync: {
93
+ env: 'SKIP_ARCHIVER_INITIAL_SYNC',
94
+ description: 'Whether to skip waiting for the archiver to be fully synced before starting other services.',
95
+ ...booleanConfigHelper(false),
96
+ },
97
+ debugForceTxProofVerification: {
98
+ env: 'DEBUG_FORCE_TX_PROOF_VERIFICATION',
99
+ description: 'Whether to skip waiting for the archiver to be fully synced before starting other services.',
100
+ ...booleanConfigHelper(false),
101
+ },
102
+ enableProverNode: {
103
+ env: 'ENABLE_PROVER_NODE',
104
+ description: 'Whether to enable the prover node as a subsystem.',
105
+ ...booleanConfigHelper(false),
106
+ },
107
+ useAutomineSequencer: {
108
+ env: 'USE_AUTOMINE_SEQUENCER',
109
+ description: 'Test-only: use AutomineSequencer instead of the production Sequencer.',
110
+ ...booleanConfigHelper(false),
50
111
  },
51
112
  };
52
113
 
@@ -58,14 +119,80 @@ export function getConfigEnvVars(): AztecNodeConfig {
58
119
  return getConfigFromMappings<AztecNodeConfig>(aztecNodeConfigMappings);
59
120
  }
60
121
 
61
- /**
62
- * Returns package version.
63
- */
64
- export function getPackageVersion() {
65
- const releasePleaseManifestPath = resolve(
66
- dirname(fileURLToPath(import.meta.url)),
67
- '../../../../.release-please-manifest.json',
68
- );
69
- const version = JSON.parse(readFileSync(releasePleaseManifestPath).toString());
70
- return version['.'];
122
+ type ConfigRequiredToBuildKeyStore = SequencerClientConfig & SharedNodeConfig & ValidatorClientConfig;
123
+
124
+ function createKeyStoreFromWeb3Signer(config: ConfigRequiredToBuildKeyStore): KeyStore | undefined {
125
+ const validatorKeyStores: ValidatorKeyStore[] = [];
126
+
127
+ if (
128
+ config.web3SignerUrl === undefined ||
129
+ config.web3SignerUrl.length === 0 ||
130
+ config.validatorAddresses === undefined ||
131
+ config.validatorAddresses.length === 0
132
+ ) {
133
+ return undefined;
134
+ }
135
+
136
+ validatorKeyStores.push({
137
+ attester: config.validatorAddresses,
138
+ feeRecipient: config.feeRecipient ?? AztecAddress.ZERO,
139
+ coinbase: config.coinbase ?? config.validatorAddresses[0],
140
+ remoteSigner: config.web3SignerUrl,
141
+ publisher: config.sequencerPublisherAddresses ?? [],
142
+ });
143
+
144
+ const keyStore: KeyStore = {
145
+ schemaVersion: 1,
146
+ slasher: undefined,
147
+ prover: undefined,
148
+ remoteSigner: undefined,
149
+ validators: validatorKeyStores,
150
+ };
151
+ return keyStore;
152
+ }
153
+
154
+ function createKeyStoreFromPrivateKeys(config: ConfigRequiredToBuildKeyStore): KeyStore | undefined {
155
+ const validatorKeyStores: ValidatorKeyStore[] = [];
156
+ const ethPrivateKeys = config.validatorPrivateKeys
157
+ ? config.validatorPrivateKeys.getValue().map((x: string) => ethPrivateKeySchema.parse(x))
158
+ : [];
159
+
160
+ if (!ethPrivateKeys.length) {
161
+ return undefined;
162
+ }
163
+ const coinbase = config.coinbase ?? EthAddress.fromString(privateKeyToAddress(ethPrivateKeys[0]));
164
+ const feeRecipient = config.feeRecipient ?? AztecAddress.ZERO;
165
+
166
+ const publisherKeys = config.sequencerPublisherPrivateKeys
167
+ ? config.sequencerPublisherPrivateKeys.map((k: { getValue: () => string }) =>
168
+ ethPrivateKeySchema.parse(k.getValue()),
169
+ )
170
+ : [];
171
+
172
+ validatorKeyStores.push({
173
+ attester: ethPrivateKeys,
174
+ feeRecipient: feeRecipient,
175
+ coinbase: coinbase,
176
+ remoteSigner: undefined,
177
+ publisher: publisherKeys,
178
+ });
179
+
180
+ const keyStore: KeyStore = {
181
+ schemaVersion: 1,
182
+ slasher: undefined,
183
+ prover: undefined,
184
+ remoteSigner: undefined,
185
+ validators: validatorKeyStores,
186
+ };
187
+ return keyStore;
188
+ }
189
+
190
+ export function createKeyStoreForValidator(
191
+ config: SequencerTxSenderConfig & SequencerClientConfig & SharedNodeConfig,
192
+ ): KeyStore | undefined {
193
+ if (config.web3SignerUrl !== undefined && config.web3SignerUrl.length > 0) {
194
+ return createKeyStoreFromWeb3Signer(config);
195
+ }
196
+
197
+ return createKeyStoreFromPrivateKeys(config);
71
198
  }
@@ -4,21 +4,26 @@ import {
4
4
  Metrics,
5
5
  type TelemetryClient,
6
6
  type UpDownCounter,
7
- ValueType,
7
+ createUpDownCounterWithDefault,
8
8
  } from '@aztec/telemetry-client';
9
9
 
10
10
  export class NodeMetrics {
11
11
  private receiveTxCount: UpDownCounter;
12
12
  private receiveTxDuration: Histogram;
13
13
 
14
+ private snapshotErrorCount: UpDownCounter;
15
+ private snapshotDuration: Histogram;
16
+
14
17
  constructor(client: TelemetryClient, name = 'AztecNode') {
15
18
  const meter = client.getMeter(name);
16
- this.receiveTxCount = meter.createUpDownCounter(Metrics.NODE_RECEIVE_TX_COUNT, {});
17
- this.receiveTxDuration = meter.createHistogram(Metrics.NODE_RECEIVE_TX_DURATION, {
18
- description: 'The duration of the receiveTx method',
19
- unit: 'ms',
20
- valueType: ValueType.INT,
19
+ this.receiveTxCount = createUpDownCounterWithDefault(meter, Metrics.NODE_RECEIVE_TX_COUNT, {
20
+ [Attributes.OK]: [true, false],
21
21
  });
22
+ this.receiveTxDuration = meter.createHistogram(Metrics.NODE_RECEIVE_TX_DURATION);
23
+
24
+ this.snapshotDuration = meter.createHistogram(Metrics.NODE_SNAPSHOT_DURATION);
25
+
26
+ this.snapshotErrorCount = createUpDownCounterWithDefault(meter, Metrics.NODE_SNAPSHOT_ERROR_COUNT);
22
27
  }
23
28
 
24
29
  receivedTx(durationMs: number, isAccepted: boolean) {
@@ -29,4 +34,16 @@ export class NodeMetrics {
29
34
  [Attributes.OK]: isAccepted,
30
35
  });
31
36
  }
37
+
38
+ recordSnapshot(durationMs: number) {
39
+ if (isNaN(durationMs)) {
40
+ return;
41
+ }
42
+
43
+ this.snapshotDuration.record(Math.ceil(durationMs));
44
+ }
45
+
46
+ recordSnapshotError() {
47
+ this.snapshotErrorCount.add(1);
48
+ }
32
49
  }
@@ -0,0 +1,35 @@
1
+ import { PublicDataWrite } from '@aztec/stdlib/avm';
2
+ import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
3
+ import type { PublicStorageOverride } from '@aztec/stdlib/interfaces/client';
4
+ import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
5
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
6
+
7
+ /**
8
+ * Injects public-state overrides into an (ephemeral) world-state fork before simulation.
9
+ *
10
+ * Each override is written via the same `sequentialInsert` path the public processor
11
+ * uses during real transaction execution, so low-leaf updates and root coherence are
12
+ * handled identically for both simulation and proof generation.
13
+ *
14
+ * Writes never reach committed world state — the fork is thrown away after simulation.
15
+ */
16
+ export async function applyPublicDataOverrides(
17
+ fork: MerkleTreeWriteOperations,
18
+ publicStorage: PublicStorageOverride[] | undefined,
19
+ ): Promise<void> {
20
+ if (!publicStorage?.length) {
21
+ return;
22
+ }
23
+
24
+ const writes = await Promise.all(
25
+ publicStorage.map(async o => {
26
+ const leafSlot = await computePublicDataTreeLeafSlot(o.contract, o.slot);
27
+ return new PublicDataWrite(leafSlot, o.value);
28
+ }),
29
+ );
30
+
31
+ await fork.sequentialInsert(
32
+ MerkleTreeId.PUBLIC_DATA_TREE,
33
+ writes.map(w => w.toBuffer()),
34
+ );
35
+ }