Skip to content

Commit

Permalink
Use correct fork and genesis root to verify bid (#11176)
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain authored Aug 5, 2022
1 parent 9261da7 commit 4e225fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
12 changes: 3 additions & 9 deletions beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,9 @@ func (vs *Server) validatorRegistered(ctx context.Context, id types.ValidatorInd

// Validates builder signature and returns an error if the signature is invalid.
func (vs *Server) validateBuilderSignature(bid *ethpb.SignedBuilderBid) error {
if vs.ForkFetcher == nil {
return errors.New("nil fork fetcher")
}
f := vs.ForkFetcher.CurrentFork()
if vs.GenesisFetcher == nil {
return errors.New("nil genesis fetcher")
}
gr := vs.GenesisFetcher.GenesisValidatorsRoot()
d, err := signing.ComputeDomain(params.BeaconConfig().DomainApplicationBuilder, f.CurrentVersion, gr[:])
d, err := signing.ComputeDomain(params.BeaconConfig().DomainApplicationBuilder,
nil, /* fork version */
nil /* genesis val root */)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ func TestServer_getAndBuildHeaderBlock(t *testing.T) {
Value: bytesutil.PadTo([]byte{1, 2, 3}, 32),
}
d := params.BeaconConfig().DomainApplicationBuilder
g := vs.GenesisFetcher.GenesisValidatorsRoot()
domain, err := signing.ComputeDomain(d, vs.ForkFetcher.CurrentFork().CurrentVersion, g[:])
domain, err := signing.ComputeDomain(d, nil, nil)
require.NoError(t, err)
sr, err := signing.ComputeSigningRoot(bid, domain)
require.NoError(t, err)
Expand Down Expand Up @@ -633,8 +632,7 @@ func TestServer_GetBellatrixBeaconBlock_BuilderCase(t *testing.T) {
Value: bytesutil.PadTo([]byte{1, 2, 3}, 32),
}
d := params.BeaconConfig().DomainApplicationBuilder
g := proposerServer.GenesisFetcher.GenesisValidatorsRoot()
domain, err := signing.ComputeDomain(d, proposerServer.ForkFetcher.CurrentFork().CurrentVersion, g[:])
domain, err := signing.ComputeDomain(d, nil, nil)
require.NoError(t, err)
sr, err := signing.ComputeSigningRoot(bid, domain)
require.NoError(t, err)
Expand Down Expand Up @@ -687,13 +685,7 @@ func TestServer_validatorRegistered(t *testing.T) {
}

func TestServer_validateBuilderSignature(t *testing.T) {
m := &blockchainTest.ChainService{
Fork: &ethpb.Fork{},
}
s := &Server{
ForkFetcher: m,
GenesisFetcher: m,
}
s := &Server{}
sk, err := bls.RandKey()
require.NoError(t, err)
bid := &ethpb.BuilderBid{
Expand All @@ -713,8 +705,7 @@ func TestServer_validateBuilderSignature(t *testing.T) {
Value: bytesutil.PadTo([]byte{1, 2, 3}, 32),
}
d := params.BeaconConfig().DomainApplicationBuilder
g := s.GenesisFetcher.GenesisValidatorsRoot()
domain, err := signing.ComputeDomain(d, s.ForkFetcher.CurrentFork().CurrentVersion, g[:])
domain, err := signing.ComputeDomain(d, nil, nil)
require.NoError(t, err)
sr, err := signing.ComputeSigningRoot(bid, domain)
require.NoError(t, err)
Expand Down

0 comments on commit 4e225fc

Please sign in to comment.