@aztec/sequencer-client 0.0.1-commit.e61ad554 → 0.0.1-commit.f146247c
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.js +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +12 -4
- package/dest/publisher/sequencer-publisher.d.ts +1 -2
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +39 -18
- package/dest/sequencer/checkpoint_proposal_job.d.ts +26 -9
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +47 -20
- package/dest/sequencer/metrics.d.ts +2 -2
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +27 -17
- package/dest/sequencer/sequencer.js +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +3 -3
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +0 -2
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +1 -1
- package/src/publisher/sequencer-publisher-metrics.ts +7 -3
- package/src/publisher/sequencer-publisher.ts +34 -18
- package/src/sequencer/checkpoint_proposal_job.ts +66 -37
- package/src/sequencer/metrics.ts +36 -18
- package/src/sequencer/sequencer.ts +1 -1
- package/src/test/mock_checkpoint_builder.ts +2 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Attributes, Metrics } from '@aztec/telemetry-client';
|
|
1
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
|
|
2
2
|
import { formatUnits } from 'viem';
|
|
3
3
|
// TODO(palla/mbps): Review all metrics and add any missing ones per checkpoint
|
|
4
4
|
export class SequencerMetrics {
|
|
@@ -39,35 +39,45 @@ export class SequencerMetrics {
|
|
|
39
39
|
this.rollup = rollup;
|
|
40
40
|
this.meter = client.getMeter(name);
|
|
41
41
|
this.tracer = client.getTracer(name);
|
|
42
|
-
this.blockCounter = this.meter
|
|
42
|
+
this.blockCounter = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_COUNT, {
|
|
43
|
+
[Attributes.STATUS]: [
|
|
44
|
+
'failed',
|
|
45
|
+
'built'
|
|
46
|
+
]
|
|
47
|
+
});
|
|
43
48
|
this.blockBuildDuration = this.meter.createHistogram(Metrics.SEQUENCER_BLOCK_BUILD_DURATION);
|
|
44
49
|
this.blockBuildManaPerSecond = this.meter.createGauge(Metrics.SEQUENCER_BLOCK_BUILD_MANA_PER_SECOND);
|
|
45
50
|
this.stateTransitionBufferDuration = this.meter.createHistogram(Metrics.SEQUENCER_STATE_TRANSITION_BUFFER_DURATION);
|
|
46
51
|
this.checkpointAttestationDelay = this.meter.createHistogram(Metrics.SEQUENCER_CHECKPOINT_ATTESTATION_DELAY);
|
|
47
|
-
// Init gauges and counters
|
|
48
|
-
this.blockCounter.add(0, {
|
|
49
|
-
[Attributes.STATUS]: 'failed'
|
|
50
|
-
});
|
|
51
|
-
this.blockCounter.add(0, {
|
|
52
|
-
[Attributes.STATUS]: 'built'
|
|
53
|
-
});
|
|
54
52
|
this.rewards = this.meter.createGauge(Metrics.SEQUENCER_CURRENT_BLOCK_REWARDS);
|
|
55
|
-
this.slots = this.meter
|
|
53
|
+
this.slots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLOT_COUNT);
|
|
56
54
|
/**
|
|
57
55
|
* NOTE: we do not track missed slots as a separate metric. That would be difficult to determine
|
|
58
56
|
* Instead, use a computed metric, `slots - filledSlots` to get the number of slots a sequencer has missed.
|
|
59
|
-
*/ this.filledSlots = this.meter
|
|
57
|
+
*/ this.filledSlots = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_FILLED_SLOT_COUNT);
|
|
60
58
|
this.timeToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_DURATION);
|
|
61
59
|
this.allowanceToCollectAttestations = this.meter.createGauge(Metrics.SEQUENCER_COLLECT_ATTESTATIONS_TIME_ALLOWANCE);
|
|
62
60
|
this.requiredAttestions = this.meter.createGauge(Metrics.SEQUENCER_REQUIRED_ATTESTATIONS_COUNT);
|
|
63
61
|
this.collectedAttestions = this.meter.createGauge(Metrics.SEQUENCER_COLLECTED_ATTESTATIONS_COUNT);
|
|
64
|
-
this.blockProposalFailed = this.meter
|
|
65
|
-
this.blockProposalSuccess = this.meter
|
|
66
|
-
this.checkpointSuccess = this.meter
|
|
67
|
-
this.blockProposalPrecheckFailed = this.meter
|
|
68
|
-
|
|
62
|
+
this.blockProposalFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_PROPOSAL_FAILED_COUNT);
|
|
63
|
+
this.blockProposalSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_PROPOSAL_SUCCESS_COUNT);
|
|
64
|
+
this.checkpointSuccess = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_CHECKPOINT_SUCCESS_COUNT);
|
|
65
|
+
this.blockProposalPrecheckFailed = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_BLOCK_PROPOSAL_PRECHECK_FAILED_COUNT, {
|
|
66
|
+
[Attributes.ERROR_TYPE]: [
|
|
67
|
+
'slot_already_taken',
|
|
68
|
+
'rollup_contract_check_failed',
|
|
69
|
+
'slot_mismatch',
|
|
70
|
+
'block_number_mismatch'
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
this.slashingAttempts = createUpDownCounterWithDefault(this.meter, Metrics.SEQUENCER_SLASHING_ATTEMPTS_COUNT);
|
|
69
74
|
// Fisherman fee analysis metrics
|
|
70
|
-
this.fishermanWouldBeIncluded = this.meter
|
|
75
|
+
this.fishermanWouldBeIncluded = createUpDownCounterWithDefault(this.meter, Metrics.FISHERMAN_FEE_ANALYSIS_WOULD_BE_INCLUDED, {
|
|
76
|
+
[Attributes.OK]: [
|
|
77
|
+
true,
|
|
78
|
+
false
|
|
79
|
+
]
|
|
80
|
+
});
|
|
71
81
|
this.fishermanTimeBeforeBlock = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_TIME_BEFORE_BLOCK);
|
|
72
82
|
this.fishermanPendingBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_PENDING_BLOB_TX_COUNT);
|
|
73
83
|
this.fishermanIncludedBlobTxCount = this.meter.createHistogram(Metrics.FISHERMAN_FEE_ANALYSIS_INCLUDED_BLOB_TX_COUNT);
|
|
@@ -705,7 +705,7 @@ _dec = trackSpan('Sequencer.work'), _dec1 = trackSpan('Sequencer.prepareCheckpoi
|
|
|
705
705
|
return this.createCheckpointProposalJob(epoch, slot, checkpointNumber, syncedTo.blockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint);
|
|
706
706
|
}
|
|
707
707
|
createCheckpointProposalJob(epoch, slot, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint) {
|
|
708
|
-
return new CheckpointProposalJob(epoch, slot, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint, this.validatorClient, this.globalsBuilder, this.p2pClient, this.worldState, this.l1ToL2MessageSource, this.l2BlockSource, this.checkpointsBuilder, this.l2BlockSource, this.l1Constants, this.config, this.timetable, this.slasherClient, this.epochCache, this.dateProvider, this.metrics, this, this.setState.bind(this), this.
|
|
708
|
+
return new CheckpointProposalJob(epoch, slot, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress, invalidateCheckpoint, this.validatorClient, this.globalsBuilder, this.p2pClient, this.worldState, this.l1ToL2MessageSource, this.l2BlockSource, this.checkpointsBuilder, this.l2BlockSource, this.l1Constants, this.config, this.timetable, this.slasherClient, this.epochCache, this.dateProvider, this.metrics, this, this.setState.bind(this), this.tracer, this.log.getBindings());
|
|
709
709
|
}
|
|
710
710
|
/**
|
|
711
711
|
* Internal helper for setting the sequencer state and checks if we have enough time left in the slot to transition to the new state.
|
|
@@ -4,7 +4,7 @@ import { L2Block } from '@aztec/stdlib/block';
|
|
|
4
4
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
5
5
|
import type { FullNodeBlockBuilderConfig, ICheckpointBlockBuilder, ICheckpointsBuilder, MerkleTreeWriteOperations, PublicProcessorLimits } from '@aztec/stdlib/interfaces/server';
|
|
6
6
|
import type { CheckpointGlobalVariables, Tx } from '@aztec/stdlib/tx';
|
|
7
|
-
import type {
|
|
7
|
+
import type { BuildBlockInCheckpointResult } from '@aztec/validator-client';
|
|
8
8
|
/**
|
|
9
9
|
* A fake CheckpointBuilder for testing that implements the same interface as the real one.
|
|
10
10
|
* Can be seeded with blocks to return sequentially on each `buildBlock` call.
|
|
@@ -39,7 +39,7 @@ export declare class MockCheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
39
39
|
*/
|
|
40
40
|
setBlockProvider(provider: () => L2Block): this;
|
|
41
41
|
getConstantData(): CheckpointGlobalVariables;
|
|
42
|
-
buildBlock(pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, blockNumber: BlockNumber, timestamp: bigint, opts: PublicProcessorLimits): Promise<
|
|
42
|
+
buildBlock(pendingTxs: Iterable<Tx> | AsyncIterable<Tx>, blockNumber: BlockNumber, timestamp: bigint, opts: PublicProcessorLimits): Promise<BuildBlockInCheckpointResult>;
|
|
43
43
|
completeCheckpoint(): Promise<Checkpoint>;
|
|
44
44
|
getCheckpoint(): Promise<Checkpoint>;
|
|
45
45
|
/**
|
|
@@ -92,4 +92,4 @@ export declare class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
92
92
|
/** Reset for reuse in another test */
|
|
93
93
|
reset(): void;
|
|
94
94
|
}
|
|
95
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
95
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjoz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BQUcsU0FBUyxDQUV4RDtJQUVELFNBQVMsSUFBSSwwQkFBMEIsQ0FPdEM7SUFFRCxZQUFZLENBQUMsTUFBTSxFQUFFLE9BQU8sQ0FBQywwQkFBMEIsQ0FBQyxHQUFHLElBQUksQ0FFOUQ7SUFFRCxlQUFlLENBQ2IsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQ2xDLFNBQVMsRUFBRSx5QkFBeUIsRUFDcEMsY0FBYyxFQUFFLEVBQUUsRUFBRSxFQUNwQiwyQkFBMkIsRUFBRSxFQUFFLEVBQUUsRUFDakMsS0FBSyxFQUFFLHlCQUF5QixHQUMvQixPQUFPLENBQUMsdUJBQXVCLENBQUMsQ0FTbEM7SUFFRCxjQUFjLENBQ1osZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQ2xDLFNBQVMsRUFBRSx5QkFBeUIsRUFDcEMsY0FBYyxFQUFFLEVBQUUsRUFBRSxFQUNwQiwyQkFBMkIsRUFBRSxFQUFFLEVBQUUsRUFDakMsS0FBSyxFQUFFLHlCQUF5QixFQUNoQyxjQUFjLEdBQUUsT0FBTyxFQUFPLEdBQzdCLE9BQU8sQ0FBQyx1QkFBdUIsQ0FBQyxDQWVsQztJQUVELE9BQU8sQ0FBQyxZQUFZLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyx5QkFBeUIsQ0FBQyxDQUVyRTtJQUVELHNDQUFzQztJQUN0QyxLQUFLLElBQUksSUFBSSxDQUtaO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock_checkpoint_builder.d.ts","sourceRoot":"","sources":["../../src/test/mock_checkpoint_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"mock_checkpoint_builder.d.ts","sourceRoot":"","sources":["../../src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E,qBAAqB,GAAG,IAAI,CAGzD;IAED;;;OAGG;IACH,uBAAuB,CACrB,SAAS,EAAE,yBAAyB,EACpC,gBAAgB,EAAE,gBAAgB,GACjC,qBAAqB,CAGvB;IAED,0DAA0D;IAC1D,oBAAoB,IAAI,qBAAqB,GAAG,SAAS,CAExD;IAED,SAAS,IAAI,0BAA0B,CAOtC;IAED,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,0BAA0B,CAAC,GAAG,IAAI,CAE9D;IAED,eAAe,CACb,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,yBAAyB,EACpC,cAAc,EAAE,EAAE,EAAE,EACpB,2BAA2B,EAAE,EAAE,EAAE,EACjC,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CASlC;IAED,cAAc,CACZ,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,yBAAyB,EACpC,cAAc,EAAE,EAAE,EAAE,EACpB,2BAA2B,EAAE,EAAE,EAAE,EACjC,KAAK,EAAE,yBAAyB,EAChC,cAAc,GAAE,OAAO,EAAO,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAelC;IAED,OAAO,CAAC,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAErE;IAED,sCAAsC;IACtC,KAAK,IAAI,IAAI,CAKZ;CACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
3
2
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
4
3
|
import { Gas } from '@aztec/stdlib/gas';
|
|
5
4
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
@@ -91,7 +90,6 @@ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
|
91
90
|
publicGas: Gas.empty(),
|
|
92
91
|
publicProcessorDuration: 0,
|
|
93
92
|
numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
|
|
94
|
-
blockBuildingTimer: new Timer(),
|
|
95
93
|
usedTxs,
|
|
96
94
|
failedTxs: [],
|
|
97
95
|
usedTxBlobFields: block?.body?.txEffects?.reduce((sum, tx)=>sum + tx.getNumBlobFields(), 0) ?? 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.f146247c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -26,38 +26,38 @@
|
|
|
26
26
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
30
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
31
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
32
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
33
|
-
"@aztec/constants": "0.0.1-commit.
|
|
34
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
35
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
36
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
37
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
38
|
-
"@aztec/merkle-tree": "0.0.1-commit.
|
|
39
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
40
|
-
"@aztec/noir-acvm_js": "0.0.1-commit.
|
|
41
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
42
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
43
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
44
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
45
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
46
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
47
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
48
|
-
"@aztec/slasher": "0.0.1-commit.
|
|
49
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
50
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
51
|
-
"@aztec/validator-client": "0.0.1-commit.
|
|
52
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
53
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
29
|
+
"@aztec/aztec.js": "0.0.1-commit.f146247c",
|
|
30
|
+
"@aztec/bb-prover": "0.0.1-commit.f146247c",
|
|
31
|
+
"@aztec/blob-client": "0.0.1-commit.f146247c",
|
|
32
|
+
"@aztec/blob-lib": "0.0.1-commit.f146247c",
|
|
33
|
+
"@aztec/constants": "0.0.1-commit.f146247c",
|
|
34
|
+
"@aztec/epoch-cache": "0.0.1-commit.f146247c",
|
|
35
|
+
"@aztec/ethereum": "0.0.1-commit.f146247c",
|
|
36
|
+
"@aztec/foundation": "0.0.1-commit.f146247c",
|
|
37
|
+
"@aztec/l1-artifacts": "0.0.1-commit.f146247c",
|
|
38
|
+
"@aztec/merkle-tree": "0.0.1-commit.f146247c",
|
|
39
|
+
"@aztec/node-keystore": "0.0.1-commit.f146247c",
|
|
40
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.f146247c",
|
|
41
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.f146247c",
|
|
42
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.f146247c",
|
|
43
|
+
"@aztec/noir-types": "0.0.1-commit.f146247c",
|
|
44
|
+
"@aztec/p2p": "0.0.1-commit.f146247c",
|
|
45
|
+
"@aztec/protocol-contracts": "0.0.1-commit.f146247c",
|
|
46
|
+
"@aztec/prover-client": "0.0.1-commit.f146247c",
|
|
47
|
+
"@aztec/simulator": "0.0.1-commit.f146247c",
|
|
48
|
+
"@aztec/slasher": "0.0.1-commit.f146247c",
|
|
49
|
+
"@aztec/stdlib": "0.0.1-commit.f146247c",
|
|
50
|
+
"@aztec/telemetry-client": "0.0.1-commit.f146247c",
|
|
51
|
+
"@aztec/validator-client": "0.0.1-commit.f146247c",
|
|
52
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.f146247c",
|
|
53
|
+
"@aztec/world-state": "0.0.1-commit.f146247c",
|
|
54
54
|
"lodash.chunk": "^4.2.0",
|
|
55
55
|
"tslib": "^2.4.0",
|
|
56
56
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
60
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
59
|
+
"@aztec/archiver": "0.0.1-commit.f146247c",
|
|
60
|
+
"@aztec/kv-store": "0.0.1-commit.f146247c",
|
|
61
61
|
"@electric-sql/pglite": "^0.3.14",
|
|
62
62
|
"@jest/globals": "^30.0.0",
|
|
63
63
|
"@types/jest": "^30.0.0",
|
|
@@ -85,7 +85,7 @@ export class SequencerClient {
|
|
|
85
85
|
publicClient,
|
|
86
86
|
l1TxUtils.map(x => x.getSenderAddress()),
|
|
87
87
|
);
|
|
88
|
-
const publisherManager = new PublisherManager(l1TxUtils, config);
|
|
88
|
+
const publisherManager = new PublisherManager(l1TxUtils, config, log.getBindings());
|
|
89
89
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
90
90
|
const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
|
|
91
91
|
rollupContract.getL1GenesisTime(),
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Metrics,
|
|
8
8
|
type TelemetryClient,
|
|
9
9
|
type UpDownCounter,
|
|
10
|
+
createUpDownCounterWithDefault,
|
|
10
11
|
} from '@aztec/telemetry-client';
|
|
11
12
|
|
|
12
13
|
import { formatEther } from 'viem/utils';
|
|
@@ -41,7 +42,10 @@ export class SequencerPublisherMetrics {
|
|
|
41
42
|
|
|
42
43
|
this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
|
|
43
44
|
|
|
44
|
-
this.txCount = meter
|
|
45
|
+
this.txCount = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_TX_COUNT, {
|
|
46
|
+
[Attributes.L1_TX_TYPE]: ['process'],
|
|
47
|
+
[Attributes.OK]: [true, false],
|
|
48
|
+
});
|
|
45
49
|
|
|
46
50
|
this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
|
|
47
51
|
|
|
@@ -59,9 +63,9 @@ export class SequencerPublisherMetrics {
|
|
|
59
63
|
|
|
60
64
|
this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS);
|
|
61
65
|
|
|
62
|
-
this.blobTxSuccessCounter = meter
|
|
66
|
+
this.blobTxSuccessCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS);
|
|
63
67
|
|
|
64
|
-
this.blobTxFailureCounter = meter
|
|
68
|
+
this.blobTxFailureCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_FAILURE);
|
|
65
69
|
|
|
66
70
|
this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
|
|
67
71
|
|
|
@@ -18,11 +18,12 @@ import {
|
|
|
18
18
|
type L1BlobInputs,
|
|
19
19
|
type L1TxConfig,
|
|
20
20
|
type L1TxRequest,
|
|
21
|
+
MAX_L1_TX_LIMIT,
|
|
21
22
|
type TransactionStats,
|
|
22
23
|
WEI_CONST,
|
|
23
24
|
} from '@aztec/ethereum/l1-tx-utils';
|
|
24
25
|
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
25
|
-
import { FormattedViemError, formatViemError, tryExtractEvent } from '@aztec/ethereum/utils';
|
|
26
|
+
import { FormattedViemError, formatViemError, mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
|
|
26
27
|
import { sumBigint } from '@aztec/foundation/bigint';
|
|
27
28
|
import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
|
|
28
29
|
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
@@ -122,11 +123,6 @@ export class SequencerPublisher {
|
|
|
122
123
|
|
|
123
124
|
/** L1 fee analyzer for fisherman mode */
|
|
124
125
|
private l1FeeAnalyzer?: L1FeeAnalyzer;
|
|
125
|
-
// @note - with blobs, the below estimate seems too large.
|
|
126
|
-
// Total used for full block from int_l1_pub e2e test: 1m (of which 86k is 1x blob)
|
|
127
|
-
// Total used for emptier block from above test: 429k (of which 84k is 1x blob)
|
|
128
|
-
public static PROPOSE_GAS_GUESS: bigint = 12_000_000n;
|
|
129
|
-
|
|
130
126
|
// A CALL to a cold address is 2700 gas
|
|
131
127
|
public static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
|
|
132
128
|
|
|
@@ -273,7 +269,7 @@ export class SequencerPublisher {
|
|
|
273
269
|
// Start the analysis
|
|
274
270
|
const analysisId = await this.l1FeeAnalyzer.startAnalysis(
|
|
275
271
|
l2SlotNumber,
|
|
276
|
-
gasLimit > 0n ? gasLimit :
|
|
272
|
+
gasLimit > 0n ? gasLimit : MAX_L1_TX_LIMIT,
|
|
277
273
|
l1Requests,
|
|
278
274
|
blobConfig,
|
|
279
275
|
onComplete,
|
|
@@ -346,7 +342,16 @@ export class SequencerPublisher {
|
|
|
346
342
|
|
|
347
343
|
// Merge gasConfigs. Yields the sum of gasLimits, and the earliest txTimeoutAt, or undefined if no gasConfig sets them.
|
|
348
344
|
const gasLimits = gasConfigs.map(g => g?.gasLimit).filter((g): g is bigint => g !== undefined);
|
|
349
|
-
|
|
345
|
+
let gasLimit = gasLimits.length > 0 ? sumBigint(gasLimits) : undefined; // sum
|
|
346
|
+
// Cap at L1 block gas limit so the node accepts the tx ("gas limit too high" otherwise).
|
|
347
|
+
const maxGas = MAX_L1_TX_LIMIT;
|
|
348
|
+
if (gasLimit !== undefined && gasLimit > maxGas) {
|
|
349
|
+
this.log.debug('Capping bundled tx gas limit to L1 max', {
|
|
350
|
+
requested: gasLimit,
|
|
351
|
+
capped: maxGas,
|
|
352
|
+
});
|
|
353
|
+
gasLimit = maxGas;
|
|
354
|
+
}
|
|
350
355
|
const txTimeoutAts = gasConfigs.map(g => g?.txTimeoutAt).filter((g): g is Date => g !== undefined);
|
|
351
356
|
const txTimeoutAt = txTimeoutAts.length > 0 ? new Date(Math.min(...txTimeoutAts.map(g => g.getTime()))) : undefined; // earliest
|
|
352
357
|
const txConfig: RequestWithExpiry['gasConfig'] = { gasLimit, txTimeoutAt };
|
|
@@ -517,7 +522,12 @@ export class SequencerPublisher {
|
|
|
517
522
|
this.log.debug(`Simulating invalidate checkpoint ${checkpointNumber}`, { ...logData, request });
|
|
518
523
|
|
|
519
524
|
try {
|
|
520
|
-
const { gasUsed } = await this.l1TxUtils.simulate(
|
|
525
|
+
const { gasUsed } = await this.l1TxUtils.simulate(
|
|
526
|
+
request,
|
|
527
|
+
undefined,
|
|
528
|
+
undefined,
|
|
529
|
+
mergeAbis([request.abi ?? [], ErrorsAbi]),
|
|
530
|
+
);
|
|
521
531
|
this.log.verbose(`Simulation for invalidate checkpoint ${checkpointNumber} succeeded`, {
|
|
522
532
|
...logData,
|
|
523
533
|
request,
|
|
@@ -536,7 +546,7 @@ export class SequencerPublisher {
|
|
|
536
546
|
|
|
537
547
|
// If the error is due to the checkpoint not being in the pending chain, and it was indeed removed by someone else,
|
|
538
548
|
// we can safely ignore it and return undefined so we go ahead with checkpoint building.
|
|
539
|
-
if (viemError.message?.includes('
|
|
549
|
+
if (viemError.message?.includes('Rollup__CheckpointNotInPendingChain')) {
|
|
540
550
|
this.log.verbose(
|
|
541
551
|
`Simulation for invalidate checkpoint ${checkpointNumber} failed due to checkpoint not being in pending chain`,
|
|
542
552
|
{ ...logData, request, error: viemError.message },
|
|
@@ -700,7 +710,7 @@ export class SequencerPublisher {
|
|
|
700
710
|
});
|
|
701
711
|
|
|
702
712
|
try {
|
|
703
|
-
await this.l1TxUtils.simulate(request, { time: timestamp }, [], ErrorsAbi);
|
|
713
|
+
await this.l1TxUtils.simulate(request, { time: timestamp }, [], mergeAbis([request.abi ?? [], ErrorsAbi]));
|
|
704
714
|
this.log.debug(`Simulation for ${action} at slot ${slotNumber} succeeded`, { request });
|
|
705
715
|
} catch (err) {
|
|
706
716
|
this.log.error(`Failed simulation for ${action} at slot ${slotNumber} (enqueuing the action anyway)`, err);
|
|
@@ -999,12 +1009,14 @@ export class SequencerPublisher {
|
|
|
999
1009
|
this.log.debug(`Simulating ${action} for slot ${slotNumber}`, logData);
|
|
1000
1010
|
|
|
1001
1011
|
let gasUsed: bigint;
|
|
1012
|
+
const simulateAbi = mergeAbis([request.abi ?? [], ErrorsAbi]);
|
|
1002
1013
|
try {
|
|
1003
|
-
({ gasUsed } = await this.l1TxUtils.simulate(request, { time: timestamp }, [],
|
|
1014
|
+
({ gasUsed } = await this.l1TxUtils.simulate(request, { time: timestamp }, [], simulateAbi)); // TODO(palla/slash): Check the timestamp logic
|
|
1004
1015
|
this.log.verbose(`Simulation for ${action} succeeded`, { ...logData, request, gasUsed });
|
|
1005
1016
|
} catch (err) {
|
|
1006
|
-
const viemError = formatViemError(err);
|
|
1017
|
+
const viemError = formatViemError(err, simulateAbi);
|
|
1007
1018
|
this.log.error(`Simulation for ${action} at ${slotNumber} failed`, viemError, logData);
|
|
1019
|
+
|
|
1008
1020
|
return false;
|
|
1009
1021
|
}
|
|
1010
1022
|
|
|
@@ -1012,10 +1024,14 @@ export class SequencerPublisher {
|
|
|
1012
1024
|
const gasLimit = this.l1TxUtils.bumpGasLimit(BigInt(Math.ceil((Number(gasUsed) * 64) / 63)));
|
|
1013
1025
|
logData.gasLimit = gasLimit;
|
|
1014
1026
|
|
|
1027
|
+
// Store the ABI used for simulation on the request so Multicall3.forward can decode errors
|
|
1028
|
+
// when the tx is sent and a revert is diagnosed via simulation.
|
|
1029
|
+
const requestWithAbi = { ...request, abi: simulateAbi };
|
|
1030
|
+
|
|
1015
1031
|
this.log.debug(`Enqueuing ${action}`, logData);
|
|
1016
1032
|
this.addRequest({
|
|
1017
1033
|
action,
|
|
1018
|
-
request,
|
|
1034
|
+
request: requestWithAbi,
|
|
1019
1035
|
gasConfig: { gasLimit },
|
|
1020
1036
|
lastValidL2Slot: slotNumber,
|
|
1021
1037
|
checkSuccess: (_req, result) => {
|
|
@@ -1171,20 +1187,20 @@ export class SequencerPublisher {
|
|
|
1171
1187
|
{
|
|
1172
1188
|
to: this.rollupContract.address,
|
|
1173
1189
|
data: rollupData,
|
|
1174
|
-
gas:
|
|
1190
|
+
gas: MAX_L1_TX_LIMIT,
|
|
1175
1191
|
...(this.proposerAddressForSimulation && { from: this.proposerAddressForSimulation.toString() }),
|
|
1176
1192
|
},
|
|
1177
1193
|
{
|
|
1178
1194
|
// @note we add 1n to the timestamp because geth implementation doesn't like simulation timestamp to be equal to the current block timestamp
|
|
1179
1195
|
time: timestamp + 1n,
|
|
1180
1196
|
// @note reth should have a 30m gas limit per block but throws errors that this tx is beyond limit so we increase here
|
|
1181
|
-
gasLimit:
|
|
1197
|
+
gasLimit: MAX_L1_TX_LIMIT * 2n,
|
|
1182
1198
|
},
|
|
1183
1199
|
stateOverrides,
|
|
1184
1200
|
RollupAbi,
|
|
1185
1201
|
{
|
|
1186
1202
|
// @note fallback gas estimate to use if the node doesn't support simulation API
|
|
1187
|
-
fallbackGasEstimate:
|
|
1203
|
+
fallbackGasEstimate: MAX_L1_TX_LIMIT,
|
|
1188
1204
|
},
|
|
1189
1205
|
)
|
|
1190
1206
|
.catch(err => {
|
|
@@ -1194,7 +1210,7 @@ export class SequencerPublisher {
|
|
|
1194
1210
|
this.log.debug(`Ignoring expected ValidatorSelection__MissingProposerSignature error in fisherman mode`);
|
|
1195
1211
|
// Return a minimal simulation result with the fallback gas estimate
|
|
1196
1212
|
return {
|
|
1197
|
-
gasUsed:
|
|
1213
|
+
gasUsed: MAX_L1_TX_LIMIT,
|
|
1198
1214
|
logs: [],
|
|
1199
1215
|
};
|
|
1200
1216
|
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { NUM_CHECKPOINT_END_MARKER_FIELDS, getNumBlockEndBlobFields } from '@aztec/blob-lib/encoding';
|
|
2
2
|
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB } from '@aztec/constants';
|
|
3
3
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
BlockNumber,
|
|
6
|
+
CheckpointNumber,
|
|
7
|
+
EpochNumber,
|
|
8
|
+
IndexWithinCheckpoint,
|
|
9
|
+
SlotNumber,
|
|
10
|
+
} from '@aztec/foundation/branded-types';
|
|
5
11
|
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
6
12
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
13
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
14
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
9
15
|
import { filter } from '@aztec/foundation/iterator';
|
|
10
|
-
import type
|
|
16
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
11
17
|
import { sleep, sleepUntil } from '@aztec/foundation/sleep';
|
|
12
18
|
import { type DateProvider, Timer } from '@aztec/foundation/timer';
|
|
13
|
-
import { type TypedEventEmitter, unfreeze } from '@aztec/foundation/types';
|
|
19
|
+
import { type TypedEventEmitter, isErrorClass, unfreeze } from '@aztec/foundation/types';
|
|
14
20
|
import type { P2P } from '@aztec/p2p';
|
|
15
21
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
16
22
|
import {
|
|
@@ -24,10 +30,11 @@ import {
|
|
|
24
30
|
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
25
31
|
import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
26
32
|
import { Gas } from '@aztec/stdlib/gas';
|
|
27
|
-
import
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
import {
|
|
34
|
+
NoValidTxsError,
|
|
35
|
+
type PublicProcessorLimits,
|
|
36
|
+
type ResolvedSequencerConfig,
|
|
37
|
+
type WorldStateSynchronizer,
|
|
31
38
|
} from '@aztec/stdlib/interfaces/server';
|
|
32
39
|
import { type L1ToL2MessageSource, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
33
40
|
import type { BlockProposalOptions, CheckpointProposal, CheckpointProposalOptions } from '@aztec/stdlib/p2p';
|
|
@@ -59,6 +66,8 @@ const TXS_POLLING_MS = 500;
|
|
|
59
66
|
* the Sequencer once the check for being the proposer for the slot has succeeded.
|
|
60
67
|
*/
|
|
61
68
|
export class CheckpointProposalJob implements Traceable {
|
|
69
|
+
protected readonly log: Logger;
|
|
70
|
+
|
|
62
71
|
constructor(
|
|
63
72
|
private readonly epoch: EpochNumber,
|
|
64
73
|
private readonly slot: SlotNumber,
|
|
@@ -86,9 +95,11 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
86
95
|
private readonly metrics: SequencerMetrics,
|
|
87
96
|
private readonly eventEmitter: TypedEventEmitter<SequencerEvents>,
|
|
88
97
|
private readonly setStateFn: (state: SequencerState, slot?: SlotNumber) => void,
|
|
89
|
-
protected readonly log: Logger,
|
|
90
98
|
public readonly tracer: Tracer,
|
|
91
|
-
|
|
99
|
+
bindings?: LoggerBindings,
|
|
100
|
+
) {
|
|
101
|
+
this.log = createLogger('sequencer:checkpoint-proposal', { ...bindings, instanceId: `slot-${slot}` });
|
|
102
|
+
}
|
|
92
103
|
|
|
93
104
|
/**
|
|
94
105
|
* Executes the checkpoint proposal job.
|
|
@@ -190,6 +201,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
190
201
|
l1ToL2Messages,
|
|
191
202
|
previousCheckpointOutHashes,
|
|
192
203
|
fork,
|
|
204
|
+
this.log.getBindings(),
|
|
193
205
|
);
|
|
194
206
|
|
|
195
207
|
// Options for the validator client when creating block and checkpoint proposals
|
|
@@ -367,7 +379,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
367
379
|
|
|
368
380
|
while (true) {
|
|
369
381
|
const blocksBuilt = blocksInCheckpoint.length;
|
|
370
|
-
const indexWithinCheckpoint = blocksBuilt;
|
|
382
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(blocksBuilt);
|
|
371
383
|
const blockNumber = BlockNumber(initialBlockNumber + blocksBuilt);
|
|
372
384
|
|
|
373
385
|
const secondsIntoSlot = this.getSecondsIntoSlot();
|
|
@@ -397,6 +409,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
397
409
|
remainingBlobFields,
|
|
398
410
|
});
|
|
399
411
|
|
|
412
|
+
// TODO(palla/mbps): Review these conditions. We may want to keep trying in some scenarios.
|
|
400
413
|
if (!buildResult && timingInfo.isLastBlock) {
|
|
401
414
|
// If no block was produced due to not enough txs and this was the last subslot, exit
|
|
402
415
|
break;
|
|
@@ -483,13 +496,13 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
483
496
|
|
|
484
497
|
/** Builds a single block. Called from the main block building loop. */
|
|
485
498
|
@trackSpan('CheckpointProposalJob.buildSingleBlock')
|
|
486
|
-
|
|
499
|
+
protected async buildSingleBlock(
|
|
487
500
|
checkpointBuilder: CheckpointBuilder,
|
|
488
501
|
opts: {
|
|
489
502
|
forceCreate?: boolean;
|
|
490
503
|
blockTimestamp: bigint;
|
|
491
504
|
blockNumber: BlockNumber;
|
|
492
|
-
indexWithinCheckpoint:
|
|
505
|
+
indexWithinCheckpoint: IndexWithinCheckpoint;
|
|
493
506
|
buildDeadline: Date | undefined;
|
|
494
507
|
txHashesAlreadyIncluded: Set<string>;
|
|
495
508
|
remainingBlobFields: number;
|
|
@@ -550,45 +563,38 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
550
563
|
};
|
|
551
564
|
|
|
552
565
|
// Actually build the block by executing txs
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
usedTxs,
|
|
561
|
-
failedTxs,
|
|
562
|
-
usedTxBlobFields,
|
|
563
|
-
} = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
564
|
-
const blockBuildDuration = workTimer.ms();
|
|
566
|
+
const buildResult = await this.buildSingleBlockWithCheckpointBuilder(
|
|
567
|
+
checkpointBuilder,
|
|
568
|
+
pendingTxs,
|
|
569
|
+
blockNumber,
|
|
570
|
+
blockTimestamp,
|
|
571
|
+
blockBuilderOptions,
|
|
572
|
+
);
|
|
565
573
|
|
|
566
574
|
// If any txs failed during execution, drop them from the mempool so we don't pick them up again
|
|
567
|
-
await this.dropFailedTxsFromP2P(failedTxs);
|
|
575
|
+
await this.dropFailedTxsFromP2P(buildResult.failedTxs);
|
|
568
576
|
|
|
569
577
|
// Check if we have created a block with enough txs. If there were invalid txs in the pool, or if execution took
|
|
570
578
|
// too long, then we may not get to minTxsPerBlock after executing public functions.
|
|
571
579
|
const minValidTxs = this.config.minValidTxsPerBlock ?? minTxs;
|
|
572
|
-
|
|
580
|
+
const numTxs = buildResult.status === 'no-valid-txs' ? 0 : buildResult.numTxs;
|
|
581
|
+
if (buildResult.status === 'no-valid-txs' || (!forceCreate && numTxs < minValidTxs)) {
|
|
573
582
|
this.log.warn(
|
|
574
|
-
`Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.slot} has too few valid txs to be proposed
|
|
575
|
-
{ slot: this.slot, blockNumber, numTxs, indexWithinCheckpoint },
|
|
583
|
+
`Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.slot} has too few valid txs to be proposed`,
|
|
584
|
+
{ slot: this.slot, blockNumber, numTxs, indexWithinCheckpoint, minValidTxs, buildResult: buildResult.status },
|
|
576
585
|
);
|
|
577
|
-
this.eventEmitter.emit('block-
|
|
578
|
-
minTxs: minValidTxs,
|
|
579
|
-
availableTxs: numTxs,
|
|
580
|
-
slot: this.slot,
|
|
581
|
-
});
|
|
586
|
+
this.eventEmitter.emit('block-build-failed', { reason: `Insufficient valid txs`, slot: this.slot });
|
|
582
587
|
this.metrics.recordBlockProposalFailed('insufficient_valid_txs');
|
|
583
588
|
return undefined;
|
|
584
589
|
}
|
|
585
590
|
|
|
586
591
|
// Block creation succeeded, emit stats and metrics
|
|
592
|
+
const { publicGas, block, publicProcessorDuration, usedTxs, usedTxBlobFields, blockBuildDuration } = buildResult;
|
|
593
|
+
|
|
587
594
|
const blockStats = {
|
|
588
595
|
eventName: 'l2-block-built',
|
|
589
596
|
duration: blockBuildDuration,
|
|
590
597
|
publicProcessDuration: publicProcessorDuration,
|
|
591
|
-
rollupCircuitsDuration: blockBuildingTimer.ms(),
|
|
592
598
|
...block.getStats(),
|
|
593
599
|
} satisfies L2BlockBuiltStats;
|
|
594
600
|
|
|
@@ -614,17 +620,40 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
614
620
|
}
|
|
615
621
|
}
|
|
616
622
|
|
|
623
|
+
/** Uses the checkpoint builder to build a block, catching specific txs */
|
|
624
|
+
private async buildSingleBlockWithCheckpointBuilder(
|
|
625
|
+
checkpointBuilder: CheckpointBuilder,
|
|
626
|
+
pendingTxs: AsyncIterable<Tx>,
|
|
627
|
+
blockNumber: BlockNumber,
|
|
628
|
+
blockTimestamp: bigint,
|
|
629
|
+
blockBuilderOptions: PublicProcessorLimits,
|
|
630
|
+
) {
|
|
631
|
+
try {
|
|
632
|
+
const workTimer = new Timer();
|
|
633
|
+
const result = await checkpointBuilder.buildBlock(pendingTxs, blockNumber, blockTimestamp, blockBuilderOptions);
|
|
634
|
+
const blockBuildDuration = workTimer.ms();
|
|
635
|
+
return { ...result, blockBuildDuration, status: 'success' as const };
|
|
636
|
+
} catch (err: unknown) {
|
|
637
|
+
if (isErrorClass(err, NoValidTxsError)) {
|
|
638
|
+
return { failedTxs: err.failedTxs, status: 'no-valid-txs' as const };
|
|
639
|
+
}
|
|
640
|
+
throw err;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
617
644
|
/** Waits until minTxs are available on the pool for building a block. */
|
|
618
645
|
@trackSpan('CheckpointProposalJob.waitForMinTxs')
|
|
619
646
|
private async waitForMinTxs(opts: {
|
|
620
647
|
forceCreate?: boolean;
|
|
621
648
|
blockNumber: BlockNumber;
|
|
622
|
-
indexWithinCheckpoint:
|
|
649
|
+
indexWithinCheckpoint: IndexWithinCheckpoint;
|
|
623
650
|
buildDeadline: Date | undefined;
|
|
624
651
|
}): Promise<{ canStartBuilding: boolean; availableTxs: number }> {
|
|
625
|
-
const minTxs = this.config.minTxsPerBlock;
|
|
626
652
|
const { indexWithinCheckpoint, blockNumber, buildDeadline, forceCreate } = opts;
|
|
627
653
|
|
|
654
|
+
// We only allow a block with 0 txs in the first block of the checkpoint
|
|
655
|
+
const minTxs = indexWithinCheckpoint > 0 && this.config.minTxsPerBlock === 0 ? 1 : this.config.minTxsPerBlock;
|
|
656
|
+
|
|
628
657
|
// Deadline is undefined if we are not enforcing the timetable, meaning we'll exit immediately when out of time
|
|
629
658
|
const startBuildingDeadline = buildDeadline
|
|
630
659
|
? new Date(buildDeadline.getTime() - this.timetable.minExecutionTime * 1000)
|
|
@@ -686,7 +715,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
686
715
|
const attestationTimeAllowed = this.config.enforceTimeTable
|
|
687
716
|
? this.timetable.getMaxAllowedTime(SequencerState.PUBLISHING_CHECKPOINT)!
|
|
688
717
|
: this.l1Constants.slotDuration;
|
|
689
|
-
const attestationDeadline = new Date(this.
|
|
718
|
+
const attestationDeadline = new Date((this.getSlotStartBuildTimestamp() + attestationTimeAllowed) * 1000);
|
|
690
719
|
|
|
691
720
|
this.metrics.recordRequiredAttestations(numberOfRequiredAttestations, attestationTimeAllowed);
|
|
692
721
|
|