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

Data Preservers Profiles #551

Merged
merged 14 commits into from
May 23, 2024
Merged

Data Preservers Profiles #551

merged 14 commits into from
May 23, 2024

Conversation

nanocryk
Copy link
Contributor

@nanocryk nanocryk commented May 13, 2024

Allow users to register profile for their data provider nodes. Profiles can be forcefully managed by origins configured in the runtime.

Later PRs will replace the current BootNodes storage with assignements from chain managers, both in a forced/free manner and a paid manner (which will add in profiles the payment plan required by the provider).

@nanocryk nanocryk marked this pull request as ready for review May 17, 2024 13:55
@nanocryk nanocryk added a0-pleasereview Pull request needs code review. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. labels May 17, 2024
@girazoki
Copy link
Collaborator

hey @nanocryk please make the CI pass while we review this

@girazoki
Copy link
Collaborator

Can we include a migration creating a profile for all existing bootnodes? I feel this would reduce the complexity in the follow-up PRs as you already have the correct data in storage

Copy link
Contributor

github-actions bot commented May 21, 2024

Coverage Report

(master)

@@                         Coverage Diff                         @@
##           master   jeremy-data-preservers-profiles      +/-   ##
===================================================================
+ Coverage   69.33%                            69.38%   +0.05%     
  Files         221                               221              
+ Lines       38618                             38883     +265     
===================================================================
+ Hits        26775                             26978     +203     
+ Misses      11843                             11905      +62     
Files Changed Coverage
/node/src/container_chain_spawner.rs 48.56% (+3.09%) 🔼
/pallets/data-preservers/src/lib.rs 89.67% (+2.44%) 🔼
/pallets/registrar/src/lib.rs 90.64% (+0.57%) 🔼
/pallets/registrar/src/weights.rs 38.35% (+3.08%) 🔼
/runtime/common/src/migrations.rs 50.00% (+3.85%) 🔼

Coverage generated Thu May 23 10:12:25 UTC 2024

@nanocryk
Copy link
Contributor Author

Can we include a migration creating a profile for all existing bootnodes? I feel this would reduce the complexity in the follow-up PRs as you already have the correct data in storage

We'll add it in the PR that'll add assignements and will effectively replace Bootnodes. Since assignements will deal with payment options (free, stream, other?) it'll add a new field to profiles, which would then require a second migration.

);

// Update deposit
let new_deposit = T::ProfileDeposit::profile_deposit(&profile)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the deposit depend on the profile instead of being fixed to the worst case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both can work. You can also impl this trait ignoring the profile and returning a const worst case cost :) This approach in the pallet is more versatile.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that we adjust it to whatever profile is being created tbh. It's definitely not the same to create a profile where you inject 100 blacklisted para-ids than one where you insert none

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah but what is the max difference going to be? 1000 bytes? How expensive is a deposit for that? My point is that I don't like to be handling dust on every profile update.

Copy link
Collaborator

Choose a reason for hiding this comment

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

how are you handling dust? you are just either releasing some amount or holding more tokens. And it's the user paying for it..

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean that the difference in deposit is so small that it doesn't matter, but I'm just guessing, maybe deposits are more expensive than I think.

#[scale_info(skip_type_params(T))]
pub struct Profile<T: Config> {
pub url: BoundedVec<u8, T::MaxBootNodeUrlLen>,
pub limited_to_para_ids: Option<BoundedVec<ParaId, T::MaxParaIdsVecLen>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

It would also be interesting to allow blacklisting some para ids, I imagine the case of a chain that is very active so this data preserver doesn't want to handle all the load.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so you want to have the choice between whitelisting and blacklisting?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it's not a bad idea and it does not cost much to add it

Copy link
Collaborator

Choose a reason for hiding this comment

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

Dont forget to update the deposit as we have new bytes now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deposit is computed from size so it should already take into account the change.

fn profile_deposit(profile: &Profile) -> Result<Balance, DispatchErrorWithPostInfo>;
}

pub struct BytesProfileDeposit<BaseCost, ByteCost>(PhantomData<(BaseCost, ByteCost)>);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is not a bad idea to be honest, but it's the first time that I see it in the pallet haha. I like it but since it's a configuration option maybe we can move it to a different file?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also let's add some comments to it

@@ -55,5 +76,209 @@ mod benchmarks {
assert_eq!(Pallet::<T>::boot_nodes(para_id), boot_nodes);
}

impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
#[benchmark]
fn create_profile(x: Linear<1, 200>, y: Linear<1, 10>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the weights, none of the benchmarks depend on x or y, that's great!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the runtime weigts it seems to use x and y but with very small multipliers. Should we simplify and remove those parameters?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would leave it, or maybe use one param which is "profile size", but it's fine

@nanocryk nanocryk merged commit a8336a4 into master May 23, 2024
32 checks passed
@nanocryk nanocryk deleted the jeremy-data-preservers-profiles branch May 23, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a0-pleasereview Pull request needs code review. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants