Skip to content

Commit

Permalink
Re-use some code from ref-fvm (#1500)
Browse files Browse the repository at this point in the history
* use fvm exports

* re-use FilterEstimate
  • Loading branch information
LesnyRumcajs authored Mar 25, 2022
1 parent 1bad495 commit b7951fb
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 556 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 types/src/build_version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use async_std::sync::RwLock;
use git_version::git_version;
use lazy_static::lazy_static;
use num_derive::FromPrimitive;
use std::fmt::{Display, Formatter, Result as FmtResult};

Expand Down
7 changes: 4 additions & 3 deletions types/src/deadlines/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

mod quantize;

pub use self::quantize::*;
use clock::ChainEpoch;
pub use fvm_shared::clock::QuantSpec;
use serde::{Deserialize, Serialize};

/// Constant defining the [QuantSpec] which performs no quantization.
pub const NO_QUANTIZATION: QuantSpec = QuantSpec { unit: 1, offset: 0 };

/// Deadline calculations with respect to a current epoch.
/// "Deadline" refers to the window during which proofs may be submitted.
/// Windows are non-overlapping ranges [Open, Close), but the challenge epoch for a window occurs
Expand Down
52 changes: 0 additions & 52 deletions types/src/deadlines/quantize.rs

This file was deleted.

86 changes: 10 additions & 76 deletions types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,91 +3,25 @@

pub mod build_version;
pub mod deadlines;
mod piece;
pub mod sector;
mod state;

#[cfg(feature = "json")]
pub mod genesis;

#[cfg(feature = "proofs")]
pub mod verifier;

pub use self::piece::*;
#[cfg(feature = "proofs")]
pub use fvm_shared::piece::zero_piece_commitment;

pub use self::sector::*;
pub use self::state::*;

pub use fvm_shared::piece::{PaddedPieceSize, PieceInfo, UnpaddedPieceSize};
pub use fvm_shared::randomness::{Randomness, RANDOMNESS_LENGTH};
pub use fvm_shared::state::{StateInfo0, StateRoot, StateTreeVersion};
pub use fvm_shared::version::NetworkVersion;

use address::Address;
use clock::ChainEpoch;
use num_bigint::BigInt;

#[macro_use]
extern crate lazy_static;

lazy_static! {
/// Total Filecoin available to the network.
pub static ref TOTAL_FILECOIN: BigInt = BigInt::from(TOTAL_FILECOIN_BASE) * FILECOIN_PRECISION;
/// Amount of total Filecoin reserved in a static ID address.
pub static ref FIL_RESERVED: BigInt = BigInt::from(300_000_000) * FILECOIN_PRECISION;

/// Zero address used to avoid allowing it to be used for verification.
/// This is intentionally disallowed because it is an edge case with Filecoin's BLS
/// signature verification.
pub static ref ZERO_ADDRESS: Address = "f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a".parse().unwrap();
}

/// Identifier for Actors, includes builtin and initialized actors
pub type ActorID = u64;

/// Default bit width for the hamt in the filecoin protocol.
pub const HAMT_BIT_WIDTH: u32 = 5;
/// Total gas limit allowed per block. This is shared across networks.
pub const BLOCK_GAS_LIMIT: i64 = 10_000_000_000;
/// Total Filecoin supply.
pub const TOTAL_FILECOIN_BASE: i64 = 2_000_000_000;

// Epochs
/// Lookback height for retrieving ticket randomness.
pub const TICKET_RANDOMNESS_LOOKBACK: ChainEpoch = 1;
/// Epochs to look back for verifying PoSt proofs.
pub const WINNING_POST_SECTOR_SET_LOOKBACK: ChainEpoch = 10;

/// The expected number of block producers in each epoch.
pub const BLOCKS_PER_EPOCH: u64 = 5;

/// Ratio of integer values to token value.
pub const FILECOIN_PRECISION: i64 = 1_000_000_000_000_000_000;

/// Allowable clock drift in validations.
pub const ALLOWABLE_CLOCK_DRIFT: u64 = 1;

/// Config trait which handles different network configurations.
pub trait NetworkParams {
/// Total filecoin available to network.
const TOTAL_FILECOIN: i64;

/// Available rewards for mining.
const MINING_REWARD_TOTAL: i64;

/// Initial reward actor balance. This function is only called in genesis setting up state.
fn initial_reward_balance() -> BigInt {
BigInt::from(Self::MINING_REWARD_TOTAL) * Self::TOTAL_FILECOIN
}

/// Convert integer value of tokens into BigInt based on the token precision.
fn from_fil(i: i64) -> BigInt {
BigInt::from(i) * FILECOIN_PRECISION
}
}

/// Params for the network. This is now continued on into mainnet and is static across networks.
// * This can be removed in the future if the new testnet is configred at build time
// * but the reason to keep as is, is for an easier transition to runtime configuration.
pub struct DefaultNetworkParams;
impl NetworkParams for DefaultNetworkParams {
const TOTAL_FILECOIN: i64 = TOTAL_FILECOIN_BASE;
const MINING_REWARD_TOTAL: i64 = 1_400_000_000;
}
pub use fvm_shared::{
ActorID, DefaultNetworkParams, NetworkParams, ALLOWABLE_CLOCK_DRIFT, BLOCKS_PER_EPOCH,
BLOCK_GAS_LIMIT, FILECOIN_PRECISION, FIL_RESERVED, HAMT_BIT_WIDTH, TICKET_RANDOMNESS_LOOKBACK,
TOTAL_FILECOIN, TOTAL_FILECOIN_BASE, WINNING_POST_SECTOR_SET_LOOKBACK, ZERO_ADDRESS,
};
122 changes: 0 additions & 122 deletions types/src/piece/mod.rs

This file was deleted.

Loading

0 comments on commit b7951fb

Please sign in to comment.