@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
|
@@ -1,133 +1,68 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type L1ContractsConfig,
|
|
3
|
-
type L1ReaderConfig,
|
|
4
2
|
RollupContract,
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
} from '@aztec/ethereum';
|
|
8
|
-
import {
|
|
3
|
+
type SimulationOverridesPlan,
|
|
4
|
+
buildSimulationOverridesStateOverride,
|
|
5
|
+
} from '@aztec/ethereum/contracts';
|
|
6
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
7
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
8
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
9
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
11
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
12
10
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
+
import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
13
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
import type {
|
|
14
|
+
CheckpointGlobalVariables,
|
|
15
|
+
GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
16
|
+
} from '@aztec/stdlib/tx';
|
|
17
|
+
|
|
18
|
+
/** Configuration for the GlobalVariableBuilder (excludes L1 client config). */
|
|
19
|
+
export type GlobalVariableBuilderConfig = {
|
|
20
|
+
rollupAddress: EthAddress;
|
|
21
|
+
ethereumSlotDuration: number;
|
|
22
|
+
rollupVersion: bigint;
|
|
23
|
+
} & Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'>;
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* Simple global variables builder.
|
|
21
27
|
*/
|
|
22
28
|
export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
23
|
-
private log = createLogger('sequencer:global_variable_builder');
|
|
24
|
-
private currentBaseFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
|
|
25
|
-
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
26
|
-
|
|
27
29
|
private readonly rollupContract: RollupContract;
|
|
28
|
-
private readonly
|
|
29
|
-
private readonly
|
|
30
|
-
|
|
31
|
-
private chainId?: Fr;
|
|
32
|
-
private version?: Fr;
|
|
33
|
-
|
|
34
|
-
constructor(config: L1ReaderConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>) {
|
|
35
|
-
const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
|
|
36
|
-
|
|
37
|
-
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
38
|
-
|
|
39
|
-
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
40
|
-
|
|
41
|
-
this.publicClient = createPublicClient({
|
|
42
|
-
chain: chain.chainInfo,
|
|
43
|
-
transport: fallback(chain.rpcUrls.map(url => http(url))),
|
|
44
|
-
pollingInterval: config.viemPollingIntervalMS,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
|
|
52
|
-
* @returns Base fees for the next block
|
|
53
|
-
*/
|
|
54
|
-
private async computeCurrentBaseFees(): Promise<GasFees> {
|
|
55
|
-
// Since this might be called in the middle of a slot where a block might have been published,
|
|
56
|
-
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
57
|
-
// The timestamp of that last block will act as a lower bound for the next block.
|
|
30
|
+
private readonly aztecSlotDuration: number;
|
|
31
|
+
private readonly l1GenesisTime: bigint;
|
|
58
32
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
SlotNumber.fromBigInt(lastBlock.slotNumber + 1n),
|
|
62
|
-
);
|
|
63
|
-
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
64
|
-
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
33
|
+
private chainId: Fr;
|
|
34
|
+
private version: Fr;
|
|
65
35
|
|
|
66
|
-
|
|
67
|
-
|
|
36
|
+
constructor(
|
|
37
|
+
private readonly publicClient: ViemPublicClient,
|
|
38
|
+
config: GlobalVariableBuilderConfig,
|
|
39
|
+
) {
|
|
40
|
+
this.version = new Fr(config.rollupVersion);
|
|
41
|
+
this.chainId = new Fr(this.publicClient.chain!.id);
|
|
68
42
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const blockNumber = await this.publicClient.getBlockNumber();
|
|
72
|
-
|
|
73
|
-
// If the L1 block number has changed then chain a new promise to get the current base fees
|
|
74
|
-
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
75
|
-
this.currentL1BlockNumber = blockNumber;
|
|
76
|
-
this.currentBaseFees = this.currentBaseFees.then(() => this.computeCurrentBaseFees());
|
|
77
|
-
}
|
|
78
|
-
return this.currentBaseFees;
|
|
79
|
-
}
|
|
43
|
+
this.aztecSlotDuration = config.slotDuration;
|
|
44
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
80
45
|
|
|
81
|
-
|
|
82
|
-
if (!this.chainId) {
|
|
83
|
-
this.chainId = new Fr(this.publicClient.chain.id);
|
|
84
|
-
}
|
|
85
|
-
if (!this.version) {
|
|
86
|
-
this.version = new Fr(await this.rollupContract.getVersion());
|
|
87
|
-
}
|
|
88
|
-
return { chainId: this.chainId, version: this.version };
|
|
46
|
+
this.rollupContract = new RollupContract(this.publicClient, config.rollupAddress);
|
|
89
47
|
}
|
|
90
48
|
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
* @param blockNumber - The block number to build global variables for.
|
|
94
|
-
* @param coinbase - The address to receive block reward.
|
|
95
|
-
* @param feeRecipient - The address to receive fees.
|
|
96
|
-
* @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
|
|
97
|
-
* @returns The global variables for the given block number.
|
|
98
|
-
*/
|
|
99
|
-
public async buildGlobalVariables(
|
|
100
|
-
blockNumber: BlockNumber,
|
|
49
|
+
/** Builds global variables that are constant throughout a checkpoint. */
|
|
50
|
+
public async buildCheckpointGlobalVariables(
|
|
101
51
|
coinbase: EthAddress,
|
|
102
52
|
feeRecipient: AztecAddress,
|
|
103
|
-
slotNumber
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
slot = slotNumber;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const timestamp = await this.rollupContract.getTimestampForSlot(slot);
|
|
116
|
-
|
|
117
|
-
// We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
|
|
118
|
-
const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
|
|
53
|
+
slotNumber: SlotNumber,
|
|
54
|
+
simulationOverridesPlan?: SimulationOverridesPlan,
|
|
55
|
+
): Promise<CheckpointGlobalVariables> {
|
|
56
|
+
const { chainId, version } = this;
|
|
57
|
+
|
|
58
|
+
const timestamp = getTimestampForSlot(slotNumber, {
|
|
59
|
+
slotDuration: this.aztecSlotDuration,
|
|
60
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
61
|
+
});
|
|
119
62
|
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
version,
|
|
123
|
-
blockNumber,
|
|
124
|
-
slot,
|
|
125
|
-
timestamp,
|
|
126
|
-
coinbase,
|
|
127
|
-
feeRecipient,
|
|
128
|
-
gasFees,
|
|
129
|
-
);
|
|
63
|
+
const stateOverride = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
|
|
64
|
+
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true, stateOverride));
|
|
130
65
|
|
|
131
|
-
return
|
|
66
|
+
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
|
132
67
|
}
|
|
133
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
export * from './client/index.js';
|
|
2
2
|
export * from './config.js';
|
|
3
3
|
export * from './publisher/index.js';
|
|
4
|
-
export {
|
|
5
|
-
FullNodeBlockBuilder as BlockBuilder,
|
|
6
|
-
Sequencer,
|
|
7
|
-
SequencerState,
|
|
8
|
-
type SequencerEvents,
|
|
9
|
-
} from './sequencer/index.js';
|
|
10
|
-
export * from './tx_validator/tx_validator_factory.js';
|
|
4
|
+
export { Sequencer, SequencerState, type SequencerEvents } from './sequencer/index.js';
|
|
11
5
|
|
|
12
6
|
// Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
|
|
13
7
|
// ISSUE(#9832)
|
package/src/publisher/config.ts
CHANGED
|
@@ -1,73 +1,171 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type L1TxUtilsConfig,
|
|
5
|
-
l1ReaderConfigMappings,
|
|
6
|
-
l1TxUtilsConfigMappings,
|
|
7
|
-
} from '@aztec/ethereum';
|
|
1
|
+
import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
3
|
+
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils/config';
|
|
8
4
|
import {
|
|
9
5
|
type ConfigMappingsType,
|
|
10
6
|
SecretValue,
|
|
11
7
|
booleanConfigHelper,
|
|
12
|
-
|
|
8
|
+
numberConfigHelper,
|
|
13
9
|
} from '@aztec/foundation/config';
|
|
14
10
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
12
|
+
import { parseEther } from 'viem';
|
|
13
|
+
|
|
14
|
+
/** Configuration of the transaction publisher. */
|
|
19
15
|
export type TxSenderConfig = L1ReaderConfig & {
|
|
20
|
-
/**
|
|
21
|
-
* The private key to be used by the publisher.
|
|
22
|
-
*/
|
|
16
|
+
/** The private key to be used by the publisher. */
|
|
23
17
|
publisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
24
18
|
|
|
25
|
-
/**
|
|
26
|
-
* Publisher addresses to be used with a remote signer
|
|
27
|
-
*/
|
|
19
|
+
/** Publisher addresses to be used with a remote signer */
|
|
28
20
|
publisherAddresses?: EthAddress[];
|
|
29
21
|
};
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
export type ProverTxSenderConfig = L1ReaderConfig & {
|
|
24
|
+
proverPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
25
|
+
proverPublisherAddresses?: EthAddress[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type SequencerTxSenderConfig = L1ReaderConfig & {
|
|
29
|
+
sequencerPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
30
|
+
sequencerPublisherAddresses?: EthAddress[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function getTxSenderConfigFromProverConfig(config: ProverTxSenderConfig): TxSenderConfig {
|
|
34
|
+
return {
|
|
35
|
+
...config,
|
|
36
|
+
publisherPrivateKeys: config.proverPublisherPrivateKeys,
|
|
37
|
+
publisherAddresses: config.proverPublisherAddresses,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getTxSenderConfigFromSequencerConfig(config: SequencerTxSenderConfig): TxSenderConfig {
|
|
42
|
+
return {
|
|
43
|
+
...config,
|
|
44
|
+
publisherPrivateKeys: config.sequencerPublisherPrivateKeys,
|
|
45
|
+
publisherAddresses: config.sequencerPublisherAddresses,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Configuration of the L1Publisher. */
|
|
34
50
|
export type PublisherConfig = L1TxUtilsConfig &
|
|
35
|
-
|
|
51
|
+
BlobClientConfig & {
|
|
36
52
|
/** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
|
|
37
53
|
publisherAllowInvalidStates?: boolean;
|
|
38
54
|
/** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1 */
|
|
39
55
|
fishermanMode?: boolean;
|
|
56
|
+
/** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
|
|
57
|
+
publisherForwarderAddress?: EthAddress;
|
|
58
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
59
|
+
l1TxFailedStore?: string;
|
|
60
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
61
|
+
publisherFundingThreshold?: bigint;
|
|
62
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
63
|
+
publisherFundingAmount?: bigint;
|
|
40
64
|
};
|
|
41
65
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
66
|
+
/** Shared config mappings for publisher funding, used by both sequencer and prover publisher configs. */
|
|
67
|
+
const publisherFundingConfigMappings = {
|
|
68
|
+
publisherFundingThreshold: {
|
|
69
|
+
env: 'PUBLISHER_FUNDING_THRESHOLD' as const,
|
|
70
|
+
description:
|
|
71
|
+
'Min ETH balance below which a publisher gets funded. Specified in ether (e.g. 0.1). Unset = funding disabled.',
|
|
72
|
+
parseEnv: (val: string) => parseEther(val),
|
|
73
|
+
},
|
|
74
|
+
publisherFundingAmount: {
|
|
75
|
+
env: 'PUBLISHER_FUNDING_AMOUNT' as const,
|
|
76
|
+
description:
|
|
77
|
+
'Amount of ETH to send when funding a publisher. Specified in ether (e.g. 0.5). Unset = funding disabled.',
|
|
78
|
+
parseEnv: (val: string) => parseEther(val),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type ProverPublisherConfig = L1TxUtilsConfig &
|
|
83
|
+
BlobClientConfig & {
|
|
84
|
+
fishermanMode?: boolean;
|
|
85
|
+
proverPublisherAllowInvalidStates?: boolean;
|
|
86
|
+
proverPublisherForwarderAddress?: EthAddress;
|
|
87
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
88
|
+
publisherFundingThreshold?: bigint;
|
|
89
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
90
|
+
publisherFundingAmount?: bigint;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type SequencerPublisherConfig = L1TxUtilsConfig &
|
|
94
|
+
BlobClientConfig & {
|
|
95
|
+
fishermanMode?: boolean;
|
|
96
|
+
sequencerPublisherAllowInvalidStates?: boolean;
|
|
97
|
+
sequencerPublisherForwarderAddress?: EthAddress;
|
|
98
|
+
/** How long to wait for the previous L1 block before sending scheduled publisher txs anyway. */
|
|
99
|
+
sequencerPublisherPreviousL1BlockWaitTimeoutMs: number;
|
|
100
|
+
/** Poll interval while waiting for the previous L1 block before scheduled publisher txs. */
|
|
101
|
+
sequencerPublisherPreviousL1BlockWaitPollIntervalMs: number;
|
|
102
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
103
|
+
l1TxFailedStore?: string;
|
|
104
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
105
|
+
publisherFundingThreshold?: bigint;
|
|
106
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
107
|
+
publisherFundingAmount?: bigint;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
|
|
111
|
+
return {
|
|
112
|
+
...config,
|
|
113
|
+
publisherAllowInvalidStates: config.proverPublisherAllowInvalidStates,
|
|
114
|
+
publisherForwarderAddress: config.proverPublisherForwarderAddress,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig {
|
|
119
|
+
return {
|
|
120
|
+
...config,
|
|
121
|
+
publisherAllowInvalidStates: config.sequencerPublisherAllowInvalidStates,
|
|
122
|
+
publisherForwarderAddress: config.sequencerPublisherForwarderAddress,
|
|
123
|
+
l1TxFailedStore: config.l1TxFailedStore,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const proverTxSenderConfigMappings: ConfigMappingsType<ProverTxSenderConfig> = {
|
|
45
128
|
...l1ReaderConfigMappings,
|
|
46
|
-
|
|
47
|
-
env:
|
|
48
|
-
description: 'The private keys to be used by the publisher.',
|
|
49
|
-
parseEnv: (val: string) =>
|
|
129
|
+
proverPublisherPrivateKeys: {
|
|
130
|
+
env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
|
|
131
|
+
description: 'The private keys to be used by the prover publisher.',
|
|
132
|
+
parseEnv: (val: string) =>
|
|
133
|
+
val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
|
|
50
134
|
defaultValue: [],
|
|
51
|
-
fallback: [
|
|
135
|
+
fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
|
|
52
136
|
},
|
|
53
|
-
|
|
54
|
-
env:
|
|
137
|
+
proverPublisherAddresses: {
|
|
138
|
+
env: `PROVER_PUBLISHER_ADDRESSES`,
|
|
55
139
|
description: 'The addresses of the publishers to use with remote signers',
|
|
56
140
|
parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
|
|
57
141
|
defaultValue: [],
|
|
58
142
|
},
|
|
59
|
-
}
|
|
143
|
+
};
|
|
60
144
|
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
|
|
145
|
+
export const sequencerTxSenderConfigMappings: ConfigMappingsType<SequencerTxSenderConfig> = {
|
|
146
|
+
...l1ReaderConfigMappings,
|
|
147
|
+
sequencerPublisherPrivateKeys: {
|
|
148
|
+
env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
|
|
149
|
+
description: 'The private keys to be used by the sequencer publisher.',
|
|
150
|
+
parseEnv: (val: string) =>
|
|
151
|
+
val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
|
|
152
|
+
defaultValue: [],
|
|
153
|
+
fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
|
|
154
|
+
},
|
|
155
|
+
sequencerPublisherAddresses: {
|
|
156
|
+
env: `SEQ_PUBLISHER_ADDRESSES`,
|
|
157
|
+
description: 'The addresses of the publishers to use with remote signers',
|
|
158
|
+
parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
|
|
159
|
+
defaultValue: [],
|
|
160
|
+
},
|
|
161
|
+
};
|
|
64
162
|
|
|
65
|
-
export const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
163
|
+
export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig> = {
|
|
164
|
+
...l1TxUtilsConfigMappings,
|
|
165
|
+
...blobClientConfigMapping,
|
|
166
|
+
sequencerPublisherAllowInvalidStates: {
|
|
167
|
+
env: `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
69
168
|
description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
|
|
70
|
-
env: scope === `PROVER` ? `PROVER_PUBLISHER_ALLOW_INVALID_STATES` : `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
71
169
|
...booleanConfigHelper(true),
|
|
72
170
|
},
|
|
73
171
|
fishermanMode: {
|
|
@@ -76,10 +174,48 @@ export const getPublisherConfigMappings: (
|
|
|
76
174
|
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
77
175
|
...booleanConfigHelper(false),
|
|
78
176
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
177
|
+
sequencerPublisherForwarderAddress: {
|
|
178
|
+
env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
|
|
179
|
+
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
180
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
181
|
+
},
|
|
182
|
+
sequencerPublisherPreviousL1BlockWaitTimeoutMs: {
|
|
183
|
+
env: `SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_TIMEOUT_MS`,
|
|
184
|
+
description:
|
|
185
|
+
'How long to wait for the previous L1 block before sending scheduled publisher txs anyway, in milliseconds.',
|
|
186
|
+
...numberConfigHelper(8_000),
|
|
187
|
+
},
|
|
188
|
+
sequencerPublisherPreviousL1BlockWaitPollIntervalMs: {
|
|
189
|
+
env: `SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_POLL_INTERVAL_MS`,
|
|
190
|
+
description:
|
|
191
|
+
'Poll interval while waiting for the previous L1 block before scheduled publisher txs, in milliseconds.',
|
|
192
|
+
...numberConfigHelper(500),
|
|
193
|
+
},
|
|
194
|
+
l1TxFailedStore: {
|
|
195
|
+
env: 'L1_TX_FAILED_STORE',
|
|
196
|
+
description: 'Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path',
|
|
197
|
+
},
|
|
198
|
+
...publisherFundingConfigMappings,
|
|
199
|
+
};
|
|
82
200
|
|
|
83
|
-
export
|
|
84
|
-
|
|
85
|
-
|
|
201
|
+
export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
|
|
202
|
+
...l1TxUtilsConfigMappings,
|
|
203
|
+
...blobClientConfigMapping,
|
|
204
|
+
proverPublisherAllowInvalidStates: {
|
|
205
|
+
env: `PROVER_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
206
|
+
description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
|
|
207
|
+
...booleanConfigHelper(true),
|
|
208
|
+
},
|
|
209
|
+
fishermanMode: {
|
|
210
|
+
env: 'FISHERMAN_MODE',
|
|
211
|
+
description:
|
|
212
|
+
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
213
|
+
...booleanConfigHelper(false),
|
|
214
|
+
},
|
|
215
|
+
proverPublisherForwarderAddress: {
|
|
216
|
+
env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
|
|
217
|
+
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
218
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
219
|
+
},
|
|
220
|
+
...publisherFundingConfigMappings,
|
|
221
|
+
};
|
package/src/publisher/index.ts
CHANGED
|
@@ -3,3 +3,6 @@ export { SequencerPublisherFactory } from './sequencer-publisher-factory.js';
|
|
|
3
3
|
|
|
4
4
|
// Used for tests
|
|
5
5
|
export { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
6
|
+
|
|
7
|
+
// Failed L1 tx store (optional, for test networks)
|
|
8
|
+
export { type FailedL1Tx, type FailedL1TxUri, type L1TxFailedStore } from './l1_tx_failed_store/index.js';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import { tryJsonStringify } from '@aztec/foundation/json-rpc';
|
|
6
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import { InboxAbi } from '@aztec/l1-artifacts';
|
|
8
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
+
|
|
10
|
+
import { decodeEventLog, getContract } from 'viem';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Sends an L1-to-L2 message via the Inbox contract and returns its hash and global leaf index.
|
|
14
|
+
* Test helper copied from the end-to-end fixtures so this integration test can live in sequencer-client.
|
|
15
|
+
*/
|
|
16
|
+
export async function sendL1ToL2Message(
|
|
17
|
+
message: { recipient: AztecAddress; content: Fr; secretHash: Fr },
|
|
18
|
+
ctx: {
|
|
19
|
+
l1Client: ExtendedViemWalletClient;
|
|
20
|
+
l1ContractAddresses: Pick<L1ContractAddresses, 'inboxAddress' | 'rollupAddress'>;
|
|
21
|
+
},
|
|
22
|
+
) {
|
|
23
|
+
const logger = createLogger('sequencer-client:l1_to_l2_messaging');
|
|
24
|
+
const inbox = getContract({
|
|
25
|
+
address: ctx.l1ContractAddresses.inboxAddress.toString(),
|
|
26
|
+
abi: InboxAbi,
|
|
27
|
+
client: ctx.l1Client,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const { recipient, content, secretHash } = message;
|
|
31
|
+
|
|
32
|
+
const version = await new RollupContract(ctx.l1Client, ctx.l1ContractAddresses.rollupAddress.toString()).getVersion();
|
|
33
|
+
|
|
34
|
+
// We inject the message to Inbox
|
|
35
|
+
const txHash = await inbox.write.sendL2Message(
|
|
36
|
+
[{ actor: recipient.toString(), version: BigInt(version) }, content.toString(), secretHash.toString()],
|
|
37
|
+
{
|
|
38
|
+
gas: 1_000_000n,
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
logger.info(`L1 to L2 message sent in tx ${txHash}`);
|
|
42
|
+
|
|
43
|
+
// We check that the message was correctly injected by checking the emitted event
|
|
44
|
+
const txReceipt = await ctx.l1Client.waitForTransactionReceipt({ hash: txHash });
|
|
45
|
+
|
|
46
|
+
if (txReceipt.status !== 'success') {
|
|
47
|
+
throw new Error(`L1 to L2 message failed to be sent in tx ${txHash}. Status: ${txReceipt.status}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
logger.info(`L1 to L2 message receipt retrieved for tx ${txReceipt.transactionHash}`, txReceipt);
|
|
51
|
+
|
|
52
|
+
if (txReceipt.transactionHash !== txHash) {
|
|
53
|
+
throw new Error(`Receipt transaction hash mismatch: ${txReceipt.transactionHash} !== ${txHash}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Filter for MessageSent events from the Inbox contract by trying to decode each log
|
|
57
|
+
const messageSentLogs = txReceipt.logs
|
|
58
|
+
.filter(log => log.address.toLowerCase() === ctx.l1ContractAddresses.inboxAddress.toString().toLowerCase())
|
|
59
|
+
.map(log => {
|
|
60
|
+
try {
|
|
61
|
+
const decoded = decodeEventLog({
|
|
62
|
+
abi: InboxAbi,
|
|
63
|
+
data: log.data,
|
|
64
|
+
topics: log.topics,
|
|
65
|
+
});
|
|
66
|
+
return { log, decoded };
|
|
67
|
+
} catch {
|
|
68
|
+
return null; // Not a decodable event from this ABI
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
.filter((item): item is { log: any; decoded: any } => item !== null && item.decoded.eventName === 'MessageSent');
|
|
72
|
+
|
|
73
|
+
if (messageSentLogs.length !== 1) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Wrong number of MessageSent logs found in ${txHash} transaction (got ${messageSentLogs.length} expected 1)\n${tryJsonStringify(messageSentLogs.map(item => item.log))}`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// We already have the decoded event
|
|
80
|
+
const topics = messageSentLogs[0].decoded;
|
|
81
|
+
const receivedMsgHash = topics.args.hash;
|
|
82
|
+
const receivedGlobalLeafIndex = topics.args.index;
|
|
83
|
+
|
|
84
|
+
return { msgHash: Fr.fromHexString(receivedMsgHash), globalLeafIndex: new Fr(receivedGlobalLeafIndex), txReceipt };
|
|
85
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { createFileStore } from '@aztec/stdlib/file-store';
|
|
3
|
+
|
|
4
|
+
import type { L1TxFailedStore } from './failed_tx_store.js';
|
|
5
|
+
import { FileStoreL1TxFailedStore } from './file_store_failed_tx_store.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates an L1TxFailedStore from a config string.
|
|
9
|
+
* Supports any backend that FileStore supports (GCS, S3, R2, local filesystem).
|
|
10
|
+
* @param config - Config string (e.g., 'gs://bucket/path', 's3://bucket/path', 'file:///path'). If undefined, returns undefined.
|
|
11
|
+
* @param logger - Optional logger.
|
|
12
|
+
* @returns The store instance, or undefined if config is not provided.
|
|
13
|
+
*/
|
|
14
|
+
export async function createL1TxFailedStore(
|
|
15
|
+
config: string | undefined,
|
|
16
|
+
logger: Logger = createLogger('sequencer:l1-tx-failed-store'),
|
|
17
|
+
): Promise<L1TxFailedStore | undefined> {
|
|
18
|
+
if (!config) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const fileStore = await createFileStore(config, logger);
|
|
23
|
+
if (!fileStore) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Failed to create file store from config: '${config}'. ` +
|
|
26
|
+
`Supported formats: 'gs://bucket/path', 's3://bucket/path', 'file:///path'.`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
logger.info(`Created L1 tx failed store`, { config });
|
|
31
|
+
return new FileStoreL1TxFailedStore(fileStore, logger);
|
|
32
|
+
}
|