@aztec/sequencer-client 0.65.1 → 0.66.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.map +1 -1
- package/dest/client/sequencer-client.js +2 -2
- package/dest/global_variable_builder/global_builder.d.ts +4 -0
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +15 -3
- package/dest/publisher/config.d.ts +4 -4
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +3 -2
- package/dest/publisher/l1-publisher.d.ts +4 -2
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +56 -38
- package/dest/sequencer/sequencer.d.ts +11 -2
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +32 -20
- package/dest/sequencer/utils.js +2 -2
- package/dest/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/tx_validator/gas_validator.js +6 -2
- package/package.json +19 -19
- package/src/client/sequencer-client.ts +1 -1
- package/src/global_variable_builder/global_builder.ts +16 -2
- package/src/publisher/config.ts +7 -4
- package/src/publisher/l1-publisher.ts +84 -49
- package/src/sequencer/sequencer.ts +32 -37
- package/src/sequencer/utils.ts +1 -1
- package/src/tx_validator/gas_validator.ts +5 -1
- package/dest/block_builder/index.d.ts +0 -7
- package/dest/block_builder/index.d.ts.map +0 -1
- package/dest/block_builder/index.js +0 -3
- package/dest/block_builder/light.d.ts +0 -26
- package/dest/block_builder/light.d.ts.map +0 -1
- package/dest/block_builder/light.js +0 -58
- package/dest/block_builder/orchestrator.d.ts +0 -23
- package/dest/block_builder/orchestrator.d.ts.map +0 -1
- package/dest/block_builder/orchestrator.js +0 -33
- package/src/block_builder/index.ts +0 -7
- package/src/block_builder/light.ts +0 -92
- package/src/block_builder/orchestrator.ts +0 -43
|
@@ -17,7 +17,13 @@ import {
|
|
|
17
17
|
type Proof,
|
|
18
18
|
type RootRollupPublicInputs,
|
|
19
19
|
} from '@aztec/circuits.js';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
type EthereumChain,
|
|
22
|
+
type L1ContractsConfig,
|
|
23
|
+
L1TxUtils,
|
|
24
|
+
type L1TxUtilsConfig,
|
|
25
|
+
createEthereumChain,
|
|
26
|
+
} from '@aztec/ethereum';
|
|
21
27
|
import { makeTuple } from '@aztec/foundation/array';
|
|
22
28
|
import { areArraysEqual, compactArray, times } from '@aztec/foundation/collection';
|
|
23
29
|
import { type Signature } from '@aztec/foundation/eth-signature';
|
|
@@ -44,6 +50,7 @@ import {
|
|
|
44
50
|
type PublicActions,
|
|
45
51
|
type PublicClient,
|
|
46
52
|
type PublicRpcSchema,
|
|
53
|
+
type TransactionReceipt,
|
|
47
54
|
type WalletActions,
|
|
48
55
|
type WalletClient,
|
|
49
56
|
type WalletRpcSchema,
|
|
@@ -161,8 +168,10 @@ export class L1Publisher {
|
|
|
161
168
|
public static PROPOSE_GAS_GUESS: bigint = 12_000_000n;
|
|
162
169
|
public static PROPOSE_AND_CLAIM_GAS_GUESS: bigint = this.PROPOSE_GAS_GUESS + 100_000n;
|
|
163
170
|
|
|
171
|
+
private readonly l1TxUtils: L1TxUtils;
|
|
172
|
+
|
|
164
173
|
constructor(
|
|
165
|
-
config: TxSenderConfig & PublisherConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'
|
|
174
|
+
config: TxSenderConfig & PublisherConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'> & L1TxUtilsConfig,
|
|
166
175
|
client: TelemetryClient,
|
|
167
176
|
) {
|
|
168
177
|
this.sleepTimeMs = config?.l1PublishRetryIntervalMS ?? 60_000;
|
|
@@ -195,6 +204,12 @@ export class L1Publisher {
|
|
|
195
204
|
client: this.walletClient,
|
|
196
205
|
});
|
|
197
206
|
}
|
|
207
|
+
|
|
208
|
+
this.l1TxUtils = new L1TxUtils(this.publicClient, this.walletClient, this.log, config);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
get publisherAddress() {
|
|
212
|
+
return this.account.address;
|
|
198
213
|
}
|
|
199
214
|
|
|
200
215
|
protected createWalletClient(
|
|
@@ -296,8 +311,13 @@ export class L1Publisher {
|
|
|
296
311
|
}
|
|
297
312
|
|
|
298
313
|
public async getProofClaim(): Promise<EpochProofClaim | undefined> {
|
|
299
|
-
const
|
|
300
|
-
|
|
314
|
+
const {
|
|
315
|
+
epochToProve,
|
|
316
|
+
basisPointFee,
|
|
317
|
+
bondAmount,
|
|
318
|
+
bondProvider: bondProviderHex,
|
|
319
|
+
proposerClaimant: proposerClaimantHex,
|
|
320
|
+
} = await this.rollupContract.read.getProofClaim();
|
|
301
321
|
|
|
302
322
|
const bondProvider = EthAddress.fromString(bondProviderHex);
|
|
303
323
|
const proposerClaimant = EthAddress.fromString(proposerClaimantHex);
|
|
@@ -503,36 +523,30 @@ export class L1Publisher {
|
|
|
503
523
|
});
|
|
504
524
|
|
|
505
525
|
this.log.verbose(`Submitting propose transaction`);
|
|
506
|
-
|
|
507
|
-
const tx = proofQuote
|
|
526
|
+
const result = proofQuote
|
|
508
527
|
? await this.sendProposeAndClaimTx(proposeTxArgs, proofQuote)
|
|
509
528
|
: await this.sendProposeTx(proposeTxArgs);
|
|
510
529
|
|
|
511
|
-
if (!
|
|
530
|
+
if (!result?.receipt) {
|
|
512
531
|
this.log.info(`Failed to publish block ${block.number} to L1`, ctx);
|
|
513
532
|
return false;
|
|
514
533
|
}
|
|
515
534
|
|
|
516
|
-
const {
|
|
517
|
-
|
|
518
|
-
const receipt = await this.getTransactionReceipt(txHash);
|
|
519
|
-
if (!receipt) {
|
|
520
|
-
this.log.info(`Failed to get receipt for tx ${txHash}`, ctx);
|
|
521
|
-
return false;
|
|
522
|
-
}
|
|
535
|
+
const { receipt, args, functionName } = result;
|
|
523
536
|
|
|
524
537
|
// Tx was mined successfully
|
|
525
|
-
if (receipt.status) {
|
|
526
|
-
const tx = await this.getTransactionStats(
|
|
538
|
+
if (receipt.status === 'success') {
|
|
539
|
+
const tx = await this.getTransactionStats(receipt.transactionHash);
|
|
527
540
|
const stats: L1PublishBlockStats = {
|
|
528
|
-
|
|
541
|
+
gasPrice: receipt.effectiveGasPrice,
|
|
542
|
+
gasUsed: receipt.gasUsed,
|
|
543
|
+
transactionHash: receipt.transactionHash,
|
|
529
544
|
...pick(tx!, 'calldataGas', 'calldataSize', 'sender'),
|
|
530
545
|
...block.getStats(),
|
|
531
546
|
eventName: 'rollup-published-to-l1',
|
|
532
547
|
};
|
|
533
548
|
this.log.info(`Published L2 block to L1 rollup contract`, { ...stats, ...ctx });
|
|
534
549
|
this.metrics.recordProcessBlockTx(timer.ms(), stats);
|
|
535
|
-
|
|
536
550
|
return true;
|
|
537
551
|
}
|
|
538
552
|
|
|
@@ -541,7 +555,6 @@ export class L1Publisher {
|
|
|
541
555
|
const errorMsg = await this.tryGetErrorFromRevertedTx({
|
|
542
556
|
args,
|
|
543
557
|
functionName,
|
|
544
|
-
gasLimit,
|
|
545
558
|
abi: RollupAbi,
|
|
546
559
|
address: this.rollupContract.address,
|
|
547
560
|
blockNumber: receipt.blockNumber,
|
|
@@ -557,7 +570,6 @@ export class L1Publisher {
|
|
|
557
570
|
private async tryGetErrorFromRevertedTx(args: {
|
|
558
571
|
args: any[];
|
|
559
572
|
functionName: string;
|
|
560
|
-
gasLimit: bigint;
|
|
561
573
|
abi: any;
|
|
562
574
|
address: Hex;
|
|
563
575
|
blockNumber: bigint | undefined;
|
|
@@ -633,7 +645,7 @@ export class L1Publisher {
|
|
|
633
645
|
const { fromBlock, toBlock, publicInputs, proof } = args;
|
|
634
646
|
|
|
635
647
|
// Check that the block numbers match the expected epoch to be proven
|
|
636
|
-
const
|
|
648
|
+
const { pendingBlockNumber: pending, provenBlockNumber: proven } = await this.rollupContract.read.getTips();
|
|
637
649
|
if (proven !== BigInt(fromBlock) - 1n) {
|
|
638
650
|
throw new Error(`Cannot submit epoch proof for ${fromBlock}-${toBlock} as proven block is ${proven}`);
|
|
639
651
|
}
|
|
@@ -720,17 +732,25 @@ export class L1Publisher {
|
|
|
720
732
|
] as const;
|
|
721
733
|
|
|
722
734
|
this.log.info(`SubmitEpochProof proofSize=${args.proof.withoutPublicInputs().length} bytes`);
|
|
723
|
-
|
|
724
|
-
|
|
735
|
+
|
|
736
|
+
const txReceipt = await this.l1TxUtils.sendAndMonitorTransaction({
|
|
737
|
+
to: this.rollupContract.address,
|
|
738
|
+
data: encodeFunctionData({
|
|
739
|
+
abi: this.rollupContract.abi,
|
|
740
|
+
functionName: 'submitEpochRootProof',
|
|
741
|
+
args: txArgs,
|
|
742
|
+
}),
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
return txReceipt.transactionHash;
|
|
725
746
|
} catch (err) {
|
|
726
747
|
this.log.error(`Rollup submit epoch proof failed`, err);
|
|
727
748
|
return undefined;
|
|
728
749
|
}
|
|
729
750
|
}
|
|
730
751
|
|
|
731
|
-
private async prepareProposeTx(encodedData: L1ProcessArgs
|
|
732
|
-
|
|
733
|
-
const computeTxsEffectsHashGas = await this.publicClient.estimateGas({
|
|
752
|
+
private async prepareProposeTx(encodedData: L1ProcessArgs) {
|
|
753
|
+
const computeTxsEffectsHashGas = await this.l1TxUtils.estimateGas(this.account, {
|
|
734
754
|
to: this.rollupContract.address,
|
|
735
755
|
data: encodeFunctionData({
|
|
736
756
|
abi: this.rollupContract.abi,
|
|
@@ -744,7 +764,7 @@ export class L1Publisher {
|
|
|
744
764
|
// we will fail estimation in the case where we are simulating for the
|
|
745
765
|
// first ethereum block within our slot (as current time is not in the
|
|
746
766
|
// slot yet).
|
|
747
|
-
const gasGuesstimate = computeTxsEffectsHashGas +
|
|
767
|
+
const gasGuesstimate = computeTxsEffectsHashGas + L1Publisher.PROPOSE_GAS_GUESS;
|
|
748
768
|
|
|
749
769
|
const attestations = encodedData.attestations
|
|
750
770
|
? encodedData.attestations.map(attest => attest.toViemSignature())
|
|
@@ -766,7 +786,7 @@ export class L1Publisher {
|
|
|
766
786
|
`0x${encodedData.body.toString('hex')}`,
|
|
767
787
|
] as const;
|
|
768
788
|
|
|
769
|
-
return { args, gasGuesstimate };
|
|
789
|
+
return { args, gas: gasGuesstimate };
|
|
770
790
|
}
|
|
771
791
|
|
|
772
792
|
private getSubmitEpochProofArgs(args: {
|
|
@@ -797,25 +817,34 @@ export class L1Publisher {
|
|
|
797
817
|
|
|
798
818
|
private async sendProposeTx(
|
|
799
819
|
encodedData: L1ProcessArgs,
|
|
800
|
-
): Promise<{
|
|
820
|
+
): Promise<{ receipt: TransactionReceipt; args: any; functionName: string } | undefined> {
|
|
801
821
|
if (this.interrupted) {
|
|
802
822
|
return undefined;
|
|
803
823
|
}
|
|
804
824
|
try {
|
|
805
|
-
const { args,
|
|
806
|
-
|
|
825
|
+
const { args, gas } = await this.prepareProposeTx(encodedData);
|
|
826
|
+
const receipt = await this.l1TxUtils.sendAndMonitorTransaction(
|
|
827
|
+
{
|
|
828
|
+
to: this.rollupContract.address,
|
|
829
|
+
data: encodeFunctionData({
|
|
830
|
+
abi: this.rollupContract.abi,
|
|
831
|
+
functionName: 'propose',
|
|
832
|
+
args,
|
|
833
|
+
}),
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
fixedGas: gas,
|
|
837
|
+
},
|
|
838
|
+
);
|
|
807
839
|
return {
|
|
808
|
-
|
|
809
|
-
account: this.account,
|
|
810
|
-
gas: gasGuesstimate,
|
|
811
|
-
}),
|
|
840
|
+
receipt,
|
|
812
841
|
args,
|
|
813
842
|
functionName: 'propose',
|
|
814
|
-
gasLimit: gasGuesstimate,
|
|
815
843
|
};
|
|
816
844
|
} catch (err) {
|
|
817
845
|
prettyLogViemError(err, this.log);
|
|
818
|
-
|
|
846
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
847
|
+
this.log.error(`Rollup publish failed`, errorMessage);
|
|
819
848
|
return undefined;
|
|
820
849
|
}
|
|
821
850
|
}
|
|
@@ -823,30 +852,36 @@ export class L1Publisher {
|
|
|
823
852
|
private async sendProposeAndClaimTx(
|
|
824
853
|
encodedData: L1ProcessArgs,
|
|
825
854
|
quote: EpochProofQuote,
|
|
826
|
-
): Promise<{
|
|
855
|
+
): Promise<{ receipt: TransactionReceipt; args: any; functionName: string } | undefined> {
|
|
827
856
|
if (this.interrupted) {
|
|
828
857
|
return undefined;
|
|
829
858
|
}
|
|
830
859
|
try {
|
|
831
|
-
const { args, gasGuesstimate } = await this.prepareProposeTx(
|
|
832
|
-
encodedData,
|
|
833
|
-
L1Publisher.PROPOSE_AND_CLAIM_GAS_GUESS,
|
|
834
|
-
);
|
|
835
860
|
this.log.info(`ProposeAndClaim`);
|
|
836
861
|
this.log.info(inspect(quote.payload));
|
|
837
862
|
|
|
863
|
+
const { args, gas } = await this.prepareProposeTx(encodedData);
|
|
864
|
+
const receipt = await this.l1TxUtils.sendAndMonitorTransaction(
|
|
865
|
+
{
|
|
866
|
+
to: this.rollupContract.address,
|
|
867
|
+
data: encodeFunctionData({
|
|
868
|
+
abi: this.rollupContract.abi,
|
|
869
|
+
functionName: 'proposeAndClaim',
|
|
870
|
+
args: [...args, quote.toViemArgs()],
|
|
871
|
+
}),
|
|
872
|
+
},
|
|
873
|
+
{ fixedGas: gas },
|
|
874
|
+
);
|
|
875
|
+
|
|
838
876
|
return {
|
|
839
|
-
|
|
840
|
-
account: this.account,
|
|
841
|
-
gas: gasGuesstimate,
|
|
842
|
-
}),
|
|
843
|
-
functionName: 'proposeAndClaim',
|
|
877
|
+
receipt,
|
|
844
878
|
args,
|
|
845
|
-
|
|
879
|
+
functionName: 'proposeAndClaim',
|
|
846
880
|
};
|
|
847
881
|
} catch (err) {
|
|
848
882
|
prettyLogViemError(err, this.log);
|
|
849
|
-
|
|
883
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
884
|
+
this.log.error(`Rollup publish failed`, errorMessage);
|
|
850
885
|
return undefined;
|
|
851
886
|
}
|
|
852
887
|
}
|
|
@@ -26,13 +26,13 @@ import { createDebugLogger } from '@aztec/foundation/log';
|
|
|
26
26
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
27
27
|
import { Timer, elapsed } from '@aztec/foundation/timer';
|
|
28
28
|
import { type P2P } from '@aztec/p2p';
|
|
29
|
+
import { type BlockBuilderFactory } from '@aztec/prover-client/block-builder';
|
|
29
30
|
import { type PublicProcessorFactory } from '@aztec/simulator';
|
|
30
31
|
import { Attributes, type TelemetryClient, type Tracer, trackSpan } from '@aztec/telemetry-client';
|
|
31
32
|
import { type ValidatorClient } from '@aztec/validator-client';
|
|
32
33
|
|
|
33
34
|
import { inspect } from 'util';
|
|
34
35
|
|
|
35
|
-
import { type BlockBuilderFactory } from '../block_builder/index.js';
|
|
36
36
|
import { type GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
|
|
37
37
|
import { type L1Publisher } from '../publisher/l1-publisher.js';
|
|
38
38
|
import { prettyLogViemErrorMsg } from '../publisher/utils.js';
|
|
@@ -189,7 +189,7 @@ export class Sequencer {
|
|
|
189
189
|
public start() {
|
|
190
190
|
this.runningPromise = new RunningPromise(this.work.bind(this), this.pollingIntervalMs);
|
|
191
191
|
this.runningPromise.start();
|
|
192
|
-
this.setState(SequencerState.IDLE,
|
|
192
|
+
this.setState(SequencerState.IDLE, 0n, true /** force */);
|
|
193
193
|
this.log.info('Sequencer started');
|
|
194
194
|
return Promise.resolve();
|
|
195
195
|
}
|
|
@@ -201,7 +201,7 @@ export class Sequencer {
|
|
|
201
201
|
this.log.debug(`Stopping sequencer`);
|
|
202
202
|
await this.runningPromise?.stop();
|
|
203
203
|
this.publisher.interrupt();
|
|
204
|
-
this.setState(SequencerState.STOPPED,
|
|
204
|
+
this.setState(SequencerState.STOPPED, 0n, true /** force */);
|
|
205
205
|
this.log.info('Stopped sequencer');
|
|
206
206
|
}
|
|
207
207
|
|
|
@@ -212,7 +212,7 @@ export class Sequencer {
|
|
|
212
212
|
this.log.info('Restarting sequencer');
|
|
213
213
|
this.publisher.restart();
|
|
214
214
|
this.runningPromise!.start();
|
|
215
|
-
this.setState(SequencerState.IDLE,
|
|
215
|
+
this.setState(SequencerState.IDLE, 0n, true /** force */);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/**
|
|
@@ -232,7 +232,7 @@ export class Sequencer {
|
|
|
232
232
|
* - If our block for some reason is not included, revert the state
|
|
233
233
|
*/
|
|
234
234
|
protected async doRealWork() {
|
|
235
|
-
this.setState(SequencerState.SYNCHRONIZING,
|
|
235
|
+
this.setState(SequencerState.SYNCHRONIZING, 0n);
|
|
236
236
|
// Update state when the previous block has been synced
|
|
237
237
|
const prevBlockSynced = await this.isBlockSynced();
|
|
238
238
|
// Do not go forward with new block if the previous one has not been mined and processed
|
|
@@ -243,7 +243,7 @@ export class Sequencer {
|
|
|
243
243
|
|
|
244
244
|
this.log.debug('Previous block has been mined and processed');
|
|
245
245
|
|
|
246
|
-
this.setState(SequencerState.PROPOSER_CHECK,
|
|
246
|
+
this.setState(SequencerState.PROPOSER_CHECK, 0n);
|
|
247
247
|
|
|
248
248
|
const chainTip = await this.l2BlockSource.getBlock(-1);
|
|
249
249
|
const historicalHeader = chainTip?.header;
|
|
@@ -277,9 +277,8 @@ export class Sequencer {
|
|
|
277
277
|
if (!this.shouldProposeBlock(historicalHeader, {})) {
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
|
-
const secondsIntoSlot = getSecondsIntoSlot(this.l1GenesisTime, this.aztecSlotDuration, Number(slot));
|
|
281
280
|
|
|
282
|
-
this.setState(SequencerState.WAITING_FOR_TXS,
|
|
281
|
+
this.setState(SequencerState.WAITING_FOR_TXS, slot);
|
|
283
282
|
|
|
284
283
|
// Get txs to build the new block.
|
|
285
284
|
const pendingTxs = this.p2pClient.getTxs('pending');
|
|
@@ -325,7 +324,7 @@ export class Sequencer {
|
|
|
325
324
|
} catch (err) {
|
|
326
325
|
this.log.error(`Error assembling block`, (err as any).stack);
|
|
327
326
|
}
|
|
328
|
-
this.setState(SequencerState.IDLE,
|
|
327
|
+
this.setState(SequencerState.IDLE, 0n);
|
|
329
328
|
}
|
|
330
329
|
|
|
331
330
|
protected async work() {
|
|
@@ -339,7 +338,7 @@ export class Sequencer {
|
|
|
339
338
|
throw err;
|
|
340
339
|
}
|
|
341
340
|
} finally {
|
|
342
|
-
this.setState(SequencerState.IDLE,
|
|
341
|
+
this.setState(SequencerState.IDLE, 0n);
|
|
343
342
|
}
|
|
344
343
|
}
|
|
345
344
|
|
|
@@ -363,7 +362,9 @@ export class Sequencer {
|
|
|
363
362
|
throw new Error(msg);
|
|
364
363
|
}
|
|
365
364
|
|
|
366
|
-
this.log.verbose(`Can propose block ${proposalBlockNumber} at slot ${slot}
|
|
365
|
+
this.log.verbose(`Can propose block ${proposalBlockNumber} at slot ${slot}`, {
|
|
366
|
+
publisherAddress: this.publisher.publisherAddress,
|
|
367
|
+
});
|
|
367
368
|
return slot;
|
|
368
369
|
} catch (err) {
|
|
369
370
|
const msg = prettyLogViemErrorMsg(err);
|
|
@@ -398,13 +399,23 @@ export class Sequencer {
|
|
|
398
399
|
return true;
|
|
399
400
|
}
|
|
400
401
|
|
|
401
|
-
|
|
402
|
+
/**
|
|
403
|
+
* Sets the sequencer state and checks if we have enough time left in the slot to transition to the new state.
|
|
404
|
+
* @param proposedState - The new state to transition to.
|
|
405
|
+
* @param currentSlotNumber - The current slot number.
|
|
406
|
+
* @param force - Whether to force the transition even if the sequencer is stopped.
|
|
407
|
+
*
|
|
408
|
+
* @dev If the `currentSlotNumber` doesn't matter (e.g. transitioning to IDLE), pass in `0n`;
|
|
409
|
+
* it is only used to check if we have enough time left in the slot to transition to the new state.
|
|
410
|
+
*/
|
|
411
|
+
setState(proposedState: SequencerState, currentSlotNumber: bigint, force: boolean = false) {
|
|
402
412
|
if (this.state === SequencerState.STOPPED && force !== true) {
|
|
403
413
|
this.log.warn(
|
|
404
414
|
`Cannot set sequencer from ${this.state} to ${proposedState} as it is stopped. Set force=true to override.`,
|
|
405
415
|
);
|
|
406
416
|
return;
|
|
407
417
|
}
|
|
418
|
+
const secondsIntoSlot = getSecondsIntoSlot(this.l1GenesisTime, this.aztecSlotDuration, Number(currentSlotNumber));
|
|
408
419
|
if (!this.doIHaveEnoughTimeLeft(proposedState, secondsIntoSlot)) {
|
|
409
420
|
throw new SequencerTooSlowError(this.state, proposedState, this.timeTable[proposedState], secondsIntoSlot);
|
|
410
421
|
}
|
|
@@ -567,12 +578,7 @@ export class Sequencer {
|
|
|
567
578
|
|
|
568
579
|
this.metrics.recordNewBlock(newGlobalVariables.blockNumber.toNumber(), validTxs.length);
|
|
569
580
|
const workTimer = new Timer();
|
|
570
|
-
|
|
571
|
-
this.l1GenesisTime,
|
|
572
|
-
this.aztecSlotDuration,
|
|
573
|
-
newGlobalVariables.slotNumber.toNumber(),
|
|
574
|
-
);
|
|
575
|
-
this.setState(SequencerState.CREATING_BLOCK, secondsIntoSlot);
|
|
581
|
+
this.setState(SequencerState.CREATING_BLOCK, newGlobalVariables.slotNumber.toBigInt());
|
|
576
582
|
this.log.info(
|
|
577
583
|
`Building blockNumber=${newGlobalVariables.blockNumber.toNumber()} txCount=${
|
|
578
584
|
validTxs.length
|
|
@@ -687,24 +693,18 @@ export class Sequencer {
|
|
|
687
693
|
|
|
688
694
|
this.log.info('Creating block proposal');
|
|
689
695
|
const proposal = await this.validatorClient.createBlockProposal(block.header, block.archive.root, txHashes);
|
|
696
|
+
if (!proposal) {
|
|
697
|
+
this.log.verbose(`Failed to create block proposal, skipping`);
|
|
698
|
+
return undefined;
|
|
699
|
+
}
|
|
690
700
|
|
|
691
|
-
|
|
692
|
-
this.l1GenesisTime,
|
|
693
|
-
this.aztecSlotDuration,
|
|
694
|
-
block.header.globalVariables.slotNumber.toNumber(),
|
|
695
|
-
);
|
|
701
|
+
const slotNumber = block.header.globalVariables.slotNumber.toBigInt();
|
|
696
702
|
|
|
697
|
-
this.setState(SequencerState.PUBLISHING_BLOCK_TO_PEERS,
|
|
703
|
+
this.setState(SequencerState.PUBLISHING_BLOCK_TO_PEERS, slotNumber);
|
|
698
704
|
this.log.info('Broadcasting block proposal to validators');
|
|
699
705
|
this.validatorClient.broadcastBlockProposal(proposal);
|
|
700
706
|
|
|
701
|
-
|
|
702
|
-
this.l1GenesisTime,
|
|
703
|
-
this.aztecSlotDuration,
|
|
704
|
-
block.header.globalVariables.slotNumber.toNumber(),
|
|
705
|
-
);
|
|
706
|
-
|
|
707
|
-
this.setState(SequencerState.WAITING_FOR_ATTESTATIONS, secondsIntoSlot);
|
|
707
|
+
this.setState(SequencerState.WAITING_FOR_ATTESTATIONS, slotNumber);
|
|
708
708
|
const attestations = await this.validatorClient.collectAttestations(proposal, numberOfRequiredAttestations);
|
|
709
709
|
this.log.info(`Collected attestations from validators, number of attestations: ${attestations.length}`);
|
|
710
710
|
|
|
@@ -761,13 +761,8 @@ export class Sequencer {
|
|
|
761
761
|
txHashes?: TxHash[],
|
|
762
762
|
proofQuote?: EpochProofQuote,
|
|
763
763
|
) {
|
|
764
|
-
const secondsIntoSlot = getSecondsIntoSlot(
|
|
765
|
-
this.l1GenesisTime,
|
|
766
|
-
this.aztecSlotDuration,
|
|
767
|
-
block.header.globalVariables.slotNumber.toNumber(),
|
|
768
|
-
);
|
|
769
764
|
// Publishes new block to the network and awaits the tx to be mined
|
|
770
|
-
this.setState(SequencerState.PUBLISHING_BLOCK,
|
|
765
|
+
this.setState(SequencerState.PUBLISHING_BLOCK, block.header.globalVariables.slotNumber.toBigInt());
|
|
771
766
|
|
|
772
767
|
const publishedL2Block = await this.publisher.proposeL2Block(block, attestations, txHashes, proofQuote);
|
|
773
768
|
if (!publishedL2Block) {
|
package/src/sequencer/utils.ts
CHANGED
|
@@ -75,5 +75,5 @@ export function orderAttestations(attestations: BlockAttestation[], orderAddress
|
|
|
75
75
|
|
|
76
76
|
export function getSecondsIntoSlot(l1GenesisTime: number, aztecSlotDuration: number, slotNumber: number): number {
|
|
77
77
|
const slotStartTimestamp = l1GenesisTime + slotNumber * aztecSlotDuration;
|
|
78
|
-
return Date.now() / 1000 - slotStartTimestamp;
|
|
78
|
+
return Number((Date.now() / 1000 - slotStartTimestamp).toFixed(3));
|
|
79
79
|
}
|
|
@@ -72,7 +72,11 @@ export class GasTxValidator implements TxValidator<Tx> {
|
|
|
72
72
|
|
|
73
73
|
const balance = claimFunctionCall ? initialBalance.add(claimFunctionCall.args[2]) : initialBalance;
|
|
74
74
|
if (balance.lt(feeLimit)) {
|
|
75
|
-
this.#log.info(`Rejecting transaction due to not enough fee payer balance`, {
|
|
75
|
+
this.#log.info(`Rejecting transaction due to not enough fee payer balance`, {
|
|
76
|
+
feePayer,
|
|
77
|
+
balance: balance.toBigInt(),
|
|
78
|
+
feeLimit: feeLimit.toBigInt(),
|
|
79
|
+
});
|
|
76
80
|
return false;
|
|
77
81
|
}
|
|
78
82
|
return true;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type BlockBuilder, type MerkleTreeReadOperations } from '@aztec/circuit-types';
|
|
2
|
-
export * from './orchestrator.js';
|
|
3
|
-
export * from './light.js';
|
|
4
|
-
export interface BlockBuilderFactory {
|
|
5
|
-
create(db: MerkleTreeReadOperations): BlockBuilder;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/block_builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAExF,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,EAAE,wBAAwB,GAAG,YAAY,CAAC;CACpD"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export * from './orchestrator.js';
|
|
2
|
-
export * from './light.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmxvY2tfYnVpbGRlci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsWUFBWSxDQUFDIn0=
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type BlockBuilder, L2Block, type MerkleTreeWriteOperations, type ProcessedTx } from '@aztec/circuit-types';
|
|
2
|
-
import { Fr, type GlobalVariables } from '@aztec/circuits.js';
|
|
3
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
-
/**
|
|
5
|
-
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
6
|
-
*/
|
|
7
|
-
export declare class LightweightBlockBuilder implements BlockBuilder {
|
|
8
|
-
private db;
|
|
9
|
-
private telemetry;
|
|
10
|
-
private numTxs?;
|
|
11
|
-
private globalVariables?;
|
|
12
|
-
private l1ToL2Messages?;
|
|
13
|
-
private readonly txs;
|
|
14
|
-
private readonly logger;
|
|
15
|
-
constructor(db: MerkleTreeWriteOperations, telemetry: TelemetryClient);
|
|
16
|
-
startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void>;
|
|
17
|
-
addNewTx(tx: ProcessedTx): Promise<void>;
|
|
18
|
-
setBlockCompleted(): Promise<L2Block>;
|
|
19
|
-
private buildBlock;
|
|
20
|
-
}
|
|
21
|
-
export declare class LightweightBlockBuilderFactory {
|
|
22
|
-
private telemetry?;
|
|
23
|
-
constructor(telemetry?: TelemetryClient | undefined);
|
|
24
|
-
create(db: MerkleTreeWriteOperations): BlockBuilder;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=light.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../src/block_builder/light.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,OAAO,EAEP,KAAK,yBAAyB,EAC9B,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,EAAE,EAAE,KAAK,eAAe,EAAuC,MAAM,oBAAoB,CAAC;AAKnG,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK/D;;GAEG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IAS9C,OAAO,CAAC,EAAE;IAA6B,OAAO,CAAC,SAAS;IARpE,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,eAAe,CAAC,CAAkB;IAC1C,OAAO,CAAC,cAAc,CAAC,CAAO;IAE9B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqB;IAEzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmE;gBAEtE,EAAE,EAAE,yBAAyB,EAAU,SAAS,EAAE,eAAe;IAE/E,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUpG,QAAQ,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxC,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;YAkB7B,UAAU;CAgBzB;AAED,qBAAa,8BAA8B;IAC7B,OAAO,CAAC,SAAS,CAAC;gBAAV,SAAS,CAAC,6BAAiB;IAE/C,MAAM,CAAC,EAAE,EAAE,yBAAyB,GAAG,YAAY;CAGpD"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { createDebugLogger } from '@aztec/aztec.js';
|
|
2
|
-
import { L2Block, MerkleTreeId, makeEmptyProcessedTx, } from '@aztec/circuit-types';
|
|
3
|
-
import { Fr, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/circuits.js';
|
|
4
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
5
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
|
|
6
|
-
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
7
|
-
import { buildBaseRollupHints, buildHeaderAndBodyFromTxs, getTreeSnapshot } from '@aztec/prover-client/helpers';
|
|
8
|
-
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
9
|
-
import { inspect } from 'util';
|
|
10
|
-
/**
|
|
11
|
-
* Builds a block and its header from a set of processed tx without running any circuits.
|
|
12
|
-
*/
|
|
13
|
-
export class LightweightBlockBuilder {
|
|
14
|
-
constructor(db, telemetry) {
|
|
15
|
-
this.db = db;
|
|
16
|
-
this.telemetry = telemetry;
|
|
17
|
-
this.txs = [];
|
|
18
|
-
this.logger = createDebugLogger('aztec:sequencer-client:block_builder_light');
|
|
19
|
-
}
|
|
20
|
-
async startNewBlock(numTxs, globalVariables, l1ToL2Messages) {
|
|
21
|
-
this.logger.verbose('Starting new block', { numTxs, globalVariables: inspect(globalVariables), l1ToL2Messages });
|
|
22
|
-
this.numTxs = numTxs;
|
|
23
|
-
this.globalVariables = globalVariables;
|
|
24
|
-
this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
25
|
-
// Update L1 to L2 tree
|
|
26
|
-
await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages);
|
|
27
|
-
}
|
|
28
|
-
async addNewTx(tx) {
|
|
29
|
-
this.logger.verbose('Adding new tx to block', { txHash: tx.hash.toString() });
|
|
30
|
-
this.txs.push(tx);
|
|
31
|
-
await buildBaseRollupHints(tx, this.globalVariables, this.db);
|
|
32
|
-
}
|
|
33
|
-
async setBlockCompleted() {
|
|
34
|
-
const paddingTxCount = this.numTxs - this.txs.length;
|
|
35
|
-
this.logger.verbose(`Setting block as completed and adding ${paddingTxCount} padding txs`);
|
|
36
|
-
for (let i = 0; i < paddingTxCount; i++) {
|
|
37
|
-
await this.addNewTx(makeEmptyProcessedTx(this.db.getInitialHeader(), this.globalVariables.chainId, this.globalVariables.version, getVKTreeRoot(), protocolContractTreeRoot));
|
|
38
|
-
}
|
|
39
|
-
return this.buildBlock();
|
|
40
|
-
}
|
|
41
|
-
async buildBlock() {
|
|
42
|
-
this.logger.verbose(`Finalising block`);
|
|
43
|
-
const { header, body } = await buildHeaderAndBodyFromTxs(this.txs, this.globalVariables, this.l1ToL2Messages, this.db);
|
|
44
|
-
await this.db.updateArchive(header);
|
|
45
|
-
const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
|
|
46
|
-
const block = new L2Block(newArchive, header, body);
|
|
47
|
-
return block;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export class LightweightBlockBuilderFactory {
|
|
51
|
-
constructor(telemetry) {
|
|
52
|
-
this.telemetry = telemetry;
|
|
53
|
-
}
|
|
54
|
-
create(db) {
|
|
55
|
-
return new LightweightBlockBuilder(db, this.telemetry ?? new NoopTelemetryClient());
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlnaHQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmxvY2tfYnVpbGRlci9saWdodC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUNwRCxPQUFPLEVBRUwsT0FBTyxFQUNQLFlBQVksRUFHWixvQkFBb0IsR0FDckIsTUFBTSxzQkFBc0IsQ0FBQztBQUM5QixPQUFPLEVBQUUsRUFBRSxFQUF3QixtQ0FBbUMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ25HLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSw4QkFBOEIs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teOperations, type ProcessedTx } from '@aztec/circuit-types';
|
|
2
|
-
import { type Fr, type GlobalVariables } from '@aztec/circuits.js';
|
|
3
|
-
import { type SimulationProvider } from '@aztec/simulator';
|
|
4
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
5
|
-
/**
|
|
6
|
-
* Implements a block simulator using a test circuit prover under the hood, which just simulates circuits and outputs empty proofs.
|
|
7
|
-
* This class is unused at the moment, but could be leveraged by a prover-node to ascertain that it can prove a block before
|
|
8
|
-
* committing to proving it by sending a quote.
|
|
9
|
-
*/
|
|
10
|
-
export declare class OrchestratorBlockBuilder implements BlockBuilder {
|
|
11
|
-
private orchestrator;
|
|
12
|
-
constructor(db: MerkleTreeWriteOperations, simulationProvider: SimulationProvider, telemetry: TelemetryClient);
|
|
13
|
-
startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void>;
|
|
14
|
-
setBlockCompleted(): Promise<L2Block>;
|
|
15
|
-
addNewTx(tx: ProcessedTx): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export declare class OrchestratorBlockBuilderFactory {
|
|
18
|
-
private simulationProvider;
|
|
19
|
-
private telemetry?;
|
|
20
|
-
constructor(simulationProvider: SimulationProvider, telemetry?: TelemetryClient | undefined);
|
|
21
|
-
create(db: MerkleTreeWriteOperations): BlockBuilder;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/block_builder/orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,yBAAyB,EAC9B,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D;;;;GAIG;AACH,qBAAa,wBAAyB,YAAW,YAAY;IAC3D,OAAO,CAAC,YAAY,CAAsB;gBAC9B,EAAE,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,SAAS,EAAE,eAAe;IAK7G,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAGpG,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAGrC,QAAQ,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAGzC;AAED,qBAAa,+BAA+B;IAC9B,OAAO,CAAC,kBAAkB;IAAsB,OAAO,CAAC,SAAS,CAAC;gBAA1D,kBAAkB,EAAE,kBAAkB,EAAU,SAAS,CAAC,6BAAiB;IAE/F,MAAM,CAAC,EAAE,EAAE,yBAAyB,GAAG,YAAY;CAGpD"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { TestCircuitProver } from '@aztec/bb-prover';
|
|
2
|
-
import { ProvingOrchestrator } from '@aztec/prover-client/orchestrator';
|
|
3
|
-
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
|
|
4
|
-
/**
|
|
5
|
-
* Implements a block simulator using a test circuit prover under the hood, which just simulates circuits and outputs empty proofs.
|
|
6
|
-
* This class is unused at the moment, but could be leveraged by a prover-node to ascertain that it can prove a block before
|
|
7
|
-
* committing to proving it by sending a quote.
|
|
8
|
-
*/
|
|
9
|
-
export class OrchestratorBlockBuilder {
|
|
10
|
-
constructor(db, simulationProvider, telemetry) {
|
|
11
|
-
const testProver = new TestCircuitProver(telemetry, simulationProvider);
|
|
12
|
-
this.orchestrator = new ProvingOrchestrator(db, testProver, telemetry);
|
|
13
|
-
}
|
|
14
|
-
startNewBlock(numTxs, globalVariables, l1ToL2Messages) {
|
|
15
|
-
return this.orchestrator.startNewBlock(numTxs, globalVariables, l1ToL2Messages);
|
|
16
|
-
}
|
|
17
|
-
setBlockCompleted() {
|
|
18
|
-
return this.orchestrator.setBlockCompleted();
|
|
19
|
-
}
|
|
20
|
-
addNewTx(tx) {
|
|
21
|
-
return this.orchestrator.addNewTx(tx);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export class OrchestratorBlockBuilderFactory {
|
|
25
|
-
constructor(simulationProvider, telemetry) {
|
|
26
|
-
this.simulationProvider = simulationProvider;
|
|
27
|
-
this.telemetry = telemetry;
|
|
28
|
-
}
|
|
29
|
-
create(db) {
|
|
30
|
-
return new OrchestratorBlockBuilder(db, this.simulationProvider, this.telemetry ?? new NoopTelemetryClient());
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JjaGVzdHJhdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2Jsb2NrX2J1aWxkZXIvb3JjaGVzdHJhdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBUXJELE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBR3hFLE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBRW5FOzs7O0dBSUc7QUFDSCxNQUFNLE9BQU8sd0JBQXdCO0lBRW5DLFlBQVksRUFBNkIsRUFBRSxrQkFBc0MsRUFBRSxTQUEwQjtRQUMzRyxNQUFNLFVBQVUsR0FBRyxJQUFJLGlCQUFpQixDQUFDLFNBQVMsRUFBRSxrQkFBa0IsQ0FBQyxDQUFDO1FBQ3hFLElBQUksQ0FBQyx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