Compare commits
No commits in common. "pallet-networks" and "main" have entirely different histories.
pallet-net
...
main
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -3648,7 +3648,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ghost-networks"
|
name = "ghost-networks"
|
||||||
version = "0.1.4"
|
version = "0.7.197"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
@ -3656,8 +3656,6 @@ dependencies = [
|
|||||||
"ghost-core-primitives",
|
"ghost-core-primitives",
|
||||||
"ghost-traits",
|
"ghost-traits",
|
||||||
"pallet-balances",
|
"pallet-balances",
|
||||||
"pallet-staking",
|
|
||||||
"pallet-staking-reward-curve",
|
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
"scale-info",
|
"scale-info",
|
||||||
"sp-io 30.0.0",
|
"sp-io 30.0.0",
|
||||||
@ -3868,7 +3866,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ghost-traits"
|
name = "ghost-traits"
|
||||||
version = "0.3.20"
|
version = "0.3.19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-support",
|
"frame-support",
|
||||||
"sp-runtime 31.0.1",
|
"sp-runtime 31.0.1",
|
||||||
|
0
LICENSE.md
Normal file → Executable file
0
LICENSE.md
Normal file → Executable file
0
cli/Cargo.toml
Normal file → Executable file
0
cli/Cargo.toml
Normal file → Executable file
0
cli/build.rs
Normal file → Executable file
0
cli/build.rs
Normal file → Executable file
0
cli/src/cli.rs
Normal file → Executable file
0
cli/src/cli.rs
Normal file → Executable file
0
cli/src/command.rs
Normal file → Executable file
0
cli/src/command.rs
Normal file → Executable file
0
cli/src/error.rs
Normal file → Executable file
0
cli/src/error.rs
Normal file → Executable file
0
cli/src/lib.rs
Normal file → Executable file
0
cli/src/lib.rs
Normal file → Executable file
0
core-primitives/Cargo.toml
Normal file → Executable file
0
core-primitives/Cargo.toml
Normal file → Executable file
0
core-primitives/src/lib.rs
Normal file → Executable file
0
core-primitives/src/lib.rs
Normal file → Executable file
0
file_header.txt
Normal file → Executable file
0
file_header.txt
Normal file → Executable file
42
pallets/networks/Cargo.toml
Normal file → Executable file
42
pallets/networks/Cargo.toml
Normal file → Executable file
@ -1,8 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ghost-networks"
|
name = "ghost-networks"
|
||||||
version = "0.1.5"
|
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
version.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
homepage.workspace = true
|
homepage.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
@ -14,42 +14,36 @@ codec = { workspace = true, features = ["max-encoded-len"] }
|
|||||||
frame-benchmarking = { workspace = true, optional = true }
|
frame-benchmarking = { workspace = true, optional = true }
|
||||||
frame-support = { workspace = true }
|
frame-support = { workspace = true }
|
||||||
frame-system = { workspace = true }
|
frame-system = { workspace = true }
|
||||||
pallet-staking = { workspace = true }
|
|
||||||
sp-runtime = { workspace = true }
|
sp-runtime = { workspace = true }
|
||||||
sp-std = { workspace = true }
|
sp-std = { workspace = true }
|
||||||
ghost-traits = { workspace = true }
|
ghost-traits = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
primitives = { workspace = true }
|
primitives = { workspace = true }
|
||||||
sp-io = { workspace = true }
|
|
||||||
pallet-balances = { workspace = true }
|
pallet-balances = { workspace = true }
|
||||||
pallet-staking-reward-curve = { workspace = true }
|
sp-io = { workspace = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
"scale-info/std",
|
"scale-info/std",
|
||||||
"codec/std",
|
"codec/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"frame-system/std",
|
"frame-system/std",
|
||||||
"frame-benchmarking?/std",
|
"frame-benchmarking?/std",
|
||||||
"sp-runtime/std",
|
"sp-runtime/std",
|
||||||
"sp-std/std",
|
"sp-std/std",
|
||||||
"sp-io/std",
|
"sp-io/std",
|
||||||
"ghost-traits/std",
|
"ghost-traits/std",
|
||||||
"pallet-staking/std",
|
"pallet-balances/std",
|
||||||
"pallet-balances/std",
|
|
||||||
]
|
]
|
||||||
runtime-benchmarks = [
|
runtime-benchmarks = [
|
||||||
"frame-benchmarking/runtime-benchmarks",
|
"frame-benchmarking/runtime-benchmarks",
|
||||||
"frame-support/runtime-benchmarks",
|
"frame-support/runtime-benchmarks",
|
||||||
"frame-system/runtime-benchmarks",
|
"frame-system/runtime-benchmarks",
|
||||||
"sp-runtime/runtime-benchmarks",
|
"sp-runtime/runtime-benchmarks",
|
||||||
"pallet-staking/runtime-benchmarks",
|
|
||||||
]
|
]
|
||||||
try-runtime = [
|
try-runtime = [
|
||||||
"frame-support/try-runtime",
|
"frame-support/try-runtime",
|
||||||
"frame-system/try-runtime",
|
"frame-system/try-runtime",
|
||||||
"pallet-staking/try-runtime",
|
|
||||||
"pallet-balances/try-runtime",
|
|
||||||
]
|
]
|
||||||
|
0
pallets/networks/src/benchmarking.rs
Normal file → Executable file
0
pallets/networks/src/benchmarking.rs
Normal file → Executable file
181
pallets/networks/src/lib.rs
Normal file → Executable file
181
pallets/networks/src/lib.rs
Normal file → Executable file
@ -4,17 +4,15 @@
|
|||||||
|
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
pallet_prelude::*,
|
pallet_prelude::*,
|
||||||
storage::PrefixIterator, traits::{tokens::fungible::Inspect, EnsureOrigin},
|
storage::PrefixIterator, traits::EnsureOrigin,
|
||||||
};
|
};
|
||||||
use frame_system::pallet_prelude::*;
|
use frame_system::pallet_prelude::*;
|
||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
|
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{CheckedSub, CheckedAdd, AtLeast32BitUnsigned, Member},
|
traits::{AtLeast32BitUnsigned, Member},
|
||||||
curve::PiecewiseLinear,
|
|
||||||
DispatchResult,
|
DispatchResult,
|
||||||
};
|
};
|
||||||
use sp_std::{prelude::*, convert::TryInto};
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
pub use ghost_traits::networks::{
|
pub use ghost_traits::networks::{
|
||||||
NetworkDataBasicHandler, NetworkDataInspectHandler,
|
NetworkDataBasicHandler, NetworkDataInspectHandler,
|
||||||
@ -33,10 +31,6 @@ mod mock;
|
|||||||
#[cfg(all(feature = "std", test))]
|
#[cfg(all(feature = "std", test))]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
pub type BalanceOf<T> = <<T as Config>::Currency as Inspect<
|
|
||||||
<T as frame_system::Config>::AccountId,
|
|
||||||
>>::Balance;
|
|
||||||
|
|
||||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
||||||
pub enum NetworkType {
|
pub enum NetworkType {
|
||||||
Evm = 0,
|
Evm = 0,
|
||||||
@ -61,50 +55,6 @@ pub struct NetworkData {
|
|||||||
pub outgoing_fee: u32,
|
pub outgoing_fee: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
|
||||||
pub struct BridgeAdjustment<Balance> {
|
|
||||||
pub bridged_out: Balance,
|
|
||||||
pub bridged_in: Balance,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct BridgedInflationCurve<RewardCurve, T>(core::marker::PhantomData<(RewardCurve, T)>);
|
|
||||||
impl<Balance, RewardCurve, T> pallet_staking::EraPayout<Balance> for BridgedInflationCurve<RewardCurve, T>
|
|
||||||
where
|
|
||||||
Balance: Default + AtLeast32BitUnsigned + Clone + Copy + From<u128>,
|
|
||||||
RewardCurve: Get<&'static PiecewiseLinear<'static>>,
|
|
||||||
T: Config,
|
|
||||||
{
|
|
||||||
fn era_payout(
|
|
||||||
total_staked: Balance,
|
|
||||||
total_issuance: Balance,
|
|
||||||
_era_duration_in_millis: u64,
|
|
||||||
) -> (Balance, Balance) {
|
|
||||||
let piecewise_linear = RewardCurve::get();
|
|
||||||
let bridge_adjustment = BridgedImbalance::<T>::get();
|
|
||||||
let accumulated_commission = AccumulatedCommission::<T>::get();
|
|
||||||
|
|
||||||
let bridged_out: u128 = bridge_adjustment.bridged_out.try_into().unwrap_or_default();
|
|
||||||
let bridged_in: u128 = bridge_adjustment.bridged_in.try_into().unwrap_or_default();
|
|
||||||
let accumulated_commission: u128 = accumulated_commission.try_into().unwrap_or_default();
|
|
||||||
|
|
||||||
let accumulated_balance = Balance::from(accumulated_commission);
|
|
||||||
let adjusted_issuance = match bridged_out > bridged_in {
|
|
||||||
true => total_issuance.saturating_add(Balance::from(bridged_out - bridged_in)),
|
|
||||||
false => total_issuance.saturating_sub(Balance::from(bridged_in - bridged_out)),
|
|
||||||
};
|
|
||||||
|
|
||||||
NullifyNeeded::<T>::set(true);
|
|
||||||
|
|
||||||
match piecewise_linear
|
|
||||||
.calculate_for_fraction_times_denominator(total_staked, adjusted_issuance)
|
|
||||||
.checked_mul(&accumulated_balance)
|
|
||||||
.and_then(|product| product.checked_div(&adjusted_issuance)) {
|
|
||||||
Some(payout) => (payout, accumulated_balance.saturating_sub(payout)),
|
|
||||||
None => (Balance::default(), Balance::default()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod module {
|
pub mod module {
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -113,9 +63,6 @@ pub mod module {
|
|||||||
pub trait Config: frame_system::Config {
|
pub trait Config: frame_system::Config {
|
||||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||||
|
|
||||||
/// The type used for the internal balance storage.
|
|
||||||
type Currency: Inspect<Self::AccountId>;
|
|
||||||
|
|
||||||
/// The type used as a unique network id.
|
/// The type used as a unique network id.
|
||||||
type NetworkId: Parameter
|
type NetworkId: Parameter
|
||||||
+ Member
|
+ Member
|
||||||
@ -167,35 +114,11 @@ pub mod module {
|
|||||||
NetworkRemoved { chain_id: T::NetworkId },
|
NetworkRemoved { chain_id: T::NetworkId },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::storage]
|
|
||||||
#[pallet::getter(fn nullify_needed)]
|
|
||||||
pub type NullifyNeeded<T: Config> = StorageValue<_, bool, ValueQuery>;
|
|
||||||
|
|
||||||
#[pallet::storage]
|
|
||||||
#[pallet::getter(fn bridged_imbalance)]
|
|
||||||
pub type BridgedImbalance<T: Config> =
|
|
||||||
StorageValue<_, BridgeAdjustment<BalanceOf<T>>, ValueQuery>;
|
|
||||||
|
|
||||||
#[pallet::storage]
|
|
||||||
#[pallet::getter(fn accumulated_commission)]
|
|
||||||
pub type AccumulatedCommission<T: Config> =
|
|
||||||
StorageValue<_, BalanceOf<T>, ValueQuery>;
|
|
||||||
|
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn networks)]
|
#[pallet::getter(fn networks)]
|
||||||
pub type Networks<T: Config> =
|
pub type Networks<T: Config> =
|
||||||
StorageMap<_, Twox64Concat, T::NetworkId, NetworkData, OptionQuery>;
|
StorageMap<_, Twox64Concat, T::NetworkId, NetworkData, OptionQuery>;
|
||||||
|
|
||||||
#[pallet::storage]
|
|
||||||
#[pallet::getter(fn gatekeeper_amount)]
|
|
||||||
pub type GatekeeperAmount<T: Config> = StorageMap<
|
|
||||||
_,
|
|
||||||
Twox64Concat,
|
|
||||||
T::NetworkId,
|
|
||||||
BalanceOf<T>,
|
|
||||||
ValueQuery,
|
|
||||||
>;
|
|
||||||
|
|
||||||
#[pallet::genesis_config]
|
#[pallet::genesis_config]
|
||||||
pub struct GenesisConfig<T: Config> {
|
pub struct GenesisConfig<T: Config> {
|
||||||
pub networks: Vec<(T::NetworkId, Vec<u8>)>,
|
pub networks: Vec<(T::NetworkId, Vec<u8>)>,
|
||||||
@ -227,18 +150,7 @@ pub mod module {
|
|||||||
pub struct Pallet<T>(PhantomData<T>);
|
pub struct Pallet<T>(PhantomData<T>);
|
||||||
|
|
||||||
#[pallet::hooks]
|
#[pallet::hooks]
|
||||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
|
||||||
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
|
|
||||||
T::DbWeight::get().reads_writes(1, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_finalize(_: BlockNumberFor<T>) {
|
|
||||||
if Self::nullify_needed() {
|
|
||||||
Self::nullify_commission();
|
|
||||||
NullifyNeeded::<T>::put(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[pallet::call]
|
#[pallet::call]
|
||||||
impl<T: Config> Pallet<T> {
|
impl<T: Config> Pallet<T> {
|
||||||
@ -613,13 +525,9 @@ impl<T: Config> NetworkDataInspectHandler<NetworkData> for Pallet<T> {
|
|||||||
fn iter() -> PrefixIterator<(Self::NetworkId, NetworkData)> {
|
fn iter() -> PrefixIterator<(Self::NetworkId, NetworkData)> {
|
||||||
Networks::<T>::iter()
|
Networks::<T>::iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_nullification_period() -> bool {
|
|
||||||
NullifyNeeded::<T>::get()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Config> NetworkDataMutateHandler<NetworkData, BalanceOf<T>> for Pallet<T> {
|
impl<T: Config> NetworkDataMutateHandler<NetworkData> for Pallet<T> {
|
||||||
fn register(chain_id: Self::NetworkId, network: NetworkData) -> DispatchResult {
|
fn register(chain_id: Self::NetworkId, network: NetworkData) -> DispatchResult {
|
||||||
Self::do_register_network(chain_id, network)
|
Self::do_register_network(chain_id, network)
|
||||||
}
|
}
|
||||||
@ -627,83 +535,4 @@ impl<T: Config> NetworkDataMutateHandler<NetworkData, BalanceOf<T>> for Pallet<T
|
|||||||
fn remove(chain_id: Self::NetworkId) -> DispatchResult {
|
fn remove(chain_id: Self::NetworkId) -> DispatchResult {
|
||||||
Self::do_remove_network(chain_id)
|
Self::do_remove_network(chain_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn increase_gatekeeper_amount(
|
|
||||||
network_id: &T::NetworkId,
|
|
||||||
amount: &BalanceOf<T>,
|
|
||||||
) -> Result<(BalanceOf<T>, BalanceOf<T>), ()> {
|
|
||||||
let new_bridged_in_amount = BridgedImbalance::<T>::mutate(|bridged_imbalance| {
|
|
||||||
match bridged_imbalance.bridged_in.checked_add(amount) {
|
|
||||||
Some(value) => {
|
|
||||||
(*bridged_imbalance).bridged_in = value;
|
|
||||||
Ok(value)
|
|
||||||
},
|
|
||||||
None => Err(())
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let new_gatekeeper_amount = GatekeeperAmount::<T>::mutate(network_id, |gatekeeper_amount| {
|
|
||||||
match gatekeeper_amount.checked_add(amount) {
|
|
||||||
Some(value) => {
|
|
||||||
*gatekeeper_amount = value;
|
|
||||||
Ok(value)
|
|
||||||
},
|
|
||||||
None => Err(())
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
|
|
||||||
Ok((new_gatekeeper_amount, new_bridged_in_amount))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn decrease_gatekeeper_amount(
|
|
||||||
network_id: &T::NetworkId,
|
|
||||||
amount: &BalanceOf<T>,
|
|
||||||
) -> Result<(BalanceOf<T>, BalanceOf<T>), ()> {
|
|
||||||
let new_gatekeeper_amount = GatekeeperAmount::<T>::mutate(network_id, |gatekeeper_amount| {
|
|
||||||
match gatekeeper_amount.checked_sub(amount) {
|
|
||||||
Some(value) => {
|
|
||||||
*gatekeeper_amount = value;
|
|
||||||
Ok(value)
|
|
||||||
},
|
|
||||||
None => Err(())
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let new_bridged_out_amount = BridgedImbalance::<T>::mutate(|bridged_imbalance| {
|
|
||||||
match bridged_imbalance.bridged_out.checked_add(amount) {
|
|
||||||
Some(value) => {
|
|
||||||
(*bridged_imbalance).bridged_out = value;
|
|
||||||
Ok(value)
|
|
||||||
},
|
|
||||||
None => Err(())
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
|
|
||||||
Ok((new_gatekeeper_amount, new_bridged_out_amount))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn accumulate_commission(commission: &BalanceOf<T>) -> Result<BalanceOf<T>, ()> {
|
|
||||||
AccumulatedCommission::<T>::mutate(|accumulated| {
|
|
||||||
match accumulated.checked_add(commission) {
|
|
||||||
Some(value) => {
|
|
||||||
*accumulated = value;
|
|
||||||
Ok(value)
|
|
||||||
},
|
|
||||||
None => Err(()),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn nullify_commission() {
|
|
||||||
AccumulatedCommission::<T>::set(Default::default());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn trigger_nullification() {
|
|
||||||
if NullifyNeeded::<T>::get() {
|
|
||||||
Self::nullify_commission();
|
|
||||||
NullifyNeeded::<T>::put(false);
|
|
||||||
} else {
|
|
||||||
NullifyNeeded::<T>::put(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
32
pallets/networks/src/mock.rs
Normal file → Executable file
32
pallets/networks/src/mock.rs
Normal file → Executable file
@ -1,25 +1,19 @@
|
|||||||
use crate::{self as ghost_networks};
|
use crate as ghost_networks;
|
||||||
use frame_system::EnsureSignedBy;
|
use frame_system::EnsureSignedBy;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
construct_runtime, ord_parameter_types, parameter_types,
|
construct_runtime, ord_parameter_types, parameter_types, traits::{ConstU128, ConstU32, Everything}
|
||||||
traits::{ConstU128, ConstU32, Everything},
|
|
||||||
};
|
};
|
||||||
pub use primitives::{
|
pub use primitives::{
|
||||||
AccountId, Balance, Nonce, BlockNumber, Hash,
|
AccountId, Balance, Nonce, BlockNumber, Hash,
|
||||||
ReserveIdentifier, FreezeIdentifier,
|
ReserveIdentifier, FreezeIdentifier,
|
||||||
};
|
};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
curve::PiecewiseLinear,
|
traits::{BlakeTwo256, AccountIdLookup},
|
||||||
traits::{AccountIdLookup, BlakeTwo256},
|
BuildStorage,
|
||||||
BuildStorage
|
|
||||||
};
|
};
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: BlockNumber = 250;
|
pub const BlockHashCount: BlockNumber = 250;
|
||||||
pub static SlashDeferDuration: u32 = 0;
|
|
||||||
pub static Period: BlockNumber = 5;
|
|
||||||
pub static Offset: BlockNumber = 0;
|
|
||||||
pub static MaxControllersInDeprecationBatch: u32 = 5_000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_system::Config for Test {
|
impl frame_system::Config for Test {
|
||||||
@ -70,21 +64,6 @@ impl pallet_balances::Config for Test {
|
|||||||
type MaxFreezes = ConstU32<50>;
|
type MaxFreezes = ConstU32<50>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pallet_staking_reward_curve::build! {
|
|
||||||
const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
|
|
||||||
min_inflation: 0_006_900,
|
|
||||||
max_inflation: 1_000_000,
|
|
||||||
ideal_stake: 0_690_000,
|
|
||||||
falloff: 0_050_000,
|
|
||||||
max_piece_count: 100,
|
|
||||||
test_precision: 0_005_000,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
parameter_types! {
|
|
||||||
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ord_parameter_types! {
|
ord_parameter_types! {
|
||||||
pub const RegistererAccount: AccountId = AccountId::from([1u8; 32]);
|
pub const RegistererAccount: AccountId = AccountId::from([1u8; 32]);
|
||||||
pub const UpdaterAccount: AccountId = AccountId::from([2u8; 32]);
|
pub const UpdaterAccount: AccountId = AccountId::from([2u8; 32]);
|
||||||
@ -94,7 +73,6 @@ ord_parameter_types! {
|
|||||||
|
|
||||||
impl ghost_networks::Config for Test {
|
impl ghost_networks::Config for Test {
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type Currency = Balances;
|
|
||||||
type NetworkId = u32;
|
type NetworkId = u32;
|
||||||
type RegisterOrigin = EnsureSignedBy::<RegistererAccount, AccountId>;
|
type RegisterOrigin = EnsureSignedBy::<RegistererAccount, AccountId>;
|
||||||
type UpdateOrigin = EnsureSignedBy::<UpdaterAccount, AccountId>;
|
type UpdateOrigin = EnsureSignedBy::<UpdaterAccount, AccountId>;
|
||||||
@ -102,7 +80,7 @@ impl ghost_networks::Config for Test {
|
|||||||
type WeightInfo = crate::weights::SubstrateWeight<Test>;
|
type WeightInfo = crate::weights::SubstrateWeight<Test>;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Block = frame_system::mocking::MockBlock<Test>;
|
type Block = frame_system::mocking::MockBlockU32<Test>;
|
||||||
|
|
||||||
construct_runtime!(
|
construct_runtime!(
|
||||||
pub enum Test {
|
pub enum Test {
|
||||||
|
318
pallets/networks/src/tests.rs
Normal file → Executable file
318
pallets/networks/src/tests.rs
Normal file → Executable file
@ -1,16 +1,16 @@
|
|||||||
use mock::{
|
use mock::{
|
||||||
ExtBuilder, System, RegistererAccount, UpdaterAccount, RemoverAccount,
|
ExtBuilder, System, RegistererAccount, UpdaterAccount, RemoverAccount,
|
||||||
RandomAccount, GhostNetworks, Test, RuntimeEvent, RuntimeOrigin, RewardCurve,
|
RandomAccount, GhostNetworks, Test, RuntimeEvent, RuntimeOrigin,
|
||||||
};
|
};
|
||||||
use frame_support::{assert_err, assert_ok};
|
use frame_support::{assert_err, assert_ok};
|
||||||
use sp_runtime::DispatchError;
|
use sp_runtime::DispatchError;
|
||||||
use pallet_staking::EraPayout;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
fn prepare_network_data() -> (u32, NetworkData) {
|
fn prepare_network_data() -> (u32, NetworkData) {
|
||||||
(1u32, NetworkData {
|
(1u32, NetworkData {
|
||||||
chain_name: "Ethereum".into(),
|
chain_name: "Ethereum".into(),
|
||||||
default_endpoint: "https:://some-endpoint.my-server.com/v1/my-super-secret-key".into(),
|
default_endpoint:
|
||||||
|
"https:://some-endpoint.my-server.com/v1/my-super-secret-key".into(),
|
||||||
finality_delay: Some(69),
|
finality_delay: Some(69),
|
||||||
release_delay: Some(69),
|
release_delay: Some(69),
|
||||||
network_type: NetworkType::Evm,
|
network_type: NetworkType::Evm,
|
||||||
@ -635,315 +635,3 @@ fn could_not_remove_non_existent_network() {
|
|||||||
assert_eq!(Networks::<Test>::get(chain_id), None);
|
assert_eq!(Networks::<Test>::get(chain_id), None);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn bridge_storage_is_empty_by_default() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
assert_eq!(AccumulatedCommission::<Test>::get(), 0);
|
|
||||||
assert_eq!(BridgedImbalance::<Test>::get(),
|
|
||||||
BridgeAdjustment::default());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn gatekeeper_amount_changes_correctly() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
let chain_id: u32 = 1;
|
|
||||||
let amount_in: u128 = 420;
|
|
||||||
let amount_out: u128 = 69;
|
|
||||||
let result = amount_in - 3 * amount_out;
|
|
||||||
|
|
||||||
assert_eq!(GatekeeperAmount::<Test>::get(&chain_id), 0);
|
|
||||||
assert_eq!(BridgedImbalance::<Test>::get(),
|
|
||||||
BridgeAdjustment::default());
|
|
||||||
|
|
||||||
assert_ok!(GhostNetworks::increase_gatekeeper_amount(&chain_id, &amount_in));
|
|
||||||
assert_ok!(GhostNetworks::decrease_gatekeeper_amount(&chain_id, &amount_out));
|
|
||||||
assert_ok!(GhostNetworks::decrease_gatekeeper_amount(&chain_id, &amount_out));
|
|
||||||
assert_ok!(GhostNetworks::decrease_gatekeeper_amount(&chain_id, &amount_out));
|
|
||||||
|
|
||||||
assert_eq!(GatekeeperAmount::<Test>::get(&chain_id), result);
|
|
||||||
assert_eq!(BridgedImbalance::<Test>::get(), BridgeAdjustment {
|
|
||||||
bridged_out: 3 * amount_out,
|
|
||||||
bridged_in: amount_in });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn commission_accumulation_is_correct() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
let commission_first: u128 = 420;
|
|
||||||
let commission_second: u128 = 69;
|
|
||||||
let result = commission_first + commission_second;
|
|
||||||
|
|
||||||
assert_eq!(AccumulatedCommission::<Test>::get(), 0);
|
|
||||||
assert_ok!(GhostNetworks::accumulate_commission(&commission_first));
|
|
||||||
assert_ok!(GhostNetworks::accumulate_commission(&commission_second));
|
|
||||||
assert_eq!(AccumulatedCommission::<Test>::get(), result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn commission_overflow_and_underflow_emits_error() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
let commission: u128 = u128::MAX - 69;
|
|
||||||
assert_eq!(AccumulatedCommission::<Test>::get(), 0);
|
|
||||||
assert_ok!(GhostNetworks::accumulate_commission(&commission));
|
|
||||||
assert_err!(GhostNetworks::accumulate_commission(&commission), ());
|
|
||||||
assert_eq!(AccumulatedCommission::<Test>::get(), commission);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn gatekeeper_amount_overflow_and_underflow_emits_error() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
let chain_id: u32 = 1;
|
|
||||||
let commission: u128 = u128::MAX - 69;
|
|
||||||
assert_eq!(GatekeeperAmount::<Test>::get(&chain_id), 0);
|
|
||||||
assert_ok!(GhostNetworks::increase_gatekeeper_amount(
|
|
||||||
&chain_id,
|
|
||||||
&commission,
|
|
||||||
), (commission, commission));
|
|
||||||
assert_err!(GhostNetworks::increase_gatekeeper_amount(
|
|
||||||
&chain_id,
|
|
||||||
&commission,
|
|
||||||
), ());
|
|
||||||
assert_eq!(GatekeeperAmount::<Test>::get(&chain_id), commission);
|
|
||||||
assert_ok!(GhostNetworks::decrease_gatekeeper_amount(
|
|
||||||
&chain_id,
|
|
||||||
&commission,
|
|
||||||
), (0, commission));
|
|
||||||
assert_err!(GhostNetworks::decrease_gatekeeper_amount(
|
|
||||||
&chain_id,
|
|
||||||
&commission,
|
|
||||||
), ());
|
|
||||||
assert_eq!(GatekeeperAmount::<Test>::get(&chain_id), 0);
|
|
||||||
assert_eq!(BridgedImbalance::<Test>::get(), BridgeAdjustment {
|
|
||||||
bridged_out: commission,
|
|
||||||
bridged_in: commission,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn bridged_amount_overflow_and_underflow_emits_error() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
let chain_id_first: u32 = 1;
|
|
||||||
let chain_id_second: u32 = 2;
|
|
||||||
let commission: u128 = u128::MAX - 69;
|
|
||||||
assert_eq!(BridgedImbalance::<Test>::get(), BridgeAdjustment {
|
|
||||||
bridged_out: 0,
|
|
||||||
bridged_in: 0,
|
|
||||||
});
|
|
||||||
assert_ok!(GhostNetworks::increase_gatekeeper_amount(
|
|
||||||
&chain_id_first,
|
|
||||||
&commission,
|
|
||||||
), (commission, commission));
|
|
||||||
assert_err!(GhostNetworks::increase_gatekeeper_amount(
|
|
||||||
&chain_id_second,
|
|
||||||
&commission,
|
|
||||||
), ());
|
|
||||||
assert_err!(GhostNetworks::increase_gatekeeper_amount(
|
|
||||||
&chain_id_first,
|
|
||||||
&u128::MAX,
|
|
||||||
), ());
|
|
||||||
assert_err!(GhostNetworks::increase_gatekeeper_amount(
|
|
||||||
&chain_id_first,
|
|
||||||
&commission,
|
|
||||||
), ());
|
|
||||||
assert_eq!(GatekeeperAmount::<Test>::get(&chain_id_first), commission);
|
|
||||||
assert_eq!(GatekeeperAmount::<Test>::get(&chain_id_second), 0);
|
|
||||||
assert_err!(GhostNetworks::decrease_gatekeeper_amount(
|
|
||||||
&chain_id_second,
|
|
||||||
&commission,
|
|
||||||
), ());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn accumulated_commission_could_be_nullified() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
let commission_first: u128 = 420;
|
|
||||||
let commission_second: u128 = 69;
|
|
||||||
|
|
||||||
assert_eq!(AccumulatedCommission::<Test>::get(), 0);
|
|
||||||
assert_ok!(GhostNetworks::accumulate_commission(
|
|
||||||
&commission_first
|
|
||||||
), commission_first);
|
|
||||||
assert_ok!(GhostNetworks::accumulate_commission(
|
|
||||||
&commission_second,
|
|
||||||
), commission_first + commission_second);
|
|
||||||
assert_eq!(AccumulatedCommission::<Test>::get(),
|
|
||||||
commission_first + commission_second);
|
|
||||||
GhostNetworks::nullify_commission();
|
|
||||||
assert_eq!(AccumulatedCommission::<Test>::get(), 0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn bridged_inlation_reward_works() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
let chain_id: u32 = 1;
|
|
||||||
let amount: u128 = 1337 * 1_000_000_000;
|
|
||||||
let commission: u128 = amount / 100; // 1% commission
|
|
||||||
let total_staked_ideal: u128 = 69;
|
|
||||||
let total_staked_not_ideal: u128 = 68;
|
|
||||||
let total_issuance: u128 = 100;
|
|
||||||
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000,
|
|
||||||
total_issuance * 1_000,
|
|
||||||
0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000,
|
|
||||||
0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000_000_000_000_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000_000_000_000_000,
|
|
||||||
0), (0, 0));
|
|
||||||
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_not_ideal * 1_000,
|
|
||||||
total_issuance * 1_000,
|
|
||||||
0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_not_ideal * 1_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000,
|
|
||||||
0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_not_ideal * 1_000_000_000_000_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000_000_000_000_000,
|
|
||||||
0), (0, 0));
|
|
||||||
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
1, total_issuance * 1_000, 0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
1, total_issuance * 1_000_000_000_000, 0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
1, total_issuance * 1_000_000_000_000_000_000_000_000, 0), (0, 0));
|
|
||||||
|
|
||||||
assert_ok!(GhostNetworks::accumulate_commission(&commission));
|
|
||||||
assert_ok!(GhostNetworks::increase_gatekeeper_amount(&chain_id, &amount));
|
|
||||||
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000,
|
|
||||||
total_issuance * 1_000 + amount,
|
|
||||||
0), (commission, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000 + amount,
|
|
||||||
0), (commission, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000_000_000_000_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000_000_000_000_000 + amount,
|
|
||||||
0), (commission, 0));
|
|
||||||
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_not_ideal * 1_000,
|
|
||||||
total_issuance * 1_000 + amount,
|
|
||||||
0), (13177472000, 192528000));
|
|
||||||
assert_eq!(13177472000 + 192528000, commission);
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_not_ideal * 1_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000 + amount,
|
|
||||||
0), (13177568884, 192431116));
|
|
||||||
assert_eq!(13177568884 + 192431116, commission);
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_not_ideal * 1_000_000_000_000_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000_000_000_000_000 + amount,
|
|
||||||
0), (13177568884, 192431116));
|
|
||||||
assert_eq!(13177568884 + 192431116, commission);
|
|
||||||
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
1, total_issuance * 1_000 + amount, 0),
|
|
||||||
(92386700, 13277613300));
|
|
||||||
assert_eq!(92386700 + 13277613300, commission);
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
1, total_issuance * 1_000_000_000_000 + amount, 0),
|
|
||||||
(92253000, 13277747000));
|
|
||||||
assert_eq!(92253000 + 13277747000, commission);
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
1, total_issuance * 1_000_000_000_000_000_000_000_000 + amount, 0),
|
|
||||||
(92253000, 13277747000));
|
|
||||||
assert_eq!(92253000 + 13277747000, commission);
|
|
||||||
|
|
||||||
GhostNetworks::nullify_commission();
|
|
||||||
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000,
|
|
||||||
total_issuance * 1_000 + amount,
|
|
||||||
0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000 + amount,
|
|
||||||
0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000_000_000_000_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000_000_000_000_000 + amount,
|
|
||||||
0), (0, 0));
|
|
||||||
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_not_ideal * 1_000,
|
|
||||||
total_issuance * 1_000 + amount,
|
|
||||||
0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_not_ideal * 1_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000 + amount,
|
|
||||||
0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_not_ideal * 1_000_000_000_000_000_000_000_000,
|
|
||||||
total_issuance * 1_000_000_000_000_000_000_000_000 + amount,
|
|
||||||
0), (0, 0));
|
|
||||||
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
1, total_issuance * 1_000 + amount, 0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
1, total_issuance * 1_000_000_000_000 + amount, 0), (0, 0));
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
1, total_issuance * 1_000_000_000_000_000_000_000_000 + amount, 0), (0, 0));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn bridged_inflation_era_payout_triggers_need_of_nullification() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
let chain_id: u32 = 1;
|
|
||||||
let amount: u128 = 1337 * 1_000_000_000;
|
|
||||||
let commission: u128 = amount / 100; // 1% commission
|
|
||||||
let total_staked_ideal: u128 = 69;
|
|
||||||
let total_issuance: u128 = 100;
|
|
||||||
|
|
||||||
assert_ok!(GhostNetworks::accumulate_commission(&commission));
|
|
||||||
assert_ok!(GhostNetworks::increase_gatekeeper_amount(&chain_id, &amount));
|
|
||||||
assert_eq!(NullifyNeeded::<Test>::get(), false);
|
|
||||||
assert_eq!(BridgedInflationCurve::<RewardCurve, Test>::era_payout(
|
|
||||||
total_staked_ideal * 1_000,
|
|
||||||
total_issuance * 1_000 + amount,
|
|
||||||
0), (commission, 0));
|
|
||||||
assert_eq!(NullifyNeeded::<Test>::get(), true);
|
|
||||||
GhostNetworks::on_finalize(69);
|
|
||||||
assert_eq!(NullifyNeeded::<Test>::get(), false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn trigger_nullification_works_as_expected() {
|
|
||||||
ExtBuilder::build()
|
|
||||||
.execute_with(|| {
|
|
||||||
assert_eq!(NullifyNeeded::<Test>::get(), false);
|
|
||||||
GhostNetworks::trigger_nullification();
|
|
||||||
assert_eq!(NullifyNeeded::<Test>::get(), true);
|
|
||||||
GhostNetworks::trigger_nullification();
|
|
||||||
assert_eq!(NullifyNeeded::<Test>::get(), false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
0
pallets/networks/src/weights.rs
Normal file → Executable file
0
pallets/networks/src/weights.rs
Normal file → Executable file
2
pallets/traits/Cargo.toml
Normal file → Executable file
2
pallets/traits/Cargo.toml
Normal file → Executable file
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ghost-traits"
|
name = "ghost-traits"
|
||||||
version = "0.3.21"
|
version = "0.3.19"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
0
pallets/traits/src/lib.rs
Normal file → Executable file
0
pallets/traits/src/lib.rs
Normal file → Executable file
15
pallets/traits/src/networks.rs
Normal file → Executable file
15
pallets/traits/src/networks.rs
Normal file → Executable file
@ -21,22 +21,9 @@ pub trait NetworkDataBasicHandler {
|
|||||||
pub trait NetworkDataInspectHandler<Network>: NetworkDataBasicHandler {
|
pub trait NetworkDataInspectHandler<Network>: NetworkDataBasicHandler {
|
||||||
fn get(n: &Self::NetworkId) -> Option<Network>;
|
fn get(n: &Self::NetworkId) -> Option<Network>;
|
||||||
fn iter() -> PrefixIterator<(Self::NetworkId, Network)>;
|
fn iter() -> PrefixIterator<(Self::NetworkId, Network)>;
|
||||||
fn is_nullification_period() -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait NetworkDataMutateHandler<Network, Balance>: NetworkDataInspectHandler<Network> {
|
pub trait NetworkDataMutateHandler<Network>: NetworkDataInspectHandler<Network> {
|
||||||
fn register(chain_id: Self::NetworkId, network: Network) -> DispatchResult;
|
fn register(chain_id: Self::NetworkId, network: Network) -> DispatchResult;
|
||||||
fn remove(chain_id: Self::NetworkId) -> DispatchResult;
|
fn remove(chain_id: Self::NetworkId) -> DispatchResult;
|
||||||
|
|
||||||
fn increase_gatekeeper_amount(
|
|
||||||
chain_id: &Self::NetworkId,
|
|
||||||
amount: &Balance,
|
|
||||||
) -> Result<(Balance, Balance), ()>;
|
|
||||||
fn decrease_gatekeeper_amount(
|
|
||||||
chain_id: &Self::NetworkId,
|
|
||||||
amount: &Balance,
|
|
||||||
) -> Result<(Balance, Balance), ()>;
|
|
||||||
fn accumulate_commission(commission: &Balance) -> Result<Balance, ()>;
|
|
||||||
fn nullify_commission();
|
|
||||||
fn trigger_nullification();
|
|
||||||
}
|
}
|
||||||
|
0
rpc/Cargo.toml
Normal file → Executable file
0
rpc/Cargo.toml
Normal file → Executable file
0
rpc/src/lib.rs
Normal file → Executable file
0
rpc/src/lib.rs
Normal file → Executable file
0
runtime/casper/Cargo.toml
Normal file → Executable file
0
runtime/casper/Cargo.toml
Normal file → Executable file
0
runtime/casper/build.rs
Normal file → Executable file
0
runtime/casper/build.rs
Normal file → Executable file
0
runtime/casper/constants/Cargo.toml
Normal file → Executable file
0
runtime/casper/constants/Cargo.toml
Normal file → Executable file
0
runtime/casper/constants/src/lib.rs
Normal file → Executable file
0
runtime/casper/constants/src/lib.rs
Normal file → Executable file
0
runtime/casper/src/cult/mod.rs
Normal file → Executable file
0
runtime/casper/src/cult/mod.rs
Normal file → Executable file
0
runtime/casper/src/cult/origins.rs
Normal file → Executable file
0
runtime/casper/src/cult/origins.rs
Normal file → Executable file
0
runtime/casper/src/cult/tracks.rs
Normal file → Executable file
0
runtime/casper/src/cult/tracks.rs
Normal file → Executable file
0
runtime/casper/src/lib.rs
Normal file → Executable file
0
runtime/casper/src/lib.rs
Normal file → Executable file
0
runtime/common/Cargo.toml
Normal file → Executable file
0
runtime/common/Cargo.toml
Normal file → Executable file
0
runtime/common/src/impls.rs
Normal file → Executable file
0
runtime/common/src/impls.rs
Normal file → Executable file
0
runtime/common/src/lib.rs
Normal file → Executable file
0
runtime/common/src/lib.rs
Normal file → Executable file
0
runtime/common/src/weights/block_weights.rs
Normal file → Executable file
0
runtime/common/src/weights/block_weights.rs
Normal file → Executable file
0
runtime/common/src/weights/extrinsic.rs
Normal file → Executable file
0
runtime/common/src/weights/extrinsic.rs
Normal file → Executable file
0
runtime/common/src/weights/mod.rs
Normal file → Executable file
0
runtime/common/src/weights/mod.rs
Normal file → Executable file
0
service/Cargo.toml
Normal file → Executable file
0
service/Cargo.toml
Normal file → Executable file
0
service/src/chain_spec.rs
Normal file → Executable file
0
service/src/chain_spec.rs
Normal file → Executable file
0
service/src/lib.rs
Normal file → Executable file
0
service/src/lib.rs
Normal file → Executable file
0
src/main.rs
Normal file → Executable file
0
src/main.rs
Normal file → Executable file
0
tests/benchmark_block.rs
Normal file → Executable file
0
tests/benchmark_block.rs
Normal file → Executable file
0
tests/benchmark_extrinsic.rs
Normal file → Executable file
0
tests/benchmark_extrinsic.rs
Normal file → Executable file
0
tests/benchmark_overhead.rs
Normal file → Executable file
0
tests/benchmark_overhead.rs
Normal file → Executable file
0
tests/benchmark_storage_works.rs
Normal file → Executable file
0
tests/benchmark_storage_works.rs
Normal file → Executable file
0
tests/common.rs
Normal file → Executable file
0
tests/common.rs
Normal file → Executable file
0
tests/invalid_order_arguments.rs
Normal file → Executable file
0
tests/invalid_order_arguments.rs
Normal file → Executable file
0
tests/purge_chain_works.rs
Normal file → Executable file
0
tests/purge_chain_works.rs
Normal file → Executable file
0
tests/running_the_node_and_interrupt.rs
Normal file → Executable file
0
tests/running_the_node_and_interrupt.rs
Normal file → Executable file
0
utils/generate-bags/Cargo.toml
Normal file → Executable file
0
utils/generate-bags/Cargo.toml
Normal file → Executable file
0
utils/generate-bags/src/main.rs
Normal file → Executable file
0
utils/generate-bags/src/main.rs
Normal file → Executable file
0
utils/ghostkey/Cargo.toml
Normal file → Executable file
0
utils/ghostkey/Cargo.toml
Normal file → Executable file
0
utils/ghostkey/src/lib.rs
Normal file → Executable file
0
utils/ghostkey/src/lib.rs
Normal file → Executable file
0
utils/ghostkey/src/main.rs
Normal file → Executable file
0
utils/ghostkey/src/main.rs
Normal file → Executable file
0
utils/staking-miner/Cargo.toml
Normal file → Executable file
0
utils/staking-miner/Cargo.toml
Normal file → Executable file
0
utils/staking-miner/playground/runtime/src/voter_bags.rs
Normal file → Executable file
0
utils/staking-miner/playground/runtime/src/voter_bags.rs
Normal file → Executable file
0
utils/staking-miner/src/main.rs
Normal file → Executable file
0
utils/staking-miner/src/main.rs
Normal file → Executable file
0
utils/staking-miner/tests/cli.rs
Normal file → Executable file
0
utils/staking-miner/tests/cli.rs
Normal file → Executable file
Loading…
Reference in New Issue
Block a user