@aztec/stdlib 4.0.4 → 4.1.0-nightly.20260312

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 (130) hide show
  1. package/dest/abi/decoder.d.ts +2 -2
  2. package/dest/abi/decoder.d.ts.map +1 -1
  3. package/dest/abi/decoder.js +6 -1
  4. package/dest/abi/encoder.d.ts +1 -1
  5. package/dest/abi/encoder.d.ts.map +1 -1
  6. package/dest/abi/encoder.js +28 -1
  7. package/dest/abi/event_metadata_definition.d.ts +3 -1
  8. package/dest/abi/event_metadata_definition.d.ts.map +1 -1
  9. package/dest/abi/event_metadata_definition.js +1 -1
  10. package/dest/abi/utils.d.ts +14 -1
  11. package/dest/abi/utils.d.ts.map +1 -1
  12. package/dest/abi/utils.js +15 -0
  13. package/dest/block/l2_block.d.ts +9 -1
  14. package/dest/block/l2_block.d.ts.map +1 -1
  15. package/dest/block/l2_block.js +12 -2
  16. package/dest/block/l2_block_source.d.ts +6 -1
  17. package/dest/block/l2_block_source.d.ts.map +1 -1
  18. package/dest/checkpoint/checkpoint.d.ts +2 -1
  19. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  20. package/dest/checkpoint/checkpoint.js +9 -4
  21. package/dest/checkpoint/index.d.ts +2 -1
  22. package/dest/checkpoint/index.d.ts.map +1 -1
  23. package/dest/checkpoint/index.js +1 -0
  24. package/dest/checkpoint/validate.d.ts +36 -0
  25. package/dest/checkpoint/validate.d.ts.map +1 -0
  26. package/dest/checkpoint/validate.js +120 -0
  27. package/dest/config/sequencer-config.d.ts +2 -4
  28. package/dest/config/sequencer-config.d.ts.map +1 -1
  29. package/dest/config/sequencer-config.js +1 -3
  30. package/dest/epoch-helpers/index.d.ts +5 -1
  31. package/dest/epoch-helpers/index.d.ts.map +1 -1
  32. package/dest/epoch-helpers/index.js +4 -2
  33. package/dest/interfaces/allowed_element.d.ts +26 -20
  34. package/dest/interfaces/allowed_element.d.ts.map +1 -1
  35. package/dest/interfaces/allowed_element.js +8 -8
  36. package/dest/interfaces/archiver.d.ts +1 -1
  37. package/dest/interfaces/archiver.d.ts.map +1 -1
  38. package/dest/interfaces/archiver.js +1 -0
  39. package/dest/interfaces/aztec-node-admin.d.ts +64 -30
  40. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  41. package/dest/interfaces/aztec-node.d.ts +10 -5
  42. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  43. package/dest/interfaces/aztec-node.js +3 -2
  44. package/dest/interfaces/block-builder.d.ts +8 -5
  45. package/dest/interfaces/block-builder.d.ts.map +1 -1
  46. package/dest/interfaces/block-builder.js +7 -2
  47. package/dest/interfaces/configs.d.ts +57 -32
  48. package/dest/interfaces/configs.d.ts.map +1 -1
  49. package/dest/interfaces/configs.js +5 -2
  50. package/dest/interfaces/prover-client.d.ts +6 -1
  51. package/dest/interfaces/prover-client.d.ts.map +1 -1
  52. package/dest/interfaces/prover-client.js +7 -1
  53. package/dest/interfaces/validator.d.ts +67 -28
  54. package/dest/interfaces/validator.d.ts.map +1 -1
  55. package/dest/interfaces/validator.js +6 -3
  56. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
  57. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
  58. package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
  59. package/dest/logs/public_log.d.ts +4 -3
  60. package/dest/logs/public_log.d.ts.map +1 -1
  61. package/dest/logs/public_log.js +2 -1
  62. package/dest/p2p/checkpoint_proposal.d.ts +1 -6
  63. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  64. package/dest/p2p/checkpoint_proposal.js +0 -12
  65. package/dest/p2p/peer_error.d.ts +3 -1
  66. package/dest/p2p/peer_error.d.ts.map +1 -1
  67. package/dest/p2p/peer_error.js +5 -0
  68. package/dest/slashing/tally.d.ts +7 -2
  69. package/dest/slashing/tally.d.ts.map +1 -1
  70. package/dest/slashing/tally.js +30 -2
  71. package/dest/tests/mocks.d.ts +4 -2
  72. package/dest/tests/mocks.d.ts.map +1 -1
  73. package/dest/tests/mocks.js +13 -8
  74. package/dest/tx/block_header.d.ts +3 -1
  75. package/dest/tx/block_header.d.ts.map +1 -1
  76. package/dest/tx/block_header.js +4 -0
  77. package/dest/tx/simulated_tx.d.ts +5 -2
  78. package/dest/tx/simulated_tx.d.ts.map +1 -1
  79. package/dest/tx/simulated_tx.js +4 -1
  80. package/dest/tx/tx.d.ts +6 -5
  81. package/dest/tx/tx.d.ts.map +1 -1
  82. package/dest/tx/tx.js +18 -6
  83. package/dest/tx/validator/error_texts.d.ts +5 -1
  84. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  85. package/dest/tx/validator/error_texts.js +4 -0
  86. package/dest/update-checker/index.d.ts +3 -2
  87. package/dest/update-checker/index.d.ts.map +1 -1
  88. package/dest/update-checker/index.js +2 -1
  89. package/dest/update-checker/package_version.d.ts +3 -0
  90. package/dest/update-checker/package_version.d.ts.map +1 -0
  91. package/dest/update-checker/package_version.js +11 -0
  92. package/dest/update-checker/version_checker.d.ts +25 -0
  93. package/dest/update-checker/version_checker.d.ts.map +1 -0
  94. package/dest/update-checker/version_checker.js +50 -0
  95. package/package.json +9 -9
  96. package/src/abi/decoder.ts +14 -2
  97. package/src/abi/encoder.ts +41 -1
  98. package/src/abi/event_metadata_definition.ts +2 -0
  99. package/src/abi/utils.ts +25 -0
  100. package/src/block/l2_block.ts +13 -1
  101. package/src/block/l2_block_source.ts +6 -0
  102. package/src/checkpoint/checkpoint.ts +12 -3
  103. package/src/checkpoint/index.ts +1 -0
  104. package/src/checkpoint/validate.ts +230 -0
  105. package/src/config/sequencer-config.ts +2 -5
  106. package/src/epoch-helpers/index.ts +3 -0
  107. package/src/interfaces/allowed_element.ts +29 -9
  108. package/src/interfaces/archiver.ts +1 -0
  109. package/src/interfaces/aztec-node.ts +14 -4
  110. package/src/interfaces/block-builder.ts +23 -6
  111. package/src/interfaces/configs.ts +22 -8
  112. package/src/interfaces/prover-client.ts +8 -0
  113. package/src/interfaces/validator.ts +18 -3
  114. package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
  115. package/src/logs/public_log.ts +4 -2
  116. package/src/p2p/checkpoint_proposal.ts +0 -17
  117. package/src/p2p/peer_error.ts +7 -0
  118. package/src/slashing/tally.ts +34 -1
  119. package/src/tests/mocks.ts +18 -7
  120. package/src/tx/block_header.ts +6 -0
  121. package/src/tx/simulated_tx.ts +8 -1
  122. package/src/tx/tx.ts +20 -11
  123. package/src/tx/validator/error_texts.ts +4 -0
  124. package/src/update-checker/index.ts +2 -1
  125. package/src/update-checker/package_version.ts +17 -0
  126. package/src/update-checker/version_checker.ts +65 -0
  127. package/dest/update-checker/update-checker.d.ts +0 -49
  128. package/dest/update-checker/update-checker.d.ts.map +0 -1
  129. package/dest/update-checker/update-checker.js +0 -130
  130. package/src/update-checker/update-checker.ts +0 -166
@@ -1,130 +0,0 @@
1
- import { RegistryContract } from '@aztec/ethereum/contracts';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { RunningPromise } from '@aztec/foundation/running-promise';
4
- import { fileURLToPath } from '@aztec/foundation/url';
5
- import { EventEmitter } from 'events';
6
- import { readFileSync } from 'fs';
7
- import { dirname, resolve } from 'path';
8
- import { isDeepStrictEqual } from 'util';
9
- import { z } from 'zod';
10
- const updateConfigSchema = z.object({
11
- version: z.string().optional(),
12
- publicTelemetry: z.any().optional(),
13
- config: z.any().optional()
14
- });
15
- export class UpdateChecker extends EventEmitter {
16
- updatesUrl;
17
- nodeVersion;
18
- rollupVersion;
19
- fetch;
20
- getLatestRollupVersion;
21
- checkIntervalMs;
22
- log;
23
- runningPromise;
24
- lastPatchedConfig;
25
- lastPatchedPublicTelemetryConfig;
26
- constructor(updatesUrl, nodeVersion, rollupVersion, fetch1, getLatestRollupVersion, checkIntervalMs = 10 * 60_000, log = createLogger('foundation:update-check')){
27
- super(), this.updatesUrl = updatesUrl, this.nodeVersion = nodeVersion, this.rollupVersion = rollupVersion, this.fetch = fetch1, this.getLatestRollupVersion = getLatestRollupVersion, this.checkIntervalMs = checkIntervalMs, this.log = log, this.lastPatchedConfig = {}, this.lastPatchedPublicTelemetryConfig = {}, this.runChecks = async ()=>{
28
- await Promise.all([
29
- this.checkRollupVersion(),
30
- this.checkConfig()
31
- ]);
32
- };
33
- this.runningPromise = new RunningPromise(this.runChecks, this.log, this.checkIntervalMs);
34
- }
35
- static async new(config) {
36
- const registryContract = new RegistryContract(config.publicClient, config.registryContractAddress);
37
- const getLatestRollupVersion = ()=>registryContract.getRollupVersions().then((versions)=>versions.at(-1));
38
- return new UpdateChecker(config.baseURL, config.nodeVersion ?? getPackageVersion(), await getLatestRollupVersion(), config.fetch ?? fetch, getLatestRollupVersion, config.checkIntervalMs);
39
- }
40
- start() {
41
- if (this.runningPromise.isRunning()) {
42
- this.log.debug(`Can't start update checker again`);
43
- return;
44
- }
45
- this.log.info('Starting update checker', {
46
- nodeVersion: this.nodeVersion,
47
- rollupVersion: this.rollupVersion
48
- });
49
- this.runningPromise.start();
50
- }
51
- stop() {
52
- if (!this.runningPromise.isRunning()) {
53
- this.log.debug(`Can't stop update checker because it is not running`);
54
- return Promise.resolve();
55
- }
56
- return this.runningPromise.stop();
57
- }
58
- trigger() {
59
- return this.runningPromise.trigger();
60
- }
61
- runChecks;
62
- async checkRollupVersion() {
63
- try {
64
- const canonicalRollupVersion = await this.getLatestRollupVersion();
65
- if (canonicalRollupVersion !== this.rollupVersion) {
66
- this.log.debug('New canonical rollup version', {
67
- currentVersion: this.rollupVersion,
68
- latestVersion: canonicalRollupVersion
69
- });
70
- this.emit('newRollupVersion', {
71
- currentVersion: this.rollupVersion,
72
- latestVersion: canonicalRollupVersion
73
- });
74
- }
75
- } catch (err) {
76
- this.log.warn(`Failed to check if there is a new rollup`, err);
77
- }
78
- }
79
- async checkConfig() {
80
- try {
81
- const response = await this.fetch(this.updatesUrl);
82
- const body = await response.json();
83
- if (!response.ok) {
84
- this.log.warn(`Unexpected HTTP response checking for updates`, {
85
- status: response.status,
86
- body: await response.text(),
87
- url: this.updatesUrl
88
- });
89
- }
90
- const { version, config, publicTelemetry } = updateConfigSchema.parse(body);
91
- if (this.nodeVersion && version && version !== this.nodeVersion) {
92
- this.log.debug('New node version', {
93
- currentVersion: this.nodeVersion,
94
- latestVersion: version
95
- });
96
- this.emit('newNodeVersion', {
97
- currentVersion: this.nodeVersion,
98
- latestVersion: version
99
- });
100
- }
101
- if (config && Object.keys(config).length > 0 && !isDeepStrictEqual(config, this.lastPatchedConfig)) {
102
- this.log.debug('New node config', {
103
- config
104
- });
105
- this.lastPatchedConfig = config;
106
- this.emit('updateNodeConfig', config);
107
- }
108
- if (publicTelemetry && Object.keys(publicTelemetry).length > 0 && !isDeepStrictEqual(publicTelemetry, this.lastPatchedPublicTelemetryConfig)) {
109
- this.log.debug('New metrics config', {
110
- config
111
- });
112
- this.lastPatchedPublicTelemetryConfig = publicTelemetry;
113
- this.emit('updatePublicTelemetryConfig', publicTelemetry);
114
- }
115
- } catch (err) {
116
- this.log.warn(`Failed to check if there is an update`, err);
117
- }
118
- }
119
- }
120
- /**
121
- * Returns package version.
122
- */ export function getPackageVersion() {
123
- try {
124
- const releasePleaseManifestPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../../../.release-please-manifest.json');
125
- const version = JSON.parse(readFileSync(releasePleaseManifestPath).toString())['.'];
126
- return version;
127
- } catch {
128
- return undefined;
129
- }
130
- }
@@ -1,166 +0,0 @@
1
- import { RegistryContract } from '@aztec/ethereum/contracts';
2
- import type { ViemClient } from '@aztec/ethereum/types';
3
- import { EthAddress } from '@aztec/foundation/eth-address';
4
- import { createLogger } from '@aztec/foundation/log';
5
- import { RunningPromise } from '@aztec/foundation/running-promise';
6
- import { fileURLToPath } from '@aztec/foundation/url';
7
-
8
- import { EventEmitter } from 'events';
9
- import { readFileSync } from 'fs';
10
- import { dirname, resolve } from 'path';
11
- import { isDeepStrictEqual } from 'util';
12
- import { z } from 'zod';
13
-
14
- const updateConfigSchema = z.object({
15
- version: z.string().optional(),
16
- publicTelemetry: z.any().optional(),
17
- config: z.any().optional(),
18
- });
19
-
20
- export type EventMap = {
21
- newRollupVersion: [{ currentVersion: bigint; latestVersion: bigint }];
22
- newNodeVersion: [{ currentVersion: string; latestVersion: string }];
23
- updateNodeConfig: [object];
24
- updatePublicTelemetryConfig: [object];
25
- };
26
-
27
- type Config = {
28
- baseURL: URL;
29
- nodeVersion?: string;
30
- checkIntervalMs?: number;
31
- registryContractAddress: EthAddress;
32
- publicClient: ViemClient;
33
- fetch?: typeof fetch;
34
- };
35
-
36
- export class UpdateChecker extends EventEmitter<EventMap> {
37
- private runningPromise: RunningPromise;
38
- private lastPatchedConfig: object = {};
39
- private lastPatchedPublicTelemetryConfig: object = {};
40
-
41
- constructor(
42
- private updatesUrl: URL,
43
- private nodeVersion: string | undefined,
44
- private rollupVersion: bigint,
45
- private fetch: typeof globalThis.fetch,
46
- private getLatestRollupVersion: () => Promise<bigint>,
47
- private checkIntervalMs = 10 * 60_000, // every 10 mins
48
- private log = createLogger('foundation:update-check'),
49
- ) {
50
- super();
51
- this.runningPromise = new RunningPromise(this.runChecks, this.log, this.checkIntervalMs);
52
- }
53
-
54
- public static async new(config: Config): Promise<UpdateChecker> {
55
- const registryContract = new RegistryContract(config.publicClient, config.registryContractAddress);
56
- const getLatestRollupVersion = () => registryContract.getRollupVersions().then(versions => versions.at(-1)!);
57
-
58
- return new UpdateChecker(
59
- config.baseURL,
60
- config.nodeVersion ?? getPackageVersion(),
61
- await getLatestRollupVersion(),
62
- config.fetch ?? fetch,
63
- getLatestRollupVersion,
64
- config.checkIntervalMs,
65
- );
66
- }
67
-
68
- public start(): void {
69
- if (this.runningPromise.isRunning()) {
70
- this.log.debug(`Can't start update checker again`);
71
- return;
72
- }
73
-
74
- this.log.info('Starting update checker', {
75
- nodeVersion: this.nodeVersion,
76
- rollupVersion: this.rollupVersion,
77
- });
78
- this.runningPromise.start();
79
- }
80
-
81
- public stop(): Promise<void> {
82
- if (!this.runningPromise.isRunning()) {
83
- this.log.debug(`Can't stop update checker because it is not running`);
84
- return Promise.resolve();
85
- }
86
- return this.runningPromise.stop();
87
- }
88
-
89
- public trigger(): Promise<void> {
90
- return this.runningPromise.trigger();
91
- }
92
-
93
- private runChecks = async (): Promise<void> => {
94
- await Promise.all([this.checkRollupVersion(), this.checkConfig()]);
95
- };
96
-
97
- private async checkRollupVersion(): Promise<void> {
98
- try {
99
- const canonicalRollupVersion = await this.getLatestRollupVersion();
100
- if (canonicalRollupVersion !== this.rollupVersion) {
101
- this.log.debug('New canonical rollup version', {
102
- currentVersion: this.rollupVersion,
103
- latestVersion: canonicalRollupVersion,
104
- });
105
- this.emit('newRollupVersion', { currentVersion: this.rollupVersion, latestVersion: canonicalRollupVersion });
106
- }
107
- } catch (err) {
108
- this.log.warn(`Failed to check if there is a new rollup`, err);
109
- }
110
- }
111
-
112
- private async checkConfig(): Promise<void> {
113
- try {
114
- const response = await this.fetch(this.updatesUrl);
115
- const body = await response.json();
116
- if (!response.ok) {
117
- this.log.warn(`Unexpected HTTP response checking for updates`, {
118
- status: response.status,
119
- body: await response.text(),
120
- url: this.updatesUrl,
121
- });
122
- }
123
-
124
- const { version, config, publicTelemetry } = updateConfigSchema.parse(body);
125
-
126
- if (this.nodeVersion && version && version !== this.nodeVersion) {
127
- this.log.debug('New node version', { currentVersion: this.nodeVersion, latestVersion: version });
128
- this.emit('newNodeVersion', { currentVersion: this.nodeVersion, latestVersion: version });
129
- }
130
-
131
- if (config && Object.keys(config).length > 0 && !isDeepStrictEqual(config, this.lastPatchedConfig)) {
132
- this.log.debug('New node config', { config });
133
- this.lastPatchedConfig = config;
134
- this.emit('updateNodeConfig', config);
135
- }
136
-
137
- if (
138
- publicTelemetry &&
139
- Object.keys(publicTelemetry).length > 0 &&
140
- !isDeepStrictEqual(publicTelemetry, this.lastPatchedPublicTelemetryConfig)
141
- ) {
142
- this.log.debug('New metrics config', { config });
143
- this.lastPatchedPublicTelemetryConfig = publicTelemetry;
144
- this.emit('updatePublicTelemetryConfig', publicTelemetry);
145
- }
146
- } catch (err) {
147
- this.log.warn(`Failed to check if there is an update`, err);
148
- }
149
- }
150
- }
151
-
152
- /**
153
- * Returns package version.
154
- */
155
- export function getPackageVersion(): string | undefined {
156
- try {
157
- const releasePleaseManifestPath = resolve(
158
- dirname(fileURLToPath(import.meta.url)),
159
- '../../../../.release-please-manifest.json',
160
- );
161
- const version = JSON.parse(readFileSync(releasePleaseManifestPath).toString())['.'];
162
- return version;
163
- } catch {
164
- return undefined;
165
- }
166
- }