@aztec/aztec-node 0.0.1-commit.a072138 → 0.0.1-commit.a5db02d
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.
- package/dest/aztec-node/block_response_helpers.d.ts +25 -0
- package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
- package/dest/aztec-node/block_response_helpers.js +112 -0
- package/dest/aztec-node/config.d.ts +23 -8
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +26 -8
- package/dest/aztec-node/node_public_calls_simulator.d.ts +90 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
- package/dest/aztec-node/node_public_calls_simulator.js +346 -0
- package/dest/aztec-node/public_data_overrides.d.ts +13 -0
- package/dest/aztec-node/public_data_overrides.d.ts.map +1 -0
- package/dest/aztec-node/public_data_overrides.js +21 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts +10 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
- package/dest/aztec-node/register_node_rpc_handlers.js +31 -0
- package/dest/aztec-node/server.d.ts +140 -135
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +490 -730
- package/dest/bin/index.js +15 -10
- package/dest/factory.d.ts +33 -0
- package/dest/factory.d.ts.map +1 -0
- package/dest/factory.js +509 -0
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/modules/block_parameter.d.ts +25 -0
- package/dest/modules/block_parameter.d.ts.map +1 -0
- package/dest/modules/block_parameter.js +100 -0
- package/dest/modules/node_block_provider.d.ts +19 -0
- package/dest/modules/node_block_provider.d.ts.map +1 -0
- package/dest/modules/node_block_provider.js +112 -0
- package/dest/modules/node_tx_receipt.d.ts +24 -0
- package/dest/modules/node_tx_receipt.d.ts.map +1 -0
- package/dest/modules/node_tx_receipt.js +70 -0
- package/dest/modules/node_world_state_queries.d.ts +65 -0
- package/dest/modules/node_world_state_queries.d.ts.map +1 -0
- package/dest/modules/node_world_state_queries.js +272 -0
- package/dest/sentinel/config.d.ts +3 -2
- package/dest/sentinel/config.d.ts.map +1 -1
- package/dest/sentinel/config.js +15 -5
- package/dest/sentinel/factory.d.ts +6 -4
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +12 -5
- package/dest/sentinel/sentinel.d.ts +146 -22
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +266 -118
- package/dest/sentinel/store.d.ts +8 -8
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +33 -21
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +28 -25
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +55 -16
- package/src/aztec-node/node_public_calls_simulator.ts +383 -0
- package/src/aztec-node/public_data_overrides.ts +35 -0
- package/src/aztec-node/register_node_rpc_handlers.ts +29 -0
- package/src/aztec-node/server.ts +632 -939
- package/src/bin/index.ts +19 -12
- package/src/factory.ts +673 -0
- package/src/index.ts +2 -0
- package/src/modules/block_parameter.ts +93 -0
- package/src/modules/node_block_provider.ts +149 -0
- package/src/modules/node_tx_receipt.ts +115 -0
- package/src/modules/node_world_state_queries.ts +374 -0
- package/src/sentinel/README.md +103 -0
- package/src/sentinel/config.ts +18 -6
- package/src/sentinel/factory.ts +22 -7
- package/src/sentinel/sentinel.ts +316 -136
- package/src/sentinel/store.ts +35 -27
- package/src/test/index.ts +2 -2
package/src/sentinel/store.ts
CHANGED
|
@@ -9,45 +9,45 @@ import type {
|
|
|
9
9
|
} from '@aztec/stdlib/validators';
|
|
10
10
|
|
|
11
11
|
export class SentinelStore {
|
|
12
|
-
public static readonly SCHEMA_VERSION =
|
|
12
|
+
public static readonly SCHEMA_VERSION = 4;
|
|
13
13
|
|
|
14
14
|
// a map from validator address to their ValidatorStatusHistory
|
|
15
15
|
private readonly historyMap: AztecAsyncMap<`0x${string}`, Buffer>;
|
|
16
16
|
|
|
17
|
-
// a map from validator address to their historical
|
|
17
|
+
// a map from validator address to their historical epoch performance, evaluated at end-of-epoch.
|
|
18
18
|
// e.g. { validator: [{ epoch: 1, missed: 1, total: 10 }, { epoch: 2, missed: 3, total: 7 }, ...] }
|
|
19
|
-
private readonly
|
|
19
|
+
private readonly epochMap: AztecAsyncMap<`0x${string}`, Buffer>;
|
|
20
20
|
|
|
21
21
|
constructor(
|
|
22
22
|
private store: AztecAsyncKVStore,
|
|
23
|
-
private config: { historyLength: number;
|
|
23
|
+
private config: { historyLength: number; historicEpochPerformanceLength: number },
|
|
24
24
|
) {
|
|
25
25
|
this.historyMap = store.openMap('sentinel-validator-status');
|
|
26
|
-
this.
|
|
26
|
+
this.epochMap = store.openMap('sentinel-validator-epoch');
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
public getHistoryLength() {
|
|
30
30
|
return this.config.historyLength;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
public
|
|
34
|
-
return this.config.
|
|
33
|
+
public getHistoricEpochPerformanceLength() {
|
|
34
|
+
return this.config.historicEpochPerformanceLength;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
public async
|
|
37
|
+
public async updateEpochPerformance(epoch: EpochNumber, performance: ValidatorsEpochPerformance) {
|
|
38
38
|
await this.store.transactionAsync(async () => {
|
|
39
39
|
for (const [who, { missed, total }] of Object.entries(performance)) {
|
|
40
|
-
await this.
|
|
40
|
+
await this.pushValidatorEpochPerformance({ who: EthAddress.fromString(who), missed, total, epoch });
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
public async
|
|
46
|
-
const currentPerformanceBuffer = await this.
|
|
45
|
+
public async getEpochPerformance(who: EthAddress): Promise<{ missed: number; total: number; epoch: EpochNumber }[]> {
|
|
46
|
+
const currentPerformanceBuffer = await this.epochMap.getAsync(who.toString());
|
|
47
47
|
return currentPerformanceBuffer ? this.deserializePerformance(currentPerformanceBuffer) : [];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
private async
|
|
50
|
+
private async pushValidatorEpochPerformance({
|
|
51
51
|
who,
|
|
52
52
|
missed,
|
|
53
53
|
total,
|
|
@@ -58,7 +58,7 @@ export class SentinelStore {
|
|
|
58
58
|
total: number;
|
|
59
59
|
epoch: EpochNumber;
|
|
60
60
|
}) {
|
|
61
|
-
const currentPerformance = await this.
|
|
61
|
+
const currentPerformance = await this.getEpochPerformance(who);
|
|
62
62
|
const existingIndex = currentPerformance.findIndex(p => p.epoch === epoch);
|
|
63
63
|
if (existingIndex !== -1) {
|
|
64
64
|
currentPerformance[existingIndex] = { missed, total, epoch };
|
|
@@ -70,10 +70,10 @@ export class SentinelStore {
|
|
|
70
70
|
// Since we keep the size small, this is not a big deal.
|
|
71
71
|
currentPerformance.sort((a, b) => Number(a.epoch - b.epoch));
|
|
72
72
|
|
|
73
|
-
// keep the most recent `
|
|
74
|
-
const performanceToKeep = currentPerformance.slice(-this.config.
|
|
73
|
+
// keep the most recent `historicEpochPerformanceLength` entries.
|
|
74
|
+
const performanceToKeep = currentPerformance.slice(-this.config.historicEpochPerformanceLength);
|
|
75
75
|
|
|
76
|
-
await this.
|
|
76
|
+
await this.epochMap.set(who.toString(), this.serializePerformance(performanceToKeep));
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
public async updateValidators(slot: SlotNumber, statuses: Record<`0x${string}`, ValidatorStatusInSlot | undefined>) {
|
|
@@ -86,11 +86,7 @@ export class SentinelStore {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
private async pushValidatorStatusForSlot(
|
|
90
|
-
who: EthAddress,
|
|
91
|
-
slot: SlotNumber,
|
|
92
|
-
status: 'block-mined' | 'block-proposed' | 'block-missed' | 'attestation-sent' | 'attestation-missed',
|
|
93
|
-
) {
|
|
89
|
+
private async pushValidatorStatusForSlot(who: EthAddress, slot: SlotNumber, status: ValidatorStatusInSlot) {
|
|
94
90
|
await this.store.transactionAsync(async () => {
|
|
95
91
|
const currentHistory = (await this.getHistory(who)) ?? [];
|
|
96
92
|
const newHistory = [...currentHistory, { slot, status }].slice(-this.config.historyLength);
|
|
@@ -149,16 +145,22 @@ export class SentinelStore {
|
|
|
149
145
|
|
|
150
146
|
private statusToNumber(status: ValidatorStatusInSlot): number {
|
|
151
147
|
switch (status) {
|
|
152
|
-
case '
|
|
148
|
+
case 'checkpoint-mined':
|
|
153
149
|
return 1;
|
|
154
|
-
case '
|
|
150
|
+
case 'checkpoint-valid':
|
|
155
151
|
return 2;
|
|
156
|
-
case '
|
|
152
|
+
case 'checkpoint-missed':
|
|
157
153
|
return 3;
|
|
158
154
|
case 'attestation-sent':
|
|
159
155
|
return 4;
|
|
160
156
|
case 'attestation-missed':
|
|
161
157
|
return 5;
|
|
158
|
+
case 'blocks-missed':
|
|
159
|
+
return 6;
|
|
160
|
+
case 'checkpoint-invalid':
|
|
161
|
+
return 7;
|
|
162
|
+
case 'checkpoint-unvalidated':
|
|
163
|
+
return 8;
|
|
162
164
|
default: {
|
|
163
165
|
const _exhaustive: never = status;
|
|
164
166
|
throw new Error(`Unknown status: ${status}`);
|
|
@@ -169,15 +171,21 @@ export class SentinelStore {
|
|
|
169
171
|
private statusFromNumber(status: number): ValidatorStatusInSlot {
|
|
170
172
|
switch (status) {
|
|
171
173
|
case 1:
|
|
172
|
-
return '
|
|
174
|
+
return 'checkpoint-mined';
|
|
173
175
|
case 2:
|
|
174
|
-
return '
|
|
176
|
+
return 'checkpoint-valid';
|
|
175
177
|
case 3:
|
|
176
|
-
return '
|
|
178
|
+
return 'checkpoint-missed';
|
|
177
179
|
case 4:
|
|
178
180
|
return 'attestation-sent';
|
|
179
181
|
case 5:
|
|
180
182
|
return 'attestation-missed';
|
|
183
|
+
case 6:
|
|
184
|
+
return 'blocks-missed';
|
|
185
|
+
case 7:
|
|
186
|
+
return 'checkpoint-invalid';
|
|
187
|
+
case 8:
|
|
188
|
+
return 'checkpoint-unvalidated';
|
|
181
189
|
default:
|
|
182
190
|
throw new Error(`Unknown status: ${status}`);
|
|
183
191
|
}
|
package/src/test/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
2
|
import type { P2P } from '@aztec/p2p';
|
|
3
3
|
import { SequencerClient } from '@aztec/sequencer-client';
|
|
4
|
-
import {
|
|
4
|
+
import { DataWithholdingWatcher, type SlasherClientInterface } from '@aztec/slasher';
|
|
5
5
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
6
6
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
7
7
|
import type { L2LogsSource, Service, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
@@ -23,7 +23,7 @@ export declare class TestAztecNodeService extends AztecNodeService {
|
|
|
23
23
|
declare public sequencer: SequencerClient | undefined;
|
|
24
24
|
declare public slasherClient: SlasherClientInterface | undefined;
|
|
25
25
|
declare public validatorsSentinel: Sentinel | undefined;
|
|
26
|
-
declare public
|
|
26
|
+
declare public dataWithholdingWatcher: DataWithholdingWatcher | undefined;
|
|
27
27
|
declare public l1ChainId: number;
|
|
28
28
|
declare public version: number;
|
|
29
29
|
declare public globalVariableBuilder: GlobalVariableBuilderInterface;
|