Skip to content

Remote Signer: Electra #14477

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

Merged
merged 23 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e70122c
updating blockv2 to handle electra blocks
james-prysm Sep 23, 2024
3d809bb
adding aggregate attesation and proof electra
james-prysm Sep 24, 2024
6ca4fa6
gaz
james-prysm Sep 24, 2024
759f0e7
Merge branch 'develop' into remote-signer-electra
james-prysm Sep 24, 2024
bed422a
changelogs
james-prysm Sep 25, 2024
3eb62c9
Merge branch 'develop' into remote-signer-electra
james-prysm Sep 27, 2024
767259f
Merge branch 'develop' into remote-signer-electra
james-prysm Oct 24, 2024
d61a796
Merge branch 'develop' into remote-signer-electra
james-prysm Dec 30, 2024
dd71aae
updating web3signer dependency
james-prysm Dec 30, 2024
1ba4420
Merge branch 'develop' into remote-signer-electra
james-prysm Dec 30, 2024
4c1e7f0
test mock was flipped
james-prysm Dec 30, 2024
182749d
fixing hex value
james-prysm Dec 31, 2024
0cd6050
accidently checked in dependency changes
james-prysm Dec 31, 2024
e14a335
Merge branch 'develop' into remote-signer-electra
james-prysm Jan 2, 2025
1a4dcb1
Merge branch 'develop' into remote-signer-electra
james-prysm Jan 6, 2025
5ad06d1
preston feedback
james-prysm Jan 6, 2025
0cb9cf8
readding old metrics to not break linting
james-prysm Jan 6, 2025
a2ba49f
Merge branch 'develop' into remote-signer-electra
james-prysm Jan 13, 2025
5239021
Merge branch 'develop' into remote-signer-electra
james-prysm Jan 15, 2025
a8b19b7
review feedback and changelog
james-prysm Jan 15, 2025
c4dfb00
Merge branch 'develop' into remote-signer-electra
james-prysm Jan 15, 2025
08e5119
gaz
james-prysm Jan 15, 2025
a8d449f
Merge branch 'develop' into remote-signer-electra
james-prysm Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- Trace IDONTWANT Messages in Pubsub.
- Add Fulu fork boilerplate.
- Separate type for unaggregated network attestations. [PR](https://github.com/prysmaticlabs/prysm/pull/14659)
- Remote signer electra fork support.

### Changed

Expand Down
6 changes: 3 additions & 3 deletions testing/endtoend/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ lighthouse_archive_name = "lighthouse-%s-x86_64-unknown-linux-gnu-portable.tar.g
def e2e_deps():
http_archive(
name = "web3signer",
urls = ["https://artifacts.consensys.net/public/web3signer/raw/names/web3signer.tar.gz/versions/23.11.0/web3signer-23.11.0.tar.gz"],
sha256 = "e7643a6aa32efd859e96a82cb3ea03a294fd92c22fffeab987e5ec97500867a8",
urls = ["https://artifacts.consensys.net/public/web3signer/raw/names/web3signer.tar.gz/versions/24.12.0/web3signer-24.12.0.tar.gz"],
sha256 = "5d2eff119e065a50bd2bd727e098963d0e61a3f6525bdc12b11515d3677a84d1",
build_file = "@prysm//testing/endtoend:web3signer.BUILD",
strip_prefix = "web3signer-23.11.0",
strip_prefix = "web3signer-24.12.0",
)

http_archive(
Expand Down
4 changes: 2 additions & 2 deletions validator/keymanager/remote-web3signer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go_library(
"//validator/accounts/petnames:go_default_library",
"//validator/keymanager:go_default_library",
"//validator/keymanager/remote-web3signer/internal:go_default_library",
"//validator/keymanager/remote-web3signer/v1:go_default_library",
"//validator/keymanager/remote-web3signer/types:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_fsnotify_fsnotify//:go_default_library",
"@com_github_go_playground_validator_v10//:go_default_library",
Expand All @@ -48,7 +48,7 @@ go_test(
"//testing/require:go_default_library",
"//validator/keymanager:go_default_library",
"//validator/keymanager/remote-web3signer/internal:go_default_library",
"//validator/keymanager/remote-web3signer/v1/mock:go_default_library",
"//validator/keymanager/remote-web3signer/types/mock:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
Expand Down
78 changes: 60 additions & 18 deletions validator/keymanager/remote-web3signer/keymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/prysmaticlabs/prysm/v5/validator/accounts/petnames"
"github.com/prysmaticlabs/prysm/v5/validator/keymanager"
"github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer/internal"
web3signerv1 "github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer/v1"
"github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer/types"
"github.com/sirupsen/logrus"
"golang.org/x/exp/maps"
)
Expand Down Expand Up @@ -406,6 +406,8 @@ func getSignRequestJson(ctx context.Context, validator *validator.Validate, requ
return handleAttestationData(ctx, validator, request, genesisValidatorsRoot)
case *validatorpb.SignRequest_AggregateAttestationAndProof:
return handleAggregateAttestationAndProof(ctx, validator, request, genesisValidatorsRoot)
case *validatorpb.SignRequest_AggregateAttestationAndProofElectra:
return handleAggregateAttestationAndProofV2Electra(ctx, validator, request, genesisValidatorsRoot)
case *validatorpb.SignRequest_Slot:
return handleAggregationSlot(ctx, validator, request, genesisValidatorsRoot)
case *validatorpb.SignRequest_BlockAltair:
Expand All @@ -422,6 +424,10 @@ func getSignRequestJson(ctx context.Context, validator *validator.Validate, requ
return handleBlockDeneb(ctx, validator, request, genesisValidatorsRoot)
case *validatorpb.SignRequest_BlindedBlockDeneb:
return handleBlindedBlockDeneb(ctx, validator, request, genesisValidatorsRoot)
case *validatorpb.SignRequest_BlockElectra:
return handleBlockElectra(ctx, validator, request, genesisValidatorsRoot)
case *validatorpb.SignRequest_BlindedBlockElectra:
return handleBlindedBlockElectra(ctx, validator, request, genesisValidatorsRoot)
// We do not support "DEPOSIT" type.
/*
case *validatorpb.:
Expand All @@ -447,7 +453,7 @@ func getSignRequestJson(ctx context.Context, validator *validator.Validate, requ
}

func handleBlock(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
bockSignRequest, err := web3signerv1.GetBlockSignRequest(request, genesisValidatorsRoot)
bockSignRequest, err := types.GetBlockSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -459,7 +465,7 @@ func handleBlock(ctx context.Context, validator *validator.Validate, request *va
}

func handleAttestationData(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
attestationSignRequest, err := web3signerv1.GetAttestationSignRequest(request, genesisValidatorsRoot)
attestationSignRequest, err := types.GetAttestationSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -471,7 +477,7 @@ func handleAttestationData(ctx context.Context, validator *validator.Validate, r
}

func handleAggregateAttestationAndProof(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
aggregateAndProofSignRequest, err := web3signerv1.GetAggregateAndProofSignRequest(request, genesisValidatorsRoot)
aggregateAndProofSignRequest, err := types.GetAggregateAndProofSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -482,8 +488,20 @@ func handleAggregateAttestationAndProof(ctx context.Context, validator *validato
return json.Marshal(aggregateAndProofSignRequest)
}

func handleAggregateAttestationAndProofV2Electra(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not covered by any test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to be V2 if it's Electra specific and is the only one?

Suggested change
func handleAggregateAttestationAndProofV2Electra(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
func handleAggregateAttestationAndProofElectra(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just be, as both seems odd

Suggested change
func handleAggregateAttestationAndProofV2Electra(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
func handleAggregateAttestationAndProofV2(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm maybe i should just use V2

aggregateAndProofSignRequestV2, err := types.GetAggregateAndProofV2ElectraSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
if err = validator.StructCtx(ctx, aggregateAndProofSignRequestV2); err != nil {
return nil, err
}
aggregateAndProofSignRequestsTotal.Inc()
return json.Marshal(aggregateAndProofSignRequestV2)
}

func handleAggregationSlot(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
aggregationSlotSignRequest, err := web3signerv1.GetAggregationSlotSignRequest(request, genesisValidatorsRoot)
aggregationSlotSignRequest, err := types.GetAggregationSlotSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -495,7 +513,7 @@ func handleAggregationSlot(ctx context.Context, validator *validator.Validate, r
}

func handleBlockAltair(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
blockv2AltairSignRequest, err := web3signerv1.GetBlockAltairSignRequest(request, genesisValidatorsRoot)
blockv2AltairSignRequest, err := types.GetBlockAltairSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -507,7 +525,7 @@ func handleBlockAltair(ctx context.Context, validator *validator.Validate, reque
}

func handleBlockBellatrix(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
blockv2BellatrixSignRequest, err := web3signerv1.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
blockv2BellatrixSignRequest, err := types.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -519,7 +537,7 @@ func handleBlockBellatrix(ctx context.Context, validator *validator.Validate, re
}

func handleBlindedBlockBellatrix(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
blindedBlockv2SignRequest, err := web3signerv1.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
blindedBlockv2SignRequest, err := types.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -531,7 +549,7 @@ func handleBlindedBlockBellatrix(ctx context.Context, validator *validator.Valid
}

func handleBlockCapella(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
blockv2CapellaSignRequest, err := web3signerv1.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
blockv2CapellaSignRequest, err := types.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -543,7 +561,7 @@ func handleBlockCapella(ctx context.Context, validator *validator.Validate, requ
}

func handleBlindedBlockCapella(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
blindedBlockv2CapellaSignRequest, err := web3signerv1.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
blindedBlockv2CapellaSignRequest, err := types.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -555,7 +573,7 @@ func handleBlindedBlockCapella(ctx context.Context, validator *validator.Validat
}

func handleBlockDeneb(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
blockv2DenebSignRequest, err := web3signerv1.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
blockv2DenebSignRequest, err := types.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -567,7 +585,7 @@ func handleBlockDeneb(ctx context.Context, validator *validator.Validate, reques
}

func handleBlindedBlockDeneb(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
blindedBlockv2DenebSignRequest, err := web3signerv1.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
blindedBlockv2DenebSignRequest, err := types.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -578,8 +596,32 @@ func handleBlindedBlockDeneb(ctx context.Context, validator *validator.Validate,
return json.Marshal(blindedBlockv2DenebSignRequest)
}

func handleBlockElectra(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
blockv2ElectraSignRequest, err := types.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
if err = validator.StructCtx(ctx, blockv2ElectraSignRequest); err != nil {
return nil, err
}
remoteBlockSignRequestsTotal.WithLabelValues("electra", "false").Inc()
return json.Marshal(blockv2ElectraSignRequest)
}

func handleBlindedBlockElectra(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
blindedBlockv2ElectraSignRequest, err := types.GetBlockV2BlindedSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
if err = validator.StructCtx(ctx, blindedBlockv2ElectraSignRequest); err != nil {
return nil, err
}
remoteBlockSignRequestsTotal.WithLabelValues("electra", "true").Inc()
return json.Marshal(blindedBlockv2ElectraSignRequest)
}

func handleRandaoReveal(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
randaoRevealSignRequest, err := web3signerv1.GetRandaoRevealSignRequest(request, genesisValidatorsRoot)
randaoRevealSignRequest, err := types.GetRandaoRevealSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -591,7 +633,7 @@ func handleRandaoReveal(ctx context.Context, validator *validator.Validate, requ
}

func handleVoluntaryExit(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
voluntaryExitRequest, err := web3signerv1.GetVoluntaryExitSignRequest(request, genesisValidatorsRoot)
voluntaryExitRequest, err := types.GetVoluntaryExitSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -603,7 +645,7 @@ func handleVoluntaryExit(ctx context.Context, validator *validator.Validate, req
}

func handleSyncMessageBlockRoot(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
syncCommitteeMessageRequest, err := web3signerv1.GetSyncCommitteeMessageSignRequest(request, genesisValidatorsRoot)
syncCommitteeMessageRequest, err := types.GetSyncCommitteeMessageSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -615,7 +657,7 @@ func handleSyncMessageBlockRoot(ctx context.Context, validator *validator.Valida
}

func handleSyncAggregatorSelectionData(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
syncCommitteeSelectionProofRequest, err := web3signerv1.GetSyncCommitteeSelectionProofSignRequest(request, genesisValidatorsRoot)
syncCommitteeSelectionProofRequest, err := types.GetSyncCommitteeSelectionProofSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -627,7 +669,7 @@ func handleSyncAggregatorSelectionData(ctx context.Context, validator *validator
}

func handleContributionAndProof(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest, genesisValidatorsRoot []byte) ([]byte, error) {
contributionAndProofRequest, err := web3signerv1.GetSyncCommitteeContributionAndProofSignRequest(request, genesisValidatorsRoot)
contributionAndProofRequest, err := types.GetSyncCommitteeContributionAndProofSignRequest(request, genesisValidatorsRoot)
if err != nil {
return nil, err
}
Expand All @@ -639,7 +681,7 @@ func handleContributionAndProof(ctx context.Context, validator *validator.Valida
}

func handleRegistration(ctx context.Context, validator *validator.Validate, request *validatorpb.SignRequest) ([]byte, error) {
validatorRegistrationRequest, err := web3signerv1.GetValidatorRegistrationSignRequest(request)
validatorRegistrationRequest, err := types.GetValidatorRegistrationSignRequest(request)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion validator/keymanager/remote-web3signer/keymanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/prysmaticlabs/prysm/v5/testing/require"
"github.com/prysmaticlabs/prysm/v5/validator/keymanager"
"github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer/internal"
"github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer/v1/mock"
"github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer/types/mock"
logTest "github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
)
Expand Down
17 changes: 13 additions & 4 deletions validator/keymanager/remote-web3signer/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ var (
Name: "remote_web3signer_errored_responses_total",
Help: "Total number of errored responses when calling web3signer",
})
blockSignRequestsTotal = promauto.NewCounter(prometheus.CounterOpts{
Name: "remote_web3signer_block_sign_requests_total",
Help: "Total number of block sign requests",
})

aggregationSlotSignRequestsTotal = promauto.NewCounter(prometheus.CounterOpts{
Name: "remote_web3signer_aggregation_slot_requests_total",
Help: "Total number of aggregation slot requests",
Expand All @@ -30,6 +27,11 @@ var (
Name: "remote_web3signer_attestation_sign_requests_total",
Help: "Total number of attestation sign requests",
})
//TODO: deprecate these fork specific counters in prysm v6...
blockSignRequestsTotal = promauto.NewCounter(prometheus.CounterOpts{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this one be included in the comment? blockSignRequestsTotal is not fork specific right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's phase 0 sign requests

Name: "remote_web3signer_block_sign_requests_total",
Help: "Total number of block sign requests",
})
blockAltairSignRequestsTotal = promauto.NewCounter(prometheus.CounterOpts{
Name: "remote_web3signer_block_altair_sign_requests_total",
Help: "Total number of block altair sign requests",
Expand Down Expand Up @@ -58,6 +60,13 @@ var (
Name: "remote_web3signer_blinded_block_deneb_sign_requests_total",
Help: "Total number of blinded block deneb sign requests",
})
/////
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah just to show that it's deprecated to there


remoteBlockSignRequestsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "remote_block_sign_requests_total",
Help: "Total number of block sign requests with fork and blinded block check",
}, []string{"fork", "isBlinded"})

randaoRevealSignRequestsTotal = promauto.NewCounter(prometheus.CounterOpts{
Name: "remote_web3signer_randao_reveal_sign_requests_total",
Help: "Total number of randao reveal sign requests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go_library(
"requests.go",
"web3signer_types.go",
],
importpath = "github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer/v1",
importpath = "github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer/types",
visibility = ["//visibility:public"],
deps = [
"//consensus-types/blocks:go_default_library",
Expand Down Expand Up @@ -35,7 +35,7 @@ go_test(
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/validator-client:go_default_library",
"//testing/require:go_default_library",
"//validator/keymanager/remote-web3signer/v1/mock:go_default_library",
"//validator/keymanager/remote-web3signer/types/mock:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package types

import (
"fmt"
Expand Down Expand Up @@ -44,6 +44,22 @@ func MapAggregateAndProof(from *ethpb.AggregateAttestationAndProof) (*AggregateA
}, nil
}

// MapAggregateAndProofElectra maps the eth2.AggregateAndProofElectra proto to the Web3Signer spec.
func MapAggregateAndProofElectra(from *ethpb.AggregateAttestationAndProofElectra) (*AggregateAndProofElectra, error) {
if from == nil {
return nil, fmt.Errorf("AggregateAttestationAndProof is nil")
}
aggregate, err := MapAttestationElectra(from.Aggregate)
if err != nil {
return nil, err
}
return &AggregateAndProofElectra{
AggregatorIndex: fmt.Sprint(from.AggregatorIndex),
Aggregate: aggregate,
SelectionProof: from.SelectionProof,
}, nil
}

// MapAttestation maps the eth2.Attestation proto to the Web3Signer spec.
func MapAttestation(attestation *ethpb.Attestation) (*Attestation, error) {
if attestation == nil {
Expand All @@ -63,6 +79,29 @@ func MapAttestation(attestation *ethpb.Attestation) (*Attestation, error) {
}, nil
}

// MapAttestationElectra maps the eth2.Attestation proto to the Web3Signer spec.
func MapAttestationElectra(attestation *ethpb.AttestationElectra) (*AttestationElectra, error) {
if attestation == nil {
return nil, fmt.Errorf("attestation is nil")
}
if attestation.AggregationBits == nil {
return nil, fmt.Errorf("aggregation bits in attestation is nil")
}
if attestation.CommitteeBits == nil {
return nil, fmt.Errorf("committee bits in attestation is nil")
}
data, err := MapAttestationData(attestation.Data)
if err != nil {
return nil, err
}
return &AttestationElectra{
AggregationBits: []byte(attestation.AggregationBits),
Data: data,
Signature: attestation.Signature,
CommitteeBits: attestation.CommitteeBits.Bytes(),
}, nil
}

// MapAttestationData maps the eth2.AttestationData proto to the Web3Signer spec.
func MapAttestationData(data *ethpb.AttestationData) (*AttestationData, error) {
if data == nil {
Expand Down
Loading
Loading