-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Conversation
Remove the genesis free function and instead completely rely on ConfigBuilder + GenesisBuilder for performing genesis.
@@ -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()); |
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.
Remove?
// let move_framework = | ||
// Object::new_package(move_modules.clone(), TransactionDigest::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.
// let move_framework = | |
// Object::new_package(move_modules.clone(), TransactionDigest::genesis()); |
// pub fn add_account(mut self, config: AccountConfig) -> Self { | ||
// self.accounts.push(config); | ||
// self | ||
// } |
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.
// 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); |
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.
// 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()); |
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.
// 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); |
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.
// objects.push(sui_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.
@bmwill i like the direction this is going.
Most of my comments are nits really.
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. |
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'sValidatorConfig
. 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 theGenesis
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.