Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tipper not working problem #323

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions runtime/khala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ pub use frame_support::{
parameter_types,
traits::{
fungible::HoldConsideration, tokens::nonfungibles::*, AsEnsureOriginWithArg, ConstBool,
ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance,
InstanceFilter, IsInVec, KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing,
OnUnbalanced, Randomness, SortedMembers, WithdrawReasons,
ConstU32, Contains, ContainsLengthBound, Currency, EitherOfDiverse, EqualPrivilegeOnly,
Everything, Imbalance, InstanceFilter, IsInVec, KeyOwnerProofSystem, LinearStoragePrice,
LockIdentifier, Nothing, OnUnbalanced, Randomness, SortedMembers, WithdrawReasons,
},
weights::{
constants::{
Expand Down Expand Up @@ -822,13 +822,31 @@ impl pallet_tips::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type DataDepositPerByte = DataDepositPerByte;
type MaximumReasonLength = MaximumReasonLength;
type Tippers = PhragmenElection;
type Tippers = CouncilMembers;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
}

pub struct CouncilMembers;
impl SortedMembers<AccountId32> for CouncilMembers {
fn sorted_members() -> Vec<AccountId32> {
Council::members()
}
fn count() -> usize {
pallet_collective::Members::<Runtime, CouncilCollective>::decode_len().unwrap_or(0)
}
}
impl ContainsLengthBound for CouncilMembers {
fn max_len() -> usize {
CouncilMaxMembers::get() as usize
}
fn min_len() -> usize {
0
}
}

parameter_types! {
pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain
pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain
Expand Down
52 changes: 36 additions & 16 deletions runtime/phala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ use primitive_types::U256;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, RuntimeDebug,
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdConversion, AccountIdLookup, Block as BlockT, Bounded, ConvertInto,
TrailingZeroInput,
},
transaction_validity::{TransactionSource, TransactionValidity},
AccountId32, ApplyExtrinsicResult, DispatchError, FixedPointNumber, Perbill, Percent, Permill,
Perquintill,
Perquintill, RuntimeDebug,
};
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
prelude::*,
};
use sp_std::{collections::{btree_map::BTreeMap, btree_set::BTreeSet}, prelude::*};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
Expand All @@ -77,10 +80,10 @@ pub use frame_support::{
pallet_prelude::Get,
parameter_types,
traits::{
tokens::nonfungibles::*, fungible::HoldConsideration, AsEnsureOriginWithArg, ConstBool, ConstU32, Contains, Currency,
EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, IsInVec,
KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing, OnUnbalanced, Randomness,
WithdrawReasons, SortedMembers,
fungible::HoldConsideration, tokens::nonfungibles::*, AsEnsureOriginWithArg, ConstBool,
ConstU32, Contains, ContainsLengthBound, Currency, EitherOfDiverse, EqualPrivilegeOnly,
Everything, Imbalance, InstanceFilter, IsInVec, KeyOwnerProofSystem, LinearStoragePrice,
LockIdentifier, Nothing, OnUnbalanced, Randomness, SortedMembers, WithdrawReasons,
},
weights::{
constants::{
Expand All @@ -102,11 +105,11 @@ use xcm::latest::{prelude::*, AssetId as XcmAssetId, Weight as XCMWeight};
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds,
FungiblesAdapter, ParentIsPreset, RelayChainAsNative, NoChecking, MintLocation,
FungiblesAdapter, MintLocation, NoChecking, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
};
use xcm_executor::{Config, XcmExecutor, traits::WithOriginFilter};
use xcm_executor::{traits::WithOriginFilter, Config, XcmExecutor};

pub use subbridge_pallets::{
chainbridge, dynamic_trader::DynamicWeightTrader, fungible_adapter::XTransferAdapter, helper,
Expand Down Expand Up @@ -219,9 +222,7 @@ pub type Executive = frame_executive::Executive<

/// All migrations executed on runtime upgrade as a nested tuple of types implementing
/// `OnRuntimeUpgrade`.
type Migrations = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
);
type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,);

type EnsureRootOrHalfCouncil = EitherOfDiverse<
EnsureRoot<AccountId>,
Expand Down Expand Up @@ -814,13 +815,31 @@ impl pallet_tips::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type DataDepositPerByte = DataDepositPerByte;
type MaximumReasonLength = MaximumReasonLength;
type Tippers = PhragmenElection;
type Tippers = CouncilMembers;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
}

pub struct CouncilMembers;
impl SortedMembers<AccountId32> for CouncilMembers {
fn sorted_members() -> Vec<AccountId32> {
Council::members()
}
fn count() -> usize {
pallet_collective::Members::<Runtime, CouncilCollective>::decode_len().unwrap_or(0)
}
}
impl ContainsLengthBound for CouncilMembers {
fn max_len() -> usize {
CouncilMaxMembers::get() as usize
}
fn min_len() -> usize {
0
}
}

parameter_types! {
pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain
pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain
Expand Down Expand Up @@ -1147,7 +1166,8 @@ impl pallet_treasury::Config for Runtime {
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
>,
AccountId, MaxBalance,
AccountId,
MaxBalance,
>;
}

Expand Down Expand Up @@ -1806,8 +1826,8 @@ impl phala_pallets::PhalaConfig for Runtime {

impl pallet_phat::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type InkCodeSizeLimit = ConstU32<{1024*1024*2}>;
type SidevmCodeSizeLimit = ConstU32<{1024*1024*8}>;
type InkCodeSizeLimit = ConstU32<{ 1024 * 1024 * 2 }>;
type SidevmCodeSizeLimit = ConstU32<{ 1024 * 1024 * 8 }>;
type Currency = Balances;
}
impl pallet_phat_tokenomic::Config for Runtime {
Expand Down
26 changes: 22 additions & 4 deletions runtime/rhala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
parameter_types,
traits::{
fungible::HoldConsideration, tokens::nonfungibles::*, AsEnsureOriginWithArg, ConstBool,
ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance,
InstanceFilter, IsInVec, KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing,
OnUnbalanced, Randomness, SortedMembers, WithdrawReasons,
ConstU32, Contains, ContainsLengthBound, Currency, EitherOfDiverse, EqualPrivilegeOnly,
Everything, Imbalance, InstanceFilter, IsInVec, KeyOwnerProofSystem, LinearStoragePrice,
LockIdentifier, Nothing, OnUnbalanced, Randomness, SortedMembers, WithdrawReasons,
},
weights::{
constants::{
Expand Down Expand Up @@ -815,13 +815,31 @@
type RuntimeEvent = RuntimeEvent;
type DataDepositPerByte = DataDepositPerByte;
type MaximumReasonLength = MaximumReasonLength;
type Tippers = PhragmenElection;
type Tippers = CouncilMembers;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
}

pub struct CouncilMembers;
impl SortedMembers<AccountId32> for CouncilMembers {
fn sorted_members() -> Vec<AccountId32> {
Council::members()
}
fn count() -> usize {
pallet_collective::Members::<Runtime, CouncilCollective>::decode_len().unwrap_or(0)
}
}
impl ContainsLengthBound for CouncilMembers {
fn max_len() -> usize {
CouncilMaxMembers::get() as usize
}
fn min_len() -> usize {
0
}
}

parameter_types! {
pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain
pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain
Expand Down Expand Up @@ -1648,7 +1666,7 @@
// When relayers signing, this address will be included in the EIP712Domain
// As long as the relayer and pallet configured with the same address, EIP712Domain should be recognized properly.
pub DestVerifyingContractAddress: VerifyingContractAddress = primitive_types::H160::from_slice(hex::decode(DEST_VERIFYING_CONTRACT_ADDRESS).ok().unwrap().as_slice());
pub sygUSDLocation: MultiLocation = MultiLocation::new(1, X2(Parachain(1000), GeneralKey { length: 6, data: hex_literal::hex!("7379675553440000000000000000000000000000000000000000000000000000") })).into();

Check warning on line 1669 in runtime/rhala/src/lib.rs

View workflow job for this annotation

GitHub Actions / Cargo test

type `sygUSDLocation` should have an upper camel case name
pub SygmaReserveAccounts: BTreeMap::<XcmAssetId, AccountId> = BTreeMap::from([
(PHALocation::get().into(), SygmaBridgeAccount::get().into()),
(sygUSDLocation::get().into(), SygmaBridgeAccount::get().into())
Expand Down
48 changes: 35 additions & 13 deletions runtime/thala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,27 @@ mod msg_routing;

use codec::{Decode, Encode, MaxEncodedLen};
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use primitive_types::U256;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, RuntimeDebug,
create_runtime_str, generic, impl_opaque_keys,
traits::{
AccountIdConversion, AccountIdLookup, Block as BlockT, Bounded, ConvertInto,
TrailingZeroInput,
},
transaction_validity::{TransactionSource, TransactionValidity},
AccountId32, ApplyExtrinsicResult, DispatchError, FixedPointNumber, Perbill, Percent, Permill,
Perquintill,
Perquintill, RuntimeDebug,
};
use sp_std::{
collections::{btree_map::BTreeMap, btree_set::BTreeSet},
prelude::*,
};
use sp_std::{collections::{btree_map::BTreeMap, btree_set::BTreeSet}, prelude::*};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use static_assertions::const_assert;
use primitive_types::U256;

// A few exports that help ease life for downstream crates.
pub use frame_support::{
Expand All @@ -77,10 +80,10 @@ pub use frame_support::{
pallet_prelude::Get,
parameter_types,
traits::{
tokens::nonfungibles::*, fungible::HoldConsideration, AsEnsureOriginWithArg, ConstBool, ConstU32, Contains, Currency,
EitherOfDiverse, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, IsInVec,
KeyOwnerProofSystem, LinearStoragePrice, LockIdentifier, Nothing, OnUnbalanced, Randomness,
WithdrawReasons, SortedMembers,
fungible::HoldConsideration, tokens::nonfungibles::*, AsEnsureOriginWithArg, ConstBool,
ConstU32, Contains, ContainsLengthBound, Currency, EitherOfDiverse, EqualPrivilegeOnly,
Everything, Imbalance, InstanceFilter, IsInVec, KeyOwnerProofSystem, LinearStoragePrice,
LockIdentifier, Nothing, OnUnbalanced, Randomness, SortedMembers, WithdrawReasons,
},
weights::{
constants::{
Expand All @@ -102,11 +105,11 @@ use xcm::latest::{prelude::*, AssetId as XcmAssetId, Weight as XCMWeight};
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds,
FungiblesAdapter, ParentIsPreset, RelayChainAsNative, NoChecking, MintLocation,
FungiblesAdapter, MintLocation, NoChecking, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
};
use xcm_executor::{Config, XcmExecutor, traits::WithOriginFilter};
use xcm_executor::{traits::WithOriginFilter, Config, XcmExecutor};

use pallet_rmrk_core::{CollectionInfoOf, InstanceInfoOf, PropertyInfoOf, ResourceInfoOf};
use pallet_rmrk_equip::{BaseInfoOf, BoundedThemeOf, PartTypeOf};
Expand All @@ -120,7 +123,7 @@ pub use parachains_common::{rmrk_core, rmrk_equip, uniques, Nonce, *};

pub use pallet_phala_world::{pallet_pw_incubation, pallet_pw_marketplace, pallet_pw_nft_sale};
pub use phala_pallets::{
pallet_base_pool, pallet_computation, pallet_phat, pallet_phat_tokenomic, pallet_mq,
pallet_base_pool, pallet_computation, pallet_mq, pallet_phat, pallet_phat_tokenomic,
pallet_registry, pallet_stake_pool, pallet_stake_pool_v2, pallet_vault,
pallet_wrapped_balances,
};
Expand Down Expand Up @@ -816,13 +819,31 @@ impl pallet_tips::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type DataDepositPerByte = DataDepositPerByte;
type MaximumReasonLength = MaximumReasonLength;
type Tippers = PhragmenElection;
type Tippers = CouncilMembers;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type WeightInfo = pallet_tips::weights::SubstrateWeight<Runtime>;
}

pub struct CouncilMembers;
impl SortedMembers<AccountId32> for CouncilMembers {
fn sorted_members() -> Vec<AccountId32> {
Council::members()
}
fn count() -> usize {
pallet_collective::Members::<Runtime, CouncilCollective>::decode_len().unwrap_or(0)
}
}
impl ContainsLengthBound for CouncilMembers {
fn max_len() -> usize {
CouncilMaxMembers::get() as usize
}
fn min_len() -> usize {
0
}
}

parameter_types! {
pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain
pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain
Expand Down Expand Up @@ -1435,7 +1456,8 @@ impl pallet_treasury::Config for Runtime {
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
>,
AccountId, MaxBalance,
AccountId,
MaxBalance,
>;
}

Expand Down
Loading