Skip to content

Commit

Permalink
less breaking change WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
gui1117 committed Feb 8, 2025
1 parent 7edbc06 commit 0942da8
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 56 deletions.
1 change: 1 addition & 0 deletions polkadot/runtime/common/src/claims/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ pub mod pallet {
}
}

// TODO TODO:
#[pallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pallet<T> {
type Call = Call<T>;
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub fn conclude_pvf_checking<T: paras::Config>(
validator_index: validator_index.into(),
};
let signature = key.sign(&statement.signing_payload());
let _ = paras::Pallet::<T>::include_pvf_check_statement_general(
let _ = paras::Pallet::<T>::include_pvf_check_statement(
frame_system::Origin::<T>::Authorized.into(),
statement,
signature.into(),
Expand Down
8 changes: 4 additions & 4 deletions polkadot/runtime/parachains/src/disputes/slashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,16 @@ impl<T: Config> HandleReports<T> for () {
}

pub trait WeightInfo {
fn report_dispute_lost(validator_count: ValidatorSetCount) -> Weight;
fn authorize_report_dispute_lost() -> Weight;
fn report_dispute_lost_unsigned(validator_count: ValidatorSetCount) -> Weight;
fn authorize_report_dispute_lost_unsigned() -> Weight;
}

pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn report_dispute_lost_unsigned(_validator_count: ValidatorSetCount) -> Weight {
Weight::zero()
}
fn authorize_report_dispute_lost() -> Weight {
fn authorize_report_dispute_lost_unsigned() -> Weight {
Weight::zero()
}
}
Expand Down Expand Up @@ -633,7 +633,7 @@ impl<T: Config> Pallet<T> {
}
}

/// Methods for the `ValidateUnsigned` or authorize implementation:
/// Methods for the `ValidateUnsigned` implementation:
///
/// It restricts calls to `report_dispute_lost_unsigned` to local calls (i.e.
/// extrinsics generated on this node) or that already in a block. This
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ mod benchmarks {
}

#[benchmark]
fn authorize_report_dispute_lost(n: Linear<4, { max_validators_for::<T>() }>) {
fn authorize_report_dispute_lost_unsigned(n: Linear<4, { max_validators_for::<T>() }>) {
let (session_index, key_owner_proof, validator_id) = setup_validator_set::<T>(n);
let dispute_proof = setup_dispute::<T>(session_index, validator_id);
let call = Call::<T>::report_dispute_lost {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ where
let stmt_n_sig = stmts.pop().unwrap();

for (stmt, sig) in stmts {
let r = Pallet::<T>::include_pvf_check_statement_general(RawOrigin::Authorized.into(), stmt, sig);
let r = Pallet::<T>::include_pvf_check_statement(RawOrigin::Authorized.into(), stmt, sig);
assert!(r.is_ok());
}

Expand Down
25 changes: 3 additions & 22 deletions polkadot/runtime/parachains/src/paras/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,7 @@ pub trait WeightInfo {
fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight;
fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight;
fn include_pvf_check_statement() -> Weight;
fn include_pvf_check_statement_general_finalize_upgrade_accept() -> Weight;
fn include_pvf_check_statement_general_finalize_upgrade_reject() -> Weight;
fn include_pvf_check_statement_general_finalize_onboarding_accept() -> Weight;
fn include_pvf_check_statement_general_finalize_onboarding_reject() -> Weight;
fn include_pvf_check_statement_general() -> Weight;
fn authorize_include_pvf_check_statement_general() -> Weight;
fn authorize_include_pvf_check_statement() -> Weight;
}

pub struct TestWeightInfo;
Expand Down Expand Up @@ -604,22 +599,7 @@ impl WeightInfo for TestWeightInfo {
// This special value is to distinguish from the finalizing variants above in tests.
Weight::MAX - Weight::from_parts(1, 1)
}
fn include_pvf_check_statement_general_finalize_upgrade_accept() -> Weight {
Weight::MAX
}
fn include_pvf_check_statement_general_finalize_upgrade_reject() -> Weight {
Weight::MAX
}
fn include_pvf_check_statement_general_finalize_onboarding_accept() -> Weight {
Weight::MAX
}
fn include_pvf_check_statement_general_finalize_onboarding_reject() -> Weight {
Weight::MAX
}
fn include_pvf_check_statement_general() -> Weight {
Weight::MAX
}
fn authorize_include_pvf_check_statement_general() -> Weight {
fn authorize_include_pvf_check_statement() -> Weight {
Weight::MAX
}
}
Expand Down Expand Up @@ -1082,6 +1062,7 @@ pub mod pallet {
.max(<T as Config>::WeightInfo::include_pvf_check_statement_finalize_onboarding_reject())
)
)]
// TODO TODO: not deprecate accept both general and unsigned
#[deprecated(note = "Use `include_pvf_check_statement_general` instead.")]
pub fn include_pvf_check_statement(
origin: OriginFor<T>,
Expand Down
12 changes: 6 additions & 6 deletions polkadot/runtime/parachains/src/paras/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn sign_and_include_pvf_check_statement(stmt: PvfCheckStatement) {
Sr25519Keyring::Ferdie,
];
let signature = validators[stmt.validator_index.0 as usize].sign(&stmt.signing_payload());
Paras::include_pvf_check_statement_general(RawOrigin::Authorized.into(), stmt, signature.into()).unwrap();
Paras::include_pvf_check_statement(RawOrigin::Authorized.into(), stmt, signature.into()).unwrap();
}

fn submit_super_majority_pvf_votes(
Expand Down Expand Up @@ -1449,7 +1449,7 @@ fn pvf_check_submit_vote() {
validators[stmt.validator_index.0 as usize].sign(&stmt.signing_payload()).into();

let call =
Call::<Test>::include_pvf_check_statement_general { stmt: stmt.clone(), signature: signature.clone() };
Call::<Test>::include_pvf_check_statement { stmt: stmt.clone(), signature: signature.clone() };

with_transaction_unchecked(|| {
let authorized = call.authorize(TransactionSource::InBlock)
Expand All @@ -1460,7 +1460,7 @@ fn pvf_check_submit_vote() {
return TransactionOutcome::Rollback(Err(err));
}

let res = Paras::include_pvf_check_statement_general(
let res = Paras::include_pvf_check_statement(
RawOrigin::Authorized.into(),
stmt.clone(),
signature.clone()
Expand Down Expand Up @@ -1606,13 +1606,13 @@ fn include_pvf_check_statement_refunds_weight() {

// Verify that just vote submission is priced accordingly.
for (stmt, sig) in stmts {
let r = Paras::include_pvf_check_statement_general(RawOrigin::Authorized.into(), stmt, sig.into()).unwrap();
assert_eq!(r.actual_weight, Some(TestWeightInfo::include_pvf_check_statement_general()));
let r = Paras::include_pvf_check_statement(RawOrigin::Authorized.into(), stmt, sig.into()).unwrap();
assert_eq!(r.actual_weight, Some(TestWeightInfo::include_pvf_check_statement()));
}

// Verify that the last statement is priced maximally.
let (stmt, sig) = last_one;
let r = Paras::include_pvf_check_statement_general(RawOrigin::Authorized.into(), stmt, sig.into()).unwrap();
let r = Paras::include_pvf_check_statement(RawOrigin::Authorized.into(), stmt, sig.into()).unwrap();
assert_eq!(r.actual_weight, None);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,10 @@ impl<T: frame_system::Config> polkadot_runtime_common::claims::WeightInfo for We
.saturating_add(Weight::from_parts(0, 3761))
.saturating_add(T::DbWeight::get().reads(2))
}
fn claim_general() -> Weight {
fn authorize_claim() -> Weight {
Weight::zero()
}
fn claim_attest_general() -> Weight {
Weight::zero()
}
fn authorize_claim_general() -> Weight {
Weight::zero()
}
fn authorize_claim_attest_general() -> Weight {
fn authorize_claim_attest() -> Weight {
Weight::zero()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,5 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::paras::WeightInfo for
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
fn include_pvf_check_statement_general_finalize_upgrade_accept() -> Weight { Weight::zero() }
fn include_pvf_check_statement_general_finalize_upgrade_reject() -> Weight { Weight::zero() }
fn include_pvf_check_statement_general_finalize_onboarding_accept() -> Weight { Weight::zero() }
fn include_pvf_check_statement_general_finalize_onboarding_reject() -> Weight { Weight::zero() }
fn include_pvf_check_statement_general() -> Weight { Weight::zero() }
fn authorize_include_pvf_check_statement_general() -> Weight { Weight::zero() }
fn authorize_include_pvf_check_statement() -> Weight { Weight::zero() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::disputes::slashing::W
.saturating_add(T::DbWeight::get().writes(9))
.saturating_add(Weight::from_parts(0, 192).saturating_mul(n.into()))
}
fn authorize_report_dispute_lost_general() -> Weight {
fn authorize_report_dispute_lost_unsigned() -> Weight {
Weight::zero()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,5 @@ impl<T: frame_system::Config> polkadot_runtime_parachains::paras::WeightInfo for
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
fn include_pvf_check_statement_general_finalize_upgrade_accept() -> Weight { Weight::zero() }
fn include_pvf_check_statement_general_finalize_upgrade_reject() -> Weight { Weight::zero() }
fn include_pvf_check_statement_general_finalize_onboarding_accept() -> Weight { Weight::zero() }
fn include_pvf_check_statement_general_finalize_onboarding_reject() -> Weight { Weight::zero() }
fn include_pvf_check_statement_general() -> Weight { Weight::zero() }
fn authorize_include_pvf_check_statement_general() -> Weight { Weight::zero() }
fn authorize_include_pvf_check_statement() -> Weight { Weight::zero() }
}
1 change: 1 addition & 0 deletions substrate/frame/mixnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ pub mod pallet {
/// The mixnode set for the very first session.
pub mixnodes: BoundedVec<BoundedMixnodeFor<T>, T::MaxAuthorities>,
}
// TODO TODO: support validate unsigned again

#[pallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
Expand Down

0 comments on commit 0942da8

Please sign in to comment.