Skip to content

Conversation

@mmagician
Copy link
Contributor

@mmagician mmagician commented Jan 31, 2026

Changes:

  • make NativeFaucet an enum with Parameters and Account variants
  • change GenesisConfig::read_toml(toml_content) to `read_toml_path(toml_path),
    • and make it take Path instead, so we can lookup the directory and read in account files accordingly, which are referenced relative to the config file
  • add a sample config 02-with-account-files.toml
    • it references 3 .mac files that correspond to AggLayer accounts. The .mac files are also committed
    • add a unit test that processes this sample config
    • and a build.rs file in config::store module that auto-generates these AccountFiles

closes #1429

@mmagician mmagician marked this pull request as ready for review February 9, 2026 15:17
.map(|file_path| {
let toml_str = fs_err::read_to_string(file_path)?;
GenesisConfig::read_toml(toml_str.as_str()).with_context(|| {
GenesisConfig::read_toml_file(file_path).with_context(|| {
Copy link
Contributor

Choose a reason for hiding this comment

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

This swallows some errors, i.e. missing, access rights

/// Generates sample agglayer account files for the `02-with-account-files` genesis config sample.
///
/// Creates:
/// - `bridge.mac` - agglayer bridge account
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we document the .mac extension somewhere? miden-account-code?

Comment on lines +5 to +6
# using deterministic seeds for reproducibility.
# They demonstrate interdependencies between accounts:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit

Suggested change
# using deterministic seeds for reproducibility.
# They demonstrate interdependencies between accounts:
# using deterministic seeds for reproducibility.
#
# They demonstrate interdependencies between accounts:

AccountDelta(#[from] AccountDeltaError),
#[error("the defined asset {symbol:?} has no corresponding faucet")]
#[error(
"the defined asset {symbol:?} has no corresponding faucet, or the faucet was provided as an account file"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should impl Fmt for TokenSymbolStr so we can do

Suggested change
"the defined asset {symbol:?} has no corresponding faucet, or the faucet was provided as an account file"
"the defined asset '{symbol}' has no corresponding faucet, or the faucet was provided as an account file"

Comment on lines +34 to +36
#[error(
"the defined asset {symbol:?} has no corresponding faucet, or the faucet was provided as an account file"
)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand how the faucet being specified as an account file is an error, but I'll return to this once I've read the rest.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are generating them if the accounts are checked-in? As a general rule build.rs should be used for out of tree code generation, not to generate code that gets checked in.

Copy link
Contributor

Choose a reason for hiding this comment

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

Out of scope: We should revisit how we deal protobuf generated code too.

let toml_str =
fs_err::read_to_string(path).map_err(|e| GenesisConfigError::ConfigFileRead {
path: path.to_path_buf(),
reason: e.to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will lose context because an errors ToString implementation generally only logs the last error and not the full back trace. This is why we generally avoid "stringly" errors.

let account_file = AccountFile::read(&full_path).map_err(|e| {
GenesisConfigError::AccountFileRead {
path: full_path.clone(),
reason: e.to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This drops error context

Comment on lines +72 to +73
#[derive(Debug, Clone, serde::Deserialize)]
struct GenesisConfigToml {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably?

Suggested change
#[derive(Debug, Clone, serde::Deserialize)]
struct GenesisConfigToml {
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(deny_unknown_fields)]
struct GenesisConfigToml {


impl From<TokenSymbol> for TokenSymbolStr {
fn from(symbol: TokenSymbol) -> Self {
// TokenSymbol guarantees valid format, so to_string should not fail
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// TokenSymbol guarantees valid format, so to_string should not fail
// SAFETY: TokenSymbol guarantees valid format, so to_string should not fail

Comment on lines +386 to +387
// Append file-loaded accounts as-is
all_accounts.extend(file_loaded_accounts);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is safe - do the accounts not need to be verified? e.g. they can contain assets which have no faucets.

},
Account {
account: Box<Account>,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is somewhat confusing because its not adding much over NativeFaucetToml apart from having the account parsed (sometimes).

I would remove this; or at least streamline/refactor things so they make more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Genesis config: custom account types

3 participants