@aztec/sequencer-client 0.69.0 → 0.69.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/client/sequencer-client.d.ts +2 -0
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +3 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -1
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +4 -2
- package/dest/publisher/config.d.ts +4 -0
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +6 -1
- package/dest/publisher/l1-publisher.d.ts +36 -11
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +154 -88
- package/dest/sequencer/index.d.ts +1 -0
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +2 -1
- package/dest/sequencer/sequencer.d.ts +9 -16
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +61 -130
- package/dest/sequencer/utils.d.ts +2 -2
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +3 -3
- package/dest/slasher/factory.d.ts +11 -0
- package/dest/slasher/factory.d.ts.map +1 -0
- package/dest/slasher/factory.js +10 -0
- package/dest/slasher/index.d.ts +3 -0
- package/dest/slasher/index.d.ts.map +1 -0
- package/dest/slasher/index.js +3 -0
- package/dest/slasher/slasher_client.d.ts +127 -0
- package/dest/slasher/slasher_client.d.ts.map +1 -0
- package/dest/slasher/slasher_client.js +305 -0
- package/dest/tx_validator/gas_validator.d.ts +2 -3
- package/dest/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/tx_validator/gas_validator.js +9 -22
- package/dest/tx_validator/nullifier_cache.d.ts +16 -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/phases_validator.d.ts +2 -3
- package/dest/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/tx_validator/phases_validator.js +15 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +15 -14
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +38 -24
- package/package.json +21 -19
- package/src/client/sequencer-client.ts +5 -2
- package/src/config.ts +10 -0
- package/src/index.ts +3 -1
- package/src/publisher/config.ts +10 -0
- package/src/publisher/l1-publisher.ts +180 -97
- package/src/sequencer/index.ts +1 -0
- package/src/sequencer/sequencer.ts +70 -180
- package/src/sequencer/utils.ts +2 -2
- package/src/slasher/factory.ts +22 -0
- package/src/slasher/index.ts +2 -0
- package/src/slasher/slasher_client.ts +402 -0
- package/src/tx_validator/gas_validator.ts +11 -24
- package/src/tx_validator/nullifier_cache.ts +29 -0
- package/src/tx_validator/phases_validator.ts +22 -33
- package/src/tx_validator/tx_validator_factory.ts +82 -40
|
@@ -1,65 +1,107 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type AllowedElement,
|
|
3
|
-
|
|
3
|
+
type ClientProtocolCircuitVerifier,
|
|
4
4
|
type MerkleTreeReadOperations,
|
|
5
5
|
type ProcessedTx,
|
|
6
6
|
type Tx,
|
|
7
7
|
type TxValidator,
|
|
8
8
|
} from '@aztec/circuit-types';
|
|
9
|
-
import { type ContractDataSource, type GlobalVariables } from '@aztec/circuits.js';
|
|
9
|
+
import { type AztecAddress, type ContractDataSource, Fr, type GasFees, type GlobalVariables } from '@aztec/circuits.js';
|
|
10
10
|
import {
|
|
11
11
|
AggregateTxValidator,
|
|
12
12
|
DataTxValidator,
|
|
13
13
|
DoubleSpendTxValidator,
|
|
14
14
|
MetadataTxValidator,
|
|
15
|
-
|
|
15
|
+
TxProofValidator,
|
|
16
16
|
} from '@aztec/p2p';
|
|
17
17
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
18
18
|
import { readPublicState } from '@aztec/simulator';
|
|
19
19
|
|
|
20
20
|
import { GasTxValidator, type PublicStateSource } from './gas_validator.js';
|
|
21
|
+
import { NullifierCache } from './nullifier_cache.js';
|
|
21
22
|
import { PhasesTxValidator } from './phases_validator.js';
|
|
22
23
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
export function createValidatorForAcceptingTxs(
|
|
25
|
+
db: MerkleTreeReadOperations,
|
|
26
|
+
contractDataSource: ContractDataSource,
|
|
27
|
+
verifier: ClientProtocolCircuitVerifier | undefined,
|
|
28
|
+
data: {
|
|
29
|
+
blockNumber: number;
|
|
30
|
+
l1ChainId: number;
|
|
31
|
+
enforceFees: boolean;
|
|
32
|
+
setupAllowList: AllowedElement[];
|
|
33
|
+
gasFees: GasFees;
|
|
34
|
+
},
|
|
35
|
+
): TxValidator<Tx> {
|
|
36
|
+
const { blockNumber, l1ChainId, enforceFees, setupAllowList, gasFees } = data;
|
|
37
|
+
const validators: TxValidator<Tx>[] = [
|
|
38
|
+
new DataTxValidator(),
|
|
39
|
+
new MetadataTxValidator(new Fr(l1ChainId), new Fr(blockNumber)),
|
|
40
|
+
new DoubleSpendTxValidator(new NullifierCache(db)),
|
|
41
|
+
new PhasesTxValidator(contractDataSource, setupAllowList),
|
|
42
|
+
new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, enforceFees, gasFees),
|
|
43
|
+
];
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return readPublicState(this.committedDb, contractAddress, slot);
|
|
41
|
-
},
|
|
42
|
-
};
|
|
45
|
+
if (verifier) {
|
|
46
|
+
validators.push(new TxProofValidator(verifier));
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
return new AggregateTxValidator(...validators);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function createValidatorsForBlockBuilding(
|
|
53
|
+
db: MerkleTreeReadOperations,
|
|
54
|
+
contractDataSource: ContractDataSource,
|
|
55
|
+
globalVariables: GlobalVariables,
|
|
56
|
+
enforceFees: boolean,
|
|
57
|
+
setupAllowList: AllowedElement[],
|
|
58
|
+
): {
|
|
59
|
+
preprocessValidator: TxValidator<Tx>;
|
|
60
|
+
postprocessValidator: TxValidator<ProcessedTx>;
|
|
61
|
+
nullifierCache: NullifierCache;
|
|
62
|
+
} {
|
|
63
|
+
const nullifierCache = new NullifierCache(db);
|
|
64
|
+
const publicStateSource = new DatabasePublicStateSource(db);
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
preprocessValidator: preprocessValidator(
|
|
68
|
+
nullifierCache,
|
|
69
|
+
publicStateSource,
|
|
70
|
+
contractDataSource,
|
|
71
|
+
enforceFees,
|
|
72
|
+
globalVariables,
|
|
73
|
+
setupAllowList,
|
|
74
|
+
),
|
|
75
|
+
postprocessValidator: postprocessValidator(nullifierCache),
|
|
76
|
+
nullifierCache,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
59
79
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
class DatabasePublicStateSource implements PublicStateSource {
|
|
81
|
+
constructor(private db: MerkleTreeReadOperations) {}
|
|
82
|
+
|
|
83
|
+
storageRead(contractAddress: AztecAddress, slot: Fr): Promise<Fr> {
|
|
84
|
+
return readPublicState(this.db, contractAddress, slot);
|
|
64
85
|
}
|
|
65
86
|
}
|
|
87
|
+
|
|
88
|
+
function preprocessValidator(
|
|
89
|
+
nullifierCache: NullifierCache,
|
|
90
|
+
publicStateSource: PublicStateSource,
|
|
91
|
+
contractDataSource: ContractDataSource,
|
|
92
|
+
enforceFees: boolean,
|
|
93
|
+
globalVariables: GlobalVariables,
|
|
94
|
+
setupAllowList: AllowedElement[],
|
|
95
|
+
): TxValidator<Tx> {
|
|
96
|
+
// We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
|
|
97
|
+
return new AggregateTxValidator(
|
|
98
|
+
new MetadataTxValidator(globalVariables.chainId, globalVariables.blockNumber),
|
|
99
|
+
new DoubleSpendTxValidator(nullifierCache),
|
|
100
|
+
new PhasesTxValidator(contractDataSource, setupAllowList),
|
|
101
|
+
new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, enforceFees, globalVariables.gasFees),
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function postprocessValidator(nullifierCache: NullifierCache): TxValidator<ProcessedTx> {
|
|
106
|
+
return new DoubleSpendTxValidator(nullifierCache);
|
|
107
|
+
}
|