From 009b9f931c209ea9ab347720547e06ce552bed9a Mon Sep 17 00:00:00 2001 From: elfedy Date: Mon, 8 Jan 2024 18:10:49 -0300 Subject: [PATCH 1/5] Use previous block hash to compute tx effectiveGasPrice --- client/rpc/src/eth/transaction.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/client/rpc/src/eth/transaction.rs b/client/rpc/src/eth/transaction.rs index 3eb5066cc2..04e6c0d7bd 100644 --- a/client/rpc/src/eth/transaction.rs +++ b/client/rpc/src/eth/transaction.rs @@ -214,7 +214,6 @@ where block, receipts, statuses, - substrate_hash, .. } = block_info.clone(); match (block, statuses, receipts) { @@ -285,17 +284,25 @@ where let mut cumulative_receipts = receipts; cumulative_receipts.truncate((status.transaction_index + 1) as usize); let transaction = block.transactions[index].clone(); + 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 = self + .block_info_by_eth_block_hash(parent_eth_hash) + .await? + .substrate_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 { From 25be8e7d8508e4a2d3724d3d3149a0767c7618d8 Mon Sep 17 00:00:00 2001 From: elfedy Date: Mon, 8 Jan 2024 18:14:43 -0300 Subject: [PATCH 2/5] Respect previous spacing --- client/rpc/src/eth/transaction.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/client/rpc/src/eth/transaction.rs b/client/rpc/src/eth/transaction.rs index 04e6c0d7bd..e7d50c41fd 100644 --- a/client/rpc/src/eth/transaction.rs +++ b/client/rpc/src/eth/transaction.rs @@ -284,7 +284,6 @@ where let mut cumulative_receipts = receipts; cumulative_receipts.truncate((status.transaction_index + 1) as usize); let transaction = block.transactions[index].clone(); - let effective_gas_price = match transaction { EthereumTransaction::Legacy(t) => t.gas_price, EthereumTransaction::EIP2930(t) => t.gas_price, From 1b510e4e443b052767ac9afb52ff32769a78edf2 Mon Sep 17 00:00:00 2001 From: elfedy Date: Tue, 9 Jan 2024 09:51:24 -0300 Subject: [PATCH 3/5] Get substrate hash vs the whole BlockInfo --- client/rpc/src/eth/transaction.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/rpc/src/eth/transaction.rs b/client/rpc/src/eth/transaction.rs index e7d50c41fd..2ac8e036b2 100644 --- a/client/rpc/src/eth/transaction.rs +++ b/client/rpc/src/eth/transaction.rs @@ -289,10 +289,15 @@ where EthereumTransaction::EIP2930(t) => t.gas_price, EthereumTransaction::EIP1559(t) => { let parent_eth_hash = block.header.parent_hash; - let parent_substrate_hash = self - .block_info_by_eth_block_hash(parent_eth_hash) - .await? - .substrate_hash; + let parent_substrate_hash = frontier_backend_client::load_hash::( + 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 block hash")) + .map_err(|err| internal_err(format!("{:?}", err)))?; self.client .runtime_api() From 09bfffdfccf58aca4f4e78d8b40defbb99b04a3a Mon Sep 17 00:00:00 2001 From: elfedy Date: Tue, 9 Jan 2024 14:09:38 -0300 Subject: [PATCH 4/5] Remove unnecessary map_err --- client/rpc/src/eth/transaction.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/rpc/src/eth/transaction.rs b/client/rpc/src/eth/transaction.rs index 2ac8e036b2..c950fbfb84 100644 --- a/client/rpc/src/eth/transaction.rs +++ b/client/rpc/src/eth/transaction.rs @@ -296,8 +296,7 @@ where ) .await .map_err(|err| internal_err(format!("{:?}", err)))? - .ok_or(internal_err("Failed to retrieve substrate block hash")) - .map_err(|err| internal_err(format!("{:?}", err)))?; + .ok_or(internal_err("Failed to retrieve substrate block hash"))?; self.client .runtime_api() From 56d5a44dddaed7c8e3fa798d18313e05d92e162e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Rodr=C3=ADguez?= Date: Fri, 12 Jan 2024 10:02:56 -0300 Subject: [PATCH 5/5] Update client/rpc/src/eth/transaction.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éloïs --- client/rpc/src/eth/transaction.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rpc/src/eth/transaction.rs b/client/rpc/src/eth/transaction.rs index c950fbfb84..dd43c964a2 100644 --- a/client/rpc/src/eth/transaction.rs +++ b/client/rpc/src/eth/transaction.rs @@ -296,7 +296,7 @@ where ) .await .map_err(|err| internal_err(format!("{:?}", err)))? - .ok_or(internal_err("Failed to retrieve substrate block hash"))?; + .ok_or(internal_err("Failed to retrieve substrate parent block hash"))?; self.client .runtime_api()