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

[stable2412] pallet-revive: remove related crates from umbrella #7894

Open
wants to merge 10 commits into
base: stable2412
Choose a base branch
from
2 changes: 1 addition & 1 deletion .config/taplo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exclude = [
[formatting]
reorder_arrays = true
inline_table_expand = false
array_auto_expand = false
array_auto_expand = true
array_auto_collapse = false
indent_string = " " # tab

Expand Down
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pallet-timestamp.workspace = true
pallet-transaction-payment.workspace = true
pallet-transaction-payment-rpc-runtime-api.workspace = true
pallet-uniques.workspace = true
pallet-revive.workspace = true
pallet-utility.workspace = true
sp-api.workspace = true
sp-block-builder.workspace = true
Expand Down Expand Up @@ -122,7 +121,6 @@ runtime-benchmarks = [
"pallet-nft-fractionalization/runtime-benchmarks",
"pallet-nfts/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-revive/runtime-benchmarks",
"pallet-state-trie-migration/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
Expand Down Expand Up @@ -163,7 +161,6 @@ try-runtime = [
"pallet-nft-fractionalization/try-runtime",
"pallet-nfts/try-runtime",
"pallet-proxy/try-runtime",
"pallet-revive/try-runtime",
"pallet-session/try-runtime",
"pallet-state-trie-migration/try-runtime",
"pallet-timestamp/try-runtime",
Expand Down Expand Up @@ -216,7 +213,6 @@ std = [
"pallet-nfts-runtime-api/std",
"pallet-nfts/std",
"pallet-proxy/std",
"pallet-revive/std",
"pallet-session/std",
"pallet-state-trie-migration/std",
"pallet-timestamp/std",
Expand Down
192 changes: 4 additions & 188 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ use frame_support::{
ord_parameter_types, parameter_types,
traits::{
fungible, fungibles,
tokens::{
imbalance::ResolveAssetTo, nonfungibles_v2::Inspect, Fortitude::Polite,
Preservation::Expendable,
},
tokens::{imbalance::ResolveAssetTo, nonfungibles_v2::Inspect},
AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, Equals,
InstanceFilter, Nothing, TransformOrigin,
InstanceFilter, TransformOrigin,
},
weights::{ConstantMultiplier, Weight, WeightToFee as _},
BoundedVec, PalletId,
Expand All @@ -61,15 +58,14 @@ use frame_system::{
};
use pallet_asset_conversion_tx_payment::SwapAssetAdapter;
use pallet_nfts::{DestroyWitness, PalletFeatures};
use pallet_revive::{evm::runtime::EthExtra, AddressMapper};
use pallet_xcm::EnsureXcm;
use parachains_common::{
impls::DealWithFees, message_queue::*, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
BlockNumber, CollectionId, Hash, Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
NORMAL_DISPATCH_RATIO,
};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160};
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
generic, impl_opaque_keys,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, Saturating, Verify},
Expand Down Expand Up @@ -950,47 +946,6 @@ parameter_types! {
pub CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(30);
}

type EventRecord = frame_system::EventRecord<
<Runtime as frame_system::Config>::RuntimeEvent,
<Runtime as frame_system::Config>::Hash,
>;

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<false>;
type UploadOrigin = EnsureSigned<Self::AccountId>;
type InstantiateOrigin = EnsureSigned<Self::AccountId>;
type RuntimeHoldReason = RuntimeHoldReason;
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Debug = ();
type Xcm = pallet_xcm::Pallet<Self>;
type ChainId = ConstU64<420_420_421>;
type NativeToEthRatio = ConstU32<1_000_000>; // 10^(18 - 12) Eth is 10^18, Native is 10^12.
}

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(()),
}
}
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
Expand Down Expand Up @@ -1039,7 +994,6 @@ construct_runtime!(
AssetsFreezer: pallet_assets_freezer::<Instance1> = 57,
ForeignAssetsFreezer: pallet_assets_freezer::<Instance2> = 58,
PoolAssetsFreezer: pallet_assets_freezer::<Instance3> = 59,
Revive: pallet_revive = 60,

StateTrieMigration: pallet_state_trie_migration = 70,

Expand Down Expand Up @@ -1071,33 +1025,9 @@ pub type TxExtension = (
frame_metadata_hash_extension::CheckMetadataHash<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::CheckMortality::from(generic::Era::Immortal),
frame_system::CheckNonce::<Runtime>::from(nonce),
frame_system::CheckWeight::<Runtime>::new(),
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(tip, None),
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim::<Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
)
}
}

/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
pallet_revive::evm::runtime::UncheckedExtrinsic<Address, Signature, EthExtraImpl>;
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;

/// Migrations to apply on runtime upgrade.
pub type Migrations = (
Expand Down Expand Up @@ -1332,7 +1262,6 @@ mod benches {
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_xcm_bridge_hub_router, ToRococo]
[pallet_asset_conversion_ops, AssetConversionMigration]
[pallet_revive, Revive]
// XCM
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
// NOTE: Make sure you point to the individual modules below.
Expand Down Expand Up @@ -2083,119 +2012,6 @@ impl_runtime_apis! {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}

impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber, EventRecord> for Runtime
{
fn balance(address: H160) -> Balance {
use frame_support::traits::fungible::Inspect;
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
Balances::reducible_balance(&account, Expendable, Polite)
}

fn nonce(address: H160) -> Nonce {
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
System::account_nonce(account)
}
fn eth_transact(
from: H160,
dest: Option<H160>,
value: Balance,
input: Vec<u8>,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
) -> pallet_revive::EthContractResult<Balance>
{
use pallet_revive::AddressMapper;
let blockweights = <Runtime as frame_system::Config>::BlockWeights::get();
let origin = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&from);

let encoded_size = |pallet_call| {
let call = RuntimeCall::Revive(pallet_call);
let uxt: UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic::new_bare(call).into();
uxt.encoded_size() as u32
};

Revive::bare_eth_transact(
origin,
dest,
value,
input,
gas_limit.unwrap_or(blockweights.max_block),
storage_deposit_limit.unwrap_or(u128::MAX),
encoded_size,
pallet_revive::DebugInfo::UnsafeDebug,
pallet_revive::CollectEvents::UnsafeCollect,
)
}

fn call(
origin: AccountId,
dest: H160,
value: Balance,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
input_data: Vec<u8>,
) -> pallet_revive::ContractResult<pallet_revive::ExecReturnValue, Balance, EventRecord> {
let blockweights= <Runtime as frame_system::Config>::BlockWeights::get();
Revive::bare_call(
RuntimeOrigin::signed(origin),
dest,
value,
gas_limit.unwrap_or(blockweights.max_block),
storage_deposit_limit.unwrap_or(u128::MAX),
input_data,
pallet_revive::DebugInfo::UnsafeDebug,
pallet_revive::CollectEvents::UnsafeCollect,
)
}

fn instantiate(
origin: AccountId,
value: Balance,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
code: pallet_revive::Code,
data: Vec<u8>,
salt: Option<[u8; 32]>,
) -> pallet_revive::ContractResult<pallet_revive::InstantiateReturnValue, Balance, EventRecord>
{
let blockweights= <Runtime as frame_system::Config>::BlockWeights::get();
Revive::bare_instantiate(
RuntimeOrigin::signed(origin),
value,
gas_limit.unwrap_or(blockweights.max_block),
storage_deposit_limit.unwrap_or(u128::MAX),
code,
data,
salt,
pallet_revive::DebugInfo::UnsafeDebug,
pallet_revive::CollectEvents::UnsafeCollect,
)
}

fn upload_code(
origin: AccountId,
code: Vec<u8>,
storage_deposit_limit: Option<Balance>,
) -> pallet_revive::CodeUploadResult<Balance>
{
Revive::bare_upload_code(
RuntimeOrigin::signed(origin),
code,
storage_deposit_limit.unwrap_or(u128::MAX),
)
}

fn get_storage(
address: H160,
key: [u8; 32],
) -> pallet_revive::GetStorageResult {
Revive::get_storage(
address,
key
)
}
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Expand Down
8 changes: 4 additions & 4 deletions substrate/bin/node/cli/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ pub fn bloaty_code_unwrap() -> &'static [u8] {
/// correct multiplier.
fn transfer_fee(extrinsic: &UncheckedExtrinsic) -> Balance {
let mut info = default_transfer_call().get_dispatch_info();
info.extension_weight = extrinsic.0.extension_weight();
info.extension_weight = extrinsic.extension_weight();
TransactionPayment::compute_fee(extrinsic.encode().len() as u32, &info, 0)
}

/// Default transfer fee, same as `transfer_fee`, but with a weight refund factored in.
fn transfer_fee_with_refund(extrinsic: &UncheckedExtrinsic, weight_refund: Weight) -> Balance {
let mut info = default_transfer_call().get_dispatch_info();
info.extension_weight = extrinsic.0.extension_weight();
info.extension_weight = extrinsic.extension_weight();
let post_info = (Some(info.total_weight().saturating_sub(weight_refund)), info.pays_fee).into();
TransactionPayment::compute_actual_fee(extrinsic.encode().len() as u32, &info, &post_info, 0)
}
Expand Down Expand Up @@ -324,7 +324,7 @@ fn full_native_block_import_works() {

let mut alice_last_known_balance: Balance = Default::default();
let mut fees = t.execute_with(|| transfer_fee(&xt()));
let extension_weight = xt().0.extension_weight();
let extension_weight = xt().extension_weight();
let weight_refund = Weight::zero();
let fees_after_refund = t.execute_with(|| transfer_fee_with_refund(&xt(), weight_refund));

Expand Down Expand Up @@ -427,7 +427,7 @@ fn full_native_block_import_works() {

fees = t.execute_with(|| transfer_fee(&xt()));
let pot = t.execute_with(|| Treasury::pot());
let extension_weight = xt().0.extension_weight();
let extension_weight = xt().extension_weight();
let weight_refund = Weight::zero();
let fees_after_refund = t.execute_with(|| transfer_fee_with_refund(&xt(), weight_refund));

Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/cli/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn transaction_fee_is_correct() {
balance_alice -= length_fee;

let mut info = default_transfer_call().get_dispatch_info();
info.extension_weight = xt.0.extension_weight();
info.extension_weight = xt.extension_weight();
let weight = info.total_weight();
let weight_fee = IdentityFee::<Balance>::weight_to_fee(&weight);

Expand Down
6 changes: 3 additions & 3 deletions substrate/bin/node/cli/tests/submit_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn should_submit_signed_twice_from_the_same_account() {
// now check that the transaction nonces are not equal
let s = state.read();
fn nonce(tx: UncheckedExtrinsic) -> frame_system::CheckNonce<Runtime> {
let extra = tx.0.preamble.to_signed().unwrap().2;
let extra = tx.preamble.to_signed().unwrap().2;
extra.5
}
let nonce1 = nonce(UncheckedExtrinsic::decode(&mut &*s.transactions[0]).unwrap());
Expand Down Expand Up @@ -180,7 +180,7 @@ fn should_submit_signed_twice_from_all_accounts() {
// now check that the transaction nonces are not equal
let s = state.read();
fn nonce(tx: UncheckedExtrinsic) -> frame_system::CheckNonce<Runtime> {
let extra = tx.0.preamble.to_signed().unwrap().2;
let extra = tx.preamble.to_signed().unwrap().2;
extra.5
}
let nonce1 = nonce(UncheckedExtrinsic::decode(&mut &*s.transactions[0]).unwrap());
Expand Down Expand Up @@ -237,7 +237,7 @@ fn submitted_transaction_should_be_valid() {
let source = TransactionSource::External;
let extrinsic = UncheckedExtrinsic::decode(&mut &*tx0).unwrap();
// add balance to the account
let author = extrinsic.0.preamble.clone().to_signed().clone().unwrap().0;
let author = extrinsic.preamble.clone().to_signed().clone().unwrap().0;
let address = Indices::lookup(author).unwrap();
let data = pallet_balances::AccountData { free: 5_000_000_000_000, ..Default::default() };
let account = frame_system::AccountInfo { providers: 1, data, ..Default::default() };
Expand Down
Loading
Loading