Skip to content

Commit

Permalink
Make the threshold check same in both mainnet and parachain
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauthamastro committed Feb 1, 2024
1 parent 012b960 commit 47113bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions pallets/thea-message-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use parity_scale_codec::Encode;
use sp_runtime::{
traits::{BlockNumberProvider, Member},
transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction},
Percent, RuntimeAppPublic, SaturatedConversion,
RuntimeAppPublic, SaturatedConversion,
};
use sp_std::prelude::*;
use thea_primitives::{
Expand Down Expand Up @@ -273,11 +273,8 @@ impl<T: Config> Pallet<T> {

let authorities = <Authorities<T>>::get(payload.validator_set_id).to_vec();
// Check for super majority
const MAJORITY: u8 = 67;
let p = Percent::from_percent(MAJORITY);
let threshold = p * authorities.len();
if payload.signatures.len() < threshold {
log::error!(target:"thea","Threshold: {:?}, Signs len: {:?}",threshold, payload.signatures.len());
if !payload.threshold_reached(authorities.len()) {
log::error!(target:"thea","Threshold not reached, Signs len: {:?}", payload.signatures.len());
return InvalidTransaction::Custom(2).into()
}

Expand Down
2 changes: 1 addition & 1 deletion runtimes/parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadex-parachain"),
impl_name: create_runtime_str!("polkadex-parachain"),
authoring_version: 1,
spec_version: 10,
spec_version: 11,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down

0 comments on commit 47113bb

Please sign in to comment.