-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
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.
Looks reasonable to me. This is blocked by #11964. A little hard to review until that is merged
7cc1144
to
5762405
Compare
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.
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? |
// 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 |
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.
any thoughts on putting these as flags with default to 4 / 10 or we simply do not want ppl to change these
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 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) |
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.
Let's just remove activeBalance
from UnrealizedCheckpoints
. It's cleaner
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.
nice one!
beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks.go
Outdated
Show resolved
Hide resolved
beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks.go
Outdated
Show resolved
Hide resolved
beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks.go
Outdated
Show resolved
Hide resolved
// 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) { |
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 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
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, 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) { |
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.
We are missing an important test case where head arrives early
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.
if early {
return
}
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.
nice!
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. Crosschecked against spec coverages and unit test coverages. This is not used in run time yet
Part of implementing honest validators orphaning late blocks.