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
2 changes: 1 addition & 1 deletion yarn-project/archiver/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
},
archiverStoreMapSizeKb: {
env: 'ARCHIVER_STORE_MAP_SIZE_KB',
parseEnv: (val: string | undefined) => (val ? +val : undefined),
parseEnv: (val: string) => +val,
description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb.',
},
skipValidateCheckpointAttestations: {
Expand Down
8 changes: 6 additions & 2 deletions yarn-project/aztec/src/cli/aztec_start_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface AztecStartOption {
parseVal?: (val: string) => any;
}

export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping>) => {
export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping<unknown>>) => {
const options: AztecStartOption[] = [];
for (const [key, { env, defaultValue: def, parseEnv, description, printDefault, fallback }] of Object.entries(
configMappings,
Expand All @@ -58,7 +58,11 @@ export const getOptions = (namespace: string, configMappings: Record<string, Con
return options;
};

const configToFlag = (flag: string, configMapping: ConfigMapping, overrideDefaultValue?: any): AztecStartOption => {
const configToFlag = (
flag: string,
configMapping: ConfigMapping<unknown>,
overrideDefaultValue?: any,
): AztecStartOption => {
if (!configMapping.isBoolean) {
flag += ' <value>';
}
Expand Down
8 changes: 7 additions & 1 deletion yarn-project/aztec/src/cli/cmds/start_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ export async function startArchiver(
const envConfig = getArchiverConfigFromEnv();
const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobClientConfig>(
options,
{ ...archiverConfigMappings, ...dataConfigMappings, ...blobClientConfigMapping },
{
// dataConfigMappings must come first: its l1Contracts only maps rollupAddress,
// while archiverConfigMappings (spread later) maps all L1 contract addresses.
...dataConfigMappings,
...archiverConfigMappings,
...blobClientConfigMapping,
},
'archiver',
);

Expand Down
4 changes: 2 additions & 2 deletions yarn-project/blob-client/src/client/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const blobClientConfigMapping: ConfigMappingsType<BlobClientConfig> = {
blobSinkMapSizeKb: {
env: 'BLOB_SINK_MAP_SIZE_KB',
description: 'The maximum possible size of the blob sink DB in KB. Overwrites the general dataStoreMapSizeKb.',
parseEnv: (val: string | undefined) => (val ? +val : undefined),
parseEnv: (val: string) => +val,
},
blobAllowEmptySources: {
env: 'BLOB_ALLOW_EMPTY_SOURCES',
Expand All @@ -116,7 +116,7 @@ export const blobClientConfigMapping: ConfigMappingsType<BlobClientConfig> = {
blobHealthcheckUploadIntervalMinutes: {
env: 'BLOB_HEALTHCHECK_UPLOAD_INTERVAL_MINUTES',
description: 'Interval in minutes for uploading healthcheck file to file store (default: 60 = 1 hour)',
parseEnv: (val: string | undefined) => (val ? +val : undefined),
parseEnv: (val: string) => +val,
},
l1HttpTimeoutMS: {
env: 'ETHEREUM_HTTP_TIMEOUT_MS',
Expand Down
28 changes: 23 additions & 5 deletions yarn-project/foundation/src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,32 @@ describe('Config', () => {
expect(parseEnv!('2.5e5')).toBe(250000n);
});

it('returns default value for empty string', () => {
const { parseEnv } = bigintConfigHelper(42n);
expect(parseEnv!('')).toBe(42n);
});

it('throws for non-integer scientific notation results', () => {
const { parseEnv } = bigintConfigHelper();
expect(() => parseEnv!('1e-3')).toThrow();
});

it('returns default value for empty string env var', () => {
const originalEnv = process.env;
process.env = { ...originalEnv, L1_MINIMUM_PRIORITY_FEE_PER_GAS_GWEI: '' };
try {
interface TestConfig {
value: bigint;
}
const config = getConfigFromMappings<TestConfig>({
value: {
env: 'L1_MINIMUM_PRIORITY_FEE_PER_GAS_GWEI',
description: 'test',
parseEnv: () => {
throw new Error('parseEnv should not be called for empty string');
},
defaultValue: 42n,
},
});
expect(config.value).toBe(42n);
} finally {
process.env = originalEnv;
}
});
});
});
Loading
Loading