Compare commits
7 Commits
3380d16dc9
...
28e8389bfc
Author | SHA1 | Date | |
---|---|---|---|
28e8389bfc | |||
1d826fbf7e | |||
0375bd1434 | |||
b4ef445281 | |||
61056ed162 | |||
b922bf6c20 | |||
fe46566d7e |
@ -17,7 +17,7 @@ homepage.workspace = true
|
||||
[workspace.package]
|
||||
license = "GPL-3.0-only"
|
||||
authors = ["571nky", "57r37ch", "f4750"]
|
||||
version = "0.7.203"
|
||||
version = "0.7.204"
|
||||
edition = "2021"
|
||||
homepage = "https://ghostchain.io"
|
||||
repository = "https://git.ghostchain.io/ghostchain/ghost-node"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-networks"
|
||||
version = "0.1.11"
|
||||
version = "0.1.12"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
|
@ -8,12 +8,17 @@ use sp_runtime::Saturating;
|
||||
|
||||
const MAX_NAME_LEN: u32 = 20;
|
||||
const MAX_ENDPOINT_LEN: u32 = 150;
|
||||
const MAX_ENDPOINT_NUMBER: u32 = 20;
|
||||
|
||||
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
|
||||
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
|
||||
}
|
||||
|
||||
fn prepare_network<T: Config>(n: u32, m: u32) -> (<T as module::Config>::NetworkId, NetworkData) {
|
||||
fn prepare_network<T: Config>(
|
||||
n: u32,
|
||||
m: u32,
|
||||
k: u32,
|
||||
) -> (<T as module::Config>::NetworkId, NetworkData) {
|
||||
let chain_id: <T as module::Config>::NetworkId = Default::default();
|
||||
let chain_id = chain_id.saturating_add((n + m).into());
|
||||
|
||||
@ -27,9 +32,14 @@ fn prepare_network<T: Config>(n: u32, m: u32) -> (<T as module::Config>::Network
|
||||
topic_name.push(i);
|
||||
}
|
||||
|
||||
let mut default_endpoints = sp_std::vec![];
|
||||
for _ in 0..(k as usize) {
|
||||
default_endpoints.push(sp_std::vec![0x69; m as usize]);
|
||||
}
|
||||
|
||||
let network = NetworkData {
|
||||
chain_name: sp_std::vec![0x69; n as usize],
|
||||
default_endpoint: sp_std::vec![0x69; m as usize],
|
||||
default_endpoints,
|
||||
gatekeeper,
|
||||
topic_name,
|
||||
network_type: NetworkType::Evm,
|
||||
@ -69,8 +79,9 @@ benchmarks! {
|
||||
register_network {
|
||||
let i in 1 .. MAX_NAME_LEN;
|
||||
let j in 1 .. MAX_ENDPOINT_LEN;
|
||||
let k in 1 .. MAX_ENDPOINT_NUMBER;
|
||||
|
||||
let (chain_id, network) = prepare_network::<T>(i, j);
|
||||
let (chain_id, network) = prepare_network::<T>(i, j, k);
|
||||
let authority = T::RegisterOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = GhostNetworks::<T>::networks(chain_id.clone());
|
||||
@ -85,7 +96,7 @@ benchmarks! {
|
||||
update_network_name {
|
||||
let n in 1 .. MAX_NAME_LEN;
|
||||
let name = sp_std::vec![0x42; n as usize];
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
@ -99,22 +110,25 @@ benchmarks! {
|
||||
|
||||
update_network_endpoint {
|
||||
let n in 1 .. MAX_ENDPOINT_LEN;
|
||||
let index_to_update = 0u32;
|
||||
let endpoint = sp_std::vec![0x42; n as usize];
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
}: _<T::RuntimeOrigin>(authority, chain_id.clone(), endpoint.clone())
|
||||
}: _<T::RuntimeOrigin>(authority, chain_id.clone(), Some(index_to_update), Some(endpoint.clone()))
|
||||
verify {
|
||||
assert_last_event::<T>(Event::NetworkEndpointUpdated {
|
||||
chain_id: chain_id.clone(), default_endpoint: endpoint,
|
||||
chain_id: chain_id.clone(),
|
||||
index: index_to_update,
|
||||
endpoint,
|
||||
}.into());
|
||||
assert_ne!(GhostNetworks::<T>::networks(chain_id.clone()), prev_network);
|
||||
}
|
||||
|
||||
update_network_finality_delay {
|
||||
let delay = 1337;
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
@ -128,7 +142,7 @@ benchmarks! {
|
||||
|
||||
update_network_rate_limit_delay {
|
||||
let rate_limit = 1337;
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
@ -142,7 +156,7 @@ benchmarks! {
|
||||
|
||||
update_network_block_distance {
|
||||
let block_distance = 1337;
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
@ -156,7 +170,7 @@ benchmarks! {
|
||||
|
||||
update_network_type {
|
||||
let network_type = NetworkType::Utxo;
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
@ -171,7 +185,7 @@ benchmarks! {
|
||||
update_network_gatekeeper {
|
||||
let mut gatekeeper = b"0x".to_vec();
|
||||
for i in 0..40 { gatekeeper.push(i + 1); }
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
@ -185,7 +199,7 @@ benchmarks! {
|
||||
|
||||
update_network_topic_name {
|
||||
let topic_name = b"0x9876543219876543219876543219876543219876543219876543219876543219".to_vec();
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
@ -199,7 +213,7 @@ benchmarks! {
|
||||
|
||||
update_incoming_network_fee {
|
||||
let incoming_fee = 1337;
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
@ -213,7 +227,7 @@ benchmarks! {
|
||||
|
||||
update_outgoing_network_fee {
|
||||
let outgoing_fee = 1337;
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::UpdateOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
@ -226,7 +240,7 @@ benchmarks! {
|
||||
}
|
||||
|
||||
remove_network {
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1);
|
||||
let (chain_id, network) = prepare_network::<T>(1, 1, 1);
|
||||
let authority = T::RemoveOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
|
||||
|
@ -52,7 +52,7 @@ impl Default for NetworkType {
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
||||
pub struct NetworkData {
|
||||
pub chain_name: Vec<u8>,
|
||||
pub default_endpoint: Vec<u8>,
|
||||
pub default_endpoints: Vec<Vec<u8>>,
|
||||
pub gatekeeper: Vec<u8>,
|
||||
pub topic_name: Vec<u8>,
|
||||
pub network_type: NetworkType,
|
||||
@ -168,7 +168,16 @@ pub mod module {
|
||||
},
|
||||
NetworkEndpointUpdated {
|
||||
chain_id: T::NetworkId,
|
||||
default_endpoint: Vec<u8>,
|
||||
index: u32,
|
||||
endpoint: Vec<u8>,
|
||||
},
|
||||
NetworkEndpointRemoved {
|
||||
chain_id: T::NetworkId,
|
||||
index: u32,
|
||||
},
|
||||
NetworkEndpointAdded {
|
||||
chain_id: T::NetworkId,
|
||||
endpoint: Vec<u8>,
|
||||
},
|
||||
NetworkFinalityDelayUpdated {
|
||||
chain_id: T::NetworkId,
|
||||
@ -280,7 +289,10 @@ pub mod module {
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::register_network(
|
||||
network.chain_name.len() as u32,
|
||||
network.default_endpoint.len() as u32,
|
||||
network.default_endpoints
|
||||
.iter()
|
||||
.map(|endpoint| endpoint.len())
|
||||
.sum::<usize>() as u32,
|
||||
))]
|
||||
pub fn register_network(
|
||||
origin: OriginFor<T>,
|
||||
@ -306,15 +318,19 @@ pub mod module {
|
||||
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(T::WeightInfo::update_network_endpoint(
|
||||
default_endpoint.len() as u32
|
||||
maybe_endpoint
|
||||
.as_ref()
|
||||
.map(|endpoint| endpoint.len())
|
||||
.unwrap_or_default() as u32
|
||||
))]
|
||||
pub fn update_network_endpoint(
|
||||
origin: OriginFor<T>,
|
||||
chain_id: T::NetworkId,
|
||||
default_endpoint: Vec<u8>,
|
||||
maybe_index: Option<u32>,
|
||||
maybe_endpoint: Option<Vec<u8>>,
|
||||
) -> DispatchResult {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
Self::do_update_network_endpoint(chain_id, default_endpoint)
|
||||
Self::do_update_network_endpoint(chain_id, maybe_index, maybe_endpoint)
|
||||
}
|
||||
|
||||
#[pallet::call_index(3)]
|
||||
@ -462,19 +478,38 @@ impl<T: Config> Pallet<T> {
|
||||
/// Update existent network default endpoint.
|
||||
pub fn do_update_network_endpoint(
|
||||
chain_id: T::NetworkId,
|
||||
default_endpoint: Vec<u8>,
|
||||
maybe_index: Option<u32>,
|
||||
maybe_endpoint: Option<Vec<u8>>,
|
||||
) -> DispatchResult {
|
||||
Networks::<T>::try_mutate(&chain_id, |maybe_network| -> DispatchResult {
|
||||
ensure!(maybe_network.is_some(), Error::<T>::NetworkDoesNotExist);
|
||||
let net = maybe_network.as_mut().unwrap();
|
||||
net.default_endpoint = default_endpoint.clone();
|
||||
*maybe_network = Some(net.clone());
|
||||
let updated_network = maybe_network.as_mut().unwrap();
|
||||
match (maybe_index, maybe_endpoint) {
|
||||
(Some(index), Some(endpoint)) => {
|
||||
if let Some(previous_endpoint) =
|
||||
updated_network.default_endpoints.get_mut(index as usize)
|
||||
{
|
||||
*previous_endpoint = endpoint.clone();
|
||||
Self::deposit_event(Event::<T>::NetworkEndpointUpdated {
|
||||
chain_id,
|
||||
index,
|
||||
endpoint,
|
||||
});
|
||||
}
|
||||
}
|
||||
(None, Some(endpoint)) => {
|
||||
updated_network.default_endpoints.push(endpoint.clone());
|
||||
Self::deposit_event(Event::<T>::NetworkEndpointAdded { chain_id, endpoint });
|
||||
}
|
||||
(Some(index), None) => {
|
||||
updated_network.default_endpoints.remove(index as usize);
|
||||
Self::deposit_event(Event::<T>::NetworkEndpointRemoved { chain_id, index });
|
||||
}
|
||||
(None, None) => {}
|
||||
}
|
||||
*maybe_network = Some(updated_network.clone());
|
||||
Ok(())
|
||||
})?;
|
||||
Self::deposit_event(Event::<T>::NetworkEndpointUpdated {
|
||||
chain_id,
|
||||
default_endpoint,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,10 @@ 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_endpoints: vec![
|
||||
"https:://some-endpoint.my-server.com/v1/my-super-secret-key".into(),
|
||||
"https:://another-endpoint.my-server.com/v1/my-super-secret-key".into(),
|
||||
],
|
||||
finality_delay: 69,
|
||||
rate_limit_delay: 69,
|
||||
block_distance: 69,
|
||||
@ -113,26 +116,117 @@ fn could_update_network_name_from_authority_account() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_update_network_endpoint_from_authority_account() {
|
||||
fn could_add_network_endpoint_from_authority_account() {
|
||||
ExtBuilder::build().execute_with(|| {
|
||||
let new_endpoint = b"https:://google.com".to_vec();
|
||||
let raw_endpoint: Vec<u8> =
|
||||
"https:://new-endpoint.my-server.com/v1/my-super-secret-key".into();
|
||||
let (chain_id, network) = prepare_network_data();
|
||||
register_and_check_network(chain_id, network.clone());
|
||||
assert_ok!(GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(UpdaterAccount::get()),
|
||||
chain_id,
|
||||
new_endpoint.clone()
|
||||
None,
|
||||
Some(raw_endpoint.clone()),
|
||||
));
|
||||
System::assert_last_event(RuntimeEvent::GhostNetworks(
|
||||
crate::Event::NetworkEndpointAdded {
|
||||
chain_id,
|
||||
endpoint: raw_endpoint.clone(),
|
||||
},
|
||||
));
|
||||
let current_network = Networks::<Test>::get(chain_id).unwrap();
|
||||
assert_eq!(
|
||||
current_network.default_endpoints.len(),
|
||||
network.default_endpoints.len() + 1
|
||||
);
|
||||
assert_eq!(
|
||||
current_network
|
||||
.default_endpoints
|
||||
.last()
|
||||
.cloned()
|
||||
.unwrap_or_default(),
|
||||
raw_endpoint
|
||||
);
|
||||
assert_ne!(&network, ¤t_network);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_remove_network_endpoint_from_authority_account() {
|
||||
ExtBuilder::build().execute_with(|| {
|
||||
let index_to_remove = 0u32;
|
||||
let (chain_id, network) = prepare_network_data();
|
||||
register_and_check_network(chain_id, network.clone());
|
||||
assert_ok!(GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(UpdaterAccount::get()),
|
||||
chain_id,
|
||||
Some(index_to_remove),
|
||||
None,
|
||||
));
|
||||
System::assert_last_event(RuntimeEvent::GhostNetworks(
|
||||
crate::Event::NetworkEndpointRemoved {
|
||||
chain_id,
|
||||
index: index_to_remove,
|
||||
},
|
||||
));
|
||||
let current_network = Networks::<Test>::get(chain_id).unwrap();
|
||||
assert_eq!(
|
||||
current_network.default_endpoints.len(),
|
||||
network.default_endpoints.len() - 1
|
||||
);
|
||||
assert_ne!(
|
||||
current_network
|
||||
.default_endpoints
|
||||
.get(index_to_remove as usize),
|
||||
network.default_endpoints.get(index_to_remove as usize)
|
||||
);
|
||||
assert_ne!(&network, ¤t_network);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_update_network_endpoint_from_authority_account() {
|
||||
ExtBuilder::build().execute_with(|| {
|
||||
let index_to_update = 0u32;
|
||||
let raw_endpoint: Vec<u8> =
|
||||
"https:://new-endpoint.my-server.com/v1/my-super-secret-key".into();
|
||||
let (chain_id, network) = prepare_network_data();
|
||||
register_and_check_network(chain_id, network.clone());
|
||||
assert_ok!(GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(UpdaterAccount::get()),
|
||||
chain_id,
|
||||
Some(index_to_update),
|
||||
Some(raw_endpoint.clone()),
|
||||
));
|
||||
System::assert_last_event(RuntimeEvent::GhostNetworks(
|
||||
crate::Event::NetworkEndpointUpdated {
|
||||
chain_id,
|
||||
default_endpoint: new_endpoint.clone(),
|
||||
index: index_to_update,
|
||||
endpoint: raw_endpoint.clone(),
|
||||
},
|
||||
));
|
||||
let previous_endpoints_len = network.default_endpoints.len();
|
||||
let mut final_network = network.clone();
|
||||
final_network.default_endpoint = new_endpoint;
|
||||
assert_eq!(Networks::<Test>::get(chain_id), Some(final_network.clone()));
|
||||
assert_ne!(network, final_network);
|
||||
if let Some(endpoint_by_index) = final_network
|
||||
.default_endpoints
|
||||
.get_mut(index_to_update as usize)
|
||||
{
|
||||
*endpoint_by_index = raw_endpoint.clone();
|
||||
}
|
||||
let current_network = Networks::<Test>::get(chain_id).unwrap();
|
||||
assert_eq!(
|
||||
current_network.default_endpoints.len(),
|
||||
previous_endpoints_len
|
||||
);
|
||||
assert_eq!(
|
||||
current_network
|
||||
.default_endpoints
|
||||
.get(index_to_update as usize)
|
||||
.cloned()
|
||||
.unwrap_or_default(),
|
||||
raw_endpoint
|
||||
);
|
||||
assert_ne!(&network, &final_network);
|
||||
});
|
||||
}
|
||||
|
||||
@ -365,13 +459,17 @@ fn could_not_update_network_name_from_random_account() {
|
||||
#[test]
|
||||
fn could_not_update_network_endpoint_from_random_account() {
|
||||
ExtBuilder::build().execute_with(|| {
|
||||
let index_to_update = 0u32;
|
||||
let raw_endpoint: Vec<u8> =
|
||||
"https:://new-endpoint.my-server.com/v1/my-super-secret-key".into();
|
||||
let (chain_id, network) = prepare_network_data();
|
||||
register_and_check_network(chain_id, network.clone());
|
||||
assert_err!(
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(RegistererAccount::get()),
|
||||
chain_id,
|
||||
"https:://google.com".into()
|
||||
Some(index_to_update),
|
||||
Some(raw_endpoint.clone()),
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
@ -379,7 +477,8 @@ fn could_not_update_network_endpoint_from_random_account() {
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(RemoverAccount::get()),
|
||||
chain_id,
|
||||
"https:://google.com".into()
|
||||
Some(index_to_update),
|
||||
Some(raw_endpoint.clone()),
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
@ -387,7 +486,83 @@ fn could_not_update_network_endpoint_from_random_account() {
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(RandomAccount::get()),
|
||||
chain_id,
|
||||
"https:://google.com".into()
|
||||
Some(index_to_update),
|
||||
Some(raw_endpoint.clone()),
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
assert_eq!(Networks::<Test>::get(chain_id), Some(network));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_not_add_network_endpoint_from_random_account() {
|
||||
ExtBuilder::build().execute_with(|| {
|
||||
let raw_endpoint: Vec<u8> =
|
||||
"https:://new-endpoint.my-server.com/v1/my-super-secret-key".into();
|
||||
let (chain_id, network) = prepare_network_data();
|
||||
register_and_check_network(chain_id, network.clone());
|
||||
assert_err!(
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(RegistererAccount::get()),
|
||||
chain_id,
|
||||
None,
|
||||
Some(raw_endpoint.clone()),
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
assert_err!(
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(RemoverAccount::get()),
|
||||
chain_id,
|
||||
None,
|
||||
Some(raw_endpoint.clone()),
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
assert_err!(
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(RandomAccount::get()),
|
||||
chain_id,
|
||||
None,
|
||||
Some(raw_endpoint.clone()),
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
assert_eq!(Networks::<Test>::get(chain_id), Some(network));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_not_remove_network_endpoint_from_random_account() {
|
||||
ExtBuilder::build().execute_with(|| {
|
||||
let index_to_remove = 0u32;
|
||||
let (chain_id, network) = prepare_network_data();
|
||||
register_and_check_network(chain_id, network.clone());
|
||||
assert_err!(
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(RegistererAccount::get()),
|
||||
chain_id,
|
||||
Some(index_to_remove),
|
||||
None,
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
assert_err!(
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(RemoverAccount::get()),
|
||||
chain_id,
|
||||
Some(index_to_remove),
|
||||
None,
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
assert_err!(
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(RandomAccount::get()),
|
||||
chain_id,
|
||||
Some(index_to_remove),
|
||||
None,
|
||||
),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
@ -688,7 +863,44 @@ fn could_not_update_endpoint_for_non_existent_network() {
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(UpdaterAccount::get()),
|
||||
chain_id,
|
||||
"https:://google.com".into()
|
||||
Some(0u32),
|
||||
Some("https:://new-endpoint.my-server.com/v1/my-super-secret-key".into()),
|
||||
),
|
||||
crate::Error::<Test>::NetworkDoesNotExist
|
||||
);
|
||||
assert_eq!(Networks::<Test>::get(chain_id), None);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_not_add_endpoint_for_non_existent_network() {
|
||||
ExtBuilder::build().execute_with(|| {
|
||||
let chain_id: u32 = 1;
|
||||
assert_eq!(Networks::<Test>::get(chain_id), None);
|
||||
assert_err!(
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(UpdaterAccount::get()),
|
||||
chain_id,
|
||||
None,
|
||||
Some("https:://new-endpoint.my-server.com/v1/my-super-secret-key".into()),
|
||||
),
|
||||
crate::Error::<Test>::NetworkDoesNotExist
|
||||
);
|
||||
assert_eq!(Networks::<Test>::get(chain_id), None);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn could_not_remove_endpoint_for_non_existent_network() {
|
||||
ExtBuilder::build().execute_with(|| {
|
||||
let chain_id: u32 = 1;
|
||||
assert_eq!(Networks::<Test>::get(chain_id), None);
|
||||
assert_err!(
|
||||
GhostNetworks::update_network_endpoint(
|
||||
RuntimeOrigin::signed(UpdaterAccount::get()),
|
||||
chain_id,
|
||||
Some(0u32),
|
||||
None,
|
||||
),
|
||||
crate::Error::<Test>::NetworkDoesNotExist
|
||||
);
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-slow-clap"
|
||||
version = "0.3.33"
|
||||
version = "0.3.34"
|
||||
description = "Applause protocol for the EVM bridge"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
@ -28,7 +28,7 @@ use sp_runtime::{
|
||||
storage_lock::{StorageLock, Time},
|
||||
HttpError,
|
||||
},
|
||||
traits::{BlockNumberProvider, Convert, Saturating},
|
||||
traits::{BlockNumberProvider, Convert, Saturating, TrailingZeroInput},
|
||||
Perbill, RuntimeAppPublic, RuntimeDebug, SaturatedConversion,
|
||||
};
|
||||
use sp_staking::{
|
||||
@ -692,14 +692,35 @@ impl<T: Config> Pallet<T> {
|
||||
let block_distance_key = Self::create_storage_key(b"block-distance-", &network_id_encoded);
|
||||
let endpoint_key = Self::create_storage_key(b"endpoint-", &network_id_encoded);
|
||||
|
||||
let rpc_endpoint = Self::read_persistent_offchain_storage(
|
||||
&endpoint_key,
|
||||
network_data.default_endpoint.clone(),
|
||||
);
|
||||
let max_block_distance = Self::read_persistent_offchain_storage(
|
||||
&block_distance_key,
|
||||
network_data.block_distance,
|
||||
);
|
||||
let stored_endpoints = Self::read_persistent_offchain_storage(
|
||||
&endpoint_key,
|
||||
network_data.default_endpoints.clone(),
|
||||
);
|
||||
|
||||
let random_seed = sp_io::offchain::random_seed();
|
||||
let random_number = <u32>::decode(
|
||||
&mut TrailingZeroInput::new(random_seed.as_ref())
|
||||
).expect("input is padded with zeroes; qed");
|
||||
|
||||
let rpc_endpoint = if stored_endpoints.len() > 0 {
|
||||
stored_endpoints
|
||||
.iter()
|
||||
.nth((random_number as usize)
|
||||
.checked_rem(stored_endpoints.len())
|
||||
.unwrap_or_default())
|
||||
.expect("stored endpoint should be non empty; qed")
|
||||
} else {
|
||||
network_data.default_endpoints
|
||||
.iter()
|
||||
.nth((random_number as usize)
|
||||
.checked_rem(network_data.default_endpoints.len())
|
||||
.unwrap_or_default())
|
||||
.expect("default endpoint should be non empty; qed")
|
||||
};
|
||||
|
||||
StorageValueRef::persistent(&block_number_key)
|
||||
.mutate(
|
||||
|
@ -22,7 +22,7 @@ fn prepare_evm_network(
|
||||
) -> NetworkData {
|
||||
let network_data = NetworkData {
|
||||
chain_name: "Ethereum".into(),
|
||||
default_endpoint: get_rpc_endpoint(),
|
||||
default_endpoints: get_rpc_endpoints(),
|
||||
finality_delay: 69,
|
||||
rate_limit_delay: 69,
|
||||
block_distance: 69,
|
||||
@ -1041,6 +1041,13 @@ fn get_rpc_endpoint() -> Vec<u8> {
|
||||
b"https://rpc.endpoint.network.com".to_vec()
|
||||
}
|
||||
|
||||
fn get_rpc_endpoints() -> Vec<Vec<u8>> {
|
||||
vec![
|
||||
get_rpc_endpoint(),
|
||||
b"https://other.endpoint.network.com".to_vec(),
|
||||
]
|
||||
}
|
||||
|
||||
fn get_gatekeeper() -> Vec<u8> {
|
||||
b"0x4d224452801ACEd8B2F0aebE155379bb5D594381".to_vec()
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-sudo"
|
||||
version = "0.0.0"
|
||||
version = "0.0.1"
|
||||
description = "Port of the sudo pallet because of dependencies issue"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
@ -1,52 +1,49 @@
|
||||
// This file is part of Substrate.
|
||||
// This file is part of Ghost Network.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Ghost Network is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// Ghost Network is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
//! Autogenerated weights for `pallet_sudo`
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Ghost Network. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `ghost_sudo`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-04-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! DATE: 2025-07-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-anb7yjbi-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
|
||||
//! HOSTNAME: `ghostown`, CPU: `Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("casper-dev")`, DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./target/production/substrate-node
|
||||
// ./target/release/ghost
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=dev
|
||||
// --chain=casper-dev
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --pallet=pallet_sudo
|
||||
// --no-storage-info
|
||||
// --no-median-slopes
|
||||
// --no-min-squares
|
||||
// --pallet=ghost-sudo
|
||||
// --extrinsic=*
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --output=./substrate/frame/sudo/src/weights.rs
|
||||
// --header=./substrate/HEADER-APACHE2
|
||||
// --template=./substrate/.maintain/frame-weight-template.hbs
|
||||
// --header=./file_header.txt
|
||||
// --output=./runtime/casper/src/weights/ghost_sudo.rs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use frame_support::{
|
||||
traits::Get,
|
||||
weights::{Weight, constants::RocksDbWeight},
|
||||
};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for `pallet_sudo`.
|
||||
@ -57,95 +54,103 @@ pub trait WeightInfo {
|
||||
fn remove_key() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `pallet_sudo` using the Substrate node and recommended hardware.
|
||||
/// Weight functions for `ghost_sudo`.
|
||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// Storage: `Sudo::Key` (r:1 w:1)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:1)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn set_key() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 9_486_000 picoseconds.
|
||||
Weight::from_parts(9_663_000, 1517)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
// Minimum execution time: 40_014_000 picoseconds.
|
||||
Weight::from_parts(40_856_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
/// Storage: `Sudo::Key` (r:1 w:0)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:0)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn sudo() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 10_501_000 picoseconds.
|
||||
Weight::from_parts(10_729_000, 1517)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 44_086_000 picoseconds.
|
||||
Weight::from_parts(45_920_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
/// Storage: `Sudo::Key` (r:1 w:0)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:0)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn sudo_as() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 10_742_000 picoseconds.
|
||||
Weight::from_parts(11_003_000, 1517)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 44_106_000 picoseconds.
|
||||
Weight::from_parts(44_650_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
/// Storage: `Sudo::Key` (r:1 w:1)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:1)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn remove_key() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 8_837_000 picoseconds.
|
||||
Weight::from_parts(9_127_000, 1517)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
// Minimum execution time: 36_416_000 picoseconds.
|
||||
Weight::from_parts(37_373_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// Storage: `Sudo::Key` (r:1 w:1)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:1)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn set_key() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 9_486_000 picoseconds.
|
||||
Weight::from_parts(9_663_000, 1517)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
// Minimum execution time: 40_014_000 picoseconds.
|
||||
Weight::from_parts(40_856_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(RocksDbWeight::get().reads(1))
|
||||
.saturating_add(RocksDbWeight::get().writes(1))
|
||||
}
|
||||
/// Storage: `Sudo::Key` (r:1 w:0)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:0)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn sudo() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 10_501_000 picoseconds.
|
||||
Weight::from_parts(10_729_000, 1517)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 44_086_000 picoseconds.
|
||||
Weight::from_parts(45_920_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(RocksDbWeight::get().reads(1))
|
||||
}
|
||||
/// Storage: `Sudo::Key` (r:1 w:0)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:0)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn sudo_as() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 10_742_000 picoseconds.
|
||||
Weight::from_parts(11_003_000, 1517)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 44_106_000 picoseconds.
|
||||
Weight::from_parts(44_650_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(RocksDbWeight::get().reads(1))
|
||||
}
|
||||
/// Storage: `Sudo::Key` (r:1 w:1)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:1)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn remove_key() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 8_837_000 picoseconds.
|
||||
Weight::from_parts(9_127_000, 1517)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
// Minimum execution time: 36_416_000 picoseconds.
|
||||
Weight::from_parts(37_373_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(RocksDbWeight::get().reads(1))
|
||||
.saturating_add(RocksDbWeight::get().writes(1))
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "casper-runtime"
|
||||
version = "3.5.26"
|
||||
version = "3.5.27"
|
||||
build = "build.rs"
|
||||
description = "Runtime of the Casper Network"
|
||||
edition.workspace = true
|
||||
|
@ -1,97 +1,95 @@
|
||||
// This file is part of Substrate.
|
||||
// This file is part of Ghost Network.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Ghost Network is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// Ghost Network is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
//! Autogenerated weights for `pallet_sudo`
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Ghost Network. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `ghost_sudo`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-04-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! DATE: 2025-07-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `runner-anb7yjbi-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
|
||||
//! HOSTNAME: `ghostown`, CPU: `Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("casper-dev")`, DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./target/production/substrate-node
|
||||
// ./target/release/ghost
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=dev
|
||||
// --chain=casper-dev
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --pallet=pallet_sudo
|
||||
// --no-storage-info
|
||||
// --no-median-slopes
|
||||
// --no-min-squares
|
||||
// --pallet=ghost-sudo
|
||||
// --extrinsic=*
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --output=./substrate/frame/sudo/src/weights.rs
|
||||
// --header=./substrate/HEADER-APACHE2
|
||||
// --template=./substrate/.maintain/frame-weight-template.hbs
|
||||
// --header=./file_header.txt
|
||||
// --output=./runtime/casper/src/weights/ghost_sudo.rs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weights for `pallet_sudo` using the Substrate node and recommended hardware.
|
||||
/// Weight functions for `ghost_sudo`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> ghost_sudo::WeightInfo for WeightInfo<T> {
|
||||
/// Storage: `Sudo::Key` (r:1 w:1)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:1)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn set_key() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 9_486_000 picoseconds.
|
||||
Weight::from_parts(9_663_000, 1517)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
// Minimum execution time: 40_014_000 picoseconds.
|
||||
Weight::from_parts(40_856_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
/// Storage: `Sudo::Key` (r:1 w:0)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:0)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn sudo() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 10_501_000 picoseconds.
|
||||
Weight::from_parts(10_729_000, 1517)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 44_086_000 picoseconds.
|
||||
Weight::from_parts(45_920_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
/// Storage: `Sudo::Key` (r:1 w:0)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:0)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn sudo_as() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 10_742_000 picoseconds.
|
||||
Weight::from_parts(11_003_000, 1517)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
// Minimum execution time: 44_106_000 picoseconds.
|
||||
Weight::from_parts(44_650_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
}
|
||||
/// Storage: `Sudo::Key` (r:1 w:1)
|
||||
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
/// Storage: `GhostSudo::Key` (r:1 w:1)
|
||||
/// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
|
||||
fn remove_key() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `165`
|
||||
// Estimated: `1517`
|
||||
// Minimum execution time: 8_837_000 picoseconds.
|
||||
Weight::from_parts(9_127_000, 1517)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
// Minimum execution time: 36_416_000 picoseconds.
|
||||
Weight::from_parts(37_373_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 1517))
|
||||
.saturating_add(T::DbWeight::get().reads(1))
|
||||
.saturating_add(T::DbWeight::get().writes(1))
|
||||
}
|
||||
}
|
||||
|
@ -200,6 +200,15 @@ if [[ $HARD_RESET = true ]]; then
|
||||
# echo "[+] fetching the latest ghost-node source code"
|
||||
# git switch main
|
||||
# git pull origin main
|
||||
|
||||
# rustc version control, this works fine
|
||||
# cargo --version | cut -d'.' -f2, if higher then do
|
||||
# rustup default 1.83.0
|
||||
# rustup target add wasm32-unknown-unknown --toolchain 1.83.0-x86_64-unknown-linux-gnu
|
||||
# rustup component add rust-src --toolchain 1.83.0-x86_64-unknown-linux-gnu
|
||||
#
|
||||
# I think we need to do clean before recompilation
|
||||
# cargo clean
|
||||
|
||||
cd $PROJECT_FOLDER
|
||||
echo "[+] starting build in 3 seconds..."
|
||||
|
@ -176,7 +176,9 @@ fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>)> {
|
||||
vec![
|
||||
(1, ghost_networks::NetworkData {
|
||||
chain_name: "ethereum-mainnet".into(),
|
||||
default_endpoint: "https://nd-422-757-666.p2pify.com/0a9d79d93fb2f4a4b1e04695da2b77a7/".into(),
|
||||
default_endpoints: vec![
|
||||
"https://nd-422-757-666.p2pify.com/0a9d79d93fb2f4a4b1e04695da2b77a7/".into(),
|
||||
],
|
||||
finality_delay: 40u64,
|
||||
rate_limit_delay: 1_000u64,
|
||||
block_distance: 50u64,
|
||||
@ -188,7 +190,9 @@ fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>)> {
|
||||
}.encode()),
|
||||
(56, ghost_networks::NetworkData {
|
||||
chain_name: "bnb-mainnet".into(),
|
||||
default_endpoint: "https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab/".into(),
|
||||
default_endpoints: vec![
|
||||
"https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab/".into(),
|
||||
],
|
||||
finality_delay: 20u64,
|
||||
rate_limit_delay: 1_000u64,
|
||||
block_distance: 50u64,
|
||||
|
Loading…
Reference in New Issue
Block a user