Skip to content

Commit

Permalink
Update evm to 0.39 (#2312)
Browse files Browse the repository at this point in the history
* Update evm to 0.39

* Adapted tests

Fixed parameter in execute is_precompile_or_fail check

format

* Removed unused imports

* Wip fallible discriminant

* fmt

* wip fix test assets costs

* fix test assets costs

* TODO temp ignore precompile macro tests

---------

Co-authored-by: tgmichel <telmo@purestake.com>
Co-authored-by: Francisco Gamundi <francisco@purestake.com>
  • Loading branch information
3 people authored and timbrinded committed Jun 2, 2023
1 parent c6e579c commit 8f502bb
Show file tree
Hide file tree
Showing 18 changed files with 416 additions and 232 deletions.
84 changes: 54 additions & 30 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
exclude = [ "bin/utils/moonkey" ]
exclude = ["bin/utils/moonkey"]
members = [
"bin/utils/moonkey",
"client/rpc/finality",
Expand Down Expand Up @@ -42,7 +42,7 @@ members = [
resolver = "2"

[workspace.package]
authors = [ "PureStake" ]
authors = ["PureStake"]
repository = "https://github.com/PureStake/moonbeam"

[workspace.dependencies]
Expand Down Expand Up @@ -226,11 +226,11 @@ ethereum = { version = "0.14.0", default-features = false, features = [
"with-codec",
] }
ethereum-types = { version = "0.14", default-features = false }
evm = { version = "0.37.0", default-features = false, features = [
evm = { version = "0.39.0", default-features = false, features = [
"with-codec",
] }
evm-gasometer = { version = "0.37.0", default-features = false }
evm-runtime = { version = "0.37.0", default-features = false }
evm-gasometer = { version = "0.39.0", default-features = false }
evm-runtime = { version = "0.39.0", default-features = false }
fp-ethereum = { git = "https://github.com/purestake/frontier", branch = "moonbeam-polkadot-v0.9.40", default-features = false }
fp-evm = { git = "https://github.com/purestake/frontier", branch = "moonbeam-polkadot-v0.9.40", default-features = false }
fp-rpc = { git = "https://github.com/purestake/frontier", branch = "moonbeam-polkadot-v0.9.40", default-features = false }
Expand Down Expand Up @@ -333,7 +333,7 @@ serde = { version = "1.0.101", default-features = false }
sha3 = { version = "0.10", default-features = false }
slices = "0.2.0"
smallvec = "1.8.0"
strum = { version = "0.24", default-features = false, features = [ "derive" ] }
strum = { version = "0.24", default-features = false, features = ["derive"] }
strum_macros = "0.24"

# Other (client)
Expand All @@ -343,7 +343,7 @@ async-io = "1.3"
bip32 = { git = "https://github.com/purestake/crates", branch = "bip32-v0.4.0-fix", default-features = false, features = [
"bip39",
] }
clap = { version = "4.0.9", features = [ "derive" ] }
clap = { version = "4.0.9", features = ["derive"] }
exit-future = "0.2"
flume = "0.10.9"
futures = { version = "0.3.21" }
Expand Down
17 changes: 11 additions & 6 deletions precompiles/assets-erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

use core::fmt::Display;
use fp_evm::PrecompileHandle;
use fp_evm::{ExitError, PrecompileHandle};
use frame_support::traits::fungibles::Inspect;
use frame_support::traits::fungibles::{
approvals::Inspect as ApprovalInspect, metadata::Inspect as MetadataInspect,
Expand Down Expand Up @@ -133,20 +133,25 @@ where
AssetIdOf<Runtime, Instance>: Display,
Runtime::AccountId: Into<H160>,
{
/// PrecompileSet discrimiant. Allows to knows if the address maps to an asset id,
/// PrecompileSet discriminant. Allows to knows if the address maps to an asset id,
/// and if this is the case which one.
#[precompile::discriminant]
fn discriminant(address: H160) -> Option<AssetIdOf<Runtime, Instance>> {
fn discriminant(address: H160, gas: u64) -> DiscriminantResult<AssetIdOf<Runtime, Instance>> {
let extra_cost = RuntimeHelper::<Runtime>::db_read_gas_cost();
if gas < extra_cost {
return DiscriminantResult::OutOfGas;
}

let account_id = Runtime::AddressMapping::into_account_id(address);
let asset_id = match Runtime::account_to_asset_id(account_id) {
Some((_, asset_id)) => asset_id,
None => return None,
None => return DiscriminantResult::None(extra_cost),
};

if pallet_assets::Pallet::<Runtime, Instance>::maybe_total_supply(asset_id).is_some() {
Some(asset_id)
DiscriminantResult::Some(asset_id, extra_cost)
} else {
None
DiscriminantResult::None(extra_cost)
}
}

Expand Down
Loading

0 comments on commit 8f502bb

Please sign in to comment.