-
Notifications
You must be signed in to change notification settings - Fork 1.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
[DO NOT MERGE]: Apply consensus and equivocation check before broadcast #12335
Conversation
beacon-chain/sync/service.go
Outdated
@@ -301,3 +302,7 @@ type Checker interface { | |||
Status() error | |||
Resync() error | |||
} | |||
|
|||
type EqChecker interface { |
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 would call it EquivocationChecker and add a thorough comment. Eq sounds like equals in other programming languages
} | ||
_, err = transition.ExecuteStateTransition(ctx, parentState, block) | ||
if err != nil { | ||
return errors.Wrap(err, "could not execute state transition") |
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.
Better change the Godoc for SubmitBlockSSZ
then.
@@ -1019,6 +1020,20 @@ func (bs *Server) submitBlock(ctx context.Context, blockRoot [fieldparams.RootLe | |||
}) | |||
}() | |||
|
|||
b := block.Block() | |||
parentState, err := bs.StateGenService.StateByRoot(ctx, b.ParentRoot()) |
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.
In our usual block processing pipeline we verify the block time disparity at this stage. Do we need to do it here?
func (s *Service) HasBlock(slot primitives.Slot, proposerIdx primitives.ValidatorIndex) bool { | ||
blks := s.pendingBlocksInCache(slot) | ||
for _, blk := range blks { | ||
if blk.Block().Slot() == slot && blk.Block().ProposerIndex() == proposerIdx { |
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.
are nil checks for blk.Block()
necessary?
case uint64(s.seenProposerIndexCache[0]) > uint64(slot): | ||
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.
This case literally can't happen.
} | ||
|
||
func (s *Service) SeenProposerIndex(slot primitives.Slot, proposerIdx primitives.ValidatorIndex) bool { | ||
if s.seenProposerIndexCache[0] != primitives.ValidatorIndex(slot) { |
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.
nilcheck for seenProposerIndexCache
if s.cfg.chain.CurrentSlot() != slot { | ||
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.
nilcheck for seenProposerIndexCache
s.seenProposerIndexCache = []primitives.ValidatorIndex{primitives.ValidatorIndex(slot)} | ||
s.seenProposerIndexCache = append(s.seenProposerIndexCache, proposerIdx) |
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.
s.seenProposerIndexCache = []primitives.ValidatorIndex{primitives.ValidatorIndex(slot)} | |
s.seenProposerIndexCache = append(s.seenProposerIndexCache, proposerIdx) | |
s.seenProposerIndexCache = []primitives.ValidatorIndex{primitives.ValidatorIndex(slot), proposerIdx} |
if block == nil || block.IsNil() { | ||
return errors.New("nil block") | ||
} |
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 you do this before the defer function?
I am setting up a testnet and I would insanely appreciate a Dockerfile in order to set this up in Docker. Would it be possible to get a hold of one? |
Is this PR still required when using the latest version of prysm used by the relays? |
hi @dewindtk check out https://github.com/OffchainLabs/eth-pos-devnet if you want to set up a testnet. If you want to test out a specific change, such as this PR, you will need to build images with Bazel here: https://docs.prylabs.network/docs/install/install-with-bazel#running-images. We do not use dockerfiles |
Before broadcast, this PR applies consensus and equivocation checks for the beacon API's propose block endpoint.
Consensus check:
Equivocation check:
develop