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 yarn-project/aztec-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"@aztec/archiver": "workspace:^",
"@aztec/bb-prover": "workspace:^",
"@aztec/blob-client": "workspace:^",
"@aztec/blob-lib": "workspace:^",
"@aztec/constants": "workspace:^",
"@aztec/epoch-cache": "workspace:^",
"@aztec/ethereum": "workspace:^",
Expand Down
18 changes: 9 additions & 9 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Archiver, createArchiver } from '@aztec/archiver';
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
import { Blob } from '@aztec/blob-lib';
import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
import { createEthereumChain } from '@aztec/ethereum/chain';
Expand All @@ -18,10 +19,7 @@ import { DateProvider, Timer } from '@aztec/foundation/timer';
import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
import {
createForwarderL1TxUtilsFromEthSigner,
createL1TxUtilsWithBlobsFromEthSigner,
} from '@aztec/node-lib/factories';
import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
import { type P2P, type P2PClientDeps, createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
Expand Down Expand Up @@ -413,18 +411,18 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
await slasherClient.start();

const l1TxUtils = config.publisherForwarderAddress
? await createForwarderL1TxUtilsFromEthSigner(
? await createForwarderL1TxUtilsFromSigners(
publicClient,
keyStoreManager!.createAllValidatorPublisherSigners(),
config.publisherForwarderAddress,
{ ...config, scope: 'sequencer' },
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
)
: await createL1TxUtilsWithBlobsFromEthSigner(
: await createL1TxUtilsFromSigners(
publicClient,
keyStoreManager!.createAllValidatorPublisherSigners(),
{ ...config, scope: 'sequencer' },
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
{ telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
);

// Create and start the sequencer client
Expand Down Expand Up @@ -468,7 +466,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
slotDuration: Number(slotDuration),
});

return new AztecNodeService(
const node = new AztecNodeService(
config,
p2pClient,
archiver,
Expand All @@ -490,6 +488,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
log,
blobClient,
);

return node;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/aztec-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
{
"path": "../blob-client"
},
{
"path": "../blob-lib"
},
{
"path": "../constants"
},
Expand Down
10 changes: 5 additions & 5 deletions yarn-project/cli/src/cmds/l1/update_l1_validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createEthereumChain, isAnvilTestChain } from '@aztec/ethereum/chain';
import { createExtendedL1Client, getPublicClient } from '@aztec/ethereum/client';
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
import { GSEContract, RollupContract } from '@aztec/ethereum/contracts';
import { createL1TxUtilsFromViemWallet } from '@aztec/ethereum/l1-tx-utils';
import { createL1TxUtils } from '@aztec/ethereum/l1-tx-utils';
import { EthCheatCodes } from '@aztec/ethereum/test';
import type { EthAddress } from '@aztec/foundation/eth-address';
import type { LogFn, Logger } from '@aztec/foundation/log';
Expand Down Expand Up @@ -88,7 +88,7 @@ export async function addL1Validator({
const gse = new GSEContract(l1Client, gseAddress);
const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);

const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });
const proofParamsObj = ZkPassportProofParams.fromBuffer(proofParams);

// Step 1: Claim STK tokens from the faucet
Expand Down Expand Up @@ -194,7 +194,7 @@ export async function addL1ValidatorViaRollup({

const registrationTuple = await gse.makeRegistrationTuple(blsSecretKey);

const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });

const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
to: rollupAddress.toString(),
Expand Down Expand Up @@ -241,7 +241,7 @@ export async function removeL1Validator({
const account = getAccount(privateKey, mnemonic);
const chain = createEthereumChain(rpcUrls, chainId);
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });

dualLog(`Removing validator ${validatorAddress.toString()} from rollup ${rollupAddress.toString()}`);
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
Expand All @@ -268,7 +268,7 @@ export async function pruneRollup({
const account = getAccount(privateKey, mnemonic);
const chain = createEthereumChain(rpcUrls, chainId);
const l1Client = createExtendedL1Client(rpcUrls, account, chain.chainInfo);
const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client, { logger: debugLogger });
const l1TxUtils = createL1TxUtils(l1Client, { logger: debugLogger });

dualLog(`Trying prune`);
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/src/e2e_debug_trace.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AztecNodeConfig } from '@aztec/aztec-node';
import { createExtendedL1Client } from '@aztec/ethereum/client';
import { FORWARDER_ABI, deployForwarderProxy } from '@aztec/ethereum/forwarder-proxy';
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
import type { PublisherManager } from '@aztec/ethereum/publisher-manager';
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
import { EthAddress } from '@aztec/foundation/eth-address';
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('e2e_debug_trace_transaction', () => {
// In this test we deploy a simple forwarder contract to L1, this serves as an additional proxy
it('can process blocks using debug trace', async () => {
// We intercept calls to sendAndMonitorTransaction to forward inner calls via the forwarder
const l1Utils: L1TxUtilsWithBlobs[] = (publisherManager as any).publishers;
const l1Utils: L1TxUtils[] = (publisherManager as any).publishers;

// Intercept sendAndMonitorTransaction to access blobInputs directly
const originalSendAndMonitor = l1Utils[0].sendAndMonitorTransaction.bind(l1Utils[0]);
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('e2e_debug_trace_transaction', () => {
// 2. Duplicate the inner call to the rollup
// 3. Corrupt the first call so it reverts (with allowFailure: true)
// 4. Keep the second call intact so it succeeds
const l1Utils: L1TxUtilsWithBlobs[] = (publisherManager as any).publishers;
const l1Utils: L1TxUtils[] = (publisherManager as any).publishers;

const originalSendAndMonitor = l1Utils[0].sendAndMonitorTransaction.bind(l1Utils[0]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { Logger } from '@aztec/aztec.js/log';
import type { AztecNode } from '@aztec/aztec.js/node';
import { createBlobClient } from '@aztec/blob-client/client';
import { Blob } from '@aztec/blob-lib';
import type { ChainMonitor, ChainMonitorEventMap, Delayer } from '@aztec/ethereum/test';
import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
import type { ChainMonitor, ChainMonitorEventMap } from '@aztec/ethereum/test';
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
import { CheckpointNumber } from '@aztec/foundation/branded-types';
import { timesAsync } from '@aztec/foundation/collection';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { getTimestampRangeForEpoch } from '@aztec/aztec.js/block';
import type { Logger } from '@aztec/aztec.js/log';
import { BatchedBlob } from '@aztec/blob-lib/types';
import { RollupContract } from '@aztec/ethereum/contracts';
import { ChainMonitor, DelayedTxUtils, type Delayer, waitUntilL1Timestamp } from '@aztec/ethereum/test';
import { type Delayer, waitUntilL1Timestamp } from '@aztec/ethereum/l1-tx-utils';
import { ChainMonitor } from '@aztec/ethereum/test';
import type { ViemClient } from '@aztec/ethereum/types';
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
import { promiseWithResolvers } from '@aztec/foundation/promise';
import { sleep } from '@aztec/foundation/sleep';
import type { ProverNodePublisher } from '@aztec/prover-node';
import type { TestProverNode } from '@aztec/prover-node/test';
import { type L1RollupConstants, getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
import { Proof } from '@aztec/stdlib/proofs';
Expand Down Expand Up @@ -72,8 +72,7 @@ describe('e2e_epochs/epochs_proof_fails', () => {
context.proverNode = proverNode;

// Get the prover delayer from the newly created prover node
proverDelayer = (((proverNode as TestProverNode).publisher as ProverNodePublisher).l1TxUtils as DelayedTxUtils)
.delayer!;
proverDelayer = proverNode.getDelayer()!;

// Hold off prover tx until end epoch 1
const [epoch2Start] = getTimestampRangeForEpoch(EpochNumber(2), constants);
Expand Down Expand Up @@ -114,8 +113,7 @@ describe('e2e_epochs/epochs_proof_fails', () => {
const proverNode = await test.createProverNode({ cancelTxOnTimeout: false, maxSpeedUpAttempts: 0 });

// Get the prover delayer from the newly created prover node
proverDelayer = (((proverNode as TestProverNode).publisher as ProverNodePublisher).l1TxUtils as DelayedTxUtils)
.delayer!;
proverDelayer = proverNode.getDelayer()!;

// Inject a delay in prover node proving equal to the length of an epoch, to make sure deadline will be hit
const epochProverManager = (proverNode as TestProverNode).prover;
Expand Down
67 changes: 14 additions & 53 deletions yarn-project/end-to-end/src/e2e_epochs/epochs_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { EpochCache } from '@aztec/epoch-cache';
import { createExtendedL1Client } from '@aztec/ethereum/client';
import { DefaultL1ContractsConfig } from '@aztec/ethereum/config';
import { RollupContract } from '@aztec/ethereum/contracts';
import { ChainMonitor, DelayedTxUtils, type Delayer, waitUntilL1Timestamp, withDelayer } from '@aztec/ethereum/test';
import { Delayer, createDelayer, waitUntilL1Timestamp, wrapClientWithDelayer } from '@aztec/ethereum/l1-tx-utils';
import { ChainMonitor } from '@aztec/ethereum/test';
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
import { BlockNumber, CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
import { SecretValue } from '@aztec/foundation/config';
Expand All @@ -20,16 +21,9 @@ import { sleep } from '@aztec/foundation/sleep';
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
import { TestContract } from '@aztec/noir-test-contracts.js/Test';
import { getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
import { ProverNode, type ProverNodeConfig, ProverNodePublisher } from '@aztec/prover-node';
import type { TestProverNode } from '@aztec/prover-node/test';
import { ProverNode, type ProverNodeConfig } from '@aztec/prover-node';
import type { PXEConfig } from '@aztec/pxe/config';
import {
type SequencerClient,
type SequencerEvents,
type SequencerPublisher,
SequencerState,
} from '@aztec/sequencer-client';
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
import { type SequencerClient, type SequencerEvents, SequencerState } from '@aztec/sequencer-client';
import { type BlockParameter, EthAddress } from '@aztec/stdlib/block';
import { type L1RollupConstants, getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers';
import { tryStop } from '@aztec/stdlib/interfaces/server';
Expand Down Expand Up @@ -169,17 +163,8 @@ export class EpochsTestContext {
// Loop that tracks L1 and L2 block numbers and logs whenever there's a new one.
this.monitor = new ChainMonitor(this.rollup, context.dateProvider, this.logger).start();

// This is hideous.
// We ought to have a definite reference to the l1TxUtils that we're using in both places, provided by the test context.
this.proverDelayer = context.proverNode
? (((context.proverNode as TestProverNode).publisher as ProverNodePublisher).l1TxUtils as DelayedTxUtils).delayer!
: undefined!;
this.sequencerDelayer = context.sequencer
? (
((context.sequencer as TestSequencerClient).sequencer.publisher as SequencerPublisher)
.l1TxUtils as DelayedTxUtils
).delayer!
: undefined!;
this.proverDelayer = context.proverDelayer!;
this.sequencerDelayer = context.sequencerDelayer!;

if ((context.proverNode && !this.proverDelayer) || (context.sequencer && !this.sequencerDelayer)) {
throw new Error(`Could not find prover or sequencer delayer`);
Expand Down Expand Up @@ -248,15 +233,13 @@ export class EpochsTestContext {

public createValidatorNode(
privateKeys: `0x${string}`[],
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
opts: Partial<AztecNodeConfig> & { dontStartSequencer?: boolean } = {},
) {
this.logger.warn('Creating and syncing a validator node...');
return this.createNode({ ...opts, disableValidator: false, validatorPrivateKeys: new SecretValue(privateKeys) });
}

private async createNode(
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
) {
private async createNode(opts: Partial<AztecNodeConfig> & { dontStartSequencer?: boolean } = {}) {
const nodeIndex = this.nodes.length + 1;
const actorPrefix = opts.disableValidator ? 'node' : 'validator';
const { mockGossipSubNetwork } = this.context;
Expand Down Expand Up @@ -285,26 +268,6 @@ export class EpochsTestContext {
),
);

// REFACTOR: We're getting too much into the internals of the sequencer here.
// We should have a single method for constructing an aztec node that returns a TestAztecNodeService
// which directly exposes the delayer and sets any test config.
if (opts.txDelayerMaxInclusionTimeIntoSlot !== undefined) {
this.logger.info(
`Setting tx delayer max inclusion time into slot to ${opts.txDelayerMaxInclusionTimeIntoSlot} seconds`,
);
// Here we reach into the sequencer and hook in a tx delayer. The problem is that the sequencer's l1 utils only uses a public client, not a wallet.
// The delayer needs a wallet (a client that can sign), so we have to create one here.
const l1Client = createExtendedL1Client(
resolvedConfig.l1RpcUrls!,
resolvedConfig.publisherPrivateKeys![0]!.getValue(),
);
const sequencer = node.getSequencer() as TestSequencerClient;
const publisher = sequencer.sequencer.publisher;
const delayed = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, this.L1_BLOCK_TIME_IN_S, l1Client);
delayed.delayer!.setMaxInclusionTimeIntoSlot(opts.txDelayerMaxInclusionTimeIntoSlot);
publisher.l1TxUtils = delayed;
}

this.nodes.push(node);
return node;
}
Expand Down Expand Up @@ -408,15 +371,13 @@ export class EpochsTestContext {

/** Creates an L1 client using a fresh account with funds from anvil, with a tx delayer already set up. */
public async createL1Client() {
const { client, delayer } = withDelayer(
createExtendedL1Client(
[...this.l1Client.chain.rpcUrls.default.http],
privateKeyToAccount(this.getNextPrivateKey()),
this.l1Client.chain,
),
this.context.dateProvider,
{ ethereumSlotDuration: this.L1_BLOCK_TIME_IN_S },
const rawClient = createExtendedL1Client(
[...this.l1Client.chain.rpcUrls.default.http],
privateKeyToAccount(this.getNextPrivateKey()),
this.l1Client.chain,
);
const delayer = createDelayer(this.context.dateProvider, { ethereumSlotDuration: this.L1_BLOCK_TIME_IN_S }, {});
const client = wrapClientWithDelayer(rawClient, delayer);
expect(await client.getBalance({ address: client.account.address })).toBeGreaterThan(0n);
return { client, delayer };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { createBlobClient } from '@aztec/blob-client/client';
import {
BatchedBlob,
BatchedBlobAccumulator,
Blob,
getBlobsPerL1Block,
getPrefixedEthBlobCommitments,
} from '@aztec/blob-lib';
Expand All @@ -24,8 +25,7 @@ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
import { type DeployAztecL1ContractsArgs, deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
import { TxUtilsState } from '@aztec/ethereum/l1-tx-utils';
import { createL1TxUtilsWithBlobsFromViemWallet } from '@aztec/ethereum/l1-tx-utils-with-blobs';
import { TxUtilsState, createL1TxUtils } from '@aztec/ethereum/l1-tx-utils';
import { EthCheatCodesWithState, RollupCheatCodes, startAnvil } from '@aztec/ethereum/test';
import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
import { range } from '@aztec/foundation/array';
Expand Down Expand Up @@ -255,7 +255,11 @@ describe('L1Publisher integration', () => {
await worldStateSynchronizer.start();

const sequencerL1Client = createExtendedL1Client(config.l1RpcUrls, sequencerPK, foundry);
const l1TxUtils = createL1TxUtilsWithBlobsFromViemWallet(sequencerL1Client, { logger, dateProvider }, config);
const l1TxUtils = createL1TxUtils(
sequencerL1Client,
{ logger, dateProvider, kzg: Blob.getViemKzgInstance() },
config,
);
const rollupContract = new RollupContract(sequencerL1Client, l1ContractAddresses.rollupAddress.toString());
const slashingProposerContract = await rollupContract.getSlashingProposer();
governanceProposerContract = new GovernanceProposerContract(
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/e2e_multi_eoa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Fr } from '@aztec/aztec.js/fields';
import type { Logger } from '@aztec/aztec.js/log';
import { waitForTx } from '@aztec/aztec.js/node';
import { EthCheatCodes } from '@aztec/aztec/testing';
import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
import type { PublisherManager } from '@aztec/ethereum/publisher-manager';
import type { ViemClient } from '@aztec/ethereum/types';
import { times } from '@aztec/foundation/collection';
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('e2e_multi_eoa', () => {
from: defaultAccountAddress,
});

const l1Utils: L1TxUtilsWithBlobs[] = (publisherManager as any).publishers;
const l1Utils: L1TxUtils[] = (publisherManager as any).publishers;

const blockedSender = l1Utils[expectedFirstSender].getSenderAddress();
const blockedTxs: Hex[] = [];
Expand Down
Loading
Loading