@aztec/sequencer-client 0.0.1-commit.179ed20 → 0.0.1-commit.181e2d196
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 +12 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +15 -4
- package/dest/config.d.ts +3 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +29 -19
- package/dest/global_variable_builder/global_builder.d.ts +2 -4
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +35 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +106 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- 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 +59 -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 +1 -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 +34 -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 +2 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -2
- package/dest/publisher/sequencer-publisher.d.ts +26 -7
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +299 -30
- package/dest/sequencer/checkpoint_proposal_job.d.ts +7 -1
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +99 -53
- package/dest/sequencer/metrics.d.ts +17 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +86 -15
- package/dest/sequencer/sequencer.d.ts +20 -8
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +30 -27
- package/dest/sequencer/timetable.d.ts +1 -4
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +2 -5
- package/dest/test/index.d.ts +3 -5
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +5 -3
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +6 -4
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -4
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +25 -7
- package/src/config.ts +40 -27
- package/src/global_variable_builder/global_builder.ts +1 -1
- package/src/publisher/config.ts +121 -43
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -6
- package/src/publisher/sequencer-publisher.ts +300 -43
- package/src/sequencer/checkpoint_proposal_job.ts +135 -48
- package/src/sequencer/metrics.ts +92 -18
- package/src/sequencer/sequencer.ts +40 -32
- package/src/sequencer/timetable.ts +7 -6
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +12 -1
- package/src/test/utils.ts +5 -2
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import type { FileStore } from '@aztec/stdlib/file-store';
|
|
3
|
+
|
|
4
|
+
import type { FailedL1Tx, FailedL1TxUri, L1TxFailedStore } from './failed_tx_store.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* L1TxFailedStore implementation using the FileStore abstraction.
|
|
8
|
+
* Supports any backend that FileStore supports (GCS, S3, R2, local filesystem).
|
|
9
|
+
*/
|
|
10
|
+
export class FileStoreL1TxFailedStore implements L1TxFailedStore {
|
|
11
|
+
private readonly log: Logger;
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
private readonly fileStore: FileStore,
|
|
15
|
+
logger?: Logger,
|
|
16
|
+
) {
|
|
17
|
+
this.log = logger ?? createLogger('sequencer:l1-tx-failed-store');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async saveFailedTx(tx: FailedL1Tx): Promise<FailedL1TxUri> {
|
|
21
|
+
const prefix = tx.receipt ? 'tx' : 'data';
|
|
22
|
+
const path = `${tx.failureType}/${prefix}-${tx.id}.json`;
|
|
23
|
+
const json = JSON.stringify(tx, null, 2);
|
|
24
|
+
|
|
25
|
+
const uri = await this.fileStore.save(path, Buffer.from(json), {
|
|
26
|
+
metadata: {
|
|
27
|
+
'content-type': 'application/json',
|
|
28
|
+
actions: tx.context.actions.join(','),
|
|
29
|
+
'failure-type': tx.failureType,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
this.log.info(`Saved failed L1 tx to ${uri}`, {
|
|
34
|
+
id: tx.id,
|
|
35
|
+
failureType: tx.failureType,
|
|
36
|
+
actions: tx.context.actions.join(','),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return uri as FailedL1TxUri;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public async getFailedTx(uri: FailedL1TxUri): Promise<FailedL1Tx> {
|
|
43
|
+
const data = await this.fileStore.read(uri);
|
|
44
|
+
return JSON.parse(data.toString()) as FailedL1Tx;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -3,7 +3,7 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
|
3
3
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
4
4
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
5
5
|
import type { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
6
|
-
import type {
|
|
6
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
7
7
|
import type { PublisherFilter, PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
8
8
|
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
9
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
@@ -26,13 +26,15 @@ export class SequencerPublisherFactory {
|
|
|
26
26
|
/** Stores the last slot in which every action was carried out by a publisher */
|
|
27
27
|
private lastActions: Partial<Record<Action, SlotNumber>> = {};
|
|
28
28
|
|
|
29
|
+
private nodeKeyStore: NodeKeystoreAdapter;
|
|
30
|
+
|
|
29
31
|
private logger: Logger;
|
|
30
32
|
|
|
31
33
|
constructor(
|
|
32
34
|
private sequencerConfig: SequencerClientConfig,
|
|
33
35
|
private deps: {
|
|
34
36
|
telemetry: TelemetryClient;
|
|
35
|
-
publisherManager: PublisherManager<
|
|
37
|
+
publisherManager: PublisherManager<L1TxUtils>;
|
|
36
38
|
blobClient: BlobClientInterface;
|
|
37
39
|
dateProvider: DateProvider;
|
|
38
40
|
epochCache: EpochCache;
|
|
@@ -45,7 +47,17 @@ export class SequencerPublisherFactory {
|
|
|
45
47
|
) {
|
|
46
48
|
this.publisherMetrics = new SequencerPublisherMetrics(deps.telemetry, 'SequencerPublisher');
|
|
47
49
|
this.logger = deps.logger ?? createLogger('sequencer');
|
|
50
|
+
this.nodeKeyStore = this.deps.nodeKeyStore;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Updates the node keystore adapter used for publisher lookups.
|
|
55
|
+
* Called when the keystore is reloaded at runtime to reflect new validator-publisher mappings.
|
|
56
|
+
*/
|
|
57
|
+
public updateNodeKeyStore(adapter: NodeKeystoreAdapter): void {
|
|
58
|
+
this.nodeKeyStore = adapter;
|
|
48
59
|
}
|
|
60
|
+
|
|
49
61
|
/**
|
|
50
62
|
* Creates a new SequencerPublisher instance.
|
|
51
63
|
* @param _validatorAddress - The address of the validator that will be using the publisher.
|
|
@@ -54,23 +66,38 @@ export class SequencerPublisherFactory {
|
|
|
54
66
|
public async create(validatorAddress?: EthAddress): Promise<AttestorPublisherPair> {
|
|
55
67
|
// If we have been given an attestor address we must only allow publishers permitted for that attestor
|
|
56
68
|
|
|
57
|
-
const allowedPublishers = !validatorAddress ? [] : this.
|
|
58
|
-
const filter: PublisherFilter<
|
|
69
|
+
const allowedPublishers = !validatorAddress ? [] : this.nodeKeyStore.getPublisherAddresses(validatorAddress);
|
|
70
|
+
const filter: PublisherFilter<L1TxUtils> = !validatorAddress
|
|
59
71
|
? () => true
|
|
60
|
-
: (utils:
|
|
72
|
+
: (utils: L1TxUtils) => {
|
|
61
73
|
const publisherAddress = utils.getSenderAddress();
|
|
62
74
|
return allowedPublishers.some(allowedPublisher => allowedPublisher.equals(publisherAddress));
|
|
63
75
|
};
|
|
64
76
|
|
|
65
77
|
const l1Publisher = await this.deps.publisherManager.getAvailablePublisher(filter);
|
|
66
78
|
const attestorAddress =
|
|
67
|
-
validatorAddress ?? this.
|
|
79
|
+
validatorAddress ?? this.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
|
|
68
80
|
|
|
69
81
|
const rollup = this.deps.rollupContract;
|
|
70
82
|
const slashingProposerContract = await rollup.getSlashingProposer();
|
|
71
83
|
|
|
84
|
+
const getNextPublisher = async (excludeAddresses: EthAddress[]): Promise<L1TxUtils | undefined> => {
|
|
85
|
+
const exclusionFilter: PublisherFilter<L1TxUtils> = (utils: L1TxUtils) => {
|
|
86
|
+
if (excludeAddresses.some(addr => addr.equals(utils.getSenderAddress()))) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return filter(utils);
|
|
90
|
+
};
|
|
91
|
+
try {
|
|
92
|
+
return await this.deps.publisherManager.getAvailablePublisher(exclusionFilter);
|
|
93
|
+
} catch {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
72
98
|
const publisher = new SequencerPublisher(this.sequencerConfig, {
|
|
73
99
|
l1TxUtils: l1Publisher,
|
|
100
|
+
getNextPublisher,
|
|
74
101
|
telemetry: this.deps.telemetry,
|
|
75
102
|
blobClient: this.deps.blobClient,
|
|
76
103
|
rollupContract: this.deps.rollupContract,
|
|
@@ -89,4 +116,9 @@ export class SequencerPublisherFactory {
|
|
|
89
116
|
publisher,
|
|
90
117
|
};
|
|
91
118
|
}
|
|
119
|
+
|
|
120
|
+
/** Interrupts all publishers managed by this factory. Used during sequencer shutdown. */
|
|
121
|
+
public interruptAll(): void {
|
|
122
|
+
this.deps.publisherManager.interrupt();
|
|
123
|
+
}
|
|
92
124
|
}
|