-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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
[fastx CLI] Add customisation to genesis #461
Conversation
@@ -1,25 +1,25 @@ | |||
// Copyright (c) Mysten Labs |
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.
Will be moving this to other files when #454 is merged
a4c5b61
to
8c4ec46
Compare
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! Looks excellent overall, only requesting changes for the generalization to a list of paths.
sui/src/config.rs
Outdated
pub authorities: Vec<AuthorityPrivateInfo>, | ||
pub accounts: Vec<AccountConfig>, | ||
#[serde(default = "default_framework_path")] | ||
pub framework_lib_path: PathBuf, |
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.
I think we should generalize this to a list of Move package paths that will be compiled and published in the specified order. This will allow us to include not only the Sui framework, but also custom packages that a particular customer wants (e.g., Geniteam would like a genesis with their demo modules).
sui/src/sui_commands.rs
Outdated
@@ -157,42 +201,28 @@ async fn make_server( | |||
committee: &Committee, | |||
pre_load_objects: &[Object], | |||
buffer_size: usize, | |||
) -> AuthorityServer { | |||
module_path: &Path, |
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.
module_path: &Path, | |
package_path: &Path, |
fn create_genesis_module_objects() -> Genesis { | ||
let sui_modules = sui_framework::get_sui_framework_modules(); | ||
let std_modules = sui_framework::get_move_stdlib_modules(); | ||
fn create_genesis_module_objects(lib_dir: &Path) -> SuiResult<Genesis> { |
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.
@awelc: I'm just realizing that this will not run the module initializers in the genesis modules, whereas we really want those to get run (since this is the only way for a custom genesis to create object types other than gas objects). I think adding this feature would be a great follow-up to Patrick's PR.
README.md
Outdated
"accounts": [ | ||
{ | ||
"address": "bd654f352c895d9ec14c491d3f2b4e1f98fb07323383bebe9f95ab625bff2fa0", | ||
"objects": [ |
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 might want to call this gas_objects
if that's the only object type we plan to support (though perhaps we'll want to generalize things a bit later). However, I think the typical approach to creating custom objects should be executing Move module initializers of genesis modules that create the custom objects + transfer them to the appropriate addresses(s). This will be safer + more ergonomic than encoding custom objects in a JSON config.
8c4ec46
to
5911a2b
Compare
sui/src/sui_commands.rs
Outdated
.collect() | ||
}; | ||
|
||
if !package.is_framework { |
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.
@sblackshear is this the right way to build packages for genesis?
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.
Looks good! We (or more accurately, module init master @awelc :)) will have to replace this code with something that calls into the adapter publishing code in order to run module initializers, but this is fine for now.
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 seems like in sui_commands.rs we are doing a lot of the same work which is done when creating genesis in genesis.rs, particularly with respect to creating the framework and standard library modules. Is it possible to merge/reuse these somehow?
Selfishly, this will also likely simplify adding support of module initializers, as it would reduce the number of places where this needs to be done.
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.
Should I create a separate issue for this? Unless there are some reasons why this would not make sense which I don't see after mu cursory look.
sui/src/config.rs
Outdated
pub fn default_genesis(path: &Path) -> Result<Self, anyhow::Error> { | ||
let working_dir = path.parent().ok_or(anyhow!("Cannot resolve file path."))?; | ||
let mut authorities = Vec::new(); | ||
for _ in 0..4 { |
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.
Define constant instead of 0..4
sui/src/config.rs
Outdated
for _ in 0..5 { | ||
let mut objects = Vec::new(); | ||
for _ in 0..5 { |
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.
Define constant instead of 0..5
sui/src/config.rs
Outdated
// Get default authority config from deserialization logic. | ||
let mut authority = AuthorityPrivateInfo::deserialize(Value::String(String::new()))?; | ||
authority.db_path = working_dir | ||
.join("authorities_db") |
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.
Define constant instead of "authorities_db"
sui/src/config.rs
Outdated
for _ in 0..5 { | ||
objects.push(ObjectConfig { | ||
object_id: ObjectID::random(), | ||
gas_value: 1000, |
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.
Define constant instead of 1000
Also we should probably use a much higher value like 10k. Gas runs out quickly when I used 1k. Just a thought
Thanks for handling this btw. It'll unblock lots of other work. |
One broader thought on genesis packages upon reflection (and apologies if this conflicts with my earlier advice). The system will not work at all without the Sui framework (e.g., the gas type is defined there!) and Move stdlib (since the Sui framework depends on these modules). So I think there is probably no point in making the paths to these user-configurable--the only thing this lets the user do is misconfigure the system in a way that won't work :). Instead, I would propose that genesis always include these modules, and only allow the user to supply paths to packages that should also be included. This will also let us simplify types like |
sui/src/sui_commands.rs
Outdated
.collect() | ||
}; | ||
|
||
if !package.is_framework { |
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.
Looks good! We (or more accurately, module init master @awelc :)) will have to replace this code with something that calls into the adapter publishing code in order to run module initializers, but this is fine for now.
sui/src/sui_commands.rs
Outdated
let object = | ||
Object::new_package(modules, SuiAddress::default(), TransactionDigest::genesis()); | ||
info!( | ||
"Loaded {}package [{}] from {:?}.", |
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.
"Loaded {}package [{}] from {:?}.", | |
"Loaded {} package [{}] from {:?}.", |
😂 no problem, this makes more sense as Sui and Move libs are mandatory. |
This PR is ready for more review. I have seperated framework_lib_path into :
|
fc8732a
to
d18fcb4
Compare
* ability to preload move module
d18fcb4
to
3c66a43
Compare
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.
Thanks for your patience Patrick
Added more metrics for primary node across the core, header_waiter, certificate_waiter & primary to primary endpoint requests.
Added more metrics for primary node across the core, header_waiter, certificate_waiter & primary to primary endpoint requests.
Todo: We should rename
AuthorityPrivateInfo
->AuthorityServerConfig
;AuthorityInfo
->AuthorityConfig
etc inconfig.rs
, we can rename them now as we have removed client.rs.Genesis customization
The genesis process can be customised by providing a genesis config file.
Example
genesis.conf
All attributes in genesis.conf are optional, default value will be use if the attributes are not provided.
For example, the config shown below will create a network of 4 authorities, and pre-populate 2 objects for 4 accounts.