Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/state_manager/message_simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use super::circulating_supply::GenesisInfo;
use super::state_computation::TipsetExecutor;
use super::utils::structured;
use super::*;
use crate::interpreter::{ExecutionContext, IMPLICIT_MESSAGE_GAS_LIMIT, VM, VMTrace};
Expand All @@ -11,6 +12,7 @@ use crate::shim::address::Protocol;
use crate::shim::crypto::{Signature, SignatureType};
use crate::shim::executor::ApplyRet;
use crate::shim::message::Message;
use anyhow::Context;
use fvm_shared4::crypto::signature::SECP_SIG_LEN;
use std::time::Duration;
use tracing::instrument;
Expand All @@ -26,7 +28,24 @@ impl StateManager {
) -> Result<ApiInvocResult, Error> {
let mut msg = msg.clone();

let state_cid = state_cid.unwrap_or(*tipset.parent_state());
let state_cid = match state_cid {
Some(cid) => cid,
None => {
let genesis_timestamp = self.chain_store().genesis_block_header().timestamp;
let exec = TipsetExecutor::new(
self.chain_index().shallow_clone(),
self.chain_config().shallow_clone(),
self.beacon_schedule().shallow_clone(),
&self.engine,
tipset.shallow_clone(),
);
let mut no_cb = NO_CALLBACK;
let (state_cid, _, _) = exec
.prepare_parent_state(genesis_timestamp, VMTrace::NotTraced, &mut no_cb)
.context("failed to prepare parent state in call_raw")?;
state_cid
}
};

let tipset_messages = self
.chain_store()
Expand All @@ -37,8 +56,6 @@ impl StateManager {
.iter()
.filter(|ts_msg| ts_msg.message().from() == msg.from());

// Handle state forks

let height = tipset.epoch();
let genesis_info = GenesisInfo::from_chain_config(self.chain_config().clone());
let mut vm = VM::new(
Expand Down
Loading