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

feat: slim down shared #1986

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion Cargo.lock

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

4 changes: 3 additions & 1 deletion fvm/src/machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ impl NetworkConfig {
epoch,
timestamp,
initial_state_root: initial_state,
circ_supply: fvm_shared::TOTAL_FILECOIN.clone(),
// This is just the default. The previous default of "total FIL supply" was incorrect as
// well, so we might as well be more neutral.
circ_supply: TokenAmount::zero(),
tracing: false,
}
}
Expand Down
2 changes: 1 addition & 1 deletion fvm/tests/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub struct TestData {
pub charge_gas_calls: usize,
}

const BLOCK_GAS_LIMIT: Gas = Gas::new(fvm_shared::BLOCK_GAS_LIMIT);
const BLOCK_GAS_LIMIT: Gas = Gas::new(10_000_000_000);

impl DummyCallManager {
pub fn new_stub() -> (Self, Rc<RefCell<TestData>>) {
Expand Down
1 change: 0 additions & 1 deletion shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ blake2b_simd = { workspace = true }
thiserror = { workspace = true }
num-traits = { workspace = true }
num-derive = { workspace = true }
lazy_static = { workspace = true }
cid = { workspace = true, features = ["serde-codec", "std"] }
multihash = { workspace = true }
unsigned-varint = { workspace = true }
Expand Down
8 changes: 0 additions & 8 deletions shared/src/clock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

mod quantize;
pub use quantize::*;

const _ISO_FORMAT: &str = "%FT%X.%.9F";

/// Duration of each tipset epoch.
pub const EPOCH_DURATION_SECONDS: i64 = 30;

/// Epoch number of a chain. This acts as a proxy for time within the VM.
pub type ChainEpoch = i64;

Expand Down
53 changes: 0 additions & 53 deletions shared/src/clock/quantize.rs

This file was deleted.

2 changes: 1 addition & 1 deletion shared/src/econ/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ mod test {
use num_bigint::BigInt;
use num_traits::Zero;

use crate::TokenAmount;
use super::TokenAmount;

fn whole(x: impl Into<BigInt>) -> TokenAmount {
TokenAmount::from_whole(x)
Expand Down
61 changes: 2 additions & 59 deletions shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

#![cfg_attr(coverage_nightly, feature(coverage_attribute))]

#[macro_use]
extern crate lazy_static;

use address::Address;
use cid::Cid;
use clock::ChainEpoch;
Expand All @@ -22,37 +19,23 @@ pub mod deal;
pub mod econ;
pub mod error;
pub mod event;
pub mod math;
pub mod message;
pub mod piece;
pub mod randomness;
pub mod receipt;
pub mod reward;
pub mod sector;
pub mod smooth;
pub mod state;
pub mod sys;
pub mod upgrade;
pub mod version;

use crypto::hash::SupportedHashes;
use econ::TokenAmount;
use fvm_ipld_encoding::ipld_block::IpldBlock;
use fvm_ipld_encoding::DAG_CBOR;
use multihash::Multihash;

use crate::error::ExitCode;

lazy_static! {
/// Total Filecoin available to the network.
pub static ref TOTAL_FILECOIN: TokenAmount = TokenAmount::from_whole(TOTAL_FILECOIN_BASE);

/// 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 = address::Network::Mainnet.parse_address("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a").unwrap();
}

/// Codec for raw data.
pub const IPLD_RAW: u64 = 0x55;

Expand All @@ -62,51 +45,11 @@ pub const IDENTITY_HASH: u64 = 0x0;
/// The maximum supported CID size.
pub const MAX_CID_LEN: usize = 100;

/// 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: u64 = 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;

/// 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() -> TokenAmount {
TokenAmount::from_whole(Self::MINING_REWARD_TOTAL)
}
}

/// 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;
}
/// Identifier for Actors, includes builtin and initialized actors
pub type ActorID = u64;

/// Method number indicator for calling actor methods.
pub type MethodNum = u64;
Expand Down
23 changes: 0 additions & 23 deletions shared/src/math.rs

This file was deleted.

15 changes: 0 additions & 15 deletions shared/src/reward.rs

This file was deleted.

10 changes: 0 additions & 10 deletions shared/src/sector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,9 @@ use crate::ActorID;
/// SectorNumber is a numeric identifier for a sector. It is usually relative to a miner.
pub type SectorNumber = u64;

/// The maximum assignable sector number.
/// Raising this would require modifying our AMT implementation.
pub const MAX_SECTOR_NUMBER: SectorNumber = i64::MAX as u64;

/// Unit of storage power (measured in bytes)
pub type StoragePower = BigInt;

/// The unit of spacetime committed to the network
pub type Spacetime = BigInt;

/// Unit of sector quality
pub type SectorQuality = BigInt;

/// SectorSize indicates one of a set of possible sizes in the network.
#[derive(Clone, Debug, PartialEq, Eq, Copy, FromPrimitive, Serialize_repr, Deserialize_repr)]
#[repr(u64)]
Expand Down
111 changes: 0 additions & 111 deletions shared/src/smooth/alpha_beta_filter.rs

This file was deleted.

9 changes: 0 additions & 9 deletions shared/src/smooth/mod.rs

This file was deleted.

Loading
Loading