diff --git a/Cargo.lock b/Cargo.lock index 59ebf0704b6aeb1ba0cce40e3dab52138f89e072..a110a6d0f4d718d45f27f47ea4ae0585416b10d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13900,6 +13900,7 @@ dependencies = [ "pallet-balances", "pallet-collator-selection", "pallet-message-queue", + "pallet-revive", "pallet-session", "pallet-sudo", "pallet-timestamp", diff --git a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml index 5b17f4f5738803aeb0b73f86296145aee94ce4ed..f53d6d7b8cdd15aedee2c964cbe11dfb4bce9f99 100644 --- a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml @@ -38,6 +38,7 @@ pallet-assets = { workspace = true } pallet-aura = { workspace = true } pallet-authorship = { workspace = true } pallet-balances = { workspace = true } +pallet-revive = { workspace = true } pallet-session = { workspace = true } pallet-sudo = { workspace = true } pallet-timestamp = { workspace = true } @@ -111,6 +112,7 @@ std = [ "pallet-balances/std", "pallet-collator-selection/std", "pallet-message-queue/std", + "pallet-revive/std", "pallet-session/std", "pallet-sudo/std", "pallet-timestamp/std", @@ -162,6 +164,7 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", + "pallet-revive/runtime-benchmarks", "pallet-sudo/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-transaction-payment/runtime-benchmarks", @@ -195,6 +198,7 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-collator-selection/try-runtime", "pallet-message-queue/try-runtime", + "pallet-revive/try-runtime", "pallet-session/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index d6be7bb16c459d3ee266a64fad2936bfe4383867..82da5764744b69349c213dda8de72f6a89ff30ee 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -64,7 +64,7 @@ use frame_support::{ traits::{ tokens::{fungible, fungibles, imbalance::ResolveAssetTo}, AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, Everything, - TransformOrigin, + Nothing, TransformOrigin, }, weights::{ constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, FeePolynomial, WeightToFee as _, @@ -76,6 +76,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, EnsureSignedBy, }; +use pallet_revive::evm::runtime::EthExtra; use parachains_common::{ impls::{AssetsToBlockAuthor, NonZeroIssuance}, message_queue::{NarrowOriginToSibling, ParaIdToSibling}, @@ -155,9 +156,33 @@ pub type TxExtension = ( frame_system::WeightReclaim<Runtime>, ); +/// Default extensions applied to Ethereum transactions. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct EthExtraImpl; + +impl EthExtra for EthExtraImpl { + type Config = Runtime; + type Extension = TxExtension; + + fn get_eth_extension(nonce: u32, tip: Balance) -> Self::Extension { + ( + frame_system::CheckNonZeroSender::<Runtime>::new(), + frame_system::CheckSpecVersion::<Runtime>::new(), + frame_system::CheckTxVersion::<Runtime>::new(), + frame_system::CheckGenesis::<Runtime>::new(), + frame_system::CheckEra::<Runtime>::from(generic::Era::Immortal), + frame_system::CheckNonce::<Runtime>::from(nonce), + frame_system::CheckWeight::<Runtime>::new(), + pallet_asset_tx_payment::ChargeAssetTxPayment::<Runtime>::from(tip, None), + frame_system::WeightReclaim::<Runtime>::new(), + ) + .into() + } +} + /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = - generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>; + pallet_revive::evm::runtime::UncheckedExtrinsic<Address, Signature, EthExtraImpl>; pub type Migrations = ( pallet_balances::migration::MigrateToTrackInactive<Runtime, xcm_config::CheckingAccount>, @@ -801,6 +826,49 @@ impl pallet_asset_tx_payment::Config for Runtime { type BenchmarkHelper = AssetTxHelper; } +parameter_types! { + pub const DepositPerItem: Balance = 0; + pub const DepositPerByte: Balance = 0; + pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30); +} + +impl pallet_revive::Config for Runtime { + type Time = Timestamp; + type Currency = Balances; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type CallFilter = Nothing; + type DepositPerItem = DepositPerItem; + type DepositPerByte = DepositPerByte; + type WeightPrice = pallet_transaction_payment::Pallet<Self>; + type WeightInfo = pallet_revive::weights::SubstrateWeight<Self>; + type ChainExtension = (); + type AddressMapper = pallet_revive::AccountId32Mapper<Self>; + type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>; + type PVFMemory = ConstU32<{ 512 * 1024 * 1024 }>; + type UnsafeUnstableInterface = ConstBool<true>; + type UploadOrigin = EnsureSigned<Self::AccountId>; + type InstantiateOrigin = EnsureSigned<Self::AccountId>; + type RuntimeHoldReason = RuntimeHoldReason; + type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent; + type Xcm = PolkadotXcm; + type ChainId = ConstU64<420_420_999>; + type NativeToEthRatio = ConstU32<1_000_000>; // 10^(18 - 12) Eth is 10^18, Native is 10^12. + type EthGasEncoder = (); + type FindAuthor = <Runtime as pallet_authorship::Config>::FindAuthor; +} + +impl TryFrom<RuntimeCall> for pallet_revive::Call<Runtime> { + type Error = (); + + fn try_from(value: RuntimeCall) -> Result<Self, Self::Error> { + match value { + RuntimeCall::Revive(call) => Ok(call), + _ => Err(()), + } + } +} + impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; @@ -841,6 +909,8 @@ construct_runtime!( PoolAssets: pallet_assets::<Instance3> = 52, AssetConversion: pallet_asset_conversion = 53, + Revive: pallet_revive = 60, + Sudo: pallet_sudo = 255, } );