@aztec/sequencer-client 0.67.1 → 0.68.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.
Files changed (55) hide show
  1. package/dest/client/sequencer-client.d.ts +3 -1
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +17 -3
  4. package/dest/config.d.ts +3 -3
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +8 -56
  7. package/dest/index.d.ts +1 -1
  8. package/dest/index.d.ts.map +1 -1
  9. package/dest/index.js +2 -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 +5 -2
  14. package/dest/publisher/l1-publisher-metrics.d.ts.map +1 -1
  15. package/dest/publisher/l1-publisher-metrics.js +16 -1
  16. package/dest/publisher/l1-publisher.d.ts +4 -1
  17. package/dest/publisher/l1-publisher.d.ts.map +1 -1
  18. package/dest/publisher/l1-publisher.js +200 -44
  19. package/dest/publisher/utils.d.ts +1 -3
  20. package/dest/publisher/utils.d.ts.map +1 -1
  21. package/dest/publisher/utils.js +2 -8
  22. package/dest/sequencer/allowed.d.ts +3 -0
  23. package/dest/sequencer/allowed.d.ts.map +1 -0
  24. package/dest/sequencer/allowed.js +34 -0
  25. package/dest/sequencer/config.d.ts +1 -1
  26. package/dest/sequencer/config.d.ts.map +1 -1
  27. package/dest/sequencer/metrics.d.ts +2 -0
  28. package/dest/sequencer/metrics.d.ts.map +1 -1
  29. package/dest/sequencer/metrics.js +13 -2
  30. package/dest/sequencer/sequencer.d.ts +14 -11
  31. package/dest/sequencer/sequencer.d.ts.map +1 -1
  32. package/dest/sequencer/sequencer.js +160 -87
  33. package/dest/sequencer/utils.d.ts +2 -7
  34. package/dest/sequencer/utils.d.ts.map +1 -1
  35. package/dest/sequencer/utils.js +3 -11
  36. package/dest/tx_validator/gas_validator.d.ts +3 -4
  37. package/dest/tx_validator/gas_validator.d.ts.map +1 -1
  38. package/dest/tx_validator/gas_validator.js +25 -8
  39. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  40. package/dest/tx_validator/tx_validator_factory.js +6 -4
  41. package/package.json +26 -23
  42. package/src/client/sequencer-client.ts +25 -5
  43. package/src/config.ts +10 -60
  44. package/src/index.ts +1 -1
  45. package/src/publisher/index.ts +0 -1
  46. package/src/publisher/l1-publisher-metrics.ts +24 -3
  47. package/src/publisher/l1-publisher.ts +241 -68
  48. package/src/publisher/utils.ts +1 -10
  49. package/src/sequencer/allowed.ts +36 -0
  50. package/src/sequencer/config.ts +1 -1
  51. package/src/sequencer/metrics.ts +15 -1
  52. package/src/sequencer/sequencer.ts +195 -109
  53. package/src/sequencer/utils.ts +2 -11
  54. package/src/tx_validator/gas_validator.ts +32 -6
  55. package/src/tx_validator/tx_validator_factory.ts +11 -3
@@ -1,5 +1,5 @@
1
1
  import { type Tx, TxExecutionPhase, type TxValidator } from '@aztec/circuit-types';
2
- import { type AztecAddress, type Fr, FunctionSelector } from '@aztec/circuits.js';
2
+ import { type AztecAddress, type Fr, FunctionSelector, type GasFees } from '@aztec/circuits.js';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { computeFeePayerBalanceStorageSlot, getExecutionRequestsByPhase } from '@aztec/simulator';
5
5
 
@@ -12,36 +12,62 @@ export class GasTxValidator implements TxValidator<Tx> {
12
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;
@@ -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
  }