Skip to content
Snippets Groups Projects
Commit 1d06645d authored by Svyatoslav Nikolsky's avatar Svyatoslav Nikolsky
Browse files

fix review comments

parent 21215cd8
Branches 1863
No related merge requests found
Pipeline #245395 passed with stages
in 18 minutes and 30 seconds
......@@ -192,7 +192,7 @@ pub mod pallet {
ensure!(best_finalized_number < *number, <Error<T, I>>::OldHeader);
let authority_set = <CurrentAuthoritySet<T, I>>::get();
let extra_proof_size_bytes = authority_set.extra_proof_size_bytes();
let unused_proof_size = authority_set.unused_proof_size();
let set_id = authority_set.set_id;
verify_justification::<T, I>(&justification, hash, *number, authority_set.into())?;
......@@ -222,9 +222,8 @@ pub mod pallet {
justification.commit.precommits.len().saturated_into(),
justification.votes_ancestries.len().saturated_into(),
);
let actual_weight = pre_dispatch_weight.set_proof_size(
pre_dispatch_weight.proof_size().saturating_sub(extra_proof_size_bytes),
);
let actual_weight = pre_dispatch_weight
.set_proof_size(pre_dispatch_weight.proof_size().saturating_sub(unused_proof_size));
Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee })
}
......@@ -851,6 +850,7 @@ mod tests {
// our test config assumes 2048 max authorities and we are just using couple
let pre_dispatch_proof_size = pre_dispatch_weight.proof_size();
let actual_proof_size = result.unwrap().actual_weight.unwrap().proof_size();
assert!(actual_proof_size > 0);
assert!(
actual_proof_size < pre_dispatch_proof_size,
"Actual proof size {actual_proof_size} must be less than the pre-dispatch {pre_dispatch_proof_size}",
......
......@@ -33,7 +33,7 @@ pub type TestNumber = crate::BridgedBlockNumber<TestRuntime, ()>;
type Block = frame_system::mocking::MockBlock<TestRuntime>;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;
pub const MAX_BRIDGED_AUTHORITIES: u32 = 2048;
pub const MAX_BRIDGED_AUTHORITIES: u32 = 5;
use crate as grandpa;
......
......@@ -53,7 +53,7 @@ impl<T: Config<I>, I: 'static> StoredAuthoritySet<T, I> {
/// Maximal authorities set size is configured by the `MaxBridgedAuthorities` constant from
/// the pallet configuration. The PoV of the call includes the size of maximal authorities
/// count. If the actual size is smaller, we may subtract extra bytes from this component.
pub fn extra_proof_size_bytes(&self) -> u64 {
pub fn unused_proof_size(&self) -> u64 {
// we can only safely estimate bytes that are occupied by the authority data itself. We have
// no means here to compute PoV bytes, occupied by extra trie nodes or extra bytes in the
// whole set encoding
......@@ -91,7 +91,7 @@ mod tests {
type StoredAuthoritySet = super::StoredAuthoritySet<TestRuntime, ()>;
#[test]
fn extra_proof_size_bytes_works() {
fn unused_proof_size_works() {
let authority_entry = authority_list().pop().unwrap();
// when we have exactly `MaxBridgedAuthorities` authorities
......@@ -101,7 +101,7 @@ mod tests {
0,
)
.unwrap()
.extra_proof_size_bytes(),
.unused_proof_size(),
0,
);
......@@ -112,7 +112,7 @@ mod tests {
0,
)
.unwrap()
.extra_proof_size_bytes(),
.unused_proof_size(),
40,
);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment