-
Notifications
You must be signed in to change notification settings - Fork 144
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
State API - RPC methods #532
Conversation
You mention this PR closes #476 but I don't see it getting hooked up to JSONRPC as done here https://github.com/ChainSafe/forest/blob/main/node/rpc/src/lib.rs#L30 |
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.
Partial review, I'll continue later
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.
Not finished yet, but leaving some comments for now. This PR is actually really hard to review hahaha thank god you broke down the other state mgr stuff haha
blockchain/state_manager/src/lib.rs
Outdated
} | ||
|
||
while back_search_wait.next().await.is_some() { | ||
if !reverts.get(back_tipset.key()).unwrap_or(&false) |
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 gets called for all ()
put through this pubsub channel, but this back_tipset
never changes, would this not just loop over and call the same code on the tipset when the back_tipset
was initiated?
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.
I thought since it is in a loop structure the same thing would be happening at the lotus side? If multiple backsearchWait events are being called the same code will potentially be called as well?
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.
Well, they are just calling that function asyncronously and only handling it once (and not recurring, they kinda use that channel as a oneshot. Seems like if you have this subscriber you could potentially be receiving events from another function call, unrelated to the logic of this.
I don't see why these events would need to be published in a pubsub way, seems pretty local (maybe clarification around why this needs to be emitted like this would be great, as I'm confused)
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.
Definitely! Wanted to use a oneshot but it looks like subheadchanges is the one that is sending these events externally? That is where the tsub starts to match in the case? I was also confused as to why they need to be externally called but following lotus seems like that might be the way they want it? I could also be very confused it is not as easy to parse haha
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.
Yes, I see they are using that and that is matched above, but this back search is completely distinct and you are using the same subscriber channel, this will just keep iterating over and never close, so this function will never end. Am I missing something here?
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 is my lack of go showing, I just recently knew that go func() is supposed to be an anoymous routine. Taking a look at this and fixing this right now, was trying to visualize as to what point the back_search_wait gets sent to and this makes more sense now
vm/message/src/lib.rs
Outdated
//turns message into cid | ||
fn to_cid(&self) -> Result<Cid, String>; |
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.
bumping this comment in case it was missed
blockchain/state_manager/src/lib.rs
Outdated
} | ||
|
||
while back_search_wait.next().await.is_some() { | ||
if !reverts.get(back_tipset.key()).unwrap_or(&false) |
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.
Yes, I see they are using that and that is matched above, but this back search is completely distinct and you are using the same subscriber channel, this will just keep iterating over and never close, so this function will never end. Am I missing something here?
Co-authored-by: Austin Abell <austinabell8@gmail.com>
Co-authored-by: Austin Abell <austinabell8@gmail.com>
Co-authored-by: Austin Abell <austinabell8@gmail.com>
Co-authored-by: Austin Abell <austinabell8@gmail.com>
…ainSafe/forest into ashanti/state_api_rpc_methods
blockchain/state_manager/src/lib.rs
Outdated
async { | ||
back_search_recieved = | ||
Some(receiver.await.map_err(|e| { | ||
Error::Other(format!("Could not receieve from channel {:?}", e)) | ||
})?); | ||
Ok::<(), Error>(()) | ||
} | ||
.await?; | ||
|
||
while let Some(subscriber) = self | ||
.subscriber | ||
.clone() | ||
.ok_or_else(|| { | ||
Error::Other("State Manager not subscribed to tipset head changes".to_string()) | ||
})? | ||
.next() | ||
.await | ||
{ |
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 should be polled at the same time as the subscriber (both the receiver channel and pubsub receiver are futures) as right now you are waiting for the function to complete, then awaiting on the subscriber events. These changes don't change anything I don't think (unless I'm reading wrong)
pub fn get_power<DB>( | ||
state_manager: &StateManager<DB>, | ||
tipset: &Tipset, | ||
address: Option<&Address>, | ||
) -> Result<(Option<Claim>, Claim), Error> | ||
where | ||
DB: BlockStore, | ||
{ | ||
get_power_raw(state_manager, tipset.parent_state(), address) | ||
} |
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.
I'm confused about why this is different from the one attached to the state manager?
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.
Yeah this was a mistake, shouldn't even be here.
Ok(miner_actor_state.info) | ||
} | ||
|
||
pub fn get_miner_deadlines<DB>( |
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.
where is this function coming from? I'm having a hard time mapping some of these functions in this file
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.
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.
only the two small things and should be good
@@ -284,7 +284,7 @@ dependencies = [ | |||
"ipld_blockstore", | |||
"ipld_hamt", | |||
"lazy_static", | |||
"libp2p", | |||
"libp2p 0.21.1", |
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.
What was the reason for bumping versions? was there something that broke? (wondering if there is something to fix) I tried without the updates and things seemed fine
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.
Not so sure, I just did a cargo update and found this
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.
ah yeah, that's what I meant to ask, just wasn't sure why the cargo update was necessary
let unsigned_box = unsigned.into_iter().map(|s| Box::new(s) as BoxMessage); | ||
let signed_box = signed.into_iter().map(|s| Box::new(s) as BoxMessage); | ||
|
||
let mut messages = Vec::new(); |
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.
bump using capacity to avoid reallocations
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.
LGTM given it will be moved to be attached to RPC API in following PR
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes #476
Closes #487
Closes #489
Other information and links