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 existing authority follower system (including local execution) for full node. #2106

Merged
merged 7 commits into from
May 21, 2022

Conversation

mystenmark
Copy link
Contributor

@mystenmark mystenmark commented May 20, 2022

Fixes: #1998

@mystenmark
Copy link
Contributor Author

Fixes #1998

Copy link
Contributor

@bmwill bmwill left a comment

Choose a reason for hiding this comment

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

Awesome!

Comment on lines +73 to +74
tokio::select! {
_ = &mut timeout => panic!("wait_for_tx timed out"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using this paradigm would it be possible to use https://docs.rs/tokio/latest/tokio/time/fn.timeout.html instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

if not, don't worry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't quite understand how to use that in a select! block, maybe you can show me next week.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah course. My hope for using the timeout type itself is to eliminate the select block. Because it seems like you're only selecting between the stream and the timeout

@mystenmark mystenmark force-pushed the mlogan-local-execution branch from 5033c91 to 2c8cae2 Compare May 21, 2022 00:36
@mystenmark mystenmark merged commit d396fa3 into main May 21, 2022
@mystenmark mystenmark deleted the mlogan-local-execution branch May 21, 2022 00:58
Comment on lines +819 to +830
match self.database.get_latest_parent_entry(*object_id)? {
None => Ok(ObjectRead::NotExists(*object_id)),
Some((obj_ref, _)) => {
if obj_ref.2.is_alive() {
match self.database.get_object_version(object_id, obj_ref.1)? {
None => {
error!("Object with in parent_entry is missing from object store, datastore is inconsistent");
Err(SuiError::ObjectNotFound {
object_id: *object_id,
})
}
Some(object) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can call database.get_object to replace this part

Copy link
Contributor

Choose a reason for hiding this comment

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

handle_object_info_request has some redundant code. See if there is opportunity to merge code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you can call database.get_object to replace this part

Not easily - the object could have been deleted after the get_latest_parent_entry call, in which case a call to get_object() would return None.

I spent 20 or 30 minutes trying to factor these functions, and didn't get anywhere. They do a lot of the same things, but they are different enough that its hard to share any code without adding tons of bool parameters or other complication.

self.database.get_account_objects(account_addr)
}

pub fn get_total_transaction_number(&self) -> Result<u64, anyhow::Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

From line 848 to 914 are all directly operating on the database. If you move all these functions to the Store, then authority and gateway can share the API and remove redundant code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't super feasible to move them into the store, but I've moved them into a separate module to reduce the duplication.

@@ -862,14 +1010,30 @@ impl AuthorityState {
signed_effects: &SignedTransactionEffects,
) -> SuiResult {
let notifier_ticket = self.batch_notifier.ticket()?;
let seq = notifier_ticket.seq();

if let Some(indexes) = &self.indexes {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's safer to update indexes after calling database.update_state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -307,6 +307,14 @@ impl<
.collect())
}

pub fn get_object_version(
Copy link
Contributor

Choose a reason for hiding this comment

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

get_object_by_key is probably a better name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

self.get_transactions_in_range(start, end)
}

pub async fn get_transaction(
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, this one probably can be replaced with make_transaction_info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can, but it doesn't really reduce the amount of code because of all the Option handling you have to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[full node] Use Local Execution Over Downloading Objects
3 participants