Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boxes/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ services:
working_dir: /root/aztec-packages/boxes
entrypoint: >
sh -c '
npx -y playwright@1.50 install --with-deps
yarn workspace @aztec/$$BOX test --project=$$BROWSER
'
environment:
Expand Down
8 changes: 7 additions & 1 deletion gaztec/src/components/contract/contract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export function ContractComponent() {
currentContractAddress,
currentContract,
setCurrentContract,
setCurrentContractAddress,
setCurrentTx,
} = useContext(AztecContext);

Expand Down Expand Up @@ -160,7 +161,10 @@ export function ContractComponent() {
});
setIsLoadingArtifact(false);
};
if (currentContractAddress) {
if (
currentContractAddress &&
currentContract?.address !== currentContractAddress
) {
loadCurrentContract();
}
}, [currentContractAddress]);
Expand Down Expand Up @@ -201,6 +205,7 @@ export function ContractComponent() {
setCurrentContract(
await Contract.at(contract.address, contractArtifact, wallet)
);
setCurrentContractAddress(contract.address);
}
setOpenDeployContractDialog(false);
setOpenRegisterContractDialog(false);
Expand Down Expand Up @@ -424,6 +429,7 @@ export function ContractComponent() {
/>
<IconButton
onClick={(e) => {
setCurrentContractAddress(null);
setCurrentContract(null);
setContractArtifact(null);
}}
Expand Down
2 changes: 2 additions & 0 deletions gaztec/src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ export function SidebarComponent() {
};
if (currentContractAddress && walletDB) {
refreshTransactions();
} else {
setTransactions([]);
}
}, [currentContractAddress, currentTx]);

Expand Down
3 changes: 2 additions & 1 deletion yarn-project/aztec.js/src/api/ethereum.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { deployL1Contract, deployL1Contracts, DeployL1Contracts } from '@aztec/ethereum';
export { deployL1Contract, deployL1Contracts, DeployL1Contracts } from '@aztec/ethereum/deploy-l1-contracts';
export { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/contract/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
GasFees,
type NodeInfo,
} from '@aztec/circuits.js';
import { type L1ContractAddresses } from '@aztec/ethereum';
import { type L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
import { type AbiDecoded, type ContractArtifact, FunctionType } from '@aztec/foundation/abi';

import { type MockProxy, mock } from 'jest-mock-extended';
Expand Down
5 changes: 2 additions & 3 deletions yarn-project/aztec.js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,12 @@ export { elapsed } from '@aztec/foundation/timer';
export { type FieldsOf } from '@aztec/foundation/types';
export { fileURLToPath } from '@aztec/foundation/url';

export { EthCheatCodes, deployL1Contract, deployL1Contracts, type DeployL1Contracts } from '@aztec/ethereum';

// Start of section that exports public api via granular api.
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
// This entire index file will be deprecated at some point after we're satisfied.
export * from './api/abi.js';
export * from './api/fee.js';
export * from './api/addresses.js';
export * from './api/ethereum.js';
// Granular export, even if not in the api folder
export * from './contract/index.js';
export * from './api/addresses.js';
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/utils/chain_monitor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type RollupContract } from '@aztec/ethereum';
import { type RollupContract } from '@aztec/ethereum/contracts';
import { createLogger } from '@aztec/foundation/log';

import { type PublicClient } from 'viem';
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/aztec.js/src/utils/cheat_codes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { type EpochProofClaim, type Note, type PXE } from '@aztec/circuit-types';
import { type AztecAddress, EthAddress, Fr } from '@aztec/circuits.js';
import { deriveStorageSlotInMap } from '@aztec/circuits.js/hash';
import { EthCheatCodes, type L1ContractAddresses } from '@aztec/ethereum';
import { EthCheatCodes } from '@aztec/ethereum/eth-cheatcodes';
import { type L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
import { createLogger } from '@aztec/foundation/log';
import { RollupAbi } from '@aztec/l1-artifacts';

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/utils/l1_contracts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type L1ContractAddresses } from '@aztec/ethereum';
import { type L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
import { retryUntil } from '@aztec/foundation/retry';

import { createPXEClient } from '../rpc_clients/index.js';
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/utils/portal_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type SiblingPath,
computeSecretHash,
} from '@aztec/aztec.js';
import { extractEvent } from '@aztec/ethereum';
import { extractEvent } from '@aztec/ethereum/utils';
import { sha256ToField } from '@aztec/foundation/crypto';
import { FeeJuicePortalAbi, OutboxAbi, TestERC20Abi, TokenPortalAbi } from '@aztec/l1-artifacts';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
PublicKeys,
getContractClassFromArtifact,
} from '@aztec/circuits.js';
import { type L1ContractAddresses, L1ContractsNames } from '@aztec/ethereum';
import { type L1ContractAddresses, L1ContractsNames } from '@aztec/ethereum/l1-contract-addresses';
import { type ContractArtifact } from '@aztec/foundation/abi';
import { memoize } from '@aztec/foundation/decorators';
import { type JsonRpcTestContext, createJsonRpcTestSetup } from '@aztec/foundation/json-rpc/test';
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuit-types/src/interfaces/aztec-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
type ProtocolContractAddresses,
ProtocolContractAddressesSchema,
} from '@aztec/circuits.js';
import { type L1ContractAddresses, L1ContractAddressesSchema } from '@aztec/ethereum';
import { type L1ContractAddresses, L1ContractAddressesSchema } from '@aztec/ethereum/l1-contract-addresses';
import type { AztecAddress } from '@aztec/foundation/aztec-address';
import type { Fr } from '@aztec/foundation/fields';
import { createSafeJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client';
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuit-types/src/interfaces/pxe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
PublicKeys,
getContractClassFromArtifact,
} from '@aztec/circuits.js';
import { type L1ContractAddresses, L1ContractsNames } from '@aztec/ethereum';
import { type L1ContractAddresses, L1ContractsNames } from '@aztec/ethereum/l1-contract-addresses';
import { type AbiDecoded, type ContractArtifact, EventSelector } from '@aztec/foundation/abi';
import { memoize } from '@aztec/foundation/decorators';
import { type JsonRpcTestContext, createJsonRpcTestSetup } from '@aztec/foundation/json-rpc/test';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type L1ContractAddresses, L1ContractAddressesSchema } from '@aztec/ethereum';
import { type L1ContractAddresses, L1ContractAddressesSchema } from '@aztec/ethereum/l1-contract-addresses';
import { type ZodFor } from '@aztec/foundation/schemas';

import { z } from 'zod';
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getSchnorrAccount } from '@aztec/accounts/schnorr';
import { type AztecNodeConfig, type AztecNodeService } from '@aztec/aztec-node';
import { type AccountWalletWithSecretKey } from '@aztec/aztec.js';
import { ChainMonitor } from '@aztec/aztec.js/utils';
import { L1TxUtils, RollupContract, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
import { L1TxUtilsWithBlobs, RollupContract, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
import { EthCheatCodesWithState } from '@aztec/ethereum/test';
import { type Logger, createLogger } from '@aztec/foundation/log';
import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class P2PNetworkTest {

private cleanupInterval: NodeJS.Timeout | undefined = undefined;

private gasUtils: L1TxUtils | undefined = undefined;
private gasUtils: L1TxUtilsWithBlobs | undefined = undefined;

constructor(
testName: string,
Expand Down Expand Up @@ -301,7 +301,7 @@ export class P2PNetworkTest {
this.ctx = await this.snapshotManager.setup();
this.startSyncMockSystemTimeInterval();

this.gasUtils = new L1TxUtils(
this.gasUtils = new L1TxUtilsWithBlobs(
this.ctx.deployL1ContractsValues.publicClient,
this.ctx.deployL1ContractsValues.walletClient,
this.logger,
Expand Down
5 changes: 4 additions & 1 deletion yarn-project/ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
"type": "module",
"exports": {
".": "./dest/index.js",
"./eth-cheatcodes": "./dest/eth_cheat_codes.js",
"./test": "./dest/test/index.js",
"./contracts": "./dest/contracts/index.js",
"./l1-contract-addresses": "./dest/l1_contract_addresses.js"
"./deploy-l1-contracts": "./dest/deploy_l1_contracts.js",
"./l1-contract-addresses": "./dest/l1_contract_addresses.js",
"./utils": "./dest/utils.js"
},
"typedocOptions": {
"entryPoints": [
Expand Down
1 change: 1 addition & 0 deletions yarn-project/ethereum/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './deploy_l1_contracts.js';
export * from './chain.js';
export * from './eth_cheat_codes.js';
export * from './l1_tx_utils.js';
export * from './l1_tx_utils_with_blobs.js';
export * from './l1_contract_addresses.js';
export * from './l1_reader.js';
export * from './utils.js';
Expand Down
13 changes: 7 additions & 6 deletions yarn-project/ethereum/src/l1_tx_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
import { foundry } from 'viem/chains';

import { EthCheatCodes } from './eth_cheat_codes.js';
import { L1TxUtils, defaultL1TxUtilsConfig } from './l1_tx_utils.js';
import { defaultL1TxUtilsConfig } from './l1_tx_utils.js';
import { L1TxUtilsWithBlobs } from './l1_tx_utils_with_blobs.js';
import { startAnvil } from './test/start_anvil.js';
import { formatViemError } from './utils.js';

Expand All @@ -35,7 +36,7 @@ export type PendingTransaction = {
};

describe('GasUtils', () => {
let gasUtils: L1TxUtils;
let gasUtils: L1TxUtilsWithBlobs;
let walletClient: WalletClient<HttpTransport, Chain, Account>;
let publicClient: PublicClient<HttpTransport, Chain>;
let anvil: Anvil;
Expand Down Expand Up @@ -73,7 +74,7 @@ describe('GasUtils', () => {
});
await cheatCodes.evmMine();

gasUtils = new L1TxUtils(publicClient, walletClient, logger, {
gasUtils = new L1TxUtilsWithBlobs(publicClient, walletClient, logger, {
gasLimitBufferPercentage: 20,
maxGwei: 500n,
minGwei: 1n,
Expand Down Expand Up @@ -201,7 +202,7 @@ describe('GasUtils', () => {
await cheatCodes.evmMine();

// First deploy without any buffer
const baselineGasUtils = new L1TxUtils(publicClient, walletClient, logger, {
const baselineGasUtils = new L1TxUtilsWithBlobs(publicClient, walletClient, logger, {
gasLimitBufferPercentage: 0,
maxGwei: 500n,
minGwei: 10n, // Increased minimum gas price
Expand All @@ -221,7 +222,7 @@ describe('GasUtils', () => {
});

// Now deploy with 20% buffer
const bufferedGasUtils = new L1TxUtils(publicClient, walletClient, logger, {
const bufferedGasUtils = new L1TxUtilsWithBlobs(publicClient, walletClient, logger, {
gasLimitBufferPercentage: 20,
maxGwei: 500n,
minGwei: 1n,
Expand Down Expand Up @@ -280,7 +281,7 @@ describe('GasUtils', () => {
});

it('respects minimum gas price bump for replacements', async () => {
const gasUtils = new L1TxUtils(publicClient, walletClient, logger, {
const gasUtils = new L1TxUtilsWithBlobs(publicClient, walletClient, logger, {
...defaultL1TxUtilsConfig,
priorityFeeRetryBumpPercentage: 5, // Set lower than minimum 10%
});
Expand Down
78 changes: 26 additions & 52 deletions yarn-project/ethereum/src/l1_tx_utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Blob } from '@aztec/foundation/blob';
import { times } from '@aztec/foundation/collection';
import {
type ConfigMappingsType,
Expand Down Expand Up @@ -185,12 +184,12 @@ export interface GasPrice {
}

export class L1TxUtils {
private readonly config: L1TxUtilsConfig;
protected readonly config: L1TxUtilsConfig;

constructor(
private readonly publicClient: PublicClient,
private readonly walletClient: WalletClient<HttpTransport, Chain, Account>,
private readonly logger?: Logger,
protected readonly publicClient: PublicClient,
protected readonly walletClient: WalletClient<HttpTransport, Chain, Account>,
protected readonly logger?: Logger,
config?: Partial<L1TxUtilsConfig>,
) {
this.config = {
Expand Down Expand Up @@ -454,7 +453,7 @@ export class L1TxUtils {
/**
* Gets the current gas price with bounds checking
*/
private async getGasPrice(
public async getGasPrice(
_gasConfig?: L1TxUtilsConfig,
isBlobTx: boolean = false,
attempt: number = 0,
Expand Down Expand Up @@ -669,7 +668,10 @@ export class L1TxUtils {
* @param attempts - The number of attempts to cancel the transaction
* @returns The hash of the cancellation transaction
*/
private async attemptTxCancellation(nonce: number, isBlobTx = false, previousGasPrice?: GasPrice, attempts = 0) {
protected async attemptTxCancellation(nonce: number, isBlobTx = false, previousGasPrice?: GasPrice, attempts = 0) {
if (isBlobTx) {
throw new Error('Cannot cancel blob transactions, please use L1TxUtilsWithBlobsClass');
}
const account = this.walletClient.account;

// Get gas price with higher priority fee for cancellation
Expand All @@ -694,50 +696,22 @@ export class L1TxUtils {
};

// Send 0-value tx to self with higher gas price
if (!isBlobTx) {
const cancelTxHash = await this.walletClient.sendTransaction({
...request,
nonce,
gas: 21_000n, // Standard ETH transfer gas
maxFeePerGas: cancelGasPrice.maxFeePerGas,
maxPriorityFeePerGas: cancelGasPrice.maxPriorityFeePerGas,
});
const receipt = await this.monitorTransaction(
request,
cancelTxHash,
{ gasLimit: 21_000n },
undefined,
undefined,
true,
);

return receipt.transactionHash;
} else {
const blobData = new Uint8Array(131072).fill(0);
const kzg = Blob.getViemKzgInstance();
const blobInputs = {
blobs: [blobData],
kzg,
maxFeePerBlobGas: cancelGasPrice.maxFeePerBlobGas!,
};
const cancelTxHash = await this.walletClient.sendTransaction({
...request,
...blobInputs,
nonce,
gas: 21_000n,
maxFeePerGas: cancelGasPrice.maxFeePerGas,
maxPriorityFeePerGas: cancelGasPrice.maxPriorityFeePerGas,
});
const receipt = await this.monitorTransaction(
request,
cancelTxHash,
{ gasLimit: 21_000n },
undefined,
blobInputs,
true,
);

return receipt.transactionHash;
}
const cancelTxHash = await this.walletClient.sendTransaction({
...request,
nonce,
gas: 21_000n, // Standard ETH transfer gas
maxFeePerGas: cancelGasPrice.maxFeePerGas,
maxPriorityFeePerGas: cancelGasPrice.maxPriorityFeePerGas,
});
const receipt = await this.monitorTransaction(
request,
cancelTxHash,
{ gasLimit: 21_000n },
undefined,
undefined,
true,
);

return receipt.transactionHash;
}
}
Loading