@aztec/ethereum 0.0.0-test.0 → 0.0.1-commit.21caa21
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/dest/account.d.ts +2 -0
- package/dest/account.d.ts.map +1 -0
- package/dest/account.js +4 -0
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +6 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +16 -2
- package/dest/config.d.ts +111 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +462 -22
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +24 -8
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +75 -2
- package/dest/contracts/empire_slashing_proposer.d.ts +66 -0
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/empire_slashing_proposer.js +200 -0
- package/dest/contracts/errors.d.ts +7 -0
- package/dest/contracts/errors.d.ts.map +1 -0
- package/dest/contracts/errors.js +12 -0
- package/dest/contracts/fee_asset_handler.d.ts +19 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
- package/dest/contracts/fee_asset_handler.js +57 -0
- package/dest/contracts/fee_juice.d.ts +6 -7
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/fee_juice.js +27 -20
- package/dest/contracts/governance.d.ts +43 -32
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +87 -84
- package/dest/contracts/governance_proposer.d.ts +16 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +37 -17
- package/dest/contracts/gse.d.ts +32 -0
- package/dest/contracts/gse.d.ts.map +1 -0
- package/dest/contracts/gse.js +72 -0
- package/dest/contracts/inbox.d.ts +26 -0
- package/dest/contracts/inbox.d.ts.map +1 -0
- package/dest/contracts/inbox.js +45 -0
- package/dest/contracts/index.d.ts +9 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +8 -2
- package/dest/contracts/multicall.d.ts +21 -0
- package/dest/contracts/multicall.d.ts.map +1 -0
- package/dest/contracts/multicall.js +156 -0
- package/dest/contracts/registry.d.ts +10 -5
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +44 -16
- package/dest/contracts/rollup.d.ts +204 -40
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +529 -79
- package/dest/contracts/slasher_contract.d.ts +44 -0
- package/dest/contracts/slasher_contract.d.ts.map +1 -0
- package/dest/contracts/slasher_contract.js +75 -0
- package/dest/contracts/tally_slashing_proposer.d.ts +139 -0
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/tally_slashing_proposer.js +313 -0
- package/dest/contracts/utils.d.ts +3 -0
- package/dest/contracts/utils.d.ts.map +1 -0
- package/dest/contracts/utils.js +11 -0
- package/dest/deploy_l1_contracts.d.ts +577 -21114
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +1225 -421
- package/dest/eth-signer/eth-signer.d.ts +21 -0
- package/dest/eth-signer/eth-signer.d.ts.map +1 -0
- package/dest/eth-signer/eth-signer.js +5 -0
- package/dest/eth-signer/index.d.ts +2 -0
- package/dest/eth-signer/index.d.ts.map +1 -0
- package/dest/eth-signer/index.js +1 -0
- package/dest/index.d.ts +7 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +6 -2
- package/dest/l1_artifacts.d.ts +77344 -0
- package/dest/l1_artifacts.d.ts.map +1 -0
- package/dest/l1_artifacts.js +166 -0
- package/dest/l1_contract_addresses.d.ts +24 -4
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +22 -18
- package/dest/l1_reader.d.ts +2 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +8 -8
- package/dest/l1_tx_utils/config.d.ts +59 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +82 -0
- package/dest/l1_tx_utils/constants.d.ts +6 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +14 -0
- package/dest/l1_tx_utils/factory.d.ts +24 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +12 -0
- package/dest/l1_tx_utils/index.d.ts +10 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +10 -0
- package/dest/l1_tx_utils/interfaces.d.ts +76 -0
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
- package/dest/l1_tx_utils/interfaces.js +4 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +94 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +610 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +94 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +430 -0
- package/dest/l1_tx_utils/signer.d.ts +4 -0
- package/dest/l1_tx_utils/signer.d.ts.map +1 -0
- package/dest/l1_tx_utils/signer.js +16 -0
- package/dest/l1_tx_utils/types.d.ts +67 -0
- package/dest/l1_tx_utils/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/types.js +26 -0
- package/dest/l1_tx_utils/utils.d.ts +4 -0
- package/dest/l1_tx_utils/utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/utils.js +14 -0
- package/dest/l1_types.d.ts +6 -0
- package/dest/l1_types.d.ts.map +1 -0
- package/dest/l1_types.js +1 -0
- package/dest/publisher_manager.d.ts +15 -0
- package/dest/publisher_manager.d.ts.map +1 -0
- package/dest/publisher_manager.js +88 -0
- package/dest/queries.d.ts +4 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +53 -12
- package/dest/test/chain_monitor.d.ts +73 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +215 -0
- package/dest/test/delayed_tx_utils.d.ts +8 -3
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/delayed_tx_utils.js +13 -6
- package/dest/test/eth_cheat_codes.d.ts +217 -0
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/test/eth_cheat_codes.js +558 -0
- package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes_with_state.js +1 -1
- package/dest/test/index.d.ts +4 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -0
- package/dest/test/rollup_cheat_codes.d.ts +87 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +266 -0
- package/dest/test/start_anvil.d.ts +7 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +16 -7
- package/dest/test/tx_delayer.d.ts +18 -7
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +95 -19
- package/dest/test/upgrade_utils.d.ts +6 -5
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +23 -16
- package/dest/types.d.ts +7 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +2 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +43 -88
- package/dest/zkPassportVerifierAddress.d.ts +15 -0
- package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
- package/dest/zkPassportVerifierAddress.js +11 -0
- package/package.json +28 -19
- package/src/account.ts +5 -0
- package/src/client.ts +42 -4
- package/src/config.ts +592 -31
- package/src/contracts/empire_base.ts +77 -7
- package/src/contracts/empire_slashing_proposer.ts +265 -0
- package/src/contracts/errors.ts +13 -0
- package/src/contracts/fee_asset_handler.ts +63 -0
- package/src/contracts/fee_juice.ts +29 -15
- package/src/contracts/governance.ts +80 -77
- package/src/contracts/governance_proposer.ts +66 -24
- package/src/contracts/gse.ts +88 -0
- package/src/contracts/inbox.ts +63 -0
- package/src/contracts/index.ts +8 -2
- package/src/contracts/multicall.ts +155 -0
- package/src/contracts/registry.ts +51 -26
- package/src/contracts/rollup.ts +596 -74
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/tally_slashing_proposer.ts +316 -0
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_l1_contracts.ts +1459 -538
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/index.ts +6 -2
- package/src/l1_artifacts.ts +254 -0
- package/src/l1_contract_addresses.ts +32 -19
- package/src/l1_reader.ts +9 -9
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +143 -0
- package/src/l1_tx_utils/constants.ts +18 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- package/src/l1_tx_utils/index.ts +12 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +718 -0
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +558 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/types.ts +85 -0
- package/src/l1_tx_utils/utils.ts +16 -0
- package/src/l1_types.ts +6 -0
- package/src/publisher_manager.ts +106 -0
- package/src/queries.ts +73 -15
- package/src/test/chain_monitor.ts +243 -0
- package/src/test/delayed_tx_utils.ts +34 -6
- package/src/test/eth_cheat_codes.ts +588 -0
- package/src/test/eth_cheat_codes_with_state.ts +1 -1
- package/src/test/index.ts +3 -0
- package/src/test/rollup_cheat_codes.ts +307 -0
- package/src/test/start_anvil.ts +22 -5
- package/src/test/tx_delayer.ts +127 -26
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +10 -8
- package/src/utils.ts +49 -90
- package/src/zkPassportVerifierAddress.ts +15 -0
- package/dest/contracts/forwarder.d.ts +0 -24
- package/dest/contracts/forwarder.d.ts.map +0 -1
- package/dest/contracts/forwarder.js +0 -101
- package/dest/contracts/slashing_proposer.d.ts +0 -21
- package/dest/contracts/slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/slashing_proposer.js +0 -47
- package/dest/eth_cheat_codes.d.ts +0 -147
- package/dest/eth_cheat_codes.d.ts.map +0 -1
- package/dest/eth_cheat_codes.js +0 -303
- package/dest/l1_tx_utils.d.ts +0 -192
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -641
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -64
- package/src/contracts/forwarder.ts +0 -132
- package/src/contracts/slashing_proposer.ts +0 -51
- package/src/eth_cheat_codes.ts +0 -314
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export var TxUtilsState = /*#__PURE__*/ function(TxUtilsState) {
|
|
2
|
+
TxUtilsState[TxUtilsState["IDLE"] = 0] = "IDLE";
|
|
3
|
+
TxUtilsState[TxUtilsState["SENT"] = 1] = "SENT";
|
|
4
|
+
TxUtilsState[TxUtilsState["SPEED_UP"] = 2] = "SPEED_UP";
|
|
5
|
+
TxUtilsState[TxUtilsState["CANCELLED"] = 3] = "CANCELLED";
|
|
6
|
+
TxUtilsState[TxUtilsState["NOT_MINED"] = 4] = "NOT_MINED";
|
|
7
|
+
TxUtilsState[TxUtilsState["MINED"] = 5] = "MINED";
|
|
8
|
+
return TxUtilsState;
|
|
9
|
+
}({});
|
|
10
|
+
export const TerminalTxUtilsState = [
|
|
11
|
+
0,
|
|
12
|
+
5,
|
|
13
|
+
4
|
|
14
|
+
];
|
|
15
|
+
export class UnknownMinedTxError extends Error {
|
|
16
|
+
constructor(nonce, account){
|
|
17
|
+
super(`Nonce ${nonce} from account ${account} is MINED but not by one of our expected transactions`);
|
|
18
|
+
this.name = 'UnknownMinedTxError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class DroppedTransactionError extends Error {
|
|
22
|
+
constructor(nonce, account){
|
|
23
|
+
super(`Transaction with nonce ${nonce} from account ${account} was dropped from the mempool`);
|
|
24
|
+
this.name = 'DroppedTransactionError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ContractFunctionExecutionError } from 'viem';
|
|
2
|
+
export declare function tryGetCustomErrorNameContractFunction(err: ContractFunctionExecutionError): string;
|
|
3
|
+
export declare function getCalldataGasUsage(data: Uint8Array): number;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMV90eF91dGlscy91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEtBQUssRUFBRSw4QkFBOEIsRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUUzRCx3QkFBZ0IscUNBQXFDLENBQUMsR0FBRyxFQUFFLDhCQUE4QixVQUV4RjtBQU9ELHdCQUFnQixtQkFBbUIsQ0FBQyxJQUFJLEVBQUUsVUFBVSxVQUVuRCJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,MAAM,CAAC;AAE3D,wBAAgB,qCAAqC,CAAC,GAAG,EAAE,8BAA8B,UAExF;AAOD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,UAEnD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { compactArray } from '@aztec/foundation/collection';
|
|
2
|
+
export function tryGetCustomErrorNameContractFunction(err) {
|
|
3
|
+
return compactArray([
|
|
4
|
+
err.shortMessage,
|
|
5
|
+
...(err.metaMessages ?? []).slice(0, 2).map((s)=>s.trim())
|
|
6
|
+
]).join(' ');
|
|
7
|
+
}
|
|
8
|
+
/*
|
|
9
|
+
* Returns cost of calldata usage in Ethereum.
|
|
10
|
+
* @param data - Calldata.
|
|
11
|
+
* @returns 4 for each zero byte, 16 for each nonzero.
|
|
12
|
+
*/ export function getCalldataGasUsage(data) {
|
|
13
|
+
return data.filter((byte)=>byte === 0).length * 4 + data.filter((byte)=>byte !== 0).length * 16;
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
+
export type L1BlockId = {
|
|
3
|
+
l1BlockNumber: bigint;
|
|
4
|
+
l1BlockHash: Buffer32;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDFfdHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9sMV90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUV6RCxNQUFNLE1BQU0sU0FBUyxHQUFHO0lBQ3RCLGFBQWEsRUFBRSxNQUFNLENBQUM7SUFDdEIsV0FBVyxFQUFFLFFBQVEsQ0FBQztDQUN2QixDQUFDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l1_types.d.ts","sourceRoot":"","sources":["../src/l1_types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,MAAM,SAAS,GAAG;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,QAAQ,CAAC;CACvB,CAAC"}
|
package/dest/l1_types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { L1TxUtils } from './l1_tx_utils/index.js';
|
|
2
|
+
export type PublisherFilter<UtilsType extends L1TxUtils> = (utils: UtilsType) => boolean;
|
|
3
|
+
export declare class PublisherManager<UtilsType extends L1TxUtils = L1TxUtils> {
|
|
4
|
+
private publishers;
|
|
5
|
+
private log;
|
|
6
|
+
private config;
|
|
7
|
+
constructor(publishers: UtilsType[], config: {
|
|
8
|
+
publisherAllowInvalidStates?: boolean;
|
|
9
|
+
});
|
|
10
|
+
/** Loads the state of all publishers and resumes monitoring any pending txs */
|
|
11
|
+
loadState(): Promise<void>;
|
|
12
|
+
getAvailablePublisher(filter?: PublisherFilter<UtilsType>): Promise<UtilsType>;
|
|
13
|
+
interrupt(): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGlzaGVyX21hbmFnZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9wdWJsaXNoZXJfbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHQSxPQUFPLEVBQUUsU0FBUyxFQUFnQixNQUFNLHdCQUF3QixDQUFDO0FBd0JqRSxNQUFNLE1BQU0sZUFBZSxDQUFDLFNBQVMsU0FBUyxTQUFTLElBQUksQ0FBQyxLQUFLLEVBQUUsU0FBUyxLQUFLLE9BQU8sQ0FB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CAAc,GAAG,OAAO,CAAC,SAAS,CAAC,CA+CtG;IAEM,SAAS,SAEf;CACF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { pick } from '@aztec/foundation/collection';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { TxUtilsState } from './l1_tx_utils/index.js';
|
|
4
|
+
// Defines the order in which we prioritise publishers based on their state (first is better)
|
|
5
|
+
const sortOrder = [
|
|
6
|
+
// Always prefer sending from idle publishers
|
|
7
|
+
TxUtilsState.IDLE,
|
|
8
|
+
// Then from publishers that have sent a tx and it got mined
|
|
9
|
+
TxUtilsState.MINED,
|
|
10
|
+
// Then from publishers that have sent a tx but it's in-flight
|
|
11
|
+
TxUtilsState.SPEED_UP,
|
|
12
|
+
TxUtilsState.SENT,
|
|
13
|
+
// We leave cancelled and not-mined states for last, since these represent failures to mines and could be problematic
|
|
14
|
+
TxUtilsState.CANCELLED,
|
|
15
|
+
TxUtilsState.NOT_MINED
|
|
16
|
+
];
|
|
17
|
+
// Which states represent a busy publisher that we should avoid if possible
|
|
18
|
+
const busyStates = [
|
|
19
|
+
TxUtilsState.SENT,
|
|
20
|
+
TxUtilsState.SPEED_UP,
|
|
21
|
+
TxUtilsState.CANCELLED,
|
|
22
|
+
TxUtilsState.NOT_MINED
|
|
23
|
+
];
|
|
24
|
+
export class PublisherManager {
|
|
25
|
+
publishers;
|
|
26
|
+
log;
|
|
27
|
+
config;
|
|
28
|
+
constructor(publishers, config){
|
|
29
|
+
this.publishers = publishers;
|
|
30
|
+
this.log = createLogger('publisher:manager');
|
|
31
|
+
this.log.info(`PublisherManager initialized with ${publishers.length} publishers.`);
|
|
32
|
+
this.publishers = publishers;
|
|
33
|
+
this.config = pick(config, 'publisherAllowInvalidStates');
|
|
34
|
+
}
|
|
35
|
+
/** Loads the state of all publishers and resumes monitoring any pending txs */ async loadState() {
|
|
36
|
+
await Promise.all(this.publishers.map((pub)=>pub.loadStateAndResumeMonitoring()));
|
|
37
|
+
}
|
|
38
|
+
// Finds and prioritises available publishers based on
|
|
39
|
+
// 1. Validity as per the provided filter function
|
|
40
|
+
// 2. Validity based on the state the publisher is in
|
|
41
|
+
// 3. Priority based on state as defined by sortOrder
|
|
42
|
+
// 4. Then priority based on highest balance
|
|
43
|
+
// 5. Then priority based on least recently used
|
|
44
|
+
async getAvailablePublisher(filter = ()=>true) {
|
|
45
|
+
this.log.debug(`Getting available publisher`, {
|
|
46
|
+
publishers: this.publishers.map((p)=>({
|
|
47
|
+
address: p.getSenderAddress(),
|
|
48
|
+
state: p.state,
|
|
49
|
+
lastMined: p.lastMinedAtBlockNumber
|
|
50
|
+
}))
|
|
51
|
+
});
|
|
52
|
+
// Extract the valid publishers
|
|
53
|
+
let validPublishers = this.publishers.filter((pub)=>!busyStates.includes(pub.state) && filter(pub));
|
|
54
|
+
// If none found but we allow invalid (busy) states, try again including them
|
|
55
|
+
if (validPublishers.length === 0 && this.config.publisherAllowInvalidStates) {
|
|
56
|
+
this.log.warn(`No valid publishers found. Trying again including invalid states.`);
|
|
57
|
+
validPublishers = this.publishers.filter((pub)=>filter(pub));
|
|
58
|
+
}
|
|
59
|
+
// Error if none found
|
|
60
|
+
if (validPublishers.length === 0) {
|
|
61
|
+
throw new Error(`Failed to find an available publisher.`);
|
|
62
|
+
}
|
|
63
|
+
// Get the balances
|
|
64
|
+
const publishersWithBalance = await Promise.all(validPublishers.map(async (pub)=>{
|
|
65
|
+
return {
|
|
66
|
+
balance: await pub.getSenderBalance(),
|
|
67
|
+
publisher: pub
|
|
68
|
+
};
|
|
69
|
+
}));
|
|
70
|
+
// Sort based on state, then balance, then time since last use
|
|
71
|
+
const sortedPublishers = publishersWithBalance.sort((a, b)=>{
|
|
72
|
+
const stateComparison = sortOrder.indexOf(a.publisher.state) - sortOrder.indexOf(b.publisher.state);
|
|
73
|
+
if (stateComparison !== 0) {
|
|
74
|
+
return stateComparison;
|
|
75
|
+
}
|
|
76
|
+
const balanceComparison = Number(b.balance - a.balance);
|
|
77
|
+
if (balanceComparison !== 0) {
|
|
78
|
+
return balanceComparison;
|
|
79
|
+
}
|
|
80
|
+
const lastUsedComparison = Number((a.publisher.lastMinedAtBlockNumber ?? 0n) - (b.publisher.lastMinedAtBlockNumber ?? 0n));
|
|
81
|
+
return lastUsedComparison;
|
|
82
|
+
});
|
|
83
|
+
return sortedPublishers[0].publisher;
|
|
84
|
+
}
|
|
85
|
+
interrupt() {
|
|
86
|
+
this.publishers.forEach((pub)=>pub.interrupt());
|
|
87
|
+
}
|
|
88
|
+
}
|
package/dest/queries.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { L1ContractsConfig } from './config.js';
|
|
3
3
|
import type { ViemPublicClient } from './types.js';
|
|
4
4
|
/** Reads the L1ContractsConfig from L1 contracts. */
|
|
@@ -8,5 +8,7 @@ export declare function getL1ContractsConfig(publicClient: ViemPublicClient, add
|
|
|
8
8
|
}): Promise<Omit<L1ContractsConfig, 'ethereumSlotDuration'> & {
|
|
9
9
|
l1StartBlock: bigint;
|
|
10
10
|
l1GenesisTime: bigint;
|
|
11
|
+
rollupVersion: number;
|
|
12
|
+
genesisArchiveTreeRoot: `0x${string}`;
|
|
11
13
|
}>;
|
|
12
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVlcmllcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3F1ZXJpZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTNELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sYUFBYSxDQUFDO0FBSXJELE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sWUFBWSxDQUFDO0FBRW5ELHFEQUFxRDtBQUNyRCx3QkFBc0Isb0JBQW9CLENBQ3hDLFlBQVksRUFBRSxnQkFBZ0IsRUFDOUIsU0FBUyxFQUFFO0lBQUUsaUJBQWlCLEVBQUUsVUFBVSxDQUFDO0lBQUMsYUFBYSxDQUFDLEVBQUUsVUFBVSxDQUFBO0NBQUUsR0FDdkUsT0FBTyxDQUNSLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxzQkFBc0IsQ0FBQyxHQUFHO0lBQ2hELFlBQVksRUFBRSxNQUFNLENBQUM7SUFDckIsYUFBYSxFQUFFLE1BQU0sQ0FBQztJQUN0QixhQUFhLEVBQUUsTUFBTSxDQUFDO0lBQ3RCLHNCQUFzQixFQUFFLEtBQUssTUFBTSxFQUFFLENBQUM7Q0FDdkMsQ0FDRixDQWdHQSJ9
|
package/dest/queries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,qDAAqD;AACrD,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,gBAAgB,EAC9B,SAAS,EAAE;IAAE,iBAAiB,EAAE,UAAU,CAAC;IAAC,aAAa,CAAC,EAAE,UAAU,CAAA;CAAE,GACvE,OAAO,CACR,IAAI,CAAC,iBAAiB,EAAE,sBAAsB,CAAC,GAAG;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,sBAAsB,EAAE,KAAK,MAAM,EAAE,CAAC;CACvC,CACF,CAgGA"}
|
package/dest/queries.js
CHANGED
|
@@ -1,35 +1,76 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { ReadOnlyGovernanceContract } from './contracts/governance.js';
|
|
3
|
+
import { GovernanceProposerContract } from './contracts/governance_proposer.js';
|
|
2
4
|
import { RollupContract } from './contracts/rollup.js';
|
|
3
5
|
/** Reads the L1ContractsConfig from L1 contracts. */ export async function getL1ContractsConfig(publicClient, addresses) {
|
|
4
|
-
const governance = new
|
|
5
|
-
const
|
|
6
|
-
const
|
|
6
|
+
const governance = new ReadOnlyGovernanceContract(addresses.governanceAddress.toString(), publicClient);
|
|
7
|
+
const governanceProposerAddress = await governance.getGovernanceProposerAddress();
|
|
8
|
+
const governanceProposer = new GovernanceProposerContract(publicClient, governanceProposerAddress.toString());
|
|
9
|
+
const rollupAddress = addresses.rollupAddress ?? await governanceProposer.getRollupAddress();
|
|
7
10
|
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
8
11
|
const slasherProposer = await rollup.getSlashingProposer();
|
|
9
|
-
const
|
|
12
|
+
const slasher = await rollup.getSlasherContract();
|
|
13
|
+
const [l1StartBlock, l1GenesisTime, aztecEpochDuration, aztecSlotDuration, aztecProofSubmissionEpochs, aztecTargetCommitteeSize, lagInEpochsForValidatorSet, lagInEpochsForRandao, activationThreshold, ejectionThreshold, localEjectionThreshold, governanceProposerQuorum, governanceProposerRoundSize, slashingQuorum, slashingRoundSize, slashingLifetimeInRounds, slashingExecutionDelayInRounds, slashingOffsetInRounds, slashingAmounts, slashingVetoer, slashingDisableDuration, manaTarget, provingCostPerMana, rollupVersion, genesisArchiveTreeRoot, exitDelay] = await Promise.all([
|
|
10
14
|
rollup.getL1StartBlock(),
|
|
11
15
|
rollup.getL1GenesisTime(),
|
|
12
16
|
rollup.getEpochDuration(),
|
|
13
|
-
rollup.getProofSubmissionWindow(),
|
|
14
17
|
rollup.getSlotDuration(),
|
|
18
|
+
rollup.getProofSubmissionEpochs(),
|
|
15
19
|
rollup.getTargetCommitteeSize(),
|
|
16
|
-
rollup.
|
|
20
|
+
rollup.getLagInEpochsForValidatorSet(),
|
|
21
|
+
rollup.getLagInEpochsForRandao(),
|
|
22
|
+
rollup.getActivationThreshold(),
|
|
23
|
+
rollup.getEjectionThreshold(),
|
|
24
|
+
rollup.getLocalEjectionThreshold(),
|
|
17
25
|
governanceProposer.getQuorumSize(),
|
|
18
26
|
governanceProposer.getRoundSize(),
|
|
19
|
-
slasherProposer
|
|
20
|
-
slasherProposer
|
|
27
|
+
slasherProposer?.getQuorumSize() ?? 0n,
|
|
28
|
+
slasherProposer?.getRoundSize() ?? 0n,
|
|
29
|
+
slasherProposer?.getLifetimeInRounds() ?? 0n,
|
|
30
|
+
slasherProposer?.getExecutionDelayInRounds() ?? 0n,
|
|
31
|
+
slasherProposer?.type === 'tally' ? slasherProposer.getSlashOffsetInRounds() : 0n,
|
|
32
|
+
slasherProposer?.type === 'tally' ? slasherProposer.getSlashingAmounts() : [
|
|
33
|
+
0n,
|
|
34
|
+
0n,
|
|
35
|
+
0n
|
|
36
|
+
],
|
|
37
|
+
slasher?.getVetoer() ?? EthAddress.ZERO,
|
|
38
|
+
slasher?.getSlashingDisableDuration() ?? 0,
|
|
39
|
+
rollup.getManaTarget(),
|
|
40
|
+
rollup.getProvingCostPerMana(),
|
|
41
|
+
rollup.getVersion(),
|
|
42
|
+
rollup.getGenesisArchiveTreeRoot(),
|
|
43
|
+
rollup.getExitDelay()
|
|
21
44
|
]);
|
|
22
45
|
return {
|
|
23
46
|
l1StartBlock,
|
|
24
47
|
l1GenesisTime,
|
|
25
48
|
aztecEpochDuration: Number(aztecEpochDuration),
|
|
26
|
-
aztecProofSubmissionWindow: Number(aztecProofSubmissionWindow),
|
|
27
49
|
aztecSlotDuration: Number(aztecSlotDuration),
|
|
50
|
+
aztecProofSubmissionEpochs: Number(aztecProofSubmissionEpochs),
|
|
28
51
|
aztecTargetCommitteeSize: Number(aztecTargetCommitteeSize),
|
|
52
|
+
lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
|
|
53
|
+
lagInEpochsForRandao: Number(lagInEpochsForRandao),
|
|
29
54
|
governanceProposerQuorum: Number(governanceProposerQuorum),
|
|
30
55
|
governanceProposerRoundSize: Number(governanceProposerRoundSize),
|
|
31
|
-
|
|
56
|
+
activationThreshold,
|
|
57
|
+
ejectionThreshold,
|
|
58
|
+
localEjectionThreshold,
|
|
32
59
|
slashingQuorum: Number(slashingQuorum),
|
|
33
|
-
|
|
60
|
+
slashingRoundSizeInEpochs: Number(slashingRoundSize / aztecEpochDuration),
|
|
61
|
+
slashingLifetimeInRounds: Number(slashingLifetimeInRounds),
|
|
62
|
+
slashingExecutionDelayInRounds: Number(slashingExecutionDelayInRounds),
|
|
63
|
+
slashingVetoer,
|
|
64
|
+
slashingDisableDuration,
|
|
65
|
+
manaTarget,
|
|
66
|
+
provingCostPerMana: provingCostPerMana,
|
|
67
|
+
rollupVersion: Number(rollupVersion),
|
|
68
|
+
genesisArchiveTreeRoot,
|
|
69
|
+
exitDelaySeconds: Number(exitDelay),
|
|
70
|
+
slasherFlavor: slasherProposer?.type ?? 'tally',
|
|
71
|
+
slashingOffsetInRounds: Number(slashingOffsetInRounds),
|
|
72
|
+
slashAmountSmall: slashingAmounts[0],
|
|
73
|
+
slashAmountMedium: slashingAmounts[1],
|
|
74
|
+
slashAmountLarge: slashingAmounts[2]
|
|
34
75
|
};
|
|
35
76
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
export type ChainMonitorEventMap = {
|
|
7
|
+
'l1-block': [{
|
|
8
|
+
l1BlockNumber: number;
|
|
9
|
+
timestamp: bigint;
|
|
10
|
+
}];
|
|
11
|
+
checkpoint: [{
|
|
12
|
+
checkpointNumber: number;
|
|
13
|
+
l1BlockNumber: number;
|
|
14
|
+
l2SlotNumber: SlotNumber;
|
|
15
|
+
timestamp: bigint;
|
|
16
|
+
}];
|
|
17
|
+
'checkpoint-proven': [{
|
|
18
|
+
provenCheckpointNumber: number;
|
|
19
|
+
l1BlockNumber: number;
|
|
20
|
+
timestamp: bigint;
|
|
21
|
+
}];
|
|
22
|
+
'l2-messages': [{
|
|
23
|
+
totalL2Messages: number;
|
|
24
|
+
l1BlockNumber: number;
|
|
25
|
+
}];
|
|
26
|
+
'l2-epoch': [{
|
|
27
|
+
l2EpochNumber: EpochNumber;
|
|
28
|
+
timestamp: bigint;
|
|
29
|
+
committee: EthAddress[] | undefined;
|
|
30
|
+
}];
|
|
31
|
+
'l2-slot': [{
|
|
32
|
+
l2SlotNumber: SlotNumber;
|
|
33
|
+
timestamp: bigint;
|
|
34
|
+
}];
|
|
35
|
+
};
|
|
36
|
+
/** Utility class that polls the chain on quick intervals and logs new L1 blocks, L2 blocks, and L2 proofs. */
|
|
37
|
+
export declare class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
38
|
+
private readonly rollup;
|
|
39
|
+
private readonly dateProvider;
|
|
40
|
+
private readonly logger;
|
|
41
|
+
private readonly intervalMs;
|
|
42
|
+
private readonly l1Client;
|
|
43
|
+
private inbox;
|
|
44
|
+
private handle;
|
|
45
|
+
private running;
|
|
46
|
+
/** Current L1 block number */
|
|
47
|
+
l1BlockNumber: number;
|
|
48
|
+
/** Current checkpoint number */
|
|
49
|
+
checkpointNumber: number;
|
|
50
|
+
/** Current proven checkpoint number */
|
|
51
|
+
provenCheckpointNumber: number;
|
|
52
|
+
/** L1 timestamp for the current checkpoint */
|
|
53
|
+
checkpointTimestamp: bigint;
|
|
54
|
+
/** L1 timestamp for the proven checkpoint */
|
|
55
|
+
provenCheckpointTimestamp: bigint;
|
|
56
|
+
/** Total number of L2 messages pushed into the Inbox */
|
|
57
|
+
totalL2Messages: number;
|
|
58
|
+
/** Current L2 epoch number */
|
|
59
|
+
l2EpochNumber: EpochNumber;
|
|
60
|
+
/** Current L2 slot number */
|
|
61
|
+
l2SlotNumber: SlotNumber;
|
|
62
|
+
constructor(rollup: RollupContract, dateProvider?: DateProvider, logger?: import("@aztec/foundation/log").Logger, intervalMs?: number);
|
|
63
|
+
start(): this;
|
|
64
|
+
stop(): Promise<void>;
|
|
65
|
+
private getInbox;
|
|
66
|
+
protected safeRun(): void;
|
|
67
|
+
run(force?: boolean): Promise<this>;
|
|
68
|
+
waitUntilL2Slot(slot: SlotNumber): Promise<void>;
|
|
69
|
+
waitUntilL1Block(block: number | bigint): Promise<void>;
|
|
70
|
+
waitUntilL1Timestamp(timestamp: number | bigint): Promise<void>;
|
|
71
|
+
waitUntilCheckpoint(checkpointNumber: number | bigint): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhaW5fbW9uaXRvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvY2hhaW5fbW9uaXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQWlCLEtBQUssY0FBYyxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDL0UsT0FBTyxFQUFFLFdBQVcsRUFBRSxVQUFVLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUMxRSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFHM0QsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRXZELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFB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tB,SAAS,CAAC,OAAO,SAYhB;IAEK,GAAG,CAAC,KAAK,UAAQ,iBAgFtB;IAEM,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAatD;IAEM,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc7D;IAEM,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAcrE;IAEM,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc3E;CACF"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { InboxContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
5
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
6
|
+
import { EventEmitter } from 'events';
|
|
7
|
+
/** Utility class that polls the chain on quick intervals and logs new L1 blocks, L2 blocks, and L2 proofs. */ export class ChainMonitor extends EventEmitter {
|
|
8
|
+
rollup;
|
|
9
|
+
dateProvider;
|
|
10
|
+
logger;
|
|
11
|
+
intervalMs;
|
|
12
|
+
l1Client;
|
|
13
|
+
inbox;
|
|
14
|
+
handle;
|
|
15
|
+
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
16
|
+
running;
|
|
17
|
+
/** Current L1 block number */ l1BlockNumber;
|
|
18
|
+
/** Current checkpoint number */ checkpointNumber;
|
|
19
|
+
/** Current proven checkpoint number */ provenCheckpointNumber;
|
|
20
|
+
/** L1 timestamp for the current checkpoint */ checkpointTimestamp;
|
|
21
|
+
/** L1 timestamp for the proven checkpoint */ provenCheckpointTimestamp;
|
|
22
|
+
/** Total number of L2 messages pushed into the Inbox */ totalL2Messages;
|
|
23
|
+
/** Current L2 epoch number */ l2EpochNumber;
|
|
24
|
+
/** Current L2 slot number */ l2SlotNumber;
|
|
25
|
+
constructor(rollup, dateProvider = new DateProvider(), logger = createLogger('aztecjs:utils:chain_monitor'), intervalMs = 200){
|
|
26
|
+
super(), this.rollup = rollup, this.dateProvider = dateProvider, this.logger = logger, this.intervalMs = intervalMs, this.running = new Set(), this.totalL2Messages = 0;
|
|
27
|
+
this.l1Client = rollup.client;
|
|
28
|
+
}
|
|
29
|
+
start() {
|
|
30
|
+
if (this.handle) {
|
|
31
|
+
throw new Error('Chain monitor already started');
|
|
32
|
+
}
|
|
33
|
+
this.handle = setInterval(this.safeRun.bind(this), this.intervalMs);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
async stop() {
|
|
37
|
+
try {
|
|
38
|
+
this.removeAllListeners();
|
|
39
|
+
if (this.handle) {
|
|
40
|
+
clearInterval(this.handle);
|
|
41
|
+
this.handle = undefined;
|
|
42
|
+
}
|
|
43
|
+
await Promise.allSettled([
|
|
44
|
+
...this.running
|
|
45
|
+
]);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
this.logger.error('Error stopping chain monitor', err);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async getInbox() {
|
|
51
|
+
if (!this.inbox) {
|
|
52
|
+
const { inboxAddress } = await this.rollup.getRollupAddresses();
|
|
53
|
+
this.inbox = new InboxContract(this.l1Client, inboxAddress);
|
|
54
|
+
}
|
|
55
|
+
return this.inbox;
|
|
56
|
+
}
|
|
57
|
+
safeRun() {
|
|
58
|
+
const running = promiseWithResolvers();
|
|
59
|
+
this.running.add(running.promise);
|
|
60
|
+
void this.run().catch((error)=>{
|
|
61
|
+
this.logger.error('Error in chain monitor loop', error);
|
|
62
|
+
}).finally(()=>{
|
|
63
|
+
running.resolve();
|
|
64
|
+
this.running.delete(running.promise);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async run(force = false) {
|
|
68
|
+
const newL1BlockNumber = Number(await this.l1Client.getBlockNumber({
|
|
69
|
+
cacheTime: 0
|
|
70
|
+
}));
|
|
71
|
+
if (!force && this.l1BlockNumber === newL1BlockNumber) {
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
this.l1BlockNumber = newL1BlockNumber;
|
|
75
|
+
const [l2SlotNumber, l2Epoch, l1block] = await Promise.all([
|
|
76
|
+
this.rollup.getSlotNumber(),
|
|
77
|
+
this.rollup.getCurrentEpoch(),
|
|
78
|
+
this.l1Client.getBlock({
|
|
79
|
+
blockNumber: BigInt(newL1BlockNumber),
|
|
80
|
+
includeTransactions: false
|
|
81
|
+
})
|
|
82
|
+
]);
|
|
83
|
+
const timestamp = l1block.timestamp;
|
|
84
|
+
const timestampString = new Date(Number(timestamp) * 1000).toTimeString().split(' ')[0];
|
|
85
|
+
this.emit('l1-block', {
|
|
86
|
+
l1BlockNumber: newL1BlockNumber,
|
|
87
|
+
timestamp
|
|
88
|
+
});
|
|
89
|
+
let msg = `L1 block ${newL1BlockNumber} mined at ${timestampString}`;
|
|
90
|
+
const newCheckpointNumber = Number(await this.rollup.getCheckpointNumber());
|
|
91
|
+
if (this.checkpointNumber !== newCheckpointNumber) {
|
|
92
|
+
const epochNumber = await this.rollup.getEpochNumberForCheckpoint(BigInt(newCheckpointNumber));
|
|
93
|
+
msg += ` with new checkpoint ${newCheckpointNumber} for epoch ${epochNumber}`;
|
|
94
|
+
this.checkpointNumber = newCheckpointNumber;
|
|
95
|
+
this.checkpointTimestamp = timestamp;
|
|
96
|
+
this.emit('checkpoint', {
|
|
97
|
+
checkpointNumber: newCheckpointNumber,
|
|
98
|
+
l1BlockNumber: newL1BlockNumber,
|
|
99
|
+
l2SlotNumber,
|
|
100
|
+
timestamp
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const newProvenCheckpointNumber = Number(await this.rollup.getProvenCheckpointNumber());
|
|
104
|
+
if (this.provenCheckpointNumber !== newProvenCheckpointNumber) {
|
|
105
|
+
const epochNumber = await this.rollup.getEpochNumberForCheckpoint(BigInt(newProvenCheckpointNumber));
|
|
106
|
+
msg += ` with proof up to checkpoint ${newProvenCheckpointNumber} for epoch ${epochNumber}`;
|
|
107
|
+
this.provenCheckpointNumber = newProvenCheckpointNumber;
|
|
108
|
+
this.provenCheckpointTimestamp = timestamp;
|
|
109
|
+
this.emit('checkpoint-proven', {
|
|
110
|
+
provenCheckpointNumber: newProvenCheckpointNumber,
|
|
111
|
+
l1BlockNumber: newL1BlockNumber,
|
|
112
|
+
timestamp
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const inbox = await this.getInbox();
|
|
116
|
+
const newTotalL2Messages = await inbox.getState().then((s)=>Number(s.totalMessagesInserted));
|
|
117
|
+
if (this.totalL2Messages !== newTotalL2Messages) {
|
|
118
|
+
msg += ` with ${newTotalL2Messages - this.totalL2Messages} new L2 messages (total ${newTotalL2Messages})`;
|
|
119
|
+
this.totalL2Messages = newTotalL2Messages;
|
|
120
|
+
this.emit('l2-messages', {
|
|
121
|
+
totalL2Messages: newTotalL2Messages,
|
|
122
|
+
l1BlockNumber: newL1BlockNumber
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
let committee;
|
|
126
|
+
if (l2Epoch !== this.l2EpochNumber) {
|
|
127
|
+
this.l2EpochNumber = l2Epoch;
|
|
128
|
+
committee = (await this.rollup.getCurrentEpochCommittee())?.map((addr)=>EthAddress.fromString(addr));
|
|
129
|
+
this.emit('l2-epoch', {
|
|
130
|
+
l2EpochNumber: l2Epoch,
|
|
131
|
+
timestamp,
|
|
132
|
+
committee
|
|
133
|
+
});
|
|
134
|
+
msg += ` starting new epoch ${this.l2EpochNumber} `;
|
|
135
|
+
}
|
|
136
|
+
if (l2SlotNumber !== this.l2SlotNumber) {
|
|
137
|
+
this.l2SlotNumber = l2SlotNumber;
|
|
138
|
+
this.emit('l2-slot', {
|
|
139
|
+
l2SlotNumber,
|
|
140
|
+
timestamp
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
this.logger.info(msg, {
|
|
144
|
+
currentTimestamp: this.dateProvider.nowInSeconds(),
|
|
145
|
+
l1Timestamp: timestamp,
|
|
146
|
+
l1BlockNumber: this.l1BlockNumber,
|
|
147
|
+
l2SlotNumber,
|
|
148
|
+
l2Epoch,
|
|
149
|
+
checkpointNumber: this.checkpointNumber,
|
|
150
|
+
provenCheckpointNumber: this.provenCheckpointNumber,
|
|
151
|
+
totalL2Messages: this.totalL2Messages,
|
|
152
|
+
committee
|
|
153
|
+
});
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
waitUntilL2Slot(slot) {
|
|
157
|
+
if (this.l2SlotNumber >= slot) {
|
|
158
|
+
return Promise.resolve();
|
|
159
|
+
}
|
|
160
|
+
return new Promise((resolve)=>{
|
|
161
|
+
const listener = (data)=>{
|
|
162
|
+
if (data.l2SlotNumber >= slot) {
|
|
163
|
+
this.off('l2-slot', listener);
|
|
164
|
+
resolve();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
this.on('l2-slot', listener);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
waitUntilL1Block(block) {
|
|
171
|
+
const targetBlock = typeof block === 'bigint' ? block.valueOf() : block;
|
|
172
|
+
if (this.l1BlockNumber >= targetBlock) {
|
|
173
|
+
return Promise.resolve();
|
|
174
|
+
}
|
|
175
|
+
return new Promise((resolve)=>{
|
|
176
|
+
const listener = (data)=>{
|
|
177
|
+
if (data.l1BlockNumber >= targetBlock) {
|
|
178
|
+
this.off('l1-block', listener);
|
|
179
|
+
resolve();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
this.on('l1-block', listener);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
waitUntilL1Timestamp(timestamp) {
|
|
186
|
+
const targetTimestamp = typeof timestamp === 'bigint' ? timestamp.valueOf() : timestamp;
|
|
187
|
+
if (this.l1BlockNumber >= targetTimestamp) {
|
|
188
|
+
return Promise.resolve();
|
|
189
|
+
}
|
|
190
|
+
return new Promise((resolve)=>{
|
|
191
|
+
const listener = (data)=>{
|
|
192
|
+
if (data.timestamp >= targetTimestamp) {
|
|
193
|
+
this.off('l1-block', listener);
|
|
194
|
+
resolve();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
this.on('l1-block', listener);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
waitUntilCheckpoint(checkpointNumber) {
|
|
201
|
+
const targetBlock = typeof checkpointNumber === 'bigint' ? checkpointNumber.valueOf() : checkpointNumber;
|
|
202
|
+
if (this.checkpointNumber >= targetBlock) {
|
|
203
|
+
return Promise.resolve();
|
|
204
|
+
}
|
|
205
|
+
return new Promise((resolve)=>{
|
|
206
|
+
const listener = (data)=>{
|
|
207
|
+
if (data.checkpointNumber >= targetBlock) {
|
|
208
|
+
this.off('checkpoint', listener);
|
|
209
|
+
resolve();
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
this.on('checkpoint', listener);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import { type L1TxUtilsConfig } from '../l1_tx_utils/index.js';
|
|
4
|
+
import { L1TxUtilsWithBlobs } from '../l1_tx_utils/l1_tx_utils_with_blobs.js';
|
|
5
|
+
import type { ExtendedViemWalletClient } from '../types.js';
|
|
2
6
|
import { type Delayer } from './tx_delayer.js';
|
|
3
7
|
export declare class DelayedTxUtils extends L1TxUtilsWithBlobs {
|
|
4
8
|
delayer: Delayer | undefined;
|
|
5
|
-
static fromL1TxUtils(l1TxUtils: L1TxUtilsWithBlobs, ethereumSlotDuration: number): DelayedTxUtils;
|
|
9
|
+
static fromL1TxUtils(l1TxUtils: L1TxUtilsWithBlobs, ethereumSlotDuration: number, wallet: ExtendedViemWalletClient): DelayedTxUtils;
|
|
6
10
|
enableDelayer(ethereumSlotDuration: number): void;
|
|
7
11
|
}
|
|
8
|
-
|
|
12
|
+
export declare function createDelayedL1TxUtilsFromViemWallet(client: ExtendedViemWalletClient, logger?: Logger, dateProvider?: DateProvider, config?: Partial<L1TxUtilsConfig>, debugMaxGasLimit?: boolean): DelayedTxUtils;
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVsYXllZF90eF91dGlscy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvZGVsYXllZF90eF91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRXZELE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBb0IsTUFBTSx5QkFBeUIsQ0FBQztBQUNqRixPQUFPLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSwwQ0FBMEMsQ0FBQztBQUM5RSxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUM1RCxPQUFPLEVBQUUsS0FBSyxPQUFPLEVBQWUsTUFBTSxpQkFBaUIsQ0FBQztBQUU1RCxxQkFBYSxjQUFlLFNBQVEsa0JBQWtCO0lBQzdDLE9BQU8sRUFBRSxPQUFPLEdBQUcsU0FBUyxDQUFDO0lBRXBDLE9BQWMsYUFBYSxDQUN6QixTQUFTLEVBQUUsa0JBQWtCLEVBQzdCLG9CQUFvQixFQUFFLE1BQU0sRUFDNUIsTUFBTSxFQUFFLHdCQUF3QixrQkFTakM7SUFFTSxhQUFhLENBQUMsb0JBQW9CLEVBQUUsTUFBTSxRQU1oRDtDQUNGO0FBRUQsd0JBQWdCLG9DQUFvQyxDQUNsRCxNQUFNLEVBQUUsd0JBQXdCLEVBQ2hDLE1BQU0sR0FBRSxNQUFrQyxFQUMxQyxZQUFZLEdBQUUsWUFBaUMsRUFDL0MsTUFBTSxDQUFDLEVBQUUsT0FBTyxDQUFDLGVBQWUsQ0FBQyxFQUNqQyxnQkFBZ0IsR0FBRSxPQUFlLGtCQVdsQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delayed_tx_utils.d.ts","sourceRoot":"","sources":["../../src/test/delayed_tx_utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delayed_tx_utils.d.ts","sourceRoot":"","sources":["../../src/test/delayed_tx_utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,iBAAiB,CAAC;AAE5D,qBAAa,cAAe,SAAQ,kBAAkB;IAC7C,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAEpC,OAAc,aAAa,CACzB,SAAS,EAAE,kBAAkB,EAC7B,oBAAoB,EAAE,MAAM,EAC5B,MAAM,EAAE,wBAAwB,kBASjC;IAEM,aAAa,CAAC,oBAAoB,EAAE,MAAM,QAMhD;CACF;AAED,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,wBAAwB,EAChC,MAAM,GAAE,MAAkC,EAC1C,YAAY,GAAE,YAAiC,EAC/C,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,EACjC,gBAAgB,GAAE,OAAe,kBAWlC"}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
|
+
import { createViemSigner } from '../l1_tx_utils/index.js';
|
|
5
|
+
import { L1TxUtilsWithBlobs } from '../l1_tx_utils/l1_tx_utils_with_blobs.js';
|
|
2
6
|
import { withDelayer } from './tx_delayer.js';
|
|
3
7
|
export class DelayedTxUtils extends L1TxUtilsWithBlobs {
|
|
4
8
|
delayer;
|
|
5
|
-
static fromL1TxUtils(l1TxUtils, ethereumSlotDuration) {
|
|
6
|
-
const { client, delayer } = withDelayer(l1TxUtils.
|
|
9
|
+
static fromL1TxUtils(l1TxUtils, ethereumSlotDuration, wallet) {
|
|
10
|
+
const { client, delayer } = withDelayer(wallet, l1TxUtils.dateProvider, {
|
|
7
11
|
ethereumSlotDuration
|
|
8
12
|
});
|
|
9
13
|
const casted = l1TxUtils;
|
|
10
14
|
casted.delayer = delayer;
|
|
11
|
-
casted.
|
|
15
|
+
casted.client = client;
|
|
12
16
|
return casted;
|
|
13
17
|
}
|
|
14
18
|
enableDelayer(ethereumSlotDuration) {
|
|
15
|
-
const { client, delayer } = withDelayer(this.
|
|
19
|
+
const { client, delayer } = withDelayer(this.client, this.dateProvider, {
|
|
16
20
|
ethereumSlotDuration
|
|
17
21
|
});
|
|
18
22
|
this.delayer = delayer;
|
|
19
|
-
this.
|
|
23
|
+
this.client = client;
|
|
20
24
|
}
|
|
21
25
|
}
|
|
26
|
+
export function createDelayedL1TxUtilsFromViemWallet(client, logger = createLogger('L1TxUtils'), dateProvider = new DateProvider(), config, debugMaxGasLimit = false) {
|
|
27
|
+
return new DelayedTxUtils(client, EthAddress.fromString(client.account.address), createViemSigner(client), logger, dateProvider, config, debugMaxGasLimit);
|
|
28
|
+
}
|