diff --git a/yarn-project/aztec/src/cli/cmds/start_node.ts b/yarn-project/aztec/src/cli/cmds/start_node.ts index abed355ce4f6..cfbcbf93ba89 100644 --- a/yarn-project/aztec/src/cli/cmds/start_node.ts +++ b/yarn-project/aztec/src/cli/cmds/start_node.ts @@ -10,6 +10,7 @@ import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici'; import type { LogFn } from '@aztec/foundation/log'; import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker'; import { type CliPXEOptions, type PXEConfig, allPxeConfigMappings } from '@aztec/pxe/config'; +import { AztecAddress } from '@aztec/stdlib/aztec-address'; import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client'; import { P2PApiSchema, ProverNodeApiSchema, type ProvingJobBroker } from '@aztec/stdlib/interfaces/server'; import { @@ -82,7 +83,8 @@ export async function startNode( const testAccounts = nodeConfig.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : []; const sponsoredFPCAccounts = nodeConfig.sponsoredFPC ? [await getSponsoredFPCAddress()] : []; - const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts); + const prefundAddresses = (nodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a)); + const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts).concat(prefundAddresses); userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`); diff --git a/yarn-project/aztec/src/local-network/local-network.ts b/yarn-project/aztec/src/local-network/local-network.ts index 1b3882881359..a2d04e8b22ab 100644 --- a/yarn-project/aztec/src/local-network/local-network.ts +++ b/yarn-project/aztec/src/local-network/local-network.ts @@ -19,6 +19,7 @@ import { DateProvider, TestDateProvider } from '@aztec/foundation/timer'; import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree'; import { protocolContractsHash } from '@aztec/protocol-contracts'; import { SequencerState } from '@aztec/sequencer-client'; +import { AztecAddress } from '@aztec/stdlib/aztec-address'; import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server'; import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees'; import { @@ -138,9 +139,12 @@ export async function createLocalNetwork(config: Partial = { const bananaFPC = await getBananaFPCAddress(initialAccounts); const sponsoredFPC = await getSponsoredFPCAddress(); - const fundedAddresses = initialAccounts.length - ? [...initialAccounts.map(a => a.address), bananaFPC, sponsoredFPC] - : []; + const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a)); + const fundedAddresses = [ + ...initialAccounts.map(a => a.address), + ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []), + ...prefundAddresses, + ]; const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses); const dateProvider = new TestDateProvider(); diff --git a/yarn-project/ethereum/src/config.ts b/yarn-project/ethereum/src/config.ts index 5c271cd915cb..6ccee3ce7c2a 100644 --- a/yarn-project/ethereum/src/config.ts +++ b/yarn-project/ethereum/src/config.ts @@ -19,6 +19,8 @@ export type GenesisStateConfig = { testAccounts: boolean; /** Whether to populate the genesis state with initial fee juice for the sponsored FPC */ sponsoredFPC: boolean; + /** Additional addresses to prefund with fee juice at genesis */ + prefundAddresses: string[]; }; export type L1ContractsConfig = { @@ -259,6 +261,16 @@ export const genesisStateConfigMappings: ConfigMappingsType description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.', ...booleanConfigHelper(false), }, + prefundAddresses: { + env: 'PREFUND_ADDRESSES', + description: 'Comma-separated list of Aztec addresses to prefund with fee juice at genesis.', + parseEnv: (val: string) => + val + .split(',') + .map(a => a.trim()) + .filter(a => a.length > 0), + defaultValue: [], + }, }; export function getL1ContractsConfigEnvVars(): L1ContractsConfig { diff --git a/yarn-project/foundation/src/config/env_var.ts b/yarn-project/foundation/src/config/env_var.ts index c7bdfed39b44..18d677c83cb8 100644 --- a/yarn-project/foundation/src/config/env_var.ts +++ b/yarn-project/foundation/src/config/env_var.ts @@ -247,6 +247,7 @@ export type EnvVar = | 'TELEMETRY' | 'TEST_ACCOUNTS' | 'SPONSORED_FPC' + | 'PREFUND_ADDRESSES' | 'TX_COLLECTION_FAST_NODES_TIMEOUT_BEFORE_REQ_RESP_MS' | 'TX_COLLECTION_SLOW_NODES_INTERVAL_MS' | 'TX_COLLECTION_SLOW_REQ_RESP_INTERVAL_MS' diff --git a/yarn-project/node-lib/src/config/index.ts b/yarn-project/node-lib/src/config/index.ts index c8403d2b09bc..e6df4c979d94 100644 --- a/yarn-project/node-lib/src/config/index.ts +++ b/yarn-project/node-lib/src/config/index.ts @@ -5,6 +5,8 @@ export type SharedNodeConfig = { testAccounts: boolean; /** Whether to populate the genesis state with initial fee juice for the sponsored FPC */ sponsoredFPC: boolean; + /** Additional addresses to prefund with fee juice at genesis */ + prefundAddresses: string[]; /** Sync mode: full to always sync via L1, snapshot to download a snapshot if there is no local data, force-snapshot to download even if there is local data. */ syncMode: 'full' | 'snapshot' | 'force-snapshot'; /** Base URLs for snapshots index. Index file will be searched at `SNAPSHOTS_BASE_URL/aztec-L1_CHAIN_ID-VERSION-ROLLUP_ADDRESS/index.json` */ @@ -35,6 +37,16 @@ export const sharedNodeConfigMappings: ConfigMappingsType = { description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.', ...booleanConfigHelper(false), }, + prefundAddresses: { + env: 'PREFUND_ADDRESSES', + description: 'Comma-separated list of Aztec addresses to prefund with fee juice at genesis.', + parseEnv: (val: string) => + val + .split(',') + .map(a => a.trim()) + .filter(a => a.length > 0), + defaultValue: [], + }, syncMode: { env: 'SYNC_MODE', description: