-
Notifications
You must be signed in to change notification settings - Fork 8
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
Wire between Orchestrator - Provider #101
Conversation
…d mirror implementation of tokio::fs with tests
…ider struct threadsafe using RwLock and Arc, added implementation logic of resume/restart/pause, destroy and helpers for logs
Refactor/provider trait l0r1s
…ions bits, added implementations and tests
…, moved error next to provider traits
…om_node in NativeProvider, removed unused comments
Sounds good, those are internals of the network_spec and not used outside,
but we can work on the naming and expose a more clear name from the module.
Not sure if we need to address this now but is a nice refactor if we have
time.
Thx!
…On Wed, 27 Sep 2023 at 17:44 Loris Moulin ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In crates/orchestrator/src/network_spec/node.rs
<#101 (comment)>
:
> + // otherwise use the default_args (can be empty).
+ let args: Vec<Arg> = if node_config.args().is_empty() {
+ chain_context
+ .default_args
+ .iter()
+ .map(|x| x.to_owned().clone())
+ .collect()
+ } else {
+ node_config.args().into_iter().cloned().collect()
+ };
+
+ let (key, peer_id) = generators::identity::generate_for_node(node_config.name())?;
+
+ let mut name = node_config.name().to_string();
+ let seed = format!("//{}{name}", name.remove(0).to_uppercase());
+ let accounts = generators::key::generate_for_node(&seed)?;
Same here
—
Reply to this email directly, view it on GitHub
<#101 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACY3B5LHWS5UP4TUIYF7TDX4SFZVANCNFSM6AAAAAA47A6JNQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Parity Technologies is a limited company registered in England and Wales
with registered number 09760015 and registered office at c/o Ignition Law,
1 Sans Walk, London, England, EC1R 0LT. This message is intended solely for
the addressee(s) and may contain confidential information. If you have
received this message in error, please notify us, and immediately and
permanently delete it. Do not use, copy or disclose the information
contained in this message or in any attachment. For information about how
we process data and monitor communications please see our Privacy policy
(https://www.parity.io/privacy/ <https://www.parity.io/privacy/>)and for
terms of use please see our Terms of Use policy
(https://www.parity.io/terms/ <https://www.parity.io/terms/>).
|
Co-authored-by: Loris Moulin <45130584+l0r1s@users.noreply.github.com>
Co-authored-by: Loris Moulin <45130584+l0r1s@users.noreply.github.com>
Coverage after merging feat/glue/network-spec_provider into main
Coverage Report
|
Coverage after merging feat/glue/network-spec_provider into main
Coverage Report
|
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.
Awesome work ! Asked many questions to understand more about how everything works and some todos we will tackle later 👏
let mut errs = vec![]; | ||
let relaychain = RelaychainSpec::from_config(network_config.relaychain())?; | ||
let mut parachains = vec![]; | ||
|
||
for para_config in network_config.parachains() { | ||
match ParachainSpec::from_config(para_config) { | ||
Ok(para) => parachains.push(para), | ||
Err(err) => errs.push(err), | ||
} | ||
} |
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.
nit: map + fold
let mut errs = vec![]; | |
let relaychain = RelaychainSpec::from_config(network_config.relaychain())?; | |
let mut parachains = vec![]; | |
for para_config in network_config.parachains() { | |
match ParachainSpec::from_config(para_config) { | |
Ok(para) => parachains.push(para), | |
Err(err) => errs.push(err), | |
} | |
} | |
let (parachains, errs) = network_config | |
.parachains() | |
.iter() | |
.map(|para_config| ParachainSpec::from_config(para_config)) | |
.fold((vec![], vec![]), |(mut parachains, mut errs), result| { | |
match result { | |
Ok(para) => parachains.push(para), | |
Err(err) => errs.push(err), | |
} | |
(parachains, errs) | |
}); |
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.
Yes, I think we can use fold
directly too :)
Err(err) => errs.push(err), | ||
} | ||
} | ||
|
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 don't use errors here, maybe do something like in network_spec::node ? A bit hacky but we will revisit later:
if !errs.is_empty() { | |
// TODO: merge errs | |
return Err(errs.swap_remove(0)); | |
} |
let main_cmd = if let Some(cmd) = config.default_command() { | ||
cmd | ||
} else if let Some(first_node) = config.collators().first() { | ||
let Some(cmd) = first_node.command() else { | ||
return Err(OrchestratorError::InvalidConfig("Parachain, either default_command or command in the first node needs to be set.".to_string())); | ||
}; | ||
|
||
cmd | ||
} else { | ||
return Err(OrchestratorError::InvalidConfig( | ||
"Parachain without nodes and default_command isn't set.".to_string(), | ||
)); | ||
}; |
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.
nit: same refacto as relaychain
let main_cmd = if let Some(cmd) = config.default_command() { | |
cmd | |
} else if let Some(first_node) = config.collators().first() { | |
let Some(cmd) = first_node.command() else { | |
return Err(OrchestratorError::InvalidConfig("Parachain, either default_command or command in the first node needs to be set.".to_string())); | |
}; | |
cmd | |
} else { | |
return Err(OrchestratorError::InvalidConfig( | |
"Parachain without nodes and default_command isn't set.".to_string(), | |
)); | |
}; | |
let main_cmd = config | |
.default_command() | |
.or(config.collators().first().and_then(|node| node.command())) | |
.ok_or(OrchestratorError::InvalidConfig( | |
"Parachain, either default_command or first node with command needs to be set." | |
.to_string(), | |
)); |
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.
TODO: extract errors to constants or variant with more details
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.
Yes, in general Errors
needs to be revamped as followup pr.
.filter(|para| match ¶.registration_strategy { | ||
RegistrationStrategy::InGenesis => true, | ||
RegistrationStrategy::UsingExtrinsic => false, | ||
}) |
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.
TODO: add helper on RegistrationStrategy to do something like this:
registration_strategy.is_in_genesis();
registration_strategy.is_using_extrinsic();
// TODO: we want to still supporting spawn a dedicated bootnode?? | ||
let mut ctx = SpawnNodeCtx { | ||
chain_id: &relay_chain_id, | ||
parachain_id: None, | ||
chain: relay_chain_name, | ||
role: ZombieRole::Node, | ||
ns: &ns, | ||
scoped_fs: &scoped_fs, | ||
parachain: None, | ||
bootnodes_addr: &vec![], | ||
}; |
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.
What do you mean ? If there is no bootnodes, do we want to bootstrap a node ourselves ?
Coverage after merging feat/glue/network-spec_provider into main
Coverage Report
|
Merging now @wirednkod / @l0r1s, thanks! |
NOTE: The base branch is a merge of
refactor/provider-trait
andfeat/network-spec
.This
pr
is still very WIP but is a good step forward and now we can spawn networks (relaychain
only at the moment), some parts of the code still have some values hardcoded that we need to replace from config/spec.A brief walkthrough
The
orchestrator
can be created by passing a filesystem (FS: Filesystem
) and a provider (P: Provider
) and have a public methodspawn
(that receive aNetworkConfig
) that in the future will return theNetwork
instance.So, basically you can use it like this
Inside the provider we compute the
NwtworkSpec
from the providedNetworkConfig
, for this we have a fewgenerators
that acts as helper methods to create stuffs likechain-spec
,node-identities
,keystore
, compute the command to run the node and other stuffs :)Ones we have the network spec computed, we start building the needed artifacts (at this point only the chain-spec for the relaychain is implemented but in the future in this step we need to create the
state
/wasm
and chain-spec for each parachain (and if is required register the para in the genesis of the relaychain).Then we calculate the bootnodes (to spawn first and get the
addr
to use in others) and continue with the process of spawning the nodes (at the moment I using a simpletry_join_all
in the future tasks but we should have a method to control the concurrency as we have in the current version)For each node at the moment we are creating a
NetworkNode
instance with theDynNode
stored asinner
and thespec
of the node also stored in the same instance. Is not ideal to hold all that info for each node but I think is something to improve ones we have a complete working version.And that all for now, there is much work to do until we have a real working version and the code is full of
//TODO: ...
to think through/implement. But to mention some things I'm sure we need to rethink:scoped filesystem
to encapsulate all the fs operations inside of the isolated (a.k.a fake root) directory of thens
, this is not ideal and would be good to implement some erasure technique to just add the logic as blanket impl. inside the trait. (Note: thefs trait
is not object-safe)config shared types
andsupport
are all over the places, we should just consolidate acommon
crate (or move all to support` to easily re-use them.env_logger
as part of a follow-up commit.TransferedFile
vsTransferFile
vsFileToTransfer
.As I said at the begging, this is very much
wip
but will be good to have your insights :)Thanks!
To run the example: