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

Rest of V5 Updates #1217

Merged
merged 60 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
93b7619
base_fee method on runtime
ec2 Jun 17, 2021
c109f75
add beacon looking back to Rand
ec2 Jun 17, 2021
834e0bd
fmt
ec2 Jun 17, 2021
db80529
bump proofs to v8
ec2 Jun 17, 2021
0f1dc97
add verify_aggregate_seals
ec2 Jun 18, 2021
84bd0ce
fmt
ec2 Jun 18, 2021
e5579ee
fix tests
ec2 Jun 21, 2021
4c0a691
fix conformance tests
ec2 Jun 21, 2021
bac8319
fix mock rt
ec2 Jun 22, 2021
bbbd1d7
fmt
ec2 Jun 22, 2021
56920f8
fix conf tests again
ec2 Jun 22, 2021
098c2fa
fix some suggestions
ec2 Jul 5, 2021
83ffdd6
comment
ec2 Jul 5, 2021
abb20cf
remove return
ec2 Jul 5, 2021
5485508
Merge branch 'main' into ec2/v5-runtime
ec2 Jul 5, 2021
d2aac95
implement aggregate proving
ec2 Jul 5, 2021
0e0e990
fmt
ec2 Jul 5, 2021
f207270
fmt
ec2 Jul 5, 2021
b5272b6
lint
ec2 Jul 5, 2021
2f81d51
Merge branch 'main' into ec2/fip13
ec2 Jul 5, 2021
0bf2190
batch precommit
ec2 Jul 12, 2021
b9686ce
clippy
ec2 Jul 12, 2021
5087ad6
constant consensus fault reward
ec2 Jul 12, 2021
04a71d9
Merge branch 'main' into ec2/fip11
ec2 Jul 12, 2021
1f0d125
allow for verifreg topup
ec2 Jul 12, 2021
0d9863f
market cron randomness modify
ec2 Jul 12, 2021
793709c
Merge branch 'ec2/fip8' into ec2/v5
ec2 Jul 12, 2021
1da88b9
Merge branch 'ec2/fip11' into ec2/v5
ec2 Jul 12, 2021
e7862b8
Merge branch 'ec2/fip12' into ec2/v5
ec2 Jul 12, 2021
3a96427
Merge branch 'ec2/fip13' into ec2/v5
ec2 Jul 12, 2021
ade476d
Merge branch 'ec2/market-cron-randomness' into ec2/v5
ec2 Jul 12, 2021
c7408f4
miner interface, state tree version bump, expose v5
ec2 Jul 12, 2021
90ff1f6
remove placeholder epochs, add hyperdrive epoch
ec2 Jul 12, 2021
057061e
update code id
ec2 Jul 12, 2021
d8b944f
update interface for all the other actors
ec2 Jul 12, 2021
238c29d
fix aggregate commit
ec2 Jul 12, 2021
5598001
convert sector id
ec2 Jul 12, 2021
0c45a30
some fixes
ec2 Jul 13, 2021
dbc0480
fix the fixs
ec2 Jul 13, 2021
995f038
fix pre_commit_due
ec2 Jul 13, 2021
4c83836
collision policy
ec2 Jul 13, 2021
8a37622
change the sort
ec2 Jul 13, 2021
8365947
cargo lock proofs update
ec2 Jul 13, 2021
fffe716
UNDO THIS COMMIT LATER: Print Deadline State
ec2 Jul 13, 2021
5f01f9f
UNDO THIS COMMIT AS WELL
ec2 Jul 13, 2021
e2be521
remove redundant info read
ec2 Jul 16, 2021
5889c81
Fix warnings. (#1198)
cryptoquick Jul 23, 2021
8b657af
check for max length on encoded bitfields
ec2 Aug 10, 2021
27ebdd6
Merge branch 'main' into ec2/v5
ec2 Aug 11, 2021
0122366
Merge branch 'main' into ec2/v5
ec2 Aug 24, 2021
a26db9e
fmt
ec2 Aug 24, 2021
c7aa238
some cleanup
ec2 Aug 24, 2021
93ba7a5
catch_unwind
Aug 31, 2021
f67e521
Linter fix.
cryptoquick Sep 1, 2021
f6bece1
Add some missing docs to the rest of v5 updates (#1224)
cryptoquick Sep 1, 2021
ecd135f
fix policies
ec2 Sep 23, 2021
4167718
Merge branch 'ec2/proofpanic' into ec2/v5
ec2 Sep 23, 2021
4d96774
clean runtime
ec2 Sep 23, 2021
30fb135
bigint version bump
ec2 Sep 23, 2021
87137d5
Merge branch 'main' into ec2/v5
ec2 Sep 23, 2021
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
4 changes: 2 additions & 2 deletions node/rpc/src/chain_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ where
DomainSeparationTag::from_i64(pers).ok_or("invalid DomainSeparationTag")?,
epoch,
&base64::decode(entropy)?,
epoch <= networks::UPGRADE_PLACEHOLDER_HEIGHT,
epoch <= networks::UPGRADE_HYPERDRIVE_HEIGHT,
)
.await?)
}
Expand All @@ -301,7 +301,7 @@ where
DomainSeparationTag::from_i64(pers).ok_or("invalid DomainSeparationTag")?,
epoch,
&base64::decode(entropy)?,
epoch <= networks::UPGRADE_PLACEHOLDER_HEIGHT,
epoch <= networks::UPGRADE_HYPERDRIVE_HEIGHT,
)
.await?)
}
6 changes: 6 additions & 0 deletions node/rpc/src/state_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,12 @@ pub(crate) async fn state_miner_sector_allocated<
.get::<bitfield::BitField>(&m.allocated_sectors)?
.ok_or("allocated sectors bitfield not found")?
.get(sector_num as usize),
miner::State::V5(m) => data
.chain_store
.db
.get::<bitfield::BitField>(&m.allocated_sectors)?
.ok_or("allocated sectors bitfield not found")?
.get(sector_num as usize),
};

Ok(allocated_sectors)
Expand Down
2 changes: 2 additions & 0 deletions types/networks/src/devnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub const UPGRADE_ACTORS_V3_HEIGHT: ChainEpoch = 550321;
pub const UPGRADE_NORWEGIAN_HEIGHT: ChainEpoch = 665280;
/// V12 network upgrade TODO
pub const UPGRADE_ACTORS_V4_HEIGHT: ChainEpoch = 999999;
/// V13 network upgrade TODO
pub const UPGRADE_HYPERDRIVE_HEIGHT: ChainEpoch = 1000000;

pub const UPGRADE_PLACEHOLDER_HEIGHT: ChainEpoch = 9999999;

Expand Down
2 changes: 2 additions & 0 deletions types/networks/src/interopnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pub const UPGRADE_ACTORS_V3_HEIGHT: ChainEpoch = 999999998;
pub const UPGRADE_NORWEGIAN_HEIGHT: ChainEpoch = 999999999;
/// V12 network upgrade TODO
pub const UPGRADE_ACTORS_V4_HEIGHT: ChainEpoch = 999999999;
/// V13 network upgrade TODO
pub const UPGRADE_HYPERDRIVE_HEIGHT: ChainEpoch = 999999999;

pub const UPGRADE_PLACEHOLDER_HEIGHT: ChainEpoch = 9999999;

Expand Down
6 changes: 5 additions & 1 deletion types/networks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct DrandPoint<'a> {
pub config: &'a DrandConfig<'a>,
}

const VERSION_SCHEDULE: [Upgrade; 12] = [
const VERSION_SCHEDULE: [Upgrade; 13] = [
Upgrade {
height: UPGRADE_BREEZE_HEIGHT,
network: NetworkVersion::V1,
Expand Down Expand Up @@ -103,6 +103,10 @@ const VERSION_SCHEDULE: [Upgrade; 12] = [
height: UPGRADE_ACTORS_V4_HEIGHT,
network: NetworkVersion::V12,
},
Upgrade {
height: UPGRADE_HYPERDRIVE_HEIGHT,
network: NetworkVersion::V13,
},
];

/// Gets network version from epoch using default Mainnet schedule.
Expand Down
2 changes: 2 additions & 0 deletions types/networks/src/mainnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ pub const UPGRADE_ACTORS_V3_HEIGHT: ChainEpoch = 550321;
pub const UPGRADE_NORWEGIAN_HEIGHT: ChainEpoch = 665280;
/// V12 network upgrade
pub const UPGRADE_ACTORS_V4_HEIGHT: ChainEpoch = 712320;
/// V13 network upgrade
pub const UPGRADE_HYPERDRIVE_HEIGHT: ChainEpoch = 892800;

pub const UPGRADE_PLACEHOLDER_HEIGHT: ChainEpoch = 9999999;

Expand Down
4 changes: 3 additions & 1 deletion types/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ pub enum StateTreeVersion {
V1,
/// Corresponds to actors = v3
V2,
/// Corresponds to actors >= v4
/// Corresponds to actors = v4
V3,
/// Corresponds to actors >= v5
V4,
}

/// State root information. Contains information about the version of the state tree,
Expand Down
7 changes: 3 additions & 4 deletions types/src/verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ pub trait ProofVerifier {
}
let spt: proofs::RegisteredSealProof = aggregate.seal_proof.try_into()?;
let prover_id = prover_id_from_u64(aggregate.miner);

struct AggregationInputs {
// replica
commr: [u8; 32],
// data
commd: [u8; 32],
sector_id: u64,
sector_id: SectorId,
ticket: [u8; 32],
seed: [u8; 32],
}
Expand All @@ -80,7 +79,7 @@ pub trait ProofVerifier {
Ok(AggregationInputs {
commr,
commd,
sector_id: info.sector_number,
sector_id: SectorId::from(info.sector_number),
ticket: info.randomness.0,
seed: info.interactive_randomness.0,
})
Expand All @@ -95,7 +94,7 @@ pub trait ProofVerifier {
input.commr,
input.commd,
prover_id,
input.sector_id.try_into()?,
input.sector_id,
input.ticket,
input.seed,
)
Expand Down
12 changes: 12 additions & 0 deletions utils/bitfield/src/rleplus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,24 @@ use super::{BitField, Result};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::borrow::Cow;

// MaxEncodedSize is the maximum encoded size of a bitfield. When expanded into
// a slice of runs, a bitfield of this size should not exceed 2MiB of memory.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olibearo I believe it says runs, which I think makes sense in this context

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(assuming RLE stands for Run-Length Encoding)

//
// This bitfield can fit at least 3072 sparse elements.
const MAX_ENCODED_SIZE: usize = 32 << 10;

impl Serialize for BitField {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
let bytes = self.to_bytes();
if bytes.len() > MAX_ENCODED_SIZE {
return Err(serde::ser::Error::custom(format!(
"encoded bitfield was too large {}",
bytes.len()
)));
}
serde_bytes::serialize(&bytes, serializer)
}
}
Expand Down
24 changes: 12 additions & 12 deletions vm/actor/src/builtin/codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
use cid::{multihash::MultihashDigest, Cid, Code::Identity, RAW};

lazy_static! {
pub static ref SYSTEM_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/system");
pub static ref INIT_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/init");
pub static ref CRON_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/cron");
pub static ref ACCOUNT_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/account");
pub static ref POWER_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/storagepower");
pub static ref MINER_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/storageminer");
pub static ref MARKET_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/storagemarket");
pub static ref PAYCH_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/paymentchannel");
pub static ref MULTISIG_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/multisig");
pub static ref REWARD_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/reward");
pub static ref VERIFREG_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/verifiedregistry");
pub static ref CHAOS_ACTOR_CODE_ID: Cid = make_builtin(b"fil/4/chaos");
pub static ref SYSTEM_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/system");
pub static ref INIT_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/init");
pub static ref CRON_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/cron");
pub static ref ACCOUNT_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/account");
pub static ref POWER_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/storagepower");
pub static ref MINER_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/storageminer");
pub static ref MARKET_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/storagemarket");
pub static ref PAYCH_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/paymentchannel");
pub static ref MULTISIG_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/multisig");
pub static ref REWARD_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/reward");
pub static ref VERIFREG_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/verifiedregistry");
pub static ref CHAOS_ACTOR_CODE_ID: Cid = make_builtin(b"fil/5/chaos");

/// Set of actor code types that can represent external signing parties.
pub static ref CALLER_TYPES_SIGNABLE: [Cid; 2] =
Expand Down
44 changes: 14 additions & 30 deletions vm/actor/src/builtin/market/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ use crate::{
};
use address::Address;
use ahash::AHashMap;
use byteorder::{BigEndian, ByteOrder};
use cid::Prefix;
use clock::{ChainEpoch, EPOCH_UNDEFINED};
use crypto::DomainSeparationTag;
use encoding::{to_vec, Cbor};
use fil_types::deadlines::QuantSpec;
use fil_types::{PieceInfo, StoragePower};
use ipld_blockstore::BlockStore;
use num_bigint::BigInt;
Expand Down Expand Up @@ -330,13 +329,7 @@ impl Actor {

// We should randomize the first epoch for when the deal will be processed so an attacker isn't able to
// schedule too many deals for the same tick.
let process_epoch = gen_rand_next_epoch(rt, rt.curr_epoch(), &deal.proposal)
.map_err(|e| {
e.downcast_default(
ExitCode::ErrIllegalState,
"failed to generate random process epoch",
)
})?;
let process_epoch = gen_rand_next_epoch(deal.proposal.start_epoch, id);

msm.deals_by_epoch
.as_mut()
Expand Down Expand Up @@ -1096,27 +1089,18 @@ where
))
}

fn gen_rand_next_epoch<BS, RT>(
rt: &RT,
curr_epoch: ChainEpoch,
deal: &DealProposal,
) -> Result<ChainEpoch, Box<dyn StdError>>
where
BS: BlockStore,
RT: Runtime<BS>,
{
let bytes = deal.marshal_cbor()?;

let rb = rt.get_randomness_from_beacon(
DomainSeparationTag::MarketDealCronSeed,
curr_epoch - 1,
&bytes,
)?;

// generate a random epoch in [baseEpoch, baseEpoch + DealUpdatesInterval)
let offset = BigEndian::read_u64(&rb.0);

Ok(deal.start_epoch + (offset % DEAL_UPDATES_INTERVAL as u64) as ChainEpoch)
fn gen_rand_next_epoch(start_epoch: ChainEpoch, deal_id: DealID) -> ChainEpoch {
let offset = deal_id as i64 % DEAL_UPDATES_INTERVAL;
let q = QuantSpec {
unit: DEAL_UPDATES_INTERVAL,
offset: 0,
};
let prev_day = q.quantize_down(start_epoch);
if prev_day + offset >= start_epoch {
return prev_day + offset;
}
let next_day = q.quantize_up(start_epoch);
next_day + offset
}
////////////////////////////////////////////////////////////////////////////////
// Checks
Expand Down
2 changes: 1 addition & 1 deletion vm/actor/src/builtin/miner/deadline_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Deadlines {
}

/// Deadline holds the state for all sectors due at a specific deadline.
#[derive(Serialize_tuple, Deserialize_tuple)]
#[derive(Debug, Serialize_tuple, Deserialize_tuple)]
pub struct Deadline {
/// Partitions in this deadline, in order.
/// The keys of this AMT are always sequential integers beginning with zero.
Expand Down
3 changes: 1 addition & 2 deletions vm/actor/src/builtin/miner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ impl Actor {
.map_err(|e| {
ActorError::new(
ErrBalanceInvariantBroken,
format!("balance invariants broken: {}", e),
format!("balance invariant broken: {}", e),
)
})?;
if needs_cron {
Expand Down Expand Up @@ -3996,7 +3996,6 @@ where
// Committed-capacity sectors licensed for early removal by new sectors being proven.
let mut replace_sectors = DeadlineSectorMap::new();
let activation = rt.curr_epoch();

// Pre-commits for new sectors.
let mut valid_pre_commits = Vec::<SectorPreCommitOnChainInfo>::new();

Expand Down
2 changes: 1 addition & 1 deletion vm/actor/src/builtin/miner/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub const ADDRESSED_PARTITIONS_MAX: u64 = MAX_PARTITIONS_PER_DEADLINE;
pub const DELCARATIONS_MAX: u64 = ADDRESSED_PARTITIONS_MAX;

/// The maximum number of sector infos that may be required to be loaded in a single invocation.
pub const ADDRESSED_SECTORS_MAX: u64 = 10_000;
pub const ADDRESSED_SECTORS_MAX: u64 = 25_000;

/// The maximum number of partitions that may be required to be loaded in a single invocation,
/// when all the sector infos for the partitions will be loaded.
Expand Down
2 changes: 1 addition & 1 deletion vm/actor/src/builtin/miner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct State {
#[serde(with = "bigint_ser")]
pub fee_debt: TokenAmount,

/// Sum of initial pledge requirements of all active sectors
/// Sum of initial pledge requirements of all active sectors.
#[serde(with = "bigint_ser")]
pub initial_pledge: TokenAmount,

Expand Down
37 changes: 15 additions & 22 deletions vm/actor/src/builtin/verifreg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,35 +277,28 @@ impl Actor {
)
})?;

// This is a one-time, upfront allocation.
// This allowance cannot be changed by calls to AddVerifiedClient as long as the
// client has not been removed. If parties need more allowance, they need to create a
// new verified client or use up the the current allowance and then create a new
// verified client.
let found = verified_clients
.contains_key(&client.to_bytes())
.map_err(|e| {
e.downcast_default(
ExitCode::ErrIllegalState,
format!("Failed to get verified client {}", client),
)
})?;
if found {
return Err(actor_error!(
ErrIllegalArgument,
"verified client already exists: {}",
client
));
}
let client_cap = verified_clients.get(&client.to_bytes()).map_err(|e| {
e.downcast_default(
ExitCode::ErrIllegalState,
format!("Failed to get verified client {}", client),
)
})?;
// if verified client exists, add allowance to existing cap
// otherwise, create new client with allownace
let client_cap = if let Some(BigIntDe(client_cap)) = client_cap {
client_cap + params.allowance
} else {
params.allowance
};

verified_clients
.set(client.to_bytes().into(), BigIntDe(params.allowance.clone()))
.set(client.to_bytes().into(), BigIntDe(client_cap.clone()))
.map_err(|e| {
e.downcast_default(
ExitCode::ErrIllegalState,
format!(
"Failed to add verified client {} with cap {}",
client, params.allowance,
client, client_cap,
),
)
})?;
Expand Down
Loading