@aztec/sequencer-client 0.0.1-commit.993d240 → 0.0.1-commit.9a89641
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 +40 -41
- package/dest/client/sequencer-client.d.ts +16 -3
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +18 -14
- package/dest/config.d.ts +9 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +29 -15
- package/dest/global_variable_builder/fee_predictor.d.ts +1 -1
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -1
- package/dest/global_variable_builder/fee_predictor.js +11 -1
- package/dest/global_variable_builder/fee_provider.d.ts +1 -1
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -1
- package/dest/global_variable_builder/fee_provider.js +27 -5
- package/dest/global_variable_builder/global_builder.d.ts +3 -16
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +2 -25
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +5 -1
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +11 -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/failed_tx_store.d.ts +48 -8
- 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-publisher.d.ts +39 -10
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +403 -75
- 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 +5 -3
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -1
- package/dest/sequencer/automine/automine_factory.js +2 -1
- package/dest/sequencer/automine/automine_sequencer.d.ts +43 -5
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -1
- package/dest/sequencer/automine/automine_sequencer.js +209 -19
- 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 +28 -15
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +158 -117
- package/dest/sequencer/events.d.ts +16 -4
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/index.d.ts +1 -3
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +0 -2
- package/dest/sequencer/missing_committee.d.ts +72 -0
- package/dest/sequencer/missing_committee.d.ts.map +1 -0
- package/dest/sequencer/missing_committee.js +139 -0
- 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 +113 -28
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +352 -162
- 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 +18 -1
- package/package.json +29 -28
- package/src/client/sequencer-client.ts +20 -14
- package/src/config.ts +32 -16
- package/src/global_variable_builder/fee_predictor.ts +11 -1
- package/src/global_variable_builder/fee_provider.ts +27 -5
- package/src/global_variable_builder/global_builder.ts +2 -34
- package/src/index.ts +1 -10
- package/src/publisher/config.ts +22 -1
- package/src/publisher/l1_to_l2_messaging.ts +85 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +114 -7
- 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-publisher.ts +430 -86
- package/src/publisher/write_json.ts +78 -0
- package/src/sequencer/README.md +16 -6
- package/src/sequencer/automine/README.md +18 -4
- package/src/sequencer/automine/automine_factory.ts +8 -1
- package/src/sequencer/automine/automine_sequencer.ts +229 -21
- package/src/sequencer/automine/index.ts +6 -0
- package/src/sequencer/checkpoint_proposal_job.ts +177 -132
- package/src/sequencer/events.ts +16 -3
- package/src/sequencer/index.ts +0 -2
- package/src/sequencer/missing_committee.ts +192 -0
- package/src/sequencer/requests_tracker.ts +43 -0
- package/src/sequencer/sequencer.ts +382 -176
- package/src/test/index.ts +2 -2
- package/src/test/utils.ts +33 -0
- package/dest/sequencer/chain_state_overrides.d.ts +0 -61
- package/dest/sequencer/chain_state_overrides.d.ts.map +0 -1
- package/dest/sequencer/chain_state_overrides.js +0 -98
- package/dest/sequencer/timetable.d.ts +0 -101
- package/dest/sequencer/timetable.d.ts.map +0 -1
- package/dest/sequencer/timetable.js +0 -231
- package/src/sequencer/chain_state_overrides.ts +0 -162
- package/src/sequencer/timetable.ts +0 -295
|
@@ -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,33 +1,40 @@
|
|
|
1
|
+
import type { WindowBlockFees } from '@aztec/ethereum/l1-fee-analysis';
|
|
2
|
+
import type { GasPrice } from '@aztec/ethereum/l1-tx-utils';
|
|
1
3
|
import type { Branded } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { type ZodFor, schemas } from '@aztec/foundation/schemas';
|
|
2
5
|
|
|
3
6
|
import type { Hex } from 'viem';
|
|
7
|
+
import { z } from 'zod';
|
|
4
8
|
|
|
5
9
|
/** URI pointing to a stored failed L1 transaction. */
|
|
6
10
|
export type FailedL1TxUri = Branded<string, 'FailedL1TxUri'>;
|
|
7
11
|
|
|
8
|
-
/**
|
|
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
|
+
*/
|
|
9
16
|
export type FailedL1Tx = {
|
|
10
17
|
/** Tx hash (for reverts) or keccak256(request.data) (for simulation/send failures). */
|
|
11
18
|
id: Hex;
|
|
12
19
|
/** Unix timestamp (ms) when failure occurred. */
|
|
13
20
|
timestamp: number;
|
|
14
|
-
/**
|
|
15
|
-
failureType: 'simulation' | 'revert' | 'send-error';
|
|
21
|
+
/** How the failure occurred. */
|
|
22
|
+
failureType: 'simulation' | 'revert' | 'send-error' | 'timeout';
|
|
16
23
|
/** The actual L1 transaction for replay (multicall-encoded for bundled txs). */
|
|
17
24
|
request: {
|
|
18
25
|
to: Hex;
|
|
19
26
|
data: Hex;
|
|
20
|
-
value?:
|
|
27
|
+
value?: bigint;
|
|
21
28
|
};
|
|
22
29
|
/** Raw blob data as hex for replay. */
|
|
23
30
|
blobData?: Hex[];
|
|
24
31
|
/** L1 block number at time of failure (simulation target or receipt block). */
|
|
25
|
-
l1BlockNumber:
|
|
32
|
+
l1BlockNumber: bigint;
|
|
26
33
|
/** Receipt info (present only for on-chain reverts). */
|
|
27
34
|
receipt?: {
|
|
28
35
|
transactionHash: Hex;
|
|
29
|
-
blockNumber:
|
|
30
|
-
gasUsed:
|
|
36
|
+
blockNumber: bigint;
|
|
37
|
+
gasUsed: bigint;
|
|
31
38
|
status: 'reverted';
|
|
32
39
|
};
|
|
33
40
|
/** Error information. */
|
|
@@ -46,8 +53,108 @@ export type FailedL1Tx = {
|
|
|
46
53
|
slot?: number;
|
|
47
54
|
sender: Hex;
|
|
48
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
|
+
};
|
|
49
88
|
};
|
|
50
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
|
+
|
|
51
158
|
/** Store for failed L1 transactions for debugging purposes. */
|
|
52
159
|
export interface L1TxFailedStore {
|
|
53
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';
|