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

feat: Unified configurations #385

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

snowmead
Copy link
Contributor

@snowmead snowmead commented Feb 27, 2025

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 and bsp_config.toml which demonstrate the structure and all possible fields you can specify as input.

Task specific cli parameters are grouped.

@snowmead snowmead force-pushed the feat/unified-configurations branch from b0257e4 to c57da17 Compare February 27, 2025 14:55
@snowmead snowmead marked this pull request as ready for review February 28, 2025 00:10
@snowmead snowmead requested review from ffarall and links234 February 28, 2025 18:50
Copy link
Contributor

@ffarall ffarall left a 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

Comment on lines +1 to +5
// TODO CONSTANTS
pub const MAX_PENDING_EVENTS: usize = 2000;
pub const MAX_TASKS_SPAWNED_PER_QUEUE: usize = 2000;

// TODO CONSTANTS
Copy link
Contributor

Choose a reason for hiding this comment

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

What's up here?

Copy link
Contributor Author

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))
Copy link
Contributor

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 {
Copy link
Contributor

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?

Comment on lines 28 to 29
chrono = { workspace = true }

# Substrate
Copy link
Contributor

Choose a reason for hiding this comment

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

Why deleting?

Comment on lines +259 to +295
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());
Copy link
Contributor

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.

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