Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
79dbe88
wip
james-prysm Mar 16, 2026
42fba9a
Merge branch 'develop' into validator-proposer-preferences
james-prysm Mar 17, 2026
1023558
Merge branch 'develop' into validator-proposer-preferences
james-prysm Mar 17, 2026
7f458ad
Merge branch 'develop' into validator-proposer-preferences
james-prysm Mar 17, 2026
e63490e
fixing proto now that it merged in
james-prysm Mar 17, 2026
555c9a5
merge helpers for efficiency
james-prysm Mar 17, 2026
5531004
fixing domain and self review
james-prysm Mar 18, 2026
acb841a
fixing unit test
james-prysm Mar 18, 2026
aee6527
self review and optimizations
james-prysm Mar 18, 2026
bbe7729
return early to avoid validator registration post gloas
james-prysm Mar 18, 2026
c63a1d6
making domain self contained
james-prysm Mar 18, 2026
c2e6102
Merge branch 'develop' into validator-proposer-preferences
james-prysm Mar 19, 2026
e2abdd4
api uses a request type instead
james-prysm Mar 19, 2026
caa83a5
changelog
james-prysm Mar 19, 2026
69f91b4
fixing unit test
james-prysm Mar 19, 2026
81a1b0d
terence's comments
james-prysm Mar 20, 2026
0a33919
adding additional tests
james-prysm Mar 20, 2026
6f3561a
fixing keymanager naming from terence's feedback
james-prysm Mar 20, 2026
37f248a
self review
james-prysm Mar 20, 2026
e14c3a5
Merge branch 'develop' into validator-proposer-preferences
james-prysm Mar 20, 2026
001e5b8
Merge branch 'develop' into validator-proposer-preferences
james-prysm Mar 23, 2026
06a0820
Merge branch 'develop' into validator-proposer-preferences
james-prysm Mar 23, 2026
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: 0 additions & 1 deletion .ethspecify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ exceptions:
- ATTESTATION_TIMELINESS_INDEX#gloas
- BUILDER_INDEX_FLAG#gloas
- BUILDER_INDEX_SELF_BUILD#gloas
- DOMAIN_PROPOSER_PREFERENCES#gloas
- NUM_BLOCK_TIMELINESS_DEADLINES#gloas
- PTC_TIMELINESS_INDEX#gloas

Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/verification/signed_proposer_preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (v *ProposerPreferencesVerifier) VerifySignature(st state.ReadOnlyBeaconSta

msg := v.message()
epoch := slots.ToEpoch(msg.ProposalSlot)
domain, err := signing.Domain(st.Fork(), epoch, params.BeaconConfig().DomainBeaconProposer, st.GenesisValidatorsRoot())
domain, err := signing.Domain(st.Fork(), epoch, params.BeaconConfig().DomainProposerPreferences, st.GenesisValidatorsRoot())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it should be this right?

if err != nil {
return errors.Wrap(err, "domain")
}
Expand Down
17 changes: 13 additions & 4 deletions beacon-chain/verification/signed_proposer_preferences_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestProposerPreferencesVerifier_VerifySignature(t *testing.T) {
verifier := &ProposerPreferencesVerifier{results: newResults(RequireProposerPreferencesSignatureValid), p: signed}
require.NoError(t, verifier.VerifySignature(st))

// Signature from the wrong key must fail.
badSig := signProposerPreferencesForState(t, keys[6], signed.Message, st)
signed.Signature = badSig
verifier = &ProposerPreferencesVerifier{results: newResults(RequireProposerPreferencesSignatureValid), p: signed}
Expand All @@ -52,8 +53,18 @@ func TestProposerPreferencesVerifier_VerifySignature(t *testing.T) {
func newSignedProposerPreferencesState(t *testing.T, currentSlot, proposalSlot primitives.Slot, validatorIndex primitives.ValidatorIndex) (state.BeaconState, []bls.SecretKey, *ethpb.SignedProposerPreferences) {
t.Helper()

params.SetupTestConfigCleanup(t)
cfg := params.BeaconConfig().Copy()
cfg.GloasForkEpoch = 0
params.OverrideBeaconConfig(cfg)

st, keys := util.DeterministicGenesisStateFulu(t, 64)
require.NoError(t, st.SetSlot(currentSlot))
require.NoError(t, st.SetFork(&ethpb.Fork{
PreviousVersion: cfg.FuluForkVersion,
CurrentVersion: cfg.GloasForkVersion,
Epoch: 0,
}))

lookaheadSize := int(uint64(params.BeaconConfig().MinSeedLookahead+1) * uint64(params.BeaconConfig().SlotsPerEpoch))
lookahead := make([]primitives.ValidatorIndex, lookaheadSize)
Expand All @@ -77,9 +88,7 @@ func signProposerPreferencesForState(t *testing.T, sk bls.SecretKey, preferences
t.Helper()

epoch := slots.ToEpoch(preferences.ProposalSlot)
domain, err := signing.Domain(st.Fork(), epoch, params.BeaconConfig().DomainBeaconProposer, st.GenesisValidatorsRoot())
require.NoError(t, err)
root, err := signing.ComputeSigningRoot(preferences, domain)
sig, err := signing.ComputeDomainAndSign(st, epoch, preferences, params.BeaconConfig().DomainProposerPreferences, sk)
require.NoError(t, err)
return sk.Sign(root[:]).Marshal()
return sig
}
1 change: 1 addition & 0 deletions config/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ type BeaconChainConfig struct {
DomainBLSToExecutionChange [4]byte `yaml:"DOMAIN_BLS_TO_EXECUTION_CHANGE" spec:"true"` // DomainBLSToExecutionChange defines the BLS signature domain to change withdrawal addresses to ETH1 prefix
DomainBeaconBuilder [4]byte `yaml:"DOMAIN_BEACON_BUILDER" spec:"true"` // DomainBeaconBuilder defines the BLS signature domain for beacon block builder.
DomainPTCAttester [4]byte `yaml:"DOMAIN_PTC_ATTESTER" spec:"true"` // DomainPTCAttester defines the BLS signature domain for payload transaction committee attester.
DomainProposerPreferences [4]byte `yaml:"DOMAIN_PROPOSER_PREFERENCES" spec:"true"` // DomainProposerPreferences defines the BLS signature domain for proposer preferences.

// Prysm constants.
GenesisValidatorsRoot [32]byte // GenesisValidatorsRoot is the root hash of the genesis validators.
Expand Down
1 change: 1 addition & 0 deletions config/params/mainnet_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ var mainnetBeaconConfig = &BeaconChainConfig{
DomainBLSToExecutionChange: bytesutil.Uint32ToBytes4(0x0A000000),
DomainBeaconBuilder: bytesutil.Uint32ToBytes4(0x0B000000),
DomainPTCAttester: bytesutil.Uint32ToBytes4(0x0C000000),
DomainProposerPreferences: bytesutil.Uint32ToBytes4(0x0D000000),

// Prysm constants.
GenesisValidatorsRoot: [32]byte{75, 54, 61, 185, 78, 40, 97, 32, 215, 110, 185, 5, 52, 15, 221, 78, 84, 191, 233, 240, 107, 243, 63, 246, 207, 90, 210, 127, 81, 27, 254, 149},
Expand Down
203 changes: 114 additions & 89 deletions proto/prysm/v1alpha1/validator-client/keymanager.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions proto/prysm/v1alpha1/validator-client/keymanager.proto
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ message SignRequest {
ethereum.eth.v1alpha1.BeaconBlockGloas block_gloas = 123;
ethereum.eth.v1alpha1.ExecutionPayloadEnvelope execution_payload_envelope = 124;
ethereum.eth.v1alpha1.PayloadAttestationData payload_attestation_data = 125;
ethereum.eth.v1alpha1.ProposerPreferences proposer_preferences = 126;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

everything above is singular, should this be preference or preferences?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

let me fix that to singular

}

reserved 4, 5; // Reserving old, deleted fields.
Expand Down
5 changes: 4 additions & 1 deletion specrefs/constants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@
</spec>

- name: DOMAIN_PROPOSER_PREFERENCES#gloas
sources: []
sources:
- file: config/params/config.go
search: DomainProposerPreferences\s+.*yaml:"DOMAIN_PROPOSER_PREFERENCES"
regex: true
spec: |
<spec constant_var="DOMAIN_PROPOSER_PREFERENCES" fork="gloas" hash="9377ecfb">
DOMAIN_PROPOSER_PREFERENCES: DomainType = '0x0D000000'
Expand Down
15 changes: 15 additions & 0 deletions testing/validator-mock/validator_client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions validator/client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ go_test(
"//validator/keymanager/local:go_default_library",
"//validator/keymanager/remote-web3signer:go_default_library",
"//validator/testing:go_default_library",
"@com_github_dgraph_io_ristretto_v2//:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_golang_protobuf//ptypes/empty",
Expand All @@ -187,6 +188,7 @@ go_test(
"@in_gopkg_d4l3k_messagediff_v1//:go_default_library",
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
"@org_golang_google_grpc//metadata:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
"@org_uber_go_mock//gomock:go_default_library",
],
Expand Down
7 changes: 7 additions & 0 deletions validator/client/beacon-api/beacon_api_validator_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ func (c *beaconApiValidatorClient) SubmitValidatorRegistrations(ctx context.Cont
})
}

// TODO(gloas): Wire up actual REST call to POST /eth/v1/validator/proposer_preferences
// once the beacon API endpoint is available (lodekeeper/beacon-APIs#1).
func (c *beaconApiValidatorClient) SubmitSignedProposerPreferences(_ context.Context, preferences []*ethpb.SignedProposerPreferences) (*empty.Empty, error) {
log.WithField("count", len(preferences)).Debug("SubmitSignedProposerPreferences not yet implemented, skipping")
return new(empty.Empty), nil
}

func (c *beaconApiValidatorClient) SubscribeCommitteeSubnets(ctx context.Context, in *ethpb.CommitteeSubnetsSubscribeRequest, duties []*ethpb.ValidatorDuty) (*empty.Empty, error) {
ctx, span := trace.StartSpan(ctx, "beacon-api.SubscribeCommitteeSubnets")
defer span.End()
Expand Down
9 changes: 9 additions & 0 deletions validator/client/grpc-api/grpc_validator_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ func (c *grpcValidatorClient) SubmitValidatorRegistrations(ctx context.Context,
return c.getClient().SubmitValidatorRegistrations(ctx, in)
}

func (c *grpcValidatorClient) SubmitSignedProposerPreferences(ctx context.Context, preferences []*ethpb.SignedProposerPreferences) (*empty.Empty, error) {
for _, preference := range preferences {
if _, err := c.getClient().SubmitSignedProposerPreferences(ctx, preference); err != nil {
return nil, err
}
}
return &empty.Empty{}, nil
}

func (c *grpcValidatorClient) SubscribeCommitteeSubnets(ctx context.Context, in *ethpb.CommitteeSubnetsSubscribeRequest, _ []*ethpb.ValidatorDuty) (*empty.Empty, error) {
return c.getClient().SubscribeCommitteeSubnets(ctx, in)
}
Expand Down
4 changes: 4 additions & 0 deletions validator/client/iface/validator_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ type ValidatorClient interface {
SyncCommitteeContribution(ctx context.Context, in *ethpb.SyncCommitteeContributionRequest) (*ethpb.SyncCommitteeContribution, error)
SubmitSignedContributionAndProof(ctx context.Context, in *ethpb.SignedContributionAndProof) (*empty.Empty, error)
SubmitValidatorRegistrations(ctx context.Context, in *ethpb.SignedValidatorRegistrationsV1) (*empty.Empty, error)
// SubmitSignedProposerPreferences submits proposer preferences for upcoming
// proposal slots. This replaces PrepareBeaconProposer and SubmitValidatorRegistrations
// for GLOAS+.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Prefer Gloas vs GLOAS

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will fix sorry

SubmitSignedProposerPreferences(ctx context.Context, preferences []*ethpb.SignedProposerPreferences) (*empty.Empty, error)
StartEventStream(ctx context.Context, topics []string, eventsChannel chan<- *event.Event)
EventStreamIsRunning() bool
AggregatedSelections(ctx context.Context, selections []BeaconCommitteeSelection) ([]BeaconCommitteeSelection, error)
Expand Down
40 changes: 40 additions & 0 deletions validator/client/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import (

"github.com/OffchainLabs/prysm/v7/beacon-chain/builder"
"github.com/OffchainLabs/prysm/v7/beacon-chain/core/signing"
fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams"
"github.com/OffchainLabs/prysm/v7/config/params"
"github.com/OffchainLabs/prysm/v7/encoding/bytesutil"
"github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace"
ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1"
validatorpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1/validator-client"
"github.com/OffchainLabs/prysm/v7/time/slots"
"github.com/OffchainLabs/prysm/v7/validator/client/iface"
"github.com/OffchainLabs/prysm/v7/validator/keymanager"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -92,6 +95,43 @@ func signValidatorRegistration(ctx context.Context, signer iface.SigningFunc, re
return sig.Marshal(), nil
}

func (v *validator) signProposerPreferences(
ctx context.Context,
km keymanager.IKeymanager,
pubkey [fieldparams.BLSPubkeyLength]byte,
pref *ethpb.ProposerPreferences,
) (*ethpb.SignedProposerPreferences, error) {
ctx, span := trace.StartSpan(ctx, "validator.signProposerPreferences")
defer span.End()

epoch := slots.ToEpoch(pref.ProposalSlot)
resp, err := v.domainData(ctx, epoch, params.BeaconConfig().DomainProposerPreferences[:])
if err != nil {
return nil, errors.Wrap(err, "could not get proposer preferences domain data")
}
domain := resp.SignatureDomain

r, err := signing.ComputeSigningRoot(pref, domain)
if err != nil {
return nil, errors.Wrap(err, signingRootErr)
}

sig, err := km.Sign(ctx, &validatorpb.SignRequest{
PublicKey: pubkey[:],
SigningRoot: r[:],
SignatureDomain: domain,
Object: &validatorpb.SignRequest_ProposerPreferences{ProposerPreferences: pref},
})
if err != nil {
return nil, errors.Wrap(err, "could not sign proposer preferences")
}

return &ethpb.SignedProposerPreferences{
Message: pref,
Signature: sig.Marshal(),
}, nil
}

// SignValidatorRegistrationRequest compares and returns either the cached validator registration request or signs a new one.
func (v *validator) SignValidatorRegistrationRequest(ctx context.Context, signer iface.SigningFunc, newValidatorRegistration *ethpb.ValidatorRegistrationV1) (*ethpb.SignedValidatorRegistrationV1, bool /* isCached */, error) {
signedReg, ok := v.signedValidatorRegistrations[bytesutil.ToBytes48(newValidatorRegistration.Pubkey)]
Expand Down
52 changes: 52 additions & 0 deletions validator/client/registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import (
"testing"
"time"

"github.com/OffchainLabs/prysm/v7/beacon-chain/core/signing"
fieldparams "github.com/OffchainLabs/prysm/v7/config/fieldparams"
"github.com/OffchainLabs/prysm/v7/config/params"
"github.com/OffchainLabs/prysm/v7/crypto/bls"
"github.com/OffchainLabs/prysm/v7/encoding/bytesutil"
ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v7/testing/require"
validatormock "github.com/OffchainLabs/prysm/v7/testing/validator-mock"
"github.com/dgraph-io/ristretto/v2"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pkg/errors"
"go.uber.org/mock/gomock"
"google.golang.org/protobuf/proto"
)

func TestSubmitValidatorRegistrations(t *testing.T) {
Expand Down Expand Up @@ -146,6 +151,53 @@ func Test_signValidatorRegistration(t *testing.T) {
}
}

func Test_signProposerPreferences(t *testing.T) {
kp := randKeypair(t)
km := newMockKeymanager(t, kp)
pref := &ethpb.ProposerPreferences{
ProposalSlot: 123,
ValidatorIndex: 456,
FeeRecipient: bytesutil.PadTo([]byte("fee"), 20),
GasLimit: 789,
}

domain, err := signing.ComputeDomain(
params.BeaconConfig().DomainProposerPreferences,
params.BeaconConfig().GenesisForkVersion,
params.BeaconConfig().GenesisValidatorsRoot[:],
)
require.NoError(t, err)

ctrl := gomock.NewController(t)
client := validatormock.NewMockValidatorClient(ctrl)
client.EXPECT().
DomainData(gomock.Any(), gomock.Any()).
Return(&ethpb.DomainResponse{SignatureDomain: domain}, nil)

cache, err := ristretto.NewCache(&ristretto.Config[string, proto.Message]{
NumCounters: 1920,
MaxCost: 192,
BufferItems: 64,
})
require.NoError(t, err)

v := validator{
validatorClient: client,
domainDataCache: cache,
}

signed, err := v.signProposerPreferences(t.Context(), km, kp.pub, pref)
require.NoError(t, err)
require.Equal(t, pref, signed.Message)

root, err := signing.ComputeSigningRoot(pref, domain)
require.NoError(t, err)

sig, err := bls.SignatureFromBytes(signed.Signature)
require.NoError(t, err)
require.Equal(t, true, sig.Verify(kp.pri.PublicKey(), root[:]))
}

func TestValidator_SignValidatorRegistrationRequest(t *testing.T) {
for _, isSlashingProtectionMinimal := range [...]bool{false, true} {
_, m, validatorKey, finish := setup(t, isSlashingProtectionMinimal)
Expand Down
Loading
Loading