apply exponential scale for bridge out amount
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
78bde93b7f
commit
352e3519a8
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-exodus"
|
||||
version = "0.0.14"
|
||||
version = "0.0.15"
|
||||
description = "Threshold signature generation with DKG included"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
@ -1846,14 +1846,16 @@ pub mod pallet {
|
||||
let base_evm_amount: BalanceOf<T> = T::BaseEvmAmount::get()
|
||||
.unique_saturated_into();
|
||||
|
||||
let pending_requests_count = ExodusRequests::<T>::count()
|
||||
.unique_saturated_into();
|
||||
let is_amount_sufficient = 1u32.checked_shl(ExodusRequests::<T>::count())
|
||||
.map(|scale| {
|
||||
T::Currency::minimum_balance()
|
||||
.saturating_mul(scale.unique_saturated_into())
|
||||
.saturating_add(base_evm_amount)
|
||||
.le(&amount)
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
let minimum_amount = base_evm_amount
|
||||
.saturating_mul(pending_requests_count)
|
||||
.saturating_add(T::Currency::minimum_balance());
|
||||
|
||||
ensure!(amount >= minimum_amount, Error::<T>::BridgeQueueMinimumNotMet);
|
||||
ensure!(is_amount_sufficient, Error::<T>::BridgeQueueMinimumNotMet);
|
||||
|
||||
let actual_amount = T::Currency::burn_from(
|
||||
&who,
|
||||
|
||||
@ -1132,9 +1132,14 @@ fn test_all_validators_can_execute_dkg() {
|
||||
ExodusSignedGovernance::<Runtime>::iter().count()
|
||||
});
|
||||
|
||||
let pending_exodus_requests = ext.execute_with(|| {
|
||||
ExodusRequests::<Runtime>::count()
|
||||
});
|
||||
|
||||
assert_eq!(rotations_count, 3);
|
||||
assert_eq!(bridges_count, 2);
|
||||
assert_eq!(governances_count, 15);
|
||||
assert_eq!(pending_exodus_requests, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1476,7 +1481,7 @@ fn register_evm_bridge_out_dynamic_threshold_works() {
|
||||
|
||||
QualificationDkgState::<Runtime>::insert(&network_curve, dkg_state);
|
||||
|
||||
let amount_1 = existential_deposit;
|
||||
let amount_1 = base_evm_amount.saturating_add(existential_deposit);
|
||||
assert_ok!(Exodus::register_evm_bridge_out_exodus(
|
||||
RuntimeOrigin::signed(user.clone()),
|
||||
network_id,
|
||||
@ -1508,7 +1513,10 @@ fn register_evm_bridge_out_dynamic_threshold_works() {
|
||||
Error::<Runtime>::BridgeQueueMinimumNotMet
|
||||
);
|
||||
|
||||
let amount_2 = existential_deposit.saturating_add(base_evm_amount);
|
||||
let amount_2 = existential_deposit
|
||||
.saturating_mul(2)
|
||||
.saturating_add(base_evm_amount);
|
||||
|
||||
assert_ok!(Exodus::register_evm_bridge_out_exodus(
|
||||
RuntimeOrigin::signed(user.clone()),
|
||||
network_id,
|
||||
@ -1530,7 +1538,10 @@ fn register_evm_bridge_out_dynamic_threshold_works() {
|
||||
|
||||
assert_eq!(ExodusRequests::<Runtime>::count(), 2);
|
||||
|
||||
let amount_3 = amount_2.saturating_add(base_evm_amount);
|
||||
let amount_3 = existential_deposit
|
||||
.saturating_mul(4)
|
||||
.saturating_add(base_evm_amount);
|
||||
|
||||
assert_ok!(Exodus::register_evm_bridge_out_exodus(
|
||||
RuntimeOrigin::signed(user.clone()),
|
||||
network_id,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user