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

Update Actors Interface and Fix Actors Consensus Issues #1041

Merged
merged 40 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e53c78a
update deadline_state
ec2 Feb 19, 2021
efba4ea
deadlines
ec2 Feb 22, 2021
6662c87
miner state update
ec2 Feb 23, 2021
f6c69ae
monies
ec2 Feb 23, 2021
13ebdaf
partition state
ec2 Feb 23, 2021
107d8ad
precommit sector
ec2 Feb 24, 2021
d929cc7
prove commit sector and confirm sector proofs valid
ec2 Feb 24, 2021
0010816
confirm sector proofs valid
ec2 Feb 24, 2021
88304f9
extend sector expiration
ec2 Feb 24, 2021
c98374e
extend sector expiration
ec2 Feb 24, 2021
a75adb0
terminate sector
ec2 Feb 24, 2021
f71d17e
everything done except new method
ec2 Feb 24, 2021
4f8e14e
fmt and compile
ec2 Feb 24, 2021
9c3b2db
setup dispute windows post params
ec2 Feb 24, 2021
8bc4e7b
dispute windowed post
ec2 Feb 25, 2021
06b858d
some warnings
ec2 Feb 25, 2021
a00ac6a
cleanup
ec2 Feb 25, 2021
1b849b4
fini
ec2 Feb 25, 2021
4be3afe
Merge branch 'main' into ec2/miner-actor-v3
ec2 Feb 25, 2021
e75a655
update actors v2
ec2 Feb 25, 2021
442a5aa
update to v3
ec2 Mar 1, 2021
f5a1a84
Merge branch 'main' into ec2/paych-actor-v3
ec2 Mar 3, 2021
00daafb
gettin ready for testing
ec2 Mar 3, 2021
c87385b
log
ec2 Mar 3, 2021
c32575d
log worker id and task
ec2 Mar 3, 2021
fab6281
update interface
ec2 Mar 4, 2021
cf0f086
fix more interface stuff
ec2 Mar 4, 2021
52ac1aa
compiles
ec2 Mar 4, 2021
349fb69
quick miner actor fix
ec2 Mar 4, 2021
48bb693
return right code in record_proven_sectors
ec2 Mar 4, 2021
501d7f8
match miner code id for v3 in interface when loading state
ec2 Mar 4, 2021
63c58e2
fix a few consensus issues
ec2 Mar 7, 2021
260d659
should sync same weight
ec2 Mar 8, 2021
60bb6ed
lint
ec2 Mar 8, 2021
79cb2df
Merge branch 'main' into ec2/v3-upgrade-mainnet
ec2 Mar 8, 2021
ed0e829
lint
ec2 Mar 8, 2021
f0ffc74
Cargo Audit Patch
ec2 Mar 8, 2021
ca6c2f3
fil-ocl 0.19.6
ec2 Mar 8, 2021
69adf87
Merge branch 'ec2/cargo-audit-fixes' into ec2/v3-upgrade-mainnet
ec2 Mar 8, 2021
ab644a3
Merge branch 'main' into ec2/v3-upgrade-mainnet
ec2 Mar 8, 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
59 changes: 43 additions & 16 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion blockchain/chain/src/store/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ where
let curr_weight = heaviest?;
if new_weight > curr_weight {
// TODO potentially need to deal with re-orgs here
info!("New heaviest tipset");
info!("New heaviest tipset: {:?}", ts.key());
self.set_heaviest_tipset(ts).await?;
}
}
Expand Down
10 changes: 5 additions & 5 deletions blockchain/chain_sync/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ where

/// Spawns a network handler and begins the syncing process.
pub async fn start(mut self, worker_tx: Sender<Arc<Tipset>>, worker_rx: Receiver<Arc<Tipset>>) {
for _ in 0..self.sync_config.worker_tasks {
self.spawn_worker(worker_rx.clone()).await;
for i in 0..self.sync_config.worker_tasks {
self.spawn_worker(worker_rx.clone(), i).await;
}

// Channels to handle fetching hello tipsets in separate task and return tipset.
Expand Down Expand Up @@ -410,7 +410,7 @@ where
}

/// Spawns a new sync worker and pushes the state to the `ChainSyncer`
async fn spawn_worker(&mut self, channel: Receiver<Arc<Tipset>>) -> JoinHandle<()> {
async fn spawn_worker(&mut self, channel: Receiver<Arc<Tipset>>, id: usize) -> JoinHandle<()> {
let state = Arc::new(RwLock::new(SyncState::default()));

// push state to managed states in Syncer.
Expand All @@ -425,7 +425,7 @@ where
verifier: PhantomData::<V>::default(),
req_window: self.sync_config.req_window,
}
.spawn(channel, Arc::clone(&self.state))
.spawn(channel, Arc::clone(&self.state), id)
.await
}

Expand Down Expand Up @@ -459,7 +459,7 @@ where
.await
// TODO we should be able to queue a tipset with the same weight on a different chain.
// Currently needed to go GT because equal tipsets are attempted to be synced.
.map(|heaviest| ts.weight() > heaviest.weight())
.map(|heaviest| ts.weight() >= heaviest.weight())
.unwrap_or(true);
if candidate_ts {
// Check message meta after all other checks (expensive)
Expand Down
8 changes: 7 additions & 1 deletion blockchain/chain_sync/src/sync_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ where
self,
mut inbound_channel: Receiver<Arc<Tipset>>,
state: Arc<Mutex<ChainSyncState>>,
id: usize,
) -> JoinHandle<()> {
task::spawn(async move {
while let Some(ts) = inbound_channel.next().await {
info!("Worker #{} starting work on: {:?}", id, ts.key());
match self.sync(ts).await {
Ok(()) => *state.lock().await = ChainSyncState::Follow,
Err(e) => {
Expand Down Expand Up @@ -410,6 +412,7 @@ where
}

let epoch = fts.epoch();
let fts_key = fts.key().clone();

let mut validations = FuturesUnordered::new();
for b in fts.into_blocks() {
Expand All @@ -435,7 +438,10 @@ where
}
}
}
info!("Successfully validated tipset at epoch: {}", epoch);
info!(
"Successfully validated tipset {:?} at epoch: {}",
fts_key, epoch
);
Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions blockchain/state_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ where

let info = ms.info(self.blockstore()).map_err(|e| e.to_string())?;

let addr = resolve_to_key_addr(&state, self.blockstore(), &info.worker)
let addr = resolve_to_key_addr(&state, self.blockstore(), &info.worker())
.map_err(|e| Error::Other(format!("Failed to resolve key address; error: {}", e)))?;
Ok(addr)
}
Expand Down Expand Up @@ -680,7 +680,7 @@ where
let (st, _) = self.tipset_state::<V>(&lbts).await?;
let state = StateTree::new_from_root(self.blockstore(), &st)?;

let worker_key = resolve_to_key_addr(&state, self.blockstore(), &info.worker)?;
let worker_key = resolve_to_key_addr(&state, self.blockstore(), &info.worker())?;

let eligible = self.eligible_to_mine(&address, &tipset.as_ref(), &lbts)?;

Expand All @@ -689,7 +689,7 @@ where
network_power: Some(tpow.quality_adj_power),
sectors,
worker_key,
sector_size: info.sector_size,
sector_size: info.sector_size(),
prev_beacon_entry: prev,
beacon_entries: entries,
eligible_for_mining: eligible,
Expand Down
27 changes: 2 additions & 25 deletions blockchain/state_manager/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where

let info = mas.info(store)?;

let spt = RegisteredSealProof::from_sector_size(info.sector_size, nv);
let spt = RegisteredSealProof::from_sector_size(info.sector_size(), nv);

let wpt = spt.registered_winning_post_proof()?;

Expand Down Expand Up @@ -191,29 +191,6 @@ where
mas.info(self.blockstore())
}

/// Get all deadlines for a miner.
pub fn get_miner_deadlines<V>(
&self,
tipset: &Tipset,
address: &Address,
) -> Result<Vec<Deadline>, Error>
where
V: ProofVerifier,
{
let actor = self
.get_actor(address, tipset.parent_state())?
.ok_or_else(|| Error::State("Power actor address could not be resolved".to_string()))?;
let mas = miner::State::load(self.blockstore(), &actor)?;
let mut out = Vec::with_capacity(mas.num_deadlines() as usize);
mas.for_each_deadline(self.blockstore(), |_, dl| {
let post_submissions = dl.into_post_submissions();

out.push(Deadline { post_submissions });
Ok(())
})?;
Ok(out)
}

fn for_each_deadline_partition<V, F>(
&self,
tipset: &Tipset,
Expand Down Expand Up @@ -311,7 +288,7 @@ where
err
))
})?;
resolve_to_key_addr(&st, self.blockstore(), &info.worker).map_err(|e| {
resolve_to_key_addr(&st, self.blockstore(), &info.worker()).map_err(|e| {
Error::State(format!(
"(get miner worker raw) failed to resolve key addr: {}",
e
Expand Down
18 changes: 10 additions & 8 deletions node/rpc/src/state_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use message::{
signed_message::{json::SignedMessageJson, SignedMessage},
unsigned_message::{json::UnsignedMessageJson, UnsignedMessage},
};
use networks::get_network_version_default;
use num_bigint::{bigint_ser, BigInt};
use serde::{Deserialize, Serialize};
use state_manager::{InvocResult, MarketBalance, MiningBaseInfo, StateManager};
Expand Down Expand Up @@ -123,6 +122,7 @@ pub(crate) async fn state_call<
#[serde(rename_all = "PascalCase")]
pub(crate) struct Deadline {
post_submissions: BitFieldJson,
disputable_proof_count: usize,
}

/// returns all the proving deadlines for the given miner
Expand All @@ -145,9 +145,9 @@ pub(crate) async fn state_miner_deadlines<

let mut out = Vec::with_capacity(mas.num_deadlines() as usize);
mas.for_each_deadline(data.state_manager.blockstore(), |_, dl| {
let ps = dl.into_post_submissions();
out.push(Deadline {
post_submissions: BitFieldJson(ps),
post_submissions: dl.partitions_posted().clone().into(),
disputable_proof_count: dl.disputable_proof_count(data.state_manager.blockstore())?,
});
Ok(())
})?;
Expand Down Expand Up @@ -199,14 +199,10 @@ pub async fn state_miner_info<

let miner_state = miner::State::load(store, &actor)?;

let mut miner_info = miner_state
let miner_info = miner_state
.info(store)
.map_err(|e| format!("Could not get info {:?}", e))?;

// TODO revisit better way of handling (Lotus does here as well)
if get_network_version_default(ts.epoch()) >= NetworkVersion::V7 {
miner_info.seal_proof_type.update_to_v1();
}
Ok(miner_info)
}

Expand Down Expand Up @@ -805,6 +801,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::V3(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/interopnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub const UPGRADE_ORANGE_HEIGHT: ChainEpoch = 180;
pub const UPGRADE_CLAUS_HEIGHT: ChainEpoch = 210;
/// V10 network upgrade height TBD
pub const UPGRADE_ACTORS_V3_HEIGHT: ChainEpoch = 999999999;
pub const UPGRADE_PLACEHOLDER_HEIGHT: ChainEpoch = 9999999;

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

Expand Down
8 changes: 5 additions & 3 deletions types/networks/src/mainnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ pub const UPGRADE_PERSIAN_HEIGHT: ChainEpoch = 272400;
pub const UPGRADE_ORANGE_HEIGHT: ChainEpoch = 336458;
/// Remove burn on window PoSt fork
pub const UPGRADE_CLAUS_HEIGHT: ChainEpoch = 343200;
/// V10 network upgrade height TBD
pub const UPGRADE_ACTORS_V3_HEIGHT: ChainEpoch = 999999999;
/// V10 network upgrade height
pub const UPGRADE_ACTORS_V3_HEIGHT: ChainEpoch = 550321;

pub const UPGRADE_PLACEHOLDER_HEIGHT: ChainEpoch = 9999999;

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

/// Bootstrap peer ids
pub const DEFAULT_BOOTSTRAP: &[&str] = &[
Expand Down
10 changes: 7 additions & 3 deletions vm/actor/src/builtin/miner/deadline_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,12 @@ impl Deadline {
// First check to see if we're proving any already proven partitions.
// This is faster than checking one by one.
let already_proven = &self.partitions_posted & &partition_indexes;
if already_proven.is_empty() {
return Err(format!("parition already proven: {:?}", already_proven).into());
if !already_proven.is_empty() {
return Err(Box::new(actor_error!(
ErrIllegalArgument,
"parition already proven: {:?}",
already_proven
)));
}

let mut partitions = self.partitions_amt(store)?;
Expand Down Expand Up @@ -1275,7 +1279,7 @@ impl Deadline {
let post = proof_arr
.delete(idx as usize)
.map_err(|e| e.downcast_wrap(format!("failed to retrieve proof {}", idx)))?
.ok_or_else(|| Box::new(actor_error!(ErrIllegalArgument, "proof {} not found", idx)))?;
.ok_or_else(|| actor_error!(ErrIllegalArgument, "proof {} not found", idx))?;

let root = proof_arr
.flush()
Expand Down
Loading