@aztec/sequencer-client 0.42.0 → 0.43.0
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.js +2 -2
- package/dest/config.d.ts +13 -0
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +46 -35
- package/dest/publisher/l1-publisher.d.ts +4 -1
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +6 -1
- package/dest/publisher/viem-tx-sender.d.ts +3 -0
- package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
- package/dest/publisher/viem-tx-sender.js +15 -1
- package/dest/sequencer/sequencer.d.ts +2 -2
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +22 -14
- package/dest/tx_validator/gas_validator.d.ts +2 -1
- package/dest/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/tx_validator/gas_validator.js +12 -5
- package/dest/tx_validator/phases_validator.d.ts +3 -3
- package/dest/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/tx_validator/phases_validator.js +25 -18
- package/dest/tx_validator/tx_validator_factory.d.ts +4 -3
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +4 -3
- package/package.json +14 -14
- package/src/client/sequencer-client.ts +1 -1
- package/src/config.ts +47 -37
- package/src/publisher/l1-publisher.ts +11 -1
- package/src/publisher/viem-tx-sender.ts +15 -0
- package/src/sequencer/sequencer.ts +25 -16
- package/src/tx_validator/gas_validator.ts +9 -5
- package/src/tx_validator/phases_validator.ts +29 -19
- package/src/tx_validator/tx_validator_factory.ts +8 -4
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type AllowedElement, PublicKernelType, Tx, type TxValidator } from '@aztec/circuit-types';
|
|
2
2
|
import { type PublicCallRequest } from '@aztec/circuits.js';
|
|
3
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { AbstractPhaseManager, ContractsDataSourcePublicDB
|
|
4
|
+
import { AbstractPhaseManager, ContractsDataSourcePublicDB } from '@aztec/simulator';
|
|
5
5
|
import { type ContractDataSource } from '@aztec/types/contracts';
|
|
6
6
|
|
|
7
7
|
export class PhasesTxValidator implements TxValidator<Tx> {
|
|
8
8
|
#log = createDebugLogger('aztec:sequencer:tx_validator:tx_phases');
|
|
9
9
|
private contractDataSource: ContractsDataSourcePublicDB;
|
|
10
10
|
|
|
11
|
-
constructor(contracts: ContractDataSource, private setupAllowList:
|
|
11
|
+
constructor(contracts: ContractDataSource, private setupAllowList: AllowedElement[]) {
|
|
12
12
|
this.contractDataSource = new ContractsDataSourcePublicDB(contracts);
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -40,7 +40,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const { [
|
|
43
|
+
const { [PublicKernelType.SETUP]: setupFns } = AbstractPhaseManager.extractEnqueuedPublicCallsByPhase(tx);
|
|
44
44
|
|
|
45
45
|
for (const setupFn of setupFns) {
|
|
46
46
|
if (!(await this.isOnAllowList(setupFn, this.setupAllowList))) {
|
|
@@ -57,7 +57,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
57
57
|
return true;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
async isOnAllowList(publicCall: PublicCallRequest, allowList:
|
|
60
|
+
async isOnAllowList(publicCall: PublicCallRequest, allowList: AllowedElement[]): Promise<boolean> {
|
|
61
61
|
if (publicCall.isEmpty()) {
|
|
62
62
|
return true;
|
|
63
63
|
}
|
|
@@ -66,27 +66,37 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
66
66
|
|
|
67
67
|
// do these checks first since they don't require the contract class
|
|
68
68
|
for (const entry of allowList) {
|
|
69
|
-
if (!('
|
|
70
|
-
|
|
69
|
+
if ('address' in entry && !('selector' in entry)) {
|
|
70
|
+
if (contractAddress.equals(entry.address)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
+
if ('address' in entry && 'selector' in entry) {
|
|
76
|
+
if (contractAddress.equals(entry.address) && entry.selector.equals(functionSelector)) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
75
79
|
}
|
|
76
|
-
}
|
|
77
80
|
|
|
78
|
-
|
|
79
|
-
if (!contractClass) {
|
|
80
|
-
throw new Error(`Contract not found: ${publicCall.contractAddress.toString()}`);
|
|
81
|
-
}
|
|
81
|
+
const contractClass = await this.contractDataSource.getContractInstance(contractAddress);
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
if (!contractClass) {
|
|
84
|
+
throw new Error(`Contract not found: ${publicCall.contractAddress.toString()}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if ('classId' in entry && !('selector' in entry)) {
|
|
88
|
+
if (contractClass.contractClassId.equals(entry.classId)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
86
91
|
}
|
|
87
92
|
|
|
88
|
-
if (
|
|
89
|
-
|
|
93
|
+
if ('classId' in entry && 'selector' in entry) {
|
|
94
|
+
if (
|
|
95
|
+
contractClass.contractClassId.equals(entry.classId) &&
|
|
96
|
+
(entry.selector === undefined || entry.selector.equals(functionSelector))
|
|
97
|
+
) {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
90
100
|
}
|
|
91
101
|
}
|
|
92
102
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type AllowedElement, type ProcessedTx, type Tx, type TxValidator } from '@aztec/circuit-types';
|
|
2
2
|
import { type GlobalVariables } from '@aztec/circuits.js';
|
|
3
3
|
import { GasTokenAddress } from '@aztec/protocol-contracts/gas-token';
|
|
4
4
|
import { WorldStateDB, WorldStatePublicDB } from '@aztec/simulator';
|
|
@@ -12,14 +12,18 @@ import { MetadataTxValidator } from './metadata_validator.js';
|
|
|
12
12
|
import { PhasesTxValidator } from './phases_validator.js';
|
|
13
13
|
|
|
14
14
|
export class TxValidatorFactory {
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(
|
|
16
|
+
private merkleTreeDb: MerkleTreeOperations,
|
|
17
|
+
private contractDataSource: ContractDataSource,
|
|
18
|
+
private enforceFees: boolean,
|
|
19
|
+
) {}
|
|
16
20
|
|
|
17
|
-
validatorForNewTxs(globalVariables: GlobalVariables, setupAllowList:
|
|
21
|
+
validatorForNewTxs(globalVariables: GlobalVariables, setupAllowList: AllowedElement[]): TxValidator<Tx> {
|
|
18
22
|
return new AggregateTxValidator(
|
|
19
23
|
new MetadataTxValidator(globalVariables),
|
|
20
24
|
new DoubleSpendTxValidator(new WorldStateDB(this.merkleTreeDb)),
|
|
21
25
|
new PhasesTxValidator(this.contractDataSource, setupAllowList),
|
|
22
|
-
new GasTxValidator(new WorldStatePublicDB(this.merkleTreeDb), GasTokenAddress),
|
|
26
|
+
new GasTxValidator(new WorldStatePublicDB(this.merkleTreeDb), GasTokenAddress, this.enforceFees),
|
|
23
27
|
);
|
|
24
28
|
}
|
|
25
29
|
|