mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Validator client: remove blob signing (#13169)
This commit is contained in:
@@ -152,10 +152,6 @@ func getSignRequestJson(ctx context.Context, validator *validator.Validate, requ
|
||||
return handleContributionAndProof(ctx, validator, request, genesisValidatorsRoot)
|
||||
case *validatorpb.SignRequest_Registration:
|
||||
return handleRegistration(ctx, validator, request)
|
||||
case *validatorpb.SignRequest_Blob:
|
||||
return handleBlob(ctx, validator, request, genesisValidatorsRoot)
|
||||
case *validatorpb.SignRequest_BlindedBlob:
|
||||
return handleBlindedBlob(ctx, validator, request, genesisValidatorsRoot)
|
||||
default:
|
||||
return nil, fmt.Errorf("web3signer sign request type %T not supported", request.Object)
|
||||
}
|
||||
@@ -365,30 +361,6 @@ func handleRegistration(ctx context.Context, validator *validator.Validate, requ
|
||||
return json.Marshal(validatorRegistrationRequest)
|
||||
}
|
||||
|
||||
func handleBlob(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
|
||||
blobRequest, err := web3signerv1.GetBlobSignRequest(request, genesisValidatorsRoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = validator.StructCtx(ctx, blobRequest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blobSignRequestsTotal.Inc()
|
||||
return json.Marshal(blobRequest)
|
||||
}
|
||||
|
||||
func handleBlindedBlob(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
|
||||
blindedBlobRequest, err := web3signerv1.GetBlobSignRequest(request, genesisValidatorsRoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = validator.StructCtx(ctx, blindedBlobRequest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blindedBlobSignRequestsTotal.Inc()
|
||||
return json.Marshal(blindedBlobRequest)
|
||||
}
|
||||
|
||||
// SubscribeAccountChanges returns the event subscription for changes to public keys.
|
||||
func (km *Keymanager) SubscribeAccountChanges(pubKeysChan chan [][fieldparams.BLSPubkeyLength]byte) event.Subscription {
|
||||
return km.accountsChangedFeed.Subscribe(pubKeysChan)
|
||||
|
||||
@@ -170,14 +170,6 @@ func TestKeymanager_Sign(t *testing.T) {
|
||||
want: desiredSig,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "BLOB_SIDECAR",
|
||||
args: args{
|
||||
request: mock.GetMockSignRequest("BLOB_SIDECAR"),
|
||||
},
|
||||
want: desiredSig,
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
@@ -82,12 +82,4 @@ var (
|
||||
Name: "remote_web3signer_validator_registration_sign_requests_total",
|
||||
Help: "Total number of validator registration sign requests",
|
||||
})
|
||||
blobSignRequestsTotal = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "remote_web3signer_blob_sign_requests_total",
|
||||
Help: "Total number of blob sign requests",
|
||||
})
|
||||
blindedBlobSignRequestsTotal = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "remote_web3signer_blinded_blob_sign_requests_total",
|
||||
Help: "Total number of blinded blob sign requests",
|
||||
})
|
||||
)
|
||||
|
||||
@@ -10,11 +10,9 @@ go_library(
|
||||
importpath = "github.com/prysmaticlabs/prysm/v4/validator/keymanager/remote-web3signer/v1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//consensus-types/blocks:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//encoding/ssz:go_default_library",
|
||||
"//network/forks:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/validator-client:go_default_library",
|
||||
|
||||
@@ -8,13 +8,11 @@ go_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//encoding/ssz:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/validator-client:go_default_library",
|
||||
"//testing/util:go_default_library",
|
||||
"//validator/keymanager/remote-web3signer/v1:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -6,12 +6,10 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/encoding/ssz"
|
||||
eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
||||
validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client"
|
||||
"github.com/prysmaticlabs/prysm/v4/testing/util"
|
||||
v1 "github.com/prysmaticlabs/prysm/v4/validator/keymanager/remote-web3signer/v1"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -464,49 +462,6 @@ func GetMockSignRequest(t string) *validatorpb.SignRequest {
|
||||
},
|
||||
SigningSlot: 0,
|
||||
}
|
||||
case "BLOB_SIDECAR":
|
||||
return &validatorpb.SignRequest{
|
||||
PublicKey: make([]byte, fieldparams.BLSPubkeyLength),
|
||||
SigningRoot: make([]byte, fieldparams.RootLength),
|
||||
SignatureDomain: make([]byte, 4),
|
||||
Object: &validatorpb.SignRequest_Blob{
|
||||
Blob: ð.DeprecatedBlobSidecar{
|
||||
BlockRoot: make([]byte, fieldparams.RootLength),
|
||||
Index: uint64(0),
|
||||
Slot: 0,
|
||||
BlockParentRoot: make([]byte, fieldparams.RootLength),
|
||||
ProposerIndex: 0,
|
||||
Blob: make([]byte, fieldparams.BlobLength),
|
||||
KzgCommitment: make([]byte, fieldparams.BLSPubkeyLength),
|
||||
KzgProof: make([]byte, fieldparams.BLSPubkeyLength),
|
||||
},
|
||||
},
|
||||
SigningSlot: 0,
|
||||
}
|
||||
case "BLINDED_BLOB_SIDECAR":
|
||||
blobRoot, err := ssz.ByteSliceRoot(make([]byte, fieldparams.BlobLength), fieldparams.BlobLength)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return nil
|
||||
}
|
||||
return &validatorpb.SignRequest{
|
||||
PublicKey: make([]byte, fieldparams.BLSPubkeyLength),
|
||||
SigningRoot: make([]byte, fieldparams.RootLength),
|
||||
SignatureDomain: make([]byte, 4),
|
||||
Object: &validatorpb.SignRequest_BlindedBlob{
|
||||
BlindedBlob: ð.BlindedBlobSidecar{
|
||||
BlockRoot: make([]byte, fieldparams.RootLength),
|
||||
Index: uint64(0),
|
||||
Slot: 0,
|
||||
BlockParentRoot: make([]byte, fieldparams.RootLength),
|
||||
ProposerIndex: 0,
|
||||
BlobRoot: blobRoot[:],
|
||||
KzgCommitment: make([]byte, fieldparams.BLSPubkeyLength),
|
||||
KzgProof: make([]byte, fieldparams.BLSPubkeyLength),
|
||||
},
|
||||
},
|
||||
SigningSlot: 0,
|
||||
}
|
||||
default:
|
||||
fmt.Printf("Web3signer sign request type: %v not found", t)
|
||||
return nil
|
||||
@@ -669,30 +624,6 @@ func ValidatorRegistrationSignRequest() *v1.ValidatorRegistrationSignRequest {
|
||||
}
|
||||
}
|
||||
|
||||
// BlobSidecarSignRequest is a mock implementation of the BlobSidecarSignRequest.
|
||||
func BlobSidecarSignRequest() *v1.BlobSidecarSignRequest {
|
||||
blobRoot, err := ssz.ByteSliceRoot(make([]byte, fieldparams.BlobLength), fieldparams.BlobLength)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return nil
|
||||
}
|
||||
return &v1.BlobSidecarSignRequest{
|
||||
Type: "BLOB_SIDECAR",
|
||||
ForkInfo: ForkInfo(),
|
||||
SigningRoot: make([]byte, fieldparams.RootLength),
|
||||
BlobSidecar: &v1.BlobSidecar{
|
||||
BlockRoot: make([]byte, fieldparams.RootLength),
|
||||
Index: fmt.Sprint(0),
|
||||
Slot: fmt.Sprint(0),
|
||||
BlockParentRoot: make([]byte, fieldparams.RootLength),
|
||||
ProposerIndex: fmt.Sprint(0),
|
||||
BlobRoot: blobRoot[:],
|
||||
KzgCommitment: make([]byte, fieldparams.BLSPubkeyLength),
|
||||
KzgProof: make([]byte, fieldparams.BLSPubkeyLength),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -4,10 +4,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v4/consensus-types/interfaces"
|
||||
"github.com/prysmaticlabs/prysm/v4/encoding/ssz"
|
||||
validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client"
|
||||
)
|
||||
|
||||
@@ -416,66 +414,3 @@ func GetValidatorRegistrationSignRequest(request *validatorpb.SignRequest) (*Val
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetBlobSignRequest maps the request for signing type BLOB_SIDECAR
|
||||
func GetBlobSignRequest(request *validatorpb.SignRequest, genesisValidatorsRoot []byte) (*BlobSidecarSignRequest, error) {
|
||||
if request == nil {
|
||||
return nil, errors.New("nil sign request provided")
|
||||
}
|
||||
fork, err := MapForkInfo(request.SigningSlot, genesisValidatorsRoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var blobSidecar *BlobSidecar
|
||||
switch request.Object.(type) {
|
||||
case *validatorpb.SignRequest_Blob:
|
||||
blob, ok := request.Object.(*validatorpb.SignRequest_Blob)
|
||||
if !ok {
|
||||
return nil, errors.New("failed to cast request object to blob sidecar")
|
||||
}
|
||||
if blob == nil || blob.Blob == nil {
|
||||
return nil, errors.New("invalid sign request: blob sidecar is nil")
|
||||
}
|
||||
blobRoot, err := ssz.ByteSliceRoot(blob.Blob.Blob, fieldparams.BlobLength)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "unable to get blob root from ssz roots")
|
||||
}
|
||||
blobSidecar = &BlobSidecar{
|
||||
BlockRoot: blob.Blob.BlockRoot,
|
||||
Index: fmt.Sprint(blob.Blob.Index),
|
||||
Slot: fmt.Sprint(blob.Blob.Slot),
|
||||
BlockParentRoot: blob.Blob.BlockParentRoot,
|
||||
ProposerIndex: fmt.Sprint(blob.Blob.ProposerIndex),
|
||||
BlobRoot: blobRoot[:],
|
||||
KzgCommitment: blob.Blob.KzgCommitment,
|
||||
KzgProof: blob.Blob.KzgProof,
|
||||
}
|
||||
case *validatorpb.SignRequest_BlindedBlob:
|
||||
blindedBlob, ok := request.Object.(*validatorpb.SignRequest_BlindedBlob)
|
||||
if !ok {
|
||||
return nil, errors.New("failed to cast request object to blinded blob sidecar")
|
||||
}
|
||||
if blindedBlob == nil || blindedBlob.BlindedBlob == nil {
|
||||
return nil, errors.New("invalid sign request: blinded blob sidecar is nil")
|
||||
}
|
||||
blobSidecar = &BlobSidecar{
|
||||
BlockRoot: blindedBlob.BlindedBlob.BlockRoot,
|
||||
Index: fmt.Sprint(blindedBlob.BlindedBlob.Index),
|
||||
Slot: fmt.Sprint(blindedBlob.BlindedBlob.Slot),
|
||||
BlockParentRoot: blindedBlob.BlindedBlob.BlockParentRoot,
|
||||
ProposerIndex: fmt.Sprint(blindedBlob.BlindedBlob.ProposerIndex),
|
||||
BlobRoot: blindedBlob.BlindedBlob.BlobRoot,
|
||||
KzgCommitment: blindedBlob.BlindedBlob.KzgCommitment,
|
||||
KzgProof: blindedBlob.BlindedBlob.KzgProof,
|
||||
}
|
||||
default:
|
||||
return nil, errors.New("invalid sign request: invalid object type")
|
||||
}
|
||||
|
||||
return &BlobSidecarSignRequest{
|
||||
Type: "BLOB_SIDECAR",
|
||||
ForkInfo: fork,
|
||||
SigningRoot: request.SigningRoot,
|
||||
BlobSidecar: blobSidecar,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -465,47 +465,6 @@ func TestGetBlockV2BlindedSignRequest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetBlobSignRequest(t *testing.T) {
|
||||
type args struct {
|
||||
request *validatorpb.SignRequest
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *v1.BlobSidecarSignRequest
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Happy Path Test",
|
||||
args: args{
|
||||
request: mock.GetMockSignRequest("BLOB_SIDECAR"),
|
||||
},
|
||||
want: mock.BlobSidecarSignRequest(),
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Happy Path Test Blinded",
|
||||
args: args{
|
||||
request: mock.GetMockSignRequest("BLINDED_BLOB_SIDECAR"),
|
||||
},
|
||||
want: mock.BlobSidecarSignRequest(),
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := v1.GetBlobSignRequest(tt.args.request, make([]byte, fieldparams.RootLength))
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("GetBlobSignRequest() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("GetBlobSignRequest() got = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetValidatorRegistrationSignRequest(t *testing.T) {
|
||||
type args struct {
|
||||
request *validatorpb.SignRequest
|
||||
|
||||
@@ -105,14 +105,6 @@ type ValidatorRegistrationSignRequest struct {
|
||||
ValidatorRegistration *ValidatorRegistration `json:"validator_registration" validate:"required"`
|
||||
}
|
||||
|
||||
// BlobSidecarSignRequest a request object for web3signer sign api.
|
||||
type BlobSidecarSignRequest struct {
|
||||
Type string `json:"type" validate:"required"`
|
||||
ForkInfo *ForkInfo `json:"fork_info" validate:"required"`
|
||||
SigningRoot hexutil.Bytes `json:"signingRoot"`
|
||||
BlobSidecar *BlobSidecar `json:"blob_sidecar" validate:"required,dive"`
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// sub properties of Sign Requests /////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -345,18 +337,6 @@ type ValidatorRegistration struct {
|
||||
Pubkey hexutil.Bytes `json:"pubkey" validate:"required"` /* bls hexadecimal string */
|
||||
}
|
||||
|
||||
// BlobSidecar a sub property of BlobSidecarSignRequest
|
||||
type BlobSidecar struct {
|
||||
BlockRoot hexutil.Bytes `json:"block_root" validate:"required"` /* 32 hexadecimal string */
|
||||
Index string `json:"index" validate:"required"` /* uint64 */
|
||||
Slot string `json:"slot" validate:"required"` /* uint64 */
|
||||
BlockParentRoot hexutil.Bytes `json:"block_parent_root" validate:"required"` /* 32 hexadecimal string */
|
||||
ProposerIndex string `json:"proposer_index" validate:"required"` /* uint64 */
|
||||
BlobRoot hexutil.Bytes `json:"blob_root" validate:"required"` /* 32 hexadecimal string */
|
||||
KzgCommitment hexutil.Bytes `json:"kzg_commitment" validate:"required"` // pattern: "^0x[a-fA-F0-9]{96}$" ssz-size:"48"
|
||||
KzgProof hexutil.Bytes `json:"kzg_proof" validate:"required"` // pattern: "^0x[a-fA-F0-9]{96}$" ssz-size:"48"
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user