@aztec/ethereum 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05
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.d.ts +16 -2
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +27 -3
- package/dest/config.d.ts +26 -73
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +64 -387
- package/dest/contracts/chain_state_override.d.ts +38 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +100 -0
- package/dest/contracts/empire_base.d.ts +4 -1
- package/dest/contracts/empire_base.d.ts.map +1 -1
- 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/fee_asset_price_oracle.d.ts +101 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +651 -0
- package/dest/contracts/governance.d.ts +3 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +14 -4
- package/dest/contracts/governance_proposer.d.ts +4 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +404 -9
- package/dest/contracts/inbox.d.ts +24 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +41 -1
- package/dest/contracts/index.d.ts +6 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +5 -2
- 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 +51 -2
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +87 -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/registry.d.ts +3 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +30 -1
- package/dest/contracts/rollup.d.ts +5178 -108
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +1004 -188
- package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +5 -5
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +18 -13
- package/dest/deploy_aztec_l1_contracts.d.ts +256 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +411 -0
- package/dest/deploy_l1_contract.d.ts +68 -0
- package/dest/deploy_l1_contract.d.ts.map +1 -0
- package/dest/deploy_l1_contract.js +312 -0
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- 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 +14161 -17158
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +9 -24
- package/dest/l1_contract_addresses.d.ts +1 -5
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +3 -9
- package/dest/l1_reader.d.ts +5 -1
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +13 -2
- package/dest/l1_tx_utils/config.d.ts +9 -3
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +31 -4
- 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/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- 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/forwarder_l1_tx_utils.d.ts +41 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +42 -0
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/index-blobs.js +2 -0
- package/dest/l1_tx_utils/index.d.ts +4 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +3 -0
- package/dest/l1_tx_utils/interfaces.d.ts +2 -2
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -1
- 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.d.ts +20 -7
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +98 -61
- 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 +61 -164
- package/dest/l1_tx_utils/tx_delayer.d.ts +56 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +65 -36
- package/dest/publisher_manager.d.ts +21 -6
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +81 -7
- package/dest/queries.d.ts +14 -3
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +74 -7
- package/dest/test/chain_monitor.d.ts +36 -14
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +45 -11
- package/dest/test/eth_cheat_codes.d.ts +18 -4
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +10 -6
- package/dest/test/index.d.ts +1 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -2
- package/dest/test/rollup_cheat_codes.d.ts +13 -6
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +41 -7
- package/dest/test/start_anvil.d.ts +24 -2
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +143 -29
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/types.d.ts +57 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/utils.d.ts +16 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +80 -12
- package/package.json +33 -16
- package/src/client.ts +28 -2
- package/src/config.ts +82 -468
- package/src/contracts/README.md +157 -0
- package/src/contracts/chain_state_override.ts +147 -0
- package/src/contracts/empire_base.ts +3 -1
- package/src/contracts/fee_asset_handler.ts +10 -7
- package/src/contracts/fee_asset_price_oracle.ts +280 -0
- package/src/contracts/governance.ts +13 -4
- package/src/contracts/governance_proposer.ts +16 -2
- package/src/contracts/inbox.ts +63 -3
- package/src/contracts/index.ts +5 -2
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +70 -3
- package/src/contracts/outbox.ts +98 -0
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +701 -149
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +18 -14
- package/src/deploy_aztec_l1_contracts.ts +646 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +21 -26
- package/src/l1_reader.ts +22 -2
- package/src/l1_tx_utils/config.ts +44 -6
- package/src/l1_tx_utils/constants.ts +13 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- 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/forwarder_l1_tx_utils.ts +108 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +3 -0
- package/src/l1_tx_utils/interfaces.ts +1 -1
- package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +98 -40
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +75 -210
- package/src/{test → l1_tx_utils}/tx_delayer.ts +82 -52
- package/src/publisher_manager.ts +107 -10
- package/src/queries.ts +81 -7
- package/src/test/chain_monitor.ts +82 -18
- package/src/test/eth_cheat_codes.ts +8 -6
- package/src/test/index.ts +0 -2
- package/src/test/rollup_cheat_codes.ts +43 -10
- package/src/test/start_anvil.ts +178 -28
- package/src/test/upgrade_utils.ts +2 -2
- package/src/types.ts +62 -0
- package/src/utils.ts +100 -15
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -66
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -200
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.d.ts +0 -673
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -1491
- package/dest/index.d.ts +0 -18
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -17
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/contracts/empire_slashing_proposer.ts +0 -265
- package/src/deploy_l1_contracts.ts +0 -1869
- package/src/index.ts +0 -17
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
package/src/types.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
Client,
|
|
6
6
|
FallbackTransport,
|
|
7
7
|
GetContractReturnType,
|
|
8
|
+
Hex,
|
|
8
9
|
HttpTransport,
|
|
9
10
|
PublicActions,
|
|
10
11
|
PublicClient,
|
|
@@ -16,6 +17,67 @@ import type {
|
|
|
16
17
|
/** Type for a viem public client */
|
|
17
18
|
export type ViemPublicClient = PublicClient<FallbackTransport<HttpTransport[]>, Chain>;
|
|
18
19
|
|
|
20
|
+
export type PublicRpcDebugSchema = [
|
|
21
|
+
{
|
|
22
|
+
Method: 'debug_traceTransaction';
|
|
23
|
+
Parameters: [txHash: `0x${string}`, options: { tracer: 'callTracer' }];
|
|
24
|
+
ReturnType: DebugCallTrace;
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
Method: 'trace_transaction';
|
|
28
|
+
Parameters: [txHash: `0x${string}`];
|
|
29
|
+
ReturnType: TraceTransactionResponse[];
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/** Return type for a debug_traceTransaction call */
|
|
34
|
+
export type DebugCallTrace = {
|
|
35
|
+
from: Hex;
|
|
36
|
+
to?: Hex;
|
|
37
|
+
type: string;
|
|
38
|
+
input?: Hex;
|
|
39
|
+
output?: Hex;
|
|
40
|
+
gas?: Hex;
|
|
41
|
+
gasUsed?: Hex;
|
|
42
|
+
value?: Hex;
|
|
43
|
+
error?: string;
|
|
44
|
+
calls?: DebugCallTrace[];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Action object for a trace_transaction call */
|
|
48
|
+
export type TraceAction = {
|
|
49
|
+
from: Hex;
|
|
50
|
+
to?: Hex;
|
|
51
|
+
callType: string;
|
|
52
|
+
gas?: Hex;
|
|
53
|
+
input?: Hex;
|
|
54
|
+
value?: Hex;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Result object for a trace_transaction call */
|
|
58
|
+
export type TraceResult = {
|
|
59
|
+
gasUsed?: Hex;
|
|
60
|
+
output?: Hex;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** Return type for a single trace in trace_transaction response */
|
|
64
|
+
export type TraceTransactionResponse = {
|
|
65
|
+
action: TraceAction;
|
|
66
|
+
result?: TraceResult;
|
|
67
|
+
error?: string;
|
|
68
|
+
subtraces: number;
|
|
69
|
+
traceAddress: number[];
|
|
70
|
+
type: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** Type for a viem public client with support for debug methods */
|
|
74
|
+
export type ViemPublicDebugClient = PublicClient<
|
|
75
|
+
FallbackTransport<HttpTransport[]>,
|
|
76
|
+
Chain,
|
|
77
|
+
undefined,
|
|
78
|
+
[...PublicRpcSchema, ...PublicRpcDebugSchema]
|
|
79
|
+
>;
|
|
80
|
+
|
|
19
81
|
export type ExtendedViemWalletClient = Client<
|
|
20
82
|
FallbackTransport<readonly HttpTransport[]>,
|
|
21
83
|
Chain,
|
package/src/utils.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
3
|
import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
type Abi,
|
|
7
|
+
type AbiItem,
|
|
7
8
|
BaseError,
|
|
8
9
|
type ContractEventName,
|
|
9
10
|
ContractFunctionRevertedError,
|
|
10
11
|
type DecodeEventLogReturnType,
|
|
12
|
+
type FormattedTransaction,
|
|
11
13
|
type Hex,
|
|
12
14
|
type Log,
|
|
13
15
|
decodeErrorResult,
|
|
14
16
|
decodeEventLog,
|
|
15
17
|
} from 'viem';
|
|
18
|
+
import { formatAbiItem, formatAbiParams } from 'viem/utils';
|
|
16
19
|
|
|
17
20
|
export interface L2Claim {
|
|
18
21
|
claimSecret: Fr;
|
|
@@ -92,6 +95,57 @@ export function prettyLogViemErrorMsg(err: any) {
|
|
|
92
95
|
return err?.message ?? err;
|
|
93
96
|
}
|
|
94
97
|
|
|
98
|
+
export function mergeAbis(abis: Abi[]): Abi {
|
|
99
|
+
let merged: Abi = [];
|
|
100
|
+
const seen = new Set<string>();
|
|
101
|
+
|
|
102
|
+
for (const abi of abis) {
|
|
103
|
+
for (const item of abi) {
|
|
104
|
+
const key = getAbiItemKey(item);
|
|
105
|
+
if (!seen.has(key)) {
|
|
106
|
+
seen.add(key);
|
|
107
|
+
merged = [...merged, item];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return merged;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function getAbiItemKey(item: AbiItem): string {
|
|
116
|
+
if (item.type === 'function') {
|
|
117
|
+
const signature = formatAbiItem(item);
|
|
118
|
+
const outputs = formatAbiParams(item.outputs);
|
|
119
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
120
|
+
return `function:${signature}:${outputs}:${stateMutability}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (item.type === 'event') {
|
|
124
|
+
const signature = formatAbiItem(item);
|
|
125
|
+
const indexed = (item.inputs ?? []).map(input => ((input as { indexed?: boolean }).indexed ? '1' : '0')).join('');
|
|
126
|
+
const anonymous = item.anonymous ? 'anonymous' : 'not-anonymous';
|
|
127
|
+
return `event:${signature}:${indexed}:${anonymous}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (item.type === 'error') {
|
|
131
|
+
const signature = formatAbiItem(item);
|
|
132
|
+
return `error:${signature}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (item.type === 'constructor') {
|
|
136
|
+
const inputs = formatAbiParams(item.inputs);
|
|
137
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
138
|
+
return `constructor::${inputs}:${stateMutability}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (item.type === 'fallback' || item.type === 'receive') {
|
|
142
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
143
|
+
return `${item.type}:::${stateMutability}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return 'unknown';
|
|
147
|
+
}
|
|
148
|
+
|
|
95
149
|
function getNestedErrorData(error: unknown): string | undefined {
|
|
96
150
|
// If nothing, bail
|
|
97
151
|
if (!error) {
|
|
@@ -116,6 +170,21 @@ function getNestedErrorData(error: unknown): string | undefined {
|
|
|
116
170
|
return undefined;
|
|
117
171
|
}
|
|
118
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Truncates an error message to a safe length for log renderers.
|
|
175
|
+
* LogExplorer can only render up to 2500 characters in its summary view.
|
|
176
|
+
* We cap at 2000 to leave room for decorating context added by callers.
|
|
177
|
+
*/
|
|
178
|
+
function truncateErrorMessage(message: string): string {
|
|
179
|
+
const MAX = 2000;
|
|
180
|
+
const CHUNK = 950;
|
|
181
|
+
if (message.length <= MAX) {
|
|
182
|
+
return message;
|
|
183
|
+
}
|
|
184
|
+
const truncated = message.length - 2 * CHUNK;
|
|
185
|
+
return message.slice(0, CHUNK) + `...${truncated} characters truncated...` + message.slice(-CHUNK);
|
|
186
|
+
}
|
|
187
|
+
|
|
119
188
|
/**
|
|
120
189
|
* Formats a Viem error into a FormattedViemError instance.
|
|
121
190
|
* @param error - The error to format.
|
|
@@ -178,22 +247,10 @@ export function formatViemError(error: any, abi: Abi = ErrorsAbi): FormattedViem
|
|
|
178
247
|
|
|
179
248
|
// If it's a regular Error instance, return it with its message
|
|
180
249
|
if (error instanceof Error) {
|
|
181
|
-
return new FormattedViemError(error.message, (error as any)?.metaMessages);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const body = String(error);
|
|
185
|
-
const length = body.length;
|
|
186
|
-
// LogExplorer can only render up to 2500 characters in it's summary view. Try to keep the whole message below this number
|
|
187
|
-
// Limit the error to 2000 chacaters in order to allow code higher up to decorate this error with extra details (up to 500 characters)
|
|
188
|
-
if (length > 2000) {
|
|
189
|
-
const chunk = 950;
|
|
190
|
-
const truncated = length - 2 * chunk;
|
|
191
|
-
return new FormattedViemError(
|
|
192
|
-
body.slice(0, chunk) + `...${truncated} characters truncated...` + body.slice(-1 * chunk),
|
|
193
|
-
);
|
|
250
|
+
return new FormattedViemError(truncateErrorMessage(error.message), (error as any)?.metaMessages);
|
|
194
251
|
}
|
|
195
252
|
|
|
196
|
-
return new FormattedViemError(
|
|
253
|
+
return new FormattedViemError(truncateErrorMessage(String(error)));
|
|
197
254
|
}
|
|
198
255
|
|
|
199
256
|
function stripAbis(obj: any) {
|
|
@@ -233,3 +290,31 @@ export function tryGetCustomErrorName(err: any) {
|
|
|
233
290
|
return undefined;
|
|
234
291
|
}
|
|
235
292
|
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Type guard to check if a transaction is a blob transaction (EIP-4844).
|
|
296
|
+
* Blob transactions have maxFeePerBlobGas and blobVersionedHashes fields.
|
|
297
|
+
*/
|
|
298
|
+
export function isBlobTransaction(tx: FormattedTransaction): tx is FormattedTransaction & {
|
|
299
|
+
maxFeePerBlobGas: bigint;
|
|
300
|
+
blobVersionedHashes: readonly Hex[];
|
|
301
|
+
} {
|
|
302
|
+
return (
|
|
303
|
+
'maxFeePerBlobGas' in tx &&
|
|
304
|
+
tx.maxFeePerBlobGas !== undefined &&
|
|
305
|
+
'blobVersionedHashes' in tx &&
|
|
306
|
+
tx.blobVersionedHashes !== undefined
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Calculates a percentile from an array of bigints
|
|
312
|
+
*/
|
|
313
|
+
export function calculatePercentile(values: bigint[], percentile: number): bigint {
|
|
314
|
+
if (values.length === 0) {
|
|
315
|
+
return 0n;
|
|
316
|
+
}
|
|
317
|
+
const sorted = [...values].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
318
|
+
const index = Math.ceil((sorted.length - 1) * (percentile / 100));
|
|
319
|
+
return sorted[index];
|
|
320
|
+
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import EventEmitter from 'events';
|
|
4
|
-
import { type Hex, type Log, type TypedDataDefinition } from 'viem';
|
|
5
|
-
import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
|
|
6
|
-
import type { ViemClient } from '../types.js';
|
|
7
|
-
import { type IEmpireBase } from './empire_base.js';
|
|
8
|
-
export declare class ProposalAlreadyExecutedError extends Error {
|
|
9
|
-
constructor(round: bigint);
|
|
10
|
-
}
|
|
11
|
-
export declare class EmpireSlashingProposerContract extends EventEmitter implements IEmpireBase {
|
|
12
|
-
readonly client: ViemClient;
|
|
13
|
-
private readonly logger;
|
|
14
|
-
private readonly proposer;
|
|
15
|
-
readonly type: "empire";
|
|
16
|
-
constructor(client: ViemClient, address: Hex | EthAddress);
|
|
17
|
-
get address(): EthAddress;
|
|
18
|
-
getQuorumSize(): Promise<bigint>;
|
|
19
|
-
getRoundSize(): Promise<bigint>;
|
|
20
|
-
getLifetimeInRounds(): Promise<bigint>;
|
|
21
|
-
getExecutionDelayInRounds(): Promise<bigint>;
|
|
22
|
-
getCurrentRound(): Promise<bigint>;
|
|
23
|
-
computeRound(slot: SlotNumber): Promise<bigint>;
|
|
24
|
-
getInstance(): Promise<`0x${string}`>;
|
|
25
|
-
getRoundInfo(rollupAddress: Hex, round: bigint): Promise<{
|
|
26
|
-
lastSignalSlot: SlotNumber;
|
|
27
|
-
payloadWithMostSignals: Hex;
|
|
28
|
-
executed: boolean;
|
|
29
|
-
}>;
|
|
30
|
-
getPayloadSignals(rollupAddress: Hex, round: bigint, payload: Hex): Promise<bigint>;
|
|
31
|
-
createSignalRequest(payload: Hex): L1TxRequest;
|
|
32
|
-
createSignalRequestWithSignature(payload: Hex, slot: SlotNumber, chainId: number, signerAddress: Hex, signer: (msg: TypedDataDefinition) => Promise<Hex>): Promise<L1TxRequest>;
|
|
33
|
-
listenToSubmittablePayloads(callback: (args: {
|
|
34
|
-
payload: `0x${string}`;
|
|
35
|
-
round: bigint;
|
|
36
|
-
}) => unknown): import("viem").WatchContractEventReturnType;
|
|
37
|
-
listenToPayloadSubmitted(callback: (args: {
|
|
38
|
-
round: bigint;
|
|
39
|
-
payload: `0x${string}`;
|
|
40
|
-
}) => unknown): import("viem").WatchContractEventReturnType;
|
|
41
|
-
listenToSignalCasted(callback: (args: {
|
|
42
|
-
round: bigint;
|
|
43
|
-
payload: `0x${string}`;
|
|
44
|
-
signaler: `0x${string}`;
|
|
45
|
-
}) => unknown): import("viem").WatchContractEventReturnType;
|
|
46
|
-
/** Creates an L1TxRequest to submit the round winner for the given round. */
|
|
47
|
-
buildExecuteRoundRequest(round: bigint): L1TxRequest;
|
|
48
|
-
/** Tries to extract a PayloadSubmitted event from the given logs. */
|
|
49
|
-
tryExtractPayloadSubmittedEvent(logs: Log[]): {
|
|
50
|
-
eventName: "PayloadSubmitted";
|
|
51
|
-
args: {
|
|
52
|
-
payload: `0x${string}`;
|
|
53
|
-
round: bigint;
|
|
54
|
-
};
|
|
55
|
-
} | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Wait for a round to be reached.
|
|
58
|
-
*
|
|
59
|
-
* @param round - The round to wait for.
|
|
60
|
-
* @param pollingIntervalSeconds - The interval in seconds to poll for the round.
|
|
61
|
-
* @returns True if the round was reached, false otherwise.
|
|
62
|
-
*/
|
|
63
|
-
waitForRound(round: bigint, pollingIntervalSeconds?: number): Promise<boolean>;
|
|
64
|
-
executeRound(txUtils: L1TxUtils, round: bigint | number): ReturnType<typeof txUtils.sendAndMonitorTransaction>;
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1waXJlX3NsYXNoaW5nX3Byb3Bvc2VyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RzL2VtcGlyZV9zbGFzaGluZ19wcm9wb3Nlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDN0QsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBSzNELE9BQU8sWUFBWSxNQUFNLFFBQVEsQ0FBQztBQUNsQyxPQUFPLEVBR0wsS0FBSyxHQUFHLEVBQ1IsS0FBSyxHQUFHLEVBQ1Is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E,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO,+CAcrG;IAEM,oBAAoB,CACzB,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO,+CAehG;IAED,6EAA6E;IACtE,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAS1D;IAED,qEAAqE;IAC9D,+BAA+B,CAAC,IAAI,EAAE,GAAG,EAAE;;;;;;kBAEjD;IAED;;;;;;OAMG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,sBAAsB,GAAE,MAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAavF;IAEY,YAAY,CACvB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,MAAM,GAAG,MAAM,GACrB,UAAU,CAAC,OAAO,OAAO,CAAC,yBAAyB,CAAC,CAgDtD;CACF"}
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
5
|
-
import { EmpireSlashingProposerAbi } from '@aztec/l1-artifacts/EmpireSlashingProposerAbi';
|
|
6
|
-
import EventEmitter from 'events';
|
|
7
|
-
import { encodeFunctionData, getContract } from 'viem';
|
|
8
|
-
import { FormattedViemError, tryExtractEvent } from '../utils.js';
|
|
9
|
-
import { encodeSignal, encodeSignalWithSignature, signSignalWithSig } from './empire_base.js';
|
|
10
|
-
export class ProposalAlreadyExecutedError extends Error {
|
|
11
|
-
constructor(round){
|
|
12
|
-
super(`Proposal already executed: ${round}`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export class EmpireSlashingProposerContract extends EventEmitter {
|
|
16
|
-
client;
|
|
17
|
-
logger;
|
|
18
|
-
proposer;
|
|
19
|
-
type;
|
|
20
|
-
constructor(client, address){
|
|
21
|
-
super(), this.client = client, this.logger = createLogger('ethereum:contracts:empire_slashing_proposer'), this.type = 'empire';
|
|
22
|
-
this.proposer = getContract({
|
|
23
|
-
address: typeof address === 'string' ? address : address.toString(),
|
|
24
|
-
abi: EmpireSlashingProposerAbi,
|
|
25
|
-
client
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
get address() {
|
|
29
|
-
return EthAddress.fromString(this.proposer.address);
|
|
30
|
-
}
|
|
31
|
-
getQuorumSize() {
|
|
32
|
-
return this.proposer.read.QUORUM_SIZE();
|
|
33
|
-
}
|
|
34
|
-
getRoundSize() {
|
|
35
|
-
return this.proposer.read.ROUND_SIZE();
|
|
36
|
-
}
|
|
37
|
-
getLifetimeInRounds() {
|
|
38
|
-
return this.proposer.read.LIFETIME_IN_ROUNDS();
|
|
39
|
-
}
|
|
40
|
-
getExecutionDelayInRounds() {
|
|
41
|
-
return this.proposer.read.EXECUTION_DELAY_IN_ROUNDS();
|
|
42
|
-
}
|
|
43
|
-
getCurrentRound() {
|
|
44
|
-
return this.proposer.read.getCurrentRound();
|
|
45
|
-
}
|
|
46
|
-
computeRound(slot) {
|
|
47
|
-
return this.proposer.read.computeRound([
|
|
48
|
-
BigInt(slot)
|
|
49
|
-
]);
|
|
50
|
-
}
|
|
51
|
-
getInstance() {
|
|
52
|
-
return this.proposer.read.getInstance();
|
|
53
|
-
}
|
|
54
|
-
async getRoundInfo(rollupAddress, round) {
|
|
55
|
-
const result = await this.proposer.read.getRoundData([
|
|
56
|
-
rollupAddress,
|
|
57
|
-
round
|
|
58
|
-
]);
|
|
59
|
-
return {
|
|
60
|
-
lastSignalSlot: SlotNumber.fromBigInt(result.lastSignalSlot),
|
|
61
|
-
payloadWithMostSignals: result.payloadWithMostSignals,
|
|
62
|
-
executed: result.executed
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
getPayloadSignals(rollupAddress, round, payload) {
|
|
66
|
-
return this.proposer.read.signalCount([
|
|
67
|
-
rollupAddress,
|
|
68
|
-
round,
|
|
69
|
-
payload
|
|
70
|
-
]);
|
|
71
|
-
}
|
|
72
|
-
createSignalRequest(payload) {
|
|
73
|
-
return {
|
|
74
|
-
to: this.address.toString(),
|
|
75
|
-
data: encodeSignal(payload)
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
async createSignalRequestWithSignature(payload, slot, chainId, signerAddress, signer) {
|
|
79
|
-
const signature = await signSignalWithSig(signer, payload, slot, await this.getInstance(), this.address.toString(), chainId);
|
|
80
|
-
return {
|
|
81
|
-
to: this.address.toString(),
|
|
82
|
-
data: encodeSignalWithSignature(payload, signature)
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
listenToSubmittablePayloads(callback) {
|
|
86
|
-
return this.proposer.watchEvent.PayloadSubmittable({}, {
|
|
87
|
-
strict: true,
|
|
88
|
-
onLogs: (logs)=>{
|
|
89
|
-
for (const log of logs){
|
|
90
|
-
const { payload, round } = log.args;
|
|
91
|
-
if (payload && round) {
|
|
92
|
-
callback({
|
|
93
|
-
payload,
|
|
94
|
-
round
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
listenToPayloadSubmitted(callback) {
|
|
102
|
-
return this.proposer.watchEvent.PayloadSubmitted({}, {
|
|
103
|
-
onLogs: (logs)=>{
|
|
104
|
-
for (const log of logs){
|
|
105
|
-
const { payload, round } = log.args;
|
|
106
|
-
if (round && payload) {
|
|
107
|
-
callback({
|
|
108
|
-
round,
|
|
109
|
-
payload
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
listenToSignalCasted(callback) {
|
|
117
|
-
return this.proposer.watchEvent.SignalCast({}, {
|
|
118
|
-
onLogs: (logs)=>{
|
|
119
|
-
for (const log of logs){
|
|
120
|
-
const { round, payload, signaler } = log.args;
|
|
121
|
-
if (round && payload && signaler) {
|
|
122
|
-
callback({
|
|
123
|
-
round,
|
|
124
|
-
payload,
|
|
125
|
-
signaler
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
/** Creates an L1TxRequest to submit the round winner for the given round. */ buildExecuteRoundRequest(round) {
|
|
133
|
-
return {
|
|
134
|
-
to: this.address.toString(),
|
|
135
|
-
data: encodeFunctionData({
|
|
136
|
-
abi: EmpireSlashingProposerAbi,
|
|
137
|
-
functionName: 'submitRoundWinner',
|
|
138
|
-
args: [
|
|
139
|
-
round
|
|
140
|
-
]
|
|
141
|
-
})
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/** Tries to extract a PayloadSubmitted event from the given logs. */ tryExtractPayloadSubmittedEvent(logs) {
|
|
145
|
-
return tryExtractEvent(logs, this.address.toString(), EmpireSlashingProposerAbi, 'PayloadSubmitted');
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Wait for a round to be reached.
|
|
149
|
-
*
|
|
150
|
-
* @param round - The round to wait for.
|
|
151
|
-
* @param pollingIntervalSeconds - The interval in seconds to poll for the round.
|
|
152
|
-
* @returns True if the round was reached, false otherwise.
|
|
153
|
-
*/ waitForRound(round, pollingIntervalSeconds = 1) {
|
|
154
|
-
return retryUntil(async ()=>{
|
|
155
|
-
const currentRound = await this.proposer.read.getCurrentRound().catch((e)=>{
|
|
156
|
-
this.logger.error('Error getting current round', e);
|
|
157
|
-
return undefined;
|
|
158
|
-
});
|
|
159
|
-
return currentRound !== undefined && currentRound >= round;
|
|
160
|
-
}, `Waiting for round ${round} to be reached`, 0, pollingIntervalSeconds).catch(()=>false);
|
|
161
|
-
}
|
|
162
|
-
async executeRound(txUtils, round) {
|
|
163
|
-
if (typeof round === 'number') {
|
|
164
|
-
round = BigInt(round);
|
|
165
|
-
}
|
|
166
|
-
const args = {
|
|
167
|
-
abi: EmpireSlashingProposerAbi,
|
|
168
|
-
functionName: 'submitRoundWinner',
|
|
169
|
-
args: [
|
|
170
|
-
round
|
|
171
|
-
]
|
|
172
|
-
};
|
|
173
|
-
const data = encodeFunctionData(args);
|
|
174
|
-
const response = await txUtils.sendAndMonitorTransaction({
|
|
175
|
-
to: this.address.toString(),
|
|
176
|
-
data
|
|
177
|
-
}, {
|
|
178
|
-
// Gas estimation is way off for this, likely because we are creating the contract/selector to call
|
|
179
|
-
// for the actual slashing dynamically.
|
|
180
|
-
gasLimitBufferPercentage: 50
|
|
181
|
-
}).catch((err)=>{
|
|
182
|
-
if (err instanceof FormattedViemError && err.message.includes('ProposalAlreadyExecuted')) {
|
|
183
|
-
throw new ProposalAlreadyExecutedError(round);
|
|
184
|
-
}
|
|
185
|
-
throw err;
|
|
186
|
-
});
|
|
187
|
-
if (response.receipt.status === 'reverted') {
|
|
188
|
-
const error = await txUtils.tryGetErrorFromRevertedTx(data, {
|
|
189
|
-
...args,
|
|
190
|
-
address: this.address.toString()
|
|
191
|
-
}, undefined, []);
|
|
192
|
-
if (error?.includes('ProposalAlreadyExecuted')) {
|
|
193
|
-
throw new ProposalAlreadyExecutedError(round);
|
|
194
|
-
}
|
|
195
|
-
const errorMessage = `Failed to execute round ${round}, TxHash: ${response.receipt.transactionHash}, Error: ${error ?? 'Unknown error'}`;
|
|
196
|
-
throw new Error(errorMessage);
|
|
197
|
-
}
|
|
198
|
-
return response;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tally_slashing_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/tally_slashing_proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAmB,MAAM,iBAAiB,CAAC;AAC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