Fix gas_used fields in receipts (#261)

* gas_used should be cumulative_gas_used!!!

* more runtime traces

* improve logs
This commit is contained in:
Svyatoslav Nikolsky
2020-07-31 16:32:22 +03:00
committed by Bastian Köcher
parent e665f93608
commit 80cc9e793e
9 changed files with 107 additions and 36 deletions
@@ -169,12 +169,7 @@ impl EthereumRpc for EthereumRpcClient {
}
async fn transaction_receipt(&self, transaction_hash: H256) -> Result<Receipt> {
let receipt = Ethereum::get_transaction_receipt(&self.client, transaction_hash).await?;
match receipt.gas_used {
Some(_) => Ok(receipt),
None => Err(RpcError::Ethereum(EthereumNodeError::IncompleteReceipt)),
}
Ok(Ethereum::get_transaction_receipt(&self.client, transaction_hash).await?)
}
async fn account_nonce(&self, address: Address) -> Result<U256> {
@@ -24,10 +24,6 @@ pub use web3::types::{Address, Bytes, CallRequest, H256, U128, U256, U64};
/// both number and hash fields filled.
pub const HEADER_ID_PROOF: &str = "checked on retrieval; qed";
/// When receipt is just received from the Ethereum node, we check that it has
/// gas_used field filled.
pub const RECEIPT_GAS_USED_PROOF: &str = "checked on retrieval; qed";
/// Ethereum transaction hash type.
pub type TransactionHash = H256;
@@ -95,8 +95,6 @@ pub enum EthereumNodeError {
ResponseParseFailed(String),
/// We have received a header with missing fields.
IncompleteHeader,
/// We have received a receipt missing a `gas_used` field.
IncompleteReceipt,
/// We have received a transaction missing a `raw` field.
IncompleteTransaction,
/// An invalid Substrate block number was received from
@@ -112,9 +110,6 @@ impl ToString for EthereumNodeError {
"Incomplete Ethereum Header Received (missing some of required fields - hash, number, logs_bloom)"
.to_string()
}
Self::IncompleteReceipt => {
"Incomplete Ethereum Receipt Recieved (missing required field - gas_used)".to_string()
}
Self::IncompleteTransaction => "Incomplete Ethereum Transaction (missing required field - raw)".to_string(),
Self::InvalidSubstrateBlockNumber => "Received an invalid Substrate block from Ethereum Node".to_string(),
}
@@ -16,7 +16,6 @@
use crate::ethereum_types::{
Header as EthereumHeader, Receipt as EthereumReceipt, HEADER_ID_PROOF as ETHEREUM_HEADER_ID_PROOF,
RECEIPT_GAS_USED_PROOF as ETHEREUM_RECEIPT_GAS_USED_PROOF,
};
use crate::sync_types::{HeaderId, HeadersSyncPipeline, QueuedHeader, SourceHeader};
use codec::Encode;
@@ -108,7 +107,7 @@ pub fn into_substrate_ethereum_receipts(
/// Convert Ethereum transactions receipt into Ethereum transactions receipt for Substrate.
pub fn into_substrate_ethereum_receipt(receipt: &EthereumReceipt) -> SubstrateEthereumReceipt {
SubstrateEthereumReceipt {
gas_used: receipt.gas_used.expect(ETHEREUM_RECEIPT_GAS_USED_PROOF),
gas_used: receipt.cumulative_gas_used,
log_bloom: receipt.logs_bloom.data().into(),
logs: receipt
.logs