@aztec/sequencer-client 0.69.1 → 0.70.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.
- package/dest/client/sequencer-client.d.ts +2 -0
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +3 -3
- package/dest/publisher/index.d.ts +0 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +1 -2
- package/dest/publisher/l1-publisher.d.ts +9 -3
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +63 -77
- package/dest/sequencer/metrics.d.ts +2 -1
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +8 -2
- package/dest/sequencer/sequencer.d.ts +17 -16
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +57 -19
- package/dest/test/index.d.ts +18 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +8 -0
- package/dest/{publisher → test}/test-l1-publisher.d.ts +1 -1
- package/dest/test/test-l1-publisher.d.ts.map +1 -0
- package/dest/test/test-l1-publisher.js +11 -0
- package/dest/tx_validator/archive_cache.d.ts +14 -0
- package/dest/tx_validator/archive_cache.d.ts.map +1 -0
- package/dest/tx_validator/archive_cache.js +22 -0
- package/dest/tx_validator/gas_validator.js +2 -2
- package/dest/tx_validator/phases_validator.js +2 -2
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +9 -6
- package/package.json +22 -20
- package/src/client/sequencer-client.ts +5 -2
- package/src/publisher/index.ts +0 -1
- package/src/publisher/l1-publisher.ts +84 -82
- package/src/sequencer/metrics.ts +11 -1
- package/src/sequencer/sequencer.ts +83 -34
- package/src/test/index.ts +23 -0
- package/src/{publisher → test}/test-l1-publisher.ts +1 -1
- package/src/tx_validator/archive_cache.ts +27 -0
- package/src/tx_validator/gas_validator.ts +1 -1
- package/src/tx_validator/phases_validator.ts +1 -1
- package/src/tx_validator/tx_validator_factory.ts +8 -1
- package/dest/publisher/test-l1-publisher.d.ts.map +0 -1
- package/dest/publisher/test-l1-publisher.js +0 -11
- package/dest/publisher/utils.d.ts +0 -2
- package/dest/publisher/utils.d.ts.map +0 -1
- package/dest/publisher/utils.js +0 -13
- package/src/publisher/utils.ts +0 -14
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
type GlobalVariables,
|
|
22
22
|
StateReference,
|
|
23
23
|
} from '@aztec/circuits.js';
|
|
24
|
+
import { prettyLogViemErrorMsg } from '@aztec/ethereum';
|
|
24
25
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
25
26
|
import { omit } from '@aztec/foundation/collection';
|
|
26
27
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -31,13 +32,14 @@ import { pickFromSchema } from '@aztec/foundation/schemas';
|
|
|
31
32
|
import { type DateProvider, Timer, elapsed } from '@aztec/foundation/timer';
|
|
32
33
|
import { type P2P } from '@aztec/p2p';
|
|
33
34
|
import { type BlockBuilderFactory } from '@aztec/prover-client/block-builder';
|
|
34
|
-
import { type PublicProcessorFactory } from '@aztec/simulator';
|
|
35
|
+
import { type PublicProcessorFactory } from '@aztec/simulator/server';
|
|
35
36
|
import { Attributes, type TelemetryClient, type Tracer, trackSpan } from '@aztec/telemetry-client';
|
|
36
37
|
import { type ValidatorClient } from '@aztec/validator-client';
|
|
37
38
|
|
|
39
|
+
import assert from 'assert';
|
|
40
|
+
|
|
38
41
|
import { type GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
|
|
39
42
|
import { type L1Publisher, VoteType } from '../publisher/l1-publisher.js';
|
|
40
|
-
import { prettyLogViemErrorMsg } from '../publisher/utils.js';
|
|
41
43
|
import { type SlasherClient } from '../slasher/slasher_client.js';
|
|
42
44
|
import { createValidatorsForBlockBuilding } from '../tx_validator/tx_validator_factory.js';
|
|
43
45
|
import { getDefaultAllowedSetupFunctions } from './allowed.js';
|
|
@@ -85,7 +87,8 @@ export class Sequencer {
|
|
|
85
87
|
private allowedInSetup: AllowedElement[] = getDefaultAllowedSetupFunctions();
|
|
86
88
|
private maxBlockSizeInBytes: number = 1024 * 1024;
|
|
87
89
|
private maxBlockGas: Gas = new Gas(10e9, 10e9);
|
|
88
|
-
|
|
90
|
+
protected processTxTime: number = 12;
|
|
91
|
+
private attestationPropagationTime: number = 2;
|
|
89
92
|
private metrics: SequencerMetrics;
|
|
90
93
|
private isFlushing: boolean = false;
|
|
91
94
|
|
|
@@ -97,22 +100,22 @@ export class Sequencer {
|
|
|
97
100
|
protected enforceTimeTable: boolean = false;
|
|
98
101
|
|
|
99
102
|
constructor(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
protected publisher: L1Publisher,
|
|
104
|
+
protected validatorClient: ValidatorClient | undefined, // During migration the validator client can be inactive
|
|
105
|
+
protected globalsBuilder: GlobalVariableBuilder,
|
|
106
|
+
protected p2pClient: P2P,
|
|
107
|
+
protected worldState: WorldStateSynchronizer,
|
|
108
|
+
protected slasherClient: SlasherClient,
|
|
109
|
+
protected blockBuilderFactory: BlockBuilderFactory,
|
|
110
|
+
protected l2BlockSource: L2BlockSource,
|
|
111
|
+
protected l1ToL2MessageSource: L1ToL2MessageSource,
|
|
112
|
+
protected publicProcessorFactory: PublicProcessorFactory,
|
|
113
|
+
protected contractDataSource: ContractDataSource,
|
|
111
114
|
protected l1Constants: SequencerRollupConstants,
|
|
112
|
-
|
|
115
|
+
protected dateProvider: DateProvider,
|
|
113
116
|
telemetry: TelemetryClient,
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
protected config: SequencerConfig = {},
|
|
118
|
+
protected log = createLogger('sequencer'),
|
|
116
119
|
) {
|
|
117
120
|
this.updateConfig(config);
|
|
118
121
|
this.metrics = new SequencerMetrics(telemetry, () => this.state, 'Sequencer');
|
|
@@ -168,7 +171,9 @@ export class Sequencer {
|
|
|
168
171
|
if (config.maxL1TxInclusionTimeIntoSlot !== undefined) {
|
|
169
172
|
this.maxL1TxInclusionTimeIntoSlot = config.maxL1TxInclusionTimeIntoSlot;
|
|
170
173
|
}
|
|
171
|
-
|
|
174
|
+
if (config.enforceTimeTable !== undefined) {
|
|
175
|
+
this.enforceTimeTable = config.enforceTimeTable;
|
|
176
|
+
}
|
|
172
177
|
|
|
173
178
|
this.setTimeTable();
|
|
174
179
|
|
|
@@ -183,15 +188,17 @@ export class Sequencer {
|
|
|
183
188
|
// How long it takes to get ready to start building
|
|
184
189
|
const blockPrepareTime = 1;
|
|
185
190
|
|
|
186
|
-
// How long it takes to for attestations to travel across the p2p layer
|
|
191
|
+
// How long it takes to for proposals and attestations to travel across the p2p layer (one-way)
|
|
187
192
|
const attestationPropagationTime = 2;
|
|
193
|
+
this.attestationPropagationTime = attestationPropagationTime;
|
|
188
194
|
|
|
189
195
|
// How long it takes to get a published block into L1. L1 builders typically accept txs up to 4 seconds into their slot,
|
|
190
196
|
// but we'll timeout sooner to give it more time to propagate (remember we also have blobs!). Still, when working in anvil,
|
|
191
|
-
// we can just post in the very last second of the L1 slot.
|
|
197
|
+
// we can just post in the very last second of the L1 slot and still expect the tx to be accepted.
|
|
192
198
|
const l1PublishingTime = this.l1Constants.ethereumSlotDuration - this.maxL1TxInclusionTimeIntoSlot;
|
|
193
199
|
|
|
194
|
-
// How much time we spend validating and processing a block after building it
|
|
200
|
+
// How much time we spend validating and processing a block after building it,
|
|
201
|
+
// and assembling the proposal to send to attestors
|
|
195
202
|
const blockValidationTime = 1;
|
|
196
203
|
|
|
197
204
|
// How much time we have left in the slot for actually processing txs and building the block.
|
|
@@ -199,11 +206,11 @@ export class Sequencer {
|
|
|
199
206
|
this.aztecSlotDuration -
|
|
200
207
|
initialTime -
|
|
201
208
|
blockPrepareTime -
|
|
202
|
-
|
|
209
|
+
blockValidationTime -
|
|
203
210
|
2 * attestationPropagationTime -
|
|
204
|
-
|
|
211
|
+
l1PublishingTime;
|
|
205
212
|
|
|
206
|
-
// Check that
|
|
213
|
+
// Check that we actually have time left for processing txs
|
|
207
214
|
if (this.enforceTimeTable && remainingTimeInSlot < 0) {
|
|
208
215
|
throw new Error(`Not enough time for block building in ${this.aztecSlotDuration}s slot`);
|
|
209
216
|
}
|
|
@@ -212,6 +219,22 @@ export class Sequencer {
|
|
|
212
219
|
const processTxsTime = remainingTimeInSlot / 2;
|
|
213
220
|
this.processTxTime = processTxsTime;
|
|
214
221
|
|
|
222
|
+
// Sanity check
|
|
223
|
+
const totalSlotTime =
|
|
224
|
+
initialTime + // Archiver, world-state, and p2p sync
|
|
225
|
+
blockPrepareTime + // Setup globals, initial checks, etc
|
|
226
|
+
processTxsTime + // Processing public txs for building the block
|
|
227
|
+
blockValidationTime + // Validating the block produced
|
|
228
|
+
attestationPropagationTime + // Propagating the block proposal to validators
|
|
229
|
+
processTxsTime + // Validators run public txs before signing
|
|
230
|
+
attestationPropagationTime + // Attestations fly back to the proposer
|
|
231
|
+
l1PublishingTime; // The publish tx sits on the L1 mempool waiting to be picked up
|
|
232
|
+
|
|
233
|
+
assert(
|
|
234
|
+
totalSlotTime === this.aztecSlotDuration,
|
|
235
|
+
`Computed total slot time does not match slot duration: ${totalSlotTime}s`,
|
|
236
|
+
);
|
|
237
|
+
|
|
215
238
|
const newTimeTable: Record<SequencerState, number> = {
|
|
216
239
|
// No checks needed for any of these transitions
|
|
217
240
|
[SequencerState.STOPPED]: this.aztecSlotDuration,
|
|
@@ -472,7 +495,12 @@ export class Sequencer {
|
|
|
472
495
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(blockNumber);
|
|
473
496
|
const msgCount = l1ToL2Messages.length;
|
|
474
497
|
|
|
475
|
-
this.log.verbose(`Building block ${blockNumber} for slot ${slot}`, {
|
|
498
|
+
this.log.verbose(`Building block ${blockNumber} for slot ${slot}`, {
|
|
499
|
+
slot,
|
|
500
|
+
blockNumber,
|
|
501
|
+
msgCount,
|
|
502
|
+
validator: opts.validateOnly,
|
|
503
|
+
});
|
|
476
504
|
|
|
477
505
|
// Sync to the previous block at least
|
|
478
506
|
await this.worldState.syncImmediate(newGlobalVariables.blockNumber.toNumber() - 1);
|
|
@@ -493,12 +521,19 @@ export class Sequencer {
|
|
|
493
521
|
const blockBuilder = this.blockBuilderFactory.create(orchestratorFork);
|
|
494
522
|
await blockBuilder.startNewBlock(newGlobalVariables, l1ToL2Messages);
|
|
495
523
|
|
|
496
|
-
//
|
|
524
|
+
// When building a block as a proposer, we set the deadline for tx processing to the start of the
|
|
525
|
+
// CREATING_BLOCK phase, plus the expected time for tx processing. When validating, we start counting
|
|
526
|
+
// the time for tx processing from the start of the COLLECTING_ATTESTATIONS phase plus the attestation
|
|
527
|
+
// propagation time. See the comments in setTimeTable for more details.
|
|
528
|
+
const processingEndTimeWithinSlot = opts.validateOnly
|
|
529
|
+
? this.timeTable[SequencerState.COLLECTING_ATTESTATIONS] + this.attestationPropagationTime + this.processTxTime
|
|
530
|
+
: this.timeTable[SequencerState.CREATING_BLOCK] + this.processTxTime;
|
|
531
|
+
|
|
497
532
|
// Deadline is only set if enforceTimeTable is enabled.
|
|
498
|
-
const processingEndTimeWithinSlot = this.timeTable[SequencerState.CREATING_BLOCK] + this.processTxTime;
|
|
499
533
|
const deadline = this.enforceTimeTable
|
|
500
534
|
? new Date((this.getSlotStartTimestamp(slot) + processingEndTimeWithinSlot) * 1000)
|
|
501
535
|
: undefined;
|
|
536
|
+
|
|
502
537
|
this.log.verbose(`Processing pending txs`, {
|
|
503
538
|
slot,
|
|
504
539
|
slotStart: new Date(this.getSlotStartTimestamp(slot) * 1000),
|
|
@@ -514,7 +549,7 @@ export class Sequencer {
|
|
|
514
549
|
this.allowedInSetup,
|
|
515
550
|
);
|
|
516
551
|
|
|
517
|
-
//
|
|
552
|
+
// TODO(#11000): Public processor should just handle processing, one tx at a time. It should be responsibility
|
|
518
553
|
// of the sequencer to update world state and iterate over txs. We should refactor this along with unifying the
|
|
519
554
|
// publicProcessorFork and orchestratorFork, to avoid doing tree insertions twice when building the block.
|
|
520
555
|
const limits = { deadline, maxTransactions: this.maxTxsPerBlock, maxBlockSize: this.maxBlockSizeInBytes };
|
|
@@ -522,7 +557,7 @@ export class Sequencer {
|
|
|
522
557
|
processor.process(pendingTxs, limits, validators),
|
|
523
558
|
);
|
|
524
559
|
|
|
525
|
-
if (failedTxs.length > 0) {
|
|
560
|
+
if (!opts.validateOnly && failedTxs.length > 0) {
|
|
526
561
|
const failedTxData = failedTxs.map(fail => fail.tx);
|
|
527
562
|
this.log.verbose(`Dropping failed txs ${Tx.getHashes(failedTxData).join(', ')}`);
|
|
528
563
|
await this.p2pClient.deleteTxs(Tx.getHashes(failedTxData));
|
|
@@ -550,11 +585,16 @@ export class Sequencer {
|
|
|
550
585
|
// All real transactions have been added, set the block as full and pad if needed
|
|
551
586
|
const block = await blockBuilder.setBlockCompleted();
|
|
552
587
|
|
|
588
|
+
// How much public gas was processed
|
|
589
|
+
const publicGas = processedTxs.reduce((acc, tx) => acc.add(tx.gasUsed.publicGas), Gas.empty());
|
|
590
|
+
|
|
553
591
|
return {
|
|
554
592
|
block,
|
|
593
|
+
publicGas,
|
|
555
594
|
publicProcessorDuration,
|
|
556
595
|
numMsgs: l1ToL2Messages.length,
|
|
557
596
|
numTxs: processedTxs.length,
|
|
597
|
+
numFailedTxs: failedTxs.length,
|
|
558
598
|
blockBuildingTimer,
|
|
559
599
|
};
|
|
560
600
|
} finally {
|
|
@@ -605,7 +645,7 @@ export class Sequencer {
|
|
|
605
645
|
|
|
606
646
|
try {
|
|
607
647
|
const buildBlockRes = await this.buildBlock(pendingTxs, newGlobalVariables, historicalHeader);
|
|
608
|
-
const { block, publicProcessorDuration, numTxs, numMsgs, blockBuildingTimer } = buildBlockRes;
|
|
648
|
+
const { publicGas, block, publicProcessorDuration, numTxs, numMsgs, blockBuildingTimer } = buildBlockRes;
|
|
609
649
|
|
|
610
650
|
// TODO(@PhilWindle) We should probably periodically check for things like another
|
|
611
651
|
// block being published before ours instead of just waiting on our block
|
|
@@ -647,16 +687,19 @@ export class Sequencer {
|
|
|
647
687
|
const proofQuote = await proofQuotePromise;
|
|
648
688
|
|
|
649
689
|
await this.publishL2Block(block, attestations, txHashes, proofQuote);
|
|
650
|
-
this.metrics.recordPublishedBlock(workDuration);
|
|
690
|
+
this.metrics.recordPublishedBlock(workDuration, publicGas.l2Gas);
|
|
691
|
+
const duration = Math.ceil(workDuration);
|
|
692
|
+
const manaPerSecond = Math.ceil((publicGas.l2Gas * 1000) / duration);
|
|
651
693
|
this.log.info(
|
|
652
|
-
`Published block ${block.number} with ${numTxs} txs and ${numMsgs} messages in ${
|
|
694
|
+
`Published block ${block.number} with ${numTxs} txs and ${numMsgs} messages in ${duration} ms at ${manaPerSecond} mana/s`,
|
|
653
695
|
{
|
|
696
|
+
publicGas,
|
|
654
697
|
blockNumber: block.number,
|
|
655
698
|
blockHash: blockHash,
|
|
656
699
|
slot,
|
|
657
700
|
txCount: txHashes.length,
|
|
658
701
|
msgCount: numMsgs,
|
|
659
|
-
duration
|
|
702
|
+
duration,
|
|
660
703
|
submitter: this.publisher.getSenderAddress().toString(),
|
|
661
704
|
},
|
|
662
705
|
);
|
|
@@ -772,7 +815,13 @@ export class Sequencer {
|
|
|
772
815
|
// Publishes new block to the network and awaits the tx to be mined
|
|
773
816
|
this.setState(SequencerState.PUBLISHING_BLOCK, block.header.globalVariables.slotNumber.toBigInt());
|
|
774
817
|
|
|
775
|
-
|
|
818
|
+
// Time out tx at the end of the slot
|
|
819
|
+
const slot = block.header.globalVariables.slotNumber.toNumber();
|
|
820
|
+
const txTimeoutAt = new Date((this.getSlotStartTimestamp(slot) + this.aztecSlotDuration) * 1000);
|
|
821
|
+
|
|
822
|
+
const publishedL2Block = await this.publisher.proposeL2Block(block, attestations, txHashes, proofQuote, {
|
|
823
|
+
txTimeoutAt,
|
|
824
|
+
});
|
|
776
825
|
if (!publishedL2Block) {
|
|
777
826
|
throw new Error(`Failed to publish block ${block.number}`);
|
|
778
827
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type PublicProcessorFactory } from '@aztec/simulator/server';
|
|
2
|
+
|
|
3
|
+
import { SequencerClient } from '../client/sequencer-client.js';
|
|
4
|
+
import { type L1Publisher } from '../publisher/l1-publisher.js';
|
|
5
|
+
import { Sequencer } from '../sequencer/sequencer.js';
|
|
6
|
+
import { type SequencerState } from '../sequencer/utils.js';
|
|
7
|
+
|
|
8
|
+
class TestSequencer_ extends Sequencer {
|
|
9
|
+
public override publicProcessorFactory!: PublicProcessorFactory;
|
|
10
|
+
public override timeTable!: Record<SequencerState, number>;
|
|
11
|
+
public override processTxTime!: number;
|
|
12
|
+
public override publisher!: L1Publisher;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type TestSequencer = TestSequencer_;
|
|
16
|
+
|
|
17
|
+
class TestSequencerClient_ extends SequencerClient {
|
|
18
|
+
public override sequencer!: TestSequencer;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type TestSequencerClient = TestSequencerClient_;
|
|
22
|
+
|
|
23
|
+
export * from './test-l1-publisher.js';
|
|
@@ -3,7 +3,7 @@ import { type Delayer, withDelayer } from '@aztec/ethereum/test';
|
|
|
3
3
|
|
|
4
4
|
import { type Chain, type HttpTransport, type PrivateKeyAccount, type WalletClient } from 'viem';
|
|
5
5
|
|
|
6
|
-
import { L1Publisher } from '
|
|
6
|
+
import { L1Publisher } from '../publisher/l1-publisher.js';
|
|
7
7
|
|
|
8
8
|
export class TestL1Publisher extends L1Publisher {
|
|
9
9
|
public delayer: Delayer | undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MerkleTreeId, type MerkleTreeReadOperations } from '@aztec/circuit-types';
|
|
2
|
+
import { type Fr } from '@aztec/circuits.js';
|
|
3
|
+
import { type ArchiveSource } from '@aztec/p2p';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Implements an archive source by checking a DB and an in-memory collection.
|
|
7
|
+
* Intended for validating transactions as they are added to a block.
|
|
8
|
+
*/
|
|
9
|
+
export class ArchiveCache implements ArchiveSource {
|
|
10
|
+
archives: Map<string, bigint>;
|
|
11
|
+
|
|
12
|
+
constructor(private db: MerkleTreeReadOperations) {
|
|
13
|
+
this.archives = new Map<string, bigint>();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public async getArchiveIndices(archives: Fr[]): Promise<(bigint | undefined)[]> {
|
|
17
|
+
const toCheckDb = archives.filter(n => !this.archives.has(n.toString()));
|
|
18
|
+
const dbHits = await this.db.findLeafIndices(MerkleTreeId.ARCHIVE, toCheckDb);
|
|
19
|
+
dbHits.forEach((x, index) => {
|
|
20
|
+
if (x !== undefined) {
|
|
21
|
+
this.archives.set(toCheckDb[index].toString(), x);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return archives.map(n => this.archives.get(n.toString()));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Tx, TxExecutionPhase, type TxValidationResult, type TxValidator } from '@aztec/circuit-types';
|
|
2
2
|
import { type AztecAddress, type Fr, FunctionSelector, type GasFees } from '@aztec/circuits.js';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { computeFeePayerBalanceStorageSlot, getExecutionRequestsByPhase } from '@aztec/simulator';
|
|
4
|
+
import { computeFeePayerBalanceStorageSlot, getExecutionRequestsByPhase } from '@aztec/simulator/server';
|
|
5
5
|
|
|
6
6
|
/** Provides a view into public contract state */
|
|
7
7
|
export interface PublicStateSource {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@aztec/circuit-types';
|
|
9
9
|
import { type ContractDataSource } from '@aztec/circuits.js';
|
|
10
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
11
|
-
import { ContractsDataSourcePublicDB, getExecutionRequestsByPhase } from '@aztec/simulator';
|
|
11
|
+
import { ContractsDataSourcePublicDB, getExecutionRequestsByPhase } from '@aztec/simulator/server';
|
|
12
12
|
|
|
13
13
|
export class PhasesTxValidator implements TxValidator<Tx> {
|
|
14
14
|
#log = createLogger('sequencer:tx_validator:tx_phases');
|
|
@@ -9,14 +9,16 @@ import {
|
|
|
9
9
|
import { type AztecAddress, type ContractDataSource, Fr, type GasFees, type GlobalVariables } from '@aztec/circuits.js';
|
|
10
10
|
import {
|
|
11
11
|
AggregateTxValidator,
|
|
12
|
+
BlockHeaderTxValidator,
|
|
12
13
|
DataTxValidator,
|
|
13
14
|
DoubleSpendTxValidator,
|
|
14
15
|
MetadataTxValidator,
|
|
15
16
|
TxProofValidator,
|
|
16
17
|
} from '@aztec/p2p';
|
|
17
18
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
18
|
-
import { readPublicState } from '@aztec/simulator';
|
|
19
|
+
import { readPublicState } from '@aztec/simulator/server';
|
|
19
20
|
|
|
21
|
+
import { ArchiveCache } from './archive_cache.js';
|
|
20
22
|
import { GasTxValidator, type PublicStateSource } from './gas_validator.js';
|
|
21
23
|
import { NullifierCache } from './nullifier_cache.js';
|
|
22
24
|
import { PhasesTxValidator } from './phases_validator.js';
|
|
@@ -40,6 +42,7 @@ export function createValidatorForAcceptingTxs(
|
|
|
40
42
|
new DoubleSpendTxValidator(new NullifierCache(db)),
|
|
41
43
|
new PhasesTxValidator(contractDataSource, setupAllowList),
|
|
42
44
|
new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, enforceFees, gasFees),
|
|
45
|
+
new BlockHeaderTxValidator(new ArchiveCache(db)),
|
|
43
46
|
];
|
|
44
47
|
|
|
45
48
|
if (verifier) {
|
|
@@ -61,11 +64,13 @@ export function createValidatorsForBlockBuilding(
|
|
|
61
64
|
nullifierCache: NullifierCache;
|
|
62
65
|
} {
|
|
63
66
|
const nullifierCache = new NullifierCache(db);
|
|
67
|
+
const archiveCache = new ArchiveCache(db);
|
|
64
68
|
const publicStateSource = new DatabasePublicStateSource(db);
|
|
65
69
|
|
|
66
70
|
return {
|
|
67
71
|
preprocessValidator: preprocessValidator(
|
|
68
72
|
nullifierCache,
|
|
73
|
+
archiveCache,
|
|
69
74
|
publicStateSource,
|
|
70
75
|
contractDataSource,
|
|
71
76
|
enforceFees,
|
|
@@ -87,6 +92,7 @@ class DatabasePublicStateSource implements PublicStateSource {
|
|
|
87
92
|
|
|
88
93
|
function preprocessValidator(
|
|
89
94
|
nullifierCache: NullifierCache,
|
|
95
|
+
archiveCache: ArchiveCache,
|
|
90
96
|
publicStateSource: PublicStateSource,
|
|
91
97
|
contractDataSource: ContractDataSource,
|
|
92
98
|
enforceFees: boolean,
|
|
@@ -99,6 +105,7 @@ function preprocessValidator(
|
|
|
99
105
|
new DoubleSpendTxValidator(nullifierCache),
|
|
100
106
|
new PhasesTxValidator(contractDataSource, setupAllowList),
|
|
101
107
|
new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, enforceFees, globalVariables.gasFees),
|
|
108
|
+
new BlockHeaderTxValidator(archiveCache),
|
|
102
109
|
);
|
|
103
110
|
}
|
|
104
111
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-l1-publisher.d.ts","sourceRoot":"","sources":["../../src/publisher/test-l1-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAEjG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,eAAgB,SAAQ,WAAW;IACvC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;cAEjB,kBAAkB,CACnC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,aAAa,GACnB,YAAY,CAAC,aAAa,EAAE,KAAK,EAAE,iBAAiB,CAAC;CAMzD"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { withDelayer } from '@aztec/ethereum/test';
|
|
2
|
-
import { L1Publisher } from './l1-publisher.js';
|
|
3
|
-
export class TestL1Publisher extends L1Publisher {
|
|
4
|
-
createWalletClient(account, chain) {
|
|
5
|
-
const baseClient = super.createWalletClient(account, chain);
|
|
6
|
-
const { client, delayer } = withDelayer(baseClient, { ethereumSlotDuration: this.ethereumSlotDuration });
|
|
7
|
-
this.delayer = delayer;
|
|
8
|
-
return client;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC1sMS1wdWJsaXNoZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHVibGlzaGVyL3Rlc3QtbDEtcHVibGlzaGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBZ0IsV0FBVyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFJakUsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRWhELE1BQU0sT0FBTyxlQUFnQixTQUFRLFdBQVc7SUFHM0Isa0JBQWtCLENBQ25DLE9BQTBCLEVBQzFCLEtBQW9CO1FBRXBCLE1BQU0sVUFBVSxHQUFHLEtBQUssQ0FBQyxrQkFBa0IsQ0FBQyxPQUFPLEVBQUUsS0FBSyxDQUFDLENBQUM7UUFDNUQsTUFBTSxFQUFFLE1BQU0sRUFBRSxPQUFPLEVBQUUsR0FBRyxXQUFXLENBQUMsVUFBVSxFQUFFLEVBQUUsb0JBQW9CLEVBQUUsSUFBSSxDQUFDLG9CQUFvQixFQUFFLENBQUMsQ0FBQztRQUN6RyxJQUFJLENBQUMsT0FBTyxHQUFHLE9BQU8sQ0FBQztRQUN2QixPQUFPLE1BQU0sQ0FBQztJQUNoQixDQUFDO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/publisher/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,OAW7C"}
|
package/dest/publisher/utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseError, ContractFunctionRevertedError } from 'viem';
|
|
2
|
-
export function prettyLogViemErrorMsg(err) {
|
|
3
|
-
if (err instanceof BaseError) {
|
|
4
|
-
const revertError = err.walk(err => err instanceof ContractFunctionRevertedError);
|
|
5
|
-
if (revertError instanceof ContractFunctionRevertedError) {
|
|
6
|
-
const errorName = revertError.data?.errorName ?? '';
|
|
7
|
-
const args = revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() : '';
|
|
8
|
-
return `${errorName}${args}`;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return err?.message ?? err;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHVibGlzaGVyL3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsNkJBQTZCLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFFaEUsTUFBTSxVQUFVLHFCQUFxQixDQUFDLEdBQVE7SUFDNUMsSUFBSSxHQUFHLFlBQVksU0FBUyxFQUFFLENBQUM7UUFDN0IsTUFBTSxXQUFXLEdBQUcsR0FBRyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsWUFBWSw2QkFBNkIsQ0FBQyxDQUFDO1FBQ2xGLElBQUksV0FBVyxZQUFZLDZCQUE2QixFQUFFLENBQUM7WUFDekQsTUFBTSxTQUFTLEdBQUcsV0FBVyxDQUFDLElBQUksRUFBRSxTQUFTLElBQUksRUFBRSxDQUFDO1lBQ3BELE1BQU0sSUFBSSxHQUNSLFdBQVcsQ0FBQyxZQUFZLElBQUksV0FBVyxDQUFDLFlBQVksRUFBRSxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxXQUFXLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDLFNBQVMsRUFBRSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUM7WUFDbEgsT0FBTyxHQUFHLFNBQVMsR0FBRyxJQUFJLEVBQUUsQ0FBQztRQUMvQixDQUFDO0lBQ0gsQ0FBQztJQUNELE9BQU8sR0FBRyxFQUFFLE9BQU8sSUFBSSxHQUFHLENBQUM7QUFDN0IsQ0FBQyJ9
|
package/src/publisher/utils.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseError, ContractFunctionRevertedError } from 'viem';
|
|
2
|
-
|
|
3
|
-
export function prettyLogViemErrorMsg(err: any) {
|
|
4
|
-
if (err instanceof BaseError) {
|
|
5
|
-
const revertError = err.walk(err => err instanceof ContractFunctionRevertedError);
|
|
6
|
-
if (revertError instanceof ContractFunctionRevertedError) {
|
|
7
|
-
const errorName = revertError.data?.errorName ?? '';
|
|
8
|
-
const args =
|
|
9
|
-
revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() : '';
|
|
10
|
-
return `${errorName}${args}`;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return err?.message ?? err;
|
|
14
|
-
}
|