chore(executor): add tx hash to evm error (#1714)

This commit is contained in:
Roman Krasiuk
2023-03-12 19:38:29 +02:00
committed by GitHub
parent 12e94029ac
commit ff34c0ec2a
2 changed files with 6 additions and 5 deletions

View File

@ -376,12 +376,13 @@ where
// Fill revm structure.
fill_tx_env(&mut self.evm.env.tx, transaction, sender);
let out = if self.stack.should_inspect(&self.evm.env, transaction.hash()) {
let hash = transaction.hash();
let out = if self.stack.should_inspect(&self.evm.env, hash) {
// execution with inspector.
let output = self.evm.inspect(&mut self.stack);
tracing::trace!(
target: "evm",
hash = ?transaction.hash(), ?output, ?transaction, env = ?self.evm.env,
?hash, ?output, ?transaction, env = ?self.evm.env,
"Executed transaction"
);
output
@ -389,7 +390,7 @@ where
// main execution.
self.evm.transact()
};
out.map_err(|e| Error::EVM(format!("{e:?}")))
out.map_err(|e| Error::EVM { hash, message: format!("{e:?}") })
}
/// Runs the provided transactions and commits their state. Will proceed

View File

@ -5,8 +5,8 @@ use thiserror::Error;
#[allow(missing_docs)]
#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum Error {
#[error("EVM reported invalid transaction:{0}")]
EVM(String),
#[error("EVM reported invalid transaction ({hash:?}): {message}")]
EVM { hash: H256, message: String },
#[error("Example of error.")]
VerificationFailed,
#[error("Fatal internal error")]