Skip to content

Read general account files at genesis#1624

Merged
mmagician merged 29 commits intonextfrom
mmagician-accountfiles--at-genesis
Feb 23, 2026
Merged

Read general account files at genesis#1624
mmagician merged 29 commits intonextfrom
mmagician-accountfiles--at-genesis

Conversation

@mmagician
Copy link
Contributor

@mmagician mmagician commented Jan 31, 2026

Changes:

  • rename NativeFaucet -> NativeFaucetConfig, and make it 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

Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't like this.

The previous variant decoupled parsing from file IO, if we need the error context, then we should use something like:

let reader = fs_err::OpenOptions::new().read(true).open(path)?:
let gc = GenesisConfig::parse(reader).with_context(|| { file.path.display().to_string() })?;
..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I refactored things so that:

  • read_toml_file reads the contents of the provided path into a str, and then:
    • determines the parent dir
    • calls into read_toml, which parses TOML into GenesisConfig
  • then, the caller uses GenesisConfig::into_state() to construct the GenesisState

LMK if this is what you had in mind, or would you further separate not just parsing of GenesisConfig -> GenesisState but also of path to TOML content?

feat: unify GenesisConfig & NativeFaucet structs

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

@drahnr drahnr Feb 10, 2026

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 with protobuf generated code too.

Comment on lines +632 to +633
// SAFETY: TokenSymbol guarantees valid format, so to_string should not fail
let raw = symbol.to_string().expect("TokenSymbol should always produce valid string");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm actually surprised the method is fallible then. Looking at its code, it really shouldn't be returning an error.

let file_loaded_accounts = account_entries
.into_iter()
.map(|acc| {
let full_path = config_dir.join(&acc.path);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if the account path was specified as an absolute path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not supported ATM

@mmagician mmagician merged commit 41a2804 into next Feb 23, 2026
20 checks passed
@mmagician mmagician deleted the mmagician-accountfiles--at-genesis branch February 23, 2026 15:12
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