Skip to content

Commit

Permalink
fix error count of sload opcode (bluealloy#7)
Browse files Browse the repository at this point in the history
* fix error count of sload opcode

* format code

---------

Co-authored-by: anonymousGiga <cryptonymGong@gmail.com>
  • Loading branch information
xudaquan2003 and anonymousGiga authored Nov 1, 2023
1 parent 3f78d41 commit 47e867e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/utils/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ use serde::{Deserialize, Serialize};

pub type RevmMetricRecord = OpcodeRecord;

const STEP_LEN: usize = 4;
const SLOAD_OPCODE_TIME_STEP: [u128; STEP_LEN] = [1, 10, 100, u128::MAX];
pub const STEP_LEN: usize = 4;
pub const SLOAD_OPCODE_TIME_STEP: [u128; STEP_LEN] = [1, 10, 100, u128::MAX];

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct OpcodeRecord {
/// The abscissa is opcode type, tuple means: (opcode counter, time, gas).
#[serde(with = "serde_arrays")]
pub opcode_record: [(u64, Duration, i128); 256],
/// tuple means:(the ladder of sload opcode excution time, sload counter).
#[serde(with = "serde_arrays")]
pub sload_opcode_record: [(u128, u128); STEP_LEN],
/// The total time of all opcode.
Expand Down Expand Up @@ -39,6 +40,8 @@ impl OpcodeRecord {

if !self.is_updated {
self.opcode_record = std::mem::replace(&mut other.opcode_record, self.opcode_record);
self.sload_opcode_record =
std::mem::replace(&mut other.sload_opcode_record, self.sload_opcode_record);
self.is_updated = true;
return;
}
Expand Down

0 comments on commit 47e867e

Please sign in to comment.