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

[help]I want to use your pallet-evm #575

Closed
master-davidlee opened this issue Jul 5, 2021 · 4 comments
Closed

[help]I want to use your pallet-evm #575

master-davidlee opened this issue Jul 5, 2021 · 4 comments

Comments

@master-davidlee
Copy link

Hi guys, I want to add your pallet-evm to my node-template runtime, but
image
,and there are another 100 errors 😢 😱

this is my cargo.toml

pallet-evm = { git = "https://github.com/purestake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.6" }        
pallet-evm-precompile-simple={default-features = false, version='1.0.0'}            
pallet-evm-precompile-modexp={default-features = false, version='1.0.0'}    
pallet-evm-precompile-sha3fips={default-features = false, version='1.0.0'}    

this is my runtime/lib.rs

pub const GAS_PER_SECOND: u64 = 40_000_000;
pub const WEIGHT_PER_GAS: u64 = WEIGHT_PER_SECOND / GAS_PER_SECOND;
pub struct MoonbeamGasWeightMapping;
impl pallet_evm::GasWeightMapping for MoonbeamGasWeightMapping {
	fn gas_to_weight(gas: u64) -> Weight {
		gas.saturating_mul(WEIGHT_PER_GAS)
	}
	fn weight_to_gas(weight: Weight) -> u64 {
		u64::try_from(weight.wrapping_div(WEIGHT_PER_GAS)).unwrap_or(u32::MAX as u64)
	}
}
parameter_types! {
	pub BlockGasLimit: U256
		= U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT / WEIGHT_PER_GAS);
}
pub struct FixedGasPrice;
impl FeeCalculator for FixedGasPrice {
	fn min_gas_price() -> U256 {
		1_000_000_000.into()
	}
}
impl pallet_evm::Config for Runtime {
	type FeeCalculator = FixedGasPrice;
	type GasWeightMapping = MoonbeamGasWeightMapping;
	type CallOrigin = EnsureAddressRoot<AccountId>;
	type WithdrawOrigin = EnsureAddressNever<AccountId>;
	type AddressMapping = IdentityAddressMapping;
	type Currency = Balances;
	type Event = Event;
	type Runner = pallet_evm::runner::stack::Runner<Self>;
	type Precompiles = (
		pallet_evm_precompile_simple::ECRecover,
		pallet_evm_precompile_simple::Sha256,
		pallet_evm_precompile_simple::Ripemd160,
		pallet_evm_precompile_simple::Identity,
		pallet_evm_precompile_modexp::Modexp,
		pallet_evm_precompile_simple::ECRecoverPublicKey,
		pallet_evm_precompile_sha3fips::Sha3FIPS256,
		pallet_evm_precompile_sha3fips::Sha3FIPS512,
	);
	type ChainId = EthereumChainId;
	type OnChargeTransaction = ();
	type BlockGasLimit = BlockGasLimit;
}
@crystalin
Copy link
Collaborator

crystalin commented Jul 6, 2021

@master-davidlee , if you are looking simply to add EVM compatibility to your runtime, I'd suggest to look at frontier template (https://github.com/paritytech/frontier/tree/master/template) , it is simpler to use.

@master-davidlee
Copy link
Author

Yeah, I noticed this, but they are using frame 2.0. I want to use frame 3.0, only your pallet-EVM is frame 3.0

@crystalin
Copy link
Collaborator

@JoshOrndorff , do we have a plan to port back the frame 3.0 to frontier directly ?

@JoshOrndorff
Copy link
Contributor

JoshOrndorff commented Jul 6, 2021

First some nomenclature. Substrate has versions 2.0 and 3.0 as well as some older and newer versions. FRAME has versions v1 and v2. FRAMEv2 was introduced with Substrate 3.0. So there is no FRAME 3.0 (or FRAME v3). I assume you meant FRAMEv2.

Our forked pallet EVM is based on frontier's upstream pallet evm. Ours is only known to work with the Substrate version specified in our Cargo.lock which is git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.6#9c572625f6557dfdb19f47474369a0327d51dfbc.

We didn't actually update pallet evm to FRAME v2 ourselves. It was updated upstream in polkadot-evm/frontier#380 before we forked. The update was later reverted upstream as explained here polkadot-evm/frontier#380 (comment)

I'm not 100% sure what incompatibilities sorpaas is talking about, but I also look forward to a day when this code makes it upstream.

In terms of helping you get your template building, I recommend taking all of your evm-related dependencies from a single repo. So if you're using our pallet-evm, then also use our precompiles, our pallet ethereum, etc. And make sure you use the same Substrate dependency we do. If you still have trouble, please share a link to your code repo so I can clone it and reproduce your error completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants