Skip to content

Commit

Permalink
nit(runtime): drop serde Serialize and Deserialize for VMOutcome (#5108)
Browse files Browse the repository at this point in the history
VMOutcome is not serialized in rpc, only used in standalone as print result, which can be replaced by pretty print. Therefore, drop serialize/deserialize for VMOutcome

Test Plan
------------
CI
  • Loading branch information
ailisp authored Nov 3, 2021
1 parent 4fedb98 commit e050532
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 1 addition & 4 deletions runtime/near-vm-logic/src/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use near_primitives_core::types::{
};
use near_vm_errors::InconsistentStateError;
use near_vm_errors::{HostError, VMLogicError};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::mem::size_of;

Expand Down Expand Up @@ -2517,16 +2516,14 @@ impl<'a> VMLogic<'a> {
}
}

#[derive(Serialize, Deserialize, Clone)]
#[derive(Clone)]
pub struct VMOutcome {
#[serde(with = "crate::serde_with::u128_dec_format")]
pub balance: Balance,
pub storage_usage: StorageUsage,
pub return_data: ReturnData,
pub burnt_gas: Gas,
pub used_gas: Gas,
pub logs: Vec<String>,
#[serde(skip)]
/// Data collected from making a contract call
pub profile: ProfileData,
}
Expand Down
9 changes: 4 additions & 5 deletions runtime/near-vm-runner-standalone/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct CliArgs {
protocol_version: Option<ProtocolVersion>,
}

#[derive(Debug, Clone, Serialize)]
#[derive(Debug, Clone)]
struct StandaloneOutput {
pub outcome: Option<VMOutcome>,
pub err: Option<String>,
Expand Down Expand Up @@ -166,14 +166,13 @@ fn main() {
let (outcome, err) = results.outcomes.pop().unwrap();

println!(
"{}",
serde_json::to_string(&StandaloneOutput {
"{:#?}",
StandaloneOutput {
outcome: outcome.clone(),
err: err.map(|it| it.to_string()),
receipts: results.state.get_receipt_create_calls().clone(),
state: State(results.state.fake_trie),
})
.unwrap()
}
);

match &outcome {
Expand Down

0 comments on commit e050532

Please sign in to comment.