diff --git a/src/state_manager/message_simulation.rs b/src/state_manager/message_simulation.rs index 637c7316979..fc89847853e 100644 --- a/src/state_manager/message_simulation.rs +++ b/src/state_manager/message_simulation.rs @@ -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}; @@ -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; @@ -26,7 +28,24 @@ impl StateManager { ) -> Result { 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() @@ -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(