@aztec/sequencer-client 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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/README.md +281 -21
- package/dest/client/sequencer-client.d.ts +41 -18
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +88 -43
- package/dest/config.d.ts +41 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +146 -55
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +138 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +80 -0
- package/dest/global_variable_builder/global_builder.d.ts +20 -26
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +28 -75
- package/dest/global_variable_builder/index.d.ts +4 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/publisher/config.d.ts +57 -20
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +134 -39
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_to_l2_messaging.d.ts +21 -0
- package/dest/publisher/l1_to_l2_messaging.d.ts.map +1 -0
- package/dest/publisher/l1_to_l2_messaging.js +70 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +98 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +68 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +36 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +3 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +15 -8
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +28 -4
- package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +23 -86
- package/dest/publisher/sequencer-publisher.d.ts +152 -90
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +1257 -421
- package/dest/publisher/write_json.d.ts +11 -0
- package/dest/publisher/write_json.d.ts.map +1 -0
- package/dest/publisher/write_json.js +57 -0
- package/dest/sequencer/automine/automine_factory.d.ts +56 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +85 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +189 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +690 -0
- package/dest/sequencer/automine/index.d.ts +3 -0
- package/dest/sequencer/automine/index.d.ts.map +1 -0
- package/dest/sequencer/automine/index.js +2 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +158 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1801 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- package/dest/sequencer/checkpoint_voter.d.ts +34 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +106 -0
- package/dest/sequencer/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/events.d.ts +103 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +4 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +3 -1
- package/dest/sequencer/metrics.d.ts +42 -7
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +241 -72
- package/dest/sequencer/requests_tracker.d.ts +22 -0
- package/dest/sequencer/requests_tracker.d.ts.map +1 -0
- package/dest/sequencer/requests_tracker.js +33 -0
- package/dest/sequencer/sequencer.d.ts +251 -138
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +1190 -704
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +14 -8
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +7 -4
- package/dest/test/index.d.ts +8 -9
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +95 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +231 -0
- package/dest/test/utils.d.ts +67 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +122 -0
- package/package.json +32 -29
- package/src/client/sequencer-client.ts +118 -66
- package/src/config.ts +173 -64
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +182 -0
- package/src/global_variable_builder/fee_provider.ts +97 -0
- package/src/global_variable_builder/global_builder.ts +45 -110
- package/src/global_variable_builder/index.ts +3 -1
- package/src/index.ts +1 -7
- package/src/publisher/config.ts +182 -46
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_to_l2_messaging.ts +85 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +164 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +47 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +43 -13
- package/src/publisher/sequencer-publisher-metrics.ts +19 -71
- package/src/publisher/sequencer-publisher.ts +1042 -542
- package/src/publisher/write_json.ts +78 -0
- package/src/sequencer/README.md +243 -0
- package/src/sequencer/automine/README.md +60 -0
- package/src/sequencer/automine/automine_factory.ts +152 -0
- package/src/sequencer/automine/automine_sequencer.ts +796 -0
- package/src/sequencer/automine/index.ts +6 -0
- package/src/sequencer/checkpoint_proposal_job.ts +1652 -0
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +119 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +88 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +302 -83
- package/src/sequencer/requests_tracker.ts +43 -0
- package/src/sequencer/sequencer.ts +1011 -898
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +7 -8
- package/src/test/mock_checkpoint_builder.ts +323 -0
- package/src/test/utils.ts +218 -0
- package/dest/sequencer/block_builder.d.ts +0 -28
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -134
- package/dest/sequencer/timetable.d.ts +0 -50
- package/dest/sequencer/timetable.d.ts.map +0 -1
- package/dest/sequencer/timetable.js +0 -137
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -53
- package/src/sequencer/block_builder.ts +0 -222
- package/src/sequencer/timetable.ts +0 -188
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -133
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Body } from '@aztec/aztec.js/block';
|
|
2
|
+
import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { times } from '@aztec/foundation/collection';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
6
|
+
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
7
|
+
import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
|
|
8
|
+
import { DEFAULT_BLOCK_DURATION_MS } from '@aztec/stdlib/config';
|
|
9
|
+
import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
|
|
10
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
11
|
+
import { TEST_COORDINATION_SIGNATURE_CONTEXT, makeAppendOnlyTreeSnapshot, mockTxForRollup } from '@aztec/stdlib/testing';
|
|
12
|
+
import { DEFAULT_CHECKPOINT_PROPOSAL_INIT_TIME, DEFAULT_CHECKPOINT_PROPOSAL_PREPARE_TIME, DEFAULT_MIN_BLOCK_DURATION, DEFAULT_P2P_PROPAGATION_TIME, ProposerTimetable } from '@aztec/stdlib/timetable';
|
|
13
|
+
import { BlockHeader, makeProcessedTxFromPrivateOnlyTx } from '@aztec/stdlib/tx';
|
|
14
|
+
// Re-export mock classes from their dedicated file
|
|
15
|
+
export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint_builder.js';
|
|
16
|
+
/**
|
|
17
|
+
* Builds a {@link ProposerTimetable} for tests from a millisecond block duration and optional budgets,
|
|
18
|
+
* filling unset budgets with the shared `DEFAULT_*` values the sequencer config layer applies. Mirrors how
|
|
19
|
+
* the sequencer constructs its timetable so tests exercise the same budget resolution.
|
|
20
|
+
*/ export function makeProposerTimetable(opts) {
|
|
21
|
+
return new ProposerTimetable({
|
|
22
|
+
l1Constants: opts.l1Constants,
|
|
23
|
+
blockDuration: (opts.blockDurationMs ?? DEFAULT_BLOCK_DURATION_MS) / 1000,
|
|
24
|
+
minBlockDuration: opts.minBlockDuration ?? DEFAULT_MIN_BLOCK_DURATION,
|
|
25
|
+
p2pPropagationTime: opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME,
|
|
26
|
+
checkpointProposalPrepareTime: opts.checkpointProposalPrepareTime ?? DEFAULT_CHECKPOINT_PROPOSAL_PREPARE_TIME,
|
|
27
|
+
checkpointProposalInitTime: DEFAULT_CHECKPOINT_PROPOSAL_INIT_TIME
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a mock transaction with a specific seed for deterministic testing
|
|
32
|
+
*/ export async function makeTx(seed, chainId) {
|
|
33
|
+
const tx = await mockTxForRollup(seed);
|
|
34
|
+
if (chainId) {
|
|
35
|
+
tx.data.constants.txContext.chainId = chainId;
|
|
36
|
+
}
|
|
37
|
+
return tx;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an L2Block from transactions and global variables
|
|
41
|
+
*/ export async function makeBlock(txs, globalVariables) {
|
|
42
|
+
const processedTxs = await Promise.all(txs.map((tx)=>makeProcessedTxFromPrivateOnlyTx(tx, Fr.ZERO, new PublicDataWrite(Fr.random(), Fr.random()), globalVariables)));
|
|
43
|
+
const body = new Body(processedTxs.map((tx)=>tx.txEffect));
|
|
44
|
+
const header = BlockHeader.empty({
|
|
45
|
+
globalVariables
|
|
46
|
+
});
|
|
47
|
+
const archive = makeAppendOnlyTreeSnapshot(globalVariables.blockNumber + 1);
|
|
48
|
+
return new L2Block(archive, header, body, CheckpointNumber.fromBlockNumber(globalVariables.blockNumber), IndexWithinCheckpoint(0));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Mocks the P2P client to return specific pending transactions
|
|
52
|
+
*/ export function mockPendingTxs(p2p, txs) {
|
|
53
|
+
p2p.getPendingTxCount.mockResolvedValue(txs.length);
|
|
54
|
+
p2p.hasEligiblePendingTxs.mockImplementation((minCount)=>Promise.resolve(txs.length >= minCount));
|
|
55
|
+
p2p.iteratePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
|
|
56
|
+
p2p.iterateEligiblePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates an async iterator for transactions
|
|
60
|
+
*/ export async function* mockTxIterator(txs) {
|
|
61
|
+
for (const tx of (await txs)){
|
|
62
|
+
yield tx;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates mock committee attestations from a signer
|
|
67
|
+
*/ export function createMockSignatures(signer) {
|
|
68
|
+
const mockedSig = Signature.random();
|
|
69
|
+
return [
|
|
70
|
+
new CommitteeAttestation(signer.address, mockedSig)
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates a CheckpointHeader from an L2Block for testing purposes.
|
|
75
|
+
* Uses mock values for blockHeadersHash, blobsHash and inHash since L2Block doesn't have these fields.
|
|
76
|
+
*/ function createCheckpointHeaderFromBlock(block) {
|
|
77
|
+
const gv = block.header.globalVariables;
|
|
78
|
+
return new CheckpointHeader(block.header.lastArchive.root, Fr.random(), Fr.random(), Fr.random(), Fr.random(), gv.slotNumber, gv.timestamp, gv.coinbase, gv.feeRecipient, gv.gasFees, block.header.totalManaUsed, block.header.totalFees);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a block proposal from a block and signature
|
|
82
|
+
*/ export function createBlockProposal(block, signature) {
|
|
83
|
+
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
84
|
+
return new BlockProposal(block.header, block.indexWithinCheckpoint, Fr.ZERO, block.archive.root, txHashes, signature, TEST_COORDINATION_SIGNATURE_CONTEXT);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates a checkpoint proposal from a block and signature
|
|
88
|
+
*/ export function createCheckpointProposal(block, checkpointSignature, blockSignature, feeAssetPriceModifier = 0n) {
|
|
89
|
+
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
90
|
+
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
91
|
+
return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, TEST_COORDINATION_SIGNATURE_CONTEXT, {
|
|
92
|
+
blockHeader: block.header,
|
|
93
|
+
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
94
|
+
txHashes,
|
|
95
|
+
signature: blockSignature ?? checkpointSignature
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Creates a checkpoint attestation from a block and signature.
|
|
100
|
+
* Note: We manually set the sender since we use random signatures in tests.
|
|
101
|
+
* In production, the sender is recovered from the signature.
|
|
102
|
+
*/ export function createCheckpointAttestation(block, signature, sender, feeAssetPriceModifier = 0n) {
|
|
103
|
+
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
104
|
+
const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier, TEST_COORDINATION_SIGNATURE_CONTEXT);
|
|
105
|
+
const attestation = new CheckpointAttestation(payload, signature, signature);
|
|
106
|
+
// Bypass signature recovery for testing since we use random signatures
|
|
107
|
+
attestation.getSender = ()=>sender;
|
|
108
|
+
attestation.getProposer = ()=>sender;
|
|
109
|
+
return attestation;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Creates transactions and a block, and mocks P2P to return them.
|
|
113
|
+
* Helper for tests that need to set up a block with transactions.
|
|
114
|
+
*/ export async function setupTxsAndBlock(p2p, globalVariables, txCount, chainId) {
|
|
115
|
+
const txs = await Promise.all(times(txCount, (i)=>makeTx(i + 1, chainId)));
|
|
116
|
+
const block = await makeBlock(txs, globalVariables);
|
|
117
|
+
mockPendingTxs(p2p, txs);
|
|
118
|
+
return {
|
|
119
|
+
txs,
|
|
120
|
+
block
|
|
121
|
+
};
|
|
122
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.d58ff9d0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
+
"./automine": "./dest/sequencer/automine/index.js",
|
|
7
8
|
"./config": "./dest/config.js",
|
|
8
9
|
"./test": "./dest/test/index.js"
|
|
9
10
|
},
|
|
@@ -26,43 +27,45 @@
|
|
|
26
27
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
30
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
31
|
-
"@aztec/blob-
|
|
32
|
-
"@aztec/blob-
|
|
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/
|
|
39
|
-
"@aztec/
|
|
40
|
-
"@aztec/noir-
|
|
41
|
-
"@aztec/noir-
|
|
42
|
-
"@aztec/noir-
|
|
43
|
-
"@aztec/
|
|
44
|
-
"@aztec/
|
|
45
|
-
"@aztec/
|
|
46
|
-
"@aztec/
|
|
47
|
-
"@aztec/
|
|
48
|
-
"@aztec/
|
|
49
|
-
"@aztec/
|
|
50
|
-
"@aztec/
|
|
51
|
-
"@aztec/validator-
|
|
52
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
30
|
+
"@aztec/aztec.js": "0.0.1-commit.d58ff9d0",
|
|
31
|
+
"@aztec/bb-prover": "0.0.1-commit.d58ff9d0",
|
|
32
|
+
"@aztec/blob-client": "0.0.1-commit.d58ff9d0",
|
|
33
|
+
"@aztec/blob-lib": "0.0.1-commit.d58ff9d0",
|
|
34
|
+
"@aztec/constants": "0.0.1-commit.d58ff9d0",
|
|
35
|
+
"@aztec/epoch-cache": "0.0.1-commit.d58ff9d0",
|
|
36
|
+
"@aztec/ethereum": "0.0.1-commit.d58ff9d0",
|
|
37
|
+
"@aztec/foundation": "0.0.1-commit.d58ff9d0",
|
|
38
|
+
"@aztec/l1-artifacts": "0.0.1-commit.d58ff9d0",
|
|
39
|
+
"@aztec/node-keystore": "0.0.1-commit.d58ff9d0",
|
|
40
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.d58ff9d0",
|
|
41
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.d58ff9d0",
|
|
42
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.d58ff9d0",
|
|
43
|
+
"@aztec/noir-types": "0.0.1-commit.d58ff9d0",
|
|
44
|
+
"@aztec/p2p": "0.0.1-commit.d58ff9d0",
|
|
45
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d58ff9d0",
|
|
46
|
+
"@aztec/prover-client": "0.0.1-commit.d58ff9d0",
|
|
47
|
+
"@aztec/simulator": "0.0.1-commit.d58ff9d0",
|
|
48
|
+
"@aztec/slasher": "0.0.1-commit.d58ff9d0",
|
|
49
|
+
"@aztec/stdlib": "0.0.1-commit.d58ff9d0",
|
|
50
|
+
"@aztec/telemetry-client": "0.0.1-commit.d58ff9d0",
|
|
51
|
+
"@aztec/validator-client": "0.0.1-commit.d58ff9d0",
|
|
52
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.d58ff9d0",
|
|
53
|
+
"@aztec/world-state": "0.0.1-commit.d58ff9d0",
|
|
53
54
|
"lodash.chunk": "^4.2.0",
|
|
54
55
|
"tslib": "^2.4.0",
|
|
55
|
-
"viem": "npm:@aztec/viem@2.38.2"
|
|
56
|
+
"viem": "npm:@aztec/viem@2.38.2",
|
|
57
|
+
"zod": "^4"
|
|
56
58
|
},
|
|
57
59
|
"devDependencies": {
|
|
58
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
59
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
60
|
+
"@aztec/archiver": "0.0.1-commit.d58ff9d0",
|
|
61
|
+
"@aztec/kv-store": "0.0.1-commit.d58ff9d0",
|
|
62
|
+
"@electric-sql/pglite": "^0.3.14",
|
|
60
63
|
"@jest/globals": "^30.0.0",
|
|
61
64
|
"@types/jest": "^30.0.0",
|
|
62
65
|
"@types/lodash.chunk": "^4.2.7",
|
|
63
66
|
"@types/lodash.pick": "^4.4.7",
|
|
64
67
|
"@types/node": "^22.15.17",
|
|
65
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
68
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
66
69
|
"concurrently": "^7.6.0",
|
|
67
70
|
"eslint": "^9.26.0",
|
|
68
71
|
"express": "^4.21.2",
|
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
|
+
import { MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
|
|
2
3
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
getPublicClient,
|
|
8
|
-
isAnvilTestChain,
|
|
9
|
-
} from '@aztec/ethereum';
|
|
10
|
-
import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
4
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
|
+
import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
6
|
+
import { type Delayer, L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
7
|
+
import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
11
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
13
10
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
14
11
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
15
12
|
import type { P2P } from '@aztec/p2p';
|
|
16
13
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
17
|
-
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
18
|
-
import type {
|
|
19
|
-
IFullNodeBlockBuilder,
|
|
20
|
-
ValidatorClientFullConfig,
|
|
21
|
-
WorldStateSynchronizer,
|
|
22
|
-
} from '@aztec/stdlib/interfaces/server';
|
|
23
|
-
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
14
|
+
import type { L2BlockSink, L2BlockSource, ProposedCheckpointSink } from '@aztec/stdlib/block';
|
|
15
|
+
import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
24
16
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
25
17
|
import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
26
|
-
import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
18
|
+
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
27
19
|
|
|
28
|
-
import type
|
|
29
|
-
import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
20
|
+
import { type SequencerClientConfig, getPublisherConfigFromSequencerConfig } from '../config.js';
|
|
21
|
+
import type { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
30
22
|
import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
31
23
|
import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
32
24
|
|
|
@@ -35,11 +27,12 @@ import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
|
35
27
|
*/
|
|
36
28
|
export class SequencerClient {
|
|
37
29
|
constructor(
|
|
38
|
-
protected publisherManager: PublisherManager<
|
|
30
|
+
protected publisherManager: PublisherManager<L1TxUtils>,
|
|
39
31
|
protected sequencer: Sequencer,
|
|
40
|
-
protected
|
|
32
|
+
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
41
33
|
protected validatorClient?: ValidatorClient,
|
|
42
34
|
private l1Metrics?: L1Metrics,
|
|
35
|
+
private delayer_?: Delayer,
|
|
43
36
|
) {}
|
|
44
37
|
|
|
45
38
|
/**
|
|
@@ -57,20 +50,22 @@ export class SequencerClient {
|
|
|
57
50
|
public static async new(
|
|
58
51
|
config: SequencerClientConfig,
|
|
59
52
|
deps: {
|
|
60
|
-
validatorClient: ValidatorClient
|
|
53
|
+
validatorClient: ValidatorClient;
|
|
61
54
|
p2pClient: P2P;
|
|
62
55
|
worldStateSynchronizer: WorldStateSynchronizer;
|
|
63
56
|
slasherClient: SlasherClientInterface | undefined;
|
|
64
|
-
|
|
65
|
-
l2BlockSource: L2BlockSource;
|
|
57
|
+
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
58
|
+
l2BlockSource: L2BlockSource & L2BlockSink & ProposedCheckpointSink;
|
|
66
59
|
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
67
60
|
telemetry: TelemetryClient;
|
|
68
61
|
publisherFactory?: SequencerPublisherFactory;
|
|
69
|
-
|
|
62
|
+
blobClient: BlobClientInterface;
|
|
70
63
|
dateProvider: DateProvider;
|
|
71
64
|
epochCache?: EpochCache;
|
|
72
|
-
l1TxUtils:
|
|
65
|
+
l1TxUtils: L1TxUtils[];
|
|
66
|
+
funderL1TxUtils?: L1TxUtils;
|
|
73
67
|
nodeKeyStore: KeystoreManager;
|
|
68
|
+
globalVariableBuilder: GlobalVariableBuilder;
|
|
74
69
|
},
|
|
75
70
|
) {
|
|
76
71
|
const {
|
|
@@ -78,7 +73,7 @@ export class SequencerClient {
|
|
|
78
73
|
p2pClient,
|
|
79
74
|
worldStateSynchronizer,
|
|
80
75
|
slasherClient,
|
|
81
|
-
|
|
76
|
+
checkpointsBuilder,
|
|
82
77
|
l2BlockSource,
|
|
83
78
|
l1ToL2MessageSource,
|
|
84
79
|
telemetry: telemetryClient,
|
|
@@ -92,21 +87,25 @@ export class SequencerClient {
|
|
|
92
87
|
publicClient,
|
|
93
88
|
l1TxUtils.map(x => x.getSenderAddress()),
|
|
94
89
|
);
|
|
95
|
-
const publisherManager = new PublisherManager(l1TxUtils, config)
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
|
|
91
|
+
bindings: log.getBindings(),
|
|
92
|
+
funder: deps.funderL1TxUtils,
|
|
93
|
+
});
|
|
94
|
+
const rollupContract = new RollupContract(publicClient, config.rollupAddress.toString());
|
|
95
|
+
const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
|
|
98
96
|
rollupContract.getL1GenesisTime(),
|
|
99
97
|
rollupContract.getSlotDuration(),
|
|
98
|
+
rollupContract.getManaLimit().then(Number),
|
|
100
99
|
] as const);
|
|
101
100
|
|
|
102
101
|
const governanceProposerContract = new GovernanceProposerContract(
|
|
103
102
|
publicClient,
|
|
104
|
-
config.
|
|
103
|
+
config.governanceProposerAddress.toString(),
|
|
105
104
|
);
|
|
106
105
|
const epochCache =
|
|
107
106
|
deps.epochCache ??
|
|
108
107
|
(await EpochCache.create(
|
|
109
|
-
config.
|
|
108
|
+
config.rollupAddress,
|
|
110
109
|
{
|
|
111
110
|
l1RpcUrls: rpcUrls,
|
|
112
111
|
l1ChainId: chainId,
|
|
@@ -116,51 +115,32 @@ export class SequencerClient {
|
|
|
116
115
|
{ dateProvider: deps.dateProvider },
|
|
117
116
|
));
|
|
118
117
|
|
|
119
|
-
const slashFactoryContract = new SlashFactoryContract(
|
|
120
|
-
publicClient,
|
|
121
|
-
config.l1Contracts.slashFactoryAddress?.toString() ?? EthAddress.ZERO.toString(),
|
|
122
|
-
);
|
|
123
|
-
|
|
124
118
|
const publisherFactory =
|
|
125
119
|
deps.publisherFactory ??
|
|
126
120
|
new SequencerPublisherFactory(config, {
|
|
127
121
|
telemetry: telemetryClient,
|
|
128
|
-
|
|
122
|
+
blobClient: deps.blobClient,
|
|
129
123
|
epochCache,
|
|
130
124
|
governanceProposerContract,
|
|
131
|
-
slashFactoryContract,
|
|
132
125
|
rollupContract,
|
|
133
126
|
dateProvider: deps.dateProvider,
|
|
134
127
|
publisherManager,
|
|
135
128
|
nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
|
|
136
129
|
logger: log,
|
|
137
130
|
});
|
|
138
|
-
const globalsBuilder = new GlobalVariableBuilder(config);
|
|
139
131
|
|
|
140
132
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
141
133
|
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
log.warn(
|
|
146
|
-
`Provided maxL2BlockGas of ${sequencerManaLimit} is greater than the maximum allowed by the L1 (${rollupManaLimit}), setting limit to ${rollupManaLimit}`,
|
|
147
|
-
);
|
|
148
|
-
sequencerManaLimit = rollupManaLimit;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
|
|
152
|
-
// Otherwise, assume we must have broadcasted the tx before the slot started (we use a default
|
|
153
|
-
// maxL1TxInclusionTimeIntoSlot of zero) to get the tx into that L1 slot.
|
|
154
|
-
// In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
|
|
155
|
-
// make it with a propagation time into slot equal to 4s. However, we prefer being conservative.
|
|
156
|
-
// See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
|
|
157
|
-
const maxInclusionBasedOnChain = isAnvilTestChain(config.l1ChainId) ? ethereumSlotDuration - 1 : 0;
|
|
158
|
-
const maxL1TxInclusionTimeIntoSlot = config.maxL1TxInclusionTimeIntoSlot ?? maxInclusionBasedOnChain;
|
|
134
|
+
const globalsBuilder = deps.globalVariableBuilder;
|
|
135
|
+
|
|
136
|
+
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
|
|
159
137
|
|
|
160
138
|
const l1Constants = {
|
|
161
139
|
l1GenesisTime,
|
|
162
140
|
slotDuration: Number(slotDuration),
|
|
163
141
|
ethereumSlotDuration,
|
|
142
|
+
rollupManaLimit,
|
|
143
|
+
epochDuration: config.aztecEpochDuration,
|
|
164
144
|
};
|
|
165
145
|
|
|
166
146
|
const sequencer = new Sequencer(
|
|
@@ -172,19 +152,22 @@ export class SequencerClient {
|
|
|
172
152
|
slasherClient,
|
|
173
153
|
l2BlockSource,
|
|
174
154
|
l1ToL2MessageSource,
|
|
175
|
-
|
|
155
|
+
checkpointsBuilder,
|
|
176
156
|
l1Constants,
|
|
177
157
|
deps.dateProvider,
|
|
178
158
|
epochCache,
|
|
179
159
|
rollupContract,
|
|
180
|
-
{ ...config,
|
|
160
|
+
{ ...config, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
|
|
181
161
|
telemetryClient,
|
|
182
162
|
log,
|
|
183
163
|
);
|
|
184
164
|
|
|
185
|
-
|
|
165
|
+
sequencer.init();
|
|
186
166
|
|
|
187
|
-
|
|
167
|
+
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
168
|
+
const delayer = l1TxUtils[0]?.delayer;
|
|
169
|
+
|
|
170
|
+
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
|
|
188
171
|
}
|
|
189
172
|
|
|
190
173
|
/**
|
|
@@ -193,32 +176,63 @@ export class SequencerClient {
|
|
|
193
176
|
*/
|
|
194
177
|
public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
|
|
195
178
|
this.sequencer.updateConfig(config);
|
|
196
|
-
this.
|
|
179
|
+
this.checkpointsBuilder.updateConfig(config);
|
|
197
180
|
this.validatorClient?.updateConfig(config);
|
|
198
181
|
}
|
|
199
182
|
|
|
200
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* Starts (or resumes) the sequencer, validator, publishers, and metrics. Each underlying start is
|
|
185
|
+
* idempotent, so this is safe to call after a previous {@link pause} to resume building and publishing.
|
|
186
|
+
* The publisher manager is started before the sequencer's poll loop so publishing is ready before the
|
|
187
|
+
* sequencer first tries to publish to L1.
|
|
188
|
+
*/
|
|
201
189
|
public async start() {
|
|
202
190
|
await this.validatorClient?.start();
|
|
191
|
+
await this.publisherManager.start();
|
|
203
192
|
this.sequencer.start();
|
|
204
193
|
this.l1Metrics?.start();
|
|
205
|
-
await this.publisherManager.loadState();
|
|
206
194
|
}
|
|
207
195
|
|
|
208
196
|
/**
|
|
209
|
-
* Stops the sequencer
|
|
197
|
+
* Stops the sequencer, validator, publishers, and metrics for good, draining in-flight work. This is the
|
|
198
|
+
* final teardown path: stopping the validator client closes its slashing-protection database. For a
|
|
199
|
+
* restartable pause (e.g. around a test clock warp) use {@link pause} instead.
|
|
210
200
|
*/
|
|
211
201
|
public async stop() {
|
|
212
202
|
await this.sequencer.stop();
|
|
213
203
|
await this.validatorClient?.stop();
|
|
214
|
-
this.publisherManager.
|
|
204
|
+
await this.publisherManager.stop();
|
|
215
205
|
this.l1Metrics?.stop();
|
|
216
206
|
}
|
|
217
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Gracefully pauses block production, waiting for in-flight work to finish rather than interrupting it,
|
|
210
|
+
* while leaving the validator, publishers, and metrics running so the sequencer can be resumed with
|
|
211
|
+
* {@link start}. Used by tests that pause sequencers around an L1 clock warp.
|
|
212
|
+
*/
|
|
213
|
+
public async pause() {
|
|
214
|
+
await this.sequencer.pause();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Triggers an immediate run of the sequencer, bypassing the polling interval. */
|
|
218
|
+
public trigger() {
|
|
219
|
+
return this.sequencer.trigger();
|
|
220
|
+
}
|
|
221
|
+
|
|
218
222
|
public getSequencer(): Sequencer {
|
|
219
223
|
return this.sequencer;
|
|
220
224
|
}
|
|
221
225
|
|
|
226
|
+
/** Updates the publisher factory's node keystore adapter after a keystore reload. */
|
|
227
|
+
public updatePublisherNodeKeyStore(adapter: NodeKeystoreAdapter): void {
|
|
228
|
+
this.sequencer.updatePublisherNodeKeyStore(adapter);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Returns the shared tx delayer for sequencer L1 txs, if enabled. Test-only. */
|
|
232
|
+
getDelayer(): Delayer | undefined {
|
|
233
|
+
return this.delayer_;
|
|
234
|
+
}
|
|
235
|
+
|
|
222
236
|
get validatorAddresses(): EthAddress[] | undefined {
|
|
223
237
|
return this.sequencer.getValidatorAddresses();
|
|
224
238
|
}
|
|
@@ -227,3 +241,41 @@ export class SequencerClient {
|
|
|
227
241
|
return this.sequencer.maxL2BlockGas;
|
|
228
242
|
}
|
|
229
243
|
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Caps operator-provided per-block limits at checkpoint-level limits.
|
|
247
|
+
* Returns undefined for any limit the operator didn't set — the checkpoint builder handles redistribution.
|
|
248
|
+
*/
|
|
249
|
+
function capPerBlockLimits(
|
|
250
|
+
config: SequencerClientConfig,
|
|
251
|
+
rollupManaLimit: number,
|
|
252
|
+
log: ReturnType<typeof createLogger>,
|
|
253
|
+
): { maxL2BlockGas: number | undefined; maxDABlockGas: number | undefined; maxTxsPerBlock: number | undefined } {
|
|
254
|
+
let maxL2BlockGas = config.maxL2BlockGas;
|
|
255
|
+
if (maxL2BlockGas !== undefined && maxL2BlockGas > rollupManaLimit) {
|
|
256
|
+
log.warn(`Provided MAX_L2_BLOCK_GAS ${maxL2BlockGas} exceeds rollup mana limit ${rollupManaLimit} (capping)`);
|
|
257
|
+
maxL2BlockGas = rollupManaLimit;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
let maxDABlockGas = config.maxDABlockGas;
|
|
261
|
+
if (maxDABlockGas !== undefined && maxDABlockGas > MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT) {
|
|
262
|
+
log.warn(
|
|
263
|
+
`Provided MAX_DA_BLOCK_GAS ${maxDABlockGas} exceeds DA checkpoint limit ${MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT} (capping)`,
|
|
264
|
+
);
|
|
265
|
+
maxDABlockGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
let maxTxsPerBlock = config.maxTxsPerBlock;
|
|
269
|
+
if (
|
|
270
|
+
maxTxsPerBlock !== undefined &&
|
|
271
|
+
config.maxTxsPerCheckpoint !== undefined &&
|
|
272
|
+
maxTxsPerBlock > config.maxTxsPerCheckpoint
|
|
273
|
+
) {
|
|
274
|
+
log.warn(
|
|
275
|
+
`Provided MAX_TX_PER_BLOCK ${maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
|
|
276
|
+
);
|
|
277
|
+
maxTxsPerBlock = config.maxTxsPerCheckpoint;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock };
|
|
281
|
+
}
|