Compare commits
No commits in common. "cc300fefb01a00c5c5ce35fd78cd281835c7e940" and "6a5029017c3dc4216a5047bf952ed1cb58a17db6" have entirely different histories.
cc300fefb0
...
6a5029017c
9
Cargo.lock
generated
9
Cargo.lock
generated
@ -1186,7 +1186,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "casper-runtime"
|
name = "casper-runtime"
|
||||||
version = "3.5.38"
|
version = "3.5.37"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"casper-runtime-constants",
|
"casper-runtime-constants",
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
@ -3650,14 +3650,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ghost-networks"
|
name = "ghost-networks"
|
||||||
version = "0.1.25"
|
version = "0.1.20"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
"frame-system",
|
"frame-system",
|
||||||
"ghost-core-primitives",
|
"ghost-core-primitives",
|
||||||
"ghost-traits",
|
"ghost-traits",
|
||||||
"log",
|
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"pallet-balances",
|
"pallet-balances",
|
||||||
"pallet-staking",
|
"pallet-staking",
|
||||||
@ -3838,7 +3837,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ghost-slow-clap"
|
name = "ghost-slow-clap"
|
||||||
version = "0.4.24"
|
version = "0.4.14"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
@ -3890,7 +3889,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ghost-traits"
|
name = "ghost-traits"
|
||||||
version = "0.3.31"
|
version = "0.3.26"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-support",
|
"frame-support",
|
||||||
"sp-runtime 31.0.1",
|
"sp-runtime 31.0.1",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ghost-slow-clap"
|
name = "ghost-slow-clap"
|
||||||
version = "0.4.24"
|
version = "0.4.23"
|
||||||
description = "Applause protocol for the EVM bridge"
|
description = "Applause protocol for the EVM bridge"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
|||||||
@ -90,7 +90,11 @@ benchmarks! {
|
|||||||
session_index,
|
session_index,
|
||||||
authority_index,
|
authority_index,
|
||||||
network_id,
|
network_id,
|
||||||
last_stored_block: 69,
|
commitment: CommitmentDetails {
|
||||||
|
last_stored_block: 69,
|
||||||
|
commits: 420,
|
||||||
|
last_updated: 1337,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let authority_id = authorities
|
let authority_id = authorities
|
||||||
@ -98,21 +102,20 @@ benchmarks! {
|
|||||||
.expect("first authority should exist");
|
.expect("first authority should exist");
|
||||||
let signature = authority_id.sign(&block_commitment.encode())
|
let signature = authority_id.sign(&block_commitment.encode())
|
||||||
.ok_or("couldn't make signature")?;
|
.ok_or("couldn't make signature")?;
|
||||||
|
|
||||||
}: _(RawOrigin::None, block_commitment, signature)
|
}: _(RawOrigin::None, block_commitment, signature)
|
||||||
verify {
|
verify {
|
||||||
let current_block_number = <Pallet<T> as BlockNumberProvider>::current_block_number();
|
|
||||||
let stored_commitment = BlockCommitments::<T>::get(&network_id)
|
let stored_commitment = BlockCommitments::<T>::get(&network_id)
|
||||||
.get(&authority_index)
|
.get(&authority_index)
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
assert_eq!(stored_commitment.last_stored_block, 69);
|
assert_eq!(stored_commitment.last_stored_block, 69);
|
||||||
assert_eq!(stored_commitment.commits, 1);
|
assert_eq!(stored_commitment.commits, 1);
|
||||||
assert_eq!(stored_commitment.last_updated, current_block_number);
|
assert_eq!(stored_commitment.last_updated, 1337);
|
||||||
}
|
}
|
||||||
|
|
||||||
try_offend_validators {
|
try_offend_validators {
|
||||||
let n in 4 .. T::MaxAuthorities::get();
|
let n in 4 .. T::MaxAuthorities::get();
|
||||||
let d in 0 .. T::MaxAuthorities::get().saturating_div(3);
|
|
||||||
|
|
||||||
let session_index = T::ValidatorSet::session_index();
|
let session_index = T::ValidatorSet::session_index();
|
||||||
let mut validators_vec = Vec::new();
|
let mut validators_vec = Vec::new();
|
||||||
@ -128,7 +131,7 @@ benchmarks! {
|
|||||||
let offence_type = OffenceType::CommitmentOffence;
|
let offence_type = OffenceType::CommitmentOffence;
|
||||||
let disabled_bitmap = BitMap::new(T::MaxAuthorities::get());
|
let disabled_bitmap = BitMap::new(T::MaxAuthorities::get());
|
||||||
let mut offence_bitmap = BitMap::new(T::MaxAuthorities::get());
|
let mut offence_bitmap = BitMap::new(T::MaxAuthorities::get());
|
||||||
for i in 0..d {
|
for i in 0 .. (n / 3) {
|
||||||
offence_bitmap.set(i);
|
offence_bitmap.set(i);
|
||||||
}
|
}
|
||||||
}: {
|
}: {
|
||||||
|
|||||||
@ -2,13 +2,10 @@ use sp_runtime::{traits::UniqueSaturatedInto, SaturatedConversion, Saturating};
|
|||||||
use sp_staking::SessionIndex;
|
use sp_staking::SessionIndex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
deserialisations::{
|
AuthIndex, BLOCK_COMMITMENT_DELAY, BalanceOf, BlockCommitment, BlockCommitments, BlockNumberFor, Call, Clap, Config, Decode, Deserialize, Encode, ExternalBlockNumber, H256, LOG_TARGET, NetworkIdOf, RuntimeAppPublic, RuntimeDebug, SubmitTransaction, Vec, deserialisations::{
|
||||||
de_string_to_block_number, de_string_to_block_number_pure, de_string_to_bytes,
|
de_string_to_bytes, de_string_to_h256, de_string_to_block_number, de_string_to_block_number_pure,
|
||||||
de_string_to_h256, de_string_to_vec_of_bytes,
|
de_string_to_vec_of_bytes,
|
||||||
},
|
}
|
||||||
AuthIndex, BalanceOf, BlockCommitment, BlockCommitments, BlockNumberFor, Call, Clap, Config,
|
|
||||||
Decode, Deserialize, Encode, ExternalBlockNumber, NetworkIdOf, RuntimeAppPublic, RuntimeDebug,
|
|
||||||
SubmitTransaction, Vec, BLOCK_COMMITMENT_DELAY, H256, LOG_TARGET,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const NUMBER_OF_TOPICS: usize = 3;
|
const NUMBER_OF_TOPICS: usize = 3;
|
||||||
|
|||||||
@ -140,11 +140,7 @@ pub struct ApplauseDetail<NetworkId, Balance> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<NetworkId, Balance: Default> ApplauseDetail<NetworkId, Balance> {
|
impl<NetworkId, Balance: Default> ApplauseDetail<NetworkId, Balance> {
|
||||||
pub fn new(
|
pub fn new(network_id: NetworkId, block_number: ExternalBlockNumber, max_authorities: usize) -> Self {
|
||||||
network_id: NetworkId,
|
|
||||||
block_number: ExternalBlockNumber,
|
|
||||||
max_authorities: usize,
|
|
||||||
) -> Self {
|
|
||||||
ApplauseDetail {
|
ApplauseDetail {
|
||||||
network_id,
|
network_id,
|
||||||
block_number,
|
block_number,
|
||||||
@ -175,11 +171,7 @@ enum OffchainErr<NetworkId> {
|
|||||||
DifferentEvmResponseTypes,
|
DifferentEvmResponseTypes,
|
||||||
MissingBlockNumber(u32, u32),
|
MissingBlockNumber(u32, u32),
|
||||||
ContradictoryTransactionLogs(u32, u32),
|
ContradictoryTransactionLogs(u32, u32),
|
||||||
ContradictoryBlockMedian(
|
ContradictoryBlockMedian(ExternalBlockNumber, ExternalBlockNumber, ExternalBlockNumber),
|
||||||
ExternalBlockNumber,
|
|
||||||
ExternalBlockNumber,
|
|
||||||
ExternalBlockNumber,
|
|
||||||
),
|
|
||||||
UnparsableRequestBody(Vec<u8>),
|
UnparsableRequestBody(Vec<u8>),
|
||||||
NoEndpointAvailable(NetworkId),
|
NoEndpointAvailable(NetworkId),
|
||||||
StorageRetrievalError(NetworkId),
|
StorageRetrievalError(NetworkId),
|
||||||
@ -511,8 +503,9 @@ pub mod pallet {
|
|||||||
if let Some((network_id, network_data)) =
|
if let Some((network_id, network_data)) =
|
||||||
T::NetworkDataHandler::network_for_block(converted_block)
|
T::NetworkDataHandler::network_for_block(converted_block)
|
||||||
{
|
{
|
||||||
weight.saturating_accrue(T::DbWeight::get().reads_writes(3, 1));
|
weight = weight.saturating_add(T::DbWeight::get().reads_writes(3, 1));
|
||||||
|
|
||||||
|
// TODO: put wrapper function with precalculated weight here
|
||||||
let session_index = T::ValidatorSet::session_index();
|
let session_index = T::ValidatorSet::session_index();
|
||||||
let block_commitments = BlockCommitments::<T>::get(&network_id);
|
let block_commitments = BlockCommitments::<T>::get(&network_id);
|
||||||
let validators = Validators::<T>::get(&session_index);
|
let validators = Validators::<T>::get(&session_index);
|
||||||
@ -575,7 +568,7 @@ pub mod pallet {
|
|||||||
network_id,
|
network_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
weight.saturating_accrue(extra_weight);
|
weight = weight.saturating_add(extra_weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
weight
|
weight
|
||||||
@ -945,11 +938,10 @@ impl<T: Config> Pallet<T> {
|
|||||||
return Err(OffchainErr::NoEndpointAvailable(network_id));
|
return Err(OffchainErr::NoEndpointAvailable(network_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
let (from_block, to_block): (ExternalBlockNumber, ExternalBlockNumber) =
|
let (from_block, to_block): (ExternalBlockNumber, ExternalBlockNumber) = StorageValueRef::persistent(&block_number_key)
|
||||||
StorageValueRef::persistent(&block_number_key)
|
.get()
|
||||||
.get()
|
.map_err(|_| OffchainErr::StorageRetrievalError(network_id))?
|
||||||
.map_err(|_| OffchainErr::StorageRetrievalError(network_id))?
|
.unwrap_or_default();
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
match network_data.network_type {
|
match network_data.network_type {
|
||||||
NetworkType::Evm => {
|
NetworkType::Evm => {
|
||||||
@ -1312,16 +1304,12 @@ impl<T: Config> Pallet<T> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let authorities_len = authorities.len();
|
let authorities_len = authorities.len();
|
||||||
let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::force_from(
|
let bounded_authorities = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(authorities)
|
||||||
authorities,
|
.expect("more than the maximum number of authorities");
|
||||||
Some("slow claps reached maximum number of authorities"),
|
|
||||||
);
|
|
||||||
|
|
||||||
let validators = T::ValidatorSet::validators();
|
let validators = T::ValidatorSet::validators();
|
||||||
let bounded_validators = WeakBoundedVec::<_, T::MaxAuthorities>::force_from(
|
let bounded_validators = WeakBoundedVec::<_, T::MaxAuthorities>::try_from(validators)
|
||||||
validators,
|
.expect("more than the maximum number of validators");
|
||||||
Some("slow claps reached maximum number of validators"),
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(target_session_index) = session_index.checked_sub(T::HistoryDepth::get()) {
|
if let Some(target_session_index) = session_index.checked_sub(T::HistoryDepth::get()) {
|
||||||
Self::clear_history(&target_session_index);
|
Self::clear_history(&target_session_index);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "casper-runtime"
|
name = "casper-runtime"
|
||||||
version = "3.5.38"
|
version = "3.5.37"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
description = "Runtime of the Casper Network"
|
description = "Runtime of the Casper Network"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|||||||
@ -117,11 +117,11 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
spec_name: create_runtime_str!("casper"),
|
spec_name: create_runtime_str!("casper"),
|
||||||
impl_name: create_runtime_str!("casper-svengali"),
|
impl_name: create_runtime_str!("casper-svengali"),
|
||||||
authoring_version: 0,
|
authoring_version: 0,
|
||||||
spec_version: 5,
|
spec_version: 4,
|
||||||
impl_version: 4,
|
impl_version: 3,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
transaction_version: 1,
|
transaction_version: 1,
|
||||||
state_version: 2,
|
state_version: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The BABE epoch configuration at genesis.
|
/// The BABE epoch configuration at genesis.
|
||||||
@ -218,7 +218,10 @@ impl pallet_preimage::Config for Runtime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64;
|
pub const EpochDuration: u64 = prod_or_fast!(
|
||||||
|
EPOCH_DURATION_IN_SLOTS as u64,
|
||||||
|
2 * MINUTES as u64
|
||||||
|
);
|
||||||
pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
|
pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
|
||||||
pub const ReportLongevity: u64 =
|
pub const ReportLongevity: u64 =
|
||||||
BondingDuration::get() as u64 *
|
BondingDuration::get() as u64 *
|
||||||
@ -329,8 +332,14 @@ impl pallet_session::historical::Config for Runtime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub SignedPhase: u32 = EPOCH_DURATION_IN_SLOTS / 4;
|
pub SignedPhase: u32 = prod_or_fast!(
|
||||||
pub UnsignedPhase: u32 = EPOCH_DURATION_IN_SLOTS / 4;
|
EPOCH_DURATION_IN_SLOTS / 4,
|
||||||
|
(1 * MINUTES).min(EpochDuration::get().saturated_into::<u32>() / 2)
|
||||||
|
);
|
||||||
|
pub UnsignedPhase: u32 = prod_or_fast!(
|
||||||
|
EPOCH_DURATION_IN_SLOTS / 4,
|
||||||
|
(1 * MINUTES).min(EpochDuration::get().saturated_into::<u32>() / 2)
|
||||||
|
);
|
||||||
|
|
||||||
// signed config
|
// signed config
|
||||||
pub const SignedMaxSubmissions: u32 = 16;
|
pub const SignedMaxSubmissions: u32 = 16;
|
||||||
@ -1020,7 +1029,6 @@ impl ghost_networks::Config for Runtime {
|
|||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type NetworkId = u64;
|
type NetworkId = u64;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type MaxNetworks = ConstU32<30>;
|
|
||||||
|
|
||||||
type RegisterOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Ghosts>;
|
type RegisterOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Ghosts>;
|
||||||
type UpdateOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Zombies>;
|
type UpdateOrigin = EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Zombies>;
|
||||||
@ -1051,12 +1059,7 @@ impl ghost_claims::Config<CultCollectiveInstance> for Runtime {
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
// will be used in `Perbill::from_parts()`
|
// will be used in `Perbill::from_parts()`
|
||||||
pub const ApplauseThreshold: u32 = if cfg!(feature = "runtime-benchmarks") {
|
pub const ApplauseThreshold: u32 = 500_000_000;
|
||||||
0
|
|
||||||
} else {
|
|
||||||
500_000_000
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const MinAuthoritiesNumber: u32 = 5;
|
pub const MinAuthoritiesNumber: u32 = 5;
|
||||||
pub const SlowClapUnsignedPriority: TransactionPriority = TransactionPriority::MAX;
|
pub const SlowClapUnsignedPriority: TransactionPriority = TransactionPriority::MAX;
|
||||||
pub const SlowClapHistoryDepth: sp_staking::SessionIndex =
|
pub const SlowClapHistoryDepth: sp_staking::SessionIndex =
|
||||||
@ -1080,7 +1083,6 @@ impl ghost_slow_clap::Config for Runtime {
|
|||||||
type UnsignedPriority = SlowClapUnsignedPriority;
|
type UnsignedPriority = SlowClapUnsignedPriority;
|
||||||
type HistoryDepth = SlowClapHistoryDepth;
|
type HistoryDepth = SlowClapHistoryDepth;
|
||||||
type MinAuthoritiesNumber = MinAuthoritiesNumber;
|
type MinAuthoritiesNumber = MinAuthoritiesNumber;
|
||||||
type EpochDuration = EpochDuration;
|
|
||||||
|
|
||||||
type WeightInfo = weights::ghost_slow_clap::WeightInfo<Runtime>;
|
type WeightInfo = weights::ghost_slow_clap::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
@ -1183,10 +1185,7 @@ pub type SignedExtra = (
|
|||||||
|
|
||||||
/// All migrations that will run on the next runtime upgrade.
|
/// All migrations that will run on the next runtime upgrade.
|
||||||
/// Should be cleared after release.
|
/// Should be cleared after release.
|
||||||
pub type Migrations = (
|
pub type Migrations = ();
|
||||||
ghost_networks::migrations::MigrateV0ToV1<Runtime>,
|
|
||||||
ghost_slow_clap::migrations::MigrateV2ToV3<Runtime>,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Unchecked extrinsic type as expected by this runtime.
|
/// Unchecked extrinsic type as expected by this runtime.
|
||||||
pub type UncheckedExtrinsic =
|
pub type UncheckedExtrinsic =
|
||||||
|
|||||||
@ -104,8 +104,4 @@ impl<T: frame_system::Config> ghost_slow_clap::WeightInfo for WeightInfo<T> {
|
|||||||
.saturating_add(T::DbWeight::get().reads(5))
|
.saturating_add(T::DbWeight::get().reads(5))
|
||||||
.saturating_add(T::DbWeight::get().writes(1))
|
.saturating_add(T::DbWeight::get().writes(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_offend_validators(_offenders_len: u32) -> Weight {
|
|
||||||
Default::default()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -211,12 +211,10 @@ fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>, u128)> {
|
|||||||
avg_block_speed: 12_000,
|
avg_block_speed: 12_000,
|
||||||
network_type: ghost_networks::NetworkType::Evm,
|
network_type: ghost_networks::NetworkType::Evm,
|
||||||
gatekeeper: "0xc85129A097773B7F8970a7364c928C05f265E6A1".into(),
|
gatekeeper: "0xc85129A097773B7F8970a7364c928C05f265E6A1".into(),
|
||||||
topic_name: "0x7ab52ec05c331e6257a3d705d6bea6e4c27277351764ad139209e06b203811a6"
|
topic_name: "0x7ab52ec05c331e6257a3d705d6bea6e4c27277351764ad139209e06b203811a6".into(),
|
||||||
.into(),
|
|
||||||
incoming_fee: 69_000_000u32,
|
incoming_fee: 69_000_000u32,
|
||||||
outgoing_fee: 0u32,
|
outgoing_fee: 0u32,
|
||||||
}
|
}.encode(),
|
||||||
.encode(),
|
|
||||||
2048861035254140036511u128,
|
2048861035254140036511u128,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
@ -234,12 +232,10 @@ fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>, u128)> {
|
|||||||
avg_block_speed: 13_000,
|
avg_block_speed: 13_000,
|
||||||
network_type: ghost_networks::NetworkType::Evm,
|
network_type: ghost_networks::NetworkType::Evm,
|
||||||
gatekeeper: "0xA59cB4ff90bE2206121aE61eEB68d0AeC7BA095f".into(),
|
gatekeeper: "0xA59cB4ff90bE2206121aE61eEB68d0AeC7BA095f".into(),
|
||||||
topic_name: "0x7ab52ec05c331e6257a3d705d6bea6e4c27277351764ad139209e06b203811a6"
|
topic_name: "0x7ab52ec05c331e6257a3d705d6bea6e4c27277351764ad139209e06b203811a6".into(),
|
||||||
.into(),
|
|
||||||
incoming_fee: 69_000_000u32,
|
incoming_fee: 69_000_000u32,
|
||||||
outgoing_fee: 0u32,
|
outgoing_fee: 0u32,
|
||||||
}
|
}.encode(),
|
||||||
.encode(),
|
|
||||||
5100000000000000000u128,
|
5100000000000000000u128,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user