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

genesis: begin reworking genesis to enable deterministic initialization of initial chain state #1972

Merged
merged 6 commits into from
May 16, 2022

Conversation

bmwill
Copy link
Contributor

@bmwill bmwill commented May 15, 2022

Today, in order to initialize a validator's initial chain state we need to disseminate a "GenesisConfig" which the validator then attempts to re-perform the entire genesis process from scratch. Unfortunately this process can be non-deterministic if configured to generate accounts without a pre-set address.

This PR changes this process by instead allowing for the genesis ceremony to be performed a single time and then have the resulting state packaged in a Genesis struct, which is then included in a validator's ValidatorConfig. This resulting state can be used to deterministically populate the initial state of the chain. More specifically, when a validator starts up and its storage is empty, it will process the contents of the Genesis struct to populate storage with the initial state of the chain.

This builds off of #1939 and implements the missing piece required for deployment as a validator's ValidatorConfig will have a complete picture of everything a validator will need when starting up.

There is still a bit more work to be done to make the genesis process a bit cleaner. Ideally genesis would be a single Transaction Certificate and this is a step toward that reality.

@bmwill bmwill mentioned this pull request May 16, 2022
@@ -403,7 +403,7 @@ async fn test_custom_genesis_with_custom_move_package() -> Result<(), anyhow::Er
// Checks network config contains package ids
let network_conf =
PersistedConfig::<NetworkConfig>::read(&working_dir.join(SUI_NETWORK_CONFIG))?;
assert_eq!(2, network_conf.loaded_move_packages().len());
// assert_eq!(2, network_conf.loaded_move_packages().len());
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove?

Comment on lines +145 to +146
// let move_framework =
// Object::new_package(move_modules.clone(), TransactionDigest::genesis());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// let move_framework =
// Object::new_package(move_modules.clone(), TransactionDigest::genesis());

Comment on lines +122 to +125
// pub fn add_account(mut self, config: AccountConfig) -> Self {
// self.accounts.push(config);
// self
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// pub fn add_account(mut self, config: AccountConfig) -> Self {
// self.accounts.push(config);
// self
// }

// let move_framework =
// Object::new_package(move_modules.clone(), TransactionDigest::genesis());
modules.push(move_modules);
// objects.push(move_framework);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// objects.push(move_framework);

);
let sui_modules =
sui_framework::get_sui_framework_modules(&sui_framework_lib_path).unwrap();
// let sui_framework = Object::new_package(sui_modules.clone(), TransactionDigest::genesis());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// let sui_framework = Object::new_package(sui_modules.clone(), TransactionDigest::genesis());

sui_framework::get_sui_framework_modules(&sui_framework_lib_path).unwrap();
// let sui_framework = Object::new_package(sui_modules.clone(), TransactionDigest::genesis());
modules.push(sui_modules);
// objects.push(sui_framework);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// objects.push(sui_framework);

Copy link
Contributor

@oxade oxade left a comment

Choose a reason for hiding this comment

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

@bmwill i like the direction this is going.
Most of my comments are nits really.

@bmwill
Copy link
Contributor Author

bmwill commented May 16, 2022

most of the things commented out were mostly around a "we probably want to do this but so I don't forget i'll comment it out". Which should be fixed on a follow up.

@bmwill bmwill merged commit 041a16f into MystenLabs:main May 16, 2022
@bmwill bmwill deleted the config branch May 16, 2022 17:07
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

Successfully merging this pull request may close these issues.

2 participants