@aztec/validator-client 0.0.1-commit.e558bd1c → 0.0.1-commit.e588bc7e5
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 +51 -10
- package/dest/checkpoint_builder.d.ts +21 -8
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +124 -46
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +26 -6
- package/dest/duties/validation_service.d.ts +2 -2
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +6 -12
- package/dest/factory.d.ts +7 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +6 -5
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/key_store/ha_key_store.js +1 -1
- package/dest/metrics.d.ts +10 -2
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +12 -0
- package/dest/proposal_handler.d.ts +107 -0
- package/dest/proposal_handler.d.ts.map +1 -0
- package/dest/proposal_handler.js +963 -0
- package/dest/validator.d.ts +34 -17
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +157 -191
- package/package.json +19 -19
- package/src/checkpoint_builder.ts +142 -39
- package/src/config.ts +26 -6
- package/src/duties/validation_service.ts +12 -11
- package/src/factory.ts +9 -3
- package/src/index.ts +1 -2
- package/src/key_store/ha_key_store.ts +1 -1
- package/src/metrics.ts +19 -1
- package/src/proposal_handler.ts +1027 -0
- package/src/validator.ts +214 -212
- package/dest/block_proposal_handler.d.ts +0 -63
- package/dest/block_proposal_handler.d.ts.map +0 -1
- package/dest/block_proposal_handler.js +0 -546
- package/dest/tx_validator/index.d.ts +0 -3
- package/dest/tx_validator/index.d.ts.map +0 -1
- package/dest/tx_validator/index.js +0 -2
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -19
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -54
- package/src/block_proposal_handler.ts +0 -555
- package/src/tx_validator/index.ts +0 -2
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -154
package/README.md
CHANGED
|
@@ -78,6 +78,7 @@ These rules must always hold:
|
|
|
78
78
|
3. **inHash is constant**: All blocks in a checkpoint share the same L1-to-L2 messages hash
|
|
79
79
|
4. **Sequential indexWithinCheckpoint**: Block N must have `indexWithinCheckpoint = parent.indexWithinCheckpoint + 1`
|
|
80
80
|
5. **One proposer per slot**: Each slot has exactly one designated proposer. Sending multiple proposals for the same position (slot, indexWithinCheckpoint) with different content is equivocation and slashable
|
|
81
|
+
6. **One attestation per slot**: Validators should only attest to one checkpoint per slot. Attesting to different proposals (different archives) for the same slot is equivocation and slashable
|
|
81
82
|
|
|
82
83
|
## Validation Flow
|
|
83
84
|
|
|
@@ -155,16 +156,15 @@ Time | Proposer | Validator
|
|
|
155
156
|
|
|
156
157
|
## Configuration
|
|
157
158
|
|
|
158
|
-
| Flag | Purpose
|
|
159
|
-
| ------------------------------------- |
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
| `
|
|
163
|
-
| `
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
167
|
-
| `disabledValidators` | Validator addresses to exclude from duties |
|
|
159
|
+
| Flag | Purpose |
|
|
160
|
+
| ------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
161
|
+
| `fishermanMode` | Validate proposals but don't broadcast attestations (monitoring only) |
|
|
162
|
+
| `alwaysReexecuteBlockProposals` | Force re-execution even when not in committee |
|
|
163
|
+
| `slashBroadcastedInvalidBlockPenalty` | Penalty amount for invalid proposals (0 = disabled) |
|
|
164
|
+
| `slashDuplicateProposalPenalty` | Penalty amount for duplicate proposals (0 = disabled) |
|
|
165
|
+
| `slashDuplicateAttestationPenalty` | Penalty amount for duplicate attestations (0 = disabled) |
|
|
166
|
+
| `attestationPollingIntervalMs` | How often to poll for attestations when collecting |
|
|
167
|
+
| `disabledValidators` | Validator addresses to exclude from duties |
|
|
168
168
|
|
|
169
169
|
### High Availability (HA) Keystore
|
|
170
170
|
|
|
@@ -221,6 +221,47 @@ This is useful for monitoring network health without participating in consensus.
|
|
|
221
221
|
- `createCheckpointProposal(...)` → `CheckpointProposal`: Signs checkpoint proposal
|
|
222
222
|
- `attestToCheckpointProposal(proposal, attestors)` → `CheckpointAttestation[]`: Creates attestations for given addresses
|
|
223
223
|
|
|
224
|
+
## Block Building Limits
|
|
225
|
+
|
|
226
|
+
L1 enforces gas and blob capacity per checkpoint. The node enforces these during block building to avoid L1 rejection. Three dimensions are metered: L2 gas (mana), DA gas, and blob fields. DA gas maps to blob fields today (`daGas = blobFields * 32`) but both are tracked independently.
|
|
227
|
+
|
|
228
|
+
### Checkpoint limits
|
|
229
|
+
|
|
230
|
+
| Dimension | Source | Budget |
|
|
231
|
+
| --- | --- | --- |
|
|
232
|
+
| L2 gas (mana) | `rollup.getManaLimit()` | Fetched from L1 at startup |
|
|
233
|
+
| DA gas | `MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT` | 786,432 (6 blobs × 4096 fields × 32 gas/field) |
|
|
234
|
+
| Blob fields | `BLOBS_PER_CHECKPOINT × FIELDS_PER_BLOB` | 24,576 minus checkpoint/block-end overhead |
|
|
235
|
+
|
|
236
|
+
### Per-block budgets
|
|
237
|
+
|
|
238
|
+
Per-block budgets prevent one block from consuming the entire checkpoint budget. The checkpoint builder dynamically computes per-block limits before each block based on the remaining checkpoint budget and the number of remaining blocks.
|
|
239
|
+
|
|
240
|
+
**Proposer**: When building a proposal (`isBuildingProposal: true`), the `CheckpointProposalJob` passes `maxBlocksPerCheckpoint` (from the timetable) and `perBlockAllocationMultiplier` (default 1.2) via opts to `CheckpointBuilder.buildBlock`. The builder computes a fair share as `min(perBlockLimit, ceil(remainingBudget / remainingBlocks * multiplier), remainingBudget)`. The multiplier greater than 1 allows early blocks to use more than their even share, since different blocks hit different limit dimensions (L2 gas, DA gas, blob fields) — a strict even split would waste capacity. As prior blocks consume budget, later blocks see tightened limits. This applies to all four dimensions (L2 gas, DA gas, blob fields, transaction count). Operators can set hard per-block caps via `SEQ_MAX_L2_BLOCK_GAS` / `SEQ_MAX_DA_BLOCK_GAS` / `SEQ_MAX_TX_PER_BLOCK` (capped at checkpoint limits at startup); these act as additional upper bounds alongside the redistribution.
|
|
241
|
+
|
|
242
|
+
**Validator**: When re-executing a proposal (`isBuildingProposal` unset), `capLimitsByCheckpointBudgets` only caps by the per-block limit and the total remaining checkpoint budget — no redistribution or multiplier is applied. This avoids false rejections due to differences between proposer and validator fair-share calculations. Validators can optionally set hard per-block limits via `VALIDATOR_MAX_L2_BLOCK_GAS`, `VALIDATOR_MAX_DA_BLOCK_GAS`, and `VALIDATOR_MAX_TX_PER_BLOCK`. When unset, no per-block limit is enforced (checkpoint-level protocol limits still apply). These are independent of the `SEQ_` vars so operators can tune proposer and validation limits separately.
|
|
243
|
+
|
|
244
|
+
### Per-transaction enforcement
|
|
245
|
+
|
|
246
|
+
**Mempool entry** (`GasLimitsValidator`): L2 gas must be ≤ `MAX_PROCESSABLE_L2_GAS` (6,540,000) and ≥ fixed minimums.
|
|
247
|
+
|
|
248
|
+
**Block building** (`PublicProcessor.process`): Before processing, txs are skipped if their estimated blob fields or gas limits would exceed the block budget. After processing, actual values are checked and the tx is reverted if limits are exceeded.
|
|
249
|
+
|
|
250
|
+
### Gas limit configuration
|
|
251
|
+
|
|
252
|
+
| Variable | Default | Description |
|
|
253
|
+
| --- | --- | --- |
|
|
254
|
+
| `SEQ_MAX_L2_BLOCK_GAS` | *none* | Hard per-block L2 gas cap. Capped at `rollupManaLimit` at startup. When unset, redistribution dynamically computes per-block limits. |
|
|
255
|
+
| `SEQ_MAX_DA_BLOCK_GAS` | *none* | Hard per-block DA gas cap. Capped at `MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT` at startup. When unset, redistribution handles it. |
|
|
256
|
+
| `SEQ_MAX_TX_PER_BLOCK` | *none* | Hard per-block tx count cap. Capped at `SEQ_MAX_TX_PER_CHECKPOINT` at startup (if set). |
|
|
257
|
+
| `SEQ_MAX_TX_PER_CHECKPOINT` | *none* | Total txs across all blocks in a checkpoint. When set, checkpoint-level capping and redistribution are enforced for tx count. |
|
|
258
|
+
| `SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER` | 1.2 | Multiplier for per-block budget redistribution. Passed via opts to the checkpoint builder during proposal building. |
|
|
259
|
+
| `SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET` | true | Legacy flag; redistribution is now always active during proposal building and inactive during validation. |
|
|
260
|
+
| `VALIDATOR_MAX_L2_BLOCK_GAS` | *none* | Per-block L2 gas limit for validation. Proposals exceeding this are rejected. |
|
|
261
|
+
| `VALIDATOR_MAX_DA_BLOCK_GAS` | *none* | Per-block DA gas limit for validation. Proposals exceeding this are rejected. |
|
|
262
|
+
| `VALIDATOR_MAX_TX_PER_BLOCK` | *none* | Per-block tx count limit for validation. Proposals exceeding this are rejected. |
|
|
263
|
+
| `VALIDATOR_MAX_TX_PER_CHECKPOINT` | *none* | Per-checkpoint tx count limit for validation. Proposals exceeding this are rejected. |
|
|
264
|
+
|
|
224
265
|
## Testing Patterns
|
|
225
266
|
|
|
226
267
|
### Common Mocks
|
|
@@ -3,12 +3,13 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
4
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
5
|
import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
|
|
6
|
-
import { PublicProcessor } from '@aztec/simulator/server';
|
|
6
|
+
import { PublicContractsDB, PublicProcessor } from '@aztec/simulator/server';
|
|
7
7
|
import { L2Block } from '@aztec/stdlib/block';
|
|
8
8
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
9
9
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
10
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
11
|
-
import { type BuildBlockInCheckpointResult, type FullNodeBlockBuilderConfig, type ICheckpointBlockBuilder, type ICheckpointsBuilder, type MerkleTreeWriteOperations, type PublicProcessorLimits, type WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
11
|
+
import { type BlockBuilderOptions, type BuildBlockInCheckpointResult, type FullNodeBlockBuilderConfig, type ICheckpointBlockBuilder, type ICheckpointsBuilder, type MerkleTreeWriteOperations, type PublicProcessorLimits, type WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
12
|
+
import { type DebugLogStore } from '@aztec/stdlib/logs';
|
|
12
13
|
import { type CheckpointGlobalVariables, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
|
|
13
14
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
14
15
|
export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/server';
|
|
@@ -23,19 +24,30 @@ export declare class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
23
24
|
private contractDataSource;
|
|
24
25
|
private dateProvider;
|
|
25
26
|
private telemetryClient;
|
|
27
|
+
private debugLogStore;
|
|
26
28
|
private log;
|
|
27
|
-
|
|
29
|
+
/** Persistent contracts DB shared across all blocks in this checkpoint. */
|
|
30
|
+
protected contractsDB: PublicContractsDB;
|
|
31
|
+
constructor(checkpointBuilder: LightweightCheckpointBuilder, fork: MerkleTreeWriteOperations, config: FullNodeBlockBuilderConfig, contractDataSource: ContractDataSource, dateProvider: DateProvider, telemetryClient: TelemetryClient, bindings?: LoggerBindings, debugLogStore?: DebugLogStore);
|
|
28
32
|
getConstantData(): CheckpointGlobalVariables;
|
|
29
33
|
/**
|
|
30
34
|
* Builds a single block within this checkpoint.
|
|
35
|
+
* Automatically caps gas and blob field limits based on checkpoint-level budgets and prior blocks.
|
|
31
36
|
*/
|
|
32
|
-
buildBlock(pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, blockNumber: BlockNumber, timestamp: bigint, opts
|
|
37
|
+
buildBlock(pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, blockNumber: BlockNumber, timestamp: bigint, opts: BlockBuilderOptions & {
|
|
33
38
|
expectedEndState?: StateReference;
|
|
34
39
|
}): Promise<BuildBlockInCheckpointResult>;
|
|
35
40
|
/** Completes the checkpoint and returns it. */
|
|
36
41
|
completeCheckpoint(): Promise<Checkpoint>;
|
|
37
42
|
/** Gets the checkpoint currently in progress. */
|
|
38
43
|
getCheckpoint(): Promise<Checkpoint>;
|
|
44
|
+
/**
|
|
45
|
+
* Caps per-block gas and blob field limits by remaining checkpoint-level budgets.
|
|
46
|
+
* When building a proposal (isBuildingProposal=true), computes a fair share of remaining budget
|
|
47
|
+
* across remaining blocks scaled by the multiplier. When validating, only caps by per-block limit
|
|
48
|
+
* and remaining checkpoint budget (no redistribution or multiplier).
|
|
49
|
+
*/
|
|
50
|
+
protected capLimitsByCheckpointBudgets(opts: BlockBuilderOptions): Pick<PublicProcessorLimits, 'maxBlockGas' | 'maxBlobFields' | 'maxTransactions'>;
|
|
39
51
|
protected makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations): Promise<{
|
|
40
52
|
processor: PublicProcessor;
|
|
41
53
|
validator: import("@aztec/stdlib/interfaces/server").PublicProcessorValidator;
|
|
@@ -48,19 +60,20 @@ export declare class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
48
60
|
private contractDataSource;
|
|
49
61
|
private dateProvider;
|
|
50
62
|
private telemetryClient;
|
|
63
|
+
private debugLogStore;
|
|
51
64
|
private log;
|
|
52
|
-
constructor(config: FullNodeBlockBuilderConfig & Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>, worldState: WorldStateSynchronizer, contractDataSource: ContractDataSource, dateProvider: DateProvider, telemetryClient?: TelemetryClient);
|
|
65
|
+
constructor(config: FullNodeBlockBuilderConfig & Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>, worldState: WorldStateSynchronizer, contractDataSource: ContractDataSource, dateProvider: DateProvider, telemetryClient?: TelemetryClient, debugLogStore?: DebugLogStore);
|
|
53
66
|
getConfig(): FullNodeBlockBuilderConfig;
|
|
54
67
|
updateConfig(config: Partial<FullNodeBlockBuilderConfig>): void;
|
|
55
68
|
/**
|
|
56
69
|
* Starts a new checkpoint and returns a CheckpointBuilder to build blocks within it.
|
|
57
70
|
*/
|
|
58
|
-
startCheckpoint(checkpointNumber: CheckpointNumber, constants: CheckpointGlobalVariables, l1ToL2Messages: Fr[], previousCheckpointOutHashes: Fr[], fork: MerkleTreeWriteOperations, bindings?: LoggerBindings): Promise<CheckpointBuilder>;
|
|
71
|
+
startCheckpoint(checkpointNumber: CheckpointNumber, constants: CheckpointGlobalVariables, feeAssetPriceModifier: bigint, l1ToL2Messages: Fr[], previousCheckpointOutHashes: Fr[], fork: MerkleTreeWriteOperations, bindings?: LoggerBindings): Promise<CheckpointBuilder>;
|
|
59
72
|
/**
|
|
60
73
|
* Opens a checkpoint, either starting fresh or resuming from existing blocks.
|
|
61
74
|
*/
|
|
62
|
-
openCheckpoint(checkpointNumber: CheckpointNumber, constants: CheckpointGlobalVariables, l1ToL2Messages: Fr[], previousCheckpointOutHashes: Fr[], fork: MerkleTreeWriteOperations, existingBlocks?: L2Block[], bindings?: LoggerBindings): Promise<CheckpointBuilder>;
|
|
75
|
+
openCheckpoint(checkpointNumber: CheckpointNumber, constants: CheckpointGlobalVariables, feeAssetPriceModifier: bigint, l1ToL2Messages: Fr[], previousCheckpointOutHashes: Fr[], fork: MerkleTreeWriteOperations, existingBlocks?: L2Block[], bindings?: LoggerBindings): Promise<CheckpointBuilder>;
|
|
63
76
|
/** Returns a fork of the world state at the given block number. */
|
|
64
77
|
getFork(blockNumber: BlockNumber): Promise<MerkleTreeWriteOperations>;
|
|
65
78
|
}
|
|
66
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
79
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2twb2ludF9idWlsZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY2hlY2twb2ludF9idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRSxXQUFXLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVoRixPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUFlLEtBQUssY0FBYyxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBRXZGLE9BQU8sRUFBRSxZQUFZLEVBQVcsTUFBTSx5QkFBeUIsQ0FBQztBQUVoRSxPQUFPLEVBQUUsNEJBQTRCLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUMxRSxPQUFPLEVBRUwsaUJBQWlCLEVBQ2pCLGVBQWUsRUFFaEIsTUFBTSx5QkFBeUIsQ0FBQztBQUNqQyxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDOUMsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQ3RELE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVyRSxPQUFPLEVBQ0wsS0FBSyxtQkFBbUIsRUFDeEIsS0FBSyw0QkFBNEIsRUFDakMsS0FBSywwQkFBMEIsRUFFL0IsS0FBSyx1QkFBdUIsRUFDNUIsS0FBSyxtQkFB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FBRyxPQUFPLENBQUMseUJBQXlCLENBQUMsQ0FFcEU7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint_builder.d.ts","sourceRoot":"","sources":["../src/checkpoint_builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkpoint_builder.d.ts","sourceRoot":"","sources":["../src/checkpoint_builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAW,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAEL,iBAAiB,EACjB,eAAe,EAEhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAE/B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EAExB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AAE3E,OAAO,EAAE,KAAK,yBAAyB,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAE,KAAK,eAAe,EAAsB,MAA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C,yBAAyB,CAAC,CAEpE;CACF"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NUM_CHECKPOINT_END_MARKER_FIELDS, getNumBlockEndBlobFields } from '@aztec/blob-lib/encoding';
|
|
2
|
+
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
|
|
3
|
+
import { merge, pick, sum } from '@aztec/foundation/collection';
|
|
2
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
5
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
4
6
|
import { elapsed } from '@aztec/foundation/timer';
|
|
5
|
-
import { getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
|
|
7
|
+
import { createTxValidatorForBlockBuilding, getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
|
|
6
8
|
import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
|
|
7
9
|
import { GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor, createPublicTxSimulatorForBlockBuilding } from '@aztec/simulator/server';
|
|
8
10
|
import { Gas } from '@aztec/stdlib/gas';
|
|
9
|
-
import { FullNodeBlockBuilderConfigKeys,
|
|
11
|
+
import { FullNodeBlockBuilderConfigKeys, InsufficientValidTxsError } from '@aztec/stdlib/interfaces/server';
|
|
12
|
+
import { NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
10
13
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
11
14
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
12
15
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
13
|
-
import {
|
|
16
|
+
import { ForkCheckpoint } from '@aztec/world-state';
|
|
14
17
|
/**
|
|
15
18
|
* Builder for a single checkpoint. Handles building blocks within the checkpoint
|
|
16
19
|
* and completing it.
|
|
@@ -21,25 +24,30 @@ import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_fac
|
|
|
21
24
|
contractDataSource;
|
|
22
25
|
dateProvider;
|
|
23
26
|
telemetryClient;
|
|
27
|
+
debugLogStore;
|
|
24
28
|
log;
|
|
25
|
-
|
|
29
|
+
/** Persistent contracts DB shared across all blocks in this checkpoint. */ contractsDB;
|
|
30
|
+
constructor(checkpointBuilder, fork, config, contractDataSource, dateProvider, telemetryClient, bindings, debugLogStore = new NullDebugLogStore()){
|
|
26
31
|
this.checkpointBuilder = checkpointBuilder;
|
|
27
32
|
this.fork = fork;
|
|
28
33
|
this.config = config;
|
|
29
34
|
this.contractDataSource = contractDataSource;
|
|
30
35
|
this.dateProvider = dateProvider;
|
|
31
36
|
this.telemetryClient = telemetryClient;
|
|
37
|
+
this.debugLogStore = debugLogStore;
|
|
32
38
|
this.log = createLogger('checkpoint-builder', {
|
|
33
39
|
...bindings,
|
|
34
40
|
instanceId: `checkpoint-${checkpointBuilder.checkpointNumber}`
|
|
35
41
|
});
|
|
42
|
+
this.contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
|
|
36
43
|
}
|
|
37
44
|
getConstantData() {
|
|
38
45
|
return this.checkpointBuilder.constants;
|
|
39
46
|
}
|
|
40
47
|
/**
|
|
41
48
|
* Builds a single block within this checkpoint.
|
|
42
|
-
|
|
49
|
+
* Automatically caps gas and blob field limits based on checkpoint-level budgets and prior blocks.
|
|
50
|
+
*/ async buildBlock(pendingTxs, blockNumber, timestamp, opts) {
|
|
43
51
|
const slot = this.checkpointBuilder.constants.slotNumber;
|
|
44
52
|
this.log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, {
|
|
45
53
|
slot,
|
|
@@ -59,32 +67,50 @@ import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_fac
|
|
|
59
67
|
gasFees: constants.gasFees
|
|
60
68
|
});
|
|
61
69
|
const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
throw new NoValidTxsError(failedTxs);
|
|
67
|
-
}
|
|
68
|
-
// Add block to checkpoint
|
|
69
|
-
const block = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
|
|
70
|
-
expectedEndState: opts.expectedEndState
|
|
71
|
-
});
|
|
72
|
-
// How much public gas was processed
|
|
73
|
-
const publicGas = processedTxs.reduce((acc, tx)=>acc.add(tx.gasUsed.publicGas), Gas.empty());
|
|
74
|
-
this.log.debug('Built block within checkpoint', {
|
|
75
|
-
header: block.header.toInspect(),
|
|
76
|
-
processedTxs: processedTxs.map((tx)=>tx.hash.toString()),
|
|
77
|
-
failedTxs: failedTxs.map((tx)=>tx.tx.txHash.toString())
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
block,
|
|
81
|
-
publicGas,
|
|
82
|
-
publicProcessorDuration,
|
|
83
|
-
numTxs: processedTxs.length,
|
|
84
|
-
failedTxs,
|
|
85
|
-
usedTxs,
|
|
86
|
-
usedTxBlobFields
|
|
70
|
+
// Cap gas limits amd available blob fields by remaining checkpoint-level budgets
|
|
71
|
+
const cappedOpts = {
|
|
72
|
+
...opts,
|
|
73
|
+
...this.capLimitsByCheckpointBudgets(opts)
|
|
87
74
|
};
|
|
75
|
+
// Create a block-level checkpoint on the contracts DB so we can roll back on failure
|
|
76
|
+
this.contractsDB.createCheckpoint();
|
|
77
|
+
// We execute all merkle tree operations on a world state fork checkpoint
|
|
78
|
+
// This enables us to discard all modifications in the event that we fail to successfully process sufficient transactions
|
|
79
|
+
const forkCheckpoint = await ForkCheckpoint.new(this.fork);
|
|
80
|
+
try {
|
|
81
|
+
const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(()=>processor.process(pendingTxs, cappedOpts, validator));
|
|
82
|
+
// Throw before updating state if we don't have enough valid txs
|
|
83
|
+
const minValidTxs = opts.minValidTxs ?? 0;
|
|
84
|
+
if (processedTxs.length < minValidTxs) {
|
|
85
|
+
throw new InsufficientValidTxsError(processedTxs.length, minValidTxs, failedTxs);
|
|
86
|
+
}
|
|
87
|
+
// Commit the fork checkpoint
|
|
88
|
+
await forkCheckpoint.commit();
|
|
89
|
+
// Add block to checkpoint
|
|
90
|
+
const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
|
|
91
|
+
expectedEndState: opts.expectedEndState
|
|
92
|
+
});
|
|
93
|
+
this.contractsDB.commitCheckpoint();
|
|
94
|
+
this.log.debug('Built block within checkpoint', {
|
|
95
|
+
header: block.header.toInspect(),
|
|
96
|
+
processedTxs: processedTxs.map((tx)=>tx.hash.toString()),
|
|
97
|
+
failedTxs: failedTxs.map((tx)=>tx.tx.txHash.toString())
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
block,
|
|
101
|
+
publicProcessorDuration,
|
|
102
|
+
numTxs: processedTxs.length,
|
|
103
|
+
failedTxs,
|
|
104
|
+
usedTxs
|
|
105
|
+
};
|
|
106
|
+
} catch (err) {
|
|
107
|
+
// Revert all changes to contracts db
|
|
108
|
+
this.contractsDB.revertCheckpoint();
|
|
109
|
+
// If we reached the point of committing the checkpoint, this does nothing
|
|
110
|
+
// Otherwise it reverts any changes made to the fork for this failed block
|
|
111
|
+
await forkCheckpoint.revert();
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
88
114
|
}
|
|
89
115
|
/** Completes the checkpoint and returns it. */ async completeCheckpoint() {
|
|
90
116
|
const checkpoint = await this.checkpointBuilder.completeCheckpoint();
|
|
@@ -98,14 +124,62 @@ import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_fac
|
|
|
98
124
|
/** Gets the checkpoint currently in progress. */ getCheckpoint() {
|
|
99
125
|
return this.checkpointBuilder.clone().completeCheckpoint();
|
|
100
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Caps per-block gas and blob field limits by remaining checkpoint-level budgets.
|
|
129
|
+
* When building a proposal (isBuildingProposal=true), computes a fair share of remaining budget
|
|
130
|
+
* across remaining blocks scaled by the multiplier. When validating, only caps by per-block limit
|
|
131
|
+
* and remaining checkpoint budget (no redistribution or multiplier).
|
|
132
|
+
*/ capLimitsByCheckpointBudgets(opts) {
|
|
133
|
+
const existingBlocks = this.checkpointBuilder.getBlocks();
|
|
134
|
+
// Remaining L2 gas (mana)
|
|
135
|
+
// IMPORTANT: This assumes mana is computed solely based on L2 gas used in transactions.
|
|
136
|
+
// This may change in the future.
|
|
137
|
+
const usedMana = sum(existingBlocks.map((b)=>b.header.totalManaUsed.toNumber()));
|
|
138
|
+
const remainingMana = this.config.rollupManaLimit - usedMana;
|
|
139
|
+
// Remaining DA gas
|
|
140
|
+
const usedDAGas = sum(existingBlocks.map((b)=>b.computeDAGasUsed())) ?? 0;
|
|
141
|
+
const remainingDAGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT - usedDAGas;
|
|
142
|
+
// Remaining blob fields (block blob fields include both tx data and block-end overhead)
|
|
143
|
+
const usedBlobFields = sum(existingBlocks.map((b)=>b.toBlobFields().length));
|
|
144
|
+
const totalBlobCapacity = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
|
|
145
|
+
const isFirstBlock = existingBlocks.length === 0;
|
|
146
|
+
const blockEndOverhead = getNumBlockEndBlobFields(isFirstBlock);
|
|
147
|
+
const maxBlobFieldsForTxs = totalBlobCapacity - usedBlobFields - blockEndOverhead;
|
|
148
|
+
// Remaining txs
|
|
149
|
+
const usedTxs = sum(existingBlocks.map((b)=>b.body.txEffects.length));
|
|
150
|
+
const remainingTxs = Math.max(0, (this.config.maxTxsPerCheckpoint ?? Infinity) - usedTxs);
|
|
151
|
+
// Cap by per-block limit + remaining checkpoint budget
|
|
152
|
+
let cappedL2Gas = Math.min(opts.maxBlockGas?.l2Gas ?? Infinity, remainingMana);
|
|
153
|
+
let cappedDAGas = Math.min(opts.maxBlockGas?.daGas ?? Infinity, remainingDAGas);
|
|
154
|
+
let cappedBlobFields = Math.min(opts.maxBlobFields ?? Infinity, maxBlobFieldsForTxs);
|
|
155
|
+
let cappedMaxTransactions = Math.min(opts.maxTransactions ?? Infinity, remainingTxs);
|
|
156
|
+
// Proposer mode: further cap by fair share of remaining budget across remaining blocks
|
|
157
|
+
if (opts.isBuildingProposal) {
|
|
158
|
+
const remainingBlocks = Math.max(1, opts.maxBlocksPerCheckpoint - existingBlocks.length);
|
|
159
|
+
const multiplier = opts.perBlockAllocationMultiplier;
|
|
160
|
+
cappedL2Gas = Math.min(cappedL2Gas, Math.ceil(remainingMana / remainingBlocks * multiplier));
|
|
161
|
+
cappedDAGas = Math.min(cappedDAGas, Math.ceil(remainingDAGas / remainingBlocks * multiplier));
|
|
162
|
+
cappedBlobFields = Math.min(cappedBlobFields, Math.ceil(maxBlobFieldsForTxs / remainingBlocks * multiplier));
|
|
163
|
+
cappedMaxTransactions = Math.min(cappedMaxTransactions, Math.ceil(remainingTxs / remainingBlocks * multiplier));
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
maxBlockGas: new Gas(cappedDAGas, cappedL2Gas),
|
|
167
|
+
maxBlobFields: cappedBlobFields,
|
|
168
|
+
maxTransactions: Number.isFinite(cappedMaxTransactions) ? cappedMaxTransactions : undefined
|
|
169
|
+
};
|
|
170
|
+
}
|
|
101
171
|
async makeBlockBuilderDeps(globalVariables, fork) {
|
|
102
|
-
const txPublicSetupAllowList =
|
|
103
|
-
|
|
172
|
+
const txPublicSetupAllowList = [
|
|
173
|
+
...await getDefaultAllowedSetupFunctions(),
|
|
174
|
+
...this.config.txPublicSetupAllowListExtend ?? []
|
|
175
|
+
];
|
|
176
|
+
const contractsDB = this.contractsDB;
|
|
104
177
|
const guardedFork = new GuardedMerkleTreeOperations(fork);
|
|
178
|
+
const collectDebugLogs = this.debugLogStore.isEnabled;
|
|
105
179
|
const bindings = this.log.getBindings();
|
|
106
|
-
const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(guardedFork, contractsDB, globalVariables, this.telemetryClient, bindings);
|
|
107
|
-
const processor = new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient, createLogger('simulator:public-processor', bindings), this.config);
|
|
108
|
-
const validator =
|
|
180
|
+
const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(guardedFork, contractsDB, globalVariables, this.telemetryClient, bindings, collectDebugLogs);
|
|
181
|
+
const processor = new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient, createLogger('simulator:public-processor', bindings), this.config, this.debugLogStore);
|
|
182
|
+
const validator = createTxValidatorForBlockBuilding(fork, this.contractDataSource, globalVariables, txPublicSetupAllowList, this.log.getBindings());
|
|
109
183
|
return {
|
|
110
184
|
processor,
|
|
111
185
|
validator
|
|
@@ -118,13 +192,15 @@ import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_fac
|
|
|
118
192
|
contractDataSource;
|
|
119
193
|
dateProvider;
|
|
120
194
|
telemetryClient;
|
|
195
|
+
debugLogStore;
|
|
121
196
|
log;
|
|
122
|
-
constructor(config, worldState, contractDataSource, dateProvider, telemetryClient = getTelemetryClient()){
|
|
197
|
+
constructor(config, worldState, contractDataSource, dateProvider, telemetryClient = getTelemetryClient(), debugLogStore = new NullDebugLogStore()){
|
|
123
198
|
this.config = config;
|
|
124
199
|
this.worldState = worldState;
|
|
125
200
|
this.contractDataSource = contractDataSource;
|
|
126
201
|
this.dateProvider = dateProvider;
|
|
127
202
|
this.telemetryClient = telemetryClient;
|
|
203
|
+
this.debugLogStore = debugLogStore;
|
|
128
204
|
this.log = createLogger('checkpoint-builder');
|
|
129
205
|
}
|
|
130
206
|
getConfig() {
|
|
@@ -135,7 +211,7 @@ import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_fac
|
|
|
135
211
|
}
|
|
136
212
|
/**
|
|
137
213
|
* Starts a new checkpoint and returns a CheckpointBuilder to build blocks within it.
|
|
138
|
-
*/ async startCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings) {
|
|
214
|
+
*/ async startCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings) {
|
|
139
215
|
const stateReference = await fork.getStateReference();
|
|
140
216
|
const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
141
217
|
this.log.verbose(`Building new checkpoint ${checkpointNumber}`, {
|
|
@@ -143,18 +219,19 @@ import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_fac
|
|
|
143
219
|
msgCount: l1ToL2Messages.length,
|
|
144
220
|
initialStateReference: stateReference.toInspect(),
|
|
145
221
|
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
146
|
-
constants
|
|
222
|
+
constants,
|
|
223
|
+
feeAssetPriceModifier
|
|
147
224
|
});
|
|
148
|
-
const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings);
|
|
149
|
-
return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, bindings);
|
|
225
|
+
const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings, feeAssetPriceModifier);
|
|
226
|
+
return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, bindings, this.debugLogStore);
|
|
150
227
|
}
|
|
151
228
|
/**
|
|
152
229
|
* Opens a checkpoint, either starting fresh or resuming from existing blocks.
|
|
153
|
-
*/ async openCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, existingBlocks = [], bindings) {
|
|
230
|
+
*/ async openCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, existingBlocks = [], bindings) {
|
|
154
231
|
const stateReference = await fork.getStateReference();
|
|
155
232
|
const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
156
233
|
if (existingBlocks.length === 0) {
|
|
157
|
-
return this.startCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings);
|
|
234
|
+
return this.startCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings);
|
|
158
235
|
}
|
|
159
236
|
this.log.verbose(`Resuming checkpoint ${checkpointNumber} with ${existingBlocks.length} existing blocks`, {
|
|
160
237
|
checkpointNumber,
|
|
@@ -162,10 +239,11 @@ import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_fac
|
|
|
162
239
|
existingBlockCount: existingBlocks.length,
|
|
163
240
|
initialStateReference: stateReference.toInspect(),
|
|
164
241
|
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
165
|
-
constants
|
|
242
|
+
constants,
|
|
243
|
+
feeAssetPriceModifier
|
|
166
244
|
});
|
|
167
|
-
const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, existingBlocks, bindings);
|
|
168
|
-
return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, bindings);
|
|
245
|
+
const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, existingBlocks, bindings);
|
|
246
|
+
return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, bindings, this.debugLogStore);
|
|
169
247
|
}
|
|
170
248
|
/** Returns a fork of the world state at the given block number. */ getFork(blockNumber) {
|
|
171
249
|
return this.worldState.fork(blockNumber);
|
package/dest/config.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export declare const validatorClientConfigMappings: ConfigMappingsType<Validator
|
|
|
8
8
|
* @returns The validator configuration.
|
|
9
9
|
*/
|
|
10
10
|
export declare function getProverEnvVars(): ValidatorClientConfig;
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxLQUFLLGtCQUFrQixFQUt4QixNQUFNLDBCQUEwQixDQUFDO0FBR2xDLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFN0UsWUFBWSxFQUFFLHFCQUFxQixFQUFFLENBQUM7QUFFdEMsZUFBTyxNQUFNLDZCQUE2QixFQUFFLGtCQUFrQixDQUFDLHFCQUFxQixDQW1GbkYsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBZ0IsZ0JBQWdCLElBQUkscUJBQXFCLENBRXhEIn0=
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAEtC,eAAO,MAAM,6BAA6B,EAAE,kBAAkB,CAAC,qBAAqB,CAmFnF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAExD"}
|
package/dest/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, secretValueConfigHelper } from '@aztec/foundation/config';
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import { validatorHASignerConfigMappings } from '@aztec/
|
|
3
|
+
import { localSignerConfigMappings, validatorHASignerConfigMappings } from '@aztec/stdlib/ha-signing';
|
|
4
4
|
export const validatorClientConfigMappings = {
|
|
5
5
|
validatorPrivateKeys: {
|
|
6
6
|
env: 'VALIDATOR_PRIVATE_KEYS',
|
|
@@ -31,11 +31,6 @@ export const validatorClientConfigMappings = {
|
|
|
31
31
|
description: 'Interval between polling for new attestations',
|
|
32
32
|
...numberConfigHelper(200)
|
|
33
33
|
},
|
|
34
|
-
validatorReexecute: {
|
|
35
|
-
env: 'VALIDATOR_REEXECUTE',
|
|
36
|
-
description: 'Re-execute transactions before attesting',
|
|
37
|
-
...booleanConfigHelper(true)
|
|
38
|
-
},
|
|
39
34
|
alwaysReexecuteBlockProposals: {
|
|
40
35
|
description: 'Whether to always reexecute block proposals, even for non-validator nodes (useful for monitoring network status).',
|
|
41
36
|
defaultValue: true
|
|
@@ -53,6 +48,31 @@ export const validatorClientConfigMappings = {
|
|
|
53
48
|
description: 'Skip pushing re-executed blocks to archiver (default: false)',
|
|
54
49
|
defaultValue: false
|
|
55
50
|
},
|
|
51
|
+
attestToEquivocatedProposals: {
|
|
52
|
+
description: 'Agree to attest to equivocated checkpoint proposals (for testing purposes only)',
|
|
53
|
+
...booleanConfigHelper(false)
|
|
54
|
+
},
|
|
55
|
+
validateMaxL2BlockGas: {
|
|
56
|
+
env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
|
|
57
|
+
description: 'Maximum L2 block gas for validation. Proposals exceeding this limit are rejected.',
|
|
58
|
+
parseEnv: (val)=>val ? parseInt(val, 10) : undefined
|
|
59
|
+
},
|
|
60
|
+
validateMaxDABlockGas: {
|
|
61
|
+
env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
|
|
62
|
+
description: 'Maximum DA block gas for validation. Proposals exceeding this limit are rejected.',
|
|
63
|
+
parseEnv: (val)=>val ? parseInt(val, 10) : undefined
|
|
64
|
+
},
|
|
65
|
+
validateMaxTxsPerBlock: {
|
|
66
|
+
env: 'VALIDATOR_MAX_TX_PER_BLOCK',
|
|
67
|
+
description: 'Maximum transactions per block for validation. Proposals exceeding this limit are rejected.',
|
|
68
|
+
parseEnv: (val)=>val ? parseInt(val, 10) : undefined
|
|
69
|
+
},
|
|
70
|
+
validateMaxTxsPerCheckpoint: {
|
|
71
|
+
env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
|
|
72
|
+
description: 'Maximum transactions per checkpoint for validation. Proposals exceeding this limit are rejected.',
|
|
73
|
+
parseEnv: (val)=>val ? parseInt(val, 10) : undefined
|
|
74
|
+
},
|
|
75
|
+
...localSignerConfigMappings,
|
|
56
76
|
...validatorHASignerConfigMappings
|
|
57
77
|
};
|
|
58
78
|
/**
|
|
@@ -39,7 +39,7 @@ export declare class ValidationService {
|
|
|
39
39
|
*
|
|
40
40
|
* @returns A checkpoint proposal signing the above information
|
|
41
41
|
*/
|
|
42
|
-
createCheckpointProposal(checkpointHeader: CheckpointHeader, archive: Fr, lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined, proposerAttesterAddress: EthAddress | undefined, options: CheckpointProposalOptions): Promise<CheckpointProposal>;
|
|
42
|
+
createCheckpointProposal(checkpointHeader: CheckpointHeader, archive: Fr, feeAssetPriceModifier: bigint, lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined, proposerAttesterAddress: EthAddress | undefined, options: CheckpointProposalOptions): Promise<CheckpointProposal>;
|
|
43
43
|
/**
|
|
44
44
|
* Attest with selection of validators to the given checkpoint proposal
|
|
45
45
|
*
|
|
@@ -63,4 +63,4 @@ export declare class ValidationService {
|
|
|
63
63
|
*/
|
|
64
64
|
signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress, slot: SlotNumber, blockNumber: BlockNumber | CheckpointNumber):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iBAAiB;IAE1B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,GAAG;IAFb,YACU,QAAQ,EAAE,iBAAiB,EAC3B,GAAG,yCAA+C,EACxD;IAEJ;;;;;;;;;;;;;;OAcG;IACI,mBAAmB,CACxB,WAAW,EAAE,WAAW,EACxB,0BAA0B,EAAE,qBAAqB,EACjD,MAAM,EAAE,EAAE,EACV,OAAO,EAAE,EAAE,EACX,GAAG,EAAE,EAAE,EAAE,EACT,uBAAuB,EAAE,UAAU,GAAG,SAAS,EAC/C,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,aAAa,CAAC,CAqBxB;IAED;;;;;;;;;;OAUG;IACI,wBAAwB,CAC7B,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,EAAE,EACX,qBAAqB,EAAE,MAAM,EAC7B,aAAa,EAAE,qCAAqC,GAAG,SAAS,EAChE,uBAAuB,EAAE,UAAU,GAAG,SAAS,EAC/C,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,kBAAkB,CAAC,CA4B7B;IAED;;;;;;;;;OASG;IACG,0BAA0B,CAC9B,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,UAAU,EAAE,GACtB,OAAO,CAAC,qBAAqB,EAAE,CAAC,CA8ClC;IAED;;;;;;;;;OASG;IACH,0BAA0B,CACxB,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAC1C,OAAO,CAAC,SAAS,CAAC,CAWpB;CACF"}
|
|
@@ -48,7 +48,7 @@ export class ValidationService {
|
|
|
48
48
|
* @param options - Checkpoint proposal options
|
|
49
49
|
*
|
|
50
50
|
* @returns A checkpoint proposal signing the above information
|
|
51
|
-
*/ createCheckpointProposal(checkpointHeader, archive, lastBlockInfo, proposerAttesterAddress, options) {
|
|
51
|
+
*/ createCheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, lastBlockInfo, proposerAttesterAddress, options) {
|
|
52
52
|
// For testing: change the archive to trigger state_mismatch validation failure
|
|
53
53
|
if (options.broadcastInvalidCheckpointProposal) {
|
|
54
54
|
archive = Fr.random();
|
|
@@ -66,7 +66,7 @@ export class ValidationService {
|
|
|
66
66
|
txHashes: lastBlockInfo.txs.map((tx)=>tx.getTxHash()),
|
|
67
67
|
txs: options.publishFullTxs ? lastBlockInfo.txs : undefined
|
|
68
68
|
};
|
|
69
|
-
return CheckpointProposal.createProposalFromSigner(checkpointHeader, archive, lastBlock, payloadSigner);
|
|
69
|
+
return CheckpointProposal.createProposalFromSigner(checkpointHeader, archive, feeAssetPriceModifier, lastBlock, payloadSigner);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Attest with selection of validators to the given checkpoint proposal
|
|
@@ -79,19 +79,13 @@ export class ValidationService {
|
|
|
79
79
|
* @returns checkpoint attestations
|
|
80
80
|
*/ async attestToCheckpointProposal(proposal, attestors) {
|
|
81
81
|
// Create the attestation payload from the checkpoint proposal
|
|
82
|
-
const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive);
|
|
82
|
+
const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive, proposal.feeAssetPriceModifier);
|
|
83
83
|
const buf = Buffer32.fromBuffer(keccak256(payload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation)));
|
|
84
84
|
// TODO(spy/ha): Use checkpointNumber instead of blockNumber once CheckpointHeader includes it.
|
|
85
|
-
//
|
|
85
|
+
// CheckpointProposalCore doesn't have lastBlock info, so use 0 as a proxy.
|
|
86
86
|
// blockNumber is NOT used for the primary key so it's safe to use here.
|
|
87
87
|
// See CheckpointHeader TODO and SigningContext types documentation.
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
blockNumber = proposal.blockNumber;
|
|
91
|
-
} catch {
|
|
92
|
-
// Checkpoint proposal may not have lastBlock, use 0 as fallback
|
|
93
|
-
blockNumber = BlockNumber(0);
|
|
94
|
-
}
|
|
88
|
+
const blockNumber = BlockNumber(0);
|
|
95
89
|
const context = {
|
|
96
90
|
slot: proposal.slotNumber,
|
|
97
91
|
blockNumber,
|
|
@@ -111,7 +105,7 @@ export class ValidationService {
|
|
|
111
105
|
} else {
|
|
112
106
|
const error = result.reason;
|
|
113
107
|
if (error instanceof DutyAlreadySignedError || error instanceof SlashingProtectionError) {
|
|
114
|
-
this.log.
|
|
108
|
+
this.log.verbose(`Attestation for slot ${proposal.slotNumber} by ${attestors[i]} already signed by another High-Availability node`);
|
|
115
109
|
// Continue with remaining attestors
|
|
116
110
|
} else {
|
|
117
111
|
throw error;
|