Skip to content

Commit

Permalink
Interopnet support (#964)
Browse files Browse the repository at this point in the history
* Move block delay secs

* Swap seal proof ordering (bug)

* Add interopnet feature and build config

* fix feature v0

* Update docs for interopnet

* Move mainnet specific tests under feature

* move flag
  • Loading branch information
austinabell authored Jan 26, 2021
1 parent 59c4413 commit d82e379
Show file tree
Hide file tree
Showing 19 changed files with 153 additions and 69 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ build:
release:
cargo build --release --bin forest

interopnet:
cargo build --release --manifest-path=forest/Cargo.toml --features "interopnet"

docker-run:
docker build -t forest:latest -f ./Dockerfile . && docker run forest

Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ make test-vectors
make test-all
```

### Joining the testnet

Build with the `interopnet` config with:

```bash
make interopnet

# Run and import past the state migrations to latest network version
./target/release/forest --import-snapshot ./types/networks/src/interopnet/snapshot.car
```

Importing the snapshot only needs to happen during the first run. Following this, to restart the daemon run:

```bash
./target/release/forest
```

### Documentation
https://chainsafe.github.io/forest/

Expand Down
6 changes: 3 additions & 3 deletions blockchain/chain_sync/src/sync_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ use cid::{Cid, Code::Blake2b256};
use crypto::{verify_bls_aggregate, DomainSeparationTag};
use encoding::{Cbor, Error as EncodingError};
use fil_types::{
verifier::ProofVerifier, NetworkVersion, Randomness, ALLOWABLE_CLOCK_DRIFT, BLOCK_DELAY_SECS,
BLOCK_GAS_LIMIT, TICKET_RANDOMNESS_LOOKBACK,
verifier::ProofVerifier, NetworkVersion, Randomness, ALLOWABLE_CLOCK_DRIFT, BLOCK_GAS_LIMIT,
TICKET_RANDOMNESS_LOOKBACK,
};
use forest_libp2p::chain_exchange::TipsetBundle;
use futures::stream::{FuturesUnordered, StreamExt};
use interpreter::price_list_by_epoch;
use ipld_blockstore::BlockStore;
use log::{debug, info, warn};
use message::{Message, SignedMessage, UnsignedMessage};
use networks::{get_network_version_default, UPGRADE_SMOKE_HEIGHT};
use networks::{get_network_version_default, BLOCK_DELAY_SECS, UPGRADE_SMOKE_HEIGHT};
use state_manager::StateManager;
use state_tree::StateTree;
use std::collections::HashMap;
Expand Down
4 changes: 2 additions & 2 deletions blockchain/message_pool/src/msgpool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use futures::{future::select, StreamExt};
use log::{error, warn};
use lru::LruCache;
use message::{ChainMessage, Message, SignedMessage, UnsignedMessage};
use networks::{NEWEST_NETWORK_VERSION, UPGRADE_BREEZE_HEIGHT};
use networks::{BLOCK_DELAY_SECS, NEWEST_NETWORK_VERSION, UPGRADE_BREEZE_HEIGHT};
use num_bigint::{BigInt, Integer};
use num_rational::BigRational;
use num_traits::cast::ToPrimitive;
Expand All @@ -45,7 +45,7 @@ const BASE_FEE_LOWER_BOUND_FACTOR_CONSERVATIVE: i64 = 100;
const BASE_FEE_LOWER_BOUND_FACTOR: i64 = 10;
const REPUB_MSG_LIMIT: usize = 30;
const PROPAGATION_DELAY_SECS: u64 = 6;
const REPUBLISH_INTERVAL: u64 = 10 * types::BLOCK_DELAY_SECS + PROPAGATION_DELAY_SECS;
const REPUBLISH_INTERVAL: u64 = 10 * BLOCK_DELAY_SECS + PROPAGATION_DELAY_SECS;

// this is *temporary* mutilation until we have implemented uncapped miner penalties -- it will go
// away in the next fork.
Expand Down
1 change: 1 addition & 0 deletions forest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ default = ["rocksdb"]
rocksdb = ["db/rocksdb", "ipld_blockstore/rocksdb"]
sled = ["db/sled", "ipld_blockstore/sled"]
devnet = ["actor/devnet"]
interopnet = ["actor/interopnet", "networks/interopnet"]
insecure_post = ["chain_sync/insecure_post"]
1 change: 1 addition & 0 deletions forest/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ pub(super) async fn start(config: Config) {
}

#[cfg(test)]
#[cfg(not(any(feature = "interopnet", feature = "devnet")))]
mod test {
use super::*;
use db::MemoryDB;
Expand Down
2 changes: 1 addition & 1 deletion node/rpc/src/common_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use fil_types::build_version::{user_version, APIVersion, Version, RUNNING_NODE_TYPE};
use fil_types::BLOCK_DELAY_SECS;
use jsonrpc_v2::Error as JsonRpcError;
use networks::BLOCK_DELAY_SECS;
use std::convert::TryInto;

pub(crate) async fn version() -> Result<APIVersion, JsonRpcError> {
Expand Down
3 changes: 3 additions & 0 deletions types/networks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ clock = { package = "fil_clock", path = "../../node/clock", version = "0.1" }
lazy_static = "1.4"
beacon = { path = "../../blockchain/beacon" }
serde_json = "1.0"

[features]
interopnet = []
Binary file added types/networks/src/interopnet/genesis.car
Binary file not shown.
50 changes: 50 additions & 0 deletions types/networks/src/interopnet/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use super::{drand::DRAND_MAINNET, DrandPoint};
use clock::{ChainEpoch, EPOCH_DURATION_SECONDS};
use fil_types::NetworkVersion;

/// Default genesis car file bytes.
pub const DEFAULT_GENESIS: &[u8] = include_bytes!("genesis.car");

/// V1 network upgrade
pub const UPGRADE_BREEZE_HEIGHT: ChainEpoch = -1;
/// V2 network upgrade
pub const UPGRADE_SMOKE_HEIGHT: ChainEpoch = -2;
/// V3 network upgrade
pub const UPGRADE_IGNITION_HEIGHT: ChainEpoch = -3;
/// V4 network upgrade
pub const UPGRADE_ACTORS_V2_HEIGHT: ChainEpoch = 30;
/// V5 network upgrade
pub const UPGRADE_TAPE_HEIGHT: ChainEpoch = 60;
/// Switching to mainnet network name
pub const UPGRADE_LIFTOFF_HEIGHT: i64 = -5;
/// V6 network upgrade
pub const UPGRADE_KUMQUAT_HEIGHT: ChainEpoch = 90;
/// V7 network upgrade
pub const UPGRADE_CALICO_HEIGHT: ChainEpoch = 120;
/// V8 network upgrade
pub const UPGRADE_PERSIAN_HEIGHT: ChainEpoch = 150;
/// V9 network upgrade
pub const UPGRADE_ORANGE_HEIGHT: ChainEpoch = 180;
/// Remove burn on window PoSt fork
pub const UPGRADE_CLAUS_HEIGHT: ChainEpoch = 210;

/// Current network version for the network
pub const NEWEST_NETWORK_VERSION: NetworkVersion = NetworkVersion::V9;

/// Bootstrap peer ids
pub const DEFAULT_BOOTSTRAP: &[&str] = &[
"/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWQmCzFxEPfEoReafjwiLMqwWsBLWLwbeNyVVm9s6foDwh",
"/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWL8YeT6dDpfushm4Y1LeZjvG1dRMbs8JUERoF4YvxDqfD",
];

lazy_static! {
pub(super) static ref DRAND_SCHEDULE: [DrandPoint<'static>; 1] = [DrandPoint {
height: 0,
config: &*DRAND_MAINNET,
},];
}

pub const BLOCK_DELAY_SECS: u64 = EPOCH_DURATION_SECONDS as u64;
Binary file added types/networks/src/interopnet/snapshot.car
Binary file not shown.
48 changes: 47 additions & 1 deletion types/networks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ extern crate lazy_static;

use beacon::{BeaconPoint, BeaconSchedule, DrandBeacon, DrandConfig};
use clock::ChainEpoch;
use fil_types::{NetworkVersion, BLOCK_DELAY_SECS};
use fil_types::NetworkVersion;
use std::{error::Error, sync::Arc};

mod drand;

#[cfg(not(any(feature = "interopnet")))]
mod mainnet;
#[cfg(not(any(feature = "interopnet")))]
pub use self::mainnet::*;

#[cfg(feature = "interopnet")]
mod interopnet;
#[cfg(feature = "interopnet")]
pub use self::interopnet::*;

struct Upgrade {
height: ChainEpoch,
network: NetworkVersion,
Expand All @@ -24,6 +31,45 @@ struct DrandPoint<'a> {
pub config: &'a DrandConfig<'a>,
}

const VERSION_SCHEDULE: [Upgrade; 9] = [
Upgrade {
height: UPGRADE_BREEZE_HEIGHT,
network: NetworkVersion::V1,
},
Upgrade {
height: UPGRADE_SMOKE_HEIGHT,
network: NetworkVersion::V2,
},
Upgrade {
height: UPGRADE_IGNITION_HEIGHT,
network: NetworkVersion::V3,
},
Upgrade {
height: UPGRADE_ACTORS_V2_HEIGHT,
network: NetworkVersion::V4,
},
Upgrade {
height: UPGRADE_TAPE_HEIGHT,
network: NetworkVersion::V5,
},
Upgrade {
height: UPGRADE_KUMQUAT_HEIGHT,
network: NetworkVersion::V6,
},
Upgrade {
height: UPGRADE_CALICO_HEIGHT,
network: NetworkVersion::V7,
},
Upgrade {
height: UPGRADE_PERSIAN_HEIGHT,
network: NetworkVersion::V8,
},
Upgrade {
height: UPGRADE_ORANGE_HEIGHT,
network: NetworkVersion::V9,
},
];

/// Gets network version from epoch using default Mainnet schedule
pub fn get_network_version_default(epoch: ChainEpoch) -> NetworkVersion {
VERSION_SCHEDULE
Expand Down
46 changes: 4 additions & 42 deletions types/networks/src/mainnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

use super::{
drand::{DRAND_INCENTINET, DRAND_MAINNET},
DrandPoint, Upgrade,
DrandPoint,
};
use clock::ChainEpoch;
use clock::{ChainEpoch, EPOCH_DURATION_SECONDS};
use fil_types::NetworkVersion;

/// Default genesis car file bytes.
Expand All @@ -32,48 +32,8 @@ pub const UPGRADE_PERSIAN_HEIGHT: ChainEpoch = 272400;
/// V9 network upgrade
pub const UPGRADE_ORANGE_HEIGHT: ChainEpoch = 336458;
/// Remove burn on window PoSt fork
// TODO implement updates for height https://github.com/ChainSafe/forest/issues/905
pub const UPGRADE_CLAUS_HEIGHT: ChainEpoch = 343200;

pub(super) const VERSION_SCHEDULE: [Upgrade; 9] = [
Upgrade {
height: UPGRADE_BREEZE_HEIGHT,
network: NetworkVersion::V1,
},
Upgrade {
height: UPGRADE_SMOKE_HEIGHT,
network: NetworkVersion::V2,
},
Upgrade {
height: UPGRADE_IGNITION_HEIGHT,
network: NetworkVersion::V3,
},
Upgrade {
height: UPGRADE_ACTORS_V2_HEIGHT,
network: NetworkVersion::V4,
},
Upgrade {
height: UPGRADE_TAPE_HEIGHT,
network: NetworkVersion::V5,
},
Upgrade {
height: UPGRADE_KUMQUAT_HEIGHT,
network: NetworkVersion::V6,
},
Upgrade {
height: UPGRADE_CALICO_HEIGHT,
network: NetworkVersion::V7,
},
Upgrade {
height: UPGRADE_PERSIAN_HEIGHT,
network: NetworkVersion::V8,
},
Upgrade {
height: UPGRADE_ORANGE_HEIGHT,
network: NetworkVersion::V9,
},
];

/// Current network version for the network
pub const NEWEST_NETWORK_VERSION: NetworkVersion = NetworkVersion::V9;

Expand Down Expand Up @@ -108,3 +68,5 @@ lazy_static! {
},
];
}

pub const BLOCK_DELAY_SECS: u64 = EPOCH_DURATION_SECONDS as u64;
5 changes: 1 addition & 4 deletions types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub use self::state::*;
pub use self::version::*;

use address::Address;
use clock::{ChainEpoch, EPOCH_DURATION_SECONDS};
use clock::ChainEpoch;
use num_bigint::BigInt;

#[macro_use]
Expand Down Expand Up @@ -54,9 +54,6 @@ 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;

/// Block delay, or epoch duration, to be used in blockchain system.
pub const BLOCK_DELAY_SECS: u64 = EPOCH_DURATION_SECONDS as u64;

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

Expand Down
8 changes: 4 additions & 4 deletions types/src/sector/registered_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ i64_conversion! {
i64_conversion! {
RegisteredSealProof;
StackedDRG2KiBV1 => 0,
StackedDRG512MiBV1 => 1,
StackedDRG8MiBV1 => 2,
StackedDRG8MiBV1 => 1,
StackedDRG512MiBV1 => 2,
StackedDRG32GiBV1 => 3,
StackedDRG64GiBV1 => 4,

StackedDRG2KiBV1P1 => 5,
StackedDRG512MiBV1P1 => 6,
StackedDRG8MiBV1P1 => 7,
StackedDRG8MiBV1P1 => 6,
StackedDRG512MiBV1P1 => 7,
StackedDRG32GiBV1P1 => 8,
StackedDRG64GiBV1P1 => 9,
}
Expand Down
3 changes: 2 additions & 1 deletion vm/actor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ hex = "0.4.2"
libp2p = { version = "0.28", default-features = false }

[features]
devnet = []
devnet = []
interopnet = []
18 changes: 10 additions & 8 deletions vm/actor/src/builtin/sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
use fil_types::{RegisteredSealProof, StoragePower};

/// Returns the minimum storage power required for each seal proof types.
#[cfg(not(feature = "devnet"))]
pub fn consensus_miner_min_power(p: RegisteredSealProof) -> Result<StoragePower, String> {
use RegisteredSealProof::*;
match p {
// Specs actors defaults to other values, these are the mainnet values put in place
StackedDRG2KiBV1 | StackedDRG2KiBV1P1 | StackedDRG512MiBV1 | StackedDRG512MiBV1P1
| StackedDRG8MiBV1 | StackedDRG8MiBV1P1 | StackedDRG32GiBV1 | StackedDRG32GiBV1P1
| StackedDRG64GiBV1 | StackedDRG64GiBV1P1 => Ok(StoragePower::from(10u64 << 40)),
| StackedDRG64GiBV1 | StackedDRG64GiBV1P1 => {
if cfg!(feature = "devnet") {
return Ok(StoragePower::from(2048));
}
if cfg!(feature = "interopnet") {
return Ok(StoragePower::from(2 << 30));
}

Ok(StoragePower::from(10u64 << 40))
}
Invalid(i) => Err(format!("unsupported proof type: {}", i)),
}
}

/// Returns the minimum storage power required for each seal proof types.
#[cfg(feature = "devnet")]
pub fn consensus_miner_min_power(_p: RegisteredSealProof) -> Result<StoragePower, String> {
Ok(StoragePower::from(2048))
}
1 change: 1 addition & 0 deletions vm/actor_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ forest_json_utils = "0.1.1"

[features]
devnet = ["actorv0/devnet", "actorv2/devnet"]
interopnet = ["actorv0/interopnet", "actorv2/interopnet"]

0 comments on commit d82e379

Please sign in to comment.