-
Notifications
You must be signed in to change notification settings - Fork 2
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 Rust-based chain specs #592
Conversation
We don't need this anymore. Functionality has been moved into the `chain_spec` module.
Let's keep this as simple as we can. If we need to add more chain configs later let's do that, but only if they're acutally being used.
This make `--dev` the default option if no chain is passed in. In the future we'll may want to change this to be our mainnet.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Ideally I'd want this to be the same as the `dev` config, but let's leave it this way for now.
node/cli/src/chain_spec/dev.rs
Outdated
Some([ | ||
28, 63, 144, 84, 78, 147, 195, 214, 190, 234, 111, 101, 117, 133, 9, 198, | ||
96, 96, 76, 140, 152, 251, 255, 28, 167, 38, 157, 185, 192, 42, 201, 82, | ||
]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are some of the mystery accounts I mention in the PR description. If nobody knows the mnemonic I'll just re-create these with a documented one in a follow-up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats not a mystery account if ive understood you. This is a tuple, (account_id, keyvisibilty, Option<x25519_public_key>)
where keyvisibility is a u8 representing public, private or permissioned. So //Eve
's account is private and has a given x25519 public key. @JesseAbram did it like this because there was some difficulty using the KeyVisibilty
type here, i don't remember exactly what it was.
This x25519 keypair was created by calling the derive_static_secret
fn //Eve
's private signing key. So we could maybe make that clearer by calling that fn here rather than giving it hard-coded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya it is sometimes wildly hard to get enums and structs to compile inside the runtime wasm and then also outside of it in the build spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats not a mystery account if ive understood you. This is a tuple, (account_id, keyvisibilty, Option<x25519_public_key>) where keyvisibility is a u8 representing public, private or permissioned. So //Eve's account is private and has a given x25519 public key
Thanks for clarifying this. In the genesis config the last part of the tuple is just a [u8; 32]
, so it's unclear what it actually was supposed to be.
This x25519 keypair was created by calling the derive_static_secret fn //Eve's private signing key. So we could maybe make that clearer by calling that fn here rather than giving it hard-coded.
Thing is, we use two different sets of Alice
, Bob
, etc. accounts. Some come from Substrate's sp_keyring
's Keyring
, while others are accounts which we've designated as Alice
, Bob
, etc. and are used by the TSS. Without the mnemonic it's hard to tell which account is which. But yes, would definitely be nicer to derive it in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya it is sometimes wildly hard to get enums and structs to compile inside the runtime wasm and then also outside of it in the build spec
We can improve this using typedefs, and things like this:
enum Enum {
Foo = 1,
Bar = 2,
Baz = 3,
}
We don't need to use complex types which are hard to serialize, and we don't need to work with raw byte arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! this makes stuff a lot clearer.
Its a little bit hard to see what exactly has changed as names of things have changed as well as what files they are in. Is the idea that docker compose would now use development_config
, and testnet-local
would be for if external people wanted to make their own testnet deployment similar to ours? I'm asking because the name 'testnet-local' kind of implies it runs locally, but it can't be used in the 'local' docker compose setup as it currently is because it has 4 validators rather than 2.
node/cli/src/chain_spec/dev.rs
Outdated
Some([ | ||
28, 63, 144, 84, 78, 147, 195, 214, 190, 234, 111, 101, 117, 133, 9, 198, | ||
96, 96, 76, 140, 152, 251, 255, 28, 167, 38, 157, 185, 192, 42, 201, 82, | ||
]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats not a mystery account if ive understood you. This is a tuple, (account_id, keyvisibilty, Option<x25519_public_key>)
where keyvisibility is a u8 representing public, private or permissioned. So //Eve
's account is private and has a given x25519 public key. @JesseAbram did it like this because there was some difficulty using the KeyVisibilty
type here, i don't remember exactly what it was.
This x25519 keypair was created by calling the derive_static_secret
fn //Eve
's private signing key. So we could maybe make that clearer by calling that fn here rather than giving it hard-coded.
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> { | ||
Ok(match id { | ||
"dev" => Box::new(chain_spec::development_config()), | ||
"test" => Box::new(chain_spec::testing_config()), | ||
"local-devnet" => Box::new(chain_spec::local_devnet_config()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docker compose setup uses local-devnet
so if removing it here i guess we need to change docker-compose.yaml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah I think you need to add it in specifically since it uses different urls to match the docker containers, this def needs to be kept in as an option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have this be configurable on the Docker side instead of having specific chainspecs for it. Future problem though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need one more chain type for docker other than that this looks good
node/cli/src/chain_spec/dev.rs
Outdated
Some([ | ||
28, 63, 144, 84, 78, 147, 195, 214, 190, 234, 111, 101, 117, 133, 9, 198, | ||
96, 96, 76, 140, 152, 251, 255, 28, 167, 38, 157, 185, 192, 42, 201, 82, | ||
]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya it is sometimes wildly hard to get enums and structs to compile inside the runtime wasm and then also outside of it in the build spec
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> { | ||
Ok(match id { | ||
"dev" => Box::new(chain_spec::development_config()), | ||
"test" => Box::new(chain_spec::testing_config()), | ||
"local-devnet" => Box::new(chain_spec::local_devnet_config()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah I think you need to add it in specifically since it uses different urls to match the docker containers, this def needs to be kept in as an option
This is meant to be compatible with the hostname scheme expected by the local `docker-compose` setup.
Yeah sorry. The best way to review is to open this up locally and look around the new
So tbh I forgot about the Docker config. Good catch on that! Your comment got me thinking and I'm gonna say that the convention is that a The |
This PR refactors the Rust-based chain spec code.
It removes some unused chain specs, and moves the remaining ones (
dev
,integration-tests
, andtestnet
) into their own modules. This makes it easier to makechanges to a specific chain spec without being tangled in a sea of other configuration
options and chain specs.
I've also pulled out a lot of accounts/public keys into consts (or equivalent) to make
the configurations easier to read.
One behavioral change here is that now if you run without specifying a
--chain
, thenit'll run a
--dev
chain. Before it used to run alocal
chain.Follow-ups
There's a few follow-ups that I'd like to do after this is merged:
testnet
genesis accounts, I'd like to use the accounts and maybe IPs that we actuallyintend to launch testnet with. This will make it so that @vitropy doesn't need to
manually fill these fields out as part of the Ansible playbooks
playbook
validators/TSS servers listed, or really any other pallet configurations
mnemonics and purpose
dev
config it's unclear if we need three different accounts in therelayer
GenesisConfigwhat the original mnemonic is
dev
andintegration-tests
networks #596