added effectiveGasPrice to eth_getTransactionReceipt return structure (#450)
This commit is contained in:
parent
e6f3794dd4
commit
e5ae846de4
@ -2392,6 +2392,7 @@ impl BlockChainClient for Client {
|
|||||||
let chain = self.chain.read();
|
let chain = self.chain.read();
|
||||||
let number = chain.block_number(&hash)?;
|
let number = chain.block_number(&hash)?;
|
||||||
let body = chain.block_body(&hash)?;
|
let body = chain.block_body(&hash)?;
|
||||||
|
let header = chain.block_header_data(&hash)?;
|
||||||
let mut receipts = chain.block_receipts(&hash)?.receipts;
|
let mut receipts = chain.block_receipts(&hash)?.receipts;
|
||||||
receipts.truncate(address.index + 1);
|
receipts.truncate(address.index + 1);
|
||||||
|
|
||||||
@ -2404,6 +2405,11 @@ impl BlockChainClient for Client {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|receipt| receipt.logs.len())
|
.map(|receipt| receipt.logs.len())
|
||||||
.sum::<usize>();
|
.sum::<usize>();
|
||||||
|
let base_fee = if number >= self.engine().params().eip1559_transition {
|
||||||
|
Some(header.base_fee())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let receipt = transaction_receipt(
|
let receipt = transaction_receipt(
|
||||||
self.engine().machine(),
|
self.engine().machine(),
|
||||||
@ -2411,6 +2417,7 @@ impl BlockChainClient for Client {
|
|||||||
receipt,
|
receipt,
|
||||||
gas_used,
|
gas_used,
|
||||||
no_of_logs,
|
no_of_logs,
|
||||||
|
base_fee,
|
||||||
);
|
);
|
||||||
Some(receipt)
|
Some(receipt)
|
||||||
}
|
}
|
||||||
@ -2422,7 +2429,13 @@ impl BlockChainClient for Client {
|
|||||||
let receipts = chain.block_receipts(&hash)?;
|
let receipts = chain.block_receipts(&hash)?;
|
||||||
let number = chain.block_number(&hash)?;
|
let number = chain.block_number(&hash)?;
|
||||||
let body = chain.block_body(&hash)?;
|
let body = chain.block_body(&hash)?;
|
||||||
|
let header = chain.block_header_data(&hash)?;
|
||||||
let engine = self.engine.clone();
|
let engine = self.engine.clone();
|
||||||
|
let base_fee = if number >= engine.params().eip1559_transition {
|
||||||
|
Some(header.base_fee())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let mut gas_used = 0.into();
|
let mut gas_used = 0.into();
|
||||||
let mut no_of_logs = 0;
|
let mut no_of_logs = 0;
|
||||||
@ -2439,6 +2452,7 @@ impl BlockChainClient for Client {
|
|||||||
receipt,
|
receipt,
|
||||||
gas_used,
|
gas_used,
|
||||||
no_of_logs,
|
no_of_logs,
|
||||||
|
base_fee,
|
||||||
);
|
);
|
||||||
gas_used = result.cumulative_gas_used;
|
gas_used = result.cumulative_gas_used;
|
||||||
no_of_logs += result.logs.len();
|
no_of_logs += result.logs.len();
|
||||||
@ -3264,6 +3278,7 @@ fn transaction_receipt(
|
|||||||
receipt: TypedReceipt,
|
receipt: TypedReceipt,
|
||||||
prior_gas_used: U256,
|
prior_gas_used: U256,
|
||||||
prior_no_of_logs: usize,
|
prior_no_of_logs: usize,
|
||||||
|
base_fee: Option<U256>,
|
||||||
) -> LocalizedReceipt {
|
) -> LocalizedReceipt {
|
||||||
let sender = tx.sender();
|
let sender = tx.sender();
|
||||||
let transaction_hash = tx.hash();
|
let transaction_hash = tx.hash();
|
||||||
@ -3315,6 +3330,10 @@ fn transaction_receipt(
|
|||||||
.collect(),
|
.collect(),
|
||||||
log_bloom: receipt.log_bloom,
|
log_bloom: receipt.log_bloom,
|
||||||
outcome: receipt.outcome.clone(),
|
outcome: receipt.outcome.clone(),
|
||||||
|
effective_gas_price: match base_fee {
|
||||||
|
Some(_) => Some(tx.effective_gas_price(base_fee)),
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3643,7 +3662,7 @@ mod tests {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
let receipt = transaction_receipt(&machine, transaction, receipt, 5.into(), 1);
|
let receipt = transaction_receipt(&machine, transaction, receipt, 5.into(), 1, None);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -3684,6 +3703,7 @@ mod tests {
|
|||||||
],
|
],
|
||||||
log_bloom: Default::default(),
|
log_bloom: Default::default(),
|
||||||
outcome: TransactionOutcome::StateRoot(state_root),
|
outcome: TransactionOutcome::StateRoot(state_root),
|
||||||
|
effective_gas_price: None,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1295,6 +1295,13 @@ impl miner::MinerService for Miner {
|
|||||||
logs: receipt.logs.clone(),
|
logs: receipt.logs.clone(),
|
||||||
log_bloom: receipt.log_bloom,
|
log_bloom: receipt.log_bloom,
|
||||||
outcome: receipt.outcome.clone(),
|
outcome: receipt.outcome.clone(),
|
||||||
|
effective_gas_price: if pending.header.number()
|
||||||
|
>= self.engine.params().eip1559_transition
|
||||||
|
{
|
||||||
|
Some(tx.effective_gas_price(pending.header.base_fee()))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
|
@ -279,6 +279,8 @@ pub struct RichReceipt {
|
|||||||
pub to: Option<H160>,
|
pub to: Option<H160>,
|
||||||
/// Sender
|
/// Sender
|
||||||
pub from: H160,
|
pub from: H160,
|
||||||
|
/// Effective gas price
|
||||||
|
pub effective_gas_price: Option<U256>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receipt with additional info.
|
/// Receipt with additional info.
|
||||||
@ -312,6 +314,8 @@ pub struct LocalizedReceipt {
|
|||||||
pub to: Option<H160>,
|
pub to: Option<H160>,
|
||||||
/// Sender
|
/// Sender
|
||||||
pub from: H160,
|
pub from: H160,
|
||||||
|
/// Effective gas price
|
||||||
|
pub effective_gas_price: Option<U256>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1184,6 +1184,7 @@ fn rpc_eth_transaction_receipt() {
|
|||||||
}],
|
}],
|
||||||
log_bloom: Bloom::zero(),
|
log_bloom: Bloom::zero(),
|
||||||
outcome: TransactionOutcome::StateRoot(H256::zero()),
|
outcome: TransactionOutcome::StateRoot(H256::zero()),
|
||||||
|
effective_gas_price: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let hash =
|
let hash =
|
||||||
@ -1242,6 +1243,7 @@ fn rpc_eth_pending_receipt() {
|
|||||||
logs: Vec::new(),
|
logs: Vec::new(),
|
||||||
log_bloom: Bloom::zero(),
|
log_bloom: Bloom::zero(),
|
||||||
outcome: TransactionOutcome::Unknown,
|
outcome: TransactionOutcome::Unknown,
|
||||||
|
effective_gas_price: None,
|
||||||
};
|
};
|
||||||
let tester = EthTester::default();
|
let tester = EthTester::default();
|
||||||
|
|
||||||
|
@ -561,6 +561,7 @@ fn rpc_parity_block_receipts() {
|
|||||||
outcome: TransactionOutcome::Unknown,
|
outcome: TransactionOutcome::Unknown,
|
||||||
to: None,
|
to: None,
|
||||||
from: Address::from_low_u64_be(9),
|
from: Address::from_low_u64_be(9),
|
||||||
|
effective_gas_price: None,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let io = deps.default_client();
|
let io = deps.default_client();
|
||||||
|
@ -55,6 +55,9 @@ pub struct Receipt {
|
|||||||
// NOTE(niklasad1): Unknown after EIP98 rules, if it's missing then skip serializing it
|
// NOTE(niklasad1): Unknown after EIP98 rules, if it's missing then skip serializing it
|
||||||
#[serde(skip_serializing_if = "Option::is_none", rename = "status")]
|
#[serde(skip_serializing_if = "Option::is_none", rename = "status")]
|
||||||
pub status_code: Option<U64>,
|
pub status_code: Option<U64>,
|
||||||
|
/// Effective gas price
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub effective_gas_price: Option<U256>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Receipt {
|
impl Receipt {
|
||||||
@ -90,6 +93,7 @@ impl From<LocalizedReceipt> for Receipt {
|
|||||||
status_code: Self::outcome_to_status_code(&r.outcome),
|
status_code: Self::outcome_to_status_code(&r.outcome),
|
||||||
state_root: Self::outcome_to_state_root(r.outcome),
|
state_root: Self::outcome_to_state_root(r.outcome),
|
||||||
logs_bloom: r.log_bloom,
|
logs_bloom: r.log_bloom,
|
||||||
|
effective_gas_price: r.effective_gas_price,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,6 +115,7 @@ impl From<RichReceipt> for Receipt {
|
|||||||
status_code: Self::outcome_to_status_code(&r.outcome),
|
status_code: Self::outcome_to_status_code(&r.outcome),
|
||||||
state_root: Self::outcome_to_state_root(r.outcome),
|
state_root: Self::outcome_to_state_root(r.outcome),
|
||||||
logs_bloom: r.log_bloom,
|
logs_bloom: r.log_bloom,
|
||||||
|
effective_gas_price: r.effective_gas_price,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,6 +139,7 @@ impl From<TypedReceipt> for Receipt {
|
|||||||
status_code: Self::outcome_to_status_code(&legacy_receipt.outcome),
|
status_code: Self::outcome_to_status_code(&legacy_receipt.outcome),
|
||||||
state_root: Self::outcome_to_state_root(legacy_receipt.outcome),
|
state_root: Self::outcome_to_state_root(legacy_receipt.outcome),
|
||||||
logs_bloom: legacy_receipt.log_bloom,
|
logs_bloom: legacy_receipt.log_bloom,
|
||||||
|
effective_gas_price: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,6 +197,7 @@ mod tests {
|
|||||||
logs_bloom: Bloom::from_low_u64_be(15),
|
logs_bloom: Bloom::from_low_u64_be(15),
|
||||||
state_root: Some(H256::from_low_u64_be(10)),
|
state_root: Some(H256::from_low_u64_be(10)),
|
||||||
status_code: Some(1u64.into()),
|
status_code: Some(1u64.into()),
|
||||||
|
effective_gas_price: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let serialized = serde_json::to_string(&receipt).unwrap();
|
let serialized = serde_json::to_string(&receipt).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user