-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: Unified configurations #385
base: main
Are you sure you want to change the base?
Conversation
b0257e4
to
c57da17
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.
Left some comments that are mostly questions. It's looking good. Not yet approving just to remind myself of talking about these things
// TODO CONSTANTS | ||
pub const MAX_PENDING_EVENTS: usize = 2000; | ||
pub const MAX_TASKS_SPAWNED_PER_QUEUE: usize = 2000; | ||
|
||
// TODO CONSTANTS |
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's up here?
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.
Thank you for spotting, marked them as constants to remove to make them cli parameters
// Send extrinsic to increase capacity | ||
match self.send_extrinsic(call, Default::default()).await { | ||
match self | ||
.send_extrinsic(call, &SendExtrinsicOptions::new(extrinsic_retry_timeout)) |
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.
This doesn't seem to be useful at all if we're not calling watch_transaction
(which we shouldn't)
} | ||
|
||
impl SendExtrinsicOptions { | ||
pub fn new() -> Self { | ||
Self::default() | ||
pub fn new(timeout: Duration) -> 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.
Why is this a "required" parameter now?
chrono = { workspace = true } | ||
|
||
# Substrate |
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.
Why deleting?
if let Some(c) = msp_delete_file { | ||
storage_hub_builder.with_msp_delete_file_config(c.clone()); | ||
} | ||
|
||
if let Some(c) = msp_charge_fees { | ||
storage_hub_builder.with_msp_charge_fees_config(c.clone()); | ||
} | ||
|
||
if let Some(c) = msp_move_bucket { | ||
storage_hub_builder.with_msp_move_bucket_config(c.clone()); | ||
} | ||
|
||
if let Some(c) = bsp_upload_file { | ||
storage_hub_builder.with_bsp_upload_file_config(c.clone()); | ||
} | ||
|
||
if let Some(c) = bsp_move_bucket { | ||
storage_hub_builder.with_bsp_move_bucket_config(c.clone()); | ||
} | ||
|
||
if let Some(c) = bsp_charge_fees { | ||
storage_hub_builder.with_bsp_charge_fees_config(c.clone()); | ||
} | ||
|
||
if let Some(c) = bsp_submit_proof { | ||
storage_hub_builder.with_bsp_submit_proof_config(c.clone()); | ||
} | ||
|
||
// Setup specific configuration for the MSP node. | ||
if *provider_type == ProviderType::Msp { | ||
storage_hub_builder | ||
.with_notify_period(*msp_charging_period) | ||
.with_indexer_db_pool(maybe_db_pool); | ||
} | ||
|
||
if let Some(c) = blockchain_service { | ||
storage_hub_builder.with_blockchain_service_config(c.clone()); |
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 this would look better if all these with_...
methods accepted an Option<>
, so that way we can call them regardless of whether the options was passed or not. It would just look cleaner.
Extracted all constants that should be exposed as cli parameters. This mostly were constants used by BSP and MSP tasks. They are now in the form of task specific configuration structs which are optionally specified by the user, otherwise they use their reasonable defaults we had already set to those previous constants.
The blockchain service now has its own configuration struct which only has at the moment the
extrinsic_retry_timeout
.Another initiative outside of the scope of this change is to separate the
StorageHubHandler
into specific actor handlers which would allow us to better handle required and non-required parameters based on the actor (provider_type
) chosen by the user - #386. As of right now this change applies the same pattern as we do for the rest of the existing builder parameters, where everything is optional.I suggest we separate the builder even further into a actor specific builder structs to only expose
with_*
methods that apply to those actors specifically. This would be to prevent an MSP actor adding BSP related configurations.There are 2 new configuration TOML examples in the root of the project -
msp_config.toml
andbsp_config.toml
which demonstrate the structure and all possible fields you can specify as input.Task specific cli parameters are grouped.