Skip to content

Commit

Permalink
Print ledger changes while replaying slots
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-François <[email protected]>
  • Loading branch information
bilboquet committed May 27, 2024
1 parent 945a774 commit 39b22d0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions massa-execution-exports/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ massa_pos_exports = {workspace = true}
massa_module_cache = {workspace = true}
massa_versioning = {workspace = true}
massa-sc-runtime = {workspace = true}
serde = {workspace = true, "features" = ["derive"]}

[dev-dependencies]
mockall = {workspace = true}
3 changes: 2 additions & 1 deletion massa-execution-exports/src/event_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
use massa_models::execution::EventFilter;
use massa_models::output_event::SCOutputEvent;
use std::collections::VecDeque;
use serde::Serialize;

/// Store for events emitted by smart contracts
#[derive(Default, Debug, Clone)]
#[derive(Default, Debug, Clone, Serialize)]
pub struct EventStore(pub VecDeque<SCOutputEvent>);

impl EventStore {
Expand Down
5 changes: 3 additions & 2 deletions massa-execution-exports/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use massa_models::{
use massa_pos_exports::ProductionStats;
use massa_storage::Storage;
use std::collections::{BTreeMap, BTreeSet};
use serde::Serialize;

#[cfg(feature = "execution-trace")]
use crate::types_trace_info::{SlotAbiCallStack, Transfer};
Expand Down Expand Up @@ -217,7 +218,7 @@ pub enum SlotExecutionOutput {
}

/// structure storing a block id + network versions (from a block header)
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize)]
pub struct ExecutedBlockInfo {
/// Block id
pub block_id: BlockId,
Expand All @@ -228,7 +229,7 @@ pub struct ExecutedBlockInfo {
}

/// structure describing the output of a single execution
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize)]
pub struct ExecutionOutput {
/// slot
pub slot: Slot,
Expand Down
9 changes: 6 additions & 3 deletions massa-execution-exports/src/types_trace_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ pub use massa_sc_runtime::{
};

#[cfg(feature = "execution-trace")]
#[derive(Debug, Clone)]
use serde::Serialize;

#[cfg(feature = "execution-trace")]
#[derive(Debug, Clone, Serialize)]
/// Structure for all abi calls in a slot
pub struct SlotAbiCallStack {
/// Slot
Expand All @@ -25,7 +28,7 @@ pub struct SlotAbiCallStack {
}

#[cfg(feature = "execution-trace")]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize)]
/// structure describing a transfer
pub struct Transfer {
/// From
Expand All @@ -46,7 +49,7 @@ pub struct Transfer {

#[cfg(feature = "execution-trace")]
/// A trace of an abi call + its parameters + the result
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize)]
pub struct AbiTrace {
/// Abi name
pub name: String,
Expand Down
6 changes: 6 additions & 0 deletions massa-execution-worker/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ impl ExecutionState {
self.update_versioning_stats(&exec_out.block_info, &exec_out.slot);

let exec_out_2 = exec_out.clone();
#[cfg(feature = "slot-replayer")]
{
println!(">>> Execution changes");
println!("{:#?}", serde_json::to_string_pretty(&exec_out));
println!("<<<");
}
// apply state changes to the final ledger
self.final_state
.write()
Expand Down
6 changes: 3 additions & 3 deletions massa-final-state/src/final_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ impl FinalState {
{
warn!("Wrong key/value for EXECUTED_DENUNCIATIONS PREFIX serialized_key: {:?}, serialized_value: {:?}", serialized_key, serialized_value);
return Err(anyhow!(
"Wrong key/value for EXECUTED_DENUNCIATIONS PREFIX serialized_key: {:?}, serialized_value: {:?}",
"Wrong key/value for EXECUTED_DENUNCIATIONS PREFIX serialized_key: {:?}, serialized_value: {:?}",
serialized_key, serialized_value
));
}
Expand All @@ -630,7 +630,7 @@ impl FinalState {
{
warn!("Wrong key/value for LEDGER PREFIX serialized_key: {:?}, serialized_value: {:?}", serialized_key, serialized_value);
return Err(anyhow!(
"Wrong key/value for LEDGER PREFIX serialized_key: {:?}, serialized_value: {:?}",
"Wrong key/value for LEDGER PREFIX serialized_key: {:?}, serialized_value: {:?}",
serialized_key, serialized_value
));
}
Expand All @@ -641,7 +641,7 @@ impl FinalState {
{
warn!("Wrong key/value for MIP Store");
return Err(anyhow!(
"Wrong key/value for MIP Store serialized_key: {:?}, serialized_value: {:?}",
"Wrong key/value for MIP Store serialized_key: {:?}, serialized_value: {:?}",
serialized_key, serialized_value
));
}
Expand Down

0 comments on commit 39b22d0

Please sign in to comment.