Compare commits
23 Commits
0d796420f2
...
fa2cb811a8
Author | SHA1 | Date | |
---|---|---|---|
fa2cb811a8 | |||
561d4430b4 | |||
b64700fb42 | |||
b3f85f426c | |||
ddec108ced | |||
cd8ad50ac3 | |||
e09ce03836 | |||
9f6f4953f7 | |||
40aba0e3af | |||
596d9a6ca7 | |||
39279697f2 | |||
d3a18e298a | |||
aede9e6e2e | |||
9ce57763cb | |||
eab90d4173 | |||
bdc094663d | |||
a22b6f92d2 | |||
b51c0dffc4 | |||
eae752a7bf | |||
346d629f95 | |||
8a0cbb94b4 | |||
a2afa3fbbc | |||
885c519519 |
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -3528,7 +3528,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ghost-cli"
|
||||
version = "0.7.196"
|
||||
version = "0.7.197"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"clap 4.5.4",
|
||||
@ -3584,7 +3584,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ghost-machine-primitives"
|
||||
version = "0.7.196"
|
||||
version = "0.7.197"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"sc-sysinfo",
|
||||
@ -3593,7 +3593,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ghost-metrics"
|
||||
version = "0.7.196"
|
||||
version = "0.7.197"
|
||||
dependencies = [
|
||||
"assert_cmd",
|
||||
"bs58 0.5.1",
|
||||
@ -3648,7 +3648,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ghost-networks"
|
||||
version = "0.7.196"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"frame-benchmarking",
|
||||
"frame-support",
|
||||
@ -3656,6 +3656,8 @@ dependencies = [
|
||||
"ghost-core-primitives",
|
||||
"ghost-traits",
|
||||
"pallet-balances",
|
||||
"pallet-staking",
|
||||
"pallet-staking-reward-curve",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"sp-io 30.0.0",
|
||||
@ -3665,7 +3667,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ghost-node"
|
||||
version = "0.7.196"
|
||||
version = "0.7.197"
|
||||
dependencies = [
|
||||
"assert_cmd",
|
||||
"color-eyre",
|
||||
@ -3696,7 +3698,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ghost-rpc"
|
||||
version = "0.7.196"
|
||||
version = "0.7.197"
|
||||
dependencies = [
|
||||
"ghost-core-primitives",
|
||||
"jsonrpsee",
|
||||
@ -3748,7 +3750,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ghost-service"
|
||||
version = "0.7.196"
|
||||
version = "0.7.197"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"async-trait",
|
||||
@ -3832,7 +3834,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ghost-slow-clap"
|
||||
version = "0.3.15"
|
||||
version = "0.3.16"
|
||||
dependencies = [
|
||||
"frame-benchmarking",
|
||||
"frame-support",
|
||||
|
28
Cargo.toml
28
Cargo.toml
@ -17,7 +17,7 @@ homepage.workspace = true
|
||||
[workspace.package]
|
||||
license = "GPL-3.0-only"
|
||||
authors = ["571nky", "57r37ch", "f4750"]
|
||||
version = "0.7.196"
|
||||
version = "0.7.197"
|
||||
edition = "2021"
|
||||
homepage = "https://ghostchain.io"
|
||||
repository = "https://git.ghostchain.io/ghostchain/ghost-node"
|
||||
@ -258,24 +258,24 @@ substrate-build-script-utils = { workspace = true }
|
||||
resolver = "2"
|
||||
|
||||
members = [
|
||||
"core-primitives",
|
||||
"core-primitives",
|
||||
"cli",
|
||||
"rpc",
|
||||
"service",
|
||||
"rpc",
|
||||
"service",
|
||||
"metrics",
|
||||
"client/cli",
|
||||
"primitives/machine",
|
||||
"runtime/common",
|
||||
"runtime/casper",
|
||||
"runtime/casper/constants",
|
||||
"pallets/networks",
|
||||
"pallets/claims",
|
||||
"pallets/slow-clap",
|
||||
"utils/bags-list",
|
||||
"utils/chain-spec-builder",
|
||||
"utils/generate-bags",
|
||||
"runtime/common",
|
||||
"runtime/casper",
|
||||
"runtime/casper/constants",
|
||||
"pallets/networks",
|
||||
"pallets/claims",
|
||||
"pallets/slow-clap",
|
||||
"utils/bags-list",
|
||||
"utils/chain-spec-builder",
|
||||
"utils/generate-bags",
|
||||
"utils/ghostkey",
|
||||
"utils/staking-miner",
|
||||
"utils/staking-miner",
|
||||
]
|
||||
|
||||
[badges]
|
||||
|
0
LICENSE.md
Executable file → Normal file
0
LICENSE.md
Executable file → Normal file
9
README.md
Executable file → Normal file
9
README.md
Executable file → Normal file
@ -320,7 +320,7 @@ Only `port 30333` should be opened.
|
||||
|
||||
Press _CTRL+C_ to stop the node.
|
||||
|
||||
# Launching GHOST TestNet 2.0
|
||||
# Launching GHOST TestNet 3.1
|
||||
|
||||
Switch to main GIT branch:
|
||||
```bash
|
||||
@ -437,9 +437,8 @@ sha256sum /etc/ghost/casper.json
|
||||
|
||||
You should see:
|
||||
```
|
||||
5aeb6fd5b9b14bdbc1a61600655b5217ded7c1b7cb05bd32929354e88935ae97
|
||||
ad653233c978bfd00c5e4525b17628632bc4319c5f5f4b4dcc2f050ef3c3d145
|
||||
```
|
||||

|
||||
|
||||
Create running `ghost-node` service that starts on system boot using `--unit-file` flag.
|
||||
And we must set up the `ghost-node` launch command by setting arguments using
|
||||
@ -492,7 +491,7 @@ Official **Boot Node** addresses:
|
||||
/dns/bootnode70.chain.ghostchain.io/tcp/30333/p2p/12D3KooWP3h5dSdqcpvsCr7fp1jyfqDj291QDZ68a4gY6VQ8T1nW
|
||||
```
|
||||
|
||||
A full list of available **Boot Nodes** can be found on [the guide page](https://blog.ghostchain.io/launching-ghost-testnet-2-0/#Boot_Node).
|
||||
A full list of available **Boot Nodes** can be found on [the guide page](https://blog.ghostchain.io/launching-ghost-testnet-3-1/#Boot_Node).
|
||||
|
||||

|
||||
|
||||
@ -508,7 +507,7 @@ Type `y` and press _Enter_ for create dedicated user for running `ghost-node`:
|
||||
|
||||

|
||||
|
||||
**DO NOT start and enable** `ghost-node.service` press _Enter_:
|
||||
**DO NOT start and DO NOT enable** `ghost-node.service` (press _Enter_):
|
||||
|
||||

|
||||
|
||||
|
14
cli/Cargo.toml
Executable file → Normal file
14
cli/Cargo.toml
Executable file → Normal file
@ -52,14 +52,14 @@ substrate-build-script-utils = { workspace = true }
|
||||
default = ["cli", "db", "full-node"]
|
||||
db = ["service/db"]
|
||||
cli = [
|
||||
"clap",
|
||||
"clap",
|
||||
"frame-benchmarking-cli",
|
||||
"sc-cli",
|
||||
"sc-service",
|
||||
"sc-tracing",
|
||||
"service",
|
||||
"ghost-client-cli",
|
||||
"ghost-machine-primitives",
|
||||
"sc-cli",
|
||||
"sc-service",
|
||||
"sc-tracing",
|
||||
"service",
|
||||
"ghost-client-cli",
|
||||
"ghost-machine-primitives",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"frame-benchmarking-cli?/runtime-benchmarks",
|
||||
|
0
cli/build.rs
Executable file → Normal file
0
cli/build.rs
Executable file → Normal file
0
cli/src/cli.rs
Executable file → Normal file
0
cli/src/cli.rs
Executable file → Normal file
0
cli/src/command.rs
Executable file → Normal file
0
cli/src/command.rs
Executable file → Normal file
0
cli/src/error.rs
Executable file → Normal file
0
cli/src/error.rs
Executable file → Normal file
0
cli/src/lib.rs
Executable file → Normal file
0
cli/src/lib.rs
Executable file → Normal file
6
core-primitives/Cargo.toml
Executable file → Normal file
6
core-primitives/Cargo.toml
Executable file → Normal file
@ -15,7 +15,7 @@ sp-runtime = { workspace = true }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
|
0
core-primitives/src/lib.rs
Executable file → Normal file
0
core-primitives/src/lib.rs
Executable file → Normal file
0
file_header.txt
Executable file → Normal file
0
file_header.txt
Executable file → Normal file
Binary file not shown.
Before Width: | Height: | Size: 8.1 KiB |
@ -37,17 +37,17 @@ serde_json = { workspace = true, default-features = true }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"frame-benchmarking?/std",
|
||||
"frame-benchmarking?/std",
|
||||
"serde/std",
|
||||
"codec/std",
|
||||
"codec/std",
|
||||
"scale-info/std",
|
||||
"libsecp256k1/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
"sp-io/std",
|
||||
"sp-std/std",
|
||||
"libsecp256k1/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
"sp-io/std",
|
||||
"sp-std/std",
|
||||
"pallet-ranked-collective/std",
|
||||
"pallet-vesting/std",
|
||||
"pallet-balances/std",
|
||||
@ -56,19 +56,19 @@ std = [
|
||||
runtime-benchmarks = [
|
||||
"libsecp256k1/hmac",
|
||||
"libsecp256k1/static-context",
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-ranked-collective/runtime-benchmarks",
|
||||
"pallet-vesting/runtime-benchmarks",
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-ranked-collective/runtime-benchmarks",
|
||||
"pallet-vesting/runtime-benchmarks",
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
"pallet-ranked-collective/try-runtime",
|
||||
"pallet-vesting/try-runtime",
|
||||
"pallet-balances/try-runtime",
|
||||
"sp-runtime/try-runtime",
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
"pallet-ranked-collective/try-runtime",
|
||||
"pallet-vesting/try-runtime",
|
||||
"pallet-balances/try-runtime",
|
||||
"sp-runtime/try-runtime",
|
||||
]
|
||||
|
40
pallets/networks/Cargo.toml
Executable file → Normal file
40
pallets/networks/Cargo.toml
Executable file → Normal file
@ -1,8 +1,8 @@
|
||||
[package]
|
||||
name = "ghost-networks"
|
||||
version = "0.1.2"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
@ -14,36 +14,40 @@ codec = { workspace = true, features = ["max-encoded-len"] }
|
||||
frame-benchmarking = { workspace = true, optional = true }
|
||||
frame-support = { workspace = true }
|
||||
frame-system = { workspace = true }
|
||||
pallet-staking = { workspace = true }
|
||||
sp-runtime = { workspace = true }
|
||||
sp-std = { workspace = true }
|
||||
ghost-traits = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { workspace = true }
|
||||
pallet-balances = { workspace = true }
|
||||
sp-io = { workspace = true }
|
||||
pallet-balances = { workspace = true }
|
||||
pallet-staking-reward-curve = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"scale-info/std",
|
||||
"codec/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"frame-benchmarking?/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"ghost-traits/std",
|
||||
"pallet-balances/std",
|
||||
"scale-info/std",
|
||||
"codec/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"frame-benchmarking?/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"ghost-traits/std",
|
||||
"pallet-staking/std",
|
||||
"pallet-balances/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"pallet-staking/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
]
|
||||
|
0
pallets/networks/src/benchmarking.rs
Executable file → Normal file
0
pallets/networks/src/benchmarking.rs
Executable file → Normal file
147
pallets/networks/src/lib.rs
Executable file → Normal file
147
pallets/networks/src/lib.rs
Executable file → Normal file
@ -4,15 +4,17 @@
|
||||
|
||||
use frame_support::{
|
||||
pallet_prelude::*,
|
||||
storage::PrefixIterator, traits::EnsureOrigin,
|
||||
storage::PrefixIterator, traits::{tokens::fungible::Inspect, EnsureOrigin},
|
||||
};
|
||||
use frame_system::pallet_prelude::*;
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{AtLeast32BitUnsigned, Member},
|
||||
traits::{CheckedSub, CheckedAdd, AtLeast32BitUnsigned, Member},
|
||||
curve::PiecewiseLinear,
|
||||
DispatchResult,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::convert::TryInto;
|
||||
|
||||
pub use ghost_traits::networks::{
|
||||
NetworkDataBasicHandler, NetworkDataInspectHandler,
|
||||
@ -31,6 +33,10 @@ mod mock;
|
||||
#[cfg(all(feature = "std", test))]
|
||||
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)]
|
||||
pub enum NetworkType {
|
||||
Evm = 0,
|
||||
@ -55,6 +61,48 @@ pub struct NetworkData {
|
||||
pub outgoing_fee: u32,
|
||||
}
|
||||
|
||||
#[derive(Default, Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
||||
pub struct BridgeAdjustment<Balance> {
|
||||
bridged_out: Balance,
|
||||
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)),
|
||||
};
|
||||
|
||||
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]
|
||||
pub mod module {
|
||||
use super::*;
|
||||
@ -63,6 +111,9 @@ pub mod module {
|
||||
pub trait Config: frame_system::Config {
|
||||
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.
|
||||
type NetworkId: Parameter
|
||||
+ Member
|
||||
@ -114,11 +165,31 @@ pub mod module {
|
||||
NetworkRemoved { chain_id: T::NetworkId },
|
||||
}
|
||||
|
||||
#[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::getter(fn networks)]
|
||||
pub type Networks<T: Config> =
|
||||
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]
|
||||
pub struct GenesisConfig<T: Config> {
|
||||
pub networks: Vec<(T::NetworkId, Vec<u8>)>,
|
||||
@ -527,7 +598,7 @@ impl<T: Config> NetworkDataInspectHandler<NetworkData> for Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> NetworkDataMutateHandler<NetworkData> for Pallet<T> {
|
||||
impl<T: Config> NetworkDataMutateHandler<NetworkData, BalanceOf<T>> for Pallet<T> {
|
||||
fn register(chain_id: Self::NetworkId, network: NetworkData) -> DispatchResult {
|
||||
Self::do_register_network(chain_id, network)
|
||||
}
|
||||
@ -535,4 +606,74 @@ impl<T: Config> NetworkDataMutateHandler<NetworkData> for Pallet<T> {
|
||||
fn remove(chain_id: Self::NetworkId) -> DispatchResult {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
32
pallets/networks/src/mock.rs
Executable file → Normal file
32
pallets/networks/src/mock.rs
Executable file → Normal file
@ -1,19 +1,25 @@
|
||||
use crate as ghost_networks;
|
||||
use crate::{self as ghost_networks};
|
||||
use frame_system::EnsureSignedBy;
|
||||
use frame_support::{
|
||||
construct_runtime, ord_parameter_types, parameter_types, traits::{ConstU128, ConstU32, Everything}
|
||||
construct_runtime, ord_parameter_types, parameter_types,
|
||||
traits::{ConstU128, ConstU32, Everything},
|
||||
};
|
||||
pub use primitives::{
|
||||
AccountId, Balance, Nonce, BlockNumber, Hash,
|
||||
ReserveIdentifier, FreezeIdentifier,
|
||||
};
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, AccountIdLookup},
|
||||
BuildStorage,
|
||||
curve::PiecewiseLinear,
|
||||
traits::{AccountIdLookup, BlakeTwo256},
|
||||
BuildStorage
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
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 {
|
||||
@ -64,6 +70,21 @@ impl pallet_balances::Config for Test {
|
||||
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! {
|
||||
pub const RegistererAccount: AccountId = AccountId::from([1u8; 32]);
|
||||
pub const UpdaterAccount: AccountId = AccountId::from([2u8; 32]);
|
||||
@ -73,6 +94,7 @@ ord_parameter_types! {
|
||||
|
||||
impl ghost_networks::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type NetworkId = u32;
|
||||
type RegisterOrigin = EnsureSignedBy::<RegistererAccount, AccountId>;
|
||||
type UpdateOrigin = EnsureSignedBy::<UpdaterAccount, AccountId>;
|
||||
@ -80,7 +102,7 @@ impl ghost_networks::Config for Test {
|
||||
type WeightInfo = crate::weights::SubstrateWeight<Test>;
|
||||
}
|
||||
|
||||
type Block = frame_system::mocking::MockBlockU32<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
|
||||
construct_runtime!(
|
||||
pub enum Test {
|
||||
|
284
pallets/networks/src/tests.rs
Executable file → Normal file
284
pallets/networks/src/tests.rs
Executable file → Normal file
@ -1,16 +1,16 @@
|
||||
use mock::{
|
||||
ExtBuilder, System, RegistererAccount, UpdaterAccount, RemoverAccount,
|
||||
RandomAccount, GhostNetworks, Test, RuntimeEvent, RuntimeOrigin,
|
||||
RandomAccount, GhostNetworks, Test, RuntimeEvent, RuntimeOrigin, RewardCurve,
|
||||
};
|
||||
use frame_support::{assert_err, assert_ok};
|
||||
use sp_runtime::DispatchError;
|
||||
use pallet_staking::EraPayout;
|
||||
use super::*;
|
||||
|
||||
fn prepare_network_data() -> (u32, NetworkData) {
|
||||
(1u32, NetworkData {
|
||||
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),
|
||||
release_delay: Some(69),
|
||||
network_type: NetworkType::Evm,
|
||||
@ -635,3 +635,281 @@ fn could_not_remove_non_existent_network() {
|
||||
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));
|
||||
});
|
||||
}
|
||||
|
0
pallets/networks/src/weights.rs
Executable file → Normal file
0
pallets/networks/src/weights.rs
Executable file → Normal file
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-slow-clap"
|
||||
version = "0.3.15"
|
||||
version = "0.3.16"
|
||||
description = "Applause protocol for the EVM bridge"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
1019
pallets/slow-clap/src/lib.rs
Executable file → Normal file
1019
pallets/slow-clap/src/lib.rs
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
@ -1,18 +1,11 @@
|
||||
use frame_support::weights::Weight;
|
||||
|
||||
pub trait WeightInfo {
|
||||
fn slow_clap(claps_len: u32, companions_len: u32) -> Weight;
|
||||
fn propose_companion() -> Weight;
|
||||
fn release_companion() -> Weight;
|
||||
fn kill_companion() -> Weight;
|
||||
fn slow_clap() -> Weight;
|
||||
fn applause()-> Weight;
|
||||
}
|
||||
|
||||
impl WeightInfo for () {
|
||||
fn slow_clap(
|
||||
_claps_len: u32,
|
||||
_companions_len: u32,
|
||||
) -> Weight { Weight::zero() }
|
||||
fn propose_companion() -> Weight { Weight::zero() }
|
||||
fn release_companion() -> Weight { Weight::zero() }
|
||||
fn kill_companion() -> Weight { Weight::zero() }
|
||||
fn slow_clap()-> Weight { Weight::zero() }
|
||||
fn applause()-> Weight { Weight::zero() }
|
||||
}
|
||||
|
4
pallets/traits/Cargo.toml
Executable file → Normal file
4
pallets/traits/Cargo.toml
Executable file → Normal file
@ -14,6 +14,6 @@ sp-runtime = { workspace = true }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
]
|
||||
|
0
pallets/traits/src/lib.rs
Executable file → Normal file
0
pallets/traits/src/lib.rs
Executable file → Normal file
13
pallets/traits/src/networks.rs
Executable file → Normal file
13
pallets/traits/src/networks.rs
Executable file → Normal file
@ -23,7 +23,18 @@ pub trait NetworkDataInspectHandler<Network>: NetworkDataBasicHandler {
|
||||
fn iter() -> PrefixIterator<(Self::NetworkId, Network)>;
|
||||
}
|
||||
|
||||
pub trait NetworkDataMutateHandler<Network>: NetworkDataInspectHandler<Network> {
|
||||
pub trait NetworkDataMutateHandler<Network, Balance>: NetworkDataInspectHandler<Network> {
|
||||
fn register(chain_id: Self::NetworkId, network: Network) -> 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();
|
||||
}
|
||||
|
0
rpc/Cargo.toml
Executable file → Normal file
0
rpc/Cargo.toml
Executable file → Normal file
0
rpc/src/lib.rs
Executable file → Normal file
0
rpc/src/lib.rs
Executable file → Normal file
0
runtime/casper/Cargo.toml
Executable file → Normal file
0
runtime/casper/Cargo.toml
Executable file → Normal file
0
runtime/casper/build.rs
Executable file → Normal file
0
runtime/casper/build.rs
Executable file → Normal file
0
runtime/casper/constants/Cargo.toml
Executable file → Normal file
0
runtime/casper/constants/Cargo.toml
Executable file → Normal file
0
runtime/casper/constants/src/lib.rs
Executable file → Normal file
0
runtime/casper/constants/src/lib.rs
Executable file → Normal file
0
runtime/casper/src/cult/mod.rs
Executable file → Normal file
0
runtime/casper/src/cult/mod.rs
Executable file → Normal file
0
runtime/casper/src/cult/origins.rs
Executable file → Normal file
0
runtime/casper/src/cult/origins.rs
Executable file → Normal file
0
runtime/casper/src/cult/tracks.rs
Executable file → Normal file
0
runtime/casper/src/cult/tracks.rs
Executable file → Normal file
0
runtime/casper/src/lib.rs
Executable file → Normal file
0
runtime/casper/src/lib.rs
Executable file → Normal file
48
runtime/common/Cargo.toml
Executable file → Normal file
48
runtime/common/Cargo.toml
Executable file → Normal file
@ -31,21 +31,21 @@ primitives = { workspace = true }
|
||||
default = ["std"]
|
||||
no_std = []
|
||||
std = [
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
"sp-staking/std",
|
||||
"frame-support/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"pallet-authorship/std",
|
||||
"pallet-balances/std",
|
||||
"pallet-staking/std",
|
||||
"pallet-staking-reward-fn/std",
|
||||
"pallet-timestamp/std",
|
||||
"pallet-transaction-payment/std",
|
||||
"pallet-treasury/std",
|
||||
"pallet-election-provider-multi-phase/std",
|
||||
"pallet-authorship/std",
|
||||
"pallet-balances/std",
|
||||
"pallet-staking/std",
|
||||
"pallet-staking-reward-fn/std",
|
||||
"pallet-timestamp/std",
|
||||
"pallet-transaction-payment/std",
|
||||
"pallet-treasury/std",
|
||||
"pallet-election-provider-multi-phase/std",
|
||||
"primitives/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
@ -53,21 +53,21 @@ runtime-benchmarks = [
|
||||
"sp-staking/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
"pallet-staking/runtime-benchmarks",
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
"pallet-treasury/runtime-benchmarks",
|
||||
"pallet-election-provider-multi-phase/runtime-benchmarks",
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
"pallet-staking/runtime-benchmarks",
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
"pallet-treasury/runtime-benchmarks",
|
||||
"pallet-election-provider-multi-phase/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"sp-runtime/try-runtime",
|
||||
"frame-support/try-runtime",
|
||||
"frame-system/try-runtime",
|
||||
"pallet-authorship/try-runtime",
|
||||
"pallet-balances/try-runtime",
|
||||
"pallet-staking/try-runtime",
|
||||
"pallet-timestamp/try-runtime",
|
||||
"pallet-transaction-payment/try-runtime",
|
||||
"pallet-treasury/try-runtime",
|
||||
"pallet-election-provider-multi-phase/try-runtime",
|
||||
"pallet-authorship/try-runtime",
|
||||
"pallet-balances/try-runtime",
|
||||
"pallet-staking/try-runtime",
|
||||
"pallet-timestamp/try-runtime",
|
||||
"pallet-transaction-payment/try-runtime",
|
||||
"pallet-treasury/try-runtime",
|
||||
"pallet-election-provider-multi-phase/try-runtime",
|
||||
]
|
||||
|
0
runtime/common/src/impls.rs
Executable file → Normal file
0
runtime/common/src/impls.rs
Executable file → Normal file
0
runtime/common/src/lib.rs
Executable file → Normal file
0
runtime/common/src/lib.rs
Executable file → Normal file
0
runtime/common/src/weights/block_weights.rs
Executable file → Normal file
0
runtime/common/src/weights/block_weights.rs
Executable file → Normal file
0
runtime/common/src/weights/extrinsic.rs
Executable file → Normal file
0
runtime/common/src/weights/extrinsic.rs
Executable file → Normal file
0
runtime/common/src/weights/mod.rs
Executable file → Normal file
0
runtime/common/src/weights/mod.rs
Executable file → Normal file
@ -1,6 +1,7 @@
|
||||
[Unit]
|
||||
Description=Ghost Node
|
||||
After=network.target
|
||||
After=network-online.target
|
||||
Requires=network-online.target
|
||||
Documentation=https://git.ghostchain.io/ghostchain/ghost-node
|
||||
|
||||
[Service]
|
||||
|
2
scripts/patch.sh
Executable file
2
scripts/patch.sh
Executable file
@ -0,0 +1,2 @@
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
bash "$SCRIPT_DIR/patches/patch-1.sh"
|
32
scripts/patches/patch-1.sh
Executable file
32
scripts/patches/patch-1.sh
Executable file
@ -0,0 +1,32 @@
|
||||
DEFAULT_SERVICE_NAME="ghost-node.service"
|
||||
|
||||
check_unit_file_validity() {
|
||||
SERVICE_NAME=$1
|
||||
if [[ "$SERVICE_NAME" != *.service ]]; then
|
||||
SERVICE_NAME="${SERVICE_NAME}.service"
|
||||
fi
|
||||
|
||||
SERVICE_FULL_PATH="/etc/systemd/system/$SERVICE_NAME"
|
||||
if [[ -e "$SERVICE_FULL_PATH" ]]; then
|
||||
NETWORK_ONLINE_EXISTS=$(grep -Fx "After=network-online.target" "$SERVICE_FULL_PATH")
|
||||
NETWORK_EXISTS=$(grep -Fx "After=network.target" "$SERVICE_FULL_PATH")
|
||||
|
||||
if [[ -z "$NETWORK_ONLINE_EXISTS" && -n "$NETWORK_EXISTS" ]]
|
||||
then
|
||||
echo "[-] WARNING: missing network-online.target dependency in $SERVICE_FULL_PATH, trying to replace"
|
||||
sudo sed -i "s/After=network.target/After=network-online.target\nRequires=network-online.target/g" "$SERVICE_FULL_PATH"
|
||||
else
|
||||
echo "[+] INFO: network-online.target is set correctly for $SERVICE_FULL_PATH"
|
||||
fi
|
||||
else
|
||||
echo "[-] No serivce found at $SERVICE_FULL_PATH"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
check_unit_file_validity $DEFAULT_SERVICE_NAME
|
||||
read -p "[?] Enter names for the node service, separated by commas (default: ghost-node): " -a SERVICE_NAMES
|
||||
for NAME in "${SERVICE_NAMES[@]}"; do
|
||||
check_unit_file_validity $NAME
|
||||
done
|
||||
sudo systemctl daemon-reload
|
@ -7,6 +7,7 @@ INSERT_KEYS=false
|
||||
UNIT_FILE=false
|
||||
SKIP_BUILD=false
|
||||
SET_ENVIRONMENT=false
|
||||
VALIDATE=false
|
||||
EXECUTABLE_PATH="/usr/bin/"
|
||||
SPECIFICATION_PATH="/etc/ghost/"
|
||||
BASE_PATH="/var/lib/ghost"
|
||||
@ -88,6 +89,7 @@ help() {
|
||||
echo -e "-k, --check-keys\n\tCheck if your keys are already included in 'ghosties' file."
|
||||
echo -e "-y, --insert-keys\n\tInsert session keys to the keystore via JSON RPC."
|
||||
echo -e "-r, --release\n\tCompile node with '--release' flag."
|
||||
echo -e "-v, --validate\n\tManipulate '--validate' flag in CLI_ARGS."
|
||||
echo -e "-p, --profile\n\tCompile node with '--profile [PROFILE]' flag."
|
||||
echo -e "-f, --features\n\tCompilation features '--features=\"FEATURE1,FEATURE2\"'"
|
||||
echo -e "-e, --executable-path\n\tPath to the executable ('/usr/lib/' is default)."
|
||||
@ -133,6 +135,9 @@ while [ $# -gt 0 ]; do
|
||||
RELEASE="--release"
|
||||
TARGET="release"
|
||||
;;
|
||||
--validate|-v)
|
||||
VALIDATE=true
|
||||
;;
|
||||
--profile*|-p*)
|
||||
if [[ "$1" != *=* ]]; then shift; fi
|
||||
RELEASE="--profile=${1#*=}"
|
||||
@ -263,6 +268,32 @@ if [[ ! -z $RELEASE ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $VALIDATE = true ]]; then
|
||||
cli_args=$(cat /etc/default/ghost)
|
||||
if prompt "[?] turn on validator mode?"; then
|
||||
if [[ $cli_args == *"--validator"* ]]; then
|
||||
echo "[+] '--validator' flag already exists in CLI_ARGS, check /etc/default/ghost"
|
||||
else
|
||||
cli_args="${cli_args%?} --validator\""
|
||||
echo "[+] '--validator' flag inserted to CLI_ARGS, check /etc/default/ghost"
|
||||
fi
|
||||
else
|
||||
cli_args=${cli_args// --validator/}
|
||||
echo "[+] '--validator' flag removed"
|
||||
fi
|
||||
|
||||
echo "[+] trying to store CLI updated arguments to '/etc/default/ghost'"
|
||||
echo "$cli_args" | sudo tee /etc/default/ghost > /dev/null
|
||||
echo "[+] updated CLI arguments stored in '/etc/default/ghost'"
|
||||
|
||||
if prompt "[?] do you want to restart 'ghost-node.service' now?"; then
|
||||
sudo systemctl status ghost-node.service
|
||||
echo "[+] 'ghost-node.service' succefully restarted, new CLI_ARGS applied"
|
||||
else
|
||||
echo "[+] don't forget to restart ghost node service manually"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $MAKE_GLOBAL = true ]]; then
|
||||
cd $PROJECT_FOLDER
|
||||
echo "[+] trying to copy executable to '$EXECUTABLE_PATH'"
|
||||
|
20
service/Cargo.toml
Executable file → Normal file
20
service/Cargo.toml
Executable file → Normal file
@ -107,16 +107,16 @@ default = ["db", "full-node"]
|
||||
db = ["sc-service/rocksdb"]
|
||||
full-node = ["kvdb-rocksdb", "parity-db"]
|
||||
runtime-benchmarks = [
|
||||
"frame-benchmarking-cli/runtime-benchmarks",
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-babe/runtime-benchmarks",
|
||||
"pallet-staking/runtime-benchmarks",
|
||||
"casper-runtime?/runtime-benchmarks",
|
||||
"sc-client-db/runtime-benchmarks",
|
||||
"sc-service/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"frame-benchmarking-cli/runtime-benchmarks",
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-babe/runtime-benchmarks",
|
||||
"pallet-staking/runtime-benchmarks",
|
||||
"casper-runtime?/runtime-benchmarks",
|
||||
"sc-client-db/runtime-benchmarks",
|
||||
"sc-service/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"frame-support/try-runtime",
|
||||
|
File diff suppressed because one or more lines are too long
0
service/src/chain_spec.rs
Executable file → Normal file
0
service/src/chain_spec.rs
Executable file → Normal file
0
service/src/lib.rs
Executable file → Normal file
0
service/src/lib.rs
Executable file → Normal file
0
src/main.rs
Executable file → Normal file
0
src/main.rs
Executable file → Normal file
0
tests/benchmark_block.rs
Executable file → Normal file
0
tests/benchmark_block.rs
Executable file → Normal file
0
tests/benchmark_extrinsic.rs
Executable file → Normal file
0
tests/benchmark_extrinsic.rs
Executable file → Normal file
0
tests/benchmark_overhead.rs
Executable file → Normal file
0
tests/benchmark_overhead.rs
Executable file → Normal file
0
tests/benchmark_storage_works.rs
Executable file → Normal file
0
tests/benchmark_storage_works.rs
Executable file → Normal file
0
tests/common.rs
Executable file → Normal file
0
tests/common.rs
Executable file → Normal file
0
tests/invalid_order_arguments.rs
Executable file → Normal file
0
tests/invalid_order_arguments.rs
Executable file → Normal file
0
tests/purge_chain_works.rs
Executable file → Normal file
0
tests/purge_chain_works.rs
Executable file → Normal file
0
tests/running_the_node_and_interrupt.rs
Executable file → Normal file
0
tests/running_the_node_and_interrupt.rs
Executable file → Normal file
0
utils/generate-bags/Cargo.toml
Executable file → Normal file
0
utils/generate-bags/Cargo.toml
Executable file → Normal file
0
utils/generate-bags/src/main.rs
Executable file → Normal file
0
utils/generate-bags/src/main.rs
Executable file → Normal file
0
utils/ghostkey/Cargo.toml
Executable file → Normal file
0
utils/ghostkey/Cargo.toml
Executable file → Normal file
0
utils/ghostkey/src/lib.rs
Executable file → Normal file
0
utils/ghostkey/src/lib.rs
Executable file → Normal file
0
utils/ghostkey/src/main.rs
Executable file → Normal file
0
utils/ghostkey/src/main.rs
Executable file → Normal file
0
utils/staking-miner/Cargo.toml
Executable file → Normal file
0
utils/staking-miner/Cargo.toml
Executable file → Normal file
0
utils/staking-miner/playground/runtime/src/voter_bags.rs
Executable file → Normal file
0
utils/staking-miner/playground/runtime/src/voter_bags.rs
Executable file → Normal file
0
utils/staking-miner/src/main.rs
Executable file → Normal file
0
utils/staking-miner/src/main.rs
Executable file → Normal file
0
utils/staking-miner/tests/cli.rs
Executable file → Normal file
0
utils/staking-miner/tests/cli.rs
Executable file → Normal file
Loading…
Reference in New Issue
Block a user