-
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
[authority] Refactor AuthorityState creation to have a single creation point #504
Conversation
I wonder if we still need the constructors that create AuthorityState without genesis. |
That's part of the refactoring. I got rid of the |
I removed the test-only constructor. Are we good with this refactoring otherwise? |
Do we still need two constructors? I was wondering if we could just always init it with genesis, and then we could just handle the module init logic in authority state constructor. |
This is the intent I expressed in this PR's description, and my previous commit removed the test-only constructor (that would not have any genesis modules anyway), but even previously we only had one constructor for non-test cases. Am I missing something here? |
Ah sorry I misunderstood somehow! |
This is because the genesis state is constructed slightly differently in genesir.rs and in sui_commands.rs and I did not intend it as too general of a refactoring, but rather just good enough to get me a single constructor for injecting module initializer execution. |
Could I please get additional revision feedback or get it it stamped? |
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.
Approving to unblock you.
But I don't quite understand why we have a path to create the state without genesis modules in sui_command. Maybe @patrickkuo or @oxade could clarify that.
Thank you! And I don't think we do a no-genesis part in sui_command. The separate |
store: Arc<AuthorityStore>, | ||
) -> Self { | ||
let (genesis_modules, native_functions) = genesis::clone_genesis_data(); | ||
// let (genesis_modules, native_functions) = genesis::clone_genesis_data(); |
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.
Oops, forgot to delete this?
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 certainly did... Thanks for noticing! Fixed in #518.
This is ideally the first step towards running module initializers when creating genesis state.
The main point of this refactoring is to have a single
AuthorityState
constructor with a clearly defined set of modules that are created as part of the genesis state, so that we can run module initializers at the point ofAuthorityState
construction.