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

use exports from ref-fvm #1495

Merged
merged 3 commits into from
Mar 24, 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
65 changes: 0 additions & 65 deletions encoding/src/bytes.rs

This file was deleted.

4 changes: 2 additions & 2 deletions encoding/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

mod bytes;
mod checked_serde_bytes;
mod hash;

pub use serde::{de, ser};
pub use serde_bytes;
pub use serde_ipld_dagcbor::error;

pub use self::bytes::*;
pub use self::checked_serde_bytes::serde_byte_array;
pub use self::hash::*;

Expand All @@ -23,6 +21,8 @@ pub mod repr {
pub use serde_repr::{Deserialize_repr, Serialize_repr};
}

pub use fvm_shared::encoding::{bytes_32, Byte32De, BytesDe, BytesSer};

/// lotus use cbor-gen for generating codec for types, it has a length limit of generic array
/// for `8192`
///
Expand Down
2 changes: 1 addition & 1 deletion types/src/genesis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use super::SectorSize;
use address::{json as addr_json, Address};
use fvm_shared::sector::SectorSize;
use num_bigint::bigint_ser::json as bigint_json;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
Expand Down
3 changes: 1 addition & 2 deletions types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
pub mod build_version;
pub mod deadlines;
mod piece;
mod randomness;
pub mod sector;
mod state;

Expand All @@ -15,10 +14,10 @@ pub mod genesis;
pub mod verifier;

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

pub use fvm_shared::randomness::{Randomness, RANDOMNESS_LENGTH};
pub use fvm_shared::version::NetworkVersion;

use address::Address;
Expand Down
30 changes: 0 additions & 30 deletions types/src/randomness.rs

This file was deleted.

57 changes: 7 additions & 50 deletions types/src/sector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,12 @@
// SPDX-License-Identifier: Apache-2.0, MIT

pub mod post;
mod registered_proof;
mod seal;

pub use self::post::*;
pub use self::registered_proof::*;
pub use self::seal::*;

use crate::ActorID;
use encoding::{repr::*, tuple::*};
use num_bigint::BigInt;
use num_derive::FromPrimitive;
use std::fmt;

/// 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, Copy, FromPrimitive, Serialize_repr, Deserialize_repr)]
#[repr(u64)]
pub enum SectorSize {
_2KiB = 2 << 10,
_8MiB = 8 << 20,
_512MiB = 512 << 20,
_32GiB = 32 << 30,
_64GiB = 2 * (32 << 30),
}

impl fmt::Display for SectorSize {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self)
}
}

/// Sector ID which contains the sector number and the actor ID for the miner.
#[derive(Clone, Debug, Default, PartialEq, Serialize_tuple, Deserialize_tuple)]
pub struct SectorID {
pub miner: ActorID,
pub number: SectorNumber,
}
pub use fvm_shared::sector::{
AggregateSealVerifyInfo, AggregateSealVerifyProofAndInfos, InteractiveSealRandomness,
OnChainWindowPoStVerifyInfo, PoStProof, PoStRandomness, RegisteredAggregateProof,
RegisteredPoStProof, RegisteredSealProof, SealRandomness, SealVerifyInfo, SealVerifyParams,
SectorID, SectorInfo, SectorNumber, SectorQuality, SectorSize, Spacetime, StoragePower,
WindowPoStVerifyInfo, WinningPoStVerifyInfo, MAX_SECTOR_NUMBER,
};
48 changes: 3 additions & 45 deletions types/src/sector/post.rs
Original file line number Diff line number Diff line change
@@ -1,56 +1,14 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use crate::{ActorID, Randomness, RegisteredPoStProof, RegisteredSealProof, SectorNumber};
use crate::{
PoStProof, Randomness, RegisteredPoStProof, RegisteredSealProof, SectorInfo, SectorNumber,
};
use cid::Cid;
use encoding::{serde_byte_array, tuple::*};

/// Randomness type used for generating PoSt proof randomness.
pub type PoStRandomness = Randomness;

/// Information about a sector necessary for PoSt verification
#[derive(Debug, PartialEq, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct SectorInfo {
/// Used when sealing - needs to be mapped to PoSt registered proof when used to verify a PoSt
pub proof: RegisteredSealProof,
pub sector_number: SectorNumber,
pub sealed_cid: Cid,
}

/// Proof of spacetime data stored on chain.
#[derive(Debug, PartialEq, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct PoStProof {
pub post_proof: RegisteredPoStProof,
#[serde(with = "serde_byte_array")]
pub proof_bytes: Vec<u8>,
}

/// Information needed to verify a Winning PoSt attached to a block header.
/// Note: this is not used within the state machine, but by the consensus/election mechanisms.
#[derive(Debug, PartialEq, Default, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct WinningPoStVerifyInfo {
pub randomness: PoStRandomness,
pub proofs: Vec<PoStProof>,
pub challenge_sectors: Vec<SectorInfo>,
/// Used to derive 32-byte prover ID
pub prover: ActorID,
}

/// Information needed to verify a Window PoSt submitted directly to a miner actor.
#[derive(Debug, PartialEq, Default, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct WindowPoStVerifyInfo {
pub randomness: PoStRandomness,
pub proofs: Vec<PoStProof>,
pub challenged_sectors: Vec<SectorInfo>,
pub prover: ActorID,
}

/// Information submitted by a miner to provide a Window PoSt.
#[derive(Debug, PartialEq, Default, Clone, Eq, Serialize_tuple, Deserialize_tuple)]
pub struct OnChainWindowPoStVerifyInfo {
pub proofs: Vec<PoStProof>,
}

#[cfg(feature = "json")]
pub mod json {
use super::*;
Expand Down
Loading