mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
Use BeaconBlockHeader in place of BeaconBlock (#5049)
This commit is contained in:
parent
01cb01a8f2
commit
0c3af32274
@ -194,18 +194,31 @@ func (v *validator) signBlock(ctx context.Context, pubKey [48]byte, epoch uint64
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get domain data")
|
||||
}
|
||||
root, err := ssz.HashTreeRoot(b)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get signing root")
|
||||
}
|
||||
var sig *bls.Signature
|
||||
if protectingKeymanager, supported := v.keyManager.(keymanager.ProtectingKeyManager); supported {
|
||||
sig, err = protectingKeymanager.SignProposal(pubKey, domain.SignatureDomain, b)
|
||||
bodyRoot, err := ssz.HashTreeRoot(b.Body)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get signing root")
|
||||
}
|
||||
blockHeader := ðpb.BeaconBlockHeader{
|
||||
Slot: b.Slot,
|
||||
StateRoot: b.StateRoot,
|
||||
ParentRoot: b.ParentRoot,
|
||||
BodyRoot: bodyRoot[:],
|
||||
}
|
||||
sig, err = protectingKeymanager.SignProposal(pubKey, domain.SignatureDomain, blockHeader)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not sign block proposal")
|
||||
}
|
||||
} else {
|
||||
sig, err = v.keyManager.Sign(pubKey, root, domain.SignatureDomain)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get signing root")
|
||||
blockRoot, err := ssz.HashTreeRoot(b)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get signing root")
|
||||
}
|
||||
sig, err = v.keyManager.Sign(pubKey, blockRoot, domain.SignatureDomain)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not sign block proposal")
|
||||
}
|
||||
}
|
||||
return sig.Marshal(), nil
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ type KeyManager interface {
|
||||
// ProtectingKeyManager provides access to a keymanager that protects its clients from slashing events.
|
||||
type ProtectingKeyManager interface {
|
||||
// SignProposal signs a block proposal for the validator to broadcast.
|
||||
SignProposal(pubKey [48]byte, domain uint64, data *ethpb.BeaconBlock) (*bls.Signature, error)
|
||||
SignProposal(pubKey [48]byte, domain uint64, data *ethpb.BeaconBlockHeader) (*bls.Signature, error)
|
||||
|
||||
// SignAttestation signs an attestation for the validator to broadcast.
|
||||
SignAttestation(pubKey [48]byte, domain uint64, data *ethpb.AttestationData) (*bls.Signature, error)
|
||||
|
Loading…
Reference in New Issue
Block a user