@aztec/sequencer-client 0.66.0 → 0.67.1-devnet

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.
Files changed (51) hide show
  1. package/dest/client/sequencer-client.js +2 -1
  2. package/dest/config.d.ts +3 -3
  3. package/dest/config.d.ts.map +1 -1
  4. package/dest/config.js +5 -58
  5. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  6. package/dest/global_variable_builder/global_builder.js +3 -4
  7. package/dest/index.d.ts +0 -1
  8. package/dest/index.d.ts.map +1 -1
  9. package/dest/index.js +1 -2
  10. package/dest/publisher/index.d.ts +0 -1
  11. package/dest/publisher/index.d.ts.map +1 -1
  12. package/dest/publisher/index.js +1 -2
  13. package/dest/publisher/l1-publisher-metrics.d.ts.map +1 -1
  14. package/dest/publisher/l1-publisher-metrics.js +2 -8
  15. package/dest/publisher/l1-publisher.d.ts +3 -2
  16. package/dest/publisher/l1-publisher.d.ts.map +1 -1
  17. package/dest/publisher/l1-publisher.js +159 -50
  18. package/dest/publisher/utils.d.ts.map +1 -1
  19. package/dest/publisher/utils.js +2 -1
  20. package/dest/sequencer/allowed.d.ts +3 -0
  21. package/dest/sequencer/allowed.d.ts.map +1 -0
  22. package/dest/sequencer/allowed.js +34 -0
  23. package/dest/sequencer/config.d.ts +1 -1
  24. package/dest/sequencer/config.d.ts.map +1 -1
  25. package/dest/sequencer/metrics.d.ts.map +1 -1
  26. package/dest/sequencer/metrics.js +2 -8
  27. package/dest/sequencer/sequencer.d.ts +2 -6
  28. package/dest/sequencer/sequencer.d.ts.map +1 -1
  29. package/dest/sequencer/sequencer.js +112 -103
  30. package/dest/tx_validator/gas_validator.d.ts +3 -4
  31. package/dest/tx_validator/gas_validator.d.ts.map +1 -1
  32. package/dest/tx_validator/gas_validator.js +27 -10
  33. package/dest/tx_validator/phases_validator.js +3 -3
  34. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  35. package/dest/tx_validator/tx_validator_factory.js +6 -4
  36. package/package.json +27 -20
  37. package/src/client/sequencer-client.ts +1 -1
  38. package/src/config.ts +7 -62
  39. package/src/global_variable_builder/global_builder.ts +3 -3
  40. package/src/index.ts +0 -1
  41. package/src/publisher/index.ts +0 -1
  42. package/src/publisher/l1-publisher-metrics.ts +1 -7
  43. package/src/publisher/l1-publisher.ts +200 -73
  44. package/src/publisher/utils.ts +1 -0
  45. package/src/sequencer/allowed.ts +36 -0
  46. package/src/sequencer/config.ts +1 -1
  47. package/src/sequencer/metrics.ts +0 -7
  48. package/src/sequencer/sequencer.ts +136 -149
  49. package/src/tx_validator/gas_validator.ts +34 -8
  50. package/src/tx_validator/phases_validator.ts +2 -2
  51. package/src/tx_validator/tx_validator_factory.ts +11 -3
@@ -1,6 +1,6 @@
1
1
  import { type Tx, TxExecutionPhase, type TxValidator } from '@aztec/circuit-types';
2
- import { type AztecAddress, type Fr, FunctionSelector } from '@aztec/circuits.js';
3
- import { createDebugLogger } from '@aztec/foundation/log';
2
+ import { type AztecAddress, type Fr, FunctionSelector, type GasFees } from '@aztec/circuits.js';
3
+ import { createLogger } from '@aztec/foundation/log';
4
4
  import { computeFeePayerBalanceStorageSlot, getExecutionRequestsByPhase } from '@aztec/simulator';
5
5
 
6
6
  /** Provides a view into public contract state */
@@ -9,39 +9,65 @@ export interface PublicStateSource {
9
9
  }
10
10
 
11
11
  export class GasTxValidator implements TxValidator<Tx> {
12
- #log = createDebugLogger('aztec:sequencer:tx_validator:tx_gas');
12
+ #log = createLogger('sequencer:tx_validator:tx_gas');
13
13
  #publicDataSource: PublicStateSource;
14
14
  #feeJuiceAddress: AztecAddress;
15
+ #enforceFees: boolean;
16
+ #gasFees: GasFees;
15
17
 
16
- constructor(publicDataSource: PublicStateSource, feeJuiceAddress: AztecAddress, public enforceFees: boolean) {
18
+ constructor(
19
+ publicDataSource: PublicStateSource,
20
+ feeJuiceAddress: AztecAddress,
21
+ enforceFees: boolean,
22
+ gasFees: GasFees,
23
+ ) {
17
24
  this.#publicDataSource = publicDataSource;
18
25
  this.#feeJuiceAddress = feeJuiceAddress;
26
+ this.#enforceFees = enforceFees;
27
+ this.#gasFees = gasFees;
19
28
  }
20
29
 
21
- async validateTxs(txs: Tx[]): Promise<[validTxs: Tx[], invalidTxs: Tx[]]> {
30
+ async validateTxs(txs: Tx[]): Promise<[validTxs: Tx[], invalidTxs: Tx[], skippedTxs: Tx[]]> {
22
31
  const validTxs: Tx[] = [];
23
32
  const invalidTxs: Tx[] = [];
33
+ const skippedTxs: Tx[] = [];
24
34
 
25
35
  for (const tx of txs) {
26
- if (await this.#validateTxFee(tx)) {
36
+ if (this.#shouldSkip(tx)) {
37
+ skippedTxs.push(tx);
38
+ } else if (await this.#validateTxFee(tx)) {
27
39
  validTxs.push(tx);
28
40
  } else {
29
41
  invalidTxs.push(tx);
30
42
  }
31
43
  }
32
44
 
33
- return [validTxs, invalidTxs];
45
+ return [validTxs, invalidTxs, skippedTxs];
34
46
  }
35
47
 
36
48
  validateTx(tx: Tx): Promise<boolean> {
37
49
  return this.#validateTxFee(tx);
38
50
  }
39
51
 
52
+ #shouldSkip(tx: Tx): boolean {
53
+ const gasSettings = tx.data.constants.txContext.gasSettings;
54
+
55
+ // Skip the tx if its max fees are not enough for the current block's gas fees.
56
+ const maxFeesPerGas = gasSettings.maxFeesPerGas;
57
+ const notEnoughMaxFees =
58
+ maxFeesPerGas.feePerDaGas.lt(this.#gasFees.feePerDaGas) ||
59
+ maxFeesPerGas.feePerL2Gas.lt(this.#gasFees.feePerL2Gas);
60
+ if (notEnoughMaxFees) {
61
+ this.#log.warn(`Skipping transaction ${tx.getTxHash()} due to insufficient fee per gas`);
62
+ }
63
+ return notEnoughMaxFees;
64
+ }
65
+
40
66
  async #validateTxFee(tx: Tx): Promise<boolean> {
41
67
  const feePayer = tx.data.feePayer;
42
68
  // TODO(@spalladino) Eventually remove the is_zero condition as we should always charge fees to every tx
43
69
  if (feePayer.isZero()) {
44
- if (this.enforceFees) {
70
+ if (this.#enforceFees) {
45
71
  this.#log.warn(`Rejecting transaction ${tx.getTxHash()} due to missing fee payer`);
46
72
  } else {
47
73
  return true;
@@ -6,11 +6,11 @@ import {
6
6
  type TxValidator,
7
7
  } from '@aztec/circuit-types';
8
8
  import { type ContractDataSource } from '@aztec/circuits.js';
9
- import { createDebugLogger } from '@aztec/foundation/log';
9
+ import { createLogger } from '@aztec/foundation/log';
10
10
  import { ContractsDataSourcePublicDB, getExecutionRequestsByPhase } from '@aztec/simulator';
11
11
 
12
12
  export class PhasesTxValidator implements TxValidator<Tx> {
13
- #log = createDebugLogger('aztec:sequencer:tx_validator:tx_phases');
13
+ #log = createLogger('sequencer:tx_validator:tx_phases');
14
14
  private contractDataSource: ContractsDataSourcePublicDB;
15
15
 
16
16
  constructor(contracts: ContractDataSource, private setupAllowList: AllowedElement[]) {
@@ -29,7 +29,10 @@ export class TxValidatorFactory {
29
29
  private enforceFees: boolean,
30
30
  ) {
31
31
  this.nullifierSource = {
32
- getNullifierIndex: nullifier => this.committedDb.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer()),
32
+ getNullifierIndices: nullifiers =>
33
+ this.committedDb
34
+ .findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers)
35
+ .then(x => x.filter(index => index !== undefined) as bigint[]),
33
36
  };
34
37
 
35
38
  this.publicStateSource = {
@@ -45,13 +48,18 @@ export class TxValidatorFactory {
45
48
  new MetadataTxValidator(globalVariables.chainId, globalVariables.blockNumber),
46
49
  new DoubleSpendTxValidator(this.nullifierSource),
47
50
  new PhasesTxValidator(this.contractDataSource, setupAllowList),
48
- new GasTxValidator(this.publicStateSource, ProtocolContractAddress.FeeJuice, this.enforceFees),
51
+ new GasTxValidator(
52
+ this.publicStateSource,
53
+ ProtocolContractAddress.FeeJuice,
54
+ this.enforceFees,
55
+ globalVariables.gasFees,
56
+ ),
49
57
  );
50
58
  }
51
59
 
52
60
  validatorForProcessedTxs(fork: MerkleTreeReadOperations): TxValidator<ProcessedTx> {
53
61
  return new DoubleSpendTxValidator({
54
- getNullifierIndex: nullifier => fork.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer()),
62
+ getNullifierIndices: nullifiers => fork.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers),
55
63
  });
56
64
  }
57
65
  }