Skip to content

Commit ab50ad1

Browse files
committed
feat: shared: remove a bunch of code
- `BLOCK_GAS_LIMIT`: Neither the FVM nor the builtin actors care about the block gas limit. And if they did, it would have to be a runtime parameter passed from the client. - `EPOCH_DURATION_SECONDS`: Different networks may have different block times, this constant is useless. - `math`, `reward`, `smooth`: part of the reward actor calculations, not relevant to the FVM itself (moved to the builtin actors). - `TOTAL_FILECOIN`, `TOTAL_FILECOIN_BASE`: Network parameter, not a concern of the FVM. - `BLOCKS_PER_EPOCH`: protocol parameter, moved to the builtin actors. - `MAX_SECTOR_NUMBER`: moved to the builtin actors. - `Spacetime`, `SectorQuality`: moved to the builtin actors. - `ZERO_ADDRESS`, `*_LOOKBACK`, `ALLOWABLE_CLOCK_DRIFT`, `NetworkParams`, `DefaultNetworkParams`: unused.
1 parent 5cd204d commit ab50ad1

File tree

14 files changed

+7
-389
lines changed

14 files changed

+7
-389
lines changed

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fvm/src/machine/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ impl NetworkConfig {
192192
epoch,
193193
timestamp,
194194
initial_state_root: initial_state,
195-
circ_supply: fvm_shared::TOTAL_FILECOIN.clone(),
195+
// This is just the default. The previous default of "total FIL supply" was incorrect as
196+
// well, so we might as well be more neutral.
197+
circ_supply: TokenAmount::zero(),
196198
tracing: false,
197199
}
198200
}

fvm/tests/dummy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub struct TestData {
200200
pub charge_gas_calls: usize,
201201
}
202202

203-
const BLOCK_GAS_LIMIT: Gas = Gas::new(fvm_shared::BLOCK_GAS_LIMIT);
203+
const BLOCK_GAS_LIMIT: Gas = Gas::new(10_000_000_000);
204204

205205
impl DummyCallManager {
206206
pub fn new_stub() -> (Self, Rc<RefCell<TestData>>) {

shared/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ blake2b_simd = { workspace = true }
1212
thiserror = { workspace = true }
1313
num-traits = { workspace = true }
1414
num-derive = { workspace = true }
15-
lazy_static = { workspace = true }
1615
cid = { workspace = true, features = ["serde-codec", "std"] }
1716
multihash = { workspace = true }
1817
unsigned-varint = { workspace = true }

shared/src/clock/mod.rs

-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
// Copyright 2019-2022 ChainSafe Systems
33
// SPDX-License-Identifier: Apache-2.0, MIT
44

5-
mod quantize;
6-
pub use quantize::*;
7-
8-
const _ISO_FORMAT: &str = "%FT%X.%.9F";
9-
10-
/// Duration of each tipset epoch.
11-
pub const EPOCH_DURATION_SECONDS: i64 = 30;
12-
135
/// Epoch number of a chain. This acts as a proxy for time within the VM.
146
pub type ChainEpoch = i64;
157

shared/src/clock/quantize.rs

-53
This file was deleted.

shared/src/econ/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ mod test {
372372
use num_bigint::BigInt;
373373
use num_traits::Zero;
374374

375-
use crate::TokenAmount;
375+
use super::TokenAmount;
376376

377377
fn whole(x: impl Into<BigInt>) -> TokenAmount {
378378
TokenAmount::from_whole(x)

shared/src/lib.rs

+2-59
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

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

7-
#[macro_use]
8-
extern crate lazy_static;
9-
107
use address::Address;
118
use cid::Cid;
129
use clock::ChainEpoch;
@@ -22,37 +19,23 @@ pub mod deal;
2219
pub mod econ;
2320
pub mod error;
2421
pub mod event;
25-
pub mod math;
2622
pub mod message;
2723
pub mod piece;
2824
pub mod randomness;
2925
pub mod receipt;
30-
pub mod reward;
3126
pub mod sector;
32-
pub mod smooth;
3327
pub mod state;
3428
pub mod sys;
3529
pub mod upgrade;
3630
pub mod version;
3731

3832
use crypto::hash::SupportedHashes;
39-
use econ::TokenAmount;
4033
use fvm_ipld_encoding::ipld_block::IpldBlock;
4134
use fvm_ipld_encoding::DAG_CBOR;
4235
use multihash::Multihash;
4336

4437
use crate::error::ExitCode;
4538

46-
lazy_static! {
47-
/// Total Filecoin available to the network.
48-
pub static ref TOTAL_FILECOIN: TokenAmount = TokenAmount::from_whole(TOTAL_FILECOIN_BASE);
49-
50-
/// Zero address used to avoid allowing it to be used for verification.
51-
/// This is intentionally disallowed because it is an edge case with Filecoin's BLS
52-
/// signature verification.
53-
pub static ref ZERO_ADDRESS: Address = address::Network::Mainnet.parse_address("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a").unwrap();
54-
}
55-
5639
/// Codec for raw data.
5740
pub const IPLD_RAW: u64 = 0x55;
5841

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

65-
/// Identifier for Actors, includes builtin and initialized actors
66-
pub type ActorID = u64;
67-
6848
/// Default bit width for the hamt in the filecoin protocol.
6949
pub const HAMT_BIT_WIDTH: u32 = 5;
70-
/// Total gas limit allowed per block. This is shared across networks.
71-
pub const BLOCK_GAS_LIMIT: u64 = 10_000_000_000;
72-
/// Total Filecoin supply.
73-
pub const TOTAL_FILECOIN_BASE: i64 = 2_000_000_000;
74-
75-
// Epochs
76-
/// Lookback height for retrieving ticket randomness.
77-
pub const TICKET_RANDOMNESS_LOOKBACK: ChainEpoch = 1;
78-
/// Epochs to look back for verifying PoSt proofs.
79-
pub const WINNING_POST_SECTOR_SET_LOOKBACK: ChainEpoch = 10;
80-
81-
/// The expected number of block producers in each epoch.
82-
pub const BLOCKS_PER_EPOCH: u64 = 5;
83-
84-
/// Allowable clock drift in validations.
85-
pub const ALLOWABLE_CLOCK_DRIFT: u64 = 1;
86-
87-
/// Config trait which handles different network configurations.
88-
pub trait NetworkParams {
89-
/// Total filecoin available to network.
90-
const TOTAL_FILECOIN: i64;
91-
92-
/// Available rewards for mining.
93-
const MINING_REWARD_TOTAL: i64;
94-
95-
/// Initial reward actor balance. This function is only called in genesis setting up state.
96-
fn initial_reward_balance() -> TokenAmount {
97-
TokenAmount::from_whole(Self::MINING_REWARD_TOTAL)
98-
}
99-
}
100-
101-
/// Params for the network. This is now continued on into mainnet and is static across networks.
102-
// * This can be removed in the future if the new testnet is configred at build time
103-
// * but the reason to keep as is, is for an easier transition to runtime configuration.
104-
pub struct DefaultNetworkParams;
10550

106-
impl NetworkParams for DefaultNetworkParams {
107-
const TOTAL_FILECOIN: i64 = TOTAL_FILECOIN_BASE;
108-
const MINING_REWARD_TOTAL: i64 = 1_400_000_000;
109-
}
51+
/// Identifier for Actors, includes builtin and initialized actors
52+
pub type ActorID = u64;
11053

11154
/// Method number indicator for calling actor methods.
11255
pub type MethodNum = u64;

shared/src/math.rs

-23
This file was deleted.

shared/src/reward.rs

-15
This file was deleted.

shared/src/sector/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,9 @@ use crate::ActorID;
2121
/// SectorNumber is a numeric identifier for a sector. It is usually relative to a miner.
2222
pub type SectorNumber = u64;
2323

24-
/// The maximum assignable sector number.
25-
/// Raising this would require modifying our AMT implementation.
26-
pub const MAX_SECTOR_NUMBER: SectorNumber = i64::MAX as u64;
27-
2824
/// Unit of storage power (measured in bytes)
2925
pub type StoragePower = BigInt;
3026

31-
/// The unit of spacetime committed to the network
32-
pub type Spacetime = BigInt;
33-
34-
/// Unit of sector quality
35-
pub type SectorQuality = BigInt;
36-
3727
/// SectorSize indicates one of a set of possible sizes in the network.
3828
#[derive(Clone, Debug, PartialEq, Eq, Copy, FromPrimitive, Serialize_repr, Deserialize_repr)]
3929
#[repr(u64)]

shared/src/smooth/alpha_beta_filter.rs

-111
This file was deleted.

shared/src/smooth/mod.rs

-9
This file was deleted.

0 commit comments

Comments
 (0)