Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cleanup #422

Merged
merged 4 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arbiter-core/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub struct Environment {

/// The [`EVM`] that is used as an execution environment and database for
/// calls and transactions.
pub(crate) evm: EVM<CacheDB<EmptyDB>>,
evm: EVM<CacheDB<EmptyDB>>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remind me why we are doing this again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we don't actually reference the evm field of Environment anywhere else in the crate, so we are safe to keep its visibility to private. I feel it's usually good to minimize visibility to the lowest point.


/// This gives a means of letting the "outside world" connect to the
/// [`Environment`] so that users (or agents) may send and receive data from
Expand Down
50 changes: 28 additions & 22 deletions arbiter-core/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,23 @@ pub enum RevmMiddlewareError {

/// The execution of a transaction was reverted, indicating that the
/// transaction was not successful.
#[error("execution failed to succeed due to revert! output is: {cause}")]
#[error("execution failed to succeed due to revert!\n gas used is: {gas_used}\n output is {output:?}")]
ExecutionRevert {
/// Provides the amount of gas used by the transaction.
gas_used: u64,

/// Provides the output or reason why the transaction was reverted.
cause: String,
output: revm::primitives::Bytes,
},

/// The execution of a transaction halted unexpectedly.
#[error("execution failed to succeed due to halt! output is: {cause}")]
#[error("execution failed to succeed due to halt!\n reason is: {reason:?}\n gas used is: {gas_used}")]
ExecutionHalt {
/// Provides the output or reason for the halt.
cause: String,
/// Provides the reason for the halt.
reason: revm::primitives::Halt,

/// Provides the amount of gas used by the transaction.
gas_used: u64,
},
}

Expand All @@ -167,7 +173,7 @@ impl MiddlewareError for RevmMiddlewareError {
}

fn as_inner(&self) -> Option<&Self::Inner> {
Some(self)
None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this to me? The middleware onion has been a little black boxed for to only handle it on one layer at a time.

}
}

Expand Down Expand Up @@ -280,7 +286,6 @@ impl Middleware for RevmMiddleware {
nonce: None,
access_list: Vec::new(),
};
println!("gotten past creating txenv");
self.provider()
.as_ref()
.tx_sender
Expand All @@ -292,7 +297,7 @@ impl Middleware for RevmMiddleware {
.map_err(|e| RevmMiddlewareError::Send {
cause: e.to_string(),
})?;
println!("sent to provider");

let revm_result = self
.provider()
.as_ref()
Expand All @@ -308,7 +313,13 @@ impl Middleware for RevmMiddleware {
_gas_refunded: _,
logs,
output,
} = unpack_execution_result(revm_result.result)?;
} = match unpack_execution_result(revm_result.result) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice i was wondering about this when i was debugging my issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shit. I don't actually want to do it this way. Doing it with ? is better.

Ok(success) => success,
Err(e) => {
return Err(e);
}
};

match output {
Output::Create(_, address) => {
let address = address.ok_or(RevmMiddlewareError::MissingData {
Expand Down Expand Up @@ -389,6 +400,7 @@ impl Middleware for RevmMiddleware {
.map_err(|e| RevmMiddlewareError::Receive {
cause: e.to_string(),
})?;

let output = unpack_execution_result(revm_result.result)?.output;
match output {
Output::Create(bytes, ..) => {
Expand Down Expand Up @@ -417,7 +429,6 @@ impl Middleware for RevmMiddleware {
}
FilterKind::Logs(filter) => ("eth_newFilter", filter),
};
println!("args: {:?}", args);
let filter = args.clone();
let mut hasher = Sha256::new();
hasher.update(
Expand Down Expand Up @@ -574,6 +585,7 @@ pub(crate) struct FilterReceiver {
}

/// Contains the result of a successful transaction execution.
#[derive(Debug)]
struct Success {
_reason: revm::primitives::Eval,
_gas_used: u64,
Expand Down Expand Up @@ -607,18 +619,12 @@ fn unpack_execution_result(
output,
})
}
ExecutionResult::Revert { gas_used, output } => Err(RevmMiddlewareError::ExecutionRevert {
cause: format!(
"Transaction reverted and used {} gas and output {:?}",
gas_used, output
),
}),
ExecutionResult::Halt { reason, gas_used } => Err(RevmMiddlewareError::ExecutionHalt {
cause: format!(
"Transaction halted for reasond {:?} gas and output {:?}",
reason, gas_used
),
}),
ExecutionResult::Revert { gas_used, output } => {
Err(RevmMiddlewareError::ExecutionRevert { gas_used, output })
}
ExecutionResult::Halt { reason, gas_used } => {
Err(RevmMiddlewareError::ExecutionHalt { reason, gas_used })
}
}
}

Expand Down
12 changes: 0 additions & 12 deletions arbiter-core/src/tests/bindings.rs

This file was deleted.

Loading
Loading