Skip to content

Commit 5f95c0b

Browse files
pgherveouatheiactions-user
authored andcommitted
[pallet-revive] Add Ethereum JSON-RPC server (paritytech#6147)
Redo of paritytech#5953 --------- Co-authored-by: Alexander Theißen <alex.theissen@me.com> Co-authored-by: GitHub Action <action@github.com>
1 parent 7d04b0b commit 5f95c0b

39 files changed

Lines changed: 2823 additions & 20 deletions

Cargo.lock

Lines changed: 163 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ members = [
402402
"substrate/frame/revive/fixtures",
403403
"substrate/frame/revive/mock-network",
404404
"substrate/frame/revive/proc-macro",
405+
"substrate/frame/revive/rpc",
405406
"substrate/frame/revive/uapi",
406407
"substrate/frame/root-offences",
407408
"substrate/frame/root-testing",
@@ -965,6 +966,7 @@ pallet-recovery = { path = "substrate/frame/recovery", default-features = false
965966
pallet-referenda = { path = "substrate/frame/referenda", default-features = false }
966967
pallet-remark = { default-features = false, path = "substrate/frame/remark" }
967968
pallet-revive = { path = "substrate/frame/revive", default-features = false }
969+
pallet-revive-eth-rpc = { path = "substrate/frame/revive/rpc", default-features = false }
968970
pallet-revive-fixtures = { path = "substrate/frame/revive/fixtures", default-features = false }
969971
pallet-revive-mock-network = { default-features = false, path = "substrate/frame/revive/mock-network" }
970972
pallet-revive-proc-macro = { path = "substrate/frame/revive/proc-macro", default-features = false }

cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use frame_system::{
5858
};
5959
use pallet_asset_conversion_tx_payment::SwapAssetAdapter;
6060
use pallet_nfts::{DestroyWitness, PalletFeatures};
61-
use pallet_revive::evm::runtime::EthExtra;
61+
use pallet_revive::{evm::runtime::EthExtra, AddressMapper};
6262
use parachains_common::{
6363
impls::DealWithFees, message_queue::*, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
6464
BlockNumber, CollectionId, Hash, Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
@@ -2069,8 +2069,17 @@ impl_runtime_apis! {
20692069
}
20702070
}
20712071

2072-
impl pallet_revive::ReviveApi<Block, AccountId, Balance, BlockNumber, EventRecord> for Runtime
2072+
impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber, EventRecord> for Runtime
20732073
{
2074+
fn balance(address: H160) -> Balance {
2075+
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
2076+
Balances::usable_balance(account)
2077+
}
2078+
2079+
fn nonce(address: H160) -> Nonce {
2080+
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
2081+
System::account_nonce(account)
2082+
}
20742083
fn eth_transact(
20752084
from: H160,
20762085
dest: Option<H160>,

prdoc/pr_6147.prdoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
title: "[pallet-revive] Ethereum JSON-RPC"
2+
3+
doc:
4+
- audience: Runtime Dev
5+
description: |
6+
Add a new Ethereum JSON-RPC server that can be used a substrate chain configured with pallet-revive
7+
crates:
8+
- name: pallet-revive
9+
bump: patch
10+
- name: asset-hub-westend-runtime
11+
bump: patch
12+
- name: pallet-revive-eth-rpc
13+
bump: patch
14+
- name: pallet-revive-fixtures
15+
bump: patch
16+
- name: polkadot-sdk
17+
bump: patch

substrate/bin/node/cli/src/chain_spec.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,6 @@ fn default_endowed_accounts() -> Vec<AccountId> {
437437
.chain([
438438
eth_account(subxt_signer::eth::dev::alith()),
439439
eth_account(subxt_signer::eth::dev::baltathar()),
440-
eth_account(subxt_signer::eth::dev::charleth()),
441-
eth_account(subxt_signer::eth::dev::dorothy()),
442-
eth_account(subxt_signer::eth::dev::ethan()),
443-
eth_account(subxt_signer::eth::dev::faith()),
444440
])
445441
.collect()
446442
}

substrate/bin/node/runtime/src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use pallet_identity::legacy::IdentityInfo;
7676
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
7777
use pallet_nfts::PalletFeatures;
7878
use pallet_nis::WithMaximumOf;
79-
use pallet_revive::evm::runtime::EthExtra;
79+
use pallet_revive::{evm::runtime::EthExtra, AddressMapper};
8080
use pallet_session::historical as pallet_session_historical;
8181
// Can't use `FungibleAdapter` here until Treasury pallet migrates to fungibles
8282
// <https://github.com/paritytech/polkadot-sdk/issues/226>
@@ -3157,8 +3157,18 @@ impl_runtime_apis! {
31573157
}
31583158
}
31593159

3160-
impl pallet_revive::ReviveApi<Block, AccountId, Balance, BlockNumber, EventRecord> for Runtime
3160+
impl pallet_revive::ReviveApi<Block, AccountId, Balance, Nonce, BlockNumber, EventRecord> for Runtime
31613161
{
3162+
fn balance(address: H160) -> Balance {
3163+
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
3164+
Balances::usable_balance(account)
3165+
}
3166+
3167+
fn nonce(address: H160) -> Nonce {
3168+
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
3169+
System::account_nonce(account)
3170+
}
3171+
31623172
fn eth_transact(
31633173
from: H160,
31643174
dest: Option<H160>,

0 commit comments

Comments
 (0)