Compare commits

...

4 Commits

Author SHA1 Message Date
e184819d16
increment version for casper runtime
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2024-10-13 20:47:45 +03:00
9c5ab07cf9
small fix for the ghost executable version
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2024-10-13 20:46:29 +03:00
f8168e525f
extra genesis preset for the casper runtime
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2024-10-13 20:39:35 +03:00
aaf842f57b
minimal requirements lowered to two stakerers at minimum
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2024-10-13 20:37:29 +03:00
7 changed files with 193 additions and 28 deletions

1
Cargo.lock generated
View File

@ -1203,6 +1203,7 @@ dependencies = [
"ghost-networks",
"ghost-runtime-common",
"ghost-slow-clap",
"hex-literal",
"log",
"pallet-alliance",
"pallet-authority-discovery",

View File

@ -1,6 +1,6 @@
[package]
name = "ghost-cli"
description = "Ghost Client Node"
description = "Implementation of a Ghost Client Node in Rust"
version.workspace = true
edition.workspace = true
authors.workspace = true

View File

@ -29,7 +29,7 @@ impl SubstrateCli for Cli {
}
fn impl_version() -> String {
env!("CARGO_PKG_DESCRIPTION").into()
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
}
fn description() -> String {

View File

@ -1,6 +1,6 @@
[package]
name = "casper-runtime"
version = "3.5.17"
version = "3.5.18"
build = "build.rs"
description = "Runtime of the Casper Network"
edition.workspace = true
@ -17,6 +17,7 @@ codec = { features = ["derive", "max-encoded-len"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
log = { workspace = true }
serde_json = { workspace = true }
hex-literal = { workspace = true, default-features = true }
frame-support = { workspace = true }
frame-system = { workspace = true }

View File

@ -1,4 +1,6 @@
use codec::Encode;
use pallet_staking::Forcing;
use sp_staking::StakerStatus;
use crate::{opaque::SessionKeys, BABE_GENESIS_EPOCH_CONFIG};
use primitives::{AccountId, AccountPublic};
@ -14,7 +16,7 @@ use sp_std::alloc::format;
use sp_std::vec::Vec;
use sp_std::prelude::*;
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::IdentifyAccount;
use sp_runtime::{Perbill, traits::IdentifyAccount};
#[derive(Encode, Clone)]
struct PreparedNetworkData {
@ -62,7 +64,7 @@ fn get_authority_keys_from_seed(
)
}
fn testnet_accounts() -> Vec<AccountId> {
fn casper_testnet_accounts() -> Vec<AccountId> {
Vec::from([
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
@ -79,7 +81,7 @@ fn testnet_accounts() -> Vec<AccountId> {
])
}
fn testnet_evm_accounts() -> Vec<(AccountId, u128, u8)> {
fn casper_testnet_evm_accounts() -> Vec<(AccountId, u128, u8)> {
vec![
// 01c928771aea942a1e7ac06adf2b73dfbc9a25d9eaa516e3673116af7f345198
(get_account_id_from_seed::<sr25519::Public>("1A69d2D5568D1878023EeB121a73d33B9116A760"), 1337 * CSPR, 1),
@ -92,7 +94,7 @@ fn testnet_evm_accounts() -> Vec<(AccountId, u128, u8)> {
]
}
fn testnet_evm_networks() -> Vec<(u32, Vec<u8>)> {
fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>)> {
vec![
(1, PreparedNetworkData {
chain_name: "ethereum-mainnet".into(),
@ -128,7 +130,7 @@ fn casper_session_keys(
SessionKeys { babe, grandpa, authority_discovery, slow_clap }
}
fn casper_testnet_genesis(
fn testnet_config_genesis(
initial_authorities: Vec<(
AccountId,
AccountId,
@ -142,15 +144,16 @@ fn casper_testnet_genesis(
evm_networks: Option<Vec<(u32, Vec<u8>)>>,
) -> serde_json::Value {
let endowed_accounts: Vec<AccountId> =
endowed_accounts.unwrap_or_else(testnet_accounts);
endowed_accounts.unwrap_or_else(casper_testnet_accounts);
let ghost_accounts: Vec<(AccountId, u128, u8)> =
ghost_accounts.unwrap_or_else(testnet_evm_accounts);
ghost_accounts.unwrap_or_else(casper_testnet_evm_accounts);
let evm_networks: Vec<(u32, Vec<u8>)> =
evm_networks.unwrap_or_else(testnet_evm_networks);
evm_networks.unwrap_or_else(casper_testnet_evm_networks);
const ENDOWMENT: u128 = 1_000 * CSPR;
const STASH: u128 = 500 * CSPR;
serde_json::json!({
"balances": {
@ -179,6 +182,155 @@ fn casper_testnet_genesis(
})
.collect::<Vec<_>>(),
},
"staking": {
"validatorCount": initial_authorities.len() as u32,
"minimumValidatorCount": 1,
"invulnerables": initial_authorities
.iter()
.map(|x| x.0.clone())
.collect::<Vec<_>>(),
"forceEra": Forcing::NotForcing,
"slashRewardFraction": Perbill::from_percent(10),
"stakers": initial_authorities
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, StakerStatus::<AccountId>::Validator))
.collect::<Vec<_>>(),
},
"babe": {
"epochConfig": Some(BABE_GENESIS_EPOCH_CONFIG),
},
"ghostNetworks": {
"networks": evm_networks,
},
"ghostClaims": {
"total": ghost_accounts
.iter()
.fold(0, |acc, k| acc + k.1),
"membersAndRanks": ghost_accounts
.iter()
.map(|k| (k.0.clone(), k.2.clone()))
.collect::<Vec<_>>(),
},
})
}
// staging
fn casper_staging_config_genesis() -> serde_json::Value {
use hex_literal::hex;
use sp_core::crypto::UncheckedInto;
// Following keys are used in genesis config for testing (casper) chains.
// DO NOT use them in production chains such as ghost.
let endowed_accounts = vec![
// sfErNwRgZ6ypB7wY8M2smXMZjxqUkc2TgUcNvC1JNQJFXS8bw
hex!["328d3b7c3046ef7700937d99fb2e98ce2591682c2b5dcf3f562e4da157650237"].into(),
// sfEwRjyvEQcpRQ1qbCZum27nEkTggKEt7DtqxwyYQULt9UuUN
hex!["3666e4e19f87bb8680495f31864ce1f1c69d4178002cc01911aef2cc7313f203"].into(),
// sfHcJxw5cgkvukZZyxcNUMCdbm9e7773orByLrGgAREka81TK
hex!["ac871e8bab00dd56ba3a1c0bd289357203dcaf10010b0b04ad7472870cd22a3c"].into(),
];
let initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
AuthorityDiscoveryId,
SlowClapId,
)> = vec![
(
// sfFXZmnDVnkQ781J2gbqUpi7K5KgMWMdM4eeii74xxGgKYnNN
hex!["507045c82be367f95408466cd054ca39bfa52697a3ef22809af14cf9de304f02"].into(),
// sfFXZmnDVnkQ781J2gbqUpi7K5KgMWMdM4eeii74xxGgKYnNN
hex!["507045c82be367f95408466cd054ca39bfa52697a3ef22809af14cf9de304f02"].into(),
// sfJeojACBa7WiH6tBwikBKAMU2oKmseEBD1GYUYATvfWuLcPa
hex!["daaaaab6a6e574099e24ae9bb75b543610edef9d374fa85a378edb573b47615f"].unchecked_into(),
// sfFdtzNxJdeEkgHxvk144rJKxf7wcYvgX5tqfgZRutW9YvAKE
hex!["55446f9a7aa99ced06b317c80ce90d56b84e56526775683af2525969e8da0b64"].unchecked_into(),
// sfE8gsMYAjAJHk5gyYZN7AW6pfmJ7V9H7xxWto24nmhzCUXaQ
hex!["12c14850562021eb99f58f90ab624fb6cfaf3ac9228a92f8b60115fe6a6af15a"].unchecked_into(),
// sfE3GKSrKZzrZpdapJ2VGRpPor45T4D4i8QBZNumSNGqGv7PX
hex!["0e9e698c7b2bf5ce3861cb4bc4ddf9e200237c282025b093ada850d764d12a35"].unchecked_into(),
),
(
// sfHLqWNC4hMKHhwvPWmWcxZsDPhCTQKgh1Ap7pm3qML5GBTBa
hex!["a0ba0196e6ee7e6b5b0553035c5cb5c04e9725001b5732839d0529cbc00c9600"].into(),
// sfHLqWNC4hMKHhwvPWmWcxZsDPhCTQKgh1Ap7pm3qML5GBTBa
hex!["a0ba0196e6ee7e6b5b0553035c5cb5c04e9725001b5732839d0529cbc00c9600"].into(),
// sfGA6tPPF8dAc8QpMCMjxitG3j8sXPhkdpm5bwz4UsXAApUiw
hex!["6c4dd88b43e2011cf9a6a73d53446336ac9e04cdd4ca23587df63187ac455e49"].unchecked_into(),
// sfGxQZXFUQH1AXv82rpjiJHFs7YsdEuVGdyvKiS2Tajpvw6Se
hex!["8f9ea20bf4a807a8e710f7559dece86e94672b5b361de157bdaa5c1f37849f8d"].unchecked_into(),
// sfGz2enFUR22cQ5ey61MdtPqbCeEWZA1wsCFFSLGaK7vKnv8C
hex!["90db5ed339a559ed157995a48d781f44c7df972dfba4bc855e4b59fa46438e17"].unchecked_into(),
// sfEtwe5BoroNjkdLsvnjnMemUKiw8MS1X4YW8bepbbGvhS4LZ
hex!["3481cdcbcf37a4669c29a78cf9ceb39383a10ef0a18b36b92d149fdd0c24ae00"].unchecked_into(),
),
(
// sfGq75CrCrkcfqNzyyidu3D4jW3AoJSzL5tKKuv1UbS16ezzy
hex!["8a0d0b66e827bf20e79f9a499317e73925ce4f422371067edfab690e43857f13"].into(),
// sfGq75CrCrkcfqNzyyidu3D4jW3AoJSzL5tKKuv1UbS16ezzy
hex!["8a0d0b66e827bf20e79f9a499317e73925ce4f422371067edfab690e43857f13"].into(),
// sfJo2ogBpssRAU9ZPTvuXFZEdmJw9pKsPydLjXe8DypRScjzT
hex!["e0f0a776ecc9fa5e1f22e2fa001fe3fba5aea52b9444bc894b45589d42132475"].unchecked_into(),
// sfHq3EVT1sqY7o5ki3zA6LEdRDfdFc29YaZN3w2Thhz6JD5ZF
hex!["b63c5a0cf342b9b04931bc8ed74d7d0165ab99ab5f8a4514797d4b299a4501fe"].unchecked_into(),
// sfEj3wrDy9EDLCAodyEdQEYxJpNnM8Etaj3RJ5bCBRzdaDced
hex!["2cf69452e9f2a8457119139408884941ed50f590c0fc0f2b044c4d82c69e4245"].unchecked_into(),
// sfE32RmBp1xX4KRTphVGLUJBxLGPN3Dzg9BwCJktxMf3iEwck
hex!["0e6fa6934f9e99fa84874f2ed9318825a0d5443a0ced984acfbd24ece72ba55e"].unchecked_into(),
),
];
let ghost_accounts: Vec<(AccountId, u128, u8)> = casper_testnet_evm_accounts();
let evm_networks = casper_testnet_evm_networks();
const ENDOWMENT: u128 = 5_000 * CSPR;
const STASH: u128 = 500 * CSPR;
serde_json::json!({
"balances": {
"balances": endowed_accounts
.iter()
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect::<Vec<_>>(),
},
"session": {
"keys": initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
casper_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
),
)
})
.collect::<Vec<_>>(),
},
"staking": {
"validatorCount": 50,
"minimumValidatorCount": 4,
"stakers": initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
STASH,
StakerStatus::<AccountId>::Validator,
)
})
.collect::<Vec<_>>(),
"invulnerables": initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>(),
"forceEra": Forcing::ForceNone,
"slashRewardFraction": Perbill::from_percent(10)
},
"babe": {
"epochConfig": Some(BABE_GENESIS_EPOCH_CONFIG),
},
@ -199,7 +351,7 @@ fn casper_testnet_genesis(
// development
fn casper_development_config_genesis() -> serde_json::Value {
casper_testnet_genesis(
testnet_config_genesis(
vec![get_authority_keys_from_seed("Alice")],
None, None, None,
)
@ -207,7 +359,7 @@ fn casper_development_config_genesis() -> serde_json::Value {
// local
fn casper_local_config_genesis() -> serde_json::Value {
casper_testnet_genesis(
testnet_config_genesis(
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
@ -220,6 +372,7 @@ fn casper_local_config_genesis() -> serde_json::Value {
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
let patch = match id.try_into() {
Ok("development") => casper_development_config_genesis(),
Ok("staging") => casper_staging_config_genesis(),
Ok("local_testnet") => casper_local_config_genesis(),
_ => return None,
};
@ -233,5 +386,6 @@ pub fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
Vec::from([
sp_genesis_builder::PresetId::from("local_testnet"),
sp_genesis_builder::PresetId::from("development"),
sp_genesis_builder::PresetId::from("staging"),
])
}

File diff suppressed because one or more lines are too long

View File

@ -384,7 +384,7 @@ fn casper_staging_config_genesis() -> serde_json::Value {
},
"staking": {
"validatorCount": 50,
"minimumValidatorCount": 4,
"minimumValidatorCount": 2,
"stakers": initial_authorities
.iter()
.map(|x| {