@aztec/validator-client 4.0.0-nightly.20260112 → 4.0.0-nightly.20260114
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 +256 -0
- package/dest/block_proposal_handler.d.ts +22 -10
- package/dest/block_proposal_handler.d.ts.map +1 -1
- package/dest/block_proposal_handler.js +347 -76
- package/dest/checkpoint_builder.d.ts +70 -0
- package/dest/checkpoint_builder.d.ts.map +1 -0
- package/dest/checkpoint_builder.js +156 -0
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +10 -5
- package/dest/duties/validation_service.d.ts +26 -10
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +51 -21
- package/dest/factory.d.ts +10 -7
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +2 -2
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/tx_validator/index.d.ts +3 -0
- package/dest/tx_validator/index.d.ts.map +1 -0
- package/dest/tx_validator/index.js +2 -0
- package/dest/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/tx_validator/nullifier_cache.js +24 -0
- package/dest/tx_validator/tx_validator_factory.d.ts +18 -0
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -0
- package/dest/tx_validator/tx_validator_factory.js +53 -0
- package/dest/validator.d.ts +39 -15
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +318 -449
- package/package.json +16 -12
- package/src/block_proposal_handler.ts +273 -43
- package/src/checkpoint_builder.ts +276 -0
- package/src/config.ts +10 -5
- package/src/duties/validation_service.ts +79 -25
- package/src/factory.ts +14 -8
- package/src/index.ts +2 -0
- package/src/tx_validator/index.ts +2 -0
- package/src/tx_validator/nullifier_cache.ts +30 -0
- package/src/tx_validator/tx_validator_factory.ts +133 -0
- package/src/validator.ts +424 -94
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
|
+
import {
|
|
5
|
+
AggregateTxValidator,
|
|
6
|
+
ArchiveCache,
|
|
7
|
+
BlockHeaderTxValidator,
|
|
8
|
+
DataTxValidator,
|
|
9
|
+
DoubleSpendTxValidator,
|
|
10
|
+
GasTxValidator,
|
|
11
|
+
MetadataTxValidator,
|
|
12
|
+
PhasesTxValidator,
|
|
13
|
+
TimestampTxValidator,
|
|
14
|
+
TxPermittedValidator,
|
|
15
|
+
TxProofValidator,
|
|
16
|
+
} from '@aztec/p2p';
|
|
17
|
+
import { ProtocolContractAddress, protocolContractsHash } from '@aztec/protocol-contracts';
|
|
18
|
+
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
19
|
+
import type { GasFees } from '@aztec/stdlib/gas';
|
|
20
|
+
import type {
|
|
21
|
+
AllowedElement,
|
|
22
|
+
ClientProtocolCircuitVerifier,
|
|
23
|
+
MerkleTreeReadOperations,
|
|
24
|
+
PublicProcessorValidator,
|
|
25
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
26
|
+
import { DatabasePublicStateSource, type PublicStateSource } from '@aztec/stdlib/trees';
|
|
27
|
+
import { GlobalVariables, type Tx, type TxValidator } from '@aztec/stdlib/tx';
|
|
28
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
29
|
+
|
|
30
|
+
import { NullifierCache } from './nullifier_cache.js';
|
|
31
|
+
|
|
32
|
+
export function createValidatorForAcceptingTxs(
|
|
33
|
+
db: MerkleTreeReadOperations,
|
|
34
|
+
contractDataSource: ContractDataSource,
|
|
35
|
+
verifier: ClientProtocolCircuitVerifier | undefined,
|
|
36
|
+
{
|
|
37
|
+
l1ChainId,
|
|
38
|
+
rollupVersion,
|
|
39
|
+
setupAllowList,
|
|
40
|
+
gasFees,
|
|
41
|
+
skipFeeEnforcement,
|
|
42
|
+
timestamp,
|
|
43
|
+
blockNumber,
|
|
44
|
+
txsPermitted,
|
|
45
|
+
}: {
|
|
46
|
+
l1ChainId: number;
|
|
47
|
+
rollupVersion: number;
|
|
48
|
+
setupAllowList: AllowedElement[];
|
|
49
|
+
gasFees: GasFees;
|
|
50
|
+
skipFeeEnforcement?: boolean;
|
|
51
|
+
timestamp: UInt64;
|
|
52
|
+
blockNumber: BlockNumber;
|
|
53
|
+
txsPermitted: boolean;
|
|
54
|
+
},
|
|
55
|
+
): TxValidator<Tx> {
|
|
56
|
+
const validators: TxValidator<Tx>[] = [
|
|
57
|
+
new TxPermittedValidator(txsPermitted),
|
|
58
|
+
new DataTxValidator(),
|
|
59
|
+
new MetadataTxValidator({
|
|
60
|
+
l1ChainId: new Fr(l1ChainId),
|
|
61
|
+
rollupVersion: new Fr(rollupVersion),
|
|
62
|
+
protocolContractsHash,
|
|
63
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
64
|
+
}),
|
|
65
|
+
new TimestampTxValidator({
|
|
66
|
+
timestamp,
|
|
67
|
+
blockNumber,
|
|
68
|
+
}),
|
|
69
|
+
new DoubleSpendTxValidator(new NullifierCache(db)),
|
|
70
|
+
new PhasesTxValidator(contractDataSource, setupAllowList, timestamp),
|
|
71
|
+
new BlockHeaderTxValidator(new ArchiveCache(db)),
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
if (!skipFeeEnforcement) {
|
|
75
|
+
validators.push(new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, gasFees));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (verifier) {
|
|
79
|
+
validators.push(new TxProofValidator(verifier));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return new AggregateTxValidator(...validators);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function createValidatorForBlockBuilding(
|
|
86
|
+
db: MerkleTreeReadOperations,
|
|
87
|
+
contractDataSource: ContractDataSource,
|
|
88
|
+
globalVariables: GlobalVariables,
|
|
89
|
+
setupAllowList: AllowedElement[],
|
|
90
|
+
): PublicProcessorValidator {
|
|
91
|
+
const nullifierCache = new NullifierCache(db);
|
|
92
|
+
const archiveCache = new ArchiveCache(db);
|
|
93
|
+
const publicStateSource = new DatabasePublicStateSource(db);
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
preprocessValidator: preprocessValidator(
|
|
97
|
+
nullifierCache,
|
|
98
|
+
archiveCache,
|
|
99
|
+
publicStateSource,
|
|
100
|
+
contractDataSource,
|
|
101
|
+
globalVariables,
|
|
102
|
+
setupAllowList,
|
|
103
|
+
),
|
|
104
|
+
nullifierCache,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function preprocessValidator(
|
|
109
|
+
nullifierCache: NullifierCache,
|
|
110
|
+
archiveCache: ArchiveCache,
|
|
111
|
+
publicStateSource: PublicStateSource,
|
|
112
|
+
contractDataSource: ContractDataSource,
|
|
113
|
+
globalVariables: GlobalVariables,
|
|
114
|
+
setupAllowList: AllowedElement[],
|
|
115
|
+
): TxValidator<Tx> {
|
|
116
|
+
// We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
|
|
117
|
+
return new AggregateTxValidator(
|
|
118
|
+
new MetadataTxValidator({
|
|
119
|
+
l1ChainId: globalVariables.chainId,
|
|
120
|
+
rollupVersion: globalVariables.version,
|
|
121
|
+
protocolContractsHash,
|
|
122
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
123
|
+
}),
|
|
124
|
+
new TimestampTxValidator({
|
|
125
|
+
timestamp: globalVariables.timestamp,
|
|
126
|
+
blockNumber: globalVariables.blockNumber,
|
|
127
|
+
}),
|
|
128
|
+
new DoubleSpendTxValidator(nullifierCache),
|
|
129
|
+
new PhasesTxValidator(contractDataSource, setupAllowList, globalVariables.timestamp),
|
|
130
|
+
new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, globalVariables.gasFees),
|
|
131
|
+
new BlockHeaderTxValidator(archiveCache),
|
|
132
|
+
);
|
|
133
|
+
}
|