@aztec/sequencer-client 0.71.0 → 0.73.0

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.
Files changed (66) hide show
  1. package/dest/client/sequencer-client.d.ts +11 -6
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +41 -10
  4. package/dest/config.d.ts +1 -1
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +3 -4
  7. package/dest/publisher/config.d.ts +5 -0
  8. package/dest/publisher/config.d.ts.map +1 -1
  9. package/dest/publisher/config.js +9 -2
  10. package/dest/publisher/index.d.ts +1 -1
  11. package/dest/publisher/index.d.ts.map +1 -1
  12. package/dest/publisher/index.js +2 -2
  13. package/dest/publisher/{l1-publisher-metrics.d.ts → sequencer-publisher-metrics.d.ts} +6 -2
  14. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -0
  15. package/dest/publisher/sequencer-publisher-metrics.js +111 -0
  16. package/dest/publisher/sequencer-publisher.d.ts +158 -0
  17. package/dest/publisher/sequencer-publisher.d.ts.map +1 -0
  18. package/dest/publisher/sequencer-publisher.js +555 -0
  19. package/dest/sequencer/allowed.d.ts +1 -1
  20. package/dest/sequencer/allowed.d.ts.map +1 -1
  21. package/dest/sequencer/allowed.js +6 -6
  22. package/dest/sequencer/metrics.d.ts +1 -1
  23. package/dest/sequencer/metrics.d.ts.map +1 -1
  24. package/dest/sequencer/metrics.js +3 -4
  25. package/dest/sequencer/sequencer.d.ts +18 -12
  26. package/dest/sequencer/sequencer.d.ts.map +1 -1
  27. package/dest/sequencer/sequencer.js +118 -125
  28. package/dest/sequencer/utils.d.ts +1 -1
  29. package/dest/sequencer/utils.d.ts.map +1 -1
  30. package/dest/sequencer/utils.js +3 -3
  31. package/dest/slasher/slasher_client.d.ts.map +1 -1
  32. package/dest/slasher/slasher_client.js +6 -3
  33. package/dest/test/index.d.ts +3 -3
  34. package/dest/test/index.d.ts.map +1 -1
  35. package/dest/test/index.js +1 -2
  36. package/dest/tx_validator/gas_validator.d.ts +1 -1
  37. package/dest/tx_validator/gas_validator.d.ts.map +1 -1
  38. package/dest/tx_validator/gas_validator.js +10 -5
  39. package/dest/tx_validator/test_utils.d.ts +4 -4
  40. package/dest/tx_validator/test_utils.d.ts.map +1 -1
  41. package/dest/tx_validator/test_utils.js +3 -3
  42. package/package.json +22 -21
  43. package/src/client/sequencer-client.ts +60 -14
  44. package/src/config.ts +3 -3
  45. package/src/publisher/config.ts +13 -1
  46. package/src/publisher/index.ts +1 -1
  47. package/src/publisher/{l1-publisher-metrics.ts → sequencer-publisher-metrics.ts} +41 -2
  48. package/src/publisher/sequencer-publisher.ts +730 -0
  49. package/src/sequencer/allowed.ts +5 -5
  50. package/src/sequencer/metrics.ts +2 -3
  51. package/src/sequencer/sequencer.ts +153 -150
  52. package/src/sequencer/utils.ts +5 -2
  53. package/src/slasher/slasher_client.ts +7 -2
  54. package/src/test/index.ts +2 -4
  55. package/src/tx_validator/gas_validator.ts +17 -4
  56. package/src/tx_validator/test_utils.ts +5 -5
  57. package/dest/publisher/l1-publisher-metrics.d.ts.map +0 -1
  58. package/dest/publisher/l1-publisher-metrics.js +0 -85
  59. package/dest/publisher/l1-publisher.d.ts +0 -195
  60. package/dest/publisher/l1-publisher.d.ts.map +0 -1
  61. package/dest/publisher/l1-publisher.js +0 -864
  62. package/dest/test/test-l1-publisher.d.ts +0 -9
  63. package/dest/test/test-l1-publisher.d.ts.map +0 -1
  64. package/dest/test/test-l1-publisher.js +0 -11
  65. package/src/publisher/l1-publisher.ts +0 -1208
  66. package/src/test/test-l1-publisher.ts +0 -20
@@ -1,5 +1,6 @@
1
1
  import { type Tx, TxExecutionPhase, type TxValidationResult, type TxValidator } from '@aztec/circuit-types';
2
- import { type AztecAddress, type Fr, FunctionSelector, type GasFees } from '@aztec/circuits.js';
2
+ import { type AztecAddress, Fr, FunctionSelector, type GasFees } from '@aztec/circuits.js';
3
+ import { U128 } from '@aztec/foundation/abi';
3
4
  import { createLogger } from '@aztec/foundation/log';
4
5
  import { computeFeePayerBalanceStorageSlot, getExecutionRequestsByPhase } from '@aztec/simulator/server';
5
6
 
@@ -34,6 +35,12 @@ export class GasTxValidator implements TxValidator<Tx> {
34
35
  return this.#validateTxFee(tx);
35
36
  }
36
37
 
38
+ /**
39
+ * Check whether the tx's max fees are valid for the current block, and skip if not.
40
+ * We skip instead of invalidating since the tx may become elligible later.
41
+ * Note that circuits check max fees even if fee payer is unset, so we
42
+ * keep this validation even if the tx does not pay fees.
43
+ */
37
44
  #shouldSkip(tx: Tx): boolean {
38
45
  const gasSettings = tx.data.constants.txContext.gasSettings;
39
46
 
@@ -67,23 +74,29 @@ export class GasTxValidator implements TxValidator<Tx> {
67
74
  // Read current balance of the feePayer
68
75
  const initialBalance = await this.#publicDataSource.storageRead(
69
76
  this.#feeJuiceAddress,
70
- computeFeePayerBalanceStorageSlot(feePayer),
77
+ await computeFeePayerBalanceStorageSlot(feePayer),
71
78
  );
72
79
 
73
80
  // If there is a claim in this tx that increases the fee payer balance in Fee Juice, add it to balance
74
81
  const setupFns = getExecutionRequestsByPhase(tx, TxExecutionPhase.SETUP);
82
+ const increasePublicBalanceSelector = await FunctionSelector.fromSignature(
83
+ '_increase_public_balance((Field),(Field,Field))',
84
+ );
75
85
  const claimFunctionCall = setupFns.find(
76
86
  fn =>
77
87
  fn.callContext.contractAddress.equals(this.#feeJuiceAddress) &&
78
88
  fn.callContext.msgSender.equals(this.#feeJuiceAddress) &&
79
89
  fn.args.length > 2 &&
80
90
  // Public functions get routed through the dispatch function, whose first argument is the target function selector.
81
- fn.args[0].equals(FunctionSelector.fromSignature('_increase_public_balance((Field),Field)').toField()) &&
91
+ fn.args[0].equals(increasePublicBalanceSelector.toField()) &&
82
92
  fn.args[1].equals(feePayer.toField()) &&
83
93
  !fn.callContext.isStaticCall,
84
94
  );
85
95
 
86
- const balance = claimFunctionCall ? initialBalance.add(claimFunctionCall.args[2]) : initialBalance;
96
+ // `amount` in the claim function call arguments occupies 2 fields as it is represented as U128.
97
+ const balance = claimFunctionCall
98
+ ? initialBalance.add(new Fr(U128.fromFields(claimFunctionCall.args.slice(2, 4)).toInteger()))
99
+ : initialBalance;
87
100
  if (balance.lt(feeLimit)) {
88
101
  this.#log.warn(`Rejecting transaction due to not enough fee payer balance`, {
89
102
  feePayer,
@@ -6,7 +6,7 @@ export function patchNonRevertibleFn(
6
6
  tx: Tx,
7
7
  index: number,
8
8
  overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
9
- ): { address: AztecAddress; selector: FunctionSelector } {
9
+ ): Promise<{ address: AztecAddress; selector: FunctionSelector }> {
10
10
  return patchFn('nonRevertibleAccumulatedData', tx, index, overrides);
11
11
  }
12
12
 
@@ -14,16 +14,16 @@ export function patchRevertibleFn(
14
14
  tx: Tx,
15
15
  index: number,
16
16
  overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
17
- ): { address: AztecAddress; selector: FunctionSelector } {
17
+ ): Promise<{ address: AztecAddress; selector: FunctionSelector }> {
18
18
  return patchFn('revertibleAccumulatedData', tx, index, overrides);
19
19
  }
20
20
 
21
- function patchFn(
21
+ async function patchFn(
22
22
  where: 'revertibleAccumulatedData' | 'nonRevertibleAccumulatedData',
23
23
  tx: Tx,
24
24
  index: number,
25
25
  overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
26
- ): { address: AztecAddress; selector: FunctionSelector } {
26
+ ): Promise<{ address: AztecAddress; selector: FunctionSelector }> {
27
27
  const fn = tx.enqueuedPublicFunctionCalls.at(-1 * index - 1)!;
28
28
  fn.callContext.contractAddress = overrides.address ?? fn.callContext.contractAddress;
29
29
  fn.callContext.functionSelector = overrides.selector;
@@ -36,7 +36,7 @@ function patchFn(
36
36
  request.msgSender = fn.callContext.msgSender;
37
37
  request.functionSelector = fn.callContext.functionSelector;
38
38
  request.isStaticCall = fn.callContext.isStaticCall;
39
- request.argsHash = computeVarArgsHash(fn.args);
39
+ request.argsHash = await computeVarArgsHash(fn.args);
40
40
  tx.data.forPublic![where].publicCallRequests[index] = request;
41
41
 
42
42
  return {
@@ -1 +0,0 @@
1
- {"version":3,"file":"l1-publisher-metrics.d.ts","sourceRoot":"","sources":["../../src/publisher/l1-publisher-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC3G,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,SAAS,GAAG,sBAAsB,CAAC;AAE1E,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAY;IAE5B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,iBAAiB,CAAY;gBAEzB,MAAM,EAAE,eAAe,EAAE,IAAI,SAAgB;IAkDzD,cAAc,CAAC,MAAM,EAAE,QAAQ;IAO/B,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB;IAIhE,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB;IAInE,4BAA4B,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc;IAItE,OAAO,CAAC,QAAQ;CA6BjB"}
@@ -1,85 +0,0 @@
1
- import { Attributes, Metrics, ValueType, } from '@aztec/telemetry-client';
2
- import { formatEther } from 'viem/utils';
3
- export class L1PublisherMetrics {
4
- constructor(client, name = 'L1Publisher') {
5
- const meter = client.getMeter(name);
6
- this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE, {
7
- description: 'The gas price used for transactions',
8
- unit: 'gwei',
9
- valueType: ValueType.DOUBLE,
10
- });
11
- this.txCount = meter.createUpDownCounter(Metrics.L1_PUBLISHER_TX_COUNT, {
12
- description: 'The number of transactions processed',
13
- });
14
- this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION, {
15
- description: 'The duration of transaction processing',
16
- unit: 'ms',
17
- valueType: ValueType.INT,
18
- });
19
- this.txGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS, {
20
- description: 'The gas consumed by transactions',
21
- unit: 'gas',
22
- valueType: ValueType.INT,
23
- });
24
- this.txCalldataSize = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE, {
25
- description: 'The size of the calldata in transactions',
26
- unit: 'By',
27
- valueType: ValueType.INT,
28
- });
29
- this.txCalldataGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS, {
30
- description: 'The gas consumed by the calldata in transactions',
31
- unit: 'gas',
32
- valueType: ValueType.INT,
33
- });
34
- this.txBlobDataGasUsed = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED, {
35
- description: 'The amount of blob gas used in transactions',
36
- unit: 'gas',
37
- valueType: ValueType.INT,
38
- });
39
- this.txBlobDataGasCost = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST, {
40
- description: 'The gas cost of blobs in transactions',
41
- unit: 'gwei',
42
- valueType: ValueType.INT,
43
- });
44
- }
45
- recordFailedTx(txType) {
46
- this.txCount.add(1, {
47
- [Attributes.L1_TX_TYPE]: txType,
48
- [Attributes.OK]: false,
49
- });
50
- }
51
- recordSubmitProof(durationMs, stats) {
52
- this.recordTx('submitProof', durationMs, stats);
53
- }
54
- recordProcessBlockTx(durationMs, stats) {
55
- this.recordTx('process', durationMs, stats);
56
- }
57
- recordClaimEpochProofRightTx(durationMs, stats) {
58
- this.recordTx('claimEpochProofRight', durationMs, stats);
59
- }
60
- recordTx(txType, durationMs, stats) {
61
- const attributes = {
62
- [Attributes.L1_TX_TYPE]: txType,
63
- [Attributes.L1_SENDER]: stats.sender,
64
- };
65
- this.txCount.add(1, {
66
- ...attributes,
67
- [Attributes.OK]: true,
68
- });
69
- this.txDuration.record(Math.ceil(durationMs), attributes);
70
- this.txGas.record(
71
- // safe to downcast - total block limit is 30M gas which fits in a JS number
72
- Number(stats.gasUsed), attributes);
73
- this.txCalldataGas.record(stats.calldataGas, attributes);
74
- this.txCalldataSize.record(stats.calldataSize, attributes);
75
- this.txBlobDataGasCost.record(Number(stats.blobDataGas), attributes);
76
- this.txBlobDataGasUsed.record(Number(stats.blobGasUsed), attributes);
77
- try {
78
- this.gasPrice.record(parseInt(formatEther(stats.gasPrice, 'gwei'), 10));
79
- }
80
- catch (e) {
81
- // ignore
82
- }
83
- }
84
- }
85
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDEtcHVibGlzaGVyLW1ldHJpY3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHVibGlzaGVyL2wxLXB1Ymxpc2hlci1tZXRyaWNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFDTCxVQUFVLEVBRVYsT0FBTyxFQUdQLFNBQVMsR0FDVixNQUFNLHlCQUF5QixDQUFDO0FBRWpDLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxZQUFZLENBQUM7QUFJekMsTUFBTSxPQUFPLGtCQUFrQjtJQVc3QixZQUFZLE1BQXVCLEVBQUUsSUFBSSxHQUFHLGFBQWE7UUFDdkQsTUFBTSxLQUFLLEdBQUcsTUFBTSxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUVwQyxJQUFJLENBQUMsUUFBUSxHQUFHLEtBQUssQ0FBQyxlQUFlLENBQUMsT0FBTyxDQUFD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BQUMsRUFBRSxVQUFVLENBQUMsQ0FBQztRQUNyRSxJQUFJLENBQUMsaUJBQWlCLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLEVBQUUsVUFBVSxDQUFDLENBQUM7UUFFckUsSUFBSSxDQUFDO1lBQ0gsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFDLFdBQVcsQ0FBQyxLQUFLLENBQUMsUUFBUSxFQUFFLE1BQU0sQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDLENBQUM7UUFDMUUsQ0FBQztRQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUM7WUFDWCxTQUFTO1FBQ1gsQ0FBQztJQUNILENBQUM7Q0FDRiJ9
@@ -1,195 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { type BlobSinkClientInterface } from '@aztec/blob-sink/client';
4
- import { type EpochProofClaim, type EpochProofQuote, type L2Block, type TxHash } from '@aztec/circuit-types';
5
- import { AZTEC_MAX_EPOCH_DURATION, type BlockHeader, EthAddress, type Proof } from '@aztec/circuits.js';
6
- import { type FeeRecipient, type RootRollupPublicInputs } from '@aztec/circuits.js/rollup';
7
- import { type EthereumChain, type L1ContractsConfig } from '@aztec/ethereum';
8
- import { Blob } from '@aztec/foundation/blob';
9
- import { type Signature } from '@aztec/foundation/eth-signature';
10
- import { Fr } from '@aztec/foundation/fields';
11
- import { type Logger } from '@aztec/foundation/log';
12
- import { type Tuple } from '@aztec/foundation/serialize';
13
- import { RollupAbi } from '@aztec/l1-artifacts';
14
- import { type TelemetryClient } from '@aztec/telemetry-client';
15
- import { type Chain, type Client, type GetContractReturnType, type HttpTransport, type PrivateKeyAccount, type PublicActions, type PublicClient, type PublicRpcSchema, type WalletActions, type WalletClient, type WalletRpcSchema } from 'viem';
16
- import { type PublisherConfig, type TxSenderConfig } from './config.js';
17
- /**
18
- * Stats for a sent transaction.
19
- */
20
- export type TransactionStats = {
21
- /** Address of the sender. */
22
- sender: string;
23
- /** Hash of the transaction. */
24
- transactionHash: string;
25
- /** Size in bytes of the tx calldata */
26
- calldataSize: number;
27
- /** Gas required to pay for the calldata inclusion (depends on size and number of zeros) */
28
- calldataGas: number;
29
- };
30
- /**
31
- * Minimal information from a tx receipt.
32
- */
33
- export type MinimalTransactionReceipt = {
34
- /** True if the tx was successful, false if reverted. */
35
- status: boolean;
36
- /** Hash of the transaction. */
37
- transactionHash: `0x${string}`;
38
- /** Effective gas used by the tx. */
39
- gasUsed: bigint;
40
- /** Effective gas price paid by the tx. */
41
- gasPrice: bigint;
42
- /** Logs emitted in this tx. */
43
- logs: any[];
44
- /** Block number in which this tx was mined. */
45
- blockNumber: bigint;
46
- /** The block hash in which this tx was mined */
47
- blockHash: `0x${string}`;
48
- };
49
- /** Arguments to the submitEpochProof method of the rollup contract */
50
- export type L1SubmitEpochProofArgs = {
51
- epochSize: number;
52
- previousArchive: Fr;
53
- endArchive: Fr;
54
- previousBlockHash: Fr;
55
- endBlockHash: Fr;
56
- endTimestamp: Fr;
57
- outHash: Fr;
58
- proverId: Fr;
59
- fees: Tuple<FeeRecipient, typeof AZTEC_MAX_EPOCH_DURATION>;
60
- proof: Proof;
61
- };
62
- export declare enum VoteType {
63
- GOVERNANCE = 0,
64
- SLASHING = 1
65
- }
66
- type GetSlashPayloadCallBack = (slotNumber: bigint) => Promise<EthAddress | undefined>;
67
- /**
68
- * Publishes L2 blocks to L1. This implementation does *not* retry a transaction in
69
- * the event of network congestion, but should work for local development.
70
- * - If sending (not mining) a tx fails, it retries indefinitely at 1-minute intervals.
71
- * - If the tx is not mined, keeps polling indefinitely at 1-second intervals.
72
- *
73
- * Adapted from https://github.com/AztecProtocol/aztec2-internal/blob/master/falafel/src/rollup_publisher.ts.
74
- */
75
- export declare class L1Publisher {
76
- private interruptibleSleep;
77
- private sleepTimeMs;
78
- private interrupted;
79
- private metrics;
80
- protected governanceLog: Logger;
81
- protected governanceProposerAddress?: EthAddress;
82
- private governancePayload;
83
- protected slashingLog: Logger;
84
- protected slashingProposerAddress?: EthAddress;
85
- private getSlashPayload?;
86
- private myLastVotes;
87
- protected log: Logger;
88
- protected rollupContract: GetContractReturnType<typeof RollupAbi, WalletClient<HttpTransport, Chain, PrivateKeyAccount>>;
89
- protected publicClient: PublicClient<HttpTransport, Chain>;
90
- protected walletClient: WalletClient<HttpTransport, Chain, PrivateKeyAccount>;
91
- protected account: PrivateKeyAccount;
92
- protected ethereumSlotDuration: bigint;
93
- private blobSinkClient;
94
- static PROPOSE_GAS_GUESS: bigint;
95
- static PROPOSE_AND_CLAIM_GAS_GUESS: bigint;
96
- private readonly l1TxUtils;
97
- constructor(config: TxSenderConfig & PublisherConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>, deps?: {
98
- telemetry?: TelemetryClient;
99
- blobSinkClient?: BlobSinkClientInterface;
100
- });
101
- registerSlashPayloadGetter(callback: GetSlashPayloadCallBack): void;
102
- private getSlashingProposerAddress;
103
- get publisherAddress(): `0x${string}`;
104
- protected createWalletClient(account: PrivateKeyAccount, chain: EthereumChain): WalletClient<HttpTransport, Chain, PrivateKeyAccount>;
105
- getGovernancePayload(): EthAddress;
106
- setGovernancePayload(payload: EthAddress): void;
107
- getSenderAddress(): EthAddress;
108
- getClient(): Client<HttpTransport, Chain, PrivateKeyAccount, [
109
- ...WalletRpcSchema,
110
- ...PublicRpcSchema
111
- ], PublicActions<HttpTransport, Chain> & WalletActions<Chain, PrivateKeyAccount>>;
112
- getRollupContract(): GetContractReturnType<typeof RollupAbi, WalletClient<HttpTransport, Chain, PrivateKeyAccount>>;
113
- /**
114
- * @notice Calls `canProposeAtTime` with the time of the next Ethereum block and the sender address
115
- *
116
- * @dev Throws if unable to propose
117
- *
118
- * @param archive - The archive that we expect to be current state
119
- * @return slot - The L2 slot number of the next Ethereum block,
120
- * @return blockNumber - The L2 block number of the next L2 block
121
- */
122
- canProposeAtNextEthBlock(archive: Buffer): Promise<[bigint, bigint]>;
123
- getClaimableEpoch(): Promise<bigint | undefined>;
124
- getEpochForSlotNumber(slotNumber: bigint): Promise<bigint>;
125
- getEpochToProve(): Promise<bigint | undefined>;
126
- getProofClaim(): Promise<EpochProofClaim | undefined>;
127
- validateProofQuote(quote: EpochProofQuote): Promise<EpochProofQuote | undefined>;
128
- /**
129
- * @notice Will call `validateHeader` to make sure that it is possible to propose
130
- *
131
- * @dev Throws if unable to propose
132
- *
133
- * @param header - The header to propose
134
- * @param digest - The digest that attestations are signing over
135
- *
136
- */
137
- validateBlockForSubmission(header: BlockHeader, attestationData?: {
138
- digest: Buffer;
139
- signatures: Signature[];
140
- }): Promise<void>;
141
- getCurrentEpochCommittee(): Promise<EthAddress[]>;
142
- getTransactionStats(txHash: string): Promise<TransactionStats | undefined>;
143
- castVote(slotNumber: bigint, timestamp: bigint, voteType: VoteType): Promise<boolean>;
144
- /**
145
- * Proposes a L2 block on L1.
146
- * @param block - L2 block to propose.
147
- * @returns True once the tx has been confirmed and is successful, false on revert or interrupt, blocks otherwise.
148
- */
149
- proposeL2Block(block: L2Block, attestations?: Signature[], txHashes?: TxHash[], proofQuote?: EpochProofQuote, opts?: {
150
- txTimeoutAt?: Date;
151
- }): Promise<boolean>;
152
- /** Calls claimEpochProofRight in the Rollup contract to submit a chosen prover quote for the previous epoch. */
153
- claimEpochProofRight(proofQuote: EpochProofQuote): Promise<boolean>;
154
- private tryGetErrorFromRevertedTx;
155
- submitEpochProof(args: {
156
- epochNumber: number;
157
- fromBlock: number;
158
- toBlock: number;
159
- publicInputs: RootRollupPublicInputs;
160
- proof: Proof;
161
- }): Promise<boolean>;
162
- private validateEpochProofSubmission;
163
- /**
164
- * Calling `interrupt` will cause any in progress call to `publishRollup` to return `false` asap.
165
- * Be warned, the call may return false even if the tx subsequently gets successfully mined.
166
- * In practice this shouldn't matter, as we'll only ever be calling `interrupt` when we know it's going to fail.
167
- * A call to `restart` is required before you can continue publishing.
168
- */
169
- interrupt(): void;
170
- /** Restarts the publisher after calling `interrupt`. */
171
- restart(): void;
172
- private sendSubmitEpochProofTx;
173
- private prepareProposeTx;
174
- private getSubmitEpochProofArgs;
175
- private sendProposeTx;
176
- private sendProposeAndClaimTx;
177
- /**
178
- * Returns a tx receipt if the tx has been mined.
179
- * @param txHash - Hash of the tx to look for.
180
- * @returns Undefined if the tx hasn't been mined yet, the receipt otherwise.
181
- */
182
- getTransactionReceipt(txHash: string): Promise<MinimalTransactionReceipt | undefined>;
183
- protected sleepOrInterrupted(): Promise<void>;
184
- /**
185
- * Send blobs to the blob sink
186
- *
187
- * If a blob sink url is configured, then we send blobs to the blob sink
188
- * - for now we use the blockHash as the identifier for the blobs;
189
- * In the future this will move to be the beacon block id - which takes a bit more work
190
- * to calculate and will need to be mocked in e2e tests
191
- */
192
- protected sendBlobsToBlobSink(blockHash: string, blobs: Blob[]): Promise<boolean>;
193
- }
194
- export {};
195
- //# sourceMappingURL=l1-publisher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"l1-publisher.d.ts","sourceRoot":"","sources":["../../src/publisher/l1-publisher.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,OAAO,EAEZ,KAAK,MAAM,EAEZ,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,wBAAwB,EACxB,KAAK,WAAW,EAChB,UAAU,EACV,KAAK,KAAK,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAC3F,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,iBAAiB,EAIvB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,OAAO,EAAE,KAAK,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