-
Notifications
You must be signed in to change notification settings - Fork 53
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
Combine RemoveParaIdsWithNoCredit
and CollatorAssignmentHook
#692
base: master
Are you sure you want to change the base?
Combine RemoveParaIdsWithNoCredit
and CollatorAssignmentHook
#692
Conversation
611e197
to
ac88d40
Compare
RemoveParaIdsWithNoCredit
and CollatorAssignmentHook
RemoveParaIdsWithNoCredit
and CollatorAssignmentHook
ac88d40
to
b01541a
Compare
RemoveParaIdsWithNoCredit
and CollatorAssignmentHook
RemoveParaIdsWithNoCredit
and CollatorAssignmentHook
b01541a
to
b655d6b
Compare
Coverage Report@@ Coverage Diff @@
## master combine-remove-paraids-and-collator-assignment-hook +/- ##
=======================================================================================
+ Coverage 65.47% 65.50% +0.03%
Files 312 312
+ Lines 54503 54665 +162
=======================================================================================
+ Hits 35685 35808 +123
+ Misses 18818 18857 +39
|
916be99
to
d0ad35f
Compare
if collators.is_empty() { | ||
return true; | ||
} | ||
with_storage_layer(|| { |
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 is with_storage_layer
¿?
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.
So, with_storage_layer
is similar to with_transaction
but it automatically commits the storage changes into parent overlay if the closure returns Ok
and do the rollback otherwise.
Parity added this function since it is more convenient to use. (i.e you don't have to manually return Ok
or Err
for commit and rollback respectively.
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.
Are there any performance concerns when running that function inside a loop? I guess not?
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.
Fairly low cost. See here: paritytech/substrate#10809 (comment)
d0ad35f
to
7ccaa48
Compare
runtime/dancebox/src/lib.rs
Outdated
// This should take into account whether we tank goes below ED | ||
// The true refers to keepAlive | ||
Balances::can_withdraw(&pallet_services_payment::Pallet::<Runtime>::parachain_tank(*para_id), remaining_to_pay).into_result(true).is_ok() | ||
fn post_assignment_remove_para_ids_with_no_credits( |
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.
So can we remove this method? pre_assignment
already uses with_transaction
to remove para_ids that would have failed if Self::charge_para_ids_internal
returns Err
, so if I'm not wrong, calling post_assignment
will never remove any additional para id?
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.
In perfect world yes. But, since we are changing state in between calling pre
and post
we need to run it again to eliminate even a tiniest possibility that some para_id escapes the restrictions.
7ccaa48
to
b47f66e
Compare
WASM runtime size check:Compared to target branchdancebox runtime: 1416 KB (no changes) ✅ flashbox runtime: 828 KB (no changes) ✅ dancelight runtime: 2012 KB (no changes) ✅ container chain template simple runtime: 1088 KB (no changes) ✅ container chain template frontier runtime: 1388 KB (no changes) ✅ |
RemoveParaIdsWithNoCredit
and CollatorAssignmentHook
RemoveParaIdsWithNoCredit
and CollatorAssignmentHook
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 like better the way it looks now. I am still missing some doc on what each of the lines does. If we can fix that would be great
Description
Combine
RemoveParaIdsWithNoCredit
andCollatorAssignmentHook
in one trait with two methods.Both method executes same logic. Only difference being
pre_assignment_*
method always rollback whilepost_assignment_*
only rollback in case it errors out.Note
Naming and tests are still remaining. Just want to get some early feedback on overall design.