@aztec-labs/ethereum 6.0.0-rc.3 → 6.0.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/blob_tx.d.ts +24 -0
- package/dest/blob_tx.d.ts.map +1 -0
- package/dest/blob_tx.js +94 -0
- package/dest/bn254/hash_to_point.d.ts +32 -0
- package/dest/bn254/hash_to_point.d.ts.map +1 -0
- package/dest/bn254/hash_to_point.js +80 -0
- package/dest/bn254/index.d.ts +3 -0
- package/dest/bn254/index.d.ts.map +1 -0
- package/dest/bn254/index.js +2 -0
- package/dest/bn254/proof_of_possession_gas.d.ts +29 -0
- package/dest/bn254/proof_of_possession_gas.d.ts.map +1 -0
- package/dest/bn254/proof_of_possession_gas.js +24 -0
- package/dest/client.d.ts +1 -1
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +5 -3
- package/dest/contracts/errors.d.ts +10 -3
- package/dest/contracts/errors.d.ts.map +1 -1
- package/dest/contracts/errors.js +10 -4
- package/dest/contracts/inbox.d.ts +1 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +2 -0
- package/dest/contracts/log.d.ts +7 -1
- package/dest/contracts/log.d.ts.map +1 -1
- package/dest/contracts/log.js +6 -0
- package/dest/contracts/rollup.d.ts +32 -4
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +63 -7
- package/dest/deploy_aztec_l1_contracts.d.ts +16 -1
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +201 -65
- package/dest/foundry_binary.d.ts +1 -1
- package/dest/foundry_binary.d.ts.map +1 -1
- package/dest/foundry_binary.js +2 -1
- package/dest/l1_tx_utils/amsterdam.d.ts +1 -1
- package/dest/l1_tx_utils/amsterdam.d.ts.map +1 -1
- package/dest/l1_tx_utils/amsterdam.js +4 -1
- package/dest/l1_tx_utils/constants.d.ts +2 -1
- package/dest/l1_tx_utils/constants.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.js +3 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +6 -1
- package/dest/l1_tx_utils/index.d.ts +2 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +21 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +71 -5
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +8 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +1 -1
- package/dest/l1_tx_utils/send_cost.d.ts +15 -0
- package/dest/l1_tx_utils/send_cost.d.ts.map +1 -0
- package/dest/l1_tx_utils/send_cost.js +10 -0
- package/dest/l1_tx_utils/signer.d.ts +2 -2
- package/dest/l1_tx_utils/signer.d.ts.map +1 -1
- package/dest/l1_tx_utils/signer.js +2 -2
- package/dest/l1_tx_utils/tx_delayer.d.ts +1 -1
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -1
- package/dest/l1_tx_utils/tx_delayer.js +8 -26
- package/dest/publisher_manager.d.ts +127 -13
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +320 -79
- package/dest/test/anvil_hardfork.d.ts +42 -0
- package/dest/test/anvil_hardfork.d.ts.map +1 -0
- package/dest/test/anvil_hardfork.js +107 -0
- package/dest/test/eth_cheat_codes.d.ts +30 -5
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +283 -101
- package/dest/test/index.d.ts +3 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +2 -0
- package/dest/test/l1_hardfork.d.ts +43 -0
- package/dest/test/l1_hardfork.d.ts.map +1 -0
- package/dest/test/l1_hardfork.js +51 -0
- package/dest/test/recording_rpc_server.d.ts +1 -1
- package/dest/test/recording_rpc_server.d.ts.map +1 -1
- package/dest/test/recording_rpc_server.js +1 -0
- package/dest/test/rollup_cheat_codes.d.ts +1 -1
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +7 -7
- package/dest/test/start_anvil.d.ts +14 -2
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +28 -11
- package/package.json +13 -11
- package/src/blob_tx.ts +118 -0
- package/src/bn254/hash_to_point.ts +95 -0
- package/src/bn254/index.ts +2 -0
- package/src/bn254/proof_of_possession_gas.ts +54 -0
- package/src/client.ts +6 -3
- package/src/contracts/errors.ts +12 -4
- package/src/contracts/inbox.ts +4 -0
- package/src/contracts/log.ts +12 -0
- package/src/contracts/rollup.ts +63 -6
- package/src/deploy_aztec_l1_contracts.ts +238 -63
- package/src/foundry_binary.ts +2 -1
- package/src/l1_tx_utils/amsterdam.ts +4 -1
- package/src/l1_tx_utils/constants.ts +4 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +11 -1
- package/src/l1_tx_utils/index.ts +1 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +72 -5
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +1 -1
- package/src/l1_tx_utils/send_cost.ts +21 -0
- package/src/l1_tx_utils/signer.ts +3 -2
- package/src/l1_tx_utils/tx_delayer.ts +8 -37
- package/src/publisher_manager.ts +458 -83
- package/src/test/anvil_hardfork.ts +95 -0
- package/src/test/eth_cheat_codes.ts +306 -81
- package/src/test/fixtures/sepolia_blob_tx.json +10 -0
- package/src/test/index.ts +2 -0
- package/src/test/l1_hardfork.ts +71 -0
- package/src/test/recording_rpc_server.ts +1 -0
- package/src/test/rollup_cheat_codes.ts +9 -9
- package/src/test/start_anvil.ts +41 -13
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GAS_PER_BLOB } from './constants.js';
|
|
2
|
+
import type { FeesPerGas } from './types.js';
|
|
3
|
+
|
|
4
|
+
/** Gas limit and blob count of an L1 send, used to bound the ETH a sender must hold to submit it. */
|
|
5
|
+
export type SendCostRequirement = {
|
|
6
|
+
/** Gas limit the tx will be sent with. */
|
|
7
|
+
gasLimit: bigint;
|
|
8
|
+
/** Number of blobs attached to the tx. */
|
|
9
|
+
blobCount: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Upper bound on the ETH a send needs up front: `gasLimit * maxFeePerGas + blobCount * GAS_PER_BLOB * maxFeePerBlobGas`.
|
|
14
|
+
* This is what the node checks against the sender balance before accepting the tx, so a sender holding less than this
|
|
15
|
+
* gets the tx rejected with an insufficient funds error.
|
|
16
|
+
*/
|
|
17
|
+
export function computeSendCost(fees: FeesPerGas, req: SendCostRequirement): bigint {
|
|
18
|
+
const executionCost = req.gasLimit * fees.maxFeePerGas;
|
|
19
|
+
const blobCost = BigInt(req.blobCount) * GAS_PER_BLOB * (fees.maxFeePerBlobGas ?? 0n);
|
|
20
|
+
return executionCost + blobCost;
|
|
21
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec-labs/foundation/eth-address';
|
|
2
2
|
import type { ViemTransactionSignature } from '@aztec-labs/foundation/eth-signature';
|
|
3
|
-
import {
|
|
3
|
+
import type { TransactionSerializable, WalletClient } from 'viem';
|
|
4
4
|
|
|
5
|
+
import { parseSignedTransaction } from '../blob_tx.js';
|
|
5
6
|
import type { SigningCallback } from './types.js';
|
|
6
7
|
|
|
7
8
|
export function createViemSigner(client: WalletClient) {
|
|
@@ -11,7 +12,7 @@ export function createViemSigner(client: WalletClient) {
|
|
|
11
12
|
): Promise<ViemTransactionSignature> => {
|
|
12
13
|
const signedTx = await client.signTransaction(tx as any);
|
|
13
14
|
|
|
14
|
-
const parsed =
|
|
15
|
+
const parsed = parseSignedTransaction(signedTx);
|
|
15
16
|
|
|
16
17
|
if (!parsed.r || !parsed.s || (parsed.yParity !== 0 && parsed.yParity !== 1)) {
|
|
17
18
|
throw new Error('Failed to extract signature from viem signed transaction');
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import { omit } from '@aztec-labs/foundation/collection';
|
|
2
|
+
import { inspect } from '@aztec-labs/foundation/inspect';
|
|
2
3
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec-labs/foundation/log';
|
|
3
4
|
import { retryUntil } from '@aztec-labs/foundation/retry';
|
|
4
5
|
import type { DateProvider } from '@aztec-labs/foundation/timer';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
type Client,
|
|
8
|
-
type Hex,
|
|
9
|
-
type PublicClient,
|
|
10
|
-
type TransactionSerializableEIP4844,
|
|
11
|
-
type TransactionSerialized,
|
|
12
|
-
keccak256,
|
|
13
|
-
parseTransaction,
|
|
14
|
-
publicActions,
|
|
15
|
-
recoverTransactionAddress,
|
|
16
|
-
serializeTransaction,
|
|
17
|
-
walletActions,
|
|
18
|
-
} from 'viem';
|
|
6
|
+
import { type Client, type Hex, type PublicClient, publicActions, walletActions } from 'viem';
|
|
19
7
|
|
|
8
|
+
import { computeSignedTransactionHash, parseSignedTransaction, recoverSignedTransactionAddress } from '../blob_tx.js';
|
|
20
9
|
import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
|
|
21
10
|
|
|
22
11
|
const MAX_WAIT_TIME_SECONDS = 180;
|
|
@@ -152,9 +141,7 @@ export function createDelayer(
|
|
|
152
141
|
/** Tries to recover the sender address from a serialized signed transaction. */
|
|
153
142
|
async function tryRecoverSender(serializedTransaction: Hex): Promise<string | undefined> {
|
|
154
143
|
try {
|
|
155
|
-
return await
|
|
156
|
-
serializedTransaction: serializedTransaction as TransactionSerialized,
|
|
157
|
-
});
|
|
144
|
+
return await recoverSignedTransactionAddress(serializedTransaction);
|
|
158
145
|
} catch {
|
|
159
146
|
return undefined;
|
|
160
147
|
}
|
|
@@ -189,7 +176,7 @@ export function wrapClientWithDelayer<T extends ViemClient>(client: T, delayer:
|
|
|
189
176
|
delayer.nextWait = undefined;
|
|
190
177
|
|
|
191
178
|
// Compute the tx hash manually so we emulate sendRawTransaction response
|
|
192
|
-
txHash =
|
|
179
|
+
txHash = computeSignedTransactionHash(serializedTransaction);
|
|
193
180
|
|
|
194
181
|
// Cancel tx outright if instructed
|
|
195
182
|
if ('indefinitely' in waitUntil && waitUntil.indefinitely) {
|
|
@@ -214,7 +201,7 @@ export function wrapClientWithDelayer<T extends ViemClient>(client: T, delayer:
|
|
|
214
201
|
logger.info(`Delaying tx ${txHash} until ${inspect(waitUntil)}`, {
|
|
215
202
|
sender,
|
|
216
203
|
argsLen: args.length,
|
|
217
|
-
...omit(
|
|
204
|
+
...omit(parseSignedTransaction(serializedTransaction), 'data', 'sidecars'),
|
|
218
205
|
});
|
|
219
206
|
} else if (delayer.maxInclusionTimeIntoSlot !== undefined) {
|
|
220
207
|
// Check if we need to delay txs sent too close to the end of the slot.
|
|
@@ -222,10 +209,10 @@ export function wrapClientWithDelayer<T extends ViemClient>(client: T, delayer:
|
|
|
222
209
|
const { timestamp: lastBlockTimestamp, number } = currentBlock;
|
|
223
210
|
const now = delayer.dateProvider.now();
|
|
224
211
|
|
|
225
|
-
txHash =
|
|
212
|
+
txHash = computeSignedTransactionHash(serializedTransaction);
|
|
226
213
|
const logData = {
|
|
227
214
|
sender,
|
|
228
|
-
...omit(
|
|
215
|
+
...omit(parseSignedTransaction(serializedTransaction), 'data', 'sidecars'),
|
|
229
216
|
lastBlockTimestamp,
|
|
230
217
|
now,
|
|
231
218
|
maxInclusionTimeIntoSlot: delayer.maxInclusionTimeIntoSlot,
|
|
@@ -284,19 +271,3 @@ export function wrapClientWithDelayer<T extends ViemClient>(client: T, delayer:
|
|
|
284
271
|
|
|
285
272
|
return extended as T;
|
|
286
273
|
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Compute the tx hash given the serialized tx. Note that if this is a blob tx, we need to
|
|
290
|
-
* exclude the blobs, commitments, and proofs from the hash.
|
|
291
|
-
*/
|
|
292
|
-
function computeTxHash(serializedTransaction: Hex) {
|
|
293
|
-
if (serializedTransaction.startsWith('0x03')) {
|
|
294
|
-
const parsed = parseTransaction(serializedTransaction);
|
|
295
|
-
if (parsed.blobs || parsed.sidecars) {
|
|
296
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
297
|
-
const { blobs, sidecars, ...rest } = parsed;
|
|
298
|
-
return keccak256(serializeTransaction({ type: 'eip4844', ...rest } as TransactionSerializableEIP4844));
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return keccak256(serializedTransaction);
|
|
302
|
-
}
|