Skip to content

Commit

Permalink
chore: set assume proven in e2e (#8830)
Browse files Browse the repository at this point in the history
for e2e tests, assume things are proven unless the test says otherwise
  • Loading branch information
just-mitch authored and Rumata888 committed Sep 27, 2024
1 parent e808ed7 commit 3302c48
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ describe('L1Publisher integration', () => {
config.l1RpcUrl,
deployerAccount,
logger,
{ assumeProvenThrough: undefined },
));

ethCheatCodes = new EthCheatCodes(config.l1RpcUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('proof_verification', () => {
rpcUrl,
mnemonicToAccount(MNEMONIC),
logger,
{ assumeProvenThrough: undefined },
));
logger.info('l1 contracts done');

Expand Down
4 changes: 3 additions & 1 deletion yarn-project/end-to-end/src/e2e_prover_node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ describe('e2e_prover_node', () => {

beforeAll(async () => {
logger = createDebugLogger('aztec:e2e_prover_node');
snapshotManager = createSnapshotManager(`e2e_prover_node`, process.env.E2E_DATA_PATH);
snapshotManager = createSnapshotManager(`e2e_prover_node`, process.env.E2E_DATA_PATH, undefined, {
assumeProvenThrough: undefined,
});

const testContractOpts = { contractAddressSalt: Fr.ONE, universalDeploy: true };
await snapshotManager.snapshot(
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/end-to-end/src/fixtures/setup_l1_contracts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type DebugLogger, type L1ContractArtifactsForDeployment, deployL1Contracts } from '@aztec/aztec.js';
import { type DeployL1ContractsArgs } from '@aztec/ethereum';
import {
FeeJuicePortalAbi,
FeeJuicePortalBytecode,
Expand All @@ -25,6 +26,7 @@ export const setupL1Contracts = async (
l1RpcUrl: string,
account: HDAccount | PrivateKeyAccount,
logger: DebugLogger,
args: Pick<DeployL1ContractsArgs, 'assumeProvenThrough' | 'initialValidators'>,
) => {
const l1Artifacts: L1ContractArtifactsForDeployment = {
registry: {
Expand Down Expand Up @@ -57,6 +59,7 @@ export const setupL1Contracts = async (
l2FeeJuiceAddress: FeeJuiceAddress,
vkTreeRoot: getVKTreeRoot(),
salt: undefined,
...args,
});

return l1Data;
Expand Down
40 changes: 32 additions & 8 deletions yarn-project/end-to-end/src/fixtures/snapshot_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@aztec/aztec.js';
import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
import { createL1Clients } from '@aztec/ethereum';
import { type DeployL1ContractsArgs, createL1Clients } from '@aztec/ethereum';
import { asyncMap } from '@aztec/foundation/async-map';
import { type Logger, createDebugLogger } from '@aztec/foundation/log';
import { makeBackoff, retry } from '@aztec/foundation/retry';
Expand Down Expand Up @@ -60,8 +60,15 @@ type SnapshotEntry = {
snapshotPath: string;
};

export function createSnapshotManager(testName: string, dataPath?: string, config: Partial<AztecNodeConfig> = {}) {
return dataPath ? new SnapshotManager(testName, dataPath, config) : new MockSnapshotManager(testName, config);
export function createSnapshotManager(
testName: string,
dataPath?: string,
config: Partial<AztecNodeConfig> = {},
deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = { assumeProvenThrough: Number.MAX_SAFE_INTEGER },
) {
return dataPath
? new SnapshotManager(testName, dataPath, config, deployL1ContractsArgs)
: new MockSnapshotManager(testName, config, deployL1ContractsArgs);
}

export interface ISnapshotManager {
Expand All @@ -81,7 +88,11 @@ class MockSnapshotManager implements ISnapshotManager {
private context?: SubsystemsContext;
private logger: DebugLogger;

constructor(testName: string, private config: Partial<AztecNodeConfig> = {}) {
constructor(
testName: string,
private config: Partial<AztecNodeConfig> = {},
private deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = { assumeProvenThrough: Number.MAX_SAFE_INTEGER },
) {
this.logger = createDebugLogger(`aztec:snapshot_manager:${testName}`);
this.logger.warn(`No data path given, will not persist any snapshots.`);
}
Expand All @@ -103,7 +114,7 @@ class MockSnapshotManager implements ISnapshotManager {

public async setup() {
if (!this.context) {
this.context = await setupFromFresh(undefined, this.logger, this.config);
this.context = await setupFromFresh(undefined, this.logger, this.config, this.deployL1ContractsArgs);
}
return this.context;
}
Expand All @@ -124,7 +135,12 @@ class SnapshotManager implements ISnapshotManager {
private livePath: string;
private logger: DebugLogger;

constructor(testName: string, private dataPath: string, private config: Partial<AztecNodeConfig> = {}) {
constructor(
testName: string,
private dataPath: string,
private config: Partial<AztecNodeConfig> = {},
private deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = { assumeProvenThrough: Number.MAX_SAFE_INTEGER },
) {
this.livePath = join(this.dataPath, 'live', testName);
this.logger = createDebugLogger(`aztec:snapshot_manager:${testName}`);
}
Expand Down Expand Up @@ -201,7 +217,7 @@ class SnapshotManager implements ISnapshotManager {
this.logger.verbose(`Restoration of ${e.name} complete.`);
});
} else {
this.context = await setupFromFresh(this.livePath, this.logger, this.config);
this.context = await setupFromFresh(this.livePath, this.logger, this.config, this.deployL1ContractsArgs);
}
}
return this.context;
Expand Down Expand Up @@ -269,6 +285,9 @@ async function setupFromFresh(
statePath: string | undefined,
logger: Logger,
config: Partial<AztecNodeConfig> = {},
deployL1ContractsArgs: Partial<DeployL1ContractsArgs> = {
assumeProvenThrough: Number.MAX_SAFE_INTEGER,
},
): Promise<SubsystemsContext> {
logger.verbose(`Initializing state...`);

Expand Down Expand Up @@ -303,7 +322,12 @@ async function setupFromFresh(
aztecNodeConfig.publisherPrivateKey = `0x${publisherPrivKey!.toString('hex')}`;
aztecNodeConfig.validatorPrivateKey = `0x${validatorPrivKey!.toString('hex')}`;

const deployL1ContractsValues = await setupL1Contracts(aztecNodeConfig.l1RpcUrl, hdAccount, logger);
const deployL1ContractsValues = await setupL1Contracts(
aztecNodeConfig.l1RpcUrl,
hdAccount,
logger,
deployL1ContractsArgs,
);
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
aztecNodeConfig.l1PublishRetryIntervalMS = 100;

Expand Down
5 changes: 4 additions & 1 deletion yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ export const setupL1Contracts = async (
l1RpcUrl: string,
account: HDAccount | PrivateKeyAccount,
logger: DebugLogger,
args: { salt?: number; initialValidators?: EthAddress[] } = {},
args: { salt?: number; initialValidators?: EthAddress[]; assumeProvenThrough?: number } = {
assumeProvenThrough: Number.MAX_SAFE_INTEGER,
},
chain: Chain = foundry,
) => {
const l1Artifacts: L1ContractArtifactsForDeployment = {
Expand Down Expand Up @@ -148,6 +150,7 @@ export const setupL1Contracts = async (
vkTreeRoot: getVKTreeRoot(),
salt: args.salt,
initialValidators: args.initialValidators,
assumeProvenThrough: args.assumeProvenThrough,
});

return l1Data;
Expand Down
31 changes: 24 additions & 7 deletions yarn-project/ethereum/src/deploy_l1_contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ export interface L1ContractArtifactsForDeployment {
feeJuicePortal: ContractArtifacts;
}

export interface DeployL1ContractsArgs {
/**
* The address of the L2 Fee Juice contract.
*/
l2FeeJuiceAddress: AztecAddress;
/**
* The vk tree root.
*/
vkTreeRoot: Fr;
/**
* The block number to assume proven through.
*/
assumeProvenThrough?: number;
/**
* The salt for CREATE2 deployment.
*/
salt: number | undefined;
/**
* The initial validators for the rollup contract.
*/
initialValidators?: EthAddress[];
}

export type L1Clients = {
publicClient: PublicClient<HttpTransport, Chain>;
walletClient: WalletClient<HttpTransport, Chain, Account>;
Expand Down Expand Up @@ -144,13 +167,7 @@ export const deployL1Contracts = async (
chain: Chain,
logger: DebugLogger,
contractsToDeploy: L1ContractArtifactsForDeployment,
args: {
l2FeeJuiceAddress: AztecAddress;
vkTreeRoot: Fr;
assumeProvenThrough?: number;
salt: number | undefined;
initialValidators?: EthAddress[];
},
args: DeployL1ContractsArgs,
): Promise<DeployL1Contracts> => {
// We are assuming that you are running this on a local anvil node which have 1s block times
// To align better with actual deployment, we update the block interval to 12s
Expand Down

0 comments on commit 3302c48

Please sign in to comment.