-
Notifications
You must be signed in to change notification settings - Fork 159
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
[Feature] StateMinerFaults RPC. #3726
Changes from 8 commits
cc65273
7343cb9
40b29ee
6a7c4ce
e291636
360a112
604e58d
50e643d
b8792bf
281bc3b
4e39776
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -20,6 +20,7 @@ use anyhow::Context as _; | |||||||||||
use cid::Cid; | ||||||||||||
use fil_actor_interface::market; | ||||||||||||
use fil_actor_interface::miner::MinerPower; | ||||||||||||
use fil_actors_shared::fvm_ipld_bitfield::BitField; | ||||||||||||
use futures::StreamExt; | ||||||||||||
use fvm_ipld_blockstore::Blockstore; | ||||||||||||
use fvm_ipld_encoding::{CborStore, DAG_CBOR}; | ||||||||||||
|
@@ -176,6 +177,22 @@ pub(in crate::rpc) async fn state_miner_power<DB: Blockstore + Send + Sync + 'st | |||||||||||
.map_err(|e| e.into()) | ||||||||||||
} | ||||||||||||
|
||||||||||||
/// looks up the miner power of the given address. | ||||||||||||
pub(in crate::rpc) async fn state_miner_faults<DB: Blockstore + Send + Sync + 'static>( | ||||||||||||
data: Data<RPCState<DB>>, | ||||||||||||
Params(LotusJson((address, key))): Params<LotusJson<(Address, TipsetKeys)>>, | ||||||||||||
) -> Result<LotusJson<BitField>, JsonRpcError> { | ||||||||||||
let ts = data | ||||||||||||
.state_manager | ||||||||||||
.chain_store() | ||||||||||||
.load_required_tipset(&key)?; | ||||||||||||
|
||||||||||||
data.state_manager | ||||||||||||
.miner_faults(&address, &ts) | ||||||||||||
.map_err(|e| e.into()) | ||||||||||||
.map(|r| r.into()) | ||||||||||||
Comment on lines
+190
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe make it more explicit what types we're converting into.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It lines up with the other endpoints, I see no reason to be explicit here, while being implicit in other methods. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we'll still need to do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, we don't, if we use the I'd say that it would be nice to go with the same approach for all the methods. I've just taken a look and we're pretty much 50/50. In my opinion the best course of action here is to let everybody go with their own flow and once we've finished the RPC compatibility routine - just do a small refactoring to make them look the same. |
||||||||||||
} | ||||||||||||
|
||||||||||||
/// returns the message receipt for the given message | ||||||||||||
pub(in crate::rpc) async fn state_get_receipt<DB: Blockstore + Send + Sync + 'static>( | ||||||||||||
data: Data<RPCState<DB>>, | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ use cid::Cid; | |
use fil_actor_interface::miner::MinerPower; | ||
use fil_actor_interface::*; | ||
use fil_actors_shared::fvm_ipld_amt::Amtv0 as Amt; | ||
use fil_actors_shared::fvm_ipld_bitfield::BitField; | ||
use fil_actors_shared::v10::runtime::Policy; | ||
use futures::{channel::oneshot, select, FutureExt}; | ||
use fvm_ipld_blockstore::Blockstore; | ||
|
@@ -979,6 +980,30 @@ where | |
Ok(out) | ||
} | ||
|
||
/// Retrieves miner faults. | ||
pub fn miner_faults( | ||
self: &Arc<Self>, | ||
addr: &Address, | ||
ts: &Arc<Tipset>, | ||
) -> Result<BitField, Error> { | ||
let actor = self | ||
.get_actor(addr, *ts.parent_state())? | ||
.ok_or_else(|| Error::State("Miner actor not found".to_string()))?; | ||
|
||
let state = miner::State::load(self.blockstore(), actor.code, actor.state)?; | ||
|
||
let mut faults = Vec::new(); | ||
|
||
state.for_each_deadline(&self.chain_config.policy, self.blockstore(), |_, part| { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer a more explicit name here, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not partition. It's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, you are referring to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I'm referring to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like |
||
part.for_each(self.blockstore(), |_, dl| { | ||
faults.push(dl.faulty_sectors().clone()); | ||
Ok(()) | ||
}) | ||
})?; | ||
|
||
Ok(BitField::union(faults.iter())) | ||
} | ||
|
||
/// Retrieves miner power. | ||
pub fn miner_power( | ||
self: &Arc<Self>, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will probably clash with #3739
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might, we'll have several PRs depeding on this version bump.