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

Stake Table Catchup in Hotshot #2623

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open

Stake Table Catchup in Hotshot #2623

wants to merge 45 commits into from

Conversation

bfish713
Copy link
Contributor

Closes #<ISSUE_NUMBER>

This PR:

Recreates: EspressoSystems/HotShot#4109

This PR does not:

Key places to review:

@bfish713 bfish713 changed the title Bring over changes Stake Table Catchup in Hotshot Feb 18, 2025
Copy link
Contributor

Unable to build without Cargo.lock file.

This means that after this change 3rd party projects may have
difficulties using crates in this repo as a dependency. If this
isn't easy to fix please open an issue so we can fix it later.

For the first failing build see: https://github.com/EspressoSystems/espresso-sequencer/actions/runs/13426683855

To reproduce locally run

cargo generate-lockfile
cargo check --all-targets

This PR can still be merged.

@bfish713 bfish713 marked this pull request as ready for review February 20, 2025 15:16
Copy link
Contributor

@ss-es ss-es left a comment

Choose a reason for hiding this comment

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

just leaving some initial comments about the swap in the Membership object internally in hotshot. I think overall it makes sense, but I'm really concerned about some of the uses of next_epoch and prev_epoch and would feel much better if we explicitly passed the full EpochMembershipCoordinator to query for a specific epoch in those places (though in some other places, like where we e.g. check to see if we're the leader for the next epoch I think next_epoch makes complete sense)

I haven't yet looked into the actual catchup logic, I'll try to do that tomorrow

let we_are_leader = task_state
.membership
.read()
let mem = task_state
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it might be nice if we had a pattern of calling this epoch_membership or something to emphasize that it's the object for one specific epoch

Comment on lines 129 to 133
let prev_epoch = qc.data.epoch;
let mem = if prev_epoch < self.membership.epoch() {
&self.membership.prev_epoch().await.ok()?
} else {
&self.membership
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems suspicious, is there not a better way to deal with this? e.g. I feel like we might rather just pass in the EpochMembershipCoordinator so we can specifically get the EpochMembership for prev_epoch

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really know what a realistic attack might be but you can imagine e.g. someone puts in a fake epoch into qc.data.epoch but tricks you into only validating against prev_epoch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah agree with this point, I had some debugging issues with other places with this pattern as well. I think we should maybe just eplicitly checking that the epoch is for the next or prev epoch rather than < or > the one in the membership would work?

Copy link
Contributor

@ss-es ss-es left a comment

Choose a reason for hiding this comment

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

some more comments on the actual catchup logic

@bfish713 bfish713 requested a review from ss-es March 4, 2025 03:36
Copy link
Contributor

@ss-es ss-es left a comment

Choose a reason for hiding this comment

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

I think this looks fine to me overall, though I admittedly didn't check the details of every membership replacement

I still have some concerns about a few things, but they could be addressed separately. maybe they're not a big deal either

@bfish713 bfish713 enabled auto-merge (squash) March 5, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants