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

Implement should_override_forkchoice_update #11981

Merged
merged 13 commits into from
Feb 18, 2023
Merged

Implement should_override_forkchoice_update #11981

merged 13 commits into from
Feb 18, 2023

Conversation

potuz
Copy link
Contributor

@potuz potuz commented Feb 10, 2023

Part of implementing honest validators orphaning late blocks.

@potuz potuz added Ready For Review A pull request ready for code review Priority: High High priority item Forkchoice labels Feb 10, 2023
@potuz potuz requested a review from a team as a code owner February 10, 2023 17:02
Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me. This is blocked by #11964. A little hard to review until that is merged

Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

Can we add a feature flag. I'm with it either inverted or default

@potuz
Copy link
Contributor Author

potuz commented Feb 17, 2023

Can we add a feature flag. I'm with it either inverted or default

How? this doesn't have any runtime changes a feature flag to gate what?

Comment on lines +15 to +21
// orphanLateBlockFirstThreshold is the number of seconds after which we
// consider a block to be late, and thus a candidate to being reorged.
const orphanLateBlockFirstThreshold = 4

// processAttestationsThreshold is the number of seconds after which we
// process attestations for the current slot
const processAttestationsThreshold = 10
Copy link
Member

Choose a reason for hiding this comment

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

any thoughts on putting these as flags with default to 4 / 10 or we simply do not want ppl to change these

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 rather users not mess with these since that can cause more trouble than what we are trying to fix.

@@ -104,14 +104,12 @@ func (s *Store) pullTips(state state.BeaconState, node *Node, jc, fc *ethpb.Chec
return jc, fc
}

ab, uj, uf, err := precompute.UnrealizedCheckpoints(state)
_, uj, uf, err := precompute.UnrealizedCheckpoints(state)
Copy link
Member

Choose a reason for hiding this comment

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

Let's just remove activeBalance from UnrealizedCheckpoints. It's cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice one!

// the engine's view of head with the parent block or the incoming block. It
// does not guarantee an attempted reorg. This will only be decided later at
// proposal time by calling GetProposerHead.
func (f *ForkChoice) ShouldOverrideFCU() (override bool) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we are missing this:

    # Only re-org if we are proposing on-time.
    time_into_slot = (store.time - store.genesis_time) % SECONDS_PER_SLOT
    proposing_on_time = time_into_slot <= SECONDS_PER_SLOT // INTERVALS_PER_SLOT // 2

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, that can't really happen, we will only call this function after receiving a block and we are proposing during the next slot. The spec implementation allows you to reorg a late block that was supposed to be ready during N and that arrives during N+1. We will always reorg such blocks anyway.

"github.com/prysmaticlabs/prysm/v3/testing/require"
)

func TestForkChoice_ShouldOverrideFCU(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

We are missing an important test case where head arrives early

Copy link
Member

Choose a reason for hiding this comment

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

	if early {
		return
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice!

Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

Lgtm. Crosschecked against spec coverages and unit test coverages. This is not used in run time yet

@potuz potuz merged commit 166f711 into develop Feb 18, 2023
@delete-merged-branch delete-merged-branch bot deleted the proposer-head-v2 branch February 18, 2023 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Forkchoice Priority: High High priority item Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants