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

Use previous block hash to compute tx effectiveGasPrice #1280

Merged
Merged
Changes from 1 commit
Commits
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
30 changes: 21 additions & 9 deletions client/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ where
block,
receipts,
statuses,
substrate_hash,
..
} = block_info.clone();
match (block, statuses, receipts) {
Expand Down Expand Up @@ -287,14 +286,27 @@ 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If parent_hash is 0x0 then it indicates genesis block, and then we should short-circuit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified to use same block hash for the genesis block

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
Loading