@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.
@@ -1,14 +1,14 @@
1
- import { type AllowedFunction, Tx, type TxValidator } from '@aztec/circuit-types';
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, PublicKernelPhase } from '@aztec/simulator';
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: AllowedFunction[]) {
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 { [PublicKernelPhase.SETUP]: setupFns } = AbstractPhaseManager.extractEnqueuedPublicCallsByPhase(tx);
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: AllowedFunction[]): Promise<boolean> {
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 (!('address' in entry)) {
70
- continue;
69
+ if ('address' in entry && !('selector' in entry)) {
70
+ if (contractAddress.equals(entry.address)) {
71
+ return true;
72
+ }
71
73
  }
72
74
 
73
- if (contractAddress.equals(entry.address) && entry.selector.equals(functionSelector)) {
74
- return true;
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
- const contractClass = await this.contractDataSource.getContractInstance(contractAddress);
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
- for (const entry of allowList) {
84
- if (!('classId' in entry)) {
85
- continue;
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 (contractClass.contractClassId.equals(entry.classId) && entry.selector.equals(functionSelector)) {
89
- return true;
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 AllowedFunction, type ProcessedTx, type Tx, type TxValidator } from '@aztec/circuit-types';
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(private merkleTreeDb: MerkleTreeOperations, private contractDataSource: ContractDataSource) {}
15
+ constructor(
16
+ private merkleTreeDb: MerkleTreeOperations,
17
+ private contractDataSource: ContractDataSource,
18
+ private enforceFees: boolean,
19
+ ) {}
16
20
 
17
- validatorForNewTxs(globalVariables: GlobalVariables, setupAllowList: AllowedFunction[]): TxValidator<Tx> {
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