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

refactor(mainnet): use genesis presets for mainnet runtime. #473

Conversation

al3mart
Copy link
Collaborator

@al3mart al3mart commented Feb 17, 2025

Based on #472

Moves genesis configuration for mainnet into the runtime.

These are the different spec that will use the mainnet runtime. These are the ones we can pass to the node via --chain <spec>.

/// A development chain running on a single node, using the `mainnet` runtime.
pub const MAINNET_DEV: &str = "pop-dev";
/// Configures a local chain running on multiple nodes for testing purposes, using the `mainnet`
/// runtime.
pub const MAINNET_LOCAL: &str = "pop-local";
/// A live chain running on multiple nodes, using the `mainnet` runtime.
pub const MAINNET: &str = "pop";

Requirements:

  • Council seats are populated in genesis state

[sc-2373]

@al3mart al3mart force-pushed the al3mart/refactor-genesis-preset-testnet branch 2 times, most recently from ae4800d to bb2046b Compare February 17, 2025 18:01
@al3mart al3mart force-pushed the al3mart/refactor-genesis-preset-mainnet branch 2 times, most recently from 10ffbe2 to 7aa5ddf Compare February 17, 2025 18:12
@al3mart al3mart force-pushed the al3mart/refactor-genesis-preset-testnet branch 2 times, most recently from d87cd19 to 8716241 Compare February 18, 2025 10:44
@al3mart al3mart force-pushed the al3mart/refactor-genesis-preset-mainnet branch from 7aa5ddf to 0d5c46a Compare February 18, 2025 11:55
@codecov-commenter
Copy link

codecov-commenter commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 96.13971% with 21 lines in your changes missing coverage. Please review.

Project coverage is 77.38%. Comparing base (2f47e84) to head (7d80362).
Report is 4 commits behind head on al3mart/refactor-genesis-preset-testnet.

Files with missing lines Patch % Lines
runtime/mainnet/src/genesis.rs 96.62% 15 Missing ⚠️
node/src/command.rs 0.00% 4 Missing ⚠️
runtime/mainnet/src/apis.rs 0.00% 2 Missing ⚠️
@@                             Coverage Diff                             @@
##           al3mart/refactor-genesis-preset-testnet     #473      +/-   ##
===========================================================================
+ Coverage                                    76.18%   77.38%   +1.19%     
===========================================================================
  Files                                           92       93       +1     
  Lines                                        18354    18758     +404     
  Branches                                     18354    18758     +404     
===========================================================================
+ Hits                                         13983    14515     +532     
+ Misses                                        4105     3977     -128     
  Partials                                       266      266              
Files with missing lines Coverage Δ
node/src/chain_spec.rs 65.73% <100.00%> (+52.36%) ⬆️
runtime/mainnet/src/lib.rs 66.23% <ø> (ø)
runtime/mainnet/src/apis.rs 0.00% <0.00%> (ø)
node/src/command.rs 0.00% <0.00%> (ø)
runtime/mainnet/src/genesis.rs 96.62% <96.62%> (ø)

... and 2 files with indirect coverage changes

@al3mart al3mart requested a review from a team February 18, 2025 17:34
@al3mart al3mart marked this pull request as ready for review February 18, 2025 17:35
@al3mart al3mart force-pushed the al3mart/refactor-genesis-preset-testnet branch from 62d1013 to 2f47e84 Compare February 18, 2025 19:07
@al3mart al3mart force-pushed the al3mart/refactor-genesis-preset-mainnet branch from 09c4cfa to 77cc194 Compare February 18, 2025 19:10
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

Well done, left some comments.

This PR is heavily correlated with the launch of devnet and testnet. Would be nice to hear what the plan is in terms of updating keys etc.

Copy link
Collaborator

@peterwht peterwht left a comment

Choose a reason for hiding this comment

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

Left a few nits, should be close to approving

Comment on lines +72 to +74
endowed_accounts.push(MaintenanceAccount::get());
endowed_accounts.push(PotId::get().into_account_truncating());
endowed_accounts.push(TreasuryAccount::get());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thoughts on giving these accounts only ED?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines 86 to 94
vec![GenesisAsset {
id: 0,
owner: Keyring::Alice.to_account_id(),
is_sufficient: false,
min_balance: ExistentialDeposit::get(),
name: "DOT".into(),
symbol: "DOT".into(),
decimals: 10,
}],
Copy link
Collaborator

@peterwht peterwht Feb 19, 2025

Choose a reason for hiding this comment

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

I realize you are getting conflicting code direction. However, for mainnet I would like to exclude this.

I am still not sold that we should have devs use the fungibles API for DOT. It introduces complexity (and potentially bad DevEx) due to pallet-balances missing functionality that pallet-assets has.

By including, we can forget its there. By excluding, we have to consciously add it in -- when we confirm it works.

If we want to reserve asset id 0, I recommend using another name than "DOT" as a placeholder.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Happy to remove from mainnet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let mut endowed_accounts = dev_accounts();
endowed_accounts.push(MaintenanceAccount::get());
endowed_accounts.push(PotId::get().into_account_truncating());
endowed_accounts.push(SudoAddress::get());
Copy link
Collaborator

Choose a reason for hiding this comment

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

SudoAddress is a multisig, right? That would mean for the local_config we wouldn't be able to use Sudo.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This also means there is a flaw in the test

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines 134 to 142
vec![GenesisAsset {
id: 0,
owner: SudoAddress::get(),
is_sufficient: false,
min_balance: ExistentialDeposit::get(),
name: "DOT".into(),
symbol: "DOT".into(),
decimals: 10,
}],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similarly, (for mainnet only) please remove or change the name from "DOT"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

})
}

// The initial balances at genesis.
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
// The initial balances at genesis.
// The initial balances at genesis for local testing only.

might consider adding this as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@al3mart
Copy link
Collaborator Author

al3mart commented Feb 20, 2025

Endowments have been improved in: 1ea9626

Such that only dev accounts get ENDOWMENT amount and all the rest are only funded with ED.
While it might have been handy to keep sudo mutlisig with more funds than ED, we can easily override this in the zombienet spec. The SS58 account is provided in a test for easy access.

No assets are stores at genesis anymore: 57f4d96.
The asset key however remain in genesis empty, as we have seen previously that for us to override any state in the zn spec we need the key to exist first.

This should solve all the concerns above.

Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

Still some comments unresolved and added some.

Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

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

LGTM! Do we need to ensure that the genesis hash is the same as the one already registered on chain?

@al3mart
Copy link
Collaborator Author

al3mart commented Feb 21, 2025

Do we need to ensure that the genesis hash is the same as the one already registered on chain?

No, it won't be.
We can use all this work for the testnet mirroring mainnet.

@al3mart al3mart merged commit f2691e4 into al3mart/refactor-genesis-preset-testnet Feb 21, 2025
3 checks passed
@al3mart al3mart deleted the al3mart/refactor-genesis-preset-mainnet branch February 21, 2025 11:27
al3mart added a commit that referenced this pull request Feb 24, 2025
* refactor(mainnet): collation config (#439)

* refactor(mainnet): add pallet_authorship to collation

* test(mainnet): add pallet_auhtorship test

* refactor(mainnet): add pallet_aura to collation

* test(mainnet): add pallet_aura tests

* refactor(mainnet): add collator_selection to collation

* test(mainnet): add collator_selection tests

* refactor(mainnet): add pallet_session & aura_ext to collation

* test(mainnet): add pallet_session tests

* chore(aura): MaxAuthorities matches max possible blocks produced

* remove unnused imports

* style(collation): order tests following pallet config

* style(collation): remove unnecessary qualifications

* style(collation): max_authorities_is_3600

* style(collation): reorg definition in session_keys_provided_by_aura test

* style(collation): better Period  comment

* style(collation): clarify session::SessionHandler comment

* refactor(collation): separate tests in modules by pallet

* style(collation): Explain SessionHandler config

fixes after rebase

* style(collation): remove prefixes from tests

* style(collation): Period comment was not helpful

changes after rebase

* chore(mainnet): remove duplicate module after rebase

* refactor(testnet): use genesis presets

* chore(testnet): add presetse to runtime api

* fix(genesis): bring vec into scope & clean build

* docs(genesis): improve testnet genesis spec comments

* chore(zombienet): update zombienet network spec

* refactor(genesis): inlcude genesis asset

* refactor(genesis): amend runtime pattern matcher for testnet

* style(chainspec): use Pop for testnet name

* refactor(genesis): use Alice as sudo account in local config

* refactor(genesis): use sudo as the genesis asset owner

* fix(genesis): missing clone for sudo_key

* refactor(mainnet): use genesis presets for mainnet runtime. (#473)

* refactor(mainnet): use genesis presets

* refactor(genesis): removed unused Relay struct

* fix(genesis): bring vec into scope & clean build

* chore(zombienet): update zombienet network spec

* refacotr(genesis): include genesis assets

* refactor(genesis): add genesis councilors

* test(chainspec): test spec configuration for mainnet

* fix(genesis): missing runtime type in sudo tests

* test(genesis): add mainnet genesis tests

* style(chainspec): use Pop as runtime name

* refactor(genesis): don't set ah as owner of genesis asset

* fix(chainspec): amend mainnet spec tests

* refactor(genesis): apply feedback

* refactor(genesis): better endowments

* refactor(genesis): remove genesis assets

* Update runtime/mainnet/src/genesis.rs

* Update runtime/mainnet/src/genesis.rs
al3mart added a commit that referenced this pull request Feb 24, 2025
* refactor(genesis): wip-use genesis presets for devnet runtime

* refactor(devnet): remove spec functions from node

* chore(devnet): add presets to runtime api

* fix(genesis): bring Vec into scope & clean build

* chore(zombienet): update zombienet devenet spec

* refactor(genesis): add relay asset at genesis

* refactor(genesis): genesis asset is not sufficient

* style(chainspec): use Pop

* fix(devnet): no endowed accounts on devnet live config

* refactor(collator_selection): reduce MaxCandidates to 0

* fix(genesis): bring vec into scope

* refactor(genesis): apply feedback

* refactor(testnet): use genesis presets for testnet runtime. (#472)

* refactor(mainnet): collation config (#439)

* refactor(mainnet): add pallet_authorship to collation

* test(mainnet): add pallet_auhtorship test

* refactor(mainnet): add pallet_aura to collation

* test(mainnet): add pallet_aura tests

* refactor(mainnet): add collator_selection to collation

* test(mainnet): add collator_selection tests

* refactor(mainnet): add pallet_session & aura_ext to collation

* test(mainnet): add pallet_session tests

* chore(aura): MaxAuthorities matches max possible blocks produced

* remove unnused imports

* style(collation): order tests following pallet config

* style(collation): remove unnecessary qualifications

* style(collation): max_authorities_is_3600

* style(collation): reorg definition in session_keys_provided_by_aura test

* style(collation): better Period  comment

* style(collation): clarify session::SessionHandler comment

* refactor(collation): separate tests in modules by pallet

* style(collation): Explain SessionHandler config

fixes after rebase

* style(collation): remove prefixes from tests

* style(collation): Period comment was not helpful

changes after rebase

* chore(mainnet): remove duplicate module after rebase

* refactor(testnet): use genesis presets

* chore(testnet): add presetse to runtime api

* fix(genesis): bring vec into scope & clean build

* docs(genesis): improve testnet genesis spec comments

* chore(zombienet): update zombienet network spec

* refactor(genesis): inlcude genesis asset

* refactor(genesis): amend runtime pattern matcher for testnet

* style(chainspec): use Pop for testnet name

* refactor(genesis): use Alice as sudo account in local config

* refactor(genesis): use sudo as the genesis asset owner

* fix(genesis): missing clone for sudo_key

* refactor(mainnet): use genesis presets for mainnet runtime. (#473)

* refactor(mainnet): use genesis presets

* refactor(genesis): removed unused Relay struct

* fix(genesis): bring vec into scope & clean build

* chore(zombienet): update zombienet network spec

* refacotr(genesis): include genesis assets

* refactor(genesis): add genesis councilors

* test(chainspec): test spec configuration for mainnet

* fix(genesis): missing runtime type in sudo tests

* test(genesis): add mainnet genesis tests

* style(chainspec): use Pop as runtime name

* refactor(genesis): don't set ah as owner of genesis asset

* fix(chainspec): amend mainnet spec tests

* refactor(genesis): apply feedback

* refactor(genesis): better endowments

* refactor(genesis): remove genesis assets

* Update runtime/mainnet/src/genesis.rs

* Update runtime/mainnet/src/genesis.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants