difftreelog
sync opan and quartz runtimes
in: master
3 files changed
README.mddiffbeforeafterboth421. Install Rust:421. Install Rust:434344```bash44```bash45sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang45sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang make46curl https://sh.rustup.rs -sSf | sh46curl https://sh.rustup.rs -sSf | sh47```47```4848runtime/opal/src/lib.rsdiffbeforeafterboth29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;30use sp_runtime::DispatchError;31use fp_self_contained::*;31use fp_self_contained::*;32use sp_runtime::traits::{Member};33// #[cfg(any(feature = "std", test))]32// #[cfg(any(feature = "std", test))]34// pub use sp_runtime::BuildStorage;33// pub use sp_runtime::BuildStorage;353436use sp_runtime::{35use sp_runtime::{37 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,36 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,38 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero},37 traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, AccountIdConversion, Zero, Member},39 transaction_validity::{TransactionSource, TransactionValidity},38 transaction_validity::{TransactionSource, TransactionValidity},40 ApplyExtrinsicResult, RuntimeAppPublic,39 ApplyExtrinsicResult, RuntimeAppPublic,41};40};runtime/quartz/src/lib.rsdiffbeforeafterboth28use sp_api::impl_runtime_apis;28use sp_api::impl_runtime_apis;29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};29use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};30use sp_runtime::DispatchError;30use sp_runtime::DispatchError;31use fp_self_contained::*;31// #[cfg(any(feature = "std", test))]32// #[cfg(any(feature = "std", test))]32// pub use sp_runtime::BuildStorage;33// pub use sp_runtime::BuildStorage;333450pub use pallet_balances::Call as BalancesCall;51pub use pallet_balances::Call as BalancesCall;51pub use pallet_evm::{52pub use pallet_evm::{52 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,53 EnsureAddressTruncated, HashedAddressMapping, Runner, account::CrossAccountId as _,54 OnMethodCall, Account as EVMAccount, FeeCalculator, GasWeightMapping,53};55};54pub use frame_support::{56pub use frame_support::{55 construct_runtime, match_types,57 construct_runtime, match_types,66 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,68 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, ConstantMultiplier,67 },69 },68};70};71use pallet_unq_scheduler::DispatchCall;72use up_data_structs::{73 CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits, 74 CollectionStats, RpcCollection, 75 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping}76};7769// use pallet_contracts::weights::WeightInfo;78// use pallet_contracts::weights::WeightInfo;70// #[cfg(any(feature = "std", test))]79// #[cfg(any(feature = "std", test))]77};86};78use smallvec::smallvec;87use smallvec::smallvec;79use codec::{Encode, Decode};88use codec::{Encode, Decode};80use pallet_evm::{Account as EVMAccount, FeeCalculator, GasWeightMapping};81use fp_rpc::TransactionStatus;89use fp_rpc::TransactionStatus;82use sp_runtime::{90use sp_runtime::{83 traits::{91 traits::{86 },94 },87 generic::Era,95 generic::Era,88 transaction_validity::TransactionValidityError,96 transaction_validity::TransactionValidityError,89 SaturatedConversion, DispatchErrorWithPostInfo,97 DispatchErrorWithPostInfo, SaturatedConversion, 90};98};9192use fp_self_contained::{SelfContainedCall, CheckedSignature};939994// pub use pallet_timestamp::Call as TimestampCall;100// pub use pallet_timestamp::Call as TimestampCall;95pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;101pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;9610297// Polkadot imports103// Polkadot imports98use pallet_xcm::XcmPassthrough;104use pallet_xcm::XcmPassthrough;99use polkadot_parachain::primitives::Sibling;105use polkadot_parachain::primitives::Sibling;100use up_data_structs::{101 CollectionId, TokenId, TokenData, Property, PropertyKeyPermission, CollectionLimits, 102 CollectionStats, RpcCollection, 103 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping}104};105use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};106use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};106use xcm_builder::{107use xcm_builder::{107 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,108 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,112};113};113use xcm_executor::{Config, XcmExecutor, Assets};114use xcm_executor::{Config, XcmExecutor, Assets};114use sp_std::{cmp::Ordering, marker::PhantomData};115use sp_std::{cmp::Ordering, marker::PhantomData};115use pallet_unq_scheduler::DispatchCall;116116117use xcm::latest::{117use xcm::latest::{118 // Xcm,118 // Xcm,148 }148 }149}149}150151/// The type for looking up accounts. We don't expect more than 4 billion of them, but you152/// never know...153pub type AccountIndex = u32;154155/// Balance of an account.156pub type Balance = u128;157158/// Index of a transaction in the chain.159pub type Index = u32;160161/// A hash of some data used by the chain.162pub type Hash = sp_core::H256;163164/// Digest item type.165pub type DigestItem = generic::DigestItem;150166151/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know167/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know152/// the specifics of the runtime. They can then be made to be agnostic over specific formats168/// the specifics of the runtime. They can then be made to be agnostic over specific formats277 }293 }278}294}295296impl pallet_evm::account::Config for Runtime {297 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;298 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;299 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;300}279301280impl pallet_evm::Config for Runtime {302impl pallet_evm::Config for Runtime {281 type BlockGasLimit = BlockGasLimit;303 type BlockGasLimit = BlockGasLimit;393 // pub const ExistentialDeposit: u128 = 500;415 // pub const ExistentialDeposit: u128 = 500;394 pub const ExistentialDeposit: u128 = 0;416 pub const ExistentialDeposit: u128 = 0;395 pub const MaxLocks: u32 = 50;417 pub const MaxLocks: u32 = 50;418 pub const MaxReserves: u32 = 50;396}419}397420398impl pallet_balances::Config for Runtime {421impl pallet_balances::Config for Runtime {879 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;902 type WeightInfo = pallet_structure::weights::SubstrateWeight<Self>;880}903}881882impl pallet_evm::account::Config for Runtime {883 type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Self>;884 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;885 type EvmBackwardsAddressMapping = fp_evm_mapping::MapBackwardsAddressTruncated;886}887904888impl pallet_fungible::Config for Runtime {905impl pallet_fungible::Config for Runtime {889 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;906 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;927 pub const MaxScheduledPerBlock: u32 = 50;944 pub const MaxScheduledPerBlock: u32 = 50;928}945}929946930type EvmSponsorshipHandler = (947type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;948use frame_support::traits::NamedReservableCurrency;949950fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {951 (931 UniqueEthSponsorshipHandler<Runtime>,952 frame_system::CheckSpecVersion::<Runtime>::new(),953 frame_system::CheckGenesis::<Runtime>::new(),954 frame_system::CheckEra::<Runtime>::from(Era::Immortal),932 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,955 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(956 from,957 )),958 frame_system::CheckWeight::<Runtime>::new(),959 // sponsoring transaction logic960 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),933);961 )962}963964pub struct SchedulerPaymentExecutor;965impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>966 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor967where968 <T as frame_system::Config>::Call: Member934type SponsorshipHandler = (969 + Dispatchable<Origin = Origin, Info = DispatchInfo>970 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>971 + GetDispatchInfo935 UniqueSponsorshipHandler<Runtime>,972 + From<frame_system::Call<Runtime>>,936 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,973 SelfContainedSignedInfo: Send + Sync + 'static,974 Call: From<<T as frame_system::Config>::Call>975 + From<<T as pallet_unq_scheduler::Config>::Call>976 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,977 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,978{979 fn dispatch_call(937 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,980 signer: <T as frame_system::Config>::AccountId,981 call: <T as pallet_unq_scheduler::Config>::Call,982 ) -> Result<983 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,984 TransactionValidityError,985 > {986 let dispatch_info = call.get_dispatch_info();987 let extrinsic = fp_self_contained::CheckedExtrinsic::<988 AccountId,989 Call,990 SignedExtraScheduler,991 SelfContainedSignedInfo,992 > {993 signed:994 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(995 signer.clone().into(),996 get_signed_extras(signer.into()),997 ),998 function: call.into(),999 };10001001 extrinsic.apply::<Runtime>(&dispatch_info, 0)1002 }10031004 fn reserve_balance(1005 id: [u8; 16],1006 sponsor: <T as frame_system::Config>::AccountId,1007 call: <T as pallet_unq_scheduler::Config>::Call,1008 count: u32,1009 ) -> Result<(), DispatchError> {938);1010 let dispatch_info = call.get_dispatch_info();1011 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1012 .saturating_mul(count.into());10131014 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1015 &id,1016 &(sponsor.into()),1017 weight.into(),1018 )1019 }10201021 fn pay_for_call(1022 id: [u8; 16],1023 sponsor: <T as frame_system::Config>::AccountId,1024 call: <T as pallet_unq_scheduler::Config>::Call,1025 ) -> Result<u128, DispatchError> {1026 let dispatch_info = call.get_dispatch_info();1027 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1028 Ok(1029 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1030 &id,1031 &(sponsor.into()),1032 weight.into(),1033 ),1034 )1035 }10361037 fn cancel_reserve(1038 id: [u8; 16],1039 sponsor: <T as frame_system::Config>::AccountId,1040 ) -> Result<u128, DispatchError> {1041 Ok(1042 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1043 &id,1044 &(sponsor.into()),1045 u128::MAX,1046 ),1047 )1048 }1049}9391050940parameter_types! {1051parameter_types! {941 pub const NoPreimagePostponement: Option<u32> = Some(10);1052 pub const NoPreimagePostponement: Option<u32> = Some(10);966 type NoPreimagePostponement = NoPreimagePostponement;1078 type NoPreimagePostponement = NoPreimagePostponement;967}1079}10801081type EvmSponsorshipHandler = (1082 UniqueEthSponsorshipHandler<Runtime>,1083 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,1084);1085type SponsorshipHandler = (1086 UniqueSponsorshipHandler<Runtime>,1087 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,1088 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,1089);9681090969impl pallet_evm_transaction_payment::Config for Runtime {1091impl pallet_evm_transaction_payment::Config for Runtime {970 type EvmSponsorshipHandler = EvmSponsorshipHandler;1092 type EvmSponsorshipHandler = EvmSponsorshipHandler;979// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;1101// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;980// }1102// }981982type ChargeTransactionPayment = pallet_charge_transaction::ChargeTransactionPayment<Runtime>;983use frame_support::traits::NamedReservableCurrency;984985fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {986 (987 frame_system::CheckSpecVersion::<Runtime>::new(),988 frame_system::CheckGenesis::<Runtime>::new(),989 frame_system::CheckEra::<Runtime>::from(Era::Immortal),990 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(991 from,992 )),993 frame_system::CheckWeight::<Runtime>::new(),994 // sponsoring transaction logic995 // pallet_charge_transaction::ChargeTransactionPayment::<Runtime>::new(0),996 )997}998999pub struct SchedulerPaymentExecutor;1000impl<T: frame_system::Config + pallet_unq_scheduler::Config, SelfContainedSignedInfo>1001 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor1002where1003 <T as frame_system::Config>::Call: Member1004 + Dispatchable<Origin = Origin, Info = DispatchInfo>1005 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>1006 + GetDispatchInfo1007 + From<frame_system::Call<Runtime>>,1008 SelfContainedSignedInfo: Send + Sync + 'static,1009 Call: From<<T as frame_system::Config>::Call>1010 + From<<T as pallet_unq_scheduler::Config>::Call>1011 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,1012 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,1013{1014 fn dispatch_call(1015 signer: <T as frame_system::Config>::AccountId,1016 call: <T as pallet_unq_scheduler::Config>::Call,1017 ) -> Result<1018 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,1019 TransactionValidityError,1020 > {1021 let dispatch_info = call.get_dispatch_info();1022 let extrinsic = fp_self_contained::CheckedExtrinsic::<1023 AccountId,1024 Call,1025 SignedExtraScheduler,1026 SelfContainedSignedInfo,1027 > {1028 signed:1029 CheckedSignature::<AccountId, SignedExtraScheduler, SelfContainedSignedInfo>::Signed(1030 signer.clone().into(),1031 get_signed_extras(signer.into()),1032 ),1033 function: call.into(),1034 };10351036 extrinsic.apply::<Runtime>(&dispatch_info, 0)1037 }10381039 fn reserve_balance(1040 id: [u8; 16],1041 sponsor: <T as frame_system::Config>::AccountId,1042 call: <T as pallet_unq_scheduler::Config>::Call,1043 count: u32,1044 ) -> Result<(), DispatchError> {1045 let dispatch_info = call.get_dispatch_info();1046 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)1047 .saturating_mul(count.into());10481049 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(1050 &id,1051 &(sponsor.into()),1052 weight.into(),1053 )1054 }10551056 fn pay_for_call(1057 id: [u8; 16],1058 sponsor: <T as frame_system::Config>::AccountId,1059 call: <T as pallet_unq_scheduler::Config>::Call,1060 ) -> Result<u128, DispatchError> {1061 let dispatch_info = call.get_dispatch_info();1062 let weight: Balance = ChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);1063 Ok(1064 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1065 &id,1066 &(sponsor.into()),1067 weight.into(),1068 ),1069 )1070 }10711072 fn cancel_reserve(1073 id: [u8; 16],1074 sponsor: <T as frame_system::Config>::AccountId,1075 ) -> Result<u128, DispatchError> {1076 Ok(1077 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(1078 &id,1079 &(sponsor.into()),1080 u128::MAX,1081 ),1082 )1083 }1084}108511031086parameter_types! {1104parameter_types! {1087 // 0x842899ECF380553E8a4de75bF534cdf6fBF640491105 // 0x842899ECF380553E8a4de75bF534cdf6fBF640491198 frame_system::CheckEra<Runtime>,1216 frame_system::CheckEra<Runtime>,1199 frame_system::CheckNonce<Runtime>,1217 frame_system::CheckNonce<Runtime>,1200 frame_system::CheckWeight<Runtime>,1218 frame_system::CheckWeight<Runtime>,1201 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,1219 ChargeTransactionPayment,1202 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1220 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,1203 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1221 pallet_ethereum::FakeTransactionFinalizer<Runtime>,1204);1222);