@aztec-labs/aztec-node 6.0.0-nightly.20260829
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/README.md +15 -0
- 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 +52 -0
- package/dest/aztec-node/config.d.ts.map +1 -0
- package/dest/aztec-node/config.js +129 -0
- package/dest/aztec-node/node_metrics.d.ts +12 -0
- package/dest/aztec-node/node_metrics.d.ts.map +1 -0
- package/dest/aztec-node/node_metrics.js +36 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts +108 -0
- package/dest/aztec-node/node_public_calls_simulator.d.ts.map +1 -0
- package/dest/aztec-node/node_public_calls_simulator.js +380 -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 +11 -0
- package/dest/aztec-node/register_node_rpc_handlers.d.ts.map +1 -0
- package/dest/aztec-node/register_node_rpc_handlers.js +48 -0
- package/dest/aztec-node/server.d.ts +281 -0
- package/dest/aztec-node/server.d.ts.map +1 -0
- package/dest/aztec-node/server.js +1235 -0
- package/dest/bin/index.d.ts +3 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +57 -0
- package/dest/factory.d.ts +33 -0
- package/dest/factory.d.ts.map +1 -0
- package/dest/factory.js +539 -0
- package/dest/index.d.ts +5 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +4 -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 +270 -0
- package/dest/sentinel/config.d.ts +9 -0
- package/dest/sentinel/config.d.ts.map +1 -0
- package/dest/sentinel/config.js +39 -0
- package/dest/sentinel/factory.d.ts +11 -0
- package/dest/sentinel/factory.d.ts.map +1 -0
- package/dest/sentinel/factory.js +24 -0
- package/dest/sentinel/index.d.ts +3 -0
- package/dest/sentinel/index.d.ts.map +1 -0
- package/dest/sentinel/index.js +1 -0
- package/dest/sentinel/sentinel.d.ts +217 -0
- package/dest/sentinel/sentinel.d.ts.map +1 -0
- package/dest/sentinel/sentinel.js +551 -0
- package/dest/sentinel/store.d.ts +35 -0
- package/dest/sentinel/store.d.ts.map +1 -0
- package/dest/sentinel/store.js +182 -0
- package/dest/test/index.d.ts +31 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +1 -0
- package/package.json +118 -0
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +216 -0
- package/src/aztec-node/node_metrics.ts +49 -0
- package/src/aztec-node/node_public_calls_simulator.ts +437 -0
- package/src/aztec-node/public_data_overrides.ts +35 -0
- package/src/aztec-node/register_node_rpc_handlers.ts +45 -0
- package/src/aztec-node/server.ts +1155 -0
- package/src/bin/index.ts +77 -0
- package/src/factory.ts +704 -0
- package/src/index.ts +4 -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 +373 -0
- package/src/sentinel/README.md +103 -0
- package/src/sentinel/config.ts +49 -0
- package/src/sentinel/factory.ts +46 -0
- package/src/sentinel/index.ts +8 -0
- package/src/sentinel/sentinel.ts +694 -0
- package/src/sentinel/store.ts +193 -0
- package/src/test/index.ts +32 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { EpochNumber, SlotNumber } from '@aztec-labs/foundation/branded-types';
|
|
2
|
+
import { EthAddress } from '@aztec-labs/foundation/eth-address';
|
|
3
|
+
import { BufferReader, numToUInt8, numToUInt32BE, serializeToBuffer } from '@aztec-labs/foundation/serialize';
|
|
4
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec-labs/kv-store';
|
|
5
|
+
import type {
|
|
6
|
+
ValidatorStatusHistory,
|
|
7
|
+
ValidatorStatusInSlot,
|
|
8
|
+
ValidatorsEpochPerformance,
|
|
9
|
+
} from '@aztec-labs/stdlib/validators';
|
|
10
|
+
|
|
11
|
+
export class SentinelStore {
|
|
12
|
+
public static readonly SCHEMA_VERSION = 4;
|
|
13
|
+
|
|
14
|
+
// a map from validator address to their ValidatorStatusHistory
|
|
15
|
+
private readonly historyMap: AztecAsyncMap<`0x${string}`, Buffer>;
|
|
16
|
+
|
|
17
|
+
// a map from validator address to their historical epoch performance, evaluated at end-of-epoch.
|
|
18
|
+
// e.g. { validator: [{ epoch: 1, missed: 1, total: 10 }, { epoch: 2, missed: 3, total: 7 }, ...] }
|
|
19
|
+
private readonly epochMap: AztecAsyncMap<`0x${string}`, Buffer>;
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
private store: AztecAsyncKVStore,
|
|
23
|
+
private config: { historyLength: number; historicEpochPerformanceLength: number },
|
|
24
|
+
) {
|
|
25
|
+
this.historyMap = store.openMap('sentinel-validator-status');
|
|
26
|
+
this.epochMap = store.openMap('sentinel-validator-epoch');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public getHistoryLength() {
|
|
30
|
+
return this.config.historyLength;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public getHistoricEpochPerformanceLength() {
|
|
34
|
+
return this.config.historicEpochPerformanceLength;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async updateEpochPerformance(epoch: EpochNumber, performance: ValidatorsEpochPerformance) {
|
|
38
|
+
await this.store.transactionAsync(async () => {
|
|
39
|
+
for (const [who, { missed, total }] of Object.entries(performance)) {
|
|
40
|
+
await this.pushValidatorEpochPerformance({ who: EthAddress.fromString(who), missed, total, epoch });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async getEpochPerformance(who: EthAddress): Promise<{ missed: number; total: number; epoch: EpochNumber }[]> {
|
|
46
|
+
const currentPerformanceBuffer = await this.epochMap.getAsync(who.toString());
|
|
47
|
+
return currentPerformanceBuffer ? this.deserializePerformance(currentPerformanceBuffer) : [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private async pushValidatorEpochPerformance({
|
|
51
|
+
who,
|
|
52
|
+
missed,
|
|
53
|
+
total,
|
|
54
|
+
epoch,
|
|
55
|
+
}: {
|
|
56
|
+
who: EthAddress;
|
|
57
|
+
missed: number;
|
|
58
|
+
total: number;
|
|
59
|
+
epoch: EpochNumber;
|
|
60
|
+
}) {
|
|
61
|
+
const currentPerformance = await this.getEpochPerformance(who);
|
|
62
|
+
const existingIndex = currentPerformance.findIndex(p => p.epoch === epoch);
|
|
63
|
+
if (existingIndex !== -1) {
|
|
64
|
+
currentPerformance[existingIndex] = { missed, total, epoch };
|
|
65
|
+
} else {
|
|
66
|
+
currentPerformance.push({ missed, total, epoch });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// This should be sorted by epoch, but just in case.
|
|
70
|
+
// Since we keep the size small, this is not a big deal.
|
|
71
|
+
currentPerformance.sort((a, b) => Number(a.epoch - b.epoch));
|
|
72
|
+
|
|
73
|
+
// keep the most recent `historicEpochPerformanceLength` entries.
|
|
74
|
+
const performanceToKeep = currentPerformance.slice(-this.config.historicEpochPerformanceLength);
|
|
75
|
+
|
|
76
|
+
await this.epochMap.set(who.toString(), this.serializePerformance(performanceToKeep));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public async updateValidators(slot: SlotNumber, statuses: Record<`0x${string}`, ValidatorStatusInSlot | undefined>) {
|
|
80
|
+
await this.store.transactionAsync(async () => {
|
|
81
|
+
for (const [who, status] of Object.entries(statuses)) {
|
|
82
|
+
if (status) {
|
|
83
|
+
await this.pushValidatorStatusForSlot(EthAddress.fromString(who), slot, status);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private async pushValidatorStatusForSlot(who: EthAddress, slot: SlotNumber, status: ValidatorStatusInSlot) {
|
|
90
|
+
await this.store.transactionAsync(async () => {
|
|
91
|
+
const currentHistory = (await this.getHistory(who)) ?? [];
|
|
92
|
+
const newHistory = [...currentHistory, { slot, status }].slice(-this.config.historyLength);
|
|
93
|
+
await this.historyMap.set(who.toString(), this.serializeHistory(newHistory));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public async getHistories(): Promise<Record<`0x${string}`, ValidatorStatusHistory>> {
|
|
98
|
+
const histories: Record<`0x${string}`, ValidatorStatusHistory> = {};
|
|
99
|
+
for await (const [address, history] of this.historyMap.entriesAsync()) {
|
|
100
|
+
histories[address] = this.deserializeHistory(history);
|
|
101
|
+
}
|
|
102
|
+
return histories;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public async getHistory(address: EthAddress): Promise<ValidatorStatusHistory | undefined> {
|
|
106
|
+
const data = await this.historyMap.getAsync(address.toString());
|
|
107
|
+
return data && this.deserializeHistory(data);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private serializePerformance(performance: { missed: number; total: number; epoch: EpochNumber }[]): Buffer {
|
|
111
|
+
return serializeToBuffer(
|
|
112
|
+
performance.map(p => [numToUInt32BE(Number(p.epoch)), numToUInt32BE(p.missed), numToUInt32BE(p.total)]),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private deserializePerformance(buffer: Buffer): { missed: number; total: number; epoch: EpochNumber }[] {
|
|
117
|
+
const reader = new BufferReader(buffer);
|
|
118
|
+
const performance: { missed: number; total: number; epoch: EpochNumber }[] = [];
|
|
119
|
+
while (!reader.isEmpty()) {
|
|
120
|
+
performance.push({
|
|
121
|
+
epoch: EpochNumber(reader.readNumber()),
|
|
122
|
+
missed: reader.readNumber(),
|
|
123
|
+
total: reader.readNumber(),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return performance;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private serializeHistory(history: ValidatorStatusHistory): Buffer {
|
|
130
|
+
return serializeToBuffer(
|
|
131
|
+
history.map(h => [numToUInt32BE(Number(h.slot)), numToUInt8(this.statusToNumber(h.status))]),
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private deserializeHistory(buffer: Buffer): ValidatorStatusHistory {
|
|
136
|
+
const reader = new BufferReader(buffer);
|
|
137
|
+
const history: ValidatorStatusHistory = [];
|
|
138
|
+
while (!reader.isEmpty()) {
|
|
139
|
+
const slot = SlotNumber(reader.readNumber());
|
|
140
|
+
const status = this.statusFromNumber(reader.readUInt8());
|
|
141
|
+
history.push({ slot, status });
|
|
142
|
+
}
|
|
143
|
+
return history;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private statusToNumber(status: ValidatorStatusInSlot): number {
|
|
147
|
+
switch (status) {
|
|
148
|
+
case 'checkpoint-mined':
|
|
149
|
+
return 1;
|
|
150
|
+
case 'checkpoint-valid':
|
|
151
|
+
return 2;
|
|
152
|
+
case 'checkpoint-missed':
|
|
153
|
+
return 3;
|
|
154
|
+
case 'attestation-sent':
|
|
155
|
+
return 4;
|
|
156
|
+
case 'attestation-missed':
|
|
157
|
+
return 5;
|
|
158
|
+
case 'blocks-missed':
|
|
159
|
+
return 6;
|
|
160
|
+
case 'checkpoint-invalid':
|
|
161
|
+
return 7;
|
|
162
|
+
case 'checkpoint-unvalidated':
|
|
163
|
+
return 8;
|
|
164
|
+
default: {
|
|
165
|
+
const _exhaustive: never = status;
|
|
166
|
+
throw new Error(`Unknown status: ${status}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private statusFromNumber(status: number): ValidatorStatusInSlot {
|
|
172
|
+
switch (status) {
|
|
173
|
+
case 1:
|
|
174
|
+
return 'checkpoint-mined';
|
|
175
|
+
case 2:
|
|
176
|
+
return 'checkpoint-valid';
|
|
177
|
+
case 3:
|
|
178
|
+
return 'checkpoint-missed';
|
|
179
|
+
case 4:
|
|
180
|
+
return 'attestation-sent';
|
|
181
|
+
case 5:
|
|
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';
|
|
189
|
+
default:
|
|
190
|
+
throw new Error(`Unknown status: ${status}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { EpochCacheInterface } from '@aztec-labs/epoch-cache';
|
|
2
|
+
import type { P2P } from '@aztec-labs/p2p';
|
|
3
|
+
import { SequencerClient } from '@aztec-labs/sequencer-client';
|
|
4
|
+
import { DataWithholdingWatcher, type SlasherClientInterface } from '@aztec-labs/slasher';
|
|
5
|
+
import type { L2BlockSource } from '@aztec-labs/stdlib/block';
|
|
6
|
+
import type { ContractDataSource } from '@aztec-labs/stdlib/contract';
|
|
7
|
+
import type { L2LogsSource, Service, WorldStateSynchronizer } from '@aztec-labs/stdlib/interfaces/server';
|
|
8
|
+
import type { L1ToL2MessageSource } from '@aztec-labs/stdlib/messaging';
|
|
9
|
+
import type { GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec-labs/stdlib/tx';
|
|
10
|
+
|
|
11
|
+
import type { AztecNodeConfig } from '../aztec-node/config.js';
|
|
12
|
+
import { AztecNodeService } from '../aztec-node/server.js';
|
|
13
|
+
import { Sentinel } from '../sentinel/sentinel.js';
|
|
14
|
+
|
|
15
|
+
export declare class TestAztecNodeService extends AztecNodeService {
|
|
16
|
+
declare public config: AztecNodeConfig;
|
|
17
|
+
declare public p2pClient: P2P;
|
|
18
|
+
declare public blockSource: L2BlockSource & Partial<Service>;
|
|
19
|
+
declare public logsSource: L2LogsSource;
|
|
20
|
+
declare public contractDataSource: ContractDataSource;
|
|
21
|
+
declare public l1ToL2MessageSource: L1ToL2MessageSource;
|
|
22
|
+
declare public worldStateSynchronizer: WorldStateSynchronizer;
|
|
23
|
+
declare public sequencer: SequencerClient | undefined;
|
|
24
|
+
declare public slasherClient: SlasherClientInterface | undefined;
|
|
25
|
+
declare public validatorsSentinel: Sentinel | undefined;
|
|
26
|
+
declare public dataWithholdingWatcher: DataWithholdingWatcher | undefined;
|
|
27
|
+
declare public l1ChainId: number;
|
|
28
|
+
declare public version: number;
|
|
29
|
+
declare public globalVariableBuilder: GlobalVariableBuilderInterface;
|
|
30
|
+
declare public epochCache: EpochCacheInterface;
|
|
31
|
+
declare public packageVersion: string;
|
|
32
|
+
}
|