@aztec/sequencer-client 0.87.7 → 1.0.0-nightly.20250604

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 (50) hide show
  1. package/dest/client/sequencer-client.d.ts +5 -5
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +8 -8
  4. package/dest/global_variable_builder/global_builder.d.ts +4 -1
  5. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  6. package/dest/global_variable_builder/global_builder.js +14 -2
  7. package/dest/index.d.ts +1 -2
  8. package/dest/index.d.ts.map +1 -1
  9. package/dest/index.js +1 -2
  10. package/dest/publisher/config.js +1 -4
  11. package/dest/publisher/sequencer-publisher.d.ts +4 -4
  12. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  13. package/dest/publisher/sequencer-publisher.js +23 -14
  14. package/dest/sequencer/block_builder.d.ts +33 -0
  15. package/dest/sequencer/block_builder.d.ts.map +1 -0
  16. package/dest/sequencer/block_builder.js +109 -0
  17. package/dest/sequencer/index.d.ts +1 -0
  18. package/dest/sequencer/index.d.ts.map +1 -1
  19. package/dest/sequencer/index.js +1 -0
  20. package/dest/sequencer/sequencer.d.ts +17 -64
  21. package/dest/sequencer/sequencer.d.ts.map +1 -1
  22. package/dest/sequencer/sequencer.js +74 -173
  23. package/dest/sequencer/utils.d.ts +2 -2
  24. package/dest/sequencer/utils.d.ts.map +1 -1
  25. package/dest/sequencer/utils.js +6 -4
  26. package/dest/tx_validator/tx_validator_factory.d.ts +2 -6
  27. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  28. package/package.json +26 -25
  29. package/src/client/sequencer-client.ts +12 -20
  30. package/src/global_variable_builder/global_builder.ts +16 -2
  31. package/src/index.ts +1 -2
  32. package/src/publisher/config.ts +1 -1
  33. package/src/publisher/sequencer-publisher.ts +32 -21
  34. package/src/sequencer/block_builder.ts +192 -0
  35. package/src/sequencer/index.ts +1 -0
  36. package/src/sequencer/sequencer.ts +96 -221
  37. package/src/sequencer/utils.ts +14 -6
  38. package/src/tx_validator/tx_validator_factory.ts +2 -4
  39. package/dest/slasher/factory.d.ts +0 -7
  40. package/dest/slasher/factory.d.ts.map +0 -1
  41. package/dest/slasher/factory.js +0 -8
  42. package/dest/slasher/index.d.ts +0 -3
  43. package/dest/slasher/index.d.ts.map +0 -1
  44. package/dest/slasher/index.js +0 -2
  45. package/dest/slasher/slasher_client.d.ts +0 -75
  46. package/dest/slasher/slasher_client.d.ts.map +0 -1
  47. package/dest/slasher/slasher_client.js +0 -135
  48. package/src/slasher/factory.ts +0 -15
  49. package/src/slasher/index.ts +0 -2
  50. package/src/slasher/slasher_client.ts +0 -199
@@ -1,24 +1,19 @@
1
- import { type L2Block } from '@aztec/aztec.js';
1
+ import type { L2Block } from '@aztec/aztec.js';
2
2
  import { EthAddress } from '@aztec/foundation/eth-address';
3
- import type { Signature } from '@aztec/foundation/eth-signature';
4
3
  import { Fr } from '@aztec/foundation/fields';
5
- import { type DateProvider, Timer } from '@aztec/foundation/timer';
4
+ import { type DateProvider } from '@aztec/foundation/timer';
6
5
  import type { P2P } from '@aztec/p2p';
7
- import type { BlockBuilderFactory } from '@aztec/prover-client/block-builder';
8
- import type { PublicProcessorFactory } from '@aztec/simulator/server';
6
+ import type { SlasherClient } from '@aztec/slasher';
9
7
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
10
- import type { L2BlockSource } from '@aztec/stdlib/block';
11
- import type { ContractDataSource } from '@aztec/stdlib/contract';
8
+ import type { CommitteeAttestation, L2BlockSource } from '@aztec/stdlib/block';
12
9
  import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
13
- import { Gas } from '@aztec/stdlib/gas';
14
- import { type WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
10
+ import { type BuildBlockOptions, type IFullNodeBlockBuilder, type WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
15
11
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
16
- import { GlobalVariables, ProposedBlockHeader, Tx, type TxHash } from '@aztec/stdlib/tx';
12
+ import { Tx, type TxHash } from '@aztec/stdlib/tx';
17
13
  import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
18
14
  import type { ValidatorClient } from '@aztec/validator-client';
19
15
  import type { GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
20
16
  import { type SequencerPublisher } from '../publisher/sequencer-publisher.js';
21
- import type { SlasherClient } from '../slasher/slasher_client.js';
22
17
  import type { SequencerConfig } from './config.js';
23
18
  import { SequencerTimetable } from './timetable.js';
24
19
  import { SequencerState } from './utils.js';
@@ -40,14 +35,13 @@ export declare class Sequencer {
40
35
  protected p2pClient: P2P;
41
36
  protected worldState: WorldStateSynchronizer;
42
37
  protected slasherClient: SlasherClient;
43
- protected blockBuilderFactory: BlockBuilderFactory;
44
38
  protected l2BlockSource: L2BlockSource;
45
39
  protected l1ToL2MessageSource: L1ToL2MessageSource;
46
- protected publicProcessorFactory: PublicProcessorFactory;
47
- protected contractDataSource: ContractDataSource;
40
+ protected blockBuilder: IFullNodeBlockBuilder;
48
41
  protected l1Constants: SequencerRollupConstants;
49
42
  protected dateProvider: DateProvider;
50
43
  protected config: SequencerConfig;
44
+ protected telemetry: TelemetryClient;
51
45
  protected log: import("@aztec/aztec.js").Logger;
52
46
  private runningPromise?;
53
47
  private pollingIntervalMs;
@@ -67,9 +61,9 @@ export declare class Sequencer {
67
61
  protected timetable: SequencerTimetable;
68
62
  protected enforceTimeTable: boolean;
69
63
  constructor(publisher: SequencerPublisher, validatorClient: ValidatorClient | undefined, // During migration the validator client can be inactive
70
- globalsBuilder: GlobalVariableBuilder, p2pClient: P2P, worldState: WorldStateSynchronizer, slasherClient: SlasherClient, blockBuilderFactory: BlockBuilderFactory, l2BlockSource: L2BlockSource, l1ToL2MessageSource: L1ToL2MessageSource, publicProcessorFactory: PublicProcessorFactory, contractDataSource: ContractDataSource, l1Constants: SequencerRollupConstants, dateProvider: DateProvider, config?: SequencerConfig, telemetry?: TelemetryClient, log?: import("@aztec/aztec.js").Logger);
64
+ globalsBuilder: GlobalVariableBuilder, p2pClient: P2P, worldState: WorldStateSynchronizer, slasherClient: SlasherClient, l2BlockSource: L2BlockSource, l1ToL2MessageSource: L1ToL2MessageSource, blockBuilder: IFullNodeBlockBuilder, l1Constants: SequencerRollupConstants, dateProvider: DateProvider, config?: SequencerConfig, telemetry?: TelemetryClient, log?: import("@aztec/aztec.js").Logger);
71
65
  get tracer(): Tracer;
72
- getValidatorAddress(): EthAddress | undefined;
66
+ getValidatorAddresses(): EthAddress[] | undefined;
73
67
  /**
74
68
  * Updates sequencer config.
75
69
  * @param config - New parameters.
@@ -108,13 +102,6 @@ export declare class Sequencer {
108
102
  protected doRealWork(): Promise<void>;
109
103
  protected work(): Promise<void>;
110
104
  getForwarderAddress(): EthAddress;
111
- /**
112
- * Checks if we can propose at the next block and returns the slot number if we can.
113
- * @param tipArchive - The archive of the previous block.
114
- * @param proposalBlockNumber - The block number of the proposal.
115
- * @returns The slot number if we can propose at the next block, otherwise undefined.
116
- */
117
- slotForProposal(tipArchive: Buffer, proposalBlockNumber: bigint): Promise<bigint | undefined>;
118
105
  /**
119
106
  * Sets the sequencer state and checks if we have enough time left in the slot to transition to the new state.
120
107
  * @param proposedState - The new state to transition to.
@@ -125,45 +112,8 @@ export declare class Sequencer {
125
112
  * it is only used to check if we have enough time left in the slot to transition to the new state.
126
113
  */
127
114
  setState(proposedState: SequencerState, currentSlotNumber: bigint, force?: boolean): void;
128
- /**
129
- * Build a block
130
- *
131
- * @param pendingTxs - The pending transactions to construct the block from
132
- * @param newGlobalVariables - The global variables for the new block
133
- * @param opts - Whether to just validate the block as a validator, as opposed to building it as a proposal
134
- */
135
- protected buildBlock(pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, newGlobalVariables: GlobalVariables, opts?: {
136
- validateOnly?: boolean;
137
- }): Promise<{
138
- block: L2Block;
139
- publicGas: Gas;
140
- publicProcessorDuration: number;
141
- numMsgs: number;
142
- numTxs: number;
143
- numFailedTxs: number;
144
- blockBuildingTimer: Timer;
145
- usedTxs: Tx[];
146
- }>;
147
- /**
148
- * Build a block from a proposal. Used by the validator to re-execute transactions.
149
- *
150
- * @param blockNumber - The block number of the proposal.
151
- * @param header - The header of the proposal.
152
- * @param pendingTxs - The pending transactions to construct the block from.
153
- * @param opts - Whether to just validate the block as a validator, as opposed to building it as a proposal.
154
- */
155
- buildBlockFromProposal(blockNumber: Fr, header: ProposedBlockHeader, pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, opts?: {
156
- validateOnly?: boolean;
157
- }): Promise<{
158
- block: L2Block;
159
- publicGas: Gas;
160
- publicProcessorDuration: number;
161
- numMsgs: number;
162
- numTxs: number;
163
- numFailedTxs: number;
164
- blockBuildingTimer: Timer;
165
- usedTxs: Tx[];
166
- }>;
115
+ private dropFailedTxsFromP2P;
116
+ protected getDefaultBlockBuilderOptions(slot: number): BuildBlockOptions;
167
117
  /**
168
118
  * @notice Build and propose a block to the chain
169
119
  *
@@ -172,14 +122,16 @@ export declare class Sequencer {
172
122
  *
173
123
  * @param pendingTxs - Iterable of pending transactions to construct the block from
174
124
  * @param proposalHeader - The partial header constructed for the proposal
125
+ * @param newGlobalVariables - The global variables for the new block
126
+ * @param proposerAddress - The address of the proposer
175
127
  */
176
128
  private buildBlockAndEnqueuePublish;
177
- protected collectAttestations(block: L2Block, txs: Tx[]): Promise<Signature[] | undefined>;
129
+ protected collectAttestations(block: L2Block, txs: Tx[], proposerAddress: EthAddress): Promise<CommitteeAttestation[] | undefined>;
178
130
  /**
179
131
  * Publishes the L2Block to the rollup contract.
180
132
  * @param block - The L2Block to be published.
181
133
  */
182
- protected enqueuePublishL2Block(block: L2Block, attestations?: Signature[], txHashes?: TxHash[]): Promise<void>;
134
+ protected enqueuePublishL2Block(block: L2Block, attestations?: CommitteeAttestation[], txHashes?: TxHash[]): Promise<void>;
183
135
  /**
184
136
  * Returns whether all dependencies have caught up.
185
137
  * We don't check against the previous block submitted since it may have been reorg'd out.
@@ -195,5 +147,6 @@ export declare class Sequencer {
195
147
  get coinbase(): EthAddress;
196
148
  get feeRecipient(): AztecAddress;
197
149
  get maxL2BlockGas(): number | undefined;
150
+ getSlasherClient(): SlasherClient;
198
151
  }
199
152
  //# sourceMappingURL=sequencer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,iBAAiB,CAAC;AAI3D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,EAAW,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAKnE,OAAO,EAAqB,eAAe,EAAE,mBAAmB,EAAE,EAAE,EAAE,K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OAUG;YAIW,2BAA2B;cAgFzB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,EAAE,EAAE,EACT,eAAe,EAAE,UAAU,GAC1B,OAAO,CAAC,oBAAoB,EAAE,GAAG,SAAS,CAAC;IAsD9C;;;OAGG;cAIa,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,oBAAoB,EAAE,EACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;OAIG;cACa,WAAW,IAAI,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC;IA+CxF,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,kBAAkB;IAK1B,IAAI,iBAAiB,WAEpB;IAED,IAAI,QAAQ,IAAI,UAAU,CAEzB;IAED,IAAI,YAAY,IAAI,YAAY,CAE/B;IAED,IAAI,aAAa,IAAI,MAAM,GAAG,SAAS,CAEtC;IAEM,gBAAgB,IAAI,aAAa;CAGzC"}
@@ -4,24 +4,23 @@ function _ts_decorate(decorators, target, key, desc) {
4
4
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  }
7
- import { retryUntil } from '@aztec/aztec.js';
8
7
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
8
+ import { FormattedViemError } from '@aztec/ethereum';
9
9
  import { omit } from '@aztec/foundation/collection';
10
10
  import { EthAddress } from '@aztec/foundation/eth-address';
11
11
  import { Fr } from '@aztec/foundation/fields';
12
12
  import { createLogger } from '@aztec/foundation/log';
13
13
  import { RunningPromise } from '@aztec/foundation/running-promise';
14
- import { Timer, elapsed } from '@aztec/foundation/timer';
14
+ import { Timer } from '@aztec/foundation/timer';
15
15
  import { getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
16
16
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
17
17
  import { Gas } from '@aztec/stdlib/gas';
18
18
  import { SequencerConfigSchema } from '@aztec/stdlib/interfaces/server';
19
19
  import { pickFromSchema } from '@aztec/stdlib/schemas';
20
20
  import { MerkleTreeId } from '@aztec/stdlib/trees';
21
- import { ContentCommitment, GlobalVariables, ProposedBlockHeader, Tx } from '@aztec/stdlib/tx';
21
+ import { ContentCommitment, ProposedBlockHeader, Tx } from '@aztec/stdlib/tx';
22
22
  import { Attributes, L1Metrics, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
23
23
  import { VoteType } from '../publisher/sequencer-publisher.js';
24
- import { createValidatorForBlockBuilding } from '../tx_validator/tx_validator_factory.js';
25
24
  import { SequencerMetrics } from './metrics.js';
26
25
  import { SequencerTimetable, SequencerTooSlowError } from './timetable.js';
27
26
  import { SequencerState, orderAttestations } from './utils.js';
@@ -41,14 +40,13 @@ export { SequencerState };
41
40
  p2pClient;
42
41
  worldState;
43
42
  slasherClient;
44
- blockBuilderFactory;
45
43
  l2BlockSource;
46
44
  l1ToL2MessageSource;
47
- publicProcessorFactory;
48
- contractDataSource;
45
+ blockBuilder;
49
46
  l1Constants;
50
47
  dateProvider;
51
48
  config;
49
+ telemetry;
52
50
  log;
53
51
  runningPromise;
54
52
  pollingIntervalMs;
@@ -67,21 +65,20 @@ export { SequencerState };
67
65
  isFlushing;
68
66
  /** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */ timetable;
69
67
  enforceTimeTable;
70
- constructor(publisher, validatorClient, globalsBuilder, p2pClient, worldState, slasherClient, blockBuilderFactory, l2BlockSource, l1ToL2MessageSource, publicProcessorFactory, contractDataSource, l1Constants, dateProvider, config = {}, telemetry = getTelemetryClient(), log = createLogger('sequencer')){
68
+ constructor(publisher, validatorClient, globalsBuilder, p2pClient, worldState, slasherClient, l2BlockSource, l1ToL2MessageSource, blockBuilder, l1Constants, dateProvider, config = {}, telemetry = getTelemetryClient(), log = createLogger('sequencer')){
71
69
  this.publisher = publisher;
72
70
  this.validatorClient = validatorClient;
73
71
  this.globalsBuilder = globalsBuilder;
74
72
  this.p2pClient = p2pClient;
75
73
  this.worldState = worldState;
76
74
  this.slasherClient = slasherClient;
77
- this.blockBuilderFactory = blockBuilderFactory;
78
75
  this.l2BlockSource = l2BlockSource;
79
76
  this.l1ToL2MessageSource = l1ToL2MessageSource;
80
- this.publicProcessorFactory = publicProcessorFactory;
81
- this.contractDataSource = contractDataSource;
77
+ this.blockBuilder = blockBuilder;
82
78
  this.l1Constants = l1Constants;
83
79
  this.dateProvider = dateProvider;
84
80
  this.config = config;
81
+ this.telemetry = telemetry;
85
82
  this.log = log;
86
83
  this.pollingIntervalMs = 1000;
87
84
  this.maxTxsPerBlock = 32;
@@ -99,16 +96,14 @@ export { SequencerState };
99
96
  this.l1Metrics = new L1Metrics(telemetry.getMeter('SequencerL1Metrics'), publisher.l1TxUtils.client, [
100
97
  publisher.getSenderAddress()
101
98
  ]);
102
- // Register the block builder with the validator client for re-execution
103
- this.validatorClient?.registerBlockBuilder(this.buildBlockFromProposal.bind(this));
104
99
  // Register the slasher on the publisher to fetch slashing payloads
105
100
  this.publisher.registerSlashPayloadGetter(this.slasherClient.getSlashPayload.bind(this.slasherClient));
106
101
  }
107
102
  get tracer() {
108
103
  return this.metrics.tracer;
109
104
  }
110
- getValidatorAddress() {
111
- return this.validatorClient?.getValidatorAddress();
105
+ getValidatorAddresses() {
106
+ return this.validatorClient?.getValidatorAddresses();
112
107
  }
113
108
  /**
114
109
  * Updates sequencer config.
@@ -182,7 +177,7 @@ export { SequencerState };
182
177
  this.metrics.stop();
183
178
  await this.validatorClient?.stop();
184
179
  await this.runningPromise?.stop();
185
- this.slasherClient.stop();
180
+ await this.slasherClient.stop();
186
181
  this.publisher.interrupt();
187
182
  this.setState(SequencerState.STOPPED, 0n, true);
188
183
  this.l1Metrics.stop();
@@ -226,10 +221,17 @@ export { SequencerState };
226
221
  const newBlockNumber = chainTip.blockNumber + 1;
227
222
  // If we cannot find a tip archive, assume genesis.
228
223
  const chainTipArchive = chainTip.archive;
229
- const slot = await this.slotForProposal(chainTipArchive.toBuffer(), BigInt(newBlockNumber));
224
+ const { slot } = this.publisher.epochCache.getEpochAndSlotInNextSlot();
230
225
  this.metrics.observeSlotChange(slot, this.publisher.getSenderAddress().toString());
231
- if (!slot) {
232
- this.log.debug(`Cannot propose block ${newBlockNumber}`);
226
+ const proposerInNextSlot = await this.publisher.epochCache.getProposerAttesterAddressInNextSlot();
227
+ const validatorAddresses = this.validatorClient.getValidatorAddresses();
228
+ // If get proposer in next slot is undefined, then there is no proposer set, and it is in free for all (sandbox) so we continue
229
+ // If we calculate a proposer in the next slot, and it is not us, then stop
230
+ if (proposerInNextSlot !== undefined && !validatorAddresses.some((addr)=>addr.equals(proposerInNextSlot))) {
231
+ this.log.debug(`Cannot propose block ${newBlockNumber}`, {
232
+ us: validatorAddresses,
233
+ proposer: proposerInNextSlot
234
+ });
233
235
  return;
234
236
  }
235
237
  this.log.debug(`Can propose block ${newBlockNumber} at slot ${slot}`);
@@ -252,15 +254,21 @@ export { SequencerState };
252
254
  });
253
255
  let finishedFlushing = false;
254
256
  const pendingTxCount = await this.p2pClient.getPendingTxCount();
257
+ this.log.debug(`Pending tx count: ${pendingTxCount}`);
255
258
  if (pendingTxCount >= this.minTxsPerBlock || this.isFlushing) {
256
259
  // We don't fetch exactly maxTxsPerBlock txs here because we may not need all of them if we hit a limit before,
257
260
  // and also we may need to fetch more if we don't have enough valid txs.
258
261
  const pendingTxs = this.p2pClient.iteratePendingTxs();
259
- await this.buildBlockAndEnqueuePublish(pendingTxs, proposalHeader, newGlobalVariables).catch((err)=>{
260
- this.log.error(`Error building/enqueuing block`, err, {
261
- blockNumber: newBlockNumber,
262
- slot
263
- });
262
+ await this.buildBlockAndEnqueuePublish(pendingTxs, proposalHeader, newGlobalVariables, proposerInNextSlot).catch((err)=>{
263
+ if (err instanceof FormattedViemError) {
264
+ this.log.verbose(`Unable to build/enqueue block ${err.message}`);
265
+ return;
266
+ } else {
267
+ this.log.error(`Error building/enqueuing block`, err, {
268
+ blockNumber: newBlockNumber,
269
+ slot
270
+ });
271
+ }
264
272
  });
265
273
  finishedFlushing = true;
266
274
  } else {
@@ -312,24 +320,6 @@ export { SequencerState };
312
320
  return this.publisher.getForwarderAddress();
313
321
  }
314
322
  /**
315
- * Checks if we can propose at the next block and returns the slot number if we can.
316
- * @param tipArchive - The archive of the previous block.
317
- * @param proposalBlockNumber - The block number of the proposal.
318
- * @returns The slot number if we can propose at the next block, otherwise undefined.
319
- */ async slotForProposal(tipArchive, proposalBlockNumber) {
320
- const result = await this.publisher.canProposeAtNextEthBlock(tipArchive);
321
- if (!result) {
322
- return undefined;
323
- }
324
- const [slot, blockNumber] = result;
325
- if (proposalBlockNumber !== blockNumber) {
326
- const msg = `Sequencer block number mismatch. Expected ${proposalBlockNumber} but got ${blockNumber}.`;
327
- this.log.warn(msg);
328
- throw new Error(msg);
329
- }
330
- return slot;
331
- }
332
- /**
333
323
  * Sets the sequencer state and checks if we have enough time left in the slot to transition to the new state.
334
324
  * @param proposedState - The new state to transition to.
335
325
  * @param currentSlotNumber - The current slot number.
@@ -347,133 +337,28 @@ export { SequencerState };
347
337
  this.log.debug(`Transitioning from ${this.state} to ${proposedState}`);
348
338
  this.state = proposedState;
349
339
  }
350
- /**
351
- * Build a block
352
- *
353
- * @param pendingTxs - The pending transactions to construct the block from
354
- * @param newGlobalVariables - The global variables for the new block
355
- * @param opts - Whether to just validate the block as a validator, as opposed to building it as a proposal
356
- */ async buildBlock(pendingTxs, newGlobalVariables, opts = {}) {
357
- const blockNumber = newGlobalVariables.blockNumber.toNumber();
358
- const slot = newGlobalVariables.slotNumber.toBigInt();
359
- this.log.debug(`Requesting L1 to L2 messages from contract for block ${blockNumber}`);
360
- const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(BigInt(blockNumber));
361
- const msgCount = l1ToL2Messages.length;
362
- this.log.verbose(`Building block ${blockNumber} for slot ${slot}`, {
363
- slot,
364
- blockNumber,
365
- msgCount,
366
- validator: opts.validateOnly
367
- });
368
- // Sync to the previous block at least. If we cannot sync to that block because the archiver hasn't caught up,
369
- // we keep retrying until the reexecution deadline. Note that this could only happen when we are a validator,
370
- // for if we are the proposer, then world-state should already be caught up, as we check this earlier.
371
- await retryUntil(()=>this.worldState.syncImmediate(blockNumber - 1, true).then((syncedTo)=>syncedTo >= blockNumber - 1), 'sync to previous block', this.timetable.getValidatorReexecTimeEnd(), 0.1);
372
- this.log.debug(`Synced to previous block ${blockNumber - 1}`);
373
- // NB: separating the dbs because both should update the state
374
- const publicProcessorDBFork = await this.worldState.fork();
375
- const orchestratorDBFork = await this.worldState.fork();
376
- const previousBlockHeader = (await this.l2BlockSource.getBlock(blockNumber - 1))?.header ?? orchestratorDBFork.getInitialHeader();
377
- try {
378
- const processor = this.publicProcessorFactory.create(publicProcessorDBFork, newGlobalVariables, true);
379
- const blockBuildingTimer = new Timer();
380
- const blockBuilder = this.blockBuilderFactory.create(orchestratorDBFork);
381
- await blockBuilder.startNewBlock(newGlobalVariables, l1ToL2Messages, previousBlockHeader);
382
- // Deadline for processing depends on whether we're proposing a block
383
- const secondsIntoSlot = this.getSecondsIntoSlot(slot);
384
- const processingEndTimeWithinSlot = opts.validateOnly ? this.timetable.getValidatorReexecTimeEnd(secondsIntoSlot) : this.timetable.getBlockProposalExecTimeEnd(secondsIntoSlot);
385
- // Deadline is only set if enforceTimeTable is enabled.
386
- const deadline = this.enforceTimeTable ? new Date((this.getSlotStartTimestamp(slot) + processingEndTimeWithinSlot) * 1000) : undefined;
387
- this.log.verbose(`Processing pending txs`, {
388
- slot,
389
- slotStart: new Date(this.getSlotStartTimestamp(slot) * 1000),
390
- now: new Date(this.dateProvider.now()),
391
- deadline
392
- });
393
- const validator = createValidatorForBlockBuilding(publicProcessorDBFork, this.contractDataSource, newGlobalVariables, this.txPublicSetupAllowList);
394
- // TODO(#11000): Public processor should just handle processing, one tx at a time. It should be responsibility
395
- // of the sequencer to update world state and iterate over txs. We should refactor this along with unifying the
396
- // publicProcessorFork and orchestratorFork, to avoid doing tree insertions twice when building the block.
397
- const proposerLimits = {
398
- maxTransactions: this.maxTxsPerBlock,
399
- maxBlockSize: this.maxBlockSizeInBytes,
400
- maxBlockGas: this.maxBlockGas
401
- };
402
- const limits = opts.validateOnly ? {
403
- deadline
404
- } : {
405
- deadline,
406
- ...proposerLimits
407
- };
408
- const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(()=>processor.process(pendingTxs, limits, validator));
409
- if (!opts.validateOnly && failedTxs.length > 0) {
410
- const failedTxData = failedTxs.map((fail)=>fail.tx);
411
- const failedTxHashes = await Tx.getHashes(failedTxData);
412
- this.log.verbose(`Dropping failed txs ${failedTxHashes.join(', ')}`);
413
- await this.p2pClient.deleteTxs(failedTxHashes);
414
- }
415
- if (!opts.validateOnly && // We check for minTxCount only if we are proposing a block, not if we are validating it
416
- !this.isFlushing && // And we skip the check when flushing, since we want all pending txs to go out, no matter if too few
417
- this.minTxsPerBlock !== undefined && processedTxs.length < this.minTxsPerBlock) {
418
- this.log.warn(`Block ${blockNumber} has too few txs to be proposed (got ${processedTxs.length} but required ${this.minTxsPerBlock})`, {
419
- slot,
420
- blockNumber,
421
- processedTxCount: processedTxs.length
422
- });
423
- throw new Error(`Block has too few successful txs to be proposed`);
424
- }
425
- const start = process.hrtime.bigint();
426
- await blockBuilder.addTxs(processedTxs);
427
- const end = process.hrtime.bigint();
428
- const duration = Number(end - start) / 1_000;
429
- this.metrics.recordBlockBuilderTreeInsertions(duration);
430
- // All real transactions have been added, set the block as full and pad if needed
431
- const block = await blockBuilder.setBlockCompleted();
432
- // How much public gas was processed
433
- const publicGas = processedTxs.reduce((acc, tx)=>acc.add(tx.gasUsed.publicGas), Gas.empty());
434
- return {
435
- block,
436
- publicGas,
437
- publicProcessorDuration,
438
- numMsgs: l1ToL2Messages.length,
439
- numTxs: processedTxs.length,
440
- numFailedTxs: failedTxs.length,
441
- blockBuildingTimer,
442
- usedTxs
443
- };
444
- } finally{
445
- // We create a fresh processor each time to reset any cached state (eg storage writes)
446
- // We wait a bit to close the forks since the processor may still be working on a dangling tx
447
- // which was interrupted due to the processingDeadline being hit.
448
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
449
- setTimeout(async ()=>{
450
- try {
451
- await publicProcessorDBFork.close();
452
- await orchestratorDBFork.close();
453
- } catch (err) {
454
- // This can happen if the sequencer is stopped before we hit this timeout.
455
- this.log.warn(`Error closing forks for block processing`, err);
456
- }
457
- }, 5000);
340
+ async dropFailedTxsFromP2P(failedTxs) {
341
+ if (failedTxs.length === 0) {
342
+ return;
458
343
  }
344
+ const failedTxData = failedTxs.map((fail)=>fail.tx);
345
+ const failedTxHashes = await Tx.getHashes(failedTxData);
346
+ this.log.verbose(`Dropping failed txs ${failedTxHashes.join(', ')}`);
347
+ await this.p2pClient.deleteTxs(failedTxHashes);
459
348
  }
460
- /**
461
- * Build a block from a proposal. Used by the validator to re-execute transactions.
462
- *
463
- * @param blockNumber - The block number of the proposal.
464
- * @param header - The header of the proposal.
465
- * @param pendingTxs - The pending transactions to construct the block from.
466
- * @param opts - Whether to just validate the block as a validator, as opposed to building it as a proposal.
467
- */ async buildBlockFromProposal(blockNumber, header, pendingTxs, opts = {}) {
468
- const { chainId, version } = await this.globalsBuilder.getGlobalConstantVariables();
469
- const globalVariables = GlobalVariables.from({
470
- ...header,
471
- blockNumber,
472
- timestamp: new Fr(header.timestamp),
473
- chainId,
474
- version
475
- });
476
- return await this.buildBlock(pendingTxs, globalVariables, opts);
349
+ getDefaultBlockBuilderOptions(slot) {
350
+ // Deadline for processing depends on whether we're proposing a block
351
+ const secondsIntoSlot = this.getSecondsIntoSlot(slot);
352
+ const processingEndTimeWithinSlot = this.timetable.getBlockProposalExecTimeEnd(secondsIntoSlot);
353
+ // Deadline is only set if enforceTimeTable is enabled.
354
+ const deadline = this.enforceTimeTable ? new Date((this.getSlotStartTimestamp(slot) + processingEndTimeWithinSlot) * 1000) : undefined;
355
+ return {
356
+ maxTransactions: this.maxTxsPerBlock,
357
+ maxBlockSize: this.maxBlockSizeInBytes,
358
+ maxBlockGas: this.maxBlockGas,
359
+ txPublicSetupAllowList: this.txPublicSetupAllowList,
360
+ deadline
361
+ };
477
362
  }
478
363
  /**
479
364
  * @notice Build and propose a block to the chain
@@ -483,7 +368,9 @@ export { SequencerState };
483
368
  *
484
369
  * @param pendingTxs - Iterable of pending transactions to construct the block from
485
370
  * @param proposalHeader - The partial header constructed for the proposal
486
- */ async buildBlockAndEnqueuePublish(pendingTxs, proposalHeader, newGlobalVariables) {
371
+ * @param newGlobalVariables - The global variables for the new block
372
+ * @param proposerAddress - The address of the proposer
373
+ */ async buildBlockAndEnqueuePublish(pendingTxs, proposalHeader, newGlobalVariables, proposerAddress) {
487
374
  await this.publisher.validateBlockForSubmission(proposalHeader);
488
375
  const blockNumber = newGlobalVariables.blockNumber.toNumber();
489
376
  const slot = proposalHeader.slotNumber.toBigInt();
@@ -491,9 +378,20 @@ export { SequencerState };
491
378
  const workTimer = new Timer();
492
379
  this.setState(SequencerState.CREATING_BLOCK, slot);
493
380
  try {
494
- const buildBlockRes = await this.buildBlock(pendingTxs, newGlobalVariables);
495
- const { publicGas, block, publicProcessorDuration, numTxs, numMsgs, blockBuildingTimer, usedTxs } = buildBlockRes;
381
+ const blockBuilderOptions = this.getDefaultBlockBuilderOptions(Number(slot));
382
+ const buildBlockRes = await this.blockBuilder.buildBlock(pendingTxs, newGlobalVariables, blockBuilderOptions);
383
+ const { publicGas, block, publicProcessorDuration, numTxs, numMsgs, blockBuildingTimer, usedTxs, failedTxs } = buildBlockRes;
496
384
  this.metrics.recordBuiltBlock(workTimer.ms(), publicGas.l2Gas);
385
+ await this.dropFailedTxsFromP2P(failedTxs);
386
+ const minTxsPerBlock = this.isFlushing ? 0 : this.minTxsPerBlock;
387
+ if (numTxs < minTxsPerBlock) {
388
+ this.log.warn(`Block ${blockNumber} has too few txs to be proposed (got ${numTxs} but required ${minTxsPerBlock})`, {
389
+ slot,
390
+ blockNumber,
391
+ numTxs
392
+ });
393
+ throw new Error(`Block has too few successful txs to be proposed`);
394
+ }
497
395
  // TODO(@PhilWindle) We should probably periodically check for things like another
498
396
  // block being published before ours instead of just waiting on our block
499
397
  await this.publisher.validateBlockForSubmission(block.header.toPropose());
@@ -515,7 +413,7 @@ export { SequencerState };
515
413
  });
516
414
  this.log.debug('Collecting attestations');
517
415
  const stopCollectingAttestationsTimer = this.metrics.startCollectingAttestationsTimer();
518
- const attestations = await this.collectAttestations(block, usedTxs);
416
+ const attestations = await this.collectAttestations(block, usedTxs, proposerAddress);
519
417
  if (attestations !== undefined) {
520
418
  this.log.verbose(`Collected ${attestations.length} attestations`, {
521
419
  blockHash,
@@ -529,7 +427,7 @@ export { SequencerState };
529
427
  throw err;
530
428
  }
531
429
  }
532
- async collectAttestations(block, txs) {
430
+ async collectAttestations(block, txs, proposerAddress) {
533
431
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/7962): inefficient to have a round trip in here - this should be cached
534
432
  const committee = await this.publisher.getCurrentEpochCommittee();
535
433
  if (committee.length === 0) {
@@ -550,7 +448,7 @@ export { SequencerState };
550
448
  const blockProposalOptions = {
551
449
  publishFullTxs: !!this.config.publishTxsWithProposals
552
450
  };
553
- const proposal = await this.validatorClient.createBlockProposal(block.header.globalVariables.blockNumber, block.header.toPropose(), block.archive.root, block.header.state, txs, blockProposalOptions);
451
+ const proposal = await this.validatorClient.createBlockProposal(block.header.globalVariables.blockNumber, block.header.toPropose(), block.archive.root, block.header.state, txs, proposerAddress, blockProposalOptions);
554
452
  if (!proposal) {
555
453
  const msg = `Failed to create block proposal`;
556
454
  throw new Error(msg);
@@ -643,6 +541,9 @@ export { SequencerState };
643
541
  get maxL2BlockGas() {
644
542
  return this.config.maxL2BlockGas;
645
543
  }
544
+ getSlasherClient() {
545
+ return this.slasherClient;
546
+ }
646
547
  }
647
548
  _ts_decorate([
648
549
  trackSpan('Sequencer.work')
@@ -1,5 +1,5 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
- import { Signature } from '@aztec/foundation/eth-signature';
2
+ import { CommitteeAttestation } from '@aztec/stdlib/block';
3
3
  import type { BlockAttestation } from '@aztec/stdlib/p2p';
4
4
  export declare enum SequencerState {
5
5
  /**
@@ -44,5 +44,5 @@ export declare function sequencerStateToNumber(state: SequencerState): number;
44
44
  *
45
45
  * @todo: perform this logic within the memory attestation store instead?
46
46
  */
47
- export declare function orderAttestations(attestations: BlockAttestation[], orderAddresses: EthAddress[]): Signature[];
47
+ export declare function orderAttestations(attestations: BlockAttestation[], orderAddresses: EthAddress[]): CommitteeAttestation[];
48
48
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/sequencer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,oBAAY,cAAc;IACxB;;OAEG;IACH,OAAO,YAAY;IACnB;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,aAAa,kBAAkB;IAC/B;;OAEG;IACH,cAAc,mBAAmB;IACjC;;OAEG;IACH,qBAAqB,0BAA0B;IAC/C;;OAEG;IACH,cAAc,mBAAmB;IACjC;;OAEG;IACH,uBAAuB,4BAA4B;IACnD;;OAEG;IACH,gBAAgB,qBAAqB;CACtC;AAED,MAAM,MAAM,sBAAsB,GAAG,MAAM,cAAc,CAAC;AAE1D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,gBAAgB,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,SAAS,EAAE,CAgB7G"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/sequencer/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,oBAAY,cAAc;IACxB;;OAEG;IACH,OAAO,YAAY;IACnB;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,aAAa,kBAAkB;IAC/B;;OAEG;IACH,cAAc,mBAAmB;IACjC;;OAEG;IACH,qBAAqB,0BAA0B;IAC/C;;OAEG;IACH,cAAc,mBAAmB;IACjC;;OAEG;IACH,uBAAuB,4BAA4B;IACnD;;OAEG;IACH,gBAAgB,qBAAqB;CACtC;AAED,MAAM,MAAM,sBAAsB,GAAG,MAAM,cAAc,CAAC;AAE1D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,gBAAgB,EAAE,EAChC,cAAc,EAAE,UAAU,EAAE,GAC3B,oBAAoB,EAAE,CAqBxB"}
@@ -1,4 +1,4 @@
1
- import { Signature } from '@aztec/foundation/eth-signature';
1
+ import { CommitteeAttestation } from '@aztec/stdlib/block';
2
2
  export var SequencerState = /*#__PURE__*/ function(SequencerState) {
3
3
  /**
4
4
  * Sequencer is stopped and not processing any txs from the pool.
@@ -40,12 +40,14 @@ export function sequencerStateToNumber(state) {
40
40
  const attestationMap = new Map();
41
41
  for (const attestation of attestations){
42
42
  const sender = attestation.getSender();
43
- attestationMap.set(sender.toString(), attestation);
43
+ if (sender) {
44
+ attestationMap.set(sender.toString(), CommitteeAttestation.fromAddressAndSignature(sender, attestation.signature));
45
+ }
44
46
  }
45
- // Create the ordered array based on the orderAddresses, else return an empty signature
47
+ // Create the ordered array based on the orderAddresses, else return an empty attestation
46
48
  const orderedAttestations = orderAddresses.map((address)=>{
47
49
  const addressString = address.toString();
48
- return attestationMap.get(addressString)?.signature || Signature.empty();
50
+ return attestationMap.get(addressString) || CommitteeAttestation.fromAddress(address);
49
51
  });
50
52
  return orderedAttestations;
51
53
  }
@@ -1,8 +1,7 @@
1
1
  import type { ContractDataSource } from '@aztec/stdlib/contract';
2
2
  import type { GasFees } from '@aztec/stdlib/gas';
3
- import type { AllowedElement, ClientProtocolCircuitVerifier, MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
3
+ import type { AllowedElement, ClientProtocolCircuitVerifier, MerkleTreeReadOperations, PublicProcessorValidator } from '@aztec/stdlib/interfaces/server';
4
4
  import { GlobalVariables, type Tx, type TxValidator } from '@aztec/stdlib/tx';
5
- import { NullifierCache } from './nullifier_cache.js';
6
5
  export declare function createValidatorForAcceptingTxs(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, verifier: ClientProtocolCircuitVerifier | undefined, { blockNumber, l1ChainId, rollupVersion, setupAllowList, gasFees, skipFeeEnforcement, }: {
7
6
  blockNumber: number;
8
7
  l1ChainId: number;
@@ -11,8 +10,5 @@ export declare function createValidatorForAcceptingTxs(db: MerkleTreeReadOperati
11
10
  gasFees: GasFees;
12
11
  skipFeeEnforcement?: boolean;
13
12
  }): TxValidator<Tx>;
14
- export declare function createValidatorForBlockBuilding(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, globalVariables: GlobalVariables, setupAllowList: AllowedElement[]): {
15
- preprocessValidator: TxValidator<Tx>;
16
- nullifierCache: NullifierCache;
17
- };
13
+ export declare function createValidatorForBlockBuilding(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, globalVariables: GlobalVariables, setupAllowList: AllowedElement[]): PublicProcessorValidator;
18
14
  //# sourceMappingURL=tx_validator_factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tx_validator_factory.d.ts","sourceRoot":"","sources":["../../src/tx_validator/tx_validator_factory.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,EACnD,EACE,WAAW,EACX,SAAS,EACT,aAAa,EACb,cAAc,EACd,OAAO,EACP,kBAAkB,GACnB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,GACA,WAAW,CAAC,EAAE,CAAC,CAwBjB;AAED,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAAE,GAC/B;IACD,mBAAmB,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IACrC,cAAc,EAAE,cAAc,CAAC;CAChC,CAgBA"}
1
+ {"version":3,"file":"tx_validator_factory.d.ts","sourceRoot":"","sources":["../../src/tx_validator/tx_validator_factory.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI9E,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,EACnD,EACE,WAAW,EACX,SAAS,EACT,aAAa,EACb,cAAc,EACd,OAAO,EACP,kBAAkB,GACnB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,GACA,WAAW,CAAC,EAAE,CAAC,CAwBjB;AAED,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAAE,GAC/B,wBAAwB,CAgB1B"}