Compare commits

..

7 Commits

Author SHA1 Message Date
28e8389bfc
fix struct field name in chain-spec
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2025-07-29 12:44:01 +03:00
1d826fbf7e
rotate endpoints on each offchain worker exection
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
2025-07-29 12:42:36 +03:00
0375bd1434
preparation for the benchmarking of upgraded ghost-networks pallet
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2025-07-28 23:53:11 +03:00
b4ef445281
make ability to have multiple default endpoints for the network
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2025-07-28 23:34:42 +03:00
61056ed162
recomendations for rustc compilation and cargo usage for automation script
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2025-07-28 16:28:23 +03:00
b922bf6c20
update weights for casper runtime
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2025-07-28 16:20:06 +03:00
fe46566d7e
insert measured weights for ghost-sudo
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
2025-07-28 16:18:24 +03:00
14 changed files with 484 additions and 179 deletions

View File

@ -17,7 +17,7 @@ homepage.workspace = true
[workspace.package] [workspace.package]
license = "GPL-3.0-only" license = "GPL-3.0-only"
authors = ["571nky", "57r37ch", "f4750"] authors = ["571nky", "57r37ch", "f4750"]
version = "0.7.203" version = "0.7.204"
edition = "2021" edition = "2021"
homepage = "https://ghostchain.io" homepage = "https://ghostchain.io"
repository = "https://git.ghostchain.io/ghostchain/ghost-node" repository = "https://git.ghostchain.io/ghostchain/ghost-node"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ghost-networks" name = "ghost-networks"
version = "0.1.11" version = "0.1.12"
license.workspace = true license.workspace = true
authors.workspace = true authors.workspace = true
edition.workspace = true edition.workspace = true

View File

@ -8,12 +8,17 @@ use sp_runtime::Saturating;
const MAX_NAME_LEN: u32 = 20; const MAX_NAME_LEN: u32 = 20;
const MAX_ENDPOINT_LEN: u32 = 150; const MAX_ENDPOINT_LEN: u32 = 150;
const MAX_ENDPOINT_NUMBER: u32 = 20;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) { fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into()); 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: <T as module::Config>::NetworkId = Default::default();
let chain_id = chain_id.saturating_add((n + m).into()); 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); 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 { let network = NetworkData {
chain_name: sp_std::vec![0x69; n as usize], chain_name: sp_std::vec![0x69; n as usize],
default_endpoint: sp_std::vec![0x69; m as usize], default_endpoints,
gatekeeper, gatekeeper,
topic_name, topic_name,
network_type: NetworkType::Evm, network_type: NetworkType::Evm,
@ -69,8 +79,9 @@ benchmarks! {
register_network { register_network {
let i in 1 .. MAX_NAME_LEN; let i in 1 .. MAX_NAME_LEN;
let j in 1 .. MAX_ENDPOINT_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() let authority = T::RegisterOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = GhostNetworks::<T>::networks(chain_id.clone()); let prev_network = GhostNetworks::<T>::networks(chain_id.clone());
@ -85,7 +96,7 @@ benchmarks! {
update_network_name { update_network_name {
let n in 1 .. MAX_NAME_LEN; let n in 1 .. MAX_NAME_LEN;
let name = sp_std::vec![0x42; n as usize]; 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
@ -99,22 +110,25 @@ benchmarks! {
update_network_endpoint { update_network_endpoint {
let n in 1 .. MAX_ENDPOINT_LEN; let n in 1 .. MAX_ENDPOINT_LEN;
let index_to_update = 0u32;
let endpoint = sp_std::vec![0x42; n as usize]; 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; 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 { verify {
assert_last_event::<T>(Event::NetworkEndpointUpdated { 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()); }.into());
assert_ne!(GhostNetworks::<T>::networks(chain_id.clone()), prev_network); assert_ne!(GhostNetworks::<T>::networks(chain_id.clone()), prev_network);
} }
update_network_finality_delay { update_network_finality_delay {
let delay = 1337; 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
@ -128,7 +142,7 @@ benchmarks! {
update_network_rate_limit_delay { update_network_rate_limit_delay {
let rate_limit = 1337; 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
@ -142,7 +156,7 @@ benchmarks! {
update_network_block_distance { update_network_block_distance {
let block_distance = 1337; 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
@ -156,7 +170,7 @@ benchmarks! {
update_network_type { update_network_type {
let network_type = NetworkType::Utxo; 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
@ -171,7 +185,7 @@ benchmarks! {
update_network_gatekeeper { update_network_gatekeeper {
let mut gatekeeper = b"0x".to_vec(); let mut gatekeeper = b"0x".to_vec();
for i in 0..40 { gatekeeper.push(i + 1); } 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
@ -185,7 +199,7 @@ benchmarks! {
update_network_topic_name { update_network_topic_name {
let topic_name = b"0x9876543219876543219876543219876543219876543219876543219876543219".to_vec(); 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
@ -199,7 +213,7 @@ benchmarks! {
update_incoming_network_fee { update_incoming_network_fee {
let incoming_fee = 1337; 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
@ -213,7 +227,7 @@ benchmarks! {
update_outgoing_network_fee { update_outgoing_network_fee {
let outgoing_fee = 1337; 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() let authority = T::UpdateOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;
@ -226,7 +240,7 @@ benchmarks! {
} }
remove_network { 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() let authority = T::RemoveOrigin::try_successful_origin()
.map_err(|_| BenchmarkError::Weightless)?; .map_err(|_| BenchmarkError::Weightless)?;
let prev_network = create_network::<T>(chain_id.clone(), network.clone())?; let prev_network = create_network::<T>(chain_id.clone(), network.clone())?;

View File

@ -52,7 +52,7 @@ impl Default for NetworkType {
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub struct NetworkData { pub struct NetworkData {
pub chain_name: Vec<u8>, pub chain_name: Vec<u8>,
pub default_endpoint: Vec<u8>, pub default_endpoints: Vec<Vec<u8>>,
pub gatekeeper: Vec<u8>, pub gatekeeper: Vec<u8>,
pub topic_name: Vec<u8>, pub topic_name: Vec<u8>,
pub network_type: NetworkType, pub network_type: NetworkType,
@ -168,7 +168,16 @@ pub mod module {
}, },
NetworkEndpointUpdated { NetworkEndpointUpdated {
chain_id: T::NetworkId, 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 { NetworkFinalityDelayUpdated {
chain_id: T::NetworkId, chain_id: T::NetworkId,
@ -280,7 +289,10 @@ pub mod module {
#[pallet::call_index(0)] #[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::register_network( #[pallet::weight(T::WeightInfo::register_network(
network.chain_name.len() as u32, 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( pub fn register_network(
origin: OriginFor<T>, origin: OriginFor<T>,
@ -306,15 +318,19 @@ pub mod module {
#[pallet::call_index(2)] #[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::update_network_endpoint( #[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( pub fn update_network_endpoint(
origin: OriginFor<T>, origin: OriginFor<T>,
chain_id: T::NetworkId, chain_id: T::NetworkId,
default_endpoint: Vec<u8>, maybe_index: Option<u32>,
maybe_endpoint: Option<Vec<u8>>,
) -> DispatchResult { ) -> DispatchResult {
T::UpdateOrigin::ensure_origin_or_root(origin)?; 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)] #[pallet::call_index(3)]
@ -462,19 +478,38 @@ impl<T: Config> Pallet<T> {
/// Update existent network default endpoint. /// Update existent network default endpoint.
pub fn do_update_network_endpoint( pub fn do_update_network_endpoint(
chain_id: T::NetworkId, chain_id: T::NetworkId,
default_endpoint: Vec<u8>, maybe_index: Option<u32>,
maybe_endpoint: Option<Vec<u8>>,
) -> DispatchResult { ) -> DispatchResult {
Networks::<T>::try_mutate(&chain_id, |maybe_network| -> DispatchResult { Networks::<T>::try_mutate(&chain_id, |maybe_network| -> DispatchResult {
ensure!(maybe_network.is_some(), Error::<T>::NetworkDoesNotExist); ensure!(maybe_network.is_some(), Error::<T>::NetworkDoesNotExist);
let net = maybe_network.as_mut().unwrap(); let updated_network = maybe_network.as_mut().unwrap();
net.default_endpoint = default_endpoint.clone(); match (maybe_index, maybe_endpoint) {
*maybe_network = Some(net.clone()); (Some(index), Some(endpoint)) => {
Ok(()) if let Some(previous_endpoint) =
})?; updated_network.default_endpoints.get_mut(index as usize)
{
*previous_endpoint = endpoint.clone();
Self::deposit_event(Event::<T>::NetworkEndpointUpdated { Self::deposit_event(Event::<T>::NetworkEndpointUpdated {
chain_id, chain_id,
default_endpoint, 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(())
})?;
Ok(()) Ok(())
} }

View File

@ -12,7 +12,10 @@ fn prepare_network_data() -> (u32, NetworkData) {
1u32, 1u32,
NetworkData { NetworkData {
chain_name: "Ethereum".into(), 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, finality_delay: 69,
rate_limit_delay: 69, rate_limit_delay: 69,
block_distance: 69, block_distance: 69,
@ -113,26 +116,117 @@ fn could_update_network_name_from_authority_account() {
} }
#[test] #[test]
fn could_update_network_endpoint_from_authority_account() { fn could_add_network_endpoint_from_authority_account() {
ExtBuilder::build().execute_with(|| { 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(); let (chain_id, network) = prepare_network_data();
register_and_check_network(chain_id, network.clone()); register_and_check_network(chain_id, network.clone());
assert_ok!(GhostNetworks::update_network_endpoint( assert_ok!(GhostNetworks::update_network_endpoint(
RuntimeOrigin::signed(UpdaterAccount::get()), RuntimeOrigin::signed(UpdaterAccount::get()),
chain_id, 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, &current_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, &current_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( System::assert_last_event(RuntimeEvent::GhostNetworks(
crate::Event::NetworkEndpointUpdated { crate::Event::NetworkEndpointUpdated {
chain_id, 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(); let mut final_network = network.clone();
final_network.default_endpoint = new_endpoint; if let Some(endpoint_by_index) = final_network
assert_eq!(Networks::<Test>::get(chain_id), Some(final_network.clone())); .default_endpoints
assert_ne!(network, final_network); .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] #[test]
fn could_not_update_network_endpoint_from_random_account() { fn could_not_update_network_endpoint_from_random_account() {
ExtBuilder::build().execute_with(|| { 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(); let (chain_id, network) = prepare_network_data();
register_and_check_network(chain_id, network.clone()); register_and_check_network(chain_id, network.clone());
assert_err!( assert_err!(
GhostNetworks::update_network_endpoint( GhostNetworks::update_network_endpoint(
RuntimeOrigin::signed(RegistererAccount::get()), RuntimeOrigin::signed(RegistererAccount::get()),
chain_id, chain_id,
"https:://google.com".into() Some(index_to_update),
Some(raw_endpoint.clone()),
), ),
DispatchError::BadOrigin DispatchError::BadOrigin
); );
@ -379,7 +477,8 @@ fn could_not_update_network_endpoint_from_random_account() {
GhostNetworks::update_network_endpoint( GhostNetworks::update_network_endpoint(
RuntimeOrigin::signed(RemoverAccount::get()), RuntimeOrigin::signed(RemoverAccount::get()),
chain_id, chain_id,
"https:://google.com".into() Some(index_to_update),
Some(raw_endpoint.clone()),
), ),
DispatchError::BadOrigin DispatchError::BadOrigin
); );
@ -387,7 +486,83 @@ fn could_not_update_network_endpoint_from_random_account() {
GhostNetworks::update_network_endpoint( GhostNetworks::update_network_endpoint(
RuntimeOrigin::signed(RandomAccount::get()), RuntimeOrigin::signed(RandomAccount::get()),
chain_id, 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 DispatchError::BadOrigin
); );
@ -688,7 +863,44 @@ fn could_not_update_endpoint_for_non_existent_network() {
GhostNetworks::update_network_endpoint( GhostNetworks::update_network_endpoint(
RuntimeOrigin::signed(UpdaterAccount::get()), RuntimeOrigin::signed(UpdaterAccount::get()),
chain_id, 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 crate::Error::<Test>::NetworkDoesNotExist
); );

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ghost-slow-clap" name = "ghost-slow-clap"
version = "0.3.33" version = "0.3.34"
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

View File

@ -28,7 +28,7 @@ use sp_runtime::{
storage_lock::{StorageLock, Time}, storage_lock::{StorageLock, Time},
HttpError, HttpError,
}, },
traits::{BlockNumberProvider, Convert, Saturating}, traits::{BlockNumberProvider, Convert, Saturating, TrailingZeroInput},
Perbill, RuntimeAppPublic, RuntimeDebug, SaturatedConversion, Perbill, RuntimeAppPublic, RuntimeDebug, SaturatedConversion,
}; };
use sp_staking::{ 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 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 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( let max_block_distance = Self::read_persistent_offchain_storage(
&block_distance_key, &block_distance_key,
network_data.block_distance, 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) StorageValueRef::persistent(&block_number_key)
.mutate( .mutate(

View File

@ -22,7 +22,7 @@ fn prepare_evm_network(
) -> NetworkData { ) -> NetworkData {
let network_data = NetworkData { let network_data = NetworkData {
chain_name: "Ethereum".into(), chain_name: "Ethereum".into(),
default_endpoint: get_rpc_endpoint(), default_endpoints: get_rpc_endpoints(),
finality_delay: 69, finality_delay: 69,
rate_limit_delay: 69, rate_limit_delay: 69,
block_distance: 69, block_distance: 69,
@ -1041,6 +1041,13 @@ fn get_rpc_endpoint() -> Vec<u8> {
b"https://rpc.endpoint.network.com".to_vec() 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> { fn get_gatekeeper() -> Vec<u8> {
b"0x4d224452801ACEd8B2F0aebE155379bb5D594381".to_vec() b"0x4d224452801ACEd8B2F0aebE155379bb5D594381".to_vec()
} }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ghost-sudo" name = "ghost-sudo"
version = "0.0.0" version = "0.0.1"
description = "Port of the sudo pallet because of dependencies issue" description = "Port of the sudo pallet because of dependencies issue"
license.workspace = true license.workspace = true
authors.workspace = true authors.workspace = true

View File

@ -1,52 +1,49 @@
// This file is part of Substrate. // This file is part of Ghost Network.
// Copyright (C) Parity Technologies (UK) Ltd. // Ghost Network is free software: you can redistribute it and/or modify
// SPDX-License-Identifier: Apache-2.0 // 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"); // Ghost Network is distributed in the hope that it will be useful,
// you may not use this file except in compliance with the License. // but WITHOUT ANY WARRANTY; without even the implied warranty of
// You may obtain a copy of the License at // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// // GNU General Public License for more details.
// 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.
//! 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 //! 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` //! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-anb7yjbi-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! HOSTNAME: `ghostown`, CPU: `Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("casper-dev")`, DB CACHE: 1024
// Executed Command: // Executed Command:
// ./target/production/substrate-node // ./target/release/ghost
// benchmark // benchmark
// pallet // pallet
// --chain=dev // --chain=casper-dev
// --steps=50 // --steps=50
// --repeat=20 // --repeat=20
// --pallet=pallet_sudo // --pallet=ghost-sudo
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --extrinsic=* // --extrinsic=*
// --wasm-execution=compiled // --wasm-execution=compiled
// --heap-pages=4096 // --heap-pages=4096
// --output=./substrate/frame/sudo/src/weights.rs // --header=./file_header.txt
// --header=./substrate/HEADER-APACHE2 // --output=./runtime/casper/src/weights/ghost_sudo.rs
// --template=./substrate/.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)] #![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
#![allow(missing_docs)] #![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; use core::marker::PhantomData;
/// Weight functions needed for `pallet_sudo`. /// Weight functions needed for `pallet_sudo`.
@ -57,95 +54,103 @@ pub trait WeightInfo {
fn remove_key() -> Weight; 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>); pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> { impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Storage: `Sudo::Key` (r:1 w:1) /// Storage: `GhostSudo::Key` (r:1 w:1)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn set_key() -> Weight { fn set_key() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 9_486_000 picoseconds. // Minimum execution time: 40_014_000 picoseconds.
Weight::from_parts(9_663_000, 1517) Weight::from_parts(40_856_000, 0)
.saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
} }
/// Storage: `Sudo::Key` (r:1 w:0) /// Storage: `GhostSudo::Key` (r:1 w:0)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn sudo() -> Weight { fn sudo() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 10_501_000 picoseconds. // Minimum execution time: 44_086_000 picoseconds.
Weight::from_parts(10_729_000, 1517) Weight::from_parts(45_920_000, 0)
.saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
} }
/// Storage: `Sudo::Key` (r:1 w:0) /// Storage: `GhostSudo::Key` (r:1 w:0)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn sudo_as() -> Weight { fn sudo_as() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 10_742_000 picoseconds. // Minimum execution time: 44_106_000 picoseconds.
Weight::from_parts(11_003_000, 1517) Weight::from_parts(44_650_000, 0)
.saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
} }
/// Storage: `Sudo::Key` (r:1 w:1) /// Storage: `GhostSudo::Key` (r:1 w:1)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn remove_key() -> Weight { fn remove_key() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 8_837_000 picoseconds. // Minimum execution time: 36_416_000 picoseconds.
Weight::from_parts(9_127_000, 1517) Weight::from_parts(37_373_000, 0)
.saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
} }
} }
// For backwards compatibility and tests. // For backwards compatibility and tests.
impl WeightInfo for () { impl WeightInfo for () {
/// Storage: `Sudo::Key` (r:1 w:1) /// Storage: `GhostSudo::Key` (r:1 w:1)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn set_key() -> Weight { fn set_key() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 9_486_000 picoseconds. // Minimum execution time: 40_014_000 picoseconds.
Weight::from_parts(9_663_000, 1517) Weight::from_parts(40_856_000, 0)
.saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
} }
/// Storage: `Sudo::Key` (r:1 w:0) /// Storage: `GhostSudo::Key` (r:1 w:0)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn sudo() -> Weight { fn sudo() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 10_501_000 picoseconds. // Minimum execution time: 44_086_000 picoseconds.
Weight::from_parts(10_729_000, 1517) Weight::from_parts(45_920_000, 0)
.saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(RocksDbWeight::get().reads(1))
} }
/// Storage: `Sudo::Key` (r:1 w:0) /// Storage: `GhostSudo::Key` (r:1 w:0)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn sudo_as() -> Weight { fn sudo_as() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 10_742_000 picoseconds. // Minimum execution time: 44_106_000 picoseconds.
Weight::from_parts(11_003_000, 1517) Weight::from_parts(44_650_000, 0)
.saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(RocksDbWeight::get().reads(1))
} }
/// Storage: `Sudo::Key` (r:1 w:1) /// Storage: `GhostSudo::Key` (r:1 w:1)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn remove_key() -> Weight { fn remove_key() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 8_837_000 picoseconds. // Minimum execution time: 36_416_000 picoseconds.
Weight::from_parts(9_127_000, 1517) Weight::from_parts(37_373_000, 0)
.saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
} }
} }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "casper-runtime" name = "casper-runtime"
version = "3.5.26" version = "3.5.27"
build = "build.rs" build = "build.rs"
description = "Runtime of the Casper Network" description = "Runtime of the Casper Network"
edition.workspace = true edition.workspace = true

View File

@ -1,97 +1,95 @@
// This file is part of Substrate. // This file is part of Ghost Network.
// Copyright (C) Parity Technologies (UK) Ltd. // Ghost Network is free software: you can redistribute it and/or modify
// SPDX-License-Identifier: Apache-2.0 // 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"); // Ghost Network is distributed in the hope that it will be useful,
// you may not use this file except in compliance with the License. // but WITHOUT ANY WARRANTY; without even the implied warranty of
// You may obtain a copy of the License at // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// // GNU General Public License for more details.
// 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.
//! 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 //! 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` //! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-anb7yjbi-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! HOSTNAME: `ghostown`, CPU: `Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("casper-dev")`, DB CACHE: 1024
// Executed Command: // Executed Command:
// ./target/production/substrate-node // ./target/release/ghost
// benchmark // benchmark
// pallet // pallet
// --chain=dev // --chain=casper-dev
// --steps=50 // --steps=50
// --repeat=20 // --repeat=20
// --pallet=pallet_sudo // --pallet=ghost-sudo
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --extrinsic=* // --extrinsic=*
// --wasm-execution=compiled // --wasm-execution=compiled
// --heap-pages=4096 // --heap-pages=4096
// --output=./substrate/frame/sudo/src/weights.rs // --header=./file_header.txt
// --header=./substrate/HEADER-APACHE2 // --output=./runtime/casper/src/weights/ghost_sudo.rs
// --template=./substrate/.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)] #![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
#![allow(missing_docs)] #![allow(missing_docs)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData; 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>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> ghost_sudo::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> ghost_sudo::WeightInfo for WeightInfo<T> {
/// Storage: `Sudo::Key` (r:1 w:1) /// Storage: `GhostSudo::Key` (r:1 w:1)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn set_key() -> Weight { fn set_key() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 9_486_000 picoseconds. // Minimum execution time: 40_014_000 picoseconds.
Weight::from_parts(9_663_000, 1517) Weight::from_parts(40_856_000, 0)
.saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
} }
/// Storage: `Sudo::Key` (r:1 w:0) /// Storage: `GhostSudo::Key` (r:1 w:0)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn sudo() -> Weight { fn sudo() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 10_501_000 picoseconds. // Minimum execution time: 44_086_000 picoseconds.
Weight::from_parts(10_729_000, 1517) Weight::from_parts(45_920_000, 0)
.saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
} }
/// Storage: `Sudo::Key` (r:1 w:0) /// Storage: `GhostSudo::Key` (r:1 w:0)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn sudo_as() -> Weight { fn sudo_as() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 10_742_000 picoseconds. // Minimum execution time: 44_106_000 picoseconds.
Weight::from_parts(11_003_000, 1517) Weight::from_parts(44_650_000, 0)
.saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
} }
/// Storage: `Sudo::Key` (r:1 w:1) /// Storage: `GhostSudo::Key` (r:1 w:1)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) /// Proof: `GhostSudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn remove_key() -> Weight { fn remove_key() -> Weight {
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `165` // Measured: `165`
// Estimated: `1517` // Estimated: `1517`
// Minimum execution time: 8_837_000 picoseconds. // Minimum execution time: 36_416_000 picoseconds.
Weight::from_parts(9_127_000, 1517) Weight::from_parts(37_373_000, 0)
.saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
} }
} }

View File

@ -201,6 +201,15 @@ if [[ $HARD_RESET = true ]]; then
# git switch main # git switch main
# git pull origin 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 cd $PROJECT_FOLDER
echo "[+] starting build in 3 seconds..." echo "[+] starting build in 3 seconds..."
sleep 3 sleep 3

View File

@ -176,7 +176,9 @@ fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>)> {
vec![ vec![
(1, ghost_networks::NetworkData { (1, ghost_networks::NetworkData {
chain_name: "ethereum-mainnet".into(), 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, finality_delay: 40u64,
rate_limit_delay: 1_000u64, rate_limit_delay: 1_000u64,
block_distance: 50u64, block_distance: 50u64,
@ -188,7 +190,9 @@ fn casper_testnet_evm_networks() -> Vec<(u32, Vec<u8>)> {
}.encode()), }.encode()),
(56, ghost_networks::NetworkData { (56, ghost_networks::NetworkData {
chain_name: "bnb-mainnet".into(), 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, finality_delay: 20u64,
rate_limit_delay: 1_000u64, rate_limit_delay: 1_000u64,
block_distance: 50u64, block_distance: 50u64,