Skip to content

Commit

Permalink
fix: lint + doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Autoparallel committed Jan 30, 2024
1 parent f5c283f commit 11a3e74
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arbiter-core/src/console/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! This module contains the backend for the `console2.log` Solidity function so
//! that these logs can be read in Arbiter.
use std::ops::Range;

use revm::{
Expand Down
4 changes: 4 additions & 0 deletions arbiter-core/src/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,15 @@ impl EnvironmentBuilder {
self
}

/// Enables inner contract logs to be printed to the console as `trace`
/// level logs prepended with "Console logs: ".
pub fn with_console_logs(mut self) -> Self {
self.parameters.console_logs = true;
self
}

/// Turns on gas payments for transactions so that the [`EVM`] will
/// automatically pay for gas and revert if balance is not met by sender.
pub fn with_pay_gas(mut self) -> Self {
self.parameters.pay_gas = true;
self
Expand Down
14 changes: 14 additions & 0 deletions arbiter-core/src/inspector.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! This module contains an extensible [`revm::Inspector`] called
//! [`ArbiterInspector`]. It is currently configurable in order to allow
//! for users to set configuration to see logs generated in Solidity contracts
//! and or enforce gas payment.
use std::ops::Range;

use revm::{
Expand All @@ -9,13 +14,22 @@ use revm_primitives::Address;

use crate::console::ConsoleLogs;

/// An configurable [`revm::Inspector`] that collects information about the
/// execution of the [`Interpreter`]. Depending on whether which or both
/// features are enabled, it collects information about the gas used by each
/// opcode and the `console2.log`s emitted during execution. It ensures gas
/// payments are made when `gas` is enabled.
#[derive(Debug, Clone)]

Check warning on line 22 in arbiter-core/src/inspector.rs

View check run for this annotation

Codecov / codecov/patch

arbiter-core/src/inspector.rs#L22

Added line #L22 was not covered by tests
pub struct ArbiterInspector {
/// Whether to collect `console2.log`s.
pub console_log: Option<ConsoleLogs>,

/// Whether to collect gas usage information.
pub gas: Option<GasInspector>,
}

impl ArbiterInspector {
/// Create a new [`ArbiterInspector`] with the given configuration.
pub fn new(console_log: bool, gas: bool) -> Self {
let console_log = if console_log {
Some(ConsoleLogs::default())
Expand Down

0 comments on commit 11a3e74

Please sign in to comment.