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 target state to compute committees #4235

Open
wants to merge 6 commits into
base: unstable
Choose a base branch
from

Conversation

paulhauner
Copy link
Member

@paulhauner paulhauner commented Apr 26, 2023

Issue Addressed

Related to #4234, but does not fully resolve it.

Proposed Changes

When we have a shuffling cache miss, sometimes compute the shuffling by loading the target state rather than the beacon block root state.

This is cheaper, because we don't need to apply blocks/skip slots to generate a mid-epoch state. It also avoids weirdness with the incomplete state advances.

Additional Info

NA

@paulhauner paulhauner added work-in-progress PR is a work-in-progress v4.2.0 Q2 2023 labels Apr 26, 2023
@paulhauner paulhauner changed the base branch from stable to unstable April 26, 2023 03:55
@paulhauner
Copy link
Member Author

After discussions with @michaelsproul we found this isn't going to work when shuffling_epoch + 1 > epoch(beacon_block_root) :(

@paulhauner
Copy link
Member Author

I've updated this PR to only sometimes use the target state, since we sometimes need the head block state.

Now this PR doesn't full resolve #4234, but it provides a useful optimization IMO.

@paulhauner paulhauner added v4.3.0 Estimated Q2 2023 and removed v4.2.0 Q2 2023 labels May 15, 2023
@paulhauner
Copy link
Member Author

I'm bumping this to v4.2.1 since it's not so important and v4.2.0 already has a decent amount of complexity.

@paulhauner paulhauner added v4.4.1 ETA August 2023 and removed v4.4.1 ETA August 2023 v4.3.0 Estimated Q2 2023 labels Jun 28, 2023
@paulhauner paulhauner added ready-for-review The code is ready for review and removed work-in-progress PR is a work-in-progress labels Jul 31, 2023
@paulhauner paulhauner marked this pull request as ready for review July 31, 2023 23:18
Comment on lines +5552 to +5561
// There's no reason we'd want to load the shuffling for a cold
// state; attestation duties will never be pre-finalized and
// attestations to finalized blocks are useless.
let split_slot = self.store.get_split_slot();
if split_slot > target_block.slot {
return Err(Error::RequestedColdShuffling {
split_slot,
request_slot: target_block.slot,
});
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned we have a race condition here that could make this error reachable, resulting in an ugly error! here. The race is:

  1. Verify attestation block isn't finalized (it's not, yet)
  2. Check fork choice, attestation block is present
  3. Finalization updates, and so does the split point
  4. The attestation slot is now prior to the split and triggers this error

Alternatively:

  1. Verify attestation block isn't finalized (it's not, yet)
  2. Check fork choice, attestation block is present
  3. Check attestation slot against split slot, still fine
  4. Finalization migration runs and advances the split
  5. Try to run get_state and fail, because the state has been pruned. Or (today) load a freezer state at great expense ( 😱 ).

This second race is related to #4610.

My preference would be to soak #4160 in Hydra and ensure it's solid before making any changes here. Then we can add this change in maybe with the following defensive changes:

@michaelsproul michaelsproul added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Aug 17, 2023
@paulhauner paulhauner removed the v4.4.1 ETA August 2023 label Aug 17, 2023
@paulhauner
Copy link
Member Author

Good points @michaelsproul. I've dropped the v4.3.1 tag since I don't think this change is urgent. I'll come back to it later, it might even be more trouble than it's worth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-author The reviewer has suggested changes and awaits thier implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Withdrawals root on "inconsistent" attestation verification states
2 participants