@aztec/sequencer-client 0.0.1-commit.343b43af6 → 0.0.1-commit.350e0a4d
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 -16
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +49 -94
- package/dest/config.d.ts +10 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +61 -25
- 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 -66
- 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 +103 -67
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +621 -525
- 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 +75 -17
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +795 -239
- 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 +62 -5
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +13 -10
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +45 -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 +159 -35
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +585 -188
- 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/mock_checkpoint_builder.d.ts +4 -4
- package/dest/test/mock_checkpoint_builder.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 -29
- package/src/client/sequencer-client.ts +70 -124
- package/src/config.ts +71 -22
- 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 -88
- 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 +720 -600
- 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 +958 -265
- 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 +57 -24
- package/src/sequencer/requests_tracker.ts +43 -0
- package/src/sequencer/sequencer.ts +690 -209
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -2
- package/src/test/mock_checkpoint_builder.ts +3 -3
- 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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
2
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import { GasFees, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
4
|
+
import type { FeeProvider } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { GlobalVariableBuilderConfig } from './global_builder.js';
|
|
6
|
+
/** Provides current and predicted fee information based on on-chain state. */
|
|
7
|
+
export declare class FeeProviderImpl implements FeeProvider {
|
|
8
|
+
private readonly dateProvider;
|
|
9
|
+
private readonly publicClient;
|
|
10
|
+
private currentMinFees;
|
|
11
|
+
private currentL1BlockNumber;
|
|
12
|
+
private readonly rollupContract;
|
|
13
|
+
private readonly feePredictor;
|
|
14
|
+
private readonly ethereumSlotDuration;
|
|
15
|
+
private readonly l1GenesisTime;
|
|
16
|
+
constructor(dateProvider: DateProvider, publicClient: ViemPublicClient, config: GlobalVariableBuilderConfig);
|
|
17
|
+
private computeCurrentMinFees;
|
|
18
|
+
getCurrentMinFees(): Promise<GasFees>;
|
|
19
|
+
getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaW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OlF;CACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { getNextL1SlotTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
4
|
+
import { GasFees, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
5
|
+
import { FeePredictor } from './fee_predictor.js';
|
|
6
|
+
/** Provides current and predicted fee information based on on-chain state. */ export class FeeProviderImpl {
|
|
7
|
+
dateProvider;
|
|
8
|
+
publicClient;
|
|
9
|
+
currentMinFees;
|
|
10
|
+
currentL1BlockNumber;
|
|
11
|
+
rollupContract;
|
|
12
|
+
feePredictor;
|
|
13
|
+
ethereumSlotDuration;
|
|
14
|
+
l1GenesisTime;
|
|
15
|
+
constructor(dateProvider, publicClient, config){
|
|
16
|
+
this.dateProvider = dateProvider;
|
|
17
|
+
this.publicClient = publicClient;
|
|
18
|
+
this.currentMinFees = Promise.resolve(new GasFees(0, 0));
|
|
19
|
+
this.currentL1BlockNumber = undefined;
|
|
20
|
+
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
21
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
22
|
+
this.rollupContract = new RollupContract(this.publicClient, config.rollupAddress);
|
|
23
|
+
this.feePredictor = new FeePredictor(this.rollupContract, this.publicClient, this.dateProvider, {
|
|
24
|
+
slotDuration: config.slotDuration,
|
|
25
|
+
l1GenesisTime: config.l1GenesisTime,
|
|
26
|
+
ethereumSlotDuration: config.ethereumSlotDuration
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
31
|
+
* @returns Min fees for the next block
|
|
32
|
+
*/ async computeCurrentMinFees() {
|
|
33
|
+
// Since this might be called in the middle of a slot where a block might have been published,
|
|
34
|
+
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
35
|
+
// The timestamp of that last block will act as a lower bound for the next block.
|
|
36
|
+
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
37
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n));
|
|
38
|
+
const nextEthTimestamp = getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
39
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
40
|
+
ethereumSlotDuration: this.ethereumSlotDuration
|
|
41
|
+
});
|
|
42
|
+
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
43
|
+
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
44
|
+
}
|
|
45
|
+
async getCurrentMinFees() {
|
|
46
|
+
// Get the current block number
|
|
47
|
+
const blockNumber = await this.publicClient.getBlockNumber({
|
|
48
|
+
cacheTime: 0
|
|
49
|
+
});
|
|
50
|
+
// If the L1 block number has changed then chain a new promise to get the current min fees.
|
|
51
|
+
// We chain off the previous promise's settlement (via a swallowing catch) rather than its
|
|
52
|
+
// fulfillment, so a prior rejection does not short-circuit the new computation. If the new
|
|
53
|
+
// computation fails (e.g. a transient L1 RPC error), reset the cached block number so the
|
|
54
|
+
// next call recomputes instead of permanently replaying the rejected promise — otherwise a
|
|
55
|
+
// single transient failure would wedge fee estimation until the next L1 block arrives. Only
|
|
56
|
+
// clear it if it still points at the block this attempt was for, so a stale rejection from an
|
|
57
|
+
// older block cannot wipe a marker a newer call already advanced (which would also defeat the
|
|
58
|
+
// monotonic block-number guard).
|
|
59
|
+
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
60
|
+
this.currentL1BlockNumber = blockNumber;
|
|
61
|
+
this.currentMinFees = this.currentMinFees.catch(()=>undefined).then(()=>this.computeCurrentMinFees().catch((err)=>{
|
|
62
|
+
if (this.currentL1BlockNumber === blockNumber) {
|
|
63
|
+
this.currentL1BlockNumber = undefined;
|
|
64
|
+
}
|
|
65
|
+
throw err;
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
return this.currentMinFees;
|
|
69
|
+
}
|
|
70
|
+
async getPredictedMinFees(manaUsage) {
|
|
71
|
+
const [currentMinFees, predictedMinFees] = await Promise.all([
|
|
72
|
+
this.getCurrentMinFees(),
|
|
73
|
+
this.feePredictor.getPredictedMinFees(manaUsage ?? ManaUsageEstimate.Target)
|
|
74
|
+
]);
|
|
75
|
+
return [
|
|
76
|
+
currentMinFees,
|
|
77
|
+
...predictedMinFees
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1,41 +1,28 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
1
|
+
import { type SimulationOverridesPlan } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
3
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
7
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
8
7
|
import type { CheckpointGlobalVariables, GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
|
|
9
|
-
|
|
8
|
+
/** Configuration for the GlobalVariableBuilder (excludes L1 client config). */
|
|
9
|
+
export type GlobalVariableBuilderConfig = {
|
|
10
|
+
rollupAddress: EthAddress;
|
|
11
|
+
ethereumSlotDuration: number;
|
|
12
|
+
rollupVersion: bigint;
|
|
13
|
+
} & Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'>;
|
|
10
14
|
/**
|
|
11
15
|
* Simple global variables builder.
|
|
12
16
|
*/
|
|
13
17
|
export declare class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
14
|
-
private log;
|
|
15
|
-
private currentMinFees;
|
|
16
|
-
private currentL1BlockNumber;
|
|
17
|
-
private readonly rollupContract;
|
|
18
18
|
private readonly publicClient;
|
|
19
|
-
private readonly
|
|
19
|
+
private readonly rollupContract;
|
|
20
20
|
private readonly aztecSlotDuration;
|
|
21
21
|
private readonly l1GenesisTime;
|
|
22
22
|
private chainId;
|
|
23
23
|
private version;
|
|
24
|
-
constructor(
|
|
25
|
-
rollupVersion: bigint;
|
|
26
|
-
});
|
|
27
|
-
private computeCurrentMinFees;
|
|
28
|
-
getCurrentMinFees(): Promise<GasFees>;
|
|
29
|
-
/**
|
|
30
|
-
* Simple builder of global variables.
|
|
31
|
-
* @param blockNumber - The block number to build global variables for.
|
|
32
|
-
* @param coinbase - The address to receive block reward.
|
|
33
|
-
* @param feeRecipient - The address to receive fees.
|
|
34
|
-
* @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
|
|
35
|
-
* @returns The global variables for the given block number.
|
|
36
|
-
*/
|
|
37
|
-
buildGlobalVariables(blockNumber: BlockNumber, coinbase: EthAddress, feeRecipient: AztecAddress, maybeSlot?: SlotNumber): Promise<GlobalVariables>;
|
|
24
|
+
constructor(publicClient: ViemPublicClient, config: GlobalVariableBuilderConfig);
|
|
38
25
|
/** Builds global variables that are constant throughout a checkpoint. */
|
|
39
|
-
buildCheckpointGlobalVariables(coinbase: EthAddress, feeRecipient: AztecAddress, slotNumber: SlotNumber): Promise<CheckpointGlobalVariables>;
|
|
26
|
+
buildCheckpointGlobalVariables(coinbase: EthAddress, feeRecipient: AztecAddress, slotNumber: SlotNumber, simulationOverridesPlan?: SimulationOverridesPlan): Promise<CheckpointGlobalVariables>;
|
|
40
27
|
}
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYmFsX2J1aWxkZXIuZC50cyIsInNvdXJjZVJvb3QiO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BaUIsQ0FBUztJQUMzQyxPQUFPLENBQUMsUUFBUSxDQUFDLGFBQWEsQ0FBUztJQUV2QyxPQUFPLENBQUMsT0FBTyxDQUFLO0lBQ3BCLE9BQU8sQ0FBQyxPQUFPLENBQUs7SUFFcEIsWUFDbUIsWUFBWSxFQUFFLGdCQUFnQixFQUMvQyxNQUFNLEVBQUUsMkJBQTJCLEVBU3BDO0lBRUQseUVBQXlFO0lBQzVELDhCQUE4QixDQUN6QyxRQUFRLEVBQUUsVUFBVSxFQUNwQixZQUFZLEVBQUUsWUFBWSxFQUMxQixVQUFVLEVBQUUsVUFBVSxFQUN0Qix1QkFBdUIsQ0FBQyxFQUFFLHVCQUF1QixHQUNoRCxPQUFPLENBQUMseUJBQXlCLENBQUMsQ0FZcEM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global_builder.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/global_builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"global_builder.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/global_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAE7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,KAAK,iBAAiB,EAAuB,MAAM,6BAA6B,CAAC;AAE1F,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,IAAI,8BAA8B,EACxD,MAAM,kBAAkB,CAAC;AAE1B,+EAA+E;AAC/E,MAAM,MAAM,2BAA2B,GAAG;IACxC,aAAa,EAAE,UAAU,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,IAAI,CAAC,iBAAiB,EAAE,cAAc,GAAG,eAAe,CAAC,CAAC;AAE9D;;GAEG;AACH,qBAAa,qBAAsB,YAAW,8BAA8B;IASxE,OAAO,CAAC,QAAQ,CAAC,YAAY;IAR/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IAEpB,YACmB,YAAY,EAAE,gBAAgB,EAC/C,MAAM,EAAE,2BAA2B,EASpC;IAED,yEAAyE;IAC5D,8BAA8B,CACzC,QAAQ,EAAE,UAAU,EACpB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,uBAAuB,CAAC,EAAE,uBAAuB,GAChD,OAAO,CAAC,yBAAyB,CAAC,CAYpC;CACF"}
|
|
@@ -1,89 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
3
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { RollupContract, buildSimulationOverridesStateOverride } from '@aztec/ethereum/contracts';
|
|
4
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
6
3
|
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
7
4
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
8
|
-
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
9
|
-
import { createPublicClient, fallback, http } from 'viem';
|
|
10
5
|
/**
|
|
11
6
|
* Simple global variables builder.
|
|
12
7
|
*/ export class GlobalVariableBuilder {
|
|
13
|
-
log = createLogger('sequencer:global_variable_builder');
|
|
14
|
-
currentMinFees = Promise.resolve(new GasFees(0, 0));
|
|
15
|
-
currentL1BlockNumber = undefined;
|
|
16
|
-
rollupContract;
|
|
17
8
|
publicClient;
|
|
18
|
-
|
|
9
|
+
rollupContract;
|
|
19
10
|
aztecSlotDuration;
|
|
20
11
|
l1GenesisTime;
|
|
21
12
|
chainId;
|
|
22
13
|
version;
|
|
23
|
-
constructor(config){
|
|
24
|
-
|
|
25
|
-
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
14
|
+
constructor(publicClient, config){
|
|
15
|
+
this.publicClient = publicClient;
|
|
26
16
|
this.version = new Fr(config.rollupVersion);
|
|
27
|
-
this.chainId = new Fr(
|
|
28
|
-
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
17
|
+
this.chainId = new Fr(this.publicClient.chain.id);
|
|
29
18
|
this.aztecSlotDuration = config.slotDuration;
|
|
30
19
|
this.l1GenesisTime = config.l1GenesisTime;
|
|
31
|
-
this.
|
|
32
|
-
chain: chain.chainInfo,
|
|
33
|
-
transport: fallback(chain.rpcUrls.map((url)=>http(url, {
|
|
34
|
-
batch: false
|
|
35
|
-
}))),
|
|
36
|
-
pollingInterval: config.viemPollingIntervalMS
|
|
37
|
-
});
|
|
38
|
-
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
42
|
-
* @returns Min fees for the next block
|
|
43
|
-
*/ async computeCurrentMinFees() {
|
|
44
|
-
// Since this might be called in the middle of a slot where a block might have been published,
|
|
45
|
-
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
46
|
-
// The timestamp of that last block will act as a lower bound for the next block.
|
|
47
|
-
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
48
|
-
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n));
|
|
49
|
-
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
50
|
-
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
51
|
-
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
52
|
-
}
|
|
53
|
-
async getCurrentMinFees() {
|
|
54
|
-
// Get the current block number
|
|
55
|
-
const blockNumber = await this.publicClient.getBlockNumber();
|
|
56
|
-
// If the L1 block number has changed then chain a new promise to get the current min fees
|
|
57
|
-
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
58
|
-
this.currentL1BlockNumber = blockNumber;
|
|
59
|
-
this.currentMinFees = this.currentMinFees.then(()=>this.computeCurrentMinFees());
|
|
60
|
-
}
|
|
61
|
-
return this.currentMinFees;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Simple builder of global variables.
|
|
65
|
-
* @param blockNumber - The block number to build global variables for.
|
|
66
|
-
* @param coinbase - The address to receive block reward.
|
|
67
|
-
* @param feeRecipient - The address to receive fees.
|
|
68
|
-
* @param slotNumber - The slot number to use for the global variables, if undefined it will be calculated.
|
|
69
|
-
* @returns The global variables for the given block number.
|
|
70
|
-
*/ async buildGlobalVariables(blockNumber, coinbase, feeRecipient, maybeSlot) {
|
|
71
|
-
const slot = maybeSlot ?? await this.rollupContract.getSlotAt(BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration)));
|
|
72
|
-
const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
|
|
73
|
-
return GlobalVariables.from({
|
|
74
|
-
blockNumber,
|
|
75
|
-
...checkpointGlobalVariables
|
|
76
|
-
});
|
|
20
|
+
this.rollupContract = new RollupContract(this.publicClient, config.rollupAddress);
|
|
77
21
|
}
|
|
78
|
-
/** Builds global variables that are constant throughout a checkpoint. */ async buildCheckpointGlobalVariables(coinbase, feeRecipient, slotNumber) {
|
|
22
|
+
/** Builds global variables that are constant throughout a checkpoint. */ async buildCheckpointGlobalVariables(coinbase, feeRecipient, slotNumber, simulationOverridesPlan) {
|
|
79
23
|
const { chainId, version } = this;
|
|
80
24
|
const timestamp = getTimestampForSlot(slotNumber, {
|
|
81
25
|
slotDuration: this.aztecSlotDuration,
|
|
82
26
|
l1GenesisTime: this.l1GenesisTime
|
|
83
27
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
28
|
+
const stateOverride = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
|
|
29
|
+
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true, stateOverride));
|
|
87
30
|
return {
|
|
88
31
|
chainId,
|
|
89
32
|
version,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export { FeeProviderImpl } from './fee_provider.js';
|
|
2
|
+
export { GlobalVariableBuilder, type GlobalVariableBuilderConfig } from './global_builder.js';
|
|
3
|
+
export { FeePredictor } from './fee_predictor.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9nbG9iYWxfdmFyaWFibGVfYnVpbGRlci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDcEQsT0FBTyxFQUFFLHFCQUFxQixFQUFFLEtBQUssMkJBQTJCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUM5RixPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/global_variable_builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,KAAK,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -30,23 +30,39 @@ export type PublisherConfig = L1TxUtilsConfig & BlobClientConfig & {
|
|
|
30
30
|
publisherForwarderAddress?: EthAddress;
|
|
31
31
|
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
32
32
|
l1TxFailedStore?: string;
|
|
33
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
34
|
+
publisherFundingThreshold?: bigint;
|
|
35
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
36
|
+
publisherFundingAmount?: bigint;
|
|
33
37
|
};
|
|
34
38
|
export type ProverPublisherConfig = L1TxUtilsConfig & BlobClientConfig & {
|
|
35
39
|
fishermanMode?: boolean;
|
|
36
40
|
proverPublisherAllowInvalidStates?: boolean;
|
|
37
41
|
proverPublisherForwarderAddress?: EthAddress;
|
|
42
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
43
|
+
publisherFundingThreshold?: bigint;
|
|
44
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
45
|
+
publisherFundingAmount?: bigint;
|
|
38
46
|
};
|
|
39
47
|
export type SequencerPublisherConfig = L1TxUtilsConfig & BlobClientConfig & {
|
|
40
48
|
fishermanMode?: boolean;
|
|
41
49
|
sequencerPublisherAllowInvalidStates?: boolean;
|
|
42
50
|
sequencerPublisherForwarderAddress?: EthAddress;
|
|
51
|
+
/** How long to wait for the previous L1 block before sending scheduled publisher txs anyway. */
|
|
52
|
+
sequencerPublisherPreviousL1BlockWaitTimeoutMs: number;
|
|
53
|
+
/** Poll interval while waiting for the previous L1 block before scheduled publisher txs. */
|
|
54
|
+
sequencerPublisherPreviousL1BlockWaitPollIntervalMs: number;
|
|
43
55
|
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
44
56
|
l1TxFailedStore?: string;
|
|
57
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
58
|
+
publisherFundingThreshold?: bigint;
|
|
59
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
60
|
+
publisherFundingAmount?: bigint;
|
|
45
61
|
};
|
|
46
62
|
export declare function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig;
|
|
47
63
|
export declare function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig;
|
|
48
|
-
export declare const proverTxSenderConfigMappings: ConfigMappingsType<
|
|
49
|
-
export declare const sequencerTxSenderConfigMappings: ConfigMappingsType<
|
|
64
|
+
export declare const proverTxSenderConfigMappings: ConfigMappingsType<ProverTxSenderConfig>;
|
|
65
|
+
export declare const sequencerTxSenderConfigMappings: ConfigMappingsType<SequencerTxSenderConfig>;
|
|
50
66
|
export declare const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig>;
|
|
51
67
|
export declare const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig>;
|
|
52
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
68
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHVibGlzaGVyL2NvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQU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oBAAoB,CAgBjF,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,kBAAkB,CAAC,uBAAuB,CAgBvF,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,kBAAkB,CAAC,wBAAwB,GAAG,eAAe,CAoC3G,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,kBAAkB,CAAC,qBAAqB,GAAG,eAAe,CAoBrG,CAAC"}
|
package/dest/publisher/config.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
2
|
import { l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
3
3
|
import { l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils/config';
|
|
4
|
-
import { SecretValue, booleanConfigHelper } from '@aztec/foundation/config';
|
|
4
|
+
import { SecretValue, booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
|
|
5
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
import { parseEther } from 'viem';
|
|
6
7
|
export function getTxSenderConfigFromProverConfig(config) {
|
|
7
8
|
return {
|
|
8
9
|
...config,
|
|
@@ -17,6 +18,18 @@ export function getTxSenderConfigFromSequencerConfig(config) {
|
|
|
17
18
|
publisherAddresses: config.sequencerPublisherAddresses
|
|
18
19
|
};
|
|
19
20
|
}
|
|
21
|
+
/** Shared config mappings for publisher funding, used by both sequencer and prover publisher configs. */ const publisherFundingConfigMappings = {
|
|
22
|
+
publisherFundingThreshold: {
|
|
23
|
+
env: 'PUBLISHER_FUNDING_THRESHOLD',
|
|
24
|
+
description: 'Min ETH balance below which a publisher gets funded. Specified in ether (e.g. 0.1). Unset = funding disabled.',
|
|
25
|
+
parseEnv: (val)=>parseEther(val)
|
|
26
|
+
},
|
|
27
|
+
publisherFundingAmount: {
|
|
28
|
+
env: 'PUBLISHER_FUNDING_AMOUNT',
|
|
29
|
+
description: 'Amount of ETH to send when funding a publisher. Specified in ether (e.g. 0.5). Unset = funding disabled.',
|
|
30
|
+
parseEnv: (val)=>parseEther(val)
|
|
31
|
+
}
|
|
32
|
+
};
|
|
20
33
|
export function getPublisherConfigFromProverConfig(config) {
|
|
21
34
|
return {
|
|
22
35
|
...config,
|
|
@@ -84,12 +97,23 @@ export const sequencerPublisherConfigMappings = {
|
|
|
84
97
|
sequencerPublisherForwarderAddress: {
|
|
85
98
|
env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
|
|
86
99
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
87
|
-
parseEnv: (val)=>
|
|
100
|
+
parseEnv: (val)=>EthAddress.fromString(val)
|
|
101
|
+
},
|
|
102
|
+
sequencerPublisherPreviousL1BlockWaitTimeoutMs: {
|
|
103
|
+
env: `SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_TIMEOUT_MS`,
|
|
104
|
+
description: 'How long to wait for the previous L1 block before sending scheduled publisher txs anyway, in milliseconds.',
|
|
105
|
+
...numberConfigHelper(8_000)
|
|
106
|
+
},
|
|
107
|
+
sequencerPublisherPreviousL1BlockWaitPollIntervalMs: {
|
|
108
|
+
env: `SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_POLL_INTERVAL_MS`,
|
|
109
|
+
description: 'Poll interval while waiting for the previous L1 block before scheduled publisher txs, in milliseconds.',
|
|
110
|
+
...numberConfigHelper(500)
|
|
88
111
|
},
|
|
89
112
|
l1TxFailedStore: {
|
|
90
113
|
env: 'L1_TX_FAILED_STORE',
|
|
91
114
|
description: 'Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path'
|
|
92
|
-
}
|
|
115
|
+
},
|
|
116
|
+
...publisherFundingConfigMappings
|
|
93
117
|
};
|
|
94
118
|
export const proverPublisherConfigMappings = {
|
|
95
119
|
...l1TxUtilsConfigMappings,
|
|
@@ -107,6 +131,7 @@ export const proverPublisherConfigMappings = {
|
|
|
107
131
|
proverPublisherForwarderAddress: {
|
|
108
132
|
env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
|
|
109
133
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
110
|
-
parseEnv: (val)=>
|
|
111
|
-
}
|
|
134
|
+
parseEnv: (val)=>EthAddress.fromString(val)
|
|
135
|
+
},
|
|
136
|
+
...publisherFundingConfigMappings
|
|
112
137
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
2
|
+
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
/**
|
|
6
|
+
* Sends an L1-to-L2 message via the Inbox contract and returns its hash and global leaf index.
|
|
7
|
+
* Test helper copied from the end-to-end fixtures so this integration test can live in sequencer-client.
|
|
8
|
+
*/
|
|
9
|
+
export declare function sendL1ToL2Message(message: {
|
|
10
|
+
recipient: AztecAddress;
|
|
11
|
+
content: Fr;
|
|
12
|
+
secretHash: Fr;
|
|
13
|
+
}, ctx: {
|
|
14
|
+
l1Client: ExtendedViemWalletClient;
|
|
15
|
+
l1ContractAddresses: Pick<L1ContractAddresses, 'inboxAddress' | 'rollupAddress'>;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
msgHash: Fr;
|
|
18
|
+
globalLeafIndex: Fr;
|
|
19
|
+
txReceipt: import("viem").TransactionReceipt;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDFfdG9fbDJfbWVzc2FnaW5nLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHVibGlzaGVyL2wxX3RvX2wyX21lc3NhZ2luZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssR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,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,EAAE,cAAc,GAAG,eAAe,CAAC,CAAC;CAClF;;;;GAgEF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { tryJsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { InboxAbi } from '@aztec/l1-artifacts';
|
|
6
|
+
import { decodeEventLog, getContract } from 'viem';
|
|
7
|
+
/**
|
|
8
|
+
* Sends an L1-to-L2 message via the Inbox contract and returns its hash and global leaf index.
|
|
9
|
+
* Test helper copied from the end-to-end fixtures so this integration test can live in sequencer-client.
|
|
10
|
+
*/ export async function sendL1ToL2Message(message, ctx) {
|
|
11
|
+
const logger = createLogger('sequencer-client:l1_to_l2_messaging');
|
|
12
|
+
const inbox = getContract({
|
|
13
|
+
address: ctx.l1ContractAddresses.inboxAddress.toString(),
|
|
14
|
+
abi: InboxAbi,
|
|
15
|
+
client: ctx.l1Client
|
|
16
|
+
});
|
|
17
|
+
const { recipient, content, secretHash } = message;
|
|
18
|
+
const version = await new RollupContract(ctx.l1Client, ctx.l1ContractAddresses.rollupAddress.toString()).getVersion();
|
|
19
|
+
// We inject the message to Inbox
|
|
20
|
+
const txHash = await inbox.write.sendL2Message([
|
|
21
|
+
{
|
|
22
|
+
actor: recipient.toString(),
|
|
23
|
+
version: BigInt(version)
|
|
24
|
+
},
|
|
25
|
+
content.toString(),
|
|
26
|
+
secretHash.toString()
|
|
27
|
+
], {
|
|
28
|
+
gas: 1_000_000n
|
|
29
|
+
});
|
|
30
|
+
logger.info(`L1 to L2 message sent in tx ${txHash}`);
|
|
31
|
+
// We check that the message was correctly injected by checking the emitted event
|
|
32
|
+
const txReceipt = await ctx.l1Client.waitForTransactionReceipt({
|
|
33
|
+
hash: txHash
|
|
34
|
+
});
|
|
35
|
+
if (txReceipt.status !== 'success') {
|
|
36
|
+
throw new Error(`L1 to L2 message failed to be sent in tx ${txHash}. Status: ${txReceipt.status}`);
|
|
37
|
+
}
|
|
38
|
+
logger.info(`L1 to L2 message receipt retrieved for tx ${txReceipt.transactionHash}`, txReceipt);
|
|
39
|
+
if (txReceipt.transactionHash !== txHash) {
|
|
40
|
+
throw new Error(`Receipt transaction hash mismatch: ${txReceipt.transactionHash} !== ${txHash}`);
|
|
41
|
+
}
|
|
42
|
+
// Filter for MessageSent events from the Inbox contract by trying to decode each log
|
|
43
|
+
const messageSentLogs = txReceipt.logs.filter((log)=>log.address.toLowerCase() === ctx.l1ContractAddresses.inboxAddress.toString().toLowerCase()).map((log)=>{
|
|
44
|
+
try {
|
|
45
|
+
const decoded = decodeEventLog({
|
|
46
|
+
abi: InboxAbi,
|
|
47
|
+
data: log.data,
|
|
48
|
+
topics: log.topics
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
log,
|
|
52
|
+
decoded
|
|
53
|
+
};
|
|
54
|
+
} catch {
|
|
55
|
+
return null; // Not a decodable event from this ABI
|
|
56
|
+
}
|
|
57
|
+
}).filter((item)=>item !== null && item.decoded.eventName === 'MessageSent');
|
|
58
|
+
if (messageSentLogs.length !== 1) {
|
|
59
|
+
throw new Error(`Wrong number of MessageSent logs found in ${txHash} transaction (got ${messageSentLogs.length} expected 1)\n${tryJsonStringify(messageSentLogs.map((item)=>item.log))}`);
|
|
60
|
+
}
|
|
61
|
+
// We already have the decoded event
|
|
62
|
+
const topics = messageSentLogs[0].decoded;
|
|
63
|
+
const receivedMsgHash = topics.args.hash;
|
|
64
|
+
const receivedGlobalLeafIndex = topics.args.index;
|
|
65
|
+
return {
|
|
66
|
+
msgHash: Fr.fromHexString(receivedMsgHash),
|
|
67
|
+
globalLeafIndex: new Fr(receivedGlobalLeafIndex),
|
|
68
|
+
txReceipt
|
|
69
|
+
};
|
|
70
|
+
}
|