Skip to content

Commit

Permalink
Feature/balance precompiles (#1845)
Browse files Browse the repository at this point in the history
* More precompiles

* Fix typos

* Fix tests for balances-erc20

* Patch frontier&fix issues found when mint erc20
  • Loading branch information
yrong authored Aug 18, 2022
1 parent 4feffcc commit 34f7995
Show file tree
Hide file tree
Showing 25 changed files with 3,226 additions and 175 deletions.
123 changes: 78 additions & 45 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ lto = true
members = ['node/*', 'pallets/*', 'runtime/*', 'support', 'precompiles/*','integration-tests']

[patch.crates-io]
#orml
orml-oracle = { git = 'https://github.com/open-web3-stack/open-runtime-module-library.git', rev = '8c625a5ab43c1c56cdeed5f8d814a891566d4cf8' }
orml-oracle-rpc = { git = 'https://github.com/open-web3-stack/open-runtime-module-library.git', rev = '8c625a5ab43c1c56cdeed5f8d814a891566d4cf8' }
orml-oracle-rpc-runtime-api = { git = 'https://github.com/open-web3-stack/open-runtime-module-library.git', rev = '8c625a5ab43c1c56cdeed5f8d814a891566d4cf8' }
Expand All @@ -22,3 +23,25 @@ orml-vesting = { git = 'https://github.com/open-web3-stack/open-r
orml-xcm = { git = 'https://github.com/open-web3-stack/open-runtime-module-library.git', rev = '8c625a5ab43c1c56cdeed5f8d814a891566d4cf8' }
orml-xcm-support = { git = 'https://github.com/open-web3-stack/open-runtime-module-library.git', rev = '8c625a5ab43c1c56cdeed5f8d814a891566d4cf8' }
orml-xtokens = { git = 'https://github.com/open-web3-stack/open-runtime-module-library.git', rev = '8c625a5ab43c1c56cdeed5f8d814a891566d4cf8' }
#evm
fc-consensus = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fc-db = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fc-mapping-sync = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fc-rpc = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fc-rpc-core = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fp-consensus = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fp-evm = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fp-rpc = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fp-storage = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fp-dynamic-fee = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-ethereum = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-evm = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
fp-self-contained = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-base-fee = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-evm-precompile-blake2 = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-evm-precompile-bn128 = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-evm-precompile-dispatch = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-evm-precompile-ed25519 = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-evm-precompile-modexp = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-evm-precompile-sha3fips = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
pallet-evm-precompile-simple = { git = 'https://github.com/parallel-finance/frontier.git', rev = 'a782f9ab37a442c2c6eb0d9d54b1634a24a9e20b' }
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ clean:
cargo clean -p parallel -p vanilla-runtime -p kerria-runtime -p heiko-runtime -p parallel-runtime

.PHONY: ci
ci: check lint check-helper check-wasm test integration-test
ci: check check-with-evm lint check-helper check-wasm test integration-test

.PHONY: check
check:
SKIP_WASM_BUILD= cargo check --all-targets --features runtime-benchmarks --features try-runtime

.PHONY: check-with-evm
check-with-evm:
SKIP_WASM_BUILD= cargo check --all-targets --features with-evm-runtime --features runtime-benchmarks --features try-runtime
SKIP_WASM_BUILD= cargo check --all-targets --features with-evm-runtime --features runtime-benchmarks --features try-runtime --features testing

.PHONY: check-wasm
check-wasm:
Expand Down Expand Up @@ -115,6 +115,9 @@ integration-test-kusama-call:
integration-test-sibling-transfer:
RUST_LOG="xcm=trace,xcm-executor=trace" SKIP_WASM_BUILD= cargo test -p runtime-integration-tests -- sibling_transfer --nocapture

.PHONY: test-pallet-evm-precompile-balances-erc20
test-pallet-evm-precompile-balances-erc20:
SKIP_WASM_BUILD= cargo test -p pallet-evm-precompile-balances-erc20 --lib --no-fail-fast -- --nocapture

.PHONY: bench
bench:build-release-if-not-exists
Expand Down
29 changes: 15 additions & 14 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"relaychain": {
"bin": "../polkadot/target/release/polkadot",
"chain": "rococo-local",
"chain": "polkadot-local",
"nodes": [
{
"name": "alice",
Expand Down Expand Up @@ -53,22 +53,22 @@
}
],
"genesis": {
"runtime": {
"runtime_genesis_config": {
"configuration": {
"config": {
"validation_upgrade_frequency": 10,
"validation_upgrade_delay": 10
}
}
}
}
}
"runtime": {
"runtime_genesis_config": {
"configuration": {
"config": {
"validation_upgrade_frequency": 10,
"validation_upgrade_delay": 10
}
}
}
}
}
},
"parachains": [
{
"bin": "./target/release/parallel",
"chain": "vanilla-dev",
"chain": "kerria-dev",
"nodes": [
{
"wsPort": 9948,
Expand All @@ -86,7 +86,8 @@
"0"
]
}
]
],
"id": 2012
}
],
"simpleParachains": [],
Expand Down
26 changes: 14 additions & 12 deletions node/parallel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,20 @@ polkadot-primitives = { git = 'https://github.com/paritytech/polkadot.git', bran
polkadot-service = { git = 'https://github.com/paritytech/polkadot.git', branch = 'release-v0.9.26' }

# Frontier dependencies
fc-consensus = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
fc-db = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
fc-mapping-sync = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
fc-rpc = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26", features = ["rpc_binary_search_estimate"] }
fc-rpc-core = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
fp-consensus = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
fp-evm = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26", default-features = false }
fp-rpc = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
fp-storage = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
fp-dynamic-fee = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
pallet-ethereum = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
pallet-evm = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26" }
fc-consensus = { version='2.0.0-dev' }
fc-db = { version='2.0.0-dev' }
fc-mapping-sync = { version='2.0.0-dev' }
fc-rpc = { version='2.0.0-dev', features = ["rpc_binary_search_estimate"] }
fc-rpc-core = { version='1.1.0-dev' }
fp-consensus = { version='2.0.0-dev' }
fp-evm = { version='3.0.0-dev', default-features = false }
fp-storage = { version='2.0.0' }
fp-dynamic-fee = { version='1.0.0' }
fp-rpc = { version='3.0.0-dev'}
fp-self-contained = { version='1.0.0-dev'}
pallet-base-fee = { version='1.0.0'}
pallet-ethereum = { version='4.0.0-dev'}
pallet-evm = { version='6.0.0-dev'}


[build-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions node/parallel/src/chain_spec/kerria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use kerria_runtime::{
CollatorSelectionConfig, CrowdloansAutomatorsMembershipConfig, DemocracyConfig, EVMConfig,
GeneralCouncilConfig, GeneralCouncilMembershipConfig, GenesisConfig,
LiquidStakingAgentsMembershipConfig, LiquidStakingConfig, OracleMembershipConfig,
ParachainInfoConfig, PolkadotXcmConfig, Precompiles, SessionConfig, SudoConfig, SystemConfig,
TechnicalCommitteeMembershipConfig, VestingConfig, WASM_BINARY,
ParachainInfoConfig, ParallelPrecompilesType, PolkadotXcmConfig, SessionConfig, SudoConfig,
SystemConfig, TechnicalCommitteeMembershipConfig, VestingConfig, WASM_BINARY,
};
use primitives::{network::NetworkType, *};
use sc_service::ChainType;
Expand Down Expand Up @@ -207,7 +207,7 @@ fn kerria_genesis(
evm: EVMConfig {
// We need _some_ code inserted at the precompile address so that
// the evm will actually call the address.
accounts: Precompiles::used_addresses()
accounts: ParallelPrecompilesType::used_addresses()
.map(|addr| {
(
addr,
Expand Down
6 changes: 3 additions & 3 deletions node/parallel/src/chain_spec/vanilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use vanilla_runtime::{
CollatorSelectionConfig, CrowdloansAutomatorsMembershipConfig, DemocracyConfig, EVMConfig,
GeneralCouncilConfig, GeneralCouncilMembershipConfig, GenesisConfig,
LiquidStakingAgentsMembershipConfig, LiquidStakingConfig, OracleMembershipConfig,
ParachainInfoConfig, PolkadotXcmConfig, Precompiles, SessionConfig, SudoConfig, SystemConfig,
TechnicalCommitteeMembershipConfig, VestingConfig, WASM_BINARY,
ParachainInfoConfig, ParallelPrecompilesType, PolkadotXcmConfig, SessionConfig, SudoConfig,
SystemConfig, TechnicalCommitteeMembershipConfig, VestingConfig, WASM_BINARY,
};

use crate::chain_spec::{
Expand Down Expand Up @@ -276,7 +276,7 @@ fn vanilla_genesis(
evm: EVMConfig {
// We need _some_ code inserted at the precompile address so that
// the evm will actually call the address.
accounts: Precompiles::used_addresses()
accounts: ParallelPrecompilesType::used_addresses()
.map(|addr| {
(
addr,
Expand Down
9 changes: 6 additions & 3 deletions precompiles/assets-erc20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ version = '1.9.0'
[dependencies]
log = "0.4.16"
num_enum = { version = "0.5.3", default-features = false }
paste = "1.0.6"
slices = "0.2.0"

precompile-utils = { path = "../utils", default-features = false }
Expand All @@ -17,14 +18,16 @@ frame-support = { git = "https://github.com/paritytech/substrate", branch = "pol
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26", default-features = false }
pallet-assets = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26", default-features = false }
scale-info = { version = "2.1.0", default-features = false, features = [ "derive" ] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26", default-features = false }

# Frontier
fp-evm = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26", default-features = false }
pallet-evm = { git = "https://github.com/parallel-finance/frontier", branch = "polkadot-v0.9.26", default-features = false }
fp-evm = { version='3.0.0-dev', default-features = false }
pallet-evm = { version='6.0.0-dev', default-features = false }

[dev-dependencies]
derive_more = { version = "0.99" }
Expand All @@ -34,7 +37,6 @@ sha3 = "0.10.1"
precompile-utils = { path = "../utils", features = ["testing"] }

codec = { package = "parity-scale-codec", version = "3.0.0", features = ["max-encoded-len"] }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26" }
scale-info = { version = "2.1.0", default-features = false, features = ["derive"] }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.26" }

Expand All @@ -48,6 +50,7 @@ std = [
"pallet-assets/std",
"pallet-evm/std",
"pallet-balances/std",
"pallet-timestamp/std",
"precompile-utils/std",
"sp-core/std",
"sp-io/std",
Expand Down
Loading

0 comments on commit 34f7995

Please sign in to comment.