Skip to content

Commit

Permalink
chore: Rename some prover env vars (#9032)
Browse files Browse the repository at this point in the history
- Renames `PROVER_TARGET|MINIMUM_STAKE_AMOUNT` to
`PROVER_TARGET|MINIMUM_ESCROW_AMOUNT`.
- Adds a `PROVER_JOB_SOURCE_URL` to replace the overloaded
`AZTEC_NODE_URL` on the prover agent.
- Updates the docker-compose.provernet.yml template.
- Defaults target escrow amount to twice the minimum if not set.
  • Loading branch information
spalladino authored Oct 8, 2024
1 parent 97e4b9b commit e27ead8
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 36 deletions.
40 changes: 28 additions & 12 deletions docker-compose.provernet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Logs latest block numbers every 10 seconds.
name: aztec-provernet
services:

# Anvil instance that serves as L1
ethereum:
image: ghcr.io/foundry-rs/foundry@sha256:29ba6e34379e79c342ec02d437beb7929c9e254261e8032b17e187be71a2609f
Expand All @@ -22,6 +23,7 @@ services:
L1_CHAIN_ID: 31337
AZTEC_PORT: 80
DEPLOY_AZTEC_CONTRACTS: 1
DEPLOY_AZTEC_CONTRACTS_SALT: 1
ARCHIVER_POLLING_INTERVAL_MS: 1000
ARCHIVER_VIEM_POLLING_INTERVAL_MS: 1000
SEQ_VIEM_POLLING_INTERVAL_MS: 1000
Expand All @@ -32,12 +34,11 @@ services:
SEQ_PUBLISHER_PRIVATE_KEY: "0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a"
VALIDATOR_PRIVATE_KEY: "0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a"
PROVER_REAL_PROOFS: "${PROVER_REAL_PROOFS:-false}"
ASSUME_PROVEN_THROUGH_BLOCK_NUMBER: "${ASSUME_PROVEN_THROUGH_BLOCK_NUMBER:-4}"
P2P_ENABLED: false
volumes:
- ./log/aztec-node/:/usr/src/yarn-project/aztec/log:rw
healthcheck:
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:$AZTEC_PORT/status" ]
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:80/status" ]
interval: 3s
timeout: 30s
start_period: 120s
Expand All @@ -49,7 +50,7 @@ services:
- "--archiver"
- "--sequencer"

# Prover node that listens for unproven blocks on L1, and generates and submits block proofs
# Prover node that listens for unproven blocks on L1, generates quotes, and submits epoch proofs
# Requires one or more agents to be connected for actually generating proofs
# Fetches individual tx proofs from the aztec-node directly
aztec-prover:
Expand All @@ -68,18 +69,19 @@ services:
PROVER_AGENT_ENABLED: false
PROVER_PUBLISHER_PRIVATE_KEY: "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97"
PROVER_REAL_PROOFS: "${PROVER_REAL_PROOFS:-false}"
ASSUME_PROVEN_THROUGH_BLOCK_NUMBER: "${ASSUME_PROVEN_THROUGH_BLOCK_NUMBER:-4}"

PROVER_MINIMUM_ESCROW_AMOUNT: 1000000000
PROVER_TARGET_ESCROW_AMOUNT: 2000000000
PROVER_ID: "${PROVER_ID:-0x01}"
volumes:
- ./log/aztec-prover/:/usr/src/yarn-project/aztec/log:rw
depends_on:
aztec-node:
condition: service_healthy
healthcheck:
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:$AZTEC_PORT/status" ]
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:80/status" ]
interval: 3s
timeout: 30s
start_period: 10s
start_period: 120s
command: [ "start", "--prover-node", "--archiver" ]
restart: on-failure:5

Expand All @@ -92,13 +94,15 @@ services:
environment:
LOG_LEVEL: verbose
ETHEREUM_HOST: http://ethereum:8545
AZTEC_NODE_URL: http://aztec-prover
AZTEC_NODE_URL: http://aztec-prover # Deprecated, use PROVER_JOB_SOURCE_URL
PROVER_JOB_SOURCE_URL: http://aztec-prover
L1_CHAIN_ID: 31337
AZTEC_PORT: 80
PROVER_REAL_PROOFS: "${PROVER_REAL_PROOFS:-false}"
PROVER_TEST_DELAY_MS: "${PROVER_TEST_DELAY_MS:-0}"
PROVER_AGENT_CONCURRENCY: 2
BB_SKIP_CLEANUP: "${BB_SKIP_CLEANUP:-0}" # Persist tmp dirs for debugging
PROVER_ID: "${PROVER_ID:-0x01}"
volumes:
- ./log/aztec-prover-agent/:/usr/src/yarn-project/aztec/log:rw
- ./cache/bb-crs/:/root/.bb-crs:rw
Expand All @@ -109,7 +113,7 @@ services:
command: [ "start", "--prover" ]
restart: on-failure:5
healthcheck:
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:$AZTEC_PORT/status" ]
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:80/status" ]
interval: 3s
timeout: 30s
start_period: 20s
Expand All @@ -127,7 +131,7 @@ services:
L1_CHAIN_ID: 31337
AZTEC_PORT: 80
BOT_PRIVATE_KEY: 0xcafe
BOT_TX_INTERVAL_SECONDS: 5
BOT_TX_INTERVAL_SECONDS: 20
BOT_PRIVATE_TRANSFERS_PER_TX: 1
BOT_PUBLIC_TRANSFERS_PER_TX: 0
BOT_NO_WAIT_FOR_TRANSFERS: true
Expand All @@ -143,7 +147,7 @@ services:
aztec-node:
condition: service_healthy
healthcheck:
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:$AZTEC_PORT/status" ]
test: [ "CMD", "curl", "-fSs", "http://127.0.0.1:80/status" ]
interval: 3s
timeout: 30s
start_period: 10s
Expand All @@ -161,6 +165,18 @@ services:
condition: service_healthy
entrypoint: '/bin/bash -c'
command: >
'while true; do node --no-warnings ./node_modules/.bin/aztec block-number -u http://aztec-bot | head -n2; sleep 10; done'
'while true; do node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js block-number -u http://aztec-bot | head -n2; sleep 10; done'
restart: on-failure:5
stop_grace_period: 1s

# Run a CLI command against the bot's PXE or L1
# docker compose run --rm aztec-cli block-number
aztec-cli:
image: "aztecprotocol/${IMAGE:-aztec:master}"
environment:
ETHEREUM_HOST: http://ethereum:8545
PXE_URL: http://aztec-bot
L1_CHAIN_ID: 31337
stdin_open: true
tty: true
scale: 0
10 changes: 5 additions & 5 deletions yarn-project/aztec/src/cli/cmds/start_prover_agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import { type ServiceStarter, extractRelevantOptions } from '../util.js';

export const startProverAgent: ServiceStarter = async (options, signalHandlers, logger) => {
const proverConfig = extractRelevantOptions<ProverClientConfig>(options, proverClientConfigMappings, 'prover');

if (!proverConfig.nodeUrl) {
throw new Error('Starting prover without an orchestrator is not supported');
const proverJobSourceUrl = proverConfig.proverJobSourceUrl ?? proverConfig.nodeUrl;
if (!proverJobSourceUrl) {
throw new Error('Starting prover without PROVER_JOB_PROVIDER_URL is not supported');
}

logger(`Connecting to prover at ${proverConfig.nodeUrl}`);
const source = createProvingJobSourceClient(proverConfig.nodeUrl, 'provingJobSource');
logger(`Connecting to prover at ${proverJobSourceUrl}`);
const source = createProvingJobSourceClient(proverJobSourceUrl, 'provingJobSource');

const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings, 'tel');
const telemetry = await createAndStartTelemetryClient(telemetryConfig);
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ export class FullProverTest {
proverNodePollingIntervalMs: 100,
quoteProviderBasisPointFee: 100,
quoteProviderBondAmount: 1000n,
proverMinimumStakeAmount: 3000n,
proverTargetStakeAmount: 6000n,
proverMinimumEscrowAmount: 3000n,
proverTargetEscrowAmount: 6000n,
};
this.proverNode = await createProverNode(proverConfig, {
aztecNodeTxProvider: this.aztecNode,
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/fixtures/snapshot_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ async function createAndSyncProverNode(
proverNodePollingIntervalMs: 200,
quoteProviderBasisPointFee: 100,
quoteProviderBondAmount: 1000n,
proverMinimumStakeAmount: 1000n,
proverTargetStakeAmount: 2000n,
proverMinimumEscrowAmount: 1000n,
proverTargetEscrowAmount: 2000n,
};
const proverNode = await createProverNode(proverConfig, {
aztecNodeTxProvider: aztecNode,
Expand Down
5 changes: 3 additions & 2 deletions yarn-project/foundation/src/config/env_var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export type EnvVar =
| 'PROVER_ID'
| 'PROVER_JOB_POLL_INTERVAL_MS'
| 'PROVER_JOB_TIMEOUT_MS'
| 'PROVER_JOB_SOURCE_URL'
| 'PROVER_NODE_POLLING_INTERVAL_MS'
| 'PROVER_NODE_MAX_PENDING_JOBS'
| 'PROVER_PUBLISH_RETRY_INTERVAL_MS'
Expand All @@ -105,8 +106,8 @@ export type EnvVar =
| 'QUOTE_PROVIDER_BASIS_POINT_FEE'
| 'QUOTE_PROVIDER_BOND_AMOUNT'
| 'QUOTE_PROVIDER_URL'
| 'PROVER_TARGET_STAKE_AMOUNT'
| 'PROVER_MINIMUM_STAKE_AMOUNT'
| 'PROVER_TARGET_ESCROW_AMOUNT'
| 'PROVER_MINIMUM_ESCROW_AMOUNT'
| 'REGISTRY_CONTRACT_ADDRESS'
| 'ROLLUP_CONTRACT_ADDRESS'
| 'SEQ_ALLOWED_SETUP_FN'
Expand Down
6 changes: 6 additions & 0 deletions yarn-project/prover-client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundatio
* The prover configuration.
*/
export type ProverClientConfig = ProverConfig & {
/** The URL to the Aztec prover node to take proving jobs from */
proverJobSourceUrl?: string;
/** The working directory to use for simulation/proving */
acvmWorkingDirectory: string;
/** The path to the ACVM binary */
Expand All @@ -16,6 +18,10 @@ export type ProverClientConfig = ProverConfig & {
};

export const proverClientConfigMappings: ConfigMappingsType<ProverClientConfig> = {
proverJobSourceUrl: {
env: 'PROVER_JOB_SOURCE_URL',
description: 'The URL to the Aztec prover node to take proving jobs from',
},
acvmWorkingDirectory: {
env: 'ACVM_WORKING_DIRECTORY',
description: 'The working directory to use for simulation/proving',
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/prover-node/src/bond/bond-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { type EscrowContract } from './escrow-contract.js';
import { type TokenContract } from './token-contract.js';

export class BondManager {
private logger = createDebugLogger('aztec:prover-node:bond-manager');
private readonly logger = createDebugLogger('aztec:prover-node:bond-manager');

constructor(
public readonly tokenContract: TokenContract,
public readonly escrowContract: EscrowContract,
private readonly tokenContract: TokenContract,
private readonly escrowContract: EscrowContract,
/** Minimum escrowed bond. A top-up will be issued once this threshold is hit. */
public minimumAmount: bigint,
/** Target escrowed bond. Top-up will target this value. */
Expand Down
14 changes: 7 additions & 7 deletions yarn-project/prover-node/src/bond/config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { type ConfigMappingsType, bigintConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';

export type ProverBondManagerConfig = {
proverMinimumStakeAmount: bigint;
proverTargetStakeAmount?: bigint;
proverMinimumEscrowAmount: bigint;
proverTargetEscrowAmount?: bigint;
};

export const proverBondManagerConfigMappings: ConfigMappingsType<ProverBondManagerConfig> = {
proverMinimumStakeAmount: {
env: 'PROVER_MINIMUM_STAKE_AMOUNT',
proverMinimumEscrowAmount: {
env: 'PROVER_MINIMUM_ESCROW_AMOUNT',
description:
'Minimum amount to ensure is staked in the escrow contract for this prover. Prover node will top up whenever escrow falls below this number.',
...bigintConfigHelper(100000n),
},
proverTargetStakeAmount: {
env: 'PROVER_TARGET_STAKE_AMOUNT',
proverTargetEscrowAmount: {
env: 'PROVER_TARGET_ESCROW_AMOUNT',
description:
'Target amount to ensure is staked in the escrow contract for this prover. Prover node will top up to this value. Defaults to the minimum amount.',
'Target amount to ensure is staked in the escrow contract for this prover. Prover node will top up to this value. Defaults to twice the minimum amount.',
...bigintConfigHelper(),
},
};
Expand Down
7 changes: 4 additions & 3 deletions yarn-project/prover-node/src/bond/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export async function createBondManager(
overrides: Partial<ProverBondManagerConfig> = {},
) {
const config = { ...getProverBondManagerConfigFromEnv(), ...compact(overrides) };
const { proverMinimumStakeAmount: minimumStake, proverTargetStakeAmount: targetStake } = config;
const { proverMinimumEscrowAmount: minimumStake, proverTargetEscrowAmount: maybeTargetStake } = config;
const targetStake = maybeTargetStake ?? minimumStake * 2n;

const escrowContractAddress = EthAddress.fromString(await rollupContract.read.PROOF_COMMITMENT_ESCROW());
const escrow = new EscrowContract(client, escrowContractAddress);
Expand All @@ -41,7 +42,7 @@ export async function createBondManager(
const token = new TokenContract(client, tokenContractAddress);

// Ensure the prover has enough balance to cover escrow and try to mint otherwise if on a dev environment
await token.ensureBalance((targetStake ?? minimumStake) * 3n);
await token.ensureBalance(targetStake * 2n);

return new BondManager(token, escrow, minimumStake, targetStake ?? minimumStake);
return new BondManager(token, escrow, minimumStake, targetStake);
}

0 comments on commit e27ead8

Please sign in to comment.