@aztec/sequencer-client 0.55.0 → 0.56.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.
Files changed (62) hide show
  1. package/dest/block_builder/index.d.ts +4 -23
  2. package/dest/block_builder/index.d.ts.map +1 -1
  3. package/dest/block_builder/index.js +3 -40
  4. package/dest/block_builder/light.d.ts +30 -0
  5. package/dest/block_builder/light.d.ts.map +1 -0
  6. package/dest/block_builder/light.js +65 -0
  7. package/dest/block_builder/orchestrator.d.ts +26 -0
  8. package/dest/block_builder/orchestrator.d.ts.map +1 -0
  9. package/dest/block_builder/orchestrator.js +40 -0
  10. package/dest/client/sequencer-client.d.ts +3 -3
  11. package/dest/client/sequencer-client.d.ts.map +1 -1
  12. package/dest/client/sequencer-client.js +3 -3
  13. package/dest/global_variable_builder/global_builder.d.ts +2 -1
  14. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  15. package/dest/global_variable_builder/global_builder.js +1 -1
  16. package/dest/index.d.ts +0 -4
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +1 -5
  19. package/dest/publisher/l1-publisher.d.ts +2 -1
  20. package/dest/publisher/l1-publisher.d.ts.map +1 -1
  21. package/dest/publisher/l1-publisher.js +6 -6
  22. package/dest/sequencer/sequencer.d.ts +5 -3
  23. package/dest/sequencer/sequencer.d.ts.map +1 -1
  24. package/dest/sequencer/sequencer.js +10 -7
  25. package/dest/tx_validator/gas_validator.d.ts +1 -0
  26. package/dest/tx_validator/gas_validator.d.ts.map +1 -1
  27. package/dest/tx_validator/gas_validator.js +7 -4
  28. package/dest/tx_validator/phases_validator.d.ts +1 -0
  29. package/dest/tx_validator/phases_validator.d.ts.map +1 -1
  30. package/dest/tx_validator/phases_validator.js +20 -20
  31. package/dest/tx_validator/test_utils.js +4 -4
  32. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  33. package/dest/tx_validator/tx_validator_factory.js +6 -8
  34. package/package.json +19 -19
  35. package/src/block_builder/index.ts +5 -49
  36. package/src/block_builder/light.ts +111 -0
  37. package/src/block_builder/orchestrator.ts +51 -0
  38. package/src/client/sequencer-client.ts +5 -5
  39. package/src/global_variable_builder/global_builder.ts +2 -1
  40. package/src/index.ts +0 -4
  41. package/src/publisher/l1-publisher.ts +7 -7
  42. package/src/sequencer/sequencer.ts +9 -8
  43. package/src/tx_validator/gas_validator.ts +7 -3
  44. package/src/tx_validator/phases_validator.ts +5 -6
  45. package/src/tx_validator/test_utils.ts +3 -3
  46. package/src/tx_validator/tx_validator_factory.ts +7 -9
  47. package/dest/tx_validator/aggregate_tx_validator.d.ts +0 -7
  48. package/dest/tx_validator/aggregate_tx_validator.d.ts.map +0 -1
  49. package/dest/tx_validator/aggregate_tx_validator.js +0 -23
  50. package/dest/tx_validator/data_validator.d.ts +0 -6
  51. package/dest/tx_validator/data_validator.d.ts.map +0 -1
  52. package/dest/tx_validator/data_validator.js +0 -47
  53. package/dest/tx_validator/double_spend_validator.d.ts +0 -11
  54. package/dest/tx_validator/double_spend_validator.d.ts.map +0 -1
  55. package/dest/tx_validator/double_spend_validator.js +0 -50
  56. package/dest/tx_validator/metadata_validator.d.ts +0 -8
  57. package/dest/tx_validator/metadata_validator.d.ts.map +0 -1
  58. package/dest/tx_validator/metadata_validator.js +0 -50
  59. package/src/tx_validator/aggregate_tx_validator.ts +0 -24
  60. package/src/tx_validator/data_validator.ts +0 -61
  61. package/src/tx_validator/double_spend_validator.ts +0 -63
  62. package/src/tx_validator/metadata_validator.ts +0 -60
@@ -1,61 +0,0 @@
1
- import { Tx, type TxValidator } from '@aztec/circuit-types';
2
- import { createDebugLogger } from '@aztec/foundation/log';
3
-
4
- export class DataTxValidator implements TxValidator<Tx> {
5
- #log = createDebugLogger('aztec:sequencer:tx_validator:tx_data');
6
-
7
- validateTxs(txs: Tx[]): Promise<[validTxs: Tx[], invalidTxs: Tx[]]> {
8
- const validTxs: Tx[] = [];
9
- const invalidTxs: Tx[] = [];
10
- for (const tx of txs) {
11
- if (!this.#hasCorrectExecutionRequests(tx)) {
12
- invalidTxs.push(tx);
13
- continue;
14
- }
15
-
16
- validTxs.push(tx);
17
- }
18
-
19
- return Promise.resolve([validTxs, invalidTxs]);
20
- }
21
-
22
- #hasCorrectExecutionRequests(tx: Tx): boolean {
23
- const callRequests = [
24
- ...tx.data.getRevertiblePublicCallRequests(),
25
- ...tx.data.getNonRevertiblePublicCallRequests(),
26
- ];
27
- if (callRequests.length !== tx.enqueuedPublicFunctionCalls.length) {
28
- this.#log.warn(
29
- `Rejecting tx ${Tx.getHash(tx)} because of mismatch number of execution requests for public calls. Expected ${
30
- callRequests.length
31
- }. Got ${tx.enqueuedPublicFunctionCalls.length}.`,
32
- );
33
- return false;
34
- }
35
-
36
- const invalidExecutionRequestIndex = tx.enqueuedPublicFunctionCalls.findIndex(
37
- (execRequest, i) => !execRequest.isForCallRequest(callRequests[i]),
38
- );
39
- if (invalidExecutionRequestIndex !== -1) {
40
- this.#log.warn(
41
- `Rejecting tx ${Tx.getHash(
42
- tx,
43
- )} because of incorrect execution requests for public call at index ${invalidExecutionRequestIndex}.`,
44
- );
45
- return false;
46
- }
47
-
48
- const teardownCallRequest = tx.data.getTeardownPublicCallRequest();
49
- const isInvalidTeardownExecutionRequest =
50
- (!teardownCallRequest && !tx.publicTeardownFunctionCall.isEmpty()) ||
51
- (teardownCallRequest && !tx.publicTeardownFunctionCall.isForCallRequest(teardownCallRequest));
52
- if (isInvalidTeardownExecutionRequest) {
53
- this.#log.warn(`Rejecting tx ${Tx.getHash(tx)} because of incorrect teardown execution requests.`);
54
- return false;
55
- }
56
-
57
- return true;
58
- }
59
-
60
- // TODO: Check logs.
61
- }
@@ -1,63 +0,0 @@
1
- import { type AnyTx, Tx, type TxValidator } from '@aztec/circuit-types';
2
- import { Fr } from '@aztec/circuits.js';
3
- import { createDebugLogger } from '@aztec/foundation/log';
4
-
5
- export interface NullifierSource {
6
- getNullifierIndex: (nullifier: Fr) => Promise<bigint | undefined>;
7
- }
8
-
9
- export class DoubleSpendTxValidator<T extends AnyTx> implements TxValidator<T> {
10
- #log = createDebugLogger('aztec:sequencer:tx_validator:tx_double_spend');
11
- #nullifierSource: NullifierSource;
12
-
13
- constructor(nullifierSource: NullifierSource) {
14
- this.#nullifierSource = nullifierSource;
15
- }
16
-
17
- async validateTxs(txs: T[]): Promise<[validTxs: T[], invalidTxs: T[]]> {
18
- const validTxs: T[] = [];
19
- const invalidTxs: T[] = [];
20
- const thisBlockNullifiers = new Set<bigint>();
21
-
22
- for (const tx of txs) {
23
- if (!(await this.#uniqueNullifiers(tx, thisBlockNullifiers))) {
24
- invalidTxs.push(tx);
25
- continue;
26
- }
27
-
28
- validTxs.push(tx);
29
- }
30
-
31
- return [validTxs, invalidTxs];
32
- }
33
-
34
- async #uniqueNullifiers(tx: AnyTx, thisBlockNullifiers: Set<bigint>): Promise<boolean> {
35
- const nullifiers = tx.data.getNonEmptyNullifiers().map(x => x.toBigInt());
36
-
37
- // Ditch this tx if it has repeated nullifiers
38
- const uniqueNullifiers = new Set(nullifiers);
39
- if (uniqueNullifiers.size !== nullifiers.length) {
40
- this.#log.warn(`Rejecting tx ${Tx.getHash(tx)} for emitting duplicate nullifiers`);
41
- return false;
42
- }
43
-
44
- for (const nullifier of nullifiers) {
45
- if (thisBlockNullifiers.has(nullifier)) {
46
- this.#log.warn(`Rejecting tx ${Tx.getHash(tx)} for repeating a nullifier in the same block`);
47
- return false;
48
- }
49
-
50
- thisBlockNullifiers.add(nullifier);
51
- }
52
-
53
- const nullifierIndexes = await Promise.all(nullifiers.map(n => this.#nullifierSource.getNullifierIndex(new Fr(n))));
54
-
55
- const hasDuplicates = nullifierIndexes.some(index => index !== undefined);
56
- if (hasDuplicates) {
57
- this.#log.warn(`Rejecting tx ${Tx.getHash(tx)} for repeating nullifiers present in state trees`);
58
- return false;
59
- }
60
-
61
- return true;
62
- }
63
- }
@@ -1,60 +0,0 @@
1
- import { type AnyTx, Tx, type TxValidator } from '@aztec/circuit-types';
2
- import { type GlobalVariables } from '@aztec/circuits.js';
3
- import { createDebugLogger } from '@aztec/foundation/log';
4
-
5
- export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
6
- #log = createDebugLogger('aztec:sequencer:tx_validator:tx_metadata');
7
- #globalVariables: GlobalVariables;
8
-
9
- constructor(globalVariables: GlobalVariables) {
10
- this.#globalVariables = globalVariables;
11
- }
12
-
13
- validateTxs(txs: T[]): Promise<[validTxs: T[], invalidTxs: T[]]> {
14
- const validTxs: T[] = [];
15
- const invalidTxs: T[] = [];
16
- for (const tx of txs) {
17
- if (!this.#hasCorrectChainId(tx)) {
18
- invalidTxs.push(tx);
19
- continue;
20
- }
21
-
22
- if (!this.#isValidForBlockNumber(tx)) {
23
- invalidTxs.push(tx);
24
- continue;
25
- }
26
-
27
- validTxs.push(tx);
28
- }
29
-
30
- return Promise.resolve([validTxs, invalidTxs]);
31
- }
32
-
33
- #hasCorrectChainId(tx: T): boolean {
34
- if (!tx.data.constants.txContext.chainId.equals(this.#globalVariables.chainId)) {
35
- this.#log.warn(
36
- `Rejecting tx ${Tx.getHash(
37
- tx,
38
- )} because of incorrect chain ${tx.data.constants.txContext.chainId.toNumber()} != ${this.#globalVariables.chainId.toNumber()}`,
39
- );
40
- return false;
41
- } else {
42
- return true;
43
- }
44
- }
45
-
46
- #isValidForBlockNumber(tx: T): boolean {
47
- const target =
48
- tx instanceof Tx
49
- ? tx.data.forRollup?.rollupValidationRequests || tx.data.forPublic!.validationRequests.forRollup
50
- : tx.data.rollupValidationRequests;
51
- const maxBlockNumber = target.maxBlockNumber;
52
-
53
- if (maxBlockNumber.isSome && maxBlockNumber.value < this.#globalVariables.blockNumber) {
54
- this.#log.warn(`Rejecting tx ${Tx.getHash(tx)} for low max block number`);
55
- return false;
56
- } else {
57
- return true;
58
- }
59
- }
60
- }