difftreelog
build update frontier
in: master
14 files changed
crates/evm-coder/Cargo.tomldiffbeforeafterboth--- a/crates/evm-coder/Cargo.toml
+++ b/crates/evm-coder/Cargo.toml
@@ -7,8 +7,8 @@
evm-coder-macros = { path = "../evm-coder-macros" }
primitive-types = { version = "0.10.1", default-features = false }
hex-literal = "0.3.3"
-ethereum = { version = "0.9", git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }
-evm-core = { default-features = false, git = "https://github.com/uniquenetwork/evm.git", branch="precompile-output-parachain" }
+ethereum = { version = "0.10.0", default-features = false }
+evm-core = { default-features = false, git = "https://github.com/uniquenetwork/evm.git", branch = "unique-weights" }
impl-trait-for-tuples = "0.2.1"
[dev-dependencies]
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -1,4 +1,5 @@
pub use pallet_evm::PrecompileOutput;
+pub use pallet_evm::PrecompileResult;
use sp_core::{H160, U256};
/// Does not always represent a full collection, for RFT it is either
@@ -6,5 +7,5 @@
pub trait CommonEvmHandler {
const CODE: &'static [u8];
- fn call(self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileOutput>;
+ fn call(self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileResult>;
}
pallets/evm-coder-substrate/Cargo.tomldiffbeforeafterboth--- a/pallets/evm-coder-substrate/Cargo.toml
+++ b/pallets/evm-coder-substrate/Cargo.toml
@@ -9,7 +9,7 @@
] }
sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
-ethereum = { version = "0.9", git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }
+ethereum = { version = "0.10.0", default-features = false }
evm-coder = { default-features = false, path = "../../crates/evm-coder" }
pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }
pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }
pallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-coder-substrate/src/lib.rs
+++ b/pallets/evm-coder-substrate/src/lib.rs
@@ -20,7 +20,8 @@
};
use frame_support::{ensure};
use pallet_evm::{
- ExitError, ExitReason, ExitRevert, ExitSucceed, PrecompileOutput, GasWeightMapping,
+ ExitError, ExitRevert, ExitSucceed, GasWeightMapping, PrecompileFailure, PrecompileOutput,
+ PrecompileResult,
};
use frame_system::ensure_signed;
pub use frame_support::dispatch::DispatchResult;
@@ -158,26 +159,28 @@
pub fn evm_to_precompile_output(
self,
result: evm_coder::execution::Result<Option<AbiWriter>>,
- ) -> Option<PrecompileOutput> {
+ ) -> Option<PrecompileResult> {
use evm_coder::execution::Error;
- let (writer, reason) = match result {
- Ok(Some(v)) => (v, ExitReason::Succeed(ExitSucceed::Returned)),
+ Some(match result {
+ Ok(Some(v)) => Ok(PrecompileOutput {
+ exit_status: ExitSucceed::Returned,
+ cost: self.initial_gas - self.gas_left(),
+ logs: self.retrieve_logs(),
+ output: v.finish(),
+ }),
Ok(None) => return None,
Err(Error::Revert(e)) => {
let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));
(&e as &str).abi_write(&mut writer);
- (writer, ExitReason::Revert(ExitRevert::Reverted))
+ Err(PrecompileFailure::Revert {
+ exit_status: ExitRevert::Reverted,
+ cost: self.initial_gas - self.gas_left(),
+ output: writer.finish(),
+ })
}
- Err(Error::Fatal(f)) => (AbiWriter::new(), ExitReason::Fatal(f)),
- Err(Error::Error(e)) => (AbiWriter::new(), ExitReason::Error(e)),
- };
-
- Some(PrecompileOutput {
- cost: self.initial_gas - self.gas_left(),
- exit_status: reason,
- logs: self.retrieve_logs(),
- output: writer.finish(),
+ Err(Error::Fatal(f)) => Err(f.into()),
+ Err(Error::Error(e)) => Err(e.into()),
})
}
@@ -234,7 +237,7 @@
mut e: E,
value: value,
input: &[u8],
- ) -> Option<PrecompileOutput> {
+ ) -> Option<PrecompileResult> {
let result = call_internal(caller, &mut e, value, input);
e.into_recorder().evm_to_precompile_output(result)
}
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -1,7 +1,10 @@
use core::marker::PhantomData;
use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};
use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
-use pallet_evm::{ExitReason, ExitRevert, OnCreate, OnMethodCall, PrecompileOutput};
+use pallet_evm::{
+ ExitReason, ExitRevert, OnCreate, OnMethodCall, PrecompileOutput, PrecompileResult,
+ PrecompileFailure,
+};
use sp_core::H160;
use crate::{
AllowlistEnabled, Config, Owner, Pallet, SelfSponsoring, SponsorBasket, SponsoringRateLimit,
@@ -109,19 +112,18 @@
gas_left: u64,
input: &[u8],
value: sp_core::U256,
- ) -> Option<PrecompileOutput> {
+ ) -> Option<PrecompileResult> {
// TODO: Extract to another OnMethodCall handler
if <AllowlistEnabled<T>>::get(target) && !<Pallet<T>>::allowed(*target, *source) {
- return Some(PrecompileOutput {
- exit_status: ExitReason::Revert(ExitRevert::Reverted),
+ return Some(Err(PrecompileFailure::Revert {
+ exit_status: ExitRevert::Reverted,
cost: 0,
output: {
let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));
writer.string("Target contract is allowlisted");
writer.finish()
},
- logs: sp_std::vec![],
- });
+ }));
}
if target != &T::ContractAddress::get() {
pallets/evm-migration/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-migration/src/lib.rs
+++ b/pallets/evm-migration/src/lib.rs
@@ -98,7 +98,7 @@
_gas_left: u64,
_input: &[u8],
_value: sp_core::U256,
- ) -> Option<pallet_evm::PrecompileOutput> {
+ ) -> Option<pallet_evm::PrecompileResult> {
None
}
pallets/fungible/Cargo.tomldiffbeforeafterboth--- a/pallets/fungible/Cargo.toml
+++ b/pallets/fungible/Cargo.toml
@@ -19,7 +19,7 @@
nft-data-structs = { default-features = false, path = '../../primitives/nft' }
evm-coder = { default-features = false, path = '../../crates/evm-coder' }
pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
-ethereum = { git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }
+ethereum = { version = "0.10.0", default-features = false }
frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
scale-info = { version = "1.0.0", default-features = false, features = [
"derive",
pallets/fungible/src/erc.rsdiffbeforeafterboth1use core::char::{REPLACEMENT_CHARACTER, decode_utf16};2use core::convert::TryInto;3use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};4use nft_data_structs::CollectionMode;5use pallet_common::erc::CommonEvmHandler;6use sp_core::{H160, U256};7use sp_std::vec::Vec;8use pallet_common::account::CrossAccountId;9use pallet_common::erc::PrecompileOutput;10use pallet_evm_coder_substrate::{call, dispatch_to_evm};1112use crate::{13 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,14 weights::WeightInfo,15};1617#[derive(ToLog)]18pub enum ERC20Events {19 Transfer {20 #[indexed]21 from: address,22 #[indexed]23 to: address,24 value: uint256,25 },26 Approval {27 #[indexed]28 owner: address,29 #[indexed]30 spender: address,31 value: uint256,32 },33}3435#[solidity_interface(name = "ERC20", events(ERC20Events))]36impl<T: Config> FungibleHandle<T> {37 fn name(&self) -> Result<string> {38 Ok(decode_utf16(self.name.iter().copied())39 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))40 .collect::<string>())41 }42 fn symbol(&self) -> Result<string> {43 Ok(string::from_utf8_lossy(&self.token_prefix).into())44 }45 fn total_supply(&self) -> Result<uint256> {46 self.consume_store_reads(1)?;47 Ok(<TotalSupply<T>>::get(self.id).into())48 }4950 fn decimals(&self) -> Result<uint8> {51 Ok(if let CollectionMode::Fungible(decimals) = &self.mode {52 *decimals53 } else {54 unreachable!()55 })56 }57 fn balance_of(&self, owner: address) -> Result<uint256> {58 self.consume_store_reads(1)?;59 let owner = T::CrossAccountId::from_eth(owner);60 let balance = <Balance<T>>::get((self.id, owner));61 Ok(balance.into())62 }63 #[weight(<SelfWeightOf<T>>::transfer())]64 fn transfer(&mut self, caller: caller, to: address, amount: uint256) -> Result<bool> {65 let caller = T::CrossAccountId::from_eth(caller);66 let to = T::CrossAccountId::from_eth(to);67 let amount = amount.try_into().map_err(|_| "amount overflow")?;6869 <Pallet<T>>::transfer(self, &caller, &to, amount).map_err(|_| "transfer error")?;70 Ok(true)71 }72 #[weight(<SelfWeightOf<T>>::transfer_from())]73 fn transfer_from(74 &mut self,75 caller: caller,76 from: address,77 to: address,78 amount: uint256,79 ) -> Result<bool> {80 let caller = T::CrossAccountId::from_eth(caller);81 let from = T::CrossAccountId::from_eth(from);82 let to = T::CrossAccountId::from_eth(to);83 let amount = amount.try_into().map_err(|_| "amount overflow")?;8485 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount)86 .map_err(dispatch_to_evm::<T>)?;87 Ok(true)88 }89 #[weight(<SelfWeightOf<T>>::approve())]90 fn approve(&mut self, caller: caller, spender: address, amount: uint256) -> Result<bool> {91 let caller = T::CrossAccountId::from_eth(caller);92 let spender = T::CrossAccountId::from_eth(spender);93 let amount = amount.try_into().map_err(|_| "amount overflow")?;9495 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)96 .map_err(dispatch_to_evm::<T>)?;97 Ok(true)98 }99 fn allowance(&self, owner: address, spender: address) -> Result<uint256> {100 self.consume_store_reads(1)?;101 let owner = T::CrossAccountId::from_eth(owner);102 let spender = T::CrossAccountId::from_eth(spender);103104 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())105 }106}107108#[solidity_interface(name = "ERC20UniqueExtensions")]109impl<T: Config> FungibleHandle<T> {110 #[weight(<SelfWeightOf<T>>::burn_from())]111 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {112 let caller = T::CrossAccountId::from_eth(caller);113 let from = T::CrossAccountId::from_eth(from);114 let amount = amount.try_into().map_err(|_| "amount overflow")?;115116 <Pallet<T>>::burn_from(self, &caller, &from, amount).map_err(dispatch_to_evm::<T>)?;117 Ok(true)118 }119}120121#[solidity_interface(name = "UniqueFungible", is(ERC20))]122impl<T: Config> FungibleHandle<T> {}123124generate_stubgen!(gen_impl, UniqueFungibleCall<()>, true);125generate_stubgen!(gen_iface, UniqueFungibleCall<()>, false);126127impl<T: Config> CommonEvmHandler for FungibleHandle<T> {128 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueFungible.raw");129130 fn call(self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileOutput> {131 call::<T, UniqueFungibleCall<T>, _>(*source, self, value, input)132 }133}1use core::char::{REPLACEMENT_CHARACTER, decode_utf16};2use core::convert::TryInto;3use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};4use nft_data_structs::CollectionMode;5use pallet_common::erc::{CommonEvmHandler, PrecompileResult};6use sp_core::{H160, U256};7use sp_std::vec::Vec;8use pallet_common::account::CrossAccountId;9use pallet_common::erc::PrecompileOutput;10use pallet_evm_coder_substrate::{call, dispatch_to_evm};1112use crate::{13 Allowance, Balance, Config, FungibleHandle, Pallet, SelfWeightOf, TotalSupply,14 weights::WeightInfo,15};1617#[derive(ToLog)]18pub enum ERC20Events {19 Transfer {20 #[indexed]21 from: address,22 #[indexed]23 to: address,24 value: uint256,25 },26 Approval {27 #[indexed]28 owner: address,29 #[indexed]30 spender: address,31 value: uint256,32 },33}3435#[solidity_interface(name = "ERC20", events(ERC20Events))]36impl<T: Config> FungibleHandle<T> {37 fn name(&self) -> Result<string> {38 Ok(decode_utf16(self.name.iter().copied())39 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))40 .collect::<string>())41 }42 fn symbol(&self) -> Result<string> {43 Ok(string::from_utf8_lossy(&self.token_prefix).into())44 }45 fn total_supply(&self) -> Result<uint256> {46 self.consume_store_reads(1)?;47 Ok(<TotalSupply<T>>::get(self.id).into())48 }4950 fn decimals(&self) -> Result<uint8> {51 Ok(if let CollectionMode::Fungible(decimals) = &self.mode {52 *decimals53 } else {54 unreachable!()55 })56 }57 fn balance_of(&self, owner: address) -> Result<uint256> {58 self.consume_store_reads(1)?;59 let owner = T::CrossAccountId::from_eth(owner);60 let balance = <Balance<T>>::get((self.id, owner));61 Ok(balance.into())62 }63 #[weight(<SelfWeightOf<T>>::transfer())]64 fn transfer(&mut self, caller: caller, to: address, amount: uint256) -> Result<bool> {65 let caller = T::CrossAccountId::from_eth(caller);66 let to = T::CrossAccountId::from_eth(to);67 let amount = amount.try_into().map_err(|_| "amount overflow")?;6869 <Pallet<T>>::transfer(self, &caller, &to, amount).map_err(|_| "transfer error")?;70 Ok(true)71 }72 #[weight(<SelfWeightOf<T>>::transfer_from())]73 fn transfer_from(74 &mut self,75 caller: caller,76 from: address,77 to: address,78 amount: uint256,79 ) -> Result<bool> {80 let caller = T::CrossAccountId::from_eth(caller);81 let from = T::CrossAccountId::from_eth(from);82 let to = T::CrossAccountId::from_eth(to);83 let amount = amount.try_into().map_err(|_| "amount overflow")?;8485 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount)86 .map_err(dispatch_to_evm::<T>)?;87 Ok(true)88 }89 #[weight(<SelfWeightOf<T>>::approve())]90 fn approve(&mut self, caller: caller, spender: address, amount: uint256) -> Result<bool> {91 let caller = T::CrossAccountId::from_eth(caller);92 let spender = T::CrossAccountId::from_eth(spender);93 let amount = amount.try_into().map_err(|_| "amount overflow")?;9495 <Pallet<T>>::set_allowance(self, &caller, &spender, amount)96 .map_err(dispatch_to_evm::<T>)?;97 Ok(true)98 }99 fn allowance(&self, owner: address, spender: address) -> Result<uint256> {100 self.consume_store_reads(1)?;101 let owner = T::CrossAccountId::from_eth(owner);102 let spender = T::CrossAccountId::from_eth(spender);103104 Ok(<Allowance<T>>::get((self.id, owner, spender)).into())105 }106}107108#[solidity_interface(name = "ERC20UniqueExtensions")]109impl<T: Config> FungibleHandle<T> {110 #[weight(<SelfWeightOf<T>>::burn_from())]111 fn burn_from(&mut self, caller: caller, from: address, amount: uint256) -> Result<bool> {112 let caller = T::CrossAccountId::from_eth(caller);113 let from = T::CrossAccountId::from_eth(from);114 let amount = amount.try_into().map_err(|_| "amount overflow")?;115116 <Pallet<T>>::burn_from(self, &caller, &from, amount).map_err(dispatch_to_evm::<T>)?;117 Ok(true)118 }119}120121#[solidity_interface(name = "UniqueFungible", is(ERC20))]122impl<T: Config> FungibleHandle<T> {}123124generate_stubgen!(gen_impl, UniqueFungibleCall<()>, true);125generate_stubgen!(gen_iface, UniqueFungibleCall<()>, false);126127impl<T: Config> CommonEvmHandler for FungibleHandle<T> {128 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueFungible.raw");129130 fn call(self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileResult> {131 call::<T, UniqueFungibleCall<T>, _>(*source, self, value, input)132 }133}pallets/nft/Cargo.tomldiffbeforeafterboth--- a/pallets/nft/Cargo.toml
+++ b/pallets/nft/Cargo.toml
@@ -131,7 +131,7 @@
scale-info = { version = "1.0.0", default-features = false, features = [
"derive",
] }
-ethereum = { version = "0.9", git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }
+ethereum = { version = "0.10.0", default-features = false }
rlp = { default-features = false, version = "0.5.0" }
sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.12" }
pallets/nft/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/mod.rs
+++ b/pallets/nft/src/eth/mod.rs
@@ -1,5 +1,6 @@
pub mod sponsoring;
+use fp_evm::PrecompileResult;
use pallet_common::{
CollectionById,
erc::CommonEvmHandler,
@@ -10,7 +11,6 @@
use pallet_refungible::{RefungibleHandle, erc::RefungibleTokenHandle};
use sp_std::borrow::ToOwned;
use sp_std::vec::Vec;
-use pallet_evm::{PrecompileOutput};
use sp_core::{H160, U256};
use crate::{CollectionMode, Config, dispatch::Dispatched};
use pallet_common::CollectionHandle;
@@ -54,7 +54,7 @@
gas_limit: u64,
input: &[u8],
value: U256,
- ) -> Option<PrecompileOutput> {
+ ) -> Option<PrecompileResult> {
if let Some(collection_id) = map_eth_to_id(target) {
let collection = <CollectionHandle<T>>::new_with_gas_limit(collection_id, gas_limit)?;
let dispatched = Dispatched::dispatch(collection);
pallets/nft/src/eth/sponsoring.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/sponsoring.rs
+++ b/pallets/nft/src/eth/sponsoring.rs
@@ -27,7 +27,7 @@
let (method_id, mut reader) = AbiReader::new_call(&call.1).ok()?;
match &collection.mode {
crate::CollectionMode::NFT => {
- let call = UniqueNFTCall::parse(method_id, &mut reader).ok()??;
+ let call = <UniqueNFTCall<T>>::parse(method_id, &mut reader).ok()??;
match call {
UniqueNFTCall::ERC721UniqueExtensions(
ERC721UniqueExtensionsCall::Transfer { token_id, .. },
@@ -49,7 +49,7 @@
}
}
crate::CollectionMode::Fungible(_) => {
- let call = UniqueFungibleCall::parse(method_id, &mut reader).ok()??;
+ let call = <UniqueFungibleCall<T>>::parse(method_id, &mut reader).ok()??;
#[allow(clippy::single_match)]
match call {
UniqueFungibleCall::ERC20(ERC20Call::Transfer { .. }) => {
pallets/nonfungible/Cargo.tomldiffbeforeafterboth--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -19,7 +19,7 @@
nft-data-structs = { default-features = false, path = '../../primitives/nft' }
evm-coder = { default-features = false, path = '../../crates/evm-coder' }
pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }
-ethereum = { git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }
+ethereum = { version = "0.10.0", default-features = false }
frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }
scale-info = { version = "1.0.0", default-features = false, features = [
"derive",
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -8,7 +8,10 @@
use pallet_evm_coder_substrate::dispatch_to_evm;
use sp_core::{H160, U256};
use sp_std::{vec::Vec, vec};
-use pallet_common::{account::CrossAccountId, erc::CommonEvmHandler};
+use pallet_common::{
+ account::CrossAccountId,
+ erc::{CommonEvmHandler, PrecompileResult},
+};
use pallet_evm_coder_substrate::call;
use pallet_common::erc::PrecompileOutput;
@@ -434,7 +437,7 @@
impl<T: Config> CommonEvmHandler for NonfungibleHandle<T> {
const CODE: &'static [u8] = include_bytes!("./stubs/UniqueNFT.raw");
- fn call(self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileOutput> {
+ fn call(self, source: &H160, input: &[u8], value: U256) -> Option<PrecompileResult> {
call::<T, UniqueNFTCall<T>, _>(*source, self, value, input)
}
}
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -11,7 +11,7 @@
_source: &sp_core::H160,
_input: &[u8],
_value: sp_core::U256,
- ) -> Option<pallet_common::erc::PrecompileOutput> {
+ ) -> Option<pallet_common::erc::PrecompileResult> {
// TODO: Implement RFT variant of ERC721
None
}
@@ -27,7 +27,7 @@
_source: &sp_core::H160,
_input: &[u8],
_value: sp_core::U256,
- ) -> Option<pallet_common::erc::PrecompileOutput> {
+ ) -> Option<pallet_common::erc::PrecompileResult> {
// TODO: Implement RFT variant of ERC20
None
}