Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xcm-emulator] Make a generic genesis constructor method #58

Closed
0xmovses opened this issue Dec 4, 2023 · 1 comment
Closed

[xcm-emulator] Make a generic genesis constructor method #58

0xmovses opened this issue Dec 4, 2023 · 1 comment

Comments

@0xmovses
Copy link

0xmovses commented Dec 4, 2023

Currently we write a separate genesis function for each Parachain when creating the emulated test environments cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/genesis.rs.
Much of this logic is repeated, but some is chain / environment specific. We can make a generic function, reducing code repetition and making this code more expressive.

We could do something like

trait RuntimeGenesisConfig {
    fn configure_storage(storage: &mut Storage);
}

Then we could do a impl RuntimeConfigurator for BridgeHubRococoRuntime, for example.

And finally:

impl Storage {
    pub fn new_with_config<R: GenesisRuntimeConfig>() -> Self {
        let mut storage = Storage::default();
        R::configure_storage(&mut storage);
        storage
    }
}

Originally suggested here by @liamaharon

@0xmovses
Copy link
Author

0xmovses commented Dec 4, 2023

Opened in wrong repo

@0xmovses 0xmovses closed this as completed Dec 4, 2023
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

No branches or pull requests

1 participant