Skip to content
Merged
12 changes: 12 additions & 0 deletions prdoc/pr_9177.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
title: align eth-rpc response with geth
doc:
- audience: Runtime Dev
description: |-
- Update serde encoding for eth-rpc to match serialization behavior of Geth
- Update GAS_PRICE to 1_000_000 to make the gas fit on u64 on Kitchensink
- Update gas_price reported by block transaction for eip1559 to be the effective_gas_price (min(max_gas_per_fee, base_fee_per_gas + priority_gas_per_fee)
crates:
- name: pallet-revive
bump: patch
- name: pallet-revive-eth-rpc
bump: patch
3 changes: 1 addition & 2 deletions substrate/frame/revive/rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,7 @@ impl Client {
transactions_root: extrinsics_root,
number: header.number.into(),
timestamp: timestamp.into(),
difficulty: Some(0u32.into()),
base_fee_per_gas: runtime_api.gas_price().await.ok(),
base_fee_per_gas: runtime_api.gas_price().await.ok().unwrap_or_default(),
gas_limit,
gas_used,
receipts_root: extrinsics_root,
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/revive/rpc/src/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<Client: EthRpcClient + Sync + Send> SubmittedTransaction<Client> {
);
return Ok(receipt)
} else {
anyhow::bail!("Transaction failed")
anyhow::bail!("Transaction failed receipt: {receipt:?}")
}
}
}
Expand Down Expand Up @@ -180,7 +180,7 @@ impl<Client: EthRpcClient + Send + Sync> TransactionBuilder<Client> {
let hash = client
.send_raw_transaction(bytes.into())
.await
.with_context(|| "transaction failed")?;
.with_context(|| "send_raw_transaction failed")?;

Ok(SubmittedTransaction {
tx: GenericTransaction::from_signed(signed_tx, gas_price, Some(from)),
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/revive/rpc/src/fee_history_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl FeeHistoryProvider {
let block_number: SubstrateBlockNumber =
block.number.try_into().expect("Block number is always valid");

let base_fee = block.base_fee_per_gas.unwrap_or_default().as_u128();
let base_fee = block.base_fee_per_gas.as_u128();
let gas_used = block.gas_used.as_u128();
let gas_used_ratio = (gas_used as f64) / (block.gas_limit.as_u128() as f64);
let mut result = FeeHistoryCacheItem { base_fee, gas_used_ratio, rewards: vec![] };
Expand Down Expand Up @@ -160,7 +160,7 @@ impl FeeHistoryProvider {
async fn test_update_fee_history() {
let block = Block {
number: U256::from(200u64),
base_fee_per_gas: Some(U256::from(1000u64)),
base_fee_per_gas: U256::from(1000u64),
gas_used: U256::from(600u64),
gas_limit: U256::from(1200u64),
..Default::default()
Expand Down
4 changes: 3 additions & 1 deletion substrate/frame/revive/rpc/src/receipt_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl ReceiptExtractor {
)?;
let transaction_hash = H256(keccak_256(&call.payload));

let signed_tx =
let mut signed_tx =
TransactionSigned::decode(&call.payload).map_err(|_| ClientError::TxDecodingFailed)?;
let from = signed_tx.recover_eth_address().map_err(|_| {
log::error!(target: LOG_TARGET, "Failed to recover eth address from signed tx");
Expand All @@ -125,6 +125,8 @@ impl ReceiptExtractor {
let tx_info =
GenericTransaction::from_signed(signed_tx.clone(), base_gas_price, Some(from));
let gas_price = tx_info.gas_price.unwrap_or_default();
signed_tx.set_effective_gas_price(gas_price);

let gas_used = U256::from(tx_fees.tip.saturating_add(tx_fees.actual_fee))
.saturating_mul(self.native_to_eth_ratio.into())
.checked_div(gas_price)
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/rpc/src/receipt_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl<B: BlockInfoProvider> ReceiptProvider<B> {
topics,
transaction_hash: H256::from_slice(&transaction_hash),
transaction_index: U256::from(transaction_index as u64),
removed: None,
removed: false,
})
})
.fetch_all(&self.pool)
Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/revive/src/evm/api/debug_rpc_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ where
#[derive(
TypeInfo, Default, Encode, Decode, Serialize, Deserialize, Clone, Debug, Eq, PartialEq,
)]
#[serde(rename_all = "camelCase")]
pub struct CallTrace<Gas = U256> {
/// Address of the sender.
pub from: H160,
/// Amount of gas provided for the call.
pub gas: Gas,
/// Amount of gas used.
#[serde(rename = "gasUsed")]
pub gas_used: Gas,
/// Address of the receiver.
pub to: H160,
Expand All @@ -277,7 +277,7 @@ pub struct CallTrace<Gas = U256> {
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
/// The revert reason, if the call reverted.
#[serde(rename = "revertReason", skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revert_reason: Option<String>,
/// List of sub-calls.
#[serde(skip_serializing_if = "Vec::is_empty")]
Expand Down Expand Up @@ -313,9 +313,9 @@ pub struct CallLog {

/// A transaction trace
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct TransactionTrace {
/// The transaction hash.
#[serde(rename = "txHash")]
pub tx_hash: H256,
/// The trace of the transaction.
#[serde(rename = "result")]
Expand Down
Loading
Loading