@aztec/sequencer-client 0.0.1-commit.b6e433891 → 0.0.1-commit.b8a057fa
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 +23 -5
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +33 -34
- package/dest/config.d.ts +11 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +55 -26
- 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 +13 -26
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +9 -67
- 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/publisher/config.d.ts +19 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +30 -5
- 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/failed_tx_store.d.ts +50 -11
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +68 -1
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +2 -2
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +4 -2
- package/dest/publisher/l1_tx_failed_store/index.d.ts +2 -2
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/index.js +1 -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 +3 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +2 -3
- package/dest/publisher/sequencer-publisher.d.ts +101 -67
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +615 -535
- 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 +71 -21
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +724 -212
- 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 +1 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +2 -5
- package/dest/sequencer/events.d.ts +61 -5
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +9 -10
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +34 -20
- 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 +155 -33
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +546 -161
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/utils.d.ts +15 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +25 -7
- package/package.json +30 -28
- package/src/client/sequencer-client.ts +47 -43
- package/src/config.ts +64 -26
- 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 +19 -89
- package/src/global_variable_builder/index.ts +3 -1
- package/src/publisher/config.ts +62 -7
- package/src/publisher/l1_to_l2_messaging.ts +85 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +117 -8
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +4 -3
- package/src/publisher/l1_tx_failed_store/index.ts +1 -1
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +3 -6
- package/src/publisher/sequencer-publisher.ts +711 -609
- package/src/publisher/write_json.ts +78 -0
- package/src/sequencer/README.md +162 -450
- 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 +844 -241
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/events.ts +66 -5
- package/src/sequencer/metrics.ts +43 -24
- package/src/sequencer/requests_tracker.ts +43 -0
- package/src/sequencer/sequencer.ts +628 -178
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -2
- package/src/test/utils.ts +61 -10
- package/dest/sequencer/timetable.d.ts +0 -88
- package/dest/sequencer/timetable.d.ts.map +0 -1
- package/dest/sequencer/timetable.js +0 -222
- package/src/sequencer/timetable.ts +0 -283
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
RollupContract,
|
|
3
|
+
type SimulationOverridesPlan,
|
|
4
|
+
buildSimulationOverridesStateOverride,
|
|
5
|
+
} from '@aztec/ethereum/contracts';
|
|
6
6
|
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
7
|
-
import {
|
|
7
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
8
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
9
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
11
10
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
11
|
import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
13
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
@@ -15,21 +14,19 @@ import type {
|
|
|
15
14
|
CheckpointGlobalVariables,
|
|
16
15
|
GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
17
16
|
} from '@aztec/stdlib/tx';
|
|
18
|
-
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
19
17
|
|
|
20
|
-
|
|
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'>;
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* Simple global variables builder.
|
|
24
27
|
*/
|
|
25
28
|
export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
26
|
-
private log = createLogger('sequencer:global_variable_builder');
|
|
27
|
-
private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
|
|
28
|
-
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
29
|
-
|
|
30
29
|
private readonly rollupContract: RollupContract;
|
|
31
|
-
private readonly publicClient: ViemPublicClient;
|
|
32
|
-
private readonly ethereumSlotDuration: number;
|
|
33
30
|
private readonly aztecSlotDuration: number;
|
|
34
31
|
private readonly l1GenesisTime: bigint;
|
|
35
32
|
|
|
@@ -37,83 +34,16 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
37
34
|
private version: Fr;
|
|
38
35
|
|
|
39
36
|
constructor(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'> & { rollupVersion: bigint },
|
|
37
|
+
private readonly publicClient: ViemPublicClient,
|
|
38
|
+
config: GlobalVariableBuilderConfig,
|
|
43
39
|
) {
|
|
44
|
-
const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
|
|
45
|
-
|
|
46
|
-
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
47
|
-
|
|
48
40
|
this.version = new Fr(config.rollupVersion);
|
|
49
|
-
this.chainId = new Fr(
|
|
41
|
+
this.chainId = new Fr(this.publicClient.chain!.id);
|
|
50
42
|
|
|
51
|
-
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
52
43
|
this.aztecSlotDuration = config.slotDuration;
|
|
53
44
|
this.l1GenesisTime = config.l1GenesisTime;
|
|
54
45
|
|
|
55
|
-
this.
|
|
56
|
-
chain: chain.chainInfo,
|
|
57
|
-
transport: makeL1HttpTransport(chain.rpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
58
|
-
pollingInterval: config.viemPollingIntervalMS,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
66
|
-
* @returns Min fees for the next block
|
|
67
|
-
*/
|
|
68
|
-
private async computeCurrentMinFees(): Promise<GasFees> {
|
|
69
|
-
// Since this might be called in the middle of a slot where a block might have been published,
|
|
70
|
-
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
71
|
-
// The timestamp of that last block will act as a lower bound for the next block.
|
|
72
|
-
|
|
73
|
-
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
74
|
-
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
75
|
-
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
76
|
-
);
|
|
77
|
-
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
78
|
-
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
79
|
-
|
|
80
|
-
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public async getCurrentMinFees(): Promise<GasFees> {
|
|
84
|
-
// Get the current block number
|
|
85
|
-
const blockNumber = await this.publicClient.getBlockNumber();
|
|
86
|
-
|
|
87
|
-
// If the L1 block number has changed then chain a new promise to get the current min fees
|
|
88
|
-
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
89
|
-
this.currentL1BlockNumber = blockNumber;
|
|
90
|
-
this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
|
|
91
|
-
}
|
|
92
|
-
return this.currentMinFees;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Simple builder of global variables.
|
|
97
|
-
* @param blockNumber - The block number to build global variables for.
|
|
98
|
-
* @param coinbase - The address to receive block reward.
|
|
99
|
-
* @param feeRecipient - The address to receive fees.
|
|
100
|
-
* @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
|
|
101
|
-
* @returns The global variables for the given block number.
|
|
102
|
-
*/
|
|
103
|
-
public async buildGlobalVariables(
|
|
104
|
-
blockNumber: BlockNumber,
|
|
105
|
-
coinbase: EthAddress,
|
|
106
|
-
feeRecipient: AztecAddress,
|
|
107
|
-
maybeSlot?: SlotNumber,
|
|
108
|
-
): Promise<GlobalVariables> {
|
|
109
|
-
const slot: SlotNumber =
|
|
110
|
-
maybeSlot ??
|
|
111
|
-
(await this.rollupContract.getSlotAt(
|
|
112
|
-
BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration)),
|
|
113
|
-
));
|
|
114
|
-
|
|
115
|
-
const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
|
|
116
|
-
return GlobalVariables.from({ blockNumber, ...checkpointGlobalVariables });
|
|
46
|
+
this.rollupContract = new RollupContract(this.publicClient, config.rollupAddress);
|
|
117
47
|
}
|
|
118
48
|
|
|
119
49
|
/** Builds global variables that are constant throughout a checkpoint. */
|
|
@@ -121,6 +51,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
121
51
|
coinbase: EthAddress,
|
|
122
52
|
feeRecipient: AztecAddress,
|
|
123
53
|
slotNumber: SlotNumber,
|
|
54
|
+
simulationOverridesPlan?: SimulationOverridesPlan,
|
|
124
55
|
): Promise<CheckpointGlobalVariables> {
|
|
125
56
|
const { chainId, version } = this;
|
|
126
57
|
|
|
@@ -129,9 +60,8 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
129
60
|
l1GenesisTime: this.l1GenesisTime,
|
|
130
61
|
});
|
|
131
62
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
63
|
+
const stateOverride = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
|
|
64
|
+
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true, stateOverride));
|
|
135
65
|
|
|
136
66
|
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
|
137
67
|
}
|
package/src/publisher/config.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
2
|
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
3
3
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils/config';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type ConfigMappingsType,
|
|
6
|
+
SecretValue,
|
|
7
|
+
booleanConfigHelper,
|
|
8
|
+
numberConfigHelper,
|
|
9
|
+
} from '@aztec/foundation/config';
|
|
5
10
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
11
|
|
|
12
|
+
import { parseEther } from 'viem';
|
|
13
|
+
|
|
7
14
|
/** Configuration of the transaction publisher. */
|
|
8
15
|
export type TxSenderConfig = L1ReaderConfig & {
|
|
9
16
|
/** The private key to be used by the publisher. */
|
|
@@ -50,13 +57,37 @@ export type PublisherConfig = L1TxUtilsConfig &
|
|
|
50
57
|
publisherForwarderAddress?: EthAddress;
|
|
51
58
|
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
52
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;
|
|
53
64
|
};
|
|
54
65
|
|
|
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
|
+
|
|
55
82
|
export type ProverPublisherConfig = L1TxUtilsConfig &
|
|
56
83
|
BlobClientConfig & {
|
|
57
84
|
fishermanMode?: boolean;
|
|
58
85
|
proverPublisherAllowInvalidStates?: boolean;
|
|
59
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;
|
|
60
91
|
};
|
|
61
92
|
|
|
62
93
|
export type SequencerPublisherConfig = L1TxUtilsConfig &
|
|
@@ -64,8 +95,16 @@ export type SequencerPublisherConfig = L1TxUtilsConfig &
|
|
|
64
95
|
fishermanMode?: boolean;
|
|
65
96
|
sequencerPublisherAllowInvalidStates?: boolean;
|
|
66
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;
|
|
67
102
|
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
68
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;
|
|
69
108
|
};
|
|
70
109
|
|
|
71
110
|
export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
|
|
@@ -85,12 +124,13 @@ export function getPublisherConfigFromSequencerConfig(config: SequencerPublisher
|
|
|
85
124
|
};
|
|
86
125
|
}
|
|
87
126
|
|
|
88
|
-
export const proverTxSenderConfigMappings: ConfigMappingsType<
|
|
127
|
+
export const proverTxSenderConfigMappings: ConfigMappingsType<ProverTxSenderConfig> = {
|
|
89
128
|
...l1ReaderConfigMappings,
|
|
90
129
|
proverPublisherPrivateKeys: {
|
|
91
130
|
env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
|
|
92
131
|
description: 'The private keys to be used by the prover publisher.',
|
|
93
|
-
parseEnv: (val: string) =>
|
|
132
|
+
parseEnv: (val: string) =>
|
|
133
|
+
val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
|
|
94
134
|
defaultValue: [],
|
|
95
135
|
fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
|
|
96
136
|
},
|
|
@@ -102,12 +142,13 @@ export const proverTxSenderConfigMappings: ConfigMappingsType<Omit<ProverTxSende
|
|
|
102
142
|
},
|
|
103
143
|
};
|
|
104
144
|
|
|
105
|
-
export const sequencerTxSenderConfigMappings: ConfigMappingsType<
|
|
145
|
+
export const sequencerTxSenderConfigMappings: ConfigMappingsType<SequencerTxSenderConfig> = {
|
|
106
146
|
...l1ReaderConfigMappings,
|
|
107
147
|
sequencerPublisherPrivateKeys: {
|
|
108
148
|
env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
|
|
109
149
|
description: 'The private keys to be used by the sequencer publisher.',
|
|
110
|
-
parseEnv: (val: string) =>
|
|
150
|
+
parseEnv: (val: string) =>
|
|
151
|
+
val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
|
|
111
152
|
defaultValue: [],
|
|
112
153
|
fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
|
|
113
154
|
},
|
|
@@ -136,12 +177,25 @@ export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPubli
|
|
|
136
177
|
sequencerPublisherForwarderAddress: {
|
|
137
178
|
env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
|
|
138
179
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
139
|
-
parseEnv: (val: string) =>
|
|
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),
|
|
140
193
|
},
|
|
141
194
|
l1TxFailedStore: {
|
|
142
195
|
env: 'L1_TX_FAILED_STORE',
|
|
143
196
|
description: 'Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path',
|
|
144
197
|
},
|
|
198
|
+
...publisherFundingConfigMappings,
|
|
145
199
|
};
|
|
146
200
|
|
|
147
201
|
export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
|
|
@@ -161,6 +215,7 @@ export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherCo
|
|
|
161
215
|
proverPublisherForwarderAddress: {
|
|
162
216
|
env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
|
|
163
217
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
164
|
-
parseEnv: (val: string) =>
|
|
218
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
165
219
|
},
|
|
220
|
+
...publisherFundingConfigMappings,
|
|
166
221
|
};
|
|
@@ -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
|
+
}
|
|
@@ -1,31 +1,40 @@
|
|
|
1
|
+
import type { WindowBlockFees } from '@aztec/ethereum/l1-fee-analysis';
|
|
2
|
+
import type { GasPrice } from '@aztec/ethereum/l1-tx-utils';
|
|
3
|
+
import type { Branded } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { type ZodFor, schemas } from '@aztec/foundation/schemas';
|
|
5
|
+
|
|
1
6
|
import type { Hex } from 'viem';
|
|
7
|
+
import { z } from 'zod';
|
|
2
8
|
|
|
3
9
|
/** URI pointing to a stored failed L1 transaction. */
|
|
4
|
-
export type FailedL1TxUri = string
|
|
10
|
+
export type FailedL1TxUri = Branded<string, 'FailedL1TxUri'>;
|
|
5
11
|
|
|
6
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* A failed L1 transaction captured for debugging and replay. Serialized with jsonStringify (bigints
|
|
14
|
+
* become decimal strings on disk) and parsed back via FailedL1TxSchema.
|
|
15
|
+
*/
|
|
7
16
|
export type FailedL1Tx = {
|
|
8
17
|
/** Tx hash (for reverts) or keccak256(request.data) (for simulation/send failures). */
|
|
9
18
|
id: Hex;
|
|
10
19
|
/** Unix timestamp (ms) when failure occurred. */
|
|
11
20
|
timestamp: number;
|
|
12
|
-
/**
|
|
13
|
-
failureType: 'simulation' | 'revert' | 'send-error';
|
|
21
|
+
/** How the failure occurred. */
|
|
22
|
+
failureType: 'simulation' | 'revert' | 'send-error' | 'timeout';
|
|
14
23
|
/** The actual L1 transaction for replay (multicall-encoded for bundled txs). */
|
|
15
24
|
request: {
|
|
16
25
|
to: Hex;
|
|
17
26
|
data: Hex;
|
|
18
|
-
value?:
|
|
27
|
+
value?: bigint;
|
|
19
28
|
};
|
|
20
29
|
/** Raw blob data as hex for replay. */
|
|
21
30
|
blobData?: Hex[];
|
|
22
31
|
/** L1 block number at time of failure (simulation target or receipt block). */
|
|
23
|
-
l1BlockNumber:
|
|
32
|
+
l1BlockNumber: bigint;
|
|
24
33
|
/** Receipt info (present only for on-chain reverts). */
|
|
25
34
|
receipt?: {
|
|
26
35
|
transactionHash: Hex;
|
|
27
|
-
blockNumber:
|
|
28
|
-
gasUsed:
|
|
36
|
+
blockNumber: bigint;
|
|
37
|
+
gasUsed: bigint;
|
|
29
38
|
status: 'reverted';
|
|
30
39
|
};
|
|
31
40
|
/** Error information. */
|
|
@@ -44,8 +53,108 @@ export type FailedL1Tx = {
|
|
|
44
53
|
slot?: number;
|
|
45
54
|
sender: Hex;
|
|
46
55
|
};
|
|
56
|
+
/** Gas pricing info at time of failure for underpricing diagnosis. */
|
|
57
|
+
gasInfo?: {
|
|
58
|
+
/** Gas prices the tx was sent with (present for revert/send-error/timeout, not simulation). */
|
|
59
|
+
sentGasPrice?: GasPrice;
|
|
60
|
+
/** Gas limit used or estimated. */
|
|
61
|
+
gasLimit?: bigint;
|
|
62
|
+
/** Nonce used for the sent tx. */
|
|
63
|
+
nonce?: number;
|
|
64
|
+
/**
|
|
65
|
+
* For timeouts: the escalating gas prices used across the initial send and each speed-up retry,
|
|
66
|
+
* in order. Compare against windowBlocks[].minIncludedPriorityFee to see if any attempt cleared the bar.
|
|
67
|
+
*/
|
|
68
|
+
sentGasPriceLadder?: GasPrice[];
|
|
69
|
+
/** Number of send attempts (initial send + speed-ups). */
|
|
70
|
+
attempts?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Per-block fee data for the L1 blocks the tx could have been included in (the target L2 slot's
|
|
73
|
+
* inclusion window), in chronological order. Compare sentGasPrice against these to see whether
|
|
74
|
+
* the tx was underpriced for each block it competed for. May be a partial or empty list if the
|
|
75
|
+
* window was not yet mined when the failure was recorded (e.g. an early send failure).
|
|
76
|
+
*/
|
|
77
|
+
windowBlocks?: WindowBlockFees[];
|
|
78
|
+
};
|
|
79
|
+
/** Timing info relative to the L2 slot. */
|
|
80
|
+
timing?: {
|
|
81
|
+
/** The target L2 slot this tx was for. */
|
|
82
|
+
targetL2Slot?: number;
|
|
83
|
+
/** Unix timestamp (seconds) when the target slot ends. */
|
|
84
|
+
slotDeadlineTimestampS?: bigint;
|
|
85
|
+
/** Milliseconds remaining until the slot deadline. Negative = past deadline. */
|
|
86
|
+
msUntilSlotDeadline?: number;
|
|
87
|
+
};
|
|
47
88
|
};
|
|
48
89
|
|
|
90
|
+
const hexSchema = schemas.HexStringWith0x;
|
|
91
|
+
|
|
92
|
+
const gasPriceSchema = z.object({
|
|
93
|
+
maxFeePerGas: schemas.BigInt,
|
|
94
|
+
maxPriorityFeePerGas: schemas.BigInt,
|
|
95
|
+
maxFeePerBlobGas: schemas.BigInt.optional(),
|
|
96
|
+
}) satisfies ZodFor<GasPrice>;
|
|
97
|
+
|
|
98
|
+
const windowBlockFeesSchema = z.object({
|
|
99
|
+
blockNumber: schemas.BigInt,
|
|
100
|
+
timestamp: schemas.BigInt,
|
|
101
|
+
baseFeePerGas: schemas.BigInt,
|
|
102
|
+
p75PriorityFee: schemas.BigInt,
|
|
103
|
+
minIncludedPriorityFee: schemas.BigInt,
|
|
104
|
+
blockBlobsFull: z.boolean(),
|
|
105
|
+
includedBlobCount: z.number(),
|
|
106
|
+
}) satisfies ZodFor<WindowBlockFees>;
|
|
107
|
+
|
|
108
|
+
/** Parses a stored failed-tx record, coercing the on-disk decimal strings back to bigints. */
|
|
109
|
+
export const FailedL1TxSchema: ZodFor<FailedL1Tx> = z.object({
|
|
110
|
+
id: hexSchema,
|
|
111
|
+
timestamp: z.number(),
|
|
112
|
+
failureType: z.enum(['simulation', 'revert', 'send-error', 'timeout']),
|
|
113
|
+
request: z.object({
|
|
114
|
+
to: hexSchema,
|
|
115
|
+
data: hexSchema,
|
|
116
|
+
value: schemas.BigInt.optional(),
|
|
117
|
+
}),
|
|
118
|
+
blobData: z.array(hexSchema).optional(),
|
|
119
|
+
l1BlockNumber: schemas.BigInt,
|
|
120
|
+
receipt: z
|
|
121
|
+
.object({
|
|
122
|
+
transactionHash: hexSchema,
|
|
123
|
+
blockNumber: schemas.BigInt,
|
|
124
|
+
gasUsed: schemas.BigInt,
|
|
125
|
+
status: z.literal('reverted'),
|
|
126
|
+
})
|
|
127
|
+
.optional(),
|
|
128
|
+
error: z.object({
|
|
129
|
+
message: z.string(),
|
|
130
|
+
name: z.string().optional(),
|
|
131
|
+
}),
|
|
132
|
+
context: z.object({
|
|
133
|
+
actions: z.array(z.string()),
|
|
134
|
+
requests: z.array(z.object({ action: z.string(), to: hexSchema, data: hexSchema })).optional(),
|
|
135
|
+
checkpointNumber: z.number().optional(),
|
|
136
|
+
slot: z.number().optional(),
|
|
137
|
+
sender: hexSchema,
|
|
138
|
+
}),
|
|
139
|
+
gasInfo: z
|
|
140
|
+
.object({
|
|
141
|
+
sentGasPrice: gasPriceSchema.optional(),
|
|
142
|
+
gasLimit: schemas.BigInt.optional(),
|
|
143
|
+
nonce: z.number().optional(),
|
|
144
|
+
sentGasPriceLadder: z.array(gasPriceSchema).optional(),
|
|
145
|
+
attempts: z.number().optional(),
|
|
146
|
+
windowBlocks: z.array(windowBlockFeesSchema).optional(),
|
|
147
|
+
})
|
|
148
|
+
.optional(),
|
|
149
|
+
timing: z
|
|
150
|
+
.object({
|
|
151
|
+
targetL2Slot: z.number().optional(),
|
|
152
|
+
slotDeadlineTimestampS: schemas.BigInt.optional(),
|
|
153
|
+
msUntilSlotDeadline: z.number().optional(),
|
|
154
|
+
})
|
|
155
|
+
.optional(),
|
|
156
|
+
});
|
|
157
|
+
|
|
49
158
|
/** Store for failed L1 transactions for debugging purposes. */
|
|
50
159
|
export interface L1TxFailedStore {
|
|
51
160
|
/** Saves a failed transaction and returns its URI. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
1
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import type { FileStore } from '@aztec/stdlib/file-store';
|
|
3
4
|
|
|
4
|
-
import type
|
|
5
|
+
import { type FailedL1Tx, FailedL1TxSchema, type FailedL1TxUri, type L1TxFailedStore } from './failed_tx_store.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* L1TxFailedStore implementation using the FileStore abstraction.
|
|
@@ -20,7 +21,7 @@ export class FileStoreL1TxFailedStore implements L1TxFailedStore {
|
|
|
20
21
|
public async saveFailedTx(tx: FailedL1Tx): Promise<FailedL1TxUri> {
|
|
21
22
|
const prefix = tx.receipt ? 'tx' : 'data';
|
|
22
23
|
const path = `${tx.failureType}/${prefix}-${tx.id}.json`;
|
|
23
|
-
const json =
|
|
24
|
+
const json = jsonStringify(tx, true);
|
|
24
25
|
|
|
25
26
|
const uri = await this.fileStore.save(path, Buffer.from(json), {
|
|
26
27
|
metadata: {
|
|
@@ -41,6 +42,6 @@ export class FileStoreL1TxFailedStore implements L1TxFailedStore {
|
|
|
41
42
|
|
|
42
43
|
public async getFailedTx(uri: FailedL1TxUri): Promise<FailedL1Tx> {
|
|
43
44
|
const data = await this.fileStore.read(uri);
|
|
44
|
-
return
|
|
45
|
+
return jsonParseWithSchema(data.toString(), FailedL1TxSchema);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { type FailedL1Tx, type FailedL1TxUri, type L1TxFailedStore } from './failed_tx_store.js';
|
|
1
|
+
export { type FailedL1Tx, FailedL1TxSchema, type FailedL1TxUri, type L1TxFailedStore } from './failed_tx_store.js';
|
|
2
2
|
export { createL1TxFailedStore } from './factory.js';
|
|
3
3
|
export { FileStoreL1TxFailedStore } from './file_store_failed_tx_store.js';
|