@aztec/aztec-node 5.0.0-private.20260319 → 5.0.0-rc.1
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 +14 -4
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +10 -5
- 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 +91 -100
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +1073 -492
- package/dest/bin/index.js +14 -9
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -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 +4 -2
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +4 -4
- package/dest/sentinel/sentinel.d.ts +133 -9
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +212 -70
- package/dest/sentinel/store.d.ts +8 -8
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +25 -17
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +27 -26
- package/src/aztec-node/block_response_helpers.ts +161 -0
- package/src/aztec-node/config.ts +23 -7
- 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 +1190 -625
- package/src/bin/index.ts +13 -11
- package/src/index.ts +1 -0
- package/src/sentinel/README.md +103 -0
- package/src/sentinel/config.ts +18 -6
- package/src/sentinel/factory.ts +7 -4
- package/src/sentinel/sentinel.ts +267 -82
- package/src/sentinel/store.ts +26 -18
- package/src/test/index.ts +2 -2
package/src/bin/index.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-warnings
|
|
2
|
+
import {
|
|
3
|
+
type NamespacedApiHandlers,
|
|
4
|
+
createNamespacedSafeJsonRpcServer,
|
|
5
|
+
startHttpRpcServer,
|
|
6
|
+
} from '@aztec/foundation/json-rpc/server';
|
|
2
7
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
4
|
-
import { createTracedJsonRpcServer } from '@aztec/telemetry-client';
|
|
8
|
+
import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
|
|
5
9
|
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '../index.js';
|
|
10
|
+
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars, registerAztecNodeRpcHandlers } from '../index.js';
|
|
9
11
|
|
|
10
12
|
const { AZTEC_NODE_PORT = 8081, API_PREFIX = '' } = process.env;
|
|
11
13
|
|
|
@@ -39,12 +41,12 @@ async function main() {
|
|
|
39
41
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
40
42
|
process.once('SIGTERM', shutdown);
|
|
41
43
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const services: NamespacedApiHandlers = {};
|
|
45
|
+
registerAztecNodeRpcHandlers(aztecNode, services);
|
|
46
|
+
const rpcServer = createNamespacedSafeJsonRpcServer(services, {
|
|
47
|
+
middlewares: [getOtelJsonRpcPropagationMiddleware()],
|
|
48
|
+
});
|
|
49
|
+
await startHttpRpcServer(rpcServer, { port: +AZTEC_NODE_PORT, apiPrefix: API_PREFIX });
|
|
48
50
|
logger.info(`Aztec Node JSON-RPC Server listening on port ${AZTEC_NODE_PORT}`);
|
|
49
51
|
}
|
|
50
52
|
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Sentinel
|
|
2
|
+
|
|
3
|
+
The Sentinel watches every committee member's behaviour each L2 slot, aggregates it into per-epoch performance once each epoch is fully observed, and emits inactivity slash payloads to the slasher.
|
|
4
|
+
|
|
5
|
+
## Responsibilities
|
|
6
|
+
|
|
7
|
+
- Classify per-slot proposer/attestor behaviour from local node observations.
|
|
8
|
+
- Persist a sliding window of per-slot history per validator.
|
|
9
|
+
- Roll up that history into per-epoch performance after each epoch ends.
|
|
10
|
+
- Decide which validators have been inactive for `slashInactivityConsecutiveEpochThreshold` consecutive epochs and emit `WANT_TO_SLASH_EVENT` with `OffenseType.INACTIVITY`.
|
|
11
|
+
- Expose validator stats to RPC consumers (`getValidatorStats`, `computeStats`).
|
|
12
|
+
|
|
13
|
+
The sentinel is one of several watchers registered with the slasher; it does not vote or publish to L1 itself.
|
|
14
|
+
|
|
15
|
+
## Inputs
|
|
16
|
+
|
|
17
|
+
| Source | What it provides |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `EpochCache` | Slot/epoch helpers, committee + proposer for a slot, escape-hatch state |
|
|
20
|
+
| `L2BlockSource` (archiver) | Synced slot, `chain-checkpointed` events, block headers |
|
|
21
|
+
| `P2PClient` | `getCheckpointAttestationsForSlot(slot, payloadHash)`, `hasBlockProposalsForSlot(slot)` |
|
|
22
|
+
| `CheckpointReexecutionTracker` | Local re-execution outcome for the proposal at each slot (`valid` / `invalid` / `unvalidated`) — populated by the validator client's `ProposalHandler` |
|
|
23
|
+
| L1-checkpointed events | `chain-checkpointed` populates `slotNumberToCheckpoint` with the canonical attestor set |
|
|
24
|
+
|
|
25
|
+
## Two cadences
|
|
26
|
+
|
|
27
|
+
`Sentinel.work()` runs every quarter L2 slot and drives two pipelines that operate independently:
|
|
28
|
+
|
|
29
|
+
### 1. Per-slot recording (lag = 2 slots)
|
|
30
|
+
|
|
31
|
+
`processSlot(currentSlot - 2)` runs once per slot. The 2-slot lag gives P2P attestations time to settle and lets the archiver catch up. It calls `getSlotActivity(slot, epoch, proposer, committee)` and writes per-validator statuses to `SentinelStore.historyMap`. History is a sliding window of `sentinelHistoryLengthInEpochs * epochDuration` slots (default 24 epochs).
|
|
32
|
+
|
|
33
|
+
If `EpochCache.getCommittee(slot)` reports `isEscapeHatchOpen`, the slot is recorded as processed without writing any per-validator entries.
|
|
34
|
+
|
|
35
|
+
### 2. Per-epoch evaluation (lag = `sentinelEpochEndBufferSlots` past the epoch's last slot)
|
|
36
|
+
|
|
37
|
+
`processEpochEnds(currentSlot)` checks whether any epoch is now fully observable and not yet evaluated. An epoch is eligible once both:
|
|
38
|
+
|
|
39
|
+
- the buffer has elapsed: `currentSlot − sentinelEpochEndBufferSlots ≥ lastSlotOfEpoch`, and
|
|
40
|
+
- per-slot recording has reached the epoch's last slot: `lastProcessedSlot ≥ lastSlotOfEpoch`.
|
|
41
|
+
|
|
42
|
+
When eligible, `handleEpochEnd(epoch)` aggregates the slot-level statuses for that epoch into per-validator `{missed, total}`, persists the result to `SentinelStore.epochMap` (default 2000-epoch window), and runs the inactivity check.
|
|
43
|
+
|
|
44
|
+
The aggregator catches up if multiple epochs become eligible at once (e.g. after a long backoff).
|
|
45
|
+
|
|
46
|
+
## Six-case taxonomy
|
|
47
|
+
|
|
48
|
+
For each slot, the proposer is assigned one of six statuses, ranked highest-confidence first:
|
|
49
|
+
|
|
50
|
+
| # | Status | Trigger | Inactive party |
|
|
51
|
+
|---|---|---|---|
|
|
52
|
+
| 6 | `checkpoint-mined` | `slotNumberToCheckpoint.has(slot)` (a checkpoint covering this slot has landed on L1) | Attestors who didn't attest |
|
|
53
|
+
| 5 | `checkpoint-valid` | `tracker.getOutcomeForSlot(slot) === 'valid'` | Attestors who didn't attest |
|
|
54
|
+
| 4 | `checkpoint-invalid` | `tracker.getOutcomeForSlot(slot) === 'invalid'` (re-executed and rejected) | Proposer |
|
|
55
|
+
| 3 | `checkpoint-unvalidated` | `tracker.getOutcomeForSlot(slot) === 'unvalidated'` (validation aborted: missing data, timeout, etc.) | Proposer |
|
|
56
|
+
| 2 | `checkpoint-missed` | `p2p.hasBlockProposalsForSlot(slot)` true (blocks seen but no checkpoint proposal observed) | Proposer |
|
|
57
|
+
| 1 | `blocks-missed` | None of the above (no block proposals observed) | Proposer |
|
|
58
|
+
|
|
59
|
+
Missing-attestor faults are only recorded in cases 5 and 6 — where the local node has positive evidence the checkpoint was valid or canonical. In cases 1–4 the proposer is at fault and no attestor penalty applies.
|
|
60
|
+
|
|
61
|
+
Each non-proposer committee member is tagged:
|
|
62
|
+
|
|
63
|
+
- `attestation-sent` — attestation seen on P2P (with valid signature) or in the L1 checkpoint's attestor set
|
|
64
|
+
- `attestation-missed` — only when proposer status is case 5 or 6 and the validator's attestation was not seen
|
|
65
|
+
- none — otherwise
|
|
66
|
+
|
|
67
|
+
## Inactivity slashing
|
|
68
|
+
|
|
69
|
+
`handleEpochPerformance(epoch, performance)`:
|
|
70
|
+
|
|
71
|
+
1. Filter validators where `missed / total ≥ slashInactivityTargetPercentage`.
|
|
72
|
+
2. For each, call `checkPastInactivity` to require `slashInactivityConsecutiveEpochThreshold − 1` past epochs (from `SentinelStore.epochMap`) over the same threshold. Epochs where the validator was not on a committee are skipped, not counted against the streak.
|
|
73
|
+
3. Emit a single `WANT_TO_SLASH_EVENT` with one `WantToSlashArgs` per qualifying validator.
|
|
74
|
+
|
|
75
|
+
`{missed, total}` only counts slots that had something happen (a proposal, an attestation, or a missed proposal opportunity). Slots where the validator was on the committee but no proposal occurred and they were not the proposer don't show up in either count — that prevents an offline validator from appearing as "5/10 missed" simply because half the epoch had no proposals.
|
|
76
|
+
|
|
77
|
+
## Storage
|
|
78
|
+
|
|
79
|
+
`SentinelStore` is an LMDB-backed KV store with two maps:
|
|
80
|
+
|
|
81
|
+
- `historyMap` — validator address → serialized `[(slot, status)]` rolling window
|
|
82
|
+
- `epochMap` — validator address → serialized `[{epoch, missed, total}]` rolling window
|
|
83
|
+
|
|
84
|
+
`SCHEMA_VERSION` controls on-disk compatibility; bumping it wipes the store on next open. The encoded status numbers live in `SentinelStore.statusToNumber`/`statusFromNumber`.
|
|
85
|
+
|
|
86
|
+
## Configuration
|
|
87
|
+
|
|
88
|
+
| Key | Env var | Default | Purpose |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `sentinelEnabled` | `SENTINEL_ENABLED` | `false` | Master switch |
|
|
91
|
+
| `sentinelHistoryLengthInEpochs` | `SENTINEL_HISTORY_LENGTH_IN_EPOCHS` | `24` | Slot-history window, in epochs |
|
|
92
|
+
| `sentinelHistoricEpochPerformanceLengthInEpochs` | `SENTINEL_HISTORIC_EPOCH_PERFORMANCE_LENGTH_IN_EPOCHS` | `2000` | Per-epoch performance window |
|
|
93
|
+
| `sentinelEpochEndBufferSlots` | `SENTINEL_EPOCH_END_BUFFER_SLOTS` | `2` | Slots to wait past an epoch's last slot before evaluating it |
|
|
94
|
+
|
|
95
|
+
The sentinel also reads slashing thresholds and L1 chain identifiers from `SentinelRuntimeConfig` (see `sentinel.ts`).
|
|
96
|
+
|
|
97
|
+
## Files
|
|
98
|
+
|
|
99
|
+
- `sentinel.ts` — main class
|
|
100
|
+
- `store.ts` — KV-backed persistence
|
|
101
|
+
- `config.ts` — `SentinelConfig` and env-var mappings
|
|
102
|
+
- `factory.ts` — `createSentinel` factory used by `AztecNodeService`
|
|
103
|
+
- `sentinel.test.ts` / `store.test.ts` — unit tests
|
package/src/sentinel/config.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { type ConfigMappingsType, booleanConfigHelper, numberConfigHelper } from
|
|
|
2
2
|
|
|
3
3
|
export type SentinelConfig = {
|
|
4
4
|
sentinelHistoryLengthInEpochs: number;
|
|
5
|
-
|
|
5
|
+
sentinelHistoricEpochPerformanceLengthInEpochs: number;
|
|
6
6
|
sentinelEnabled: boolean;
|
|
7
|
+
sentinelEpochEndBufferSlots: number;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
export const sentinelConfigMappings: ConfigMappingsType<SentinelConfig> = {
|
|
@@ -13,8 +14,9 @@ export const sentinelConfigMappings: ConfigMappingsType<SentinelConfig> = {
|
|
|
13
14
|
...numberConfigHelper(24),
|
|
14
15
|
},
|
|
15
16
|
/**
|
|
16
|
-
* The number of L2 epochs kept of
|
|
17
|
-
*
|
|
17
|
+
* The number of L2 epochs kept of per-epoch performance history for each validator. End-of-epoch
|
|
18
|
+
* activity is recorded here and used to decide consecutive-epoch inactivity slashing.
|
|
19
|
+
* This value must be large enough so that we have epoch performance for every validator
|
|
18
20
|
* for at least slashInactivityConsecutiveEpochThreshold. Assuming this value is 3,
|
|
19
21
|
* and the committee size is 48, and we have 10k validators, then we pick 48 out of 10k each draw.
|
|
20
22
|
* For any fixed element, per-draw prob = 48/10000 = 0.0048.
|
|
@@ -24,9 +26,9 @@ export const sentinelConfigMappings: ConfigMappingsType<SentinelConfig> = {
|
|
|
24
26
|
* - 95% chance: n = 1310
|
|
25
27
|
* - 99% chance: n = 1749
|
|
26
28
|
*/
|
|
27
|
-
|
|
28
|
-
description: 'The number of L2 epochs kept of
|
|
29
|
-
env: '
|
|
29
|
+
sentinelHistoricEpochPerformanceLengthInEpochs: {
|
|
30
|
+
description: 'The number of L2 epochs kept of per-epoch performance history for each validator.',
|
|
31
|
+
env: 'SENTINEL_HISTORIC_EPOCH_PERFORMANCE_LENGTH_IN_EPOCHS',
|
|
30
32
|
...numberConfigHelper(2000),
|
|
31
33
|
},
|
|
32
34
|
sentinelEnabled: {
|
|
@@ -34,4 +36,14 @@ export const sentinelConfigMappings: ConfigMappingsType<SentinelConfig> = {
|
|
|
34
36
|
env: 'SENTINEL_ENABLED',
|
|
35
37
|
...booleanConfigHelper(false),
|
|
36
38
|
},
|
|
39
|
+
/**
|
|
40
|
+
* Number of L2 slots to wait after the end of an epoch before computing the epoch's performance.
|
|
41
|
+
* The buffer allows P2P attestations and the local archiver to settle. Higher values reduce the
|
|
42
|
+
* risk of misjudging late-arriving activity at the cost of delayed slashing.
|
|
43
|
+
*/
|
|
44
|
+
sentinelEpochEndBufferSlots: {
|
|
45
|
+
description: 'Number of L2 slots after the end of an epoch before the sentinel evaluates it.',
|
|
46
|
+
env: 'SENTINEL_EPOCH_END_BUFFER_SLOTS',
|
|
47
|
+
...numberConfigHelper(2),
|
|
48
|
+
},
|
|
37
49
|
};
|
package/src/sentinel/factory.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
3
3
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
4
4
|
import type { P2PClient } from '@aztec/p2p';
|
|
5
5
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
6
|
+
import type { CheckpointReexecutionTracker } from '@aztec/stdlib/checkpoint';
|
|
7
|
+
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
6
8
|
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
7
9
|
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
8
10
|
|
|
@@ -14,7 +16,8 @@ export async function createSentinel(
|
|
|
14
16
|
epochCache: EpochCache,
|
|
15
17
|
archiver: L2BlockSource,
|
|
16
18
|
p2p: P2PClient,
|
|
17
|
-
|
|
19
|
+
reexecutionTracker: CheckpointReexecutionTracker,
|
|
20
|
+
config: SentinelConfig & DataStoreConfig & SlasherConfig & Pick<ChainConfig, 'l1ChainId' | 'rollupAddress'>,
|
|
18
21
|
logger = createLogger('node:sentinel'),
|
|
19
22
|
): Promise<Sentinel | undefined> {
|
|
20
23
|
if (!config.sentinelEnabled) {
|
|
@@ -22,10 +25,10 @@ export async function createSentinel(
|
|
|
22
25
|
}
|
|
23
26
|
const kvStore = await createStore('sentinel', SentinelStore.SCHEMA_VERSION, config, logger.getBindings());
|
|
24
27
|
const storeHistoryLength = config.sentinelHistoryLengthInEpochs * epochCache.getL1Constants().epochDuration;
|
|
25
|
-
const
|
|
28
|
+
const storeHistoricEpochPerformanceLength = config.sentinelHistoricEpochPerformanceLengthInEpochs;
|
|
26
29
|
const sentinelStore = new SentinelStore(kvStore, {
|
|
27
30
|
historyLength: storeHistoryLength,
|
|
28
|
-
|
|
31
|
+
historicEpochPerformanceLength: storeHistoricEpochPerformanceLength,
|
|
29
32
|
});
|
|
30
|
-
return new Sentinel(epochCache, archiver, p2p, sentinelStore, config, logger);
|
|
33
|
+
return new Sentinel(epochCache, archiver, p2p, sentinelStore, reexecutionTracker, config, logger);
|
|
31
34
|
}
|