@aztec/ethereum 0.86.0 → 0.87.0-nightly.20250521
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 +1 -1
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +1 -1
- package/dest/contracts/errors.d.ts +4 -0
- package/dest/contracts/errors.d.ts.map +1 -0
- package/dest/contracts/errors.js +6 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/forwarder.d.ts.map +1 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +1 -0
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- 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 +2 -0
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +2 -0
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +2 -2
- package/dest/contracts/rollup.d.ts +6 -2
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +13 -2
- package/dest/contracts/slashing_proposer.d.ts.map +1 -1
- 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 +1275 -634
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +22 -25
- package/dest/eth_cheat_codes.d.ts.map +1 -1
- package/dest/eth_cheat_codes.js +8 -1
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/l1_tx_utils.d.ts +12 -11
- package/dest/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils.js +1 -1
- 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/test/chain_monitor.d.ts +6 -3
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +27 -5
- package/dest/test/tx_delayer.d.ts +6 -2
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +41 -9
- package/dest/utils.js +2 -2
- package/package.json +7 -7
- package/src/client.ts +2 -2
- package/src/contracts/errors.ts +6 -0
- package/src/contracts/fee_asset_handler.ts +4 -1
- package/src/contracts/fee_juice.ts +4 -1
- package/src/contracts/forwarder.ts +5 -1
- package/src/contracts/governance.ts +9 -2
- package/src/contracts/governance_proposer.ts +4 -1
- package/src/contracts/inbox.ts +63 -0
- package/src/contracts/index.ts +2 -0
- package/src/contracts/registry.ts +6 -3
- package/src/contracts/rollup.ts +17 -3
- package/src/contracts/slashing_proposer.ts +4 -1
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_l1_contracts.ts +23 -19
- package/src/eth_cheat_codes.ts +8 -1
- package/src/index.ts +1 -0
- package/src/l1_tx_utils.ts +2 -1
- package/src/l1_types.ts +6 -0
- package/src/test/chain_monitor.ts +26 -4
- package/src/test/tx_delayer.ts +55 -13
- package/src/utils.ts +2 -2
package/src/test/tx_delayer.ts
CHANGED
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
type Client,
|
|
8
8
|
type Hex,
|
|
9
9
|
type PublicClient,
|
|
10
|
+
type TransactionSerializableEIP4844,
|
|
10
11
|
keccak256,
|
|
11
12
|
parseTransaction,
|
|
12
13
|
publicActions,
|
|
14
|
+
serializeTransaction,
|
|
13
15
|
walletActions,
|
|
14
16
|
} from 'viem';
|
|
15
17
|
|
|
@@ -59,12 +61,16 @@ export function waitUntilL1Timestamp<T extends Client>(client: T, timestamp: num
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
export interface Delayer {
|
|
62
|
-
/** Returns the
|
|
63
|
-
|
|
64
|
+
/** Returns the hashes of all effectively sent txs. */
|
|
65
|
+
getSentTxHashes(): Hex[];
|
|
66
|
+
/** Returns the raw hex for all cancelled txs. */
|
|
67
|
+
getCancelledTxs(): Hex[];
|
|
64
68
|
/** Delays the next tx to be sent so it lands on the given L1 block number. */
|
|
65
69
|
pauseNextTxUntilBlock(l1BlockNumber: number | bigint | undefined): void;
|
|
66
70
|
/** Delays the next tx to be sent so it lands on the given timestamp. */
|
|
67
71
|
pauseNextTxUntilTimestamp(l1Timestamp: number | bigint | undefined): void;
|
|
72
|
+
/** Delays the next tx to be sent indefinitely. */
|
|
73
|
+
cancelNextTx(): void;
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
class DelayerImpl implements Delayer {
|
|
@@ -73,11 +79,16 @@ class DelayerImpl implements Delayer {
|
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
public ethereumSlotDuration: bigint;
|
|
76
|
-
public nextWait: { l1Timestamp: bigint } | { l1BlockNumber: bigint } | undefined = undefined;
|
|
77
|
-
public
|
|
82
|
+
public nextWait: { l1Timestamp: bigint } | { l1BlockNumber: bigint } | { indefinitely: true } | undefined = undefined;
|
|
83
|
+
public sentTxHashes: Hex[] = [];
|
|
84
|
+
public cancelledTxs: Hex[] = [];
|
|
78
85
|
|
|
79
|
-
|
|
80
|
-
return this.
|
|
86
|
+
getSentTxHashes() {
|
|
87
|
+
return this.sentTxHashes;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getCancelledTxs(): Hex[] {
|
|
91
|
+
return this.cancelledTxs;
|
|
81
92
|
}
|
|
82
93
|
|
|
83
94
|
pauseNextTxUntilBlock(l1BlockNumber: number | bigint) {
|
|
@@ -87,6 +98,10 @@ class DelayerImpl implements Delayer {
|
|
|
87
98
|
pauseNextTxUntilTimestamp(l1Timestamp: number | bigint) {
|
|
88
99
|
this.nextWait = { l1Timestamp: BigInt(l1Timestamp) };
|
|
89
100
|
}
|
|
101
|
+
|
|
102
|
+
cancelNextTx() {
|
|
103
|
+
this.nextWait = { indefinitely: true };
|
|
104
|
+
}
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
/**
|
|
@@ -103,6 +118,7 @@ export function withDelayer<T extends ViemClient>(
|
|
|
103
118
|
}
|
|
104
119
|
const logger = createLogger('ethereum:tx_delayer');
|
|
105
120
|
const delayer = new DelayerImpl(opts);
|
|
121
|
+
|
|
106
122
|
const extended = client
|
|
107
123
|
// Tweak sendRawTransaction so it uses the delay defined in the delayer.
|
|
108
124
|
// Note that this will only work with local accounts (ie accounts for which we have the private key).
|
|
@@ -114,15 +130,25 @@ export function withDelayer<T extends ViemClient>(
|
|
|
114
130
|
const waitUntil = delayer.nextWait;
|
|
115
131
|
delayer.nextWait = undefined;
|
|
116
132
|
|
|
133
|
+
// Compute the tx hash manually so we emulate sendRawTransaction response
|
|
134
|
+
const { serializedTransaction } = args[0];
|
|
135
|
+
const txHash = computeTxHash(serializedTransaction);
|
|
136
|
+
|
|
137
|
+
// Cancel tx outright if instructed
|
|
138
|
+
if ('indefinitely' in waitUntil && waitUntil.indefinitely) {
|
|
139
|
+
logger.info(`Cancelling tx ${txHash}`);
|
|
140
|
+
delayer.cancelledTxs.push(serializedTransaction);
|
|
141
|
+
return Promise.resolve(txHash);
|
|
142
|
+
}
|
|
143
|
+
|
|
117
144
|
const publicClient = client as unknown as PublicClient;
|
|
118
145
|
const wait =
|
|
119
146
|
'l1BlockNumber' in waitUntil
|
|
120
147
|
? waitUntilBlock(publicClient, waitUntil.l1BlockNumber - 1n, logger)
|
|
121
|
-
:
|
|
148
|
+
: 'l1Timestamp' in waitUntil
|
|
149
|
+
? waitUntilL1Timestamp(publicClient, waitUntil.l1Timestamp - delayer.ethereumSlotDuration, logger)
|
|
150
|
+
: undefined;
|
|
122
151
|
|
|
123
|
-
// Compute the tx hash manually so we emulate sendRawTransaction response
|
|
124
|
-
const { serializedTransaction } = args[0];
|
|
125
|
-
const txHash = keccak256(serializedTransaction);
|
|
126
152
|
logger.info(`Delaying tx ${txHash} until ${inspect(waitUntil)}`, {
|
|
127
153
|
argsLen: args.length,
|
|
128
154
|
...omit(parseTransaction(serializedTransaction), 'data', 'sidecars'),
|
|
@@ -131,7 +157,7 @@ export function withDelayer<T extends ViemClient>(
|
|
|
131
157
|
// Do not await here so we can return the tx hash immediately as if it had been sent on the spot.
|
|
132
158
|
// Instead, delay it so it lands on the desired block number or timestamp, assuming anvil will
|
|
133
159
|
// mine it immediately.
|
|
134
|
-
void wait
|
|
160
|
+
void wait!
|
|
135
161
|
.then(async () => {
|
|
136
162
|
const clientTxHash = await client.sendRawTransaction(...args);
|
|
137
163
|
if (clientTxHash !== txHash) {
|
|
@@ -141,7 +167,7 @@ export function withDelayer<T extends ViemClient>(
|
|
|
141
167
|
});
|
|
142
168
|
}
|
|
143
169
|
logger.info(`Sent previously delayed tx ${clientTxHash} to land on ${inspect(waitUntil)}`);
|
|
144
|
-
delayer.
|
|
170
|
+
delayer.sentTxHashes.push(clientTxHash);
|
|
145
171
|
})
|
|
146
172
|
.catch(err => logger.error(`Error sending tx after delay`, err));
|
|
147
173
|
|
|
@@ -149,7 +175,7 @@ export function withDelayer<T extends ViemClient>(
|
|
|
149
175
|
} else {
|
|
150
176
|
const txHash = await client.sendRawTransaction(...args);
|
|
151
177
|
logger.verbose(`Sent tx immediately ${txHash}`);
|
|
152
|
-
delayer.
|
|
178
|
+
delayer.sentTxHashes.push(txHash);
|
|
153
179
|
return txHash;
|
|
154
180
|
}
|
|
155
181
|
},
|
|
@@ -164,3 +190,19 @@ export function withDelayer<T extends ViemClient>(
|
|
|
164
190
|
|
|
165
191
|
return { client: extended, delayer };
|
|
166
192
|
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Compute the tx hash given the serialized tx. Note that if this is a blob tx, we need to
|
|
196
|
+
* exclude the blobs, commitments, and proofs from the hash.
|
|
197
|
+
*/
|
|
198
|
+
function computeTxHash(serializedTransaction: Hex) {
|
|
199
|
+
if (serializedTransaction.startsWith('0x03')) {
|
|
200
|
+
const parsed = parseTransaction(serializedTransaction);
|
|
201
|
+
if (parsed.blobs || parsed.sidecars) {
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
203
|
+
const { blobs, sidecars, ...rest } = parsed;
|
|
204
|
+
return keccak256(serializeTransaction({ type: 'eip4844', ...rest } as TransactionSerializableEIP4844));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return keccak256(serializedTransaction);
|
|
208
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -158,7 +158,7 @@ export function formatViemError(error: any, abi: Abi = ErrorsAbi): FormattedViem
|
|
|
158
158
|
return new FormattedViemError(`${errorName}${args}`, error?.metaMessages);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
} catch
|
|
161
|
+
} catch {
|
|
162
162
|
// If decoding fails, we fall back to the original formatting
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -400,7 +400,7 @@ export function tryGetCustomErrorName(err: any) {
|
|
|
400
400
|
return (revertError as ContractFunctionRevertedError).data?.errorName;
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
} catch
|
|
403
|
+
} catch {
|
|
404
404
|
return undefined;
|
|
405
405
|
}
|
|
406
406
|
}
|