@aztec/ethereum 3.0.3 → 4.0.0-devnet.1-patch.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.
- package/dest/client.js +6 -2
- package/dest/config.d.ts +17 -27
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +51 -54
- package/dest/contracts/empire_base.d.ts +2 -1
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +2 -1
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +22 -15
- package/dest/contracts/fee_asset_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +11 -9
- package/dest/contracts/governance.d.ts +3 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +11 -1
- package/dest/contracts/governance_proposer.d.ts +2 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +395 -9
- package/dest/contracts/inbox.d.ts +22 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +36 -1
- package/dest/contracts/index.d.ts +3 -1
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +2 -0
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/multicall.d.ts +1 -1
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +2 -1
- package/dest/contracts/outbox.d.ts +41 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +86 -0
- package/dest/contracts/rollup.d.ts +162 -81
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +691 -132
- package/dest/contracts/tally_slashing_proposer.d.ts +1 -1
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +8 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +17 -2
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +87 -19
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +4964 -1573
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_contract_addresses.d.ts +1 -1
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +3 -3
- package/dest/l1_tx_utils/constants.d.ts +8 -2
- package/dest/l1_tx_utils/constants.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.js +27 -2
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
- package/dest/l1_tx_utils/index.d.ts +3 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +2 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +6 -6
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +4 -15
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +35 -143
- package/dest/publisher_manager.d.ts +3 -2
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +2 -2
- package/dest/queries.d.ts +2 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +12 -4
- package/dest/test/chain_monitor.js +1 -2
- package/dest/test/eth_cheat_codes.d.ts +13 -1
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +3 -1
- package/dest/test/rollup_cheat_codes.d.ts +5 -2
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +22 -3
- package/dest/test/start_anvil.js +1 -1
- package/dest/test/tx_delayer.js +1 -1
- package/dest/utils.d.ts +15 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +64 -0
- package/package.json +9 -7
- package/src/client.ts +2 -2
- package/src/config.ts +62 -53
- package/src/contracts/README.md +157 -0
- package/src/contracts/empire_base.ts +1 -1
- package/src/contracts/empire_slashing_proposer.ts +22 -28
- package/src/contracts/fee_asset_handler.ts +10 -7
- package/src/contracts/governance.ts +10 -1
- package/src/contracts/governance_proposer.ts +10 -2
- package/src/contracts/inbox.ts +53 -1
- package/src/contracts/index.ts +2 -0
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +5 -2
- package/src/contracts/outbox.ts +98 -0
- package/src/contracts/rollup.ts +364 -100
- package/src/contracts/tally_slashing_proposer.ts +5 -1
- package/src/deploy_aztec_l1_contracts.ts +94 -18
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_contract_addresses.ts +22 -20
- package/src/l1_tx_utils/constants.ts +13 -2
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
- package/src/l1_tx_utils/index.ts +2 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +6 -6
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +48 -186
- package/src/publisher_manager.ts +4 -2
- package/src/queries.ts +11 -3
- package/src/test/chain_monitor.ts +1 -1
- package/src/test/eth_cheat_codes.ts +1 -1
- package/src/test/rollup_cheat_codes.ts +22 -4
- package/src/test/start_anvil.ts +1 -1
- package/src/test/tx_delayer.ts +1 -1
- package/src/utils.ts +82 -0
package/dest/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
-
import { type Abi, type ContractEventName, type DecodeEventLogReturnType, type Hex, type Log } from 'viem';
|
|
3
|
+
import { type Abi, type ContractEventName, type DecodeEventLogReturnType, type FormattedTransaction, type Hex, type Log } from 'viem';
|
|
4
4
|
export interface L2Claim {
|
|
5
5
|
claimSecret: Fr;
|
|
6
6
|
claimAmount: Fr;
|
|
@@ -14,6 +14,7 @@ export declare class FormattedViemError extends Error {
|
|
|
14
14
|
export declare function extractEvent<const TAbi extends Abi | readonly unknown[], TEventName extends ContractEventName<TAbi>, TEventType = DecodeEventLogReturnType<TAbi, TEventName, Hex[], undefined, true>>(logs: Log[], address: Hex, abi: TAbi, eventName: TEventName, filter?: (log: TEventType) => boolean, logger?: Logger): TEventType;
|
|
15
15
|
export declare function tryExtractEvent<const TAbi extends Abi | readonly unknown[], TEventName extends ContractEventName<TAbi>, TEventType = DecodeEventLogReturnType<TAbi, TEventName, Hex[], undefined, true>>(logs: Log[], address: Hex, abi: TAbi, eventName: TEventName, filter?: (log: TEventType) => boolean, logger?: Logger): TEventType | undefined;
|
|
16
16
|
export declare function prettyLogViemErrorMsg(err: any): any;
|
|
17
|
+
export declare function mergeAbis(abis: Abi[]): Abi;
|
|
17
18
|
/**
|
|
18
19
|
* Formats a Viem error into a FormattedViemError instance.
|
|
19
20
|
* @param error - The error to format.
|
|
@@ -22,4 +23,16 @@ export declare function prettyLogViemErrorMsg(err: any): any;
|
|
|
22
23
|
*/
|
|
23
24
|
export declare function formatViemError(error: any, abi?: Abi): FormattedViemError;
|
|
24
25
|
export declare function tryGetCustomErrorName(err: any): string | undefined;
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a transaction is a blob transaction (EIP-4844).
|
|
28
|
+
* Blob transactions have maxFeePerBlobGas and blobVersionedHashes fields.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isBlobTransaction(tx: FormattedTransaction): tx is FormattedTransaction & {
|
|
31
|
+
maxFeePerBlobGas: bigint;
|
|
32
|
+
blobVersionedHashes: readonly Hex[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Calculates a percentile from an array of bigints
|
|
36
|
+
*/
|
|
37
|
+
export declare function calculatePercentile(values: bigint[], percentile: number): bigint;
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUdwRCxPQUFPLEVBQ0wsS0FBSyxHQUFHLEVBR1IsS0FBSyxpQkFBaUIsRU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FQUFFLE1BQU0sR0FBRyxNQUFNLENBT2hGIn0=
|
package/dest/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EACL,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EACL,KAAK,GAAG,EAGR,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,GAAG,EACR,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAGd,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,EAAE,CAAC;IAChB,WAAW,EAAE,EAAE,CAAC;IAChB,WAAW,EAAE,GAAG,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;IAErB,YAAY,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,EAAE,EAIhD;CACF;AAED,wBAAgB,YAAY,CAC1B,KAAK,CAAC,IAAI,SAAS,GAAG,GAAG,SAAS,OAAO,EAAE,EAC3C,UAAU,SAAS,iBAAiB,CAAC,IAAI,CAAC,EAC1C,UAAU,GAAG,wBAAwB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,EAE/E,IAAI,EAAE,GAAG,EAAE,EACX,OAAO,EAA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@
|
|
|
1
1
|
import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
|
|
2
2
|
import { BaseError, ContractFunctionRevertedError, decodeErrorResult, decodeEventLog } from 'viem';
|
|
3
|
+
import { formatAbiItem, formatAbiParams } from 'viem/utils';
|
|
3
4
|
export class FormattedViemError extends Error {
|
|
4
5
|
metaMessages;
|
|
5
6
|
constructor(message, metaMessages){
|
|
@@ -46,6 +47,51 @@ export function prettyLogViemErrorMsg(err) {
|
|
|
46
47
|
}
|
|
47
48
|
return err?.message ?? err;
|
|
48
49
|
}
|
|
50
|
+
export function mergeAbis(abis) {
|
|
51
|
+
let merged = [];
|
|
52
|
+
const seen = new Set();
|
|
53
|
+
for (const abi of abis){
|
|
54
|
+
for (const item of abi){
|
|
55
|
+
const key = getAbiItemKey(item);
|
|
56
|
+
if (!seen.has(key)) {
|
|
57
|
+
seen.add(key);
|
|
58
|
+
merged = [
|
|
59
|
+
...merged,
|
|
60
|
+
item
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return merged;
|
|
66
|
+
}
|
|
67
|
+
function getAbiItemKey(item) {
|
|
68
|
+
if (item.type === 'function') {
|
|
69
|
+
const signature = formatAbiItem(item);
|
|
70
|
+
const outputs = formatAbiParams(item.outputs);
|
|
71
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
72
|
+
return `function:${signature}:${outputs}:${stateMutability}`;
|
|
73
|
+
}
|
|
74
|
+
if (item.type === 'event') {
|
|
75
|
+
const signature = formatAbiItem(item);
|
|
76
|
+
const indexed = (item.inputs ?? []).map((input)=>input.indexed ? '1' : '0').join('');
|
|
77
|
+
const anonymous = item.anonymous ? 'anonymous' : 'not-anonymous';
|
|
78
|
+
return `event:${signature}:${indexed}:${anonymous}`;
|
|
79
|
+
}
|
|
80
|
+
if (item.type === 'error') {
|
|
81
|
+
const signature = formatAbiItem(item);
|
|
82
|
+
return `error:${signature}`;
|
|
83
|
+
}
|
|
84
|
+
if (item.type === 'constructor') {
|
|
85
|
+
const inputs = formatAbiParams(item.inputs);
|
|
86
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
87
|
+
return `constructor::${inputs}:${stateMutability}`;
|
|
88
|
+
}
|
|
89
|
+
if (item.type === 'fallback' || item.type === 'receive') {
|
|
90
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
91
|
+
return `${item.type}:::${stateMutability}`;
|
|
92
|
+
}
|
|
93
|
+
return 'unknown';
|
|
94
|
+
}
|
|
49
95
|
function getNestedErrorData(error) {
|
|
50
96
|
// If nothing, bail
|
|
51
97
|
if (!error) {
|
|
@@ -162,3 +208,21 @@ export function tryGetCustomErrorName(err) {
|
|
|
162
208
|
return undefined;
|
|
163
209
|
}
|
|
164
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Type guard to check if a transaction is a blob transaction (EIP-4844).
|
|
213
|
+
* Blob transactions have maxFeePerBlobGas and blobVersionedHashes fields.
|
|
214
|
+
*/ export function isBlobTransaction(tx) {
|
|
215
|
+
return 'maxFeePerBlobGas' in tx && tx.maxFeePerBlobGas !== undefined && 'blobVersionedHashes' in tx && tx.blobVersionedHashes !== undefined;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Calculates a percentile from an array of bigints
|
|
219
|
+
*/ export function calculatePercentile(values, percentile) {
|
|
220
|
+
if (values.length === 0) {
|
|
221
|
+
return 0n;
|
|
222
|
+
}
|
|
223
|
+
const sorted = [
|
|
224
|
+
...values
|
|
225
|
+
].sort((a, b)=>a < b ? -1 : a > b ? 1 : 0);
|
|
226
|
+
const index = Math.ceil((sorted.length - 1) * (percentile / 100));
|
|
227
|
+
return sorted[index];
|
|
228
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-devnet.1-patch.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./account": "./dest/account.js",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"./forwarder-proxy": "./dest/forwarder_proxy.js",
|
|
18
18
|
"./l1-artifacts": "./dest/l1_artifacts.js",
|
|
19
19
|
"./l1-contract-addresses": "./dest/l1_contract_addresses.js",
|
|
20
|
+
"./l1-fee-analysis": "./dest/l1_tx_utils/l1_fee_analyzer.js",
|
|
20
21
|
"./l1-reader": "./dest/l1_reader.js",
|
|
21
22
|
"./l1-tx-utils": "./dest/l1_tx_utils/index.js",
|
|
22
23
|
"./l1-tx-utils-with-blobs": "./dest/l1_tx_utils/index-blobs.js",
|
|
@@ -39,7 +40,8 @@
|
|
|
39
40
|
"build": "yarn clean && ../scripts/tsc.sh",
|
|
40
41
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
41
42
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
42
|
-
"
|
|
43
|
+
"generate": "./scripts/generate.sh",
|
|
44
|
+
"start:dev": "concurrently -k \"../scripts/tsc.sh --watch\" \"nodemon --watch dest --exec yarn start\"",
|
|
43
45
|
"start": "node ./dest/index.js",
|
|
44
46
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
45
47
|
"proposer-address": "node ./dest/cli/forwarder_address.js"
|
|
@@ -48,10 +50,10 @@
|
|
|
48
50
|
"../package.common.json"
|
|
49
51
|
],
|
|
50
52
|
"dependencies": {
|
|
51
|
-
"@aztec/blob-lib": "
|
|
52
|
-
"@aztec/constants": "
|
|
53
|
-
"@aztec/foundation": "
|
|
54
|
-
"@aztec/l1-artifacts": "
|
|
53
|
+
"@aztec/blob-lib": "4.0.0-devnet.1-patch.0",
|
|
54
|
+
"@aztec/constants": "4.0.0-devnet.1-patch.0",
|
|
55
|
+
"@aztec/foundation": "4.0.0-devnet.1-patch.0",
|
|
56
|
+
"@aztec/l1-artifacts": "4.0.0-devnet.1-patch.0",
|
|
55
57
|
"@viem/anvil": "^0.0.10",
|
|
56
58
|
"dotenv": "^16.0.3",
|
|
57
59
|
"lodash.chunk": "^4.2.0",
|
|
@@ -66,7 +68,7 @@
|
|
|
66
68
|
"@types/jest": "^30.0.0",
|
|
67
69
|
"@types/lodash.pickby": "^4",
|
|
68
70
|
"@types/node": "^22.15.17",
|
|
69
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
71
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
70
72
|
"@viem/anvil": "^0.0.10",
|
|
71
73
|
"get-port": "^7.1.0",
|
|
72
74
|
"jest": "^30.0.0",
|
package/src/client.ts
CHANGED
|
@@ -36,7 +36,7 @@ export function getPublicClient(config: Config): ViemPublicClient {
|
|
|
36
36
|
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
37
37
|
return createPublicClient({
|
|
38
38
|
chain: chain.chainInfo,
|
|
39
|
-
transport: fallback(config.l1RpcUrls.map(url => http(url))),
|
|
39
|
+
transport: fallback(config.l1RpcUrls.map(url => http(url, { batch: false }))),
|
|
40
40
|
pollingInterval: config.viemPollingIntervalMS,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -88,7 +88,7 @@ export function createExtendedL1Client(
|
|
|
88
88
|
const extendedClient = createWalletClient({
|
|
89
89
|
account: hdAccount,
|
|
90
90
|
chain,
|
|
91
|
-
transport: fallback(rpcUrls.map(url => http(url))),
|
|
91
|
+
transport: fallback(rpcUrls.map(url => http(url, { batch: false }))),
|
|
92
92
|
pollingInterval: pollingIntervalMS,
|
|
93
93
|
}).extend(publicActions);
|
|
94
94
|
|
package/src/config.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
|
-
// type NetworkNames,
|
|
4
3
|
bigintConfigHelper,
|
|
5
4
|
booleanConfigHelper,
|
|
6
5
|
enumConfigHelper,
|
|
7
6
|
getConfigFromMappings,
|
|
7
|
+
getDefaultConfig,
|
|
8
8
|
numberConfigHelper,
|
|
9
9
|
optionalNumberConfigHelper,
|
|
10
10
|
} from '@aztec/foundation/config';
|
|
11
11
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
12
|
|
|
13
|
+
import { l1ContractsDefaultEnv } from './generated/l1-contracts-defaults.js';
|
|
13
14
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils/config.js';
|
|
14
15
|
|
|
15
16
|
export type GenesisStateConfig = {
|
|
@@ -32,6 +33,8 @@ export type L1ContractsConfig = {
|
|
|
32
33
|
lagInEpochsForValidatorSet: number;
|
|
33
34
|
/** The number of epochs to lag behind the current epoch for randao selection. */
|
|
34
35
|
lagInEpochsForRandao: number;
|
|
36
|
+
/** The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks). */
|
|
37
|
+
inboxLag: number;
|
|
35
38
|
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
36
39
|
aztecProofSubmissionEpochs: number;
|
|
37
40
|
/** The deposit amount for a validator */
|
|
@@ -66,118 +69,108 @@ export type L1ContractsConfig = {
|
|
|
66
69
|
governanceProposerQuorum?: number;
|
|
67
70
|
/** Governance proposing round size */
|
|
68
71
|
governanceProposerRoundSize: number;
|
|
72
|
+
/** Governance voting duration in seconds (only for local/devnet/next-net, default 3600) */
|
|
73
|
+
governanceVotingDuration?: number;
|
|
69
74
|
/** The mana target for the rollup */
|
|
70
75
|
manaTarget: bigint;
|
|
71
76
|
/** The proving cost per mana */
|
|
72
77
|
provingCostPerMana: bigint;
|
|
78
|
+
/** The initial ETH per fee asset price (with 1e12 precision) */
|
|
79
|
+
initialEthPerFeeAsset: bigint;
|
|
73
80
|
/** The number of seconds to wait for an exit */
|
|
74
81
|
exitDelaySeconds: number;
|
|
75
82
|
} & L1TxUtilsConfig;
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
lagInEpochsForValidatorSet: 2,
|
|
83
|
-
lagInEpochsForRandao: 2, // For PROD, this value should be > lagInEpochsForValidatorSet
|
|
84
|
-
aztecProofSubmissionEpochs: 1, // you have a full epoch to submit a proof after the epoch to prove ends
|
|
85
|
-
activationThreshold: 100n * 10n ** 18n,
|
|
86
|
-
ejectionThreshold: 50n * 10n ** 18n,
|
|
87
|
-
localEjectionThreshold: 98n * 10n ** 18n,
|
|
88
|
-
slashAmountSmall: 10n * 10n ** 18n,
|
|
89
|
-
slashAmountMedium: 20n * 10n ** 18n,
|
|
90
|
-
slashAmountLarge: 50n * 10n ** 18n,
|
|
91
|
-
slashingRoundSizeInEpochs: 4,
|
|
92
|
-
slashingLifetimeInRounds: 5,
|
|
93
|
-
slashingExecutionDelayInRounds: 0, // round N may be submitted in round N + 1
|
|
94
|
-
slashingVetoer: EthAddress.ZERO,
|
|
95
|
-
governanceProposerRoundSize: 300,
|
|
96
|
-
manaTarget: BigInt(100e6),
|
|
97
|
-
provingCostPerMana: BigInt(100),
|
|
98
|
-
exitDelaySeconds: 2 * 24 * 60 * 60,
|
|
99
|
-
slasherFlavor: 'tally' as const,
|
|
100
|
-
slashingOffsetInRounds: 2,
|
|
101
|
-
slashingDisableDuration: 5 * 24 * 60 * 60, // 5 days in seconds
|
|
102
|
-
} satisfies L1ContractsConfig;
|
|
103
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Config mappings for L1ContractsConfig.
|
|
86
|
+
* Default values come from generated l1-contracts-defaults.json (source: defaults.yml).
|
|
87
|
+
* Real deployments use forge scripts which require explicit env vars (vm.envUint).
|
|
88
|
+
*/
|
|
104
89
|
export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> = {
|
|
105
90
|
ethereumSlotDuration: {
|
|
106
91
|
env: 'ETHEREUM_SLOT_DURATION',
|
|
107
92
|
description: 'How many seconds an L1 slot lasts.',
|
|
108
|
-
...numberConfigHelper(
|
|
93
|
+
...numberConfigHelper(l1ContractsDefaultEnv.ETHEREUM_SLOT_DURATION),
|
|
109
94
|
},
|
|
110
95
|
aztecSlotDuration: {
|
|
111
96
|
env: 'AZTEC_SLOT_DURATION',
|
|
112
97
|
description: 'How many seconds an L2 slots lasts (must be multiple of ethereum slot duration).',
|
|
113
|
-
...numberConfigHelper(
|
|
98
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLOT_DURATION),
|
|
114
99
|
},
|
|
115
100
|
aztecEpochDuration: {
|
|
116
101
|
env: 'AZTEC_EPOCH_DURATION',
|
|
117
|
-
description: `How many L2 slots an epoch lasts (maximum
|
|
118
|
-
...numberConfigHelper(
|
|
102
|
+
description: `How many L2 slots an epoch lasts (maximum MAX_CHECKPOINTS_PER_EPOCH).`,
|
|
103
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EPOCH_DURATION),
|
|
119
104
|
},
|
|
120
105
|
aztecTargetCommitteeSize: {
|
|
121
106
|
env: 'AZTEC_TARGET_COMMITTEE_SIZE',
|
|
122
107
|
description: 'The target validator committee size.',
|
|
123
|
-
...numberConfigHelper(
|
|
108
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_TARGET_COMMITTEE_SIZE),
|
|
124
109
|
},
|
|
125
110
|
lagInEpochsForValidatorSet: {
|
|
126
111
|
env: 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET',
|
|
127
112
|
description: 'The number of epochs to lag behind the current epoch for validator selection.',
|
|
128
|
-
...numberConfigHelper(
|
|
113
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET),
|
|
129
114
|
},
|
|
130
115
|
lagInEpochsForRandao: {
|
|
131
116
|
env: 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO',
|
|
132
117
|
description: 'The number of epochs to lag behind the current epoch for randao selection.',
|
|
133
|
-
...numberConfigHelper(
|
|
118
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_LAG_IN_EPOCHS_FOR_RANDAO),
|
|
119
|
+
},
|
|
120
|
+
inboxLag: {
|
|
121
|
+
env: 'AZTEC_INBOX_LAG',
|
|
122
|
+
description: 'The number of checkpoints to lag in the inbox (prevents sequencer DOS attacks).',
|
|
123
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_INBOX_LAG),
|
|
134
124
|
},
|
|
135
125
|
aztecProofSubmissionEpochs: {
|
|
136
126
|
env: 'AZTEC_PROOF_SUBMISSION_EPOCHS',
|
|
137
127
|
description: 'The number of epochs after an epoch ends that proofs are still accepted.',
|
|
138
|
-
...numberConfigHelper(
|
|
128
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_PROOF_SUBMISSION_EPOCHS),
|
|
139
129
|
},
|
|
140
130
|
activationThreshold: {
|
|
141
131
|
env: 'AZTEC_ACTIVATION_THRESHOLD',
|
|
142
132
|
description: 'The deposit amount for a validator',
|
|
143
|
-
...bigintConfigHelper(
|
|
133
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_ACTIVATION_THRESHOLD)),
|
|
144
134
|
},
|
|
145
135
|
ejectionThreshold: {
|
|
146
136
|
env: 'AZTEC_EJECTION_THRESHOLD',
|
|
147
137
|
description: 'The minimum stake for a validator.',
|
|
148
|
-
...bigintConfigHelper(
|
|
138
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_EJECTION_THRESHOLD)),
|
|
149
139
|
},
|
|
150
140
|
localEjectionThreshold: {
|
|
151
141
|
env: 'AZTEC_LOCAL_EJECTION_THRESHOLD',
|
|
152
142
|
description:
|
|
153
143
|
'The local ejection threshold for a validator. Stricter than ejectionThreshold but local to a specific rollup',
|
|
154
|
-
...bigintConfigHelper(
|
|
144
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_LOCAL_EJECTION_THRESHOLD)),
|
|
155
145
|
},
|
|
156
146
|
slashingOffsetInRounds: {
|
|
157
147
|
env: 'AZTEC_SLASHING_OFFSET_IN_ROUNDS',
|
|
158
148
|
description:
|
|
159
149
|
'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
|
|
160
|
-
...numberConfigHelper(
|
|
150
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
|
|
161
151
|
},
|
|
162
152
|
slasherFlavor: {
|
|
163
153
|
env: 'AZTEC_SLASHER_FLAVOR',
|
|
164
154
|
description: 'Type of slasher proposer (empire, tally, or none)',
|
|
165
|
-
...enumConfigHelper(
|
|
155
|
+
...enumConfigHelper(
|
|
156
|
+
['empire', 'tally', 'none'] as const,
|
|
157
|
+
l1ContractsDefaultEnv.AZTEC_SLASHER_FLAVOR as 'empire' | 'tally' | 'none',
|
|
158
|
+
),
|
|
166
159
|
},
|
|
167
160
|
slashAmountSmall: {
|
|
168
161
|
env: 'AZTEC_SLASH_AMOUNT_SMALL',
|
|
169
162
|
description: 'Small slashing amount for light offenses',
|
|
170
|
-
...bigintConfigHelper(
|
|
163
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_SMALL)),
|
|
171
164
|
},
|
|
172
165
|
slashAmountMedium: {
|
|
173
166
|
env: 'AZTEC_SLASH_AMOUNT_MEDIUM',
|
|
174
167
|
description: 'Medium slashing amount for moderate offenses',
|
|
175
|
-
...bigintConfigHelper(
|
|
168
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_MEDIUM)),
|
|
176
169
|
},
|
|
177
170
|
slashAmountLarge: {
|
|
178
171
|
env: 'AZTEC_SLASH_AMOUNT_LARGE',
|
|
179
172
|
description: 'Large slashing amount for severe offenses',
|
|
180
|
-
...bigintConfigHelper(
|
|
173
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_SLASH_AMOUNT_LARGE)),
|
|
181
174
|
},
|
|
182
175
|
slashingQuorum: {
|
|
183
176
|
env: 'AZTEC_SLASHING_QUORUM',
|
|
@@ -187,28 +180,28 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
187
180
|
slashingRoundSizeInEpochs: {
|
|
188
181
|
env: 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS',
|
|
189
182
|
description: 'The slashing round size',
|
|
190
|
-
...numberConfigHelper(
|
|
183
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS),
|
|
191
184
|
},
|
|
192
185
|
slashingLifetimeInRounds: {
|
|
193
186
|
env: 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS',
|
|
194
187
|
description: 'The slashing lifetime in rounds',
|
|
195
|
-
...numberConfigHelper(
|
|
188
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_LIFETIME_IN_ROUNDS),
|
|
196
189
|
},
|
|
197
190
|
slashingExecutionDelayInRounds: {
|
|
198
191
|
env: 'AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS',
|
|
199
192
|
description: 'The slashing execution delay in rounds',
|
|
200
|
-
...numberConfigHelper(
|
|
193
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS),
|
|
201
194
|
},
|
|
202
195
|
slashingVetoer: {
|
|
203
196
|
env: 'AZTEC_SLASHING_VETOER',
|
|
204
197
|
description: 'The slashing vetoer',
|
|
205
198
|
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
206
|
-
defaultValue:
|
|
199
|
+
defaultValue: EthAddress.fromString(l1ContractsDefaultEnv.AZTEC_SLASHING_VETOER),
|
|
207
200
|
},
|
|
208
201
|
slashingDisableDuration: {
|
|
209
202
|
env: 'AZTEC_SLASHING_DISABLE_DURATION',
|
|
210
203
|
description: 'How long slashing can be disabled for in seconds when vetoer disables it',
|
|
211
|
-
...numberConfigHelper(
|
|
204
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_DISABLE_DURATION),
|
|
212
205
|
},
|
|
213
206
|
governanceProposerQuorum: {
|
|
214
207
|
env: 'AZTEC_GOVERNANCE_PROPOSER_QUORUM',
|
|
@@ -218,26 +211,42 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
218
211
|
governanceProposerRoundSize: {
|
|
219
212
|
env: 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE',
|
|
220
213
|
description: 'The governance proposing round size',
|
|
221
|
-
...numberConfigHelper(
|
|
214
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE),
|
|
215
|
+
},
|
|
216
|
+
governanceVotingDuration: {
|
|
217
|
+
env: 'AZTEC_GOVERNANCE_VOTING_DURATION',
|
|
218
|
+
description: 'Governance voting duration in seconds (only for local/devnet/next-net)',
|
|
219
|
+
...numberConfigHelper(3600), // 1 hour default, not in generated defaults as it's deployment-time only
|
|
222
220
|
},
|
|
223
221
|
manaTarget: {
|
|
224
222
|
env: 'AZTEC_MANA_TARGET',
|
|
225
223
|
description: 'The mana target for the rollup',
|
|
226
|
-
...bigintConfigHelper(
|
|
224
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_MANA_TARGET)),
|
|
227
225
|
},
|
|
228
226
|
provingCostPerMana: {
|
|
229
227
|
env: 'AZTEC_PROVING_COST_PER_MANA',
|
|
230
228
|
description: 'The proving cost per mana',
|
|
231
|
-
...bigintConfigHelper(
|
|
229
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_PROVING_COST_PER_MANA)),
|
|
230
|
+
},
|
|
231
|
+
initialEthPerFeeAsset: {
|
|
232
|
+
env: 'AZTEC_INITIAL_ETH_PER_FEE_ASSET',
|
|
233
|
+
description: 'The initial ETH per fee asset price (with 1e12 precision)',
|
|
234
|
+
...bigintConfigHelper(BigInt(l1ContractsDefaultEnv.AZTEC_INITIAL_ETH_PER_FEE_ASSET)),
|
|
232
235
|
},
|
|
233
236
|
exitDelaySeconds: {
|
|
234
237
|
env: 'AZTEC_EXIT_DELAY_SECONDS',
|
|
235
238
|
description: 'The delay before a validator can exit the set',
|
|
236
|
-
...numberConfigHelper(
|
|
239
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
|
|
237
240
|
},
|
|
238
241
|
...l1TxUtilsConfigMappings,
|
|
239
242
|
};
|
|
240
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Default L1 contracts configuration derived from l1ContractsConfigMappings.
|
|
246
|
+
* Source of truth: spartan/environments/defaults.yml -> defaults.l1-contracts
|
|
247
|
+
*/
|
|
248
|
+
export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
|
|
249
|
+
|
|
241
250
|
export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
|
|
242
251
|
testAccounts: {
|
|
243
252
|
env: 'TEST_ACCOUNTS',
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# L1 Contract Wrappers
|
|
2
|
+
|
|
3
|
+
This folder contains TypeScript wrappers for L1 contracts defined in `l1-contracts/`. These wrappers are used by the node client to interact with the rollup and related contracts on Ethereum.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
The goal of wrapping is to shield consumers from L1-specific and viem-specific details. Clients using these wrappers interact with domain types and branded types native to the Aztec codebase, without needing to understand viem's ABI type system or deal with raw types like `Hex` and `bigint`.
|
|
8
|
+
|
|
9
|
+
## Type Safety
|
|
10
|
+
|
|
11
|
+
### Explicit Return Types
|
|
12
|
+
|
|
13
|
+
Every function in the contract wrappers must declare its return type explicitly. This is critical because viem's type inference over ABI types is slow and significantly impacts IDE performance.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
// Good: Explicit return type
|
|
17
|
+
async getSlotNumber(): Promise<SlotNumber> {
|
|
18
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Bad: Inferred return type (slow)
|
|
22
|
+
async getSlotNumber() {
|
|
23
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Branded and Domain Types
|
|
28
|
+
|
|
29
|
+
Use branded types and domain-specific types instead of viem's autogenerated types for both arguments and return values:
|
|
30
|
+
|
|
31
|
+
- `CheckpointNumber`, `EpochNumber`, `SlotNumber` instead of `bigint`
|
|
32
|
+
- `EthAddress` instead of `` `0x${string}` `` or `Hex`
|
|
33
|
+
- `Fr`, `Buffer32` instead of `Hex` for hashes and field elements
|
|
34
|
+
- Custom domain types (e.g., `CheckpointLog`, `AttesterView`) instead of raw tuples
|
|
35
|
+
|
|
36
|
+
Type conversions happen inside wrapper methods, not at the call site:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
async getCheckpoint(checkpointNumber: CheckpointNumber): Promise<CheckpointLog> {
|
|
40
|
+
const result = await this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
|
|
41
|
+
return {
|
|
42
|
+
archive: Fr.fromString(result.archive),
|
|
43
|
+
headerHash: Buffer32.fromString(result.headerHash),
|
|
44
|
+
blockCount: result.blockCount,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Wrapper Pattern
|
|
50
|
+
|
|
51
|
+
### Basic Structure
|
|
52
|
+
|
|
53
|
+
Each wrapper follows a consistent structure:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
export class FooContract {
|
|
57
|
+
private readonly foo: GetContractReturnType<typeof FooAbi, ViemClient>;
|
|
58
|
+
|
|
59
|
+
constructor(
|
|
60
|
+
public readonly client: ViemClient,
|
|
61
|
+
address: Hex | EthAddress,
|
|
62
|
+
) {
|
|
63
|
+
if (address instanceof EthAddress) {
|
|
64
|
+
address = address.toString();
|
|
65
|
+
}
|
|
66
|
+
this.foo = getContract({ address, abi: FooAbi, client });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public get address(): Hex {
|
|
70
|
+
return this.foo.address;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public getContract(): GetContractReturnType<typeof FooAbi, ViemClient> {
|
|
74
|
+
return this.foo;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The raw contract is exposed via `getContract()` for cases where direct access is needed, but most consumers should use the typed wrapper methods. Relying on `getContract()` is a code smell and should be avoided.
|
|
80
|
+
|
|
81
|
+
### Static Factory Methods
|
|
82
|
+
|
|
83
|
+
Wrappers may provide static factory methods for common initialization patterns:
|
|
84
|
+
|
|
85
|
+
- `getFromConfig(config)` - construct from configuration object
|
|
86
|
+
- `getFromL1ContractsValues(deployResult)` - construct from deployment result
|
|
87
|
+
|
|
88
|
+
### Wallet Assertions
|
|
89
|
+
|
|
90
|
+
For write operations that require a wallet, use an assertion helper:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
private assertWallet(): GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient> {
|
|
94
|
+
if (!isExtendedClient(this.client)) {
|
|
95
|
+
throw new Error('Wallet client is required for this operation');
|
|
96
|
+
}
|
|
97
|
+
return this.foo as GetContractReturnType<typeof FooAbi, ExtendedViemWalletClient>;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Event Handling
|
|
102
|
+
|
|
103
|
+
### Event Log Types
|
|
104
|
+
|
|
105
|
+
Event logs are wrapped in `L1EventLog<T>` to include L1 block context:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
type L1EventLog<T> = {
|
|
109
|
+
l1BlockNumber: bigint;
|
|
110
|
+
l1BlockHash: Buffer32;
|
|
111
|
+
l1TransactionHash: Hex;
|
|
112
|
+
args: T;
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Event Fetching
|
|
117
|
+
|
|
118
|
+
Methods that fetch events convert viem's raw logs to domain types:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
async getCheckpointProposedEvents(fromBlock: bigint, toBlock: bigint): Promise<CheckpointProposedLog[]> {
|
|
122
|
+
const logs = await this.rollup.getEvents.CheckpointProposed({}, { fromBlock, toBlock });
|
|
123
|
+
return logs.map(log => ({
|
|
124
|
+
l1BlockNumber: log.blockNumber!,
|
|
125
|
+
l1BlockHash: Buffer32.fromString(log.blockHash!),
|
|
126
|
+
l1TransactionHash: log.transactionHash!,
|
|
127
|
+
args: {
|
|
128
|
+
checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber!),
|
|
129
|
+
// ... convert other fields
|
|
130
|
+
},
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Event Listeners
|
|
136
|
+
|
|
137
|
+
For reactive event handling, wrapper methods convert arguments before invoking callbacks:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
public listenToCheckpointInvalidated(
|
|
141
|
+
callback: (args: { checkpointNumber: CheckpointNumber }) => unknown,
|
|
142
|
+
): WatchContractEventReturnType {
|
|
143
|
+
return this.rollup.watchEvent.CheckpointInvalidated({}, {
|
|
144
|
+
onLogs: logs => {
|
|
145
|
+
for (const log of logs) {
|
|
146
|
+
if (log.args.checkpointNumber !== undefined) {
|
|
147
|
+
callback({ checkpointNumber: CheckpointNumber.fromBigInt(log.args.checkpointNumber) });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Error Handling
|
|
156
|
+
|
|
157
|
+
Custom error classes in `errors.ts` extend `Error` and set `this.name` for proper error identification. Include relevant context as public readonly properties.
|
|
@@ -12,7 +12,7 @@ export interface IEmpireBase {
|
|
|
12
12
|
getRoundInfo(
|
|
13
13
|
rollupAddress: Hex,
|
|
14
14
|
round: bigint,
|
|
15
|
-
): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; executed: boolean }>;
|
|
15
|
+
): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; quorumReached: boolean; executed: boolean }>;
|
|
16
16
|
computeRound(slot: SlotNumber): Promise<bigint>;
|
|
17
17
|
createSignalRequest(payload: Hex): L1TxRequest;
|
|
18
18
|
createSignalRequestWithSignature(
|