-
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
Add Gossip Handler For BLS To Execution Changes #11690
Merged
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f49e1c1
add it in
nisdas fa7c0b8
gaz
nisdas aeee96c
simplify fork watcher
nisdas dda6072
satisfy linter
nisdas 17a45c0
fix
nisdas 5223615
tests
nisdas 71220d0
gazelle
potuz 6958ed5
fix build
nisdas 3ae4b97
build
nisdas 764e1f5
make it all work
nisdas 9a0879b
add test
nisdas ffc12ce
fix weights
nisdas 88e13eb
fix
nisdas 02cb964
comments
nisdas 0f8af8e
Added test
potuz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package sync | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1" | ||
"google.golang.org/protobuf/proto" | ||
) | ||
|
||
func (s *Service) blsToExecutionChangeSubscriber(ctx context.Context, msg proto.Message) error { | ||
blsMsg, ok := msg.(*ethpb.SignedBLSToExecutionChange) | ||
if !ok { | ||
return errors.Errorf("incorrect type of message received, wanted %T but got %T", ðpb.SignedBLSToExecutionChange{}, msg) | ||
} | ||
s.cfg.blsToExecPool.InsertBLSToExecChange(blsMsg) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package sync | ||
|
||
import ( | ||
"context" | ||
|
||
pubsub "github.com/libp2p/go-libp2p-pubsub" | ||
"github.com/libp2p/go-libp2p/core/peer" | ||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/signing" | ||
"github.com/prysmaticlabs/prysm/v3/config/params" | ||
"github.com/prysmaticlabs/prysm/v3/monitoring/tracing" | ||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1" | ||
"github.com/prysmaticlabs/prysm/v3/time/slots" | ||
"go.opencensus.io/trace" | ||
) | ||
|
||
func (s *Service) validateBlsToExecutionChange(ctx context.Context, pid peer.ID, msg *pubsub.Message) (pubsub.ValidationResult, error) { | ||
// Validation runs on publish (not just subscriptions), so we should approve any message from | ||
// ourselves. | ||
if pid == s.cfg.p2p.PeerID() { | ||
return pubsub.ValidationAccept, nil | ||
} | ||
|
||
// The head state will be too far away to validate any execution change. | ||
if s.cfg.initialSync.Syncing() { | ||
return pubsub.ValidationIgnore, nil | ||
} | ||
|
||
ctx, span := trace.StartSpan(ctx, "sync.validateBlsToExecutionChange") | ||
defer span.End() | ||
|
||
m, err := s.decodePubsubMessage(msg) | ||
if err != nil { | ||
tracing.AnnotateError(span, err) | ||
return pubsub.ValidationReject, err | ||
} | ||
|
||
blsChange, ok := m.(*ethpb.SignedBLSToExecutionChange) | ||
if !ok { | ||
return pubsub.ValidationReject, errWrongMessage | ||
} | ||
|
||
if s.cfg.blsToExecPool.ValidatorExists(blsChange.Message.ValidatorIndex) { | ||
return pubsub.ValidationIgnore, nil | ||
} | ||
st, err := s.cfg.chain.HeadState(ctx) | ||
if err != nil { | ||
return pubsub.ValidationIgnore, err | ||
} | ||
|
||
epoch := slots.ToEpoch(st.Slot()) | ||
domain, err := signing.Domain(st.Fork(), epoch, params.BeaconConfig().DomainBLSToExecutionChange, st.GenesisValidatorsRoot()) | ||
if err != nil { | ||
return pubsub.ValidationIgnore, err | ||
} | ||
if err := signing.VerifySigningRoot(blsChange.Message, blsChange.Message.FromBlsPubkey, blsChange.Signature, domain); err != nil { | ||
return pubsub.ValidationReject, signing.ErrSigFailedToVerify | ||
} | ||
// TODO(Potuz): BLSChange Validation | ||
// TODO(Nishant): Add to batch gossip sig verification | ||
|
||
msg.ValidatorData = blsChange // Used in downstream subscriber | ||
return pubsub.ValidationAccept, nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this weight is really going to be a constant then we need to return the same as above and avoid code duplication.
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.
good catch, this is the incorrect weight. I will have to set a new one for our scoring params