Compare commits
No commits in common. "ab37f862f5535b44cf0f19ba9e9a692325417c24" and "352e3519a8f8928ae45ebe77bab93e3d878edd14" have entirely different histories.
ab37f862f5
...
352e3519a8
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-governance"
|
||||
version = "0.3.9"
|
||||
version = "0.3.8"
|
||||
description = "Full-chain and cross-chain governance pallet with early adopter share claims"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
@ -32,7 +32,7 @@ mod benchmarks {
|
||||
let dummy_evm_address = EvmAddress::from(evm_addr_bytes);
|
||||
|
||||
let target_index = max_proof_depth - 1;
|
||||
let claim_package_init = ClaimPackage::<T> {
|
||||
let claim_package_init = ClaimPackage {
|
||||
shares: dummy_shares,
|
||||
merkle_proof: Default::default(),
|
||||
token_id: 0,
|
||||
|
||||
@ -36,6 +36,8 @@ mod benchmarking;
|
||||
mod mock;
|
||||
mod tests;
|
||||
|
||||
const MAX_POSSIBLE_PROOF_DEPTH: u32 = 18;
|
||||
|
||||
type TokenId = u128;
|
||||
type ClaimNonce = u8;
|
||||
type EvmHash = sp_core::H256;
|
||||
@ -142,36 +144,21 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
#[scale_info(skip_type_params(T))]
|
||||
pub struct ClaimPackage<T: pallet::Config> {
|
||||
#[derive(Encode, Decode, Clone, RuntimeDebug, TypeInfo, PartialEq, Eq)]
|
||||
pub struct ClaimPackage<Balance>
|
||||
where
|
||||
Balance: Default + Copy + Clone,
|
||||
{
|
||||
pub index: u32,
|
||||
pub token_id: TokenId,
|
||||
pub shares: BalanceOf<T>,
|
||||
pub merkle_proof: BoundedVec<EvmHash, T::MaxProofDepth>,
|
||||
pub shares: Balance,
|
||||
pub merkle_proof: BoundedVec<EvmHash, ConstU32<MAX_POSSIBLE_PROOF_DEPTH>>,
|
||||
}
|
||||
|
||||
impl<T: pallet::Config> Clone for ClaimPackage<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
index: self.index,
|
||||
token_id: self.token_id,
|
||||
shares: self.shares,
|
||||
merkle_proof: self.merkle_proof.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: pallet::Config> PartialEq for ClaimPackage<T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.index == other.index &&
|
||||
self.token_id == other.token_id &&
|
||||
self.shares == other.shares &&
|
||||
self.merkle_proof == other.merkle_proof
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: pallet::Config> ClaimPackage<T> {
|
||||
impl<Balance> ClaimPackage<Balance>
|
||||
where
|
||||
Balance: Default + Copy + Clone + UniqueSaturatedInto<u128>,
|
||||
{
|
||||
pub fn get_preimage<NetworkId>(
|
||||
&self,
|
||||
evm_address: &EvmAddress,
|
||||
@ -346,7 +333,7 @@ pub mod pallet {
|
||||
pub fn claim(
|
||||
origin: OriginFor<T>,
|
||||
network_id: NetworkIdOf<T>,
|
||||
claim_package: ClaimPackage<T>,
|
||||
claim_package: ClaimPackage<BalanceOf<T>>,
|
||||
evm_address: EvmAddress,
|
||||
evm_signature: EvmSignature,
|
||||
requested_shares: BalanceOf<T>,
|
||||
@ -438,7 +425,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
fn to_ascii_base10<N: PrimInt + UniqueSaturatedInto<u128>>(num: N) -> Vec<u8> {
|
||||
let zero = N::zero();
|
||||
if num == zero { return sp_std::vec![b'0']; }
|
||||
if num == zero { return vec![b'0']; }
|
||||
|
||||
let ten = N::from(10).unwrap_or_else(|| N::zero());
|
||||
let num_u128 = num.unique_saturated_into();
|
||||
@ -532,7 +519,7 @@ impl<T: Config> Pallet<T> {
|
||||
fn verify_merkle_proof(
|
||||
network_id: &NetworkIdOf<T>,
|
||||
preimage: &[u8],
|
||||
claim_package: &ClaimPackage<T>,
|
||||
claim_package: &ClaimPackage<BalanceOf<T>>,
|
||||
) -> DispatchResult {
|
||||
let network_state = NetworkShares::<T>::get(network_id);
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ impl Config for Test {
|
||||
type NetworkDataHandler = Networks;
|
||||
|
||||
type MinimumDonation = ConstU128<69>;
|
||||
type MaxProofDepth = ConstU32<7>;
|
||||
type MaxProofDepth = ConstU32<5>;
|
||||
type MaxPartialClaims = ConstU8<3>;
|
||||
|
||||
type WeightInfo = ();
|
||||
|
||||
@ -87,7 +87,7 @@ fn claim_happy_path() {
|
||||
|item: (u8, &NewTestUser)| -> Result<(usize, Vec<u8>), ()> {
|
||||
let (index, u) = item;
|
||||
|
||||
let tmp_package = ClaimPackage::<Test> {
|
||||
let tmp_package = ClaimPackage {
|
||||
shares: u.allowed_shares,
|
||||
merkle_proof: Default::default(),
|
||||
token_id: u.token_id,
|
||||
@ -118,7 +118,7 @@ fn claim_happy_path() {
|
||||
|
||||
let proof = generate_proof::<SubstrateKeccakHasher, u8>(&merkle_tree, max_index, slot_index as u8);
|
||||
|
||||
let claim_package = ClaimPackage::<Test> {
|
||||
let claim_package = ClaimPackage {
|
||||
shares: current_user.allowed_shares,
|
||||
merkle_proof: BoundedVec::try_from(proof).unwrap(),
|
||||
token_id: current_user.token_id,
|
||||
@ -211,7 +211,7 @@ fn partial_claims_happy_path() {
|
||||
|
||||
|item: (u8, &NewTestUser)| -> Result<(usize, Vec<u8>), ()> {
|
||||
let (index, u) = item;
|
||||
let tmp_package = ClaimPackage::<Test> {
|
||||
let tmp_package = ClaimPackage {
|
||||
shares: u.allowed_shares,
|
||||
merkle_proof: Default::default(),
|
||||
token_id: u.token_id,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-weaver"
|
||||
version = "0.0.12"
|
||||
version = "0.0.11"
|
||||
description = "Weaving a secure cryptographic tapestry across different external chains."
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
use super::*;
|
||||
use frame_benchmarking::v2::*;
|
||||
use frame_system::RawOrigin;
|
||||
use sp_runtime::traits::Saturating;
|
||||
use sp_std::vec;
|
||||
|
||||
use ghost_helpers::networks::NetworkDataBuilder;
|
||||
@ -145,17 +144,6 @@ mod benchmarks {
|
||||
let max_history_depth = a as usize;
|
||||
let (network_id, _, _) = prepare_pallet::<T>(1, None);
|
||||
|
||||
let expected_receiver_bytes = hex::decode("1657090d02985f0cdb41436fe2d5a83a3acb1995d963a698e7e619e927bdcc5e").unwrap();
|
||||
let mut receiver_raw = [0u8; 32];
|
||||
receiver_raw.copy_from_slice(&expected_receiver_bytes);
|
||||
|
||||
let transfer_amount: u64 = 153348847;
|
||||
let receiver = T::AccountId::decode(&mut &receiver_raw[..])
|
||||
.expect("32-byte array must cleanly decode into T::AccountId");
|
||||
|
||||
let existential_deposit = <T as Config>::Currency::minimum_balance();
|
||||
<T as Config>::Currency::set_balance(&receiver, existential_deposit);
|
||||
|
||||
// Real world tx at block #481838
|
||||
// Block https://blockstream.info/block/0000000000000000011bdccb39e19e942a60edffdccd9779653c5b46b337904a
|
||||
// Transaction: https://blockstream.info/tx/4a3fdd9ebb30b9c6df05d4199f8474b2f0c795d1f40a58d0d73342fc666b4a2e
|
||||
@ -334,16 +322,11 @@ mod benchmarks {
|
||||
let pulled_thread_key = thread_proof.get_unique_key(session, network_id);
|
||||
|
||||
assert!(!PulledThreads::<T>::contains_key(&pulled_thread_key));
|
||||
assert_eq!(T::Currency::balance(&receiver), existential_deposit);
|
||||
|
||||
#[extrinsic_call]
|
||||
pull_thread(RawOrigin::None, network_id, session, thread_proof);
|
||||
|
||||
let final_amount = existential_deposit.saturating_add(
|
||||
transfer_amount.unique_saturated_into()
|
||||
);
|
||||
assert!(PulledThreads::<T>::contains_key(&pulled_thread_key));
|
||||
assert_eq!(T::Currency::balance(&receiver), final_amount);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -369,13 +352,8 @@ mod benchmarks {
|
||||
.try_into()
|
||||
.expect("Hex string must be exactly 32 bytes long");
|
||||
|
||||
let transfer_amount: BalanceOf<T> = 420u64.unique_saturated_into();
|
||||
let receiver_account = sp_runtime::AccountId32::from(receiver_32);
|
||||
let receiver_account_t = T::AccountId::decode(&mut &receiver_32[..])
|
||||
.expect("32-byte array must cleanly decode into T::AccountId");
|
||||
|
||||
let existential_deposit = <T as Config>::Currency::minimum_balance();
|
||||
<T as Config>::Currency::set_balance(&receiver_account_t, existential_deposit);
|
||||
let transfer_amount: BalanceOf<T> = 420u64.unique_saturated_into();
|
||||
|
||||
let proof = vec![
|
||||
H256::from_slice(&hex::decode("7d831a4be9e37572687117870c3f96669a66bf07971e4fd705a36a0a4d6365b0").expect("Proof should be valid")),
|
||||
@ -392,7 +370,7 @@ mod benchmarks {
|
||||
.expect("Slot should be valid hex"),
|
||||
)];
|
||||
|
||||
let evm_thread_proof = EvmThreadProof::new(0, 1, receiver_account.into(), transfer_amount, proof, slots);
|
||||
let evm_thread_proof = EvmThreadProof::new(0, 1, receiver_account, transfer_amount, proof, slots);
|
||||
|
||||
let thread_proof = ThreadProof::EvmThreadProof(evm_thread_proof);
|
||||
let pulled_thread_key = thread_proof.get_unique_key(session, network_id);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "casper-runtime"
|
||||
version = "4.0.12"
|
||||
version = "4.0.11"
|
||||
build = "build.rs"
|
||||
description = "Runtime of the Casper Network"
|
||||
edition.workspace = true
|
||||
|
||||
@ -15,7 +15,7 @@ use frame_support::{
|
||||
traits::{
|
||||
fungible::HoldConsideration,
|
||||
tokens::{imbalance::ResolveTo, UnityAssetBalanceConversion},
|
||||
ConstU128, ConstU32, ConstU8, InstanceFilter, KeyOwnerProofSystem,
|
||||
ConstU128, ConstU32, InstanceFilter, KeyOwnerProofSystem,
|
||||
LinearStoragePrice,
|
||||
},
|
||||
};
|
||||
@ -860,7 +860,7 @@ impl ghost_nomination_pools::Config for Runtime {
|
||||
type PalletId = PoolsPalletId;
|
||||
type MaxPointsToBalance = MaxPointsToBalance;
|
||||
type AdminOrigin = EnsureRoot<Self::AccountId>;
|
||||
type WeightInfo = weights::ghost_nomination_pools::WeightInfo<Runtime>;
|
||||
type WeightInfo = weights::ghost_nomination_pools::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
impl ghost_networks::Config for Runtime {
|
||||
@ -887,8 +887,7 @@ impl ghost_governance::Config for Runtime {
|
||||
type Currency = Balances;
|
||||
type NetworkDataHandler = GhostNetworks;
|
||||
type MinimumDonation = ConstU128<{ 6_900 * STRH }>;
|
||||
type MaxProofDepth = ConstU32<18>;
|
||||
type MaxPartialClaims = ConstU8<20>;
|
||||
type MaxProofDepth = ConstU32<20>;
|
||||
|
||||
type WeightInfo = weights::ghost_governance::WeightInfo<Runtime>;
|
||||
}
|
||||
@ -914,7 +913,6 @@ parameter_types! {
|
||||
pub ExodusDkgRoundPeriod: u64 = 50;
|
||||
pub ExodusRemovalLimit: u32 = 64;
|
||||
pub ExodusMaxCursorLen: u32 = 100;
|
||||
pub MinBridgeOut: u128 = 500 * STRH;
|
||||
}
|
||||
|
||||
impl ghost_weaver::Config for Runtime {
|
||||
@ -953,7 +951,6 @@ impl ghost_exodus::Config for Runtime {
|
||||
type DkgRoundPeriod = ExodusDkgRoundPeriod;
|
||||
type RemovalLimit = ExodusRemovalLimit;
|
||||
type MaxCursorLen = ExodusMaxCursorLen;
|
||||
type BaseEvmAmount = MinBridgeOut;
|
||||
|
||||
type WeightInfo = weights::ghost_exodus::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user