Compare commits
1 Commits
main
...
pallet-wea
| Author | SHA1 | Date | |
|---|---|---|---|
| fde1f68dc0 |
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ghost-exodus"
|
name = "ghost-exodus"
|
||||||
version = "0.0.11"
|
version = "0.0.12"
|
||||||
description = "Threshold signature generation with DKG included"
|
description = "Threshold signature generation with DKG included"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
|||||||
@ -808,7 +808,9 @@ mod benchmarks {
|
|||||||
let (_, network_curve, _, _) = prepare_pallet::<T>(1usize);
|
let (_, network_curve, _, _) = prepare_pallet::<T>(1usize);
|
||||||
|
|
||||||
let network_id = NetworkIdOf::<T>::default();
|
let network_id = NetworkIdOf::<T>::default();
|
||||||
let amount: BalanceOf<T> = 10_000u32.into();
|
let base_amount: BalanceOf<T> = 10_000u32.into();
|
||||||
|
let amount = base_amount.saturating_add(T::Currency::minimum_balance());
|
||||||
|
|
||||||
let bounty = Perbill::from_percent(5);
|
let bounty = Perbill::from_percent(5);
|
||||||
let receiver = EvmAddress::from([69u8; 20]);
|
let receiver = EvmAddress::from([69u8; 20]);
|
||||||
|
|
||||||
@ -819,14 +821,14 @@ mod benchmarks {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let total_existential = T::Currency::minimum_balance();
|
let initial_balance = T::Currency::minimum_balance()
|
||||||
let initial_balance = total_existential
|
|
||||||
.saturating_mul(5u32.into())
|
.saturating_mul(5u32.into())
|
||||||
.saturating_add(amount);
|
.saturating_add(amount);
|
||||||
|
|
||||||
let _ = T::Currency::make_free_balance_be(&caller, initial_balance);
|
T::Currency::mint_into(&caller, initial_balance).unwrap();
|
||||||
let _ = T::NetworkDataHandler::register_incoming(&network_id, amount).unwrap();
|
let _ = T::NetworkDataHandler::register_incoming(&network_id, amount).unwrap();
|
||||||
|
|
||||||
|
let total_issuance = T::Currency::total_issuance();
|
||||||
let current_exodus_session = CurrentExodus::<T>::get();
|
let current_exodus_session = CurrentExodus::<T>::get();
|
||||||
|
|
||||||
#[extrinsic_call]
|
#[extrinsic_call]
|
||||||
@ -840,7 +842,8 @@ mod benchmarks {
|
|||||||
|
|
||||||
assert!(ExodusRequests::<T>::contains_key(&network_curve, current_exodus_session));
|
assert!(ExodusRequests::<T>::contains_key(&network_curve, current_exodus_session));
|
||||||
assert_eq!(CurrentExodus::<T>::get(), current_exodus_session + 1);
|
assert_eq!(CurrentExodus::<T>::get(), current_exodus_session + 1);
|
||||||
assert_eq!(T::Currency::free_balance(&caller), initial_balance - amount);
|
assert_eq!(T::Currency::balance(&caller), initial_balance - amount);
|
||||||
|
assert_eq!(T::Currency::total_issuance(), total_issuance - amount);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,9 @@
|
|||||||
use frame_support::{
|
use frame_support::{
|
||||||
pallet_prelude::*,
|
pallet_prelude::*,
|
||||||
traits::{
|
traits::{
|
||||||
Currency, DisabledValidators, ValidatorSet, ValidatorSetWithIdentification,
|
tokens::{Preservation, Precision, Fortitude}, fungible::{Inspect, Mutate},
|
||||||
OneSessionHandler, WithdrawReasons, ExistenceRequirement,
|
DisabledValidators, ValidatorSet, ValidatorSetWithIdentification,
|
||||||
|
OneSessionHandler,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use frame_system::{
|
use frame_system::{
|
||||||
@ -223,11 +224,8 @@ type BitmapByAuthority<T> = BoundedBTreeMap<AuthIndex, ParticipantsBitmap<T>, <T
|
|||||||
type QualifyingState<T> = PendingDkgAuthorities<ParticipantsBitmap<T>, BlockNumberFor<T>>;
|
type QualifyingState<T> = PendingDkgAuthorities<ParticipantsBitmap<T>, BlockNumberFor<T>>;
|
||||||
type ActivatedState<T> = ReadyDkgAuthorities<ParticipantsBitmap<T>>;
|
type ActivatedState<T> = ReadyDkgAuthorities<ParticipantsBitmap<T>>;
|
||||||
|
|
||||||
pub type BalanceOf<T> =
|
pub type BalanceOf<T> = <<T as Config>::Currency as Inspect<<T as frame_system::Config>::AccountId>>::Balance;
|
||||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
pub type NetworkIdOf<T> = <<T as Config>::NetworkDataHandler as NetworkDataBasicHandler>::NetworkId;
|
||||||
|
|
||||||
pub type NetworkIdOf<T> =
|
|
||||||
<<T as Config>::NetworkDataHandler as NetworkDataBasicHandler>::NetworkId;
|
|
||||||
|
|
||||||
pub type ValidatorId<T> = <<T as Config>::ValidatorSet as ValidatorSet<
|
pub type ValidatorId<T> = <<T as Config>::ValidatorSet as ValidatorSet<
|
||||||
<T as frame_system::Config>::AccountId,
|
<T as frame_system::Config>::AccountId,
|
||||||
@ -394,7 +392,7 @@ pub mod pallet {
|
|||||||
+ MaxEncodedLen;
|
+ MaxEncodedLen;
|
||||||
|
|
||||||
type ValidatorSet: ValidatorSetWithIdentification<Self::AccountId>;
|
type ValidatorSet: ValidatorSetWithIdentification<Self::AccountId>;
|
||||||
type Currency: Currency<Self::AccountId>;
|
type Currency: Inspect<Self::AccountId> + Mutate<Self::AccountId>;
|
||||||
|
|
||||||
type NetworkDataHandler: NetworkDataInspectHandler<NetworkData>
|
type NetworkDataHandler: NetworkDataInspectHandler<NetworkData>
|
||||||
+ NetworkDataMutateHandler<NetworkData, BalanceOf<Self>>
|
+ NetworkDataMutateHandler<NetworkData, BalanceOf<Self>>
|
||||||
@ -504,6 +502,7 @@ pub mod pallet {
|
|||||||
NoActiveAuthorities,
|
NoActiveAuthorities,
|
||||||
InvalidSignatureShare,
|
InvalidSignatureShare,
|
||||||
VerifyingShareNotFound,
|
VerifyingShareNotFound,
|
||||||
|
BelowExistentialBalance,
|
||||||
DkgAuthoritiesInProgress,
|
DkgAuthoritiesInProgress,
|
||||||
PackagesAlreadyRegistered,
|
PackagesAlreadyRegistered,
|
||||||
DkgAuthoritiesNotInitialized,
|
DkgAuthoritiesNotInitialized,
|
||||||
@ -1839,16 +1838,22 @@ pub mod pallet {
|
|||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
|
||||||
let _imbalance = T::Currency::withdraw(
|
ensure!(
|
||||||
|
amount > T::Currency::minimum_balance(),
|
||||||
|
Error::<T>::BelowExistentialBalance
|
||||||
|
);
|
||||||
|
|
||||||
|
let actual_amount = T::Currency::burn_from(
|
||||||
&who,
|
&who,
|
||||||
amount,
|
amount,
|
||||||
WithdrawReasons::TRANSFER,
|
Preservation::Expendable,
|
||||||
ExistenceRequirement::AllowDeath,
|
Precision::Exact,
|
||||||
|
Fortitude::Polite,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Self::do_register_evm_bridge_out_exodus(
|
Self::do_register_evm_bridge_out_exodus(
|
||||||
network_id,
|
network_id,
|
||||||
amount,
|
actual_amount,
|
||||||
bounty,
|
bounty,
|
||||||
receiver,
|
receiver,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ghost-weaver"
|
name = "ghost-weaver"
|
||||||
version = "0.0.10"
|
version = "0.0.11"
|
||||||
description = "Weaving a secure cryptographic tapestry across different external chains."
|
description = "Weaving a secure cryptographic tapestry across different external chains."
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
|||||||
@ -3,7 +3,10 @@
|
|||||||
|
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
pallet_prelude::*,
|
pallet_prelude::*,
|
||||||
traits::{Currency, Get, OneSessionHandler},
|
traits::{
|
||||||
|
Get, OneSessionHandler,
|
||||||
|
tokens::fungible::{Inspect, Mutate},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use frame_system::{
|
use frame_system::{
|
||||||
pallet_prelude::*,
|
pallet_prelude::*,
|
||||||
@ -86,13 +89,10 @@ type ThreadId = u64;
|
|||||||
type WeavingSession = u64;
|
type WeavingSession = u64;
|
||||||
type ExternalBlockNumber = u64;
|
type ExternalBlockNumber = u64;
|
||||||
|
|
||||||
type BalanceOf<T> =
|
type BalanceOf<T> = <<T as Config>::Currency as Inspect<<T as frame_system::Config>::AccountId>>::Balance;
|
||||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
type NetworkIdOf<T> = <<T as Config>::NetworkDataHandler as NetworkDataBasicHandler>::NetworkId;
|
||||||
|
|
||||||
pub type NetworkIdOf<T> = <<T as Config>::NetworkDataHandler as NetworkDataBasicHandler>::NetworkId;
|
|
||||||
|
|
||||||
type WeavingResult<T, O> = Result<O, WeavingError<NetworkIdOf<T>>>;
|
type WeavingResult<T, O> = Result<O, WeavingError<NetworkIdOf<T>>>;
|
||||||
|
|
||||||
type WeaversBitmap<T> = BoundedBitmap<BitmapChunk, <T as Config>::MaxAuthoritiesChunks>;
|
type WeaversBitmap<T> = BoundedBitmap<BitmapChunk, <T as Config>::MaxAuthoritiesChunks>;
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
@ -117,7 +117,7 @@ pub mod pallet {
|
|||||||
+ MaybeSerializeDeserialize
|
+ MaybeSerializeDeserialize
|
||||||
+ MaxEncodedLen;
|
+ MaxEncodedLen;
|
||||||
|
|
||||||
type Currency: Currency<Self::AccountId>;
|
type Currency: Inspect<Self::AccountId> + Mutate<Self::AccountId>;
|
||||||
|
|
||||||
type NetworkDataHandler: NetworkDataBasicHandler
|
type NetworkDataHandler: NetworkDataBasicHandler
|
||||||
+ NetworkDataInspectHandler<NetworkData>
|
+ NetworkDataInspectHandler<NetworkData>
|
||||||
@ -458,7 +458,7 @@ pub mod pallet {
|
|||||||
T::NetworkDataHandler::register_incoming(&network_id, amount)
|
T::NetworkDataHandler::register_incoming(&network_id, amount)
|
||||||
.map_err(|_| Error::<T>::CouldNotRegisterIncoming)?;
|
.map_err(|_| Error::<T>::CouldNotRegisterIncoming)?;
|
||||||
|
|
||||||
let _ = T::Currency::deposit_creating(&receiver, pure_amount);
|
T::Currency::mint_into(&receiver, pure_amount)?;
|
||||||
PulledThreads::<T>::insert(pulled_thread_key, ());
|
PulledThreads::<T>::insert(pulled_thread_key, ());
|
||||||
|
|
||||||
Self::deposit_event(Event::<T>::ThreadPulled {
|
Self::deposit_event(Event::<T>::ThreadPulled {
|
||||||
|
|||||||
@ -644,6 +644,8 @@ fn should_successfully_pull_evm_thread_and_mint_currency() {
|
|||||||
let expected_root = H256::from_slice(&root_string);
|
let expected_root = H256::from_slice(&root_string);
|
||||||
LoomStates::<TestRuntime>::insert(&network_id, &session, expected_root);
|
LoomStates::<TestRuntime>::insert(&network_id, &session, expected_root);
|
||||||
|
|
||||||
|
let mut total_issuance = 0;
|
||||||
|
|
||||||
for insert in inserts.into_iter() {
|
for insert in inserts.into_iter() {
|
||||||
let index_usize = insert.0 as crate::ThreadId;
|
let index_usize = insert.0 as crate::ThreadId;
|
||||||
let proof_index = index_usize % 256; // tree depth is fixed to 8
|
let proof_index = index_usize % 256; // tree depth is fixed to 8
|
||||||
@ -671,6 +673,7 @@ fn should_successfully_pull_evm_thread_and_mint_currency() {
|
|||||||
let thread_info = ThreadProof::EvmThreadProof(evm_thread_proof);
|
let thread_info = ThreadProof::EvmThreadProof(evm_thread_proof);
|
||||||
let pulled_thread_key = thread_info.get_unique_key(session, network_id);
|
let pulled_thread_key = thread_info.get_unique_key(session, network_id);
|
||||||
|
|
||||||
|
assert_eq!(Balances::total_issuance(), total_issuance);
|
||||||
assert_eq!(Balances::free_balance(&receiver_account), 0);
|
assert_eq!(Balances::free_balance(&receiver_account), 0);
|
||||||
assert!(!PulledThreads::<TestRuntime>::contains_key(
|
assert!(!PulledThreads::<TestRuntime>::contains_key(
|
||||||
&pulled_thread_key
|
&pulled_thread_key
|
||||||
@ -688,12 +691,15 @@ fn should_successfully_pull_evm_thread_and_mint_currency() {
|
|||||||
|
|
||||||
let expected_commission = 0u64;
|
let expected_commission = 0u64;
|
||||||
let expected_pure_amount = transfer_amount - expected_commission;
|
let expected_pure_amount = transfer_amount - expected_commission;
|
||||||
|
total_issuance = total_issuance.saturating_add(expected_pure_amount);
|
||||||
|
|
||||||
|
assert_eq!(Balances::total_issuance(), total_issuance);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Balances::free_balance(&receiver_account),
|
Balances::free_balance(&receiver_account),
|
||||||
expected_pure_amount
|
expected_pure_amount
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
System::assert_last_event(RuntimeEvent::GhostWeaver(Event::ThreadPulled {
|
System::assert_last_event(RuntimeEvent::GhostWeaver(Event::ThreadPulled {
|
||||||
pulled_thread_key,
|
pulled_thread_key,
|
||||||
network_id,
|
network_id,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user