Skip to content
Closed
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
20 changes: 20 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu

# Astar pallets & modules
# (wasm)
pallet-account = { git = "https://github.com/AstarNetwork/astar-frame", branch = "feature/pallet-account", default-features = false }
pallet-block-reward = { git = "https://github.com/AstarNetwork/astar-frame", branch = "polkadot-v0.9.39", default-features = false }
pallet-collator-selection = { git = "https://github.com/AstarNetwork/astar-frame", branch = "polkadot-v0.9.39", default-features = false }
pallet-custom-signatures = { git = "https://github.com/AstarNetwork/astar-frame", branch = "polkadot-v0.9.39", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions runtime/local/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fp-self-contained = { workspace = true }
frame-executive = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-account = { workspace = true }
pallet-assets = { workspace = true }
pallet-aura = { workspace = true }
pallet-balances = { workspace = true }
Expand Down Expand Up @@ -103,6 +104,7 @@ std = [
"frame-support/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"pallet-account/std",
"pallet-assets/std",
"pallet-aura/std",
"pallet-balances/std",
Expand Down
28 changes: 27 additions & 1 deletion runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,28 @@ parameter_types! {
pub WeightPerGas: Weight = Weight::from_ref_time(WEIGHT_PER_GAS);
}

/// Ensure that the origin is EVM compatible.
pub struct EnsureEvmOrigin;
impl<OuterOrigin> pallet_evm::EnsureAddressOrigin<OuterOrigin> for EnsureEvmOrigin
where
OuterOrigin: Into<Result<pallet_account::NativeAndEVM, OuterOrigin>>
+ From<pallet_account::NativeAndEVM>,
{
type Success = ();
fn try_address_origin(address: &H160, origin: OuterOrigin) -> Result<(), OuterOrigin> {
origin.into().and_then(|o| match o {
pallet_account::NativeAndEVM::H160(a) if *address == a => Ok(()),
r => Err(OuterOrigin::from(r)),
})
}
}

impl pallet_evm::Config for Runtime {
type FeeCalculator = BaseFee;
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Runtime>;
type CallOrigin = pallet_evm::EnsureAddressRoot<AccountId>;
type CallOrigin = EnsureEvmOrigin;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should remain root - it's only related to who can call the actual pallet-evm extrinsics (which should be no one), it won't help with signature verification in pallet-ethereum.

The whole point of switching away from pallet-evm is to still emit relevant events for EVM indexers. It's all described in the BL ticket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach makes possible substrate users call EVM without any changes in frontier, didn’t it good enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, details are in the backlog item.

type WithdrawOrigin = pallet_evm::EnsureAddressTruncated;
type AddressMapping = pallet_evm::HashedAddressMapping<BlakeTwo256>;
type Currency = Balances;
Expand Down Expand Up @@ -958,6 +974,15 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = ConstU128<{ MILLIAST * 660 }>;
}

impl pallet_account::Config for Runtime {
type CustomOrigin = pallet_account::NativeAndEVM;
type CustomOriginKind = pallet_account::NativeAndEVMKind;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type WeightInfo = ();
}

// TODO: remove this once https://github.com/paritytech/substrate/issues/12161 is resolved
#[rustfmt::skip]
construct_runtime!(
Expand Down Expand Up @@ -991,6 +1016,7 @@ construct_runtime!(
TechnicalCommittee: pallet_collective::<Instance2>,
Treasury: pallet_treasury,
Xvm: pallet_xvm,
Account: pallet_account,
Proxy: pallet_proxy,
Preimage: pallet_preimage,
}
Expand Down
2 changes: 2 additions & 0 deletions runtime/shibuya/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ frame-executive = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
pallet-account = { workspace = true }
pallet-assets = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
Expand Down Expand Up @@ -157,6 +158,7 @@ std = [
"frame-executive/std",
"frame-system/std",
"frame-system-rpc-runtime-api/std",
"pallet-account/std",
"pallet-authorship/std",
"pallet-aura/std",
"pallet-assets/std",
Expand Down
28 changes: 27 additions & 1 deletion runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,28 @@ parameter_types! {
pub WeightPerGas: Weight = Weight::from_ref_time(WEIGHT_PER_GAS);
}

/// Ensure that the origin is EVM compatible.
pub struct EnsureEvmOrigin;
impl<OuterOrigin> pallet_evm::EnsureAddressOrigin<OuterOrigin> for EnsureEvmOrigin
where
OuterOrigin: Into<Result<pallet_account::NativeAndEVM, OuterOrigin>>
+ From<pallet_account::NativeAndEVM>,
{
type Success = ();
fn try_address_origin(address: &H160, origin: OuterOrigin) -> Result<(), OuterOrigin> {
origin.into().and_then(|o| match o {
pallet_account::NativeAndEVM::H160(a) if *address == a => Ok(()),
r => Err(OuterOrigin::from(r)),
})
}
}

impl pallet_evm::Config for Runtime {
type FeeCalculator = BaseFee;
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Runtime>;
type CallOrigin = pallet_evm::EnsureAddressRoot<AccountId>;
type CallOrigin = EnsureEvmOrigin;
type WithdrawOrigin = pallet_evm::EnsureAddressTruncated;
type AddressMapping = pallet_evm::HashedAddressMapping<BlakeTwo256>;
type Currency = Balances;
Expand Down Expand Up @@ -1211,6 +1227,15 @@ impl pallet_xc_asset_config::Config for Runtime {
type WeightInfo = pallet_xc_asset_config::weights::SubstrateWeight<Self>;
}

impl pallet_account::Config for Runtime {
type CustomOrigin = pallet_account::NativeAndEVM;
type CustomOriginKind = pallet_account::NativeAndEVMKind;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type WeightInfo = ();
}

parameter_types! {
// The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high)
pub const MigrationSignedDepositPerItem: Balance = 10 * MILLISBY;
Expand Down Expand Up @@ -1286,6 +1311,7 @@ construct_runtime!(
Preimage: pallet_preimage = 84,

Xvm: pallet_xvm = 90,
Account: pallet_account= 91,

Sudo: pallet_sudo = 99,

Expand Down