mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix: return gas per tx in error (#4858)
This commit is contained in:
@ -66,6 +66,11 @@ impl Receipts {
|
||||
Self { receipt_vec: vec }
|
||||
}
|
||||
|
||||
/// Create a new `Receipts` instance from a single block receipt.
|
||||
pub fn from_block_receipt(block_receipts: Vec<Receipt>) -> Self {
|
||||
Self { receipt_vec: vec![block_receipts.into_iter().map(Option::Some).collect()] }
|
||||
}
|
||||
|
||||
/// Returns the length of the `Receipts` vector.
|
||||
pub fn len(&self) -> usize {
|
||||
self.receipt_vec.len()
|
||||
|
||||
@ -349,10 +349,11 @@ impl<'a> EVMProcessor<'a> {
|
||||
|
||||
// Check if gas used matches the value set in header.
|
||||
if block.gas_used != cumulative_gas_used {
|
||||
let receipts = Receipts::from_block_receipt(receipts);
|
||||
return Err(BlockValidationError::BlockGasUsed {
|
||||
got: cumulative_gas_used,
|
||||
expected: block.gas_used,
|
||||
gas_spent_by_tx: self.receipts.gas_spent_by_tx()?,
|
||||
gas_spent_by_tx: receipts.gas_spent_by_tx()?,
|
||||
}
|
||||
.into())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user