Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a prover-node to the proving e2e tests #7952

Merged
merged 18 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/devnet-deploys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ env:
TF_VAR_BOT_PRIVATE_TRANSFERS_PER_TX: 0 # no private transfers
TF_VAR_BOT_PUBLIC_TRANSFERS_PER_TX: 1
TF_VAR_BOT_TX_MINED_WAIT_SECONDS: 2400
TF_VAR_BOT_NO_WAIT_FOR_TRANSFERS: true
TF_VAR_BOT_FOLLOW_CHAIN: "proven_chain"
TF_VAR_BOT_TX_INTERVAL_SECONDS: 180
TF_VAR_BOT_COUNT: 1

Expand Down
3 changes: 3 additions & 0 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,9 @@ int main(int argc, char* argv[])
} else if (command == "prove_keccak_ultra_honk") {
std::string output_path = get_option(args, "-o", "./proofs/proof");
prove_honk<UltraKeccakFlavor>(bytecode_path, witness_path, output_path);
} else if (command == "prove_keccak_ultra_honk_output_all") {
std::string output_path = get_option(args, "-o", "./proofs/proof");
prove_honk_output_all<UltraKeccakFlavor>(bytecode_path, witness_path, output_path);
} else if (command == "verify_ultra_honk") {
return verify_honk<UltraFlavor>(proof_path, vk_path) ? 0 : 1;
} else if (command == "verify_keccak_ultra_honk") {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/terraform/bot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ resource "aws_ecs_task_definition" "aztec-bot" {
{ name = "BOT_PRIVATE_TRANSFERS_PER_TX", value = var.BOT_PRIVATE_TRANSFERS_PER_TX },
{ name = "BOT_PUBLIC_TRANSFERS_PER_TX", value = var.BOT_PUBLIC_TRANSFERS_PER_TX },
{ name = "BOT_TX_MINED_WAIT_SECONDS", value = var.BOT_TX_MINED_WAIT_SECONDS },
{ name = "BOT_NO_WAIT_FOR_TRANSFERS", value = var.BOT_NO_WAIT_FOR_TRANSFERS },
{ name = "BOT_FOLLOW_CHAIN", value = var.BOT_FOLLOW_CHAIN },
{ name = "AZTEC_NODE_URL", value = "http://${var.DEPLOY_TAG}-aztec-node-1.local/${var.DEPLOY_TAG}/aztec-node-1/${var.API_KEY}" },
{ name = "PXE_PROVER_ENABLED", value = tostring(var.PROVING_ENABLED) },
{ name = "NETWORK", value = var.DEPLOY_TAG }
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/terraform/bot/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ variable "BOT_TX_MINED_WAIT_SECONDS" {
type = string
}

variable "BOT_NO_WAIT_FOR_TRANSFERS" {
variable "BOT_FOLLOW_CHAIN" {
type = string
default = true
}
Expand Down
13 changes: 10 additions & 3 deletions yarn-project/bot/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,20 @@ export class Bot {

const txHash = await tx.getTxHash();

if (this.config.noWaitForTransfers) {
if (this.config.followChain === 'none') {
this.log.info(`Transaction ${txHash} sent, not waiting for it to be mined`);
return;
}

this.log.verbose(`Awaiting tx ${txHash} to be mined (timeout ${this.config.txMinedWaitSeconds}s)`, logCtx);
const receipt = await tx.wait({ timeout: this.config.txMinedWaitSeconds });
this.log.verbose(
`Awaiting tx ${txHash} to be on the ${this.config.followChain} (timeout ${this.config.txMinedWaitSeconds}s)`,
logCtx,
);
const receipt = await tx.wait({
timeout: this.config.txMinedWaitSeconds,
provenTimeout: this.config.txMinedWaitSeconds,
proven: this.config.followChain === 'proven_chain',
});
this.log.info(`Tx ${receipt.txHash} mined in block ${receipt.blockNumber}`, logCtx);
}

Expand Down
20 changes: 14 additions & 6 deletions yarn-project/bot/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
numberConfigHelper,
} from '@aztec/foundation/config';

const botFollowChain = ['none', 'pending_chain', 'proven_chain'] as const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really minor but can we make it 'NONE', 'PENDING', 'PROVEN'?

type BotFollowChain = (typeof botFollowChain)[number];

export type BotConfig = {
/** URL to the PXE for sending txs, or undefined if an in-proc PXE is used. */
pxeUrl: string | undefined;
Expand All @@ -28,8 +31,7 @@ export type BotConfig = {
noStart: boolean;
/** How long to wait for a tx to be mined before reporting an error. */
txMinedWaitSeconds: number;
/** Don't wait for transfer transactions. */
noWaitForTransfers: boolean;
followChain: BotFollowChain;
};

export const botConfigMappings: ConfigMappingsType<BotConfig> = {
Expand Down Expand Up @@ -86,10 +88,16 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
description: 'How long to wait for a tx to be mined before reporting an error.',
...numberConfigHelper(180),
},
noWaitForTransfers: {
env: 'BOT_NO_WAIT_FOR_TRANSFERS',
description: "Don't wait for transfer transactions.",
...booleanConfigHelper(),
followChain: {
env: 'BOT_FOLLOW_CHAIN',
description: 'Which chain the bot follows',
defaultValue: 'none',
parseEnv(val) {
if (!botFollowChain.includes(val as any)) {
throw new Error(`Invalid value for BOT_FOLLOW_CHAIN: ${val}`);
}
return val as BotFollowChain;
},
},
};

Expand Down
33 changes: 30 additions & 3 deletions yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SchnorrAccountContractArtifact, getSchnorrAccount } from '@aztec/accounts/schnorr';
import { type Archiver } from '@aztec/archiver';
import {
type AccountWalletWithSecretKey,
type AztecNode,
Expand All @@ -17,6 +18,7 @@ import {
import { BBCircuitVerifier } from '@aztec/bb-prover';
import { RollupAbi } from '@aztec/l1-artifacts';
import { TokenContract } from '@aztec/noir-contracts.js';
import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
import { type PXEService } from '@aztec/pxe';

// TODO(#7373): Deploy honk solidity verifier
Expand Down Expand Up @@ -72,6 +74,7 @@ export class FullProverTest {
circuitProofVerifier?: BBCircuitVerifier;
provenAssets: TokenContract[] = [];
private context!: SubsystemsContext;
private proverNode!: ProverNode;

constructor(testName: string, private minNumberOfTxsPerBlock: number) {
this.logger = createDebugLogger(`aztec:full_prover_test:${testName}`);
Expand Down Expand Up @@ -153,12 +156,11 @@ export class FullProverTest {

this.logger.debug(`Configuring the node for real proofs...`);
await this.aztecNode.setConfig({
proverAgentConcurrency: 2,
realProofs: true,
minTxsPerBlock: this.minNumberOfTxsPerBlock,
});

this.logger.debug(`Main setup completed, initializing full prover PXE and Node...`);
this.logger.debug(`Main setup completed, initializing full prover PXE, Node, and Prover Node...`);

for (let i = 0; i < 2; i++) {
const result = await setupPXEService(
Expand Down Expand Up @@ -204,7 +206,32 @@ export class FullProverTest {
this.provenAssets.push(asset);
}

this.logger.debug(`Full prover PXE started!!`);
this.logger.info(`Full prover PXE started`);

const blockNumber = await this.context.pxe.getBlockNumber();
await this.context.deployL1ContractsValues.publicClient.waitForTransactionReceipt({
hash: await getContract({
abi: RollupAbi,
address: this.context.deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
client: this.context.deployL1ContractsValues.walletClient,
}).write.setAssumeProvenUntilBlockNumber([BigInt(blockNumber)]),
});
this.logger.verbose(`Rollup contract set to assume proven until block ${blockNumber}`);

const proverConfig: ProverNodeConfig = {
...this.context.aztecNodeConfig,
txProviderNodeUrl: undefined,
dataDirectory: undefined,
proverId: new Fr(42),
realProofs: true,
proverAgentConcurrency: 2,
};
const archiver = this.context.aztecNode.getBlockSource() as Archiver;
this.proverNode = await createProverNode(proverConfig, { aztecNodeTxProvider: this.aztecNode, archiver });
this.proverNode.start();

this.logger.info('Prover node started');

return this;
}

Expand Down
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/src/e2e_prover/full.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('full_prover', () => {
await t.applyBaseSnapshots();
await t.applyMintSnapshot();
await t.setup();
await t.deployVerifier();
// await t.deployVerifier();
({ provenAssets, accounts, tokenSim, logger } = t);
});

Expand Down Expand Up @@ -63,8 +63,8 @@ describe('full_prover', () => {
const sentPrivateTx = privateInteraction.send({ skipPublicSimulation: true });
const sentPublicTx = publicInteraction.send({ skipPublicSimulation: true });
await Promise.all([
sentPrivateTx.wait({ timeout: 1200, interval: 10 }),
sentPublicTx.wait({ timeout: 1200, interval: 10 }),
sentPrivateTx.wait({ timeout: 60, interval: 10, proven: true, provenTimeout: 600 }),
sentPublicTx.wait({ timeout: 60, interval: 10, proven: true, provenTimeout: 600 }),
]);
tokenSim.transferPrivate(accounts[0].address, accounts[1].address, privateSendAmount);
tokenSim.transferPublic(accounts[0].address, accounts[1].address, publicSendAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('full_prover_with_padding_tx', () => {
await t.applyBaseSnapshots();
await t.applyMintSnapshot();
await t.setup();
await t.deployVerifier();
// await t.deployVerifier();
({ provenAssets, accounts, tokenSim, logger } = t);
});

Expand Down
Loading
Loading