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