diff --git a/src/evm/input.rs b/src/evm/input.rs index d3a7f6d1b..c717946f9 100644 --- a/src/evm/input.rs +++ b/src/evm/input.rs @@ -185,6 +185,55 @@ pub struct ConciseEVMInput { pub return_data: Option>, } +/// EVM Input Minimum for Deserializing with human readable ABI +#[derive(Serialize, Deserialize, Clone, Debug, Default)] +pub struct ConciseEVMInputReadable { + /// Input type + pub input_type: EVMInputTy, + + /// Caller address + pub caller: EVMAddress, + + /// Contract address + pub contract: EVMAddress, + + /// Input data in ABI format + #[cfg(not(feature = "debug"))] + pub data: Option, + #[cfg(not(feature = "debug"))] + pub data_readable: Option, + + #[cfg(feature = "debug")] + pub direct_data: String, + + /// Transaction value in wei + pub txn_value: Option, + + /// Whether to resume execution from the last control leak + pub step: bool, + + /// Environment (block, timestamp, etc.) + pub env: Env, + + /// Percentage of the token amount in all callers' account to liquidate + pub liquidation_percent: u8, + + /// Additional random bytes for mutator + pub randomness: Vec, + + /// Execute the transaction multiple times + pub repeat: usize, + + /// How many post execution steps to take + pub layer: usize, + + /// When to control leak, after `call_leak` number of calls + pub call_leak: u32, + + /// return data + pub return_data: Option>, +} + impl ConciseEVMInput { pub fn from_input( input: &I, @@ -280,6 +329,29 @@ impl ConciseEVMInput { ) } + pub fn to_readable(&self) -> ConciseEVMInputReadable { + ConciseEVMInputReadable { + input_type: self.input_type.clone(), + caller: self.caller, + contract: self.contract, + #[cfg(not(feature = "debug"))] + data: self.data.clone(), + #[cfg(not(feature = "debug"))] + data_readable: self.data.clone().map(|d| format!("{}", d)), + #[cfg(feature = "debug")] + direct_data: self.direct_data.clone(), + txn_value: self.txn_value, + step: self.step, + env: self.env.clone(), + liquidation_percent: self.liquidation_percent, + randomness: self.randomness.clone(), + repeat: self.repeat, + layer: self.layer, + call_leak: self.call_leak, + return_data: self.return_data.clone(), + } + } + // Variable `liq` is used when `debug` feature is disabled #[allow(unused_variables)] fn pretty_txn(&self) -> Option { @@ -770,7 +842,7 @@ impl EVMInput { impl ConciseSerde for ConciseEVMInput { fn serialize_concise(&self) -> Vec { - serde_json::to_vec(self).expect("Failed to deserialize concise input") + serde_json::to_vec(&self.to_readable()).expect("Failed to deserialize concise input") } fn deserialize_concise(data: &[u8]) -> Self {