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

[pallet-revive] fix eth-rpc indexing #7493

Merged
merged 27 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/workflows/build-publish-eth-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ concurrency:

env:
ETH_RPC_IMAGE_NAME: "docker.io/paritypr/eth-rpc"
ETH_INDEXER_IMAGE_NAME: "docker.io/paritypr/eth-indexer"

jobs:
set-variables:
Expand Down Expand Up @@ -53,15 +52,6 @@ jobs:
tags: |
${{ env.ETH_RPC_IMAGE_NAME }}:${{ env.VERSION }}

- name: Build eth-indexer Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./substrate/frame/revive/rpc/dockerfiles/eth-indexer/Dockerfile
push: false
tags: |
${{ env.ETH_INDEXER_IMAGE_NAME }}:${{ env.VERSION }}

build_push_docker:
name: Build and push docker images
runs-on: parity-large
Expand All @@ -88,11 +78,3 @@ jobs:
tags: |
${{ env.ETH_RPC_IMAGE_NAME }}:${{ env.VERSION }}

- name: Build eth-indexer Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./substrate/frame/revive/rpc/dockerfiles/eth-indexer/Dockerfile
push: true
tags: |
${{ env.ETH_INDEXER_IMAGE_NAME }}:${{ env.VERSION }}
31 changes: 15 additions & 16 deletions Cargo.lock

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

29 changes: 18 additions & 11 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ClaimQueueOffset, CoreSelector, ParaId};
use frame_support::{
construct_runtime, derive_impl,
dispatch::DispatchClass,
dispatch::{DispatchClass, DispatchInfo},
genesis_builder_helper::{build_state, get_preset},
ord_parameter_types, parameter_types,
traits::{
Expand Down Expand Up @@ -71,7 +71,9 @@ use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160, U256};
use sp_runtime::{
generic, impl_opaque_keys,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, Saturating, Verify},
traits::{
AccountIdConversion, BlakeTwo256, Block as BlockT, Saturating, TransactionExtension, Verify,
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Perbill, Permill, RuntimeDebug,
};
Expand Down Expand Up @@ -129,7 +131,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: alloc::borrow::Cow::Borrowed("westmint"),
impl_name: alloc::borrow::Cow::Borrowed("westmint"),
authoring_version: 1,
spec_version: 1_017_006,
spec_version: 1_017_007,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 16,
Expand Down Expand Up @@ -2216,6 +2218,10 @@ impl_runtime_apis! {
Revive::evm_block_gas_limit()
}

fn gas_price() -> U256 {
Revive::evm_gas_price()
}

fn nonce(address: H160) -> Nonce {
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
System::account_nonce(account)
Expand All @@ -2224,18 +2230,19 @@ impl_runtime_apis! {
fn eth_transact(tx: pallet_revive::evm::GenericTransaction) -> Result<pallet_revive::EthTransactInfo<Balance>, pallet_revive::EthTransactError>
{
let blockweights: BlockWeights = <Runtime as frame_system::Config>::BlockWeights::get();

let encoded_size = |pallet_call| {
let tx_fee = |pallet_call, mut dispatch_info: DispatchInfo| {
let call = RuntimeCall::Revive(pallet_call);
dispatch_info.extension_weight = EthExtraImpl::get_eth_extension(0, 0u32.into()).weight(&call);
let uxt: UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic::new_bare(call).into();
uxt.encoded_size() as u32

pallet_transaction_payment::Pallet::<Runtime>::compute_fee(
uxt.encoded_size() as u32,
&dispatch_info,
0u32.into(),
)
};

Revive::bare_eth_transact(
tx,
blockweights.max_block,
encoded_size,
)
Revive::bare_eth_transact(tx, blockweights.max_block, tx_fee)
}

fn call(
Expand Down
17 changes: 17 additions & 0 deletions prdoc/pr_7463.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
title: '[pallet-revive] tx fee fixes'
doc:
- audience: Runtime Dev
description: |-
Apply some fixes to properly estimate ethereum tx fees:

- Set the `extension_weight` on the dispatch_info to properly calculate the fee with pallet_transaction_payment
- Expose the gas_price through Runtime API, just in case we decide to tweak the value in future updates, it should be read from the chain rather than be a shared constant exposed by the crate
- add a `evm_gas_to_fee` utility function to properly convert gas to substrate fee
- Fix some minor gas encoding for edge cases
crates:
- name: asset-hub-westend-runtime
bump: minor
- name: pallet-revive-eth-rpc
bump: minor
- name: pallet-revive
bump: minor
7 changes: 7 additions & 0 deletions prdoc/pr_7482.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: '[pallet-revive] rpc - gas used fixes '
doc:
- audience: Runtime Dev
description: '#7463 follow up with RPC fixes'
crates:
- name: pallet-revive-eth-rpc
bump: minor
9 changes: 9 additions & 0 deletions prdoc/pr_7493.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: '[pallet-revive] fix eth-rpc indexing'
doc:
- audience: Runtime Dev
description: |-
- Fix a deadlock on the RWLock cache
- Remove eth-indexer, we won't need it anymore, the indexing will be started from within eth-rpc directly
crates:
- name: pallet-revive-eth-rpc
bump: minor
24 changes: 15 additions & 9 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use frame_election_provider_support::{
};
use frame_support::{
derive_impl,
dispatch::DispatchClass,
dispatch::{DispatchClass, DispatchInfo},
dynamic_params::{dynamic_pallet_params, dynamic_params},
genesis_builder_helper::{build_state, get_preset},
instances::{Instance1, Instance2},
Expand Down Expand Up @@ -89,6 +89,7 @@ use pallet_nomination_pools::PoolId;
use pallet_revive::{evm::runtime::EthExtra, AddressMapper};
use pallet_session::historical as pallet_session_historical;
use sp_core::U256;
use sp_runtime::traits::TransactionExtension;
// Can't use `FungibleAdapter` here until Treasury pallet migrates to fungibles
// <https://github.com/paritytech/polkadot-sdk/issues/226>
use pallet_broker::TaskId;
Expand Down Expand Up @@ -3313,6 +3314,10 @@ impl_runtime_apis! {
Revive::evm_block_gas_limit()
}

fn gas_price() -> U256 {
Revive::evm_gas_price()
}

fn nonce(address: H160) -> Nonce {
let account = <Runtime as pallet_revive::Config>::AddressMapper::to_account_id(&address);
System::account_nonce(account)
Expand All @@ -3321,18 +3326,19 @@ impl_runtime_apis! {
fn eth_transact(tx: pallet_revive::evm::GenericTransaction) -> Result<pallet_revive::EthTransactInfo<Balance>, pallet_revive::EthTransactError>
{
let blockweights: BlockWeights = <Runtime as frame_system::Config>::BlockWeights::get();

let encoded_size = |pallet_call| {
let tx_fee = |pallet_call, mut dispatch_info: DispatchInfo| {
let call = RuntimeCall::Revive(pallet_call);
dispatch_info.extension_weight = EthExtraImpl::get_eth_extension(0, 0u32.into()).weight(&call);
let uxt: UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic::new_bare(call).into();
uxt.encoded_size() as u32

pallet_transaction_payment::Pallet::<Runtime>::compute_fee(
uxt.encoded_size() as u32,
&dispatch_info,
0u32.into(),
)
};

Revive::bare_eth_transact(
tx,
blockweights.max_block,
encoded_size,
)
Revive::bare_eth_transact(tx, blockweights.max_block, tx_fee)
}

fn call(
Expand Down
4 changes: 0 additions & 4 deletions substrate/frame/revive/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ default-run = "eth-rpc"
name = "eth-rpc"
path = "src/main.rs"

[[bin]]
name = "eth-indexer"
path = "src/eth-indexer.rs"

[[bin]]
name = "eth-rpc-tester"
path = "src/eth-rpc-tester.rs"
Expand Down
28 changes: 0 additions & 28 deletions substrate/frame/revive/rpc/dockerfiles/eth-indexer/Dockerfile

This file was deleted.

Loading
Loading