Skip to content

Commit

Permalink
chore: update the FVM to v4.1.0 (#446)
Browse files Browse the repository at this point in the history
1. Implements the new tracing changes.
2. Explicitly uses the new "FilecoinKernel".
3. Enables support for nv22.
  • Loading branch information
Stebalien authored Jan 25, 2024
1 parent 8e6cb7a commit 880602e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 23 deletions.
53 changes: 43 additions & 10 deletions rust/Cargo.lock

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

4 changes: 2 additions & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ rayon = "1.2.1"
anyhow = "1.0.23"
serde_json = "1.0.46"
rust-gpu-tools = { version = "0.7", optional = true, default-features = false }
fvm4 = { package = "fvm", version = "~4.0.0-alpha.4", default-features = false }
fvm4_shared = { package = "fvm_shared", version = "~4.0.0-alpha.4" }
fvm4 = { package = "fvm", version = "~4.1.1", default-features = false }
fvm4_shared = { package = "fvm_shared", version = "~4.1.1" }
fvm3 = { package = "fvm", version = "~3.8.0", default-features = false }
fvm3_shared = { package = "fvm_shared", version = "~3.6.0" }
fvm2 = { package = "fvm", version = "~2.7", default-features = false }
Expand Down
9 changes: 3 additions & 6 deletions rust/src/fvm/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl TryFrom<u32> for EngineVersion {
match value {
16 | 17 => Ok(EngineVersion::V1),
18 | 19 | 20 => Ok(EngineVersion::V2),
21 => Ok(EngineVersion::V3),
21 | 22 => Ok(EngineVersion::V3),
_ => return Err(anyhow!("network version not supported")),
}
}
Expand Down Expand Up @@ -164,8 +164,8 @@ mod v4 {
ApplyKind, ApplyRet, DefaultExecutor as DefaultExecutor4,
ThreadedExecutor as ThreadedExecutor4,
};
use fvm4::kernel::filecoin::DefaultFilecoinKernel as DefaultFilecoinKernel4;
use fvm4::machine::{DefaultMachine as DefaultMachine4, NetworkConfig};
use fvm4::DefaultKernel as DefaultKernel4;
use fvm4_shared::{chainid::ChainID, clock::ChainEpoch, message::Message};

use crate::fvm::engine::{
Expand All @@ -175,7 +175,7 @@ mod v4 {
use super::Config;

type CgoMachine4 = DefaultMachine4<CgoBlockstore, CgoExterns>;
type BaseExecutor4 = DefaultExecutor4<DefaultKernel4<DefaultCallManager4<CgoMachine4>>>;
type BaseExecutor4 = DefaultExecutor4<DefaultFilecoinKernel4<DefaultCallManager4<CgoMachine4>>>;
type CgoExecutor4 = ThreadedExecutor4<BaseExecutor4>;

fn new_executor(
Expand Down Expand Up @@ -427,9 +427,6 @@ mod v3 {
.unwrap_or(ErrorNumber::AssertionFailed),
)))
}
ExecutionEvent3::InvokeActor(cid) => {
Some(ExecutionEvent::InvokeActor(cid))
}
_ => None,
})
.collect(),
Expand Down
20 changes: 15 additions & 5 deletions rust/src/fvm/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use fvm4::executor::ApplyKind;
use fvm4::gas::GasCharge;
use fvm4::trace::ExecutionEvent;
use fvm4_shared::address::Address;
use fvm4_shared::MethodNum;
use fvm4_shared::state::ActorState;
use fvm4_shared::{ActorID, MethodNum};
use fvm_ipld_encoding::ipld_block::IpldBlock;
use fvm_ipld_encoding::tuple::{Deserialize_tuple, Serialize_tuple};
use fvm_ipld_encoding::{strict_bytes, to_vec, CborStore};
Expand Down Expand Up @@ -369,6 +370,7 @@ struct LotusGasCharge {
struct Trace {
pub msg: TraceMessage,
pub msg_ret: TraceReturn,
pub msg_invoked: Option<TraceActor>,
pub gas_charges: Vec<LotusGasCharge>,
pub subcalls: Vec<Trace>,
}
Expand All @@ -384,7 +386,12 @@ pub struct TraceMessage {
pub codec: u64,
pub gas_limit: u64,
pub read_only: bool,
pub code_cid: Cid,
}

#[derive(Serialize_tuple, Deserialize_tuple, Debug, PartialEq, Eq, Clone)]
pub struct TraceActor {
pub actor_id: ActorID,
pub actor_state: ActorState,
}

#[derive(Serialize_tuple, Deserialize_tuple, Debug, PartialEq, Eq, Clone)]
Expand Down Expand Up @@ -417,8 +424,8 @@ fn build_lotus_trace(
codec: params.codec,
gas_limit,
read_only,
code_cid: Cid::default(),
},
msg_invoked: None,
msg_ret: TraceReturn {
exit_code: ExitCode::OK,
return_data: Vec::new(),
Expand All @@ -443,8 +450,11 @@ fn build_lotus_trace(
from, to, method, params, value, gas_limit, read_only, trace_iter,
)?);
}
ExecutionEvent::InvokeActor(cid) => {
new_trace.msg.code_cid = cid;
ExecutionEvent::InvokeActor { id, state } => {
new_trace.msg_invoked = Some(TraceActor {
actor_id: id,
actor_state: state,
})
}
ExecutionEvent::CallReturn(exit_code, return_data) => {
let return_data = return_data.unwrap_or_default();
Expand Down

0 comments on commit 880602e

Please sign in to comment.