Skip to content

Commit

Permalink
Merge pull request #199 from moonbeam-foundation/moonbeam-polkadot-v1…
Browse files Browse the repository at this point in the history
….3.0-elfedy-fix-tr

Use previous block hash to compute tx effectiveGasPrice
  • Loading branch information
elfedy authored Jan 12, 2024
2 parents 00bd4a6 + 56d5a44 commit 539225f
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions client/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ where
block,
receipts,
statuses,
substrate_hash,
..
} = block_info.clone();
match (block, statuses, receipts) {
Expand Down Expand Up @@ -288,14 +287,25 @@ where
let effective_gas_price = match transaction {
EthereumTransaction::Legacy(t) => t.gas_price,
EthereumTransaction::EIP2930(t) => t.gas_price,
EthereumTransaction::EIP1559(t) => self
.client
.runtime_api()
.gas_price(substrate_hash)
.unwrap_or_default()
.checked_add(t.max_priority_fee_per_gas)
.unwrap_or_else(U256::max_value)
.min(t.max_fee_per_gas),
EthereumTransaction::EIP1559(t) => {
let parent_eth_hash = block.header.parent_hash;
let parent_substrate_hash = frontier_backend_client::load_hash::<B, C>(
self.client.as_ref(),
self.backend.as_ref(),
parent_eth_hash,
)
.await
.map_err(|err| internal_err(format!("{:?}", err)))?
.ok_or(internal_err("Failed to retrieve substrate parent block hash"))?;

self.client
.runtime_api()
.gas_price(parent_substrate_hash)
.unwrap_or_default()
.checked_add(t.max_priority_fee_per_gas)
.unwrap_or_else(U256::max_value)
.min(t.max_fee_per_gas)
}
};

return Ok(Some(Receipt {
Expand Down

0 comments on commit 539225f

Please sign in to comment.