Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
jobs:
Checks:
name: Fmt-Clippy-Test-Benchmark
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

Expand Down
8 changes: 4 additions & 4 deletions runtime/chainx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("chainx"),
impl_name: create_runtime_str!("chainx-net"),
authoring_version: 1,
spec_version: 34,
spec_version: 35,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 7,
transaction_version: 8,
state_version: 0,
};

Expand Down Expand Up @@ -687,8 +687,8 @@ parameter_types! {
pub const VotingBondFactor: Balance = deposit(0, 32);
pub const VotingBond: Balance = DOLLARS;
pub const TermDuration: BlockNumber = DAYS;
pub const DesiredMembers: u32 = 11;
pub const DesiredRunnersUp: u32 = 7;
pub const DesiredMembers: u32 = 6;
pub const DesiredRunnersUp: u32 = 0;
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"pcx/phre";
}

Expand Down
45 changes: 43 additions & 2 deletions xpallets/gateway/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,28 @@ pub mod pallet {
Ok(())
}

/// Set the desired number of trustees for a chain.
///
/// This allows dynamically adjusting the trustee count (e.g., from 10 to 6).
/// The signature threshold will be automatically calculated as 2/3 of the trustee count.
///
/// This is called by the council or root.
#[pallet::weight(0u64)]
pub fn set_trustee_count(origin: OriginFor<T>, chain: Chain, count: u32) -> DispatchResult {
T::CouncilOrigin::try_origin(origin)
.map(|_| ())
.or_else(ensure_root)?;

let config = Self::trustee_info_config_of(chain);
ensure!(
count >= config.min_trustee_count && count <= config.max_trustee_count,
Error::<T>::TrusteeMembersNotEnough
);

TrusteeCount::<T>::insert(chain, count);
Ok(())
}

/// Set dst chain proxy address
///
/// Used to proxy the address of a certain target chain and help
Expand Down Expand Up @@ -773,6 +795,18 @@ pub mod pallet {
pub(crate) type TrusteeTransitionStatus<T: Config> =
StorageMap<_, Twox64Concat, Chain, bool, ValueQuery>;

/// The desired number of trustees for each chain.
/// Default is 10 to maintain compatibility with the current mainnet.
#[pallet::storage]
#[pallet::getter(fn trustee_count)]
pub(crate) type TrusteeCount<T: Config> =
StorageMap<_, Twox64Concat, Chain, u32, ValueQuery, DefaultForTrusteeCount>;

#[pallet::type_value]
pub fn DefaultForTrusteeCount() -> u32 {
0 // Default 0 means use DesiredMembers - 1 (original logic)
}

/// Members not participating in trustee elections.
///
/// The current trustee members did not conduct multiple signings and put the members in the
Expand Down Expand Up @@ -1012,8 +1046,15 @@ impl<T: Config> Pallet<T> {
})
.collect::<Vec<_>>();

let desired_members =
(<T as pallet_elections_phragmen::Config>::DesiredMembers::get() - 1) as usize;
// Use TrusteeCount storage if set, otherwise fallback to DesiredMembers - 1
let desired_members = {
let count = Self::trustee_count(chain);
if count > 0 {
count as usize
} else {
(<T as pallet_elections_phragmen::Config>::DesiredMembers::get() - 1) as usize
}
};

ensure!(
new_trustee_pool.len() >= desired_members,
Expand Down
Loading