Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update conformance test vectors (and fix test driver) #1404

Merged
merged 4 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions tests/conformance_tests/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use super::*;
use db::MemoryDB;
use interpreter::{CircSupplyCalc, LookbackStateGetter};
use networks::get_network_version_default;
use state_tree::StateTree;
use vm::TokenAmount;

Expand All @@ -23,6 +22,7 @@ pub struct ExecuteMessageParams<'a> {
pub circ_supply: TokenAmount,
pub basefee: TokenAmount,
pub randomness: ReplayingRand<'a>,
pub nv: fil_types::NetworkVersion,
}

struct MockCircSupply(TokenAmount);
Expand Down Expand Up @@ -51,13 +51,14 @@ pub fn execute_message(
let circ_supply = MockCircSupply(params.circ_supply);
let lb = MockStateLB(bs);

let nv = params.nv;
let mut vm = VM::<_, _, _, _, _>::new(
params.pre_root,
bs,
params.epoch,
&params.randomness,
params.basefee,
get_network_version_default,
|_| nv,
&circ_supply,
&lb,
)?;
Expand Down
2 changes: 1 addition & 1 deletion tests/conformance_tests/test-vectors
Submodule test-vectors updated 2295 files
3 changes: 3 additions & 0 deletions tests/conformance_tests/tests/conformance_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use cid::Cid;
use clock::ChainEpoch;
use conformance_tests::*;
use encoding::Cbor;
use fil_types::NetworkVersion;
use fil_types::TOTAL_FILECOIN;
use flate2::read::GzDecoder;
use forest_message::{MessageReceipt, UnsignedMessage};
Expand All @@ -21,6 +22,7 @@ use paramfetch::{get_params_default, SectorSizeOpt};
use regex::Regex;
use state_manager::StateManager;
use statediff::print_state_diff;
use std::convert::TryInto;
use std::error::Error as StdError;
use std::fmt;
use std::fs::File;
Expand Down Expand Up @@ -189,6 +191,7 @@ async fn execute_message_vector(
.map(|i| i.to_bigint().unwrap())
.unwrap_or(DEFAULT_BASE_FEE.clone()),
randomness: ReplayingRand::new(randomness),
nv: variant.nv.try_into().unwrap_or(NetworkVersion::V0),
},
)?;
root = post_root;
Expand Down
16 changes: 15 additions & 1 deletion types/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use encoding::repr::Serialize_repr;
use std::convert::TryFrom;
use std::fmt::{self, Display, Formatter};
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;

/// Specifies the network version
#[derive(Debug, PartialEq, Clone, Copy, PartialOrd, Serialize_repr)]
#[derive(Debug, PartialEq, Clone, Copy, PartialOrd, Serialize_repr, FromPrimitive)]
#[repr(u32)]
pub enum NetworkVersion {
/// genesis (specs-actors v0.9.3)
Expand Down Expand Up @@ -40,6 +43,17 @@ pub enum NetworkVersion {
V14,
}

impl TryFrom<u32> for NetworkVersion {
type Error = ();

fn try_from(v: u32) -> Result<Self, Self::Error> {
match FromPrimitive::from_u32(v) {
Some(nv) => Ok(nv),
_ => Err(()),
}
}
}

impl Display for NetworkVersion {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Expand Down