Skip to content

Commit

Permalink
fix(rpc): use u64 for gas (paradigmxyz#3004)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jun 6, 2023
1 parent 9614b46 commit 6e3b420
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions crates/revm/revm-inspectors/src/tracing/builder/geth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use crate::tracing::{
types::{CallTraceNode, CallTraceStepStackItem},
TracingInspectorConfig,
};
use reth_primitives::{Address, JsonU256, H256, U256};
use reth_primitives::{Address, H256};
use reth_rpc_types::trace::geth::*;

use std::collections::{BTreeMap, HashMap, VecDeque};

/// A type for creating geth style traces
Expand Down Expand Up @@ -85,7 +84,7 @@ impl GethTraceBuilder {
pub fn geth_traces(
&self,
// TODO(mattsse): This should be the total gas used, or gas used by last CallTrace?
receipt_gas_used: U256,
receipt_gas_used: u64,
opts: GethDefaultTracingOptions,
) -> DefaultFrame {
if self.nodes.is_empty() {
Expand All @@ -102,7 +101,7 @@ impl GethTraceBuilder {
DefaultFrame {
// If the top-level trace succeeded, then it was a success
failed: !main_trace.success,
gas: JsonU256(receipt_gas_used),
gas: receipt_gas_used,
return_value: main_trace.output.clone().into(),
struct_logs,
}
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc/rpc-types/src/eth/trace/geth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Geth tracing types
#![allow(missing_docs)]

use crate::{state::StateOverride, BlockOverrides};
/// Geth tracing types
use reth_primitives::{Bytes, JsonU256, H256, U256};
use reth_primitives::{Bytes, H256, U256};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;

Expand Down Expand Up @@ -41,7 +41,7 @@ pub struct BlockTraceResult {
#[serde(rename_all = "camelCase")]
pub struct DefaultFrame {
pub failed: bool,
pub gas: JsonU256,
pub gas: u64,
pub return_value: Bytes,
pub struct_logs: Vec<StructLog>,
}
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
};
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
use reth_primitives::{Block, BlockId, BlockNumberOrTag, Bytes, TransactionSigned, H256, U256};
use reth_primitives::{Block, BlockId, BlockNumberOrTag, Bytes, TransactionSigned, H256};
use reth_provider::{BlockProviderIdExt, HeaderProvider, ReceiptProviderIdExt, StateProviderBox};
use reth_revm::{
database::{State, SubState},
Expand Down Expand Up @@ -317,7 +317,7 @@ where
self.inner.eth_api.inspect_call_at(call, at, state_overrides, &mut inspector).await?;
let gas_used = res.result.gas_used();

let frame = inspector.into_geth_builder().geth_traces(U256::from(gas_used), config);
let frame = inspector.into_geth_builder().geth_traces(gas_used, config);

Ok(frame.into())
}
Expand Down Expand Up @@ -549,7 +549,7 @@ fn trace_transaction(
let (res, _) = inspect(db, env, &mut inspector)?;
let gas_used = res.result.gas_used();

let frame = inspector.into_geth_builder().geth_traces(U256::from(gas_used), config);
let frame = inspector.into_geth_builder().geth_traces(gas_used, config);

Ok((frame.into(), res.state))
}

0 comments on commit 6e3b420

Please sign in to comment.