From 09da0b549be7d90e6d0f87b09c73f7db8df059ed Mon Sep 17 00:00:00 2001 From: avalonche Date: Sat, 3 Dec 2022 05:17:55 +1100 Subject: [PATCH 1/3] Fix duplicate relay registrations in cache --- builder/relay_aggregator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/builder/relay_aggregator.go b/builder/relay_aggregator.go index 7071791f09..d5969982f8 100644 --- a/builder/relay_aggregator.go +++ b/builder/relay_aggregator.go @@ -112,6 +112,10 @@ func (r *RemoteRelayAggregator) updateRelayRegistrations(nextSlot uint64, regist topRegistrationCh <- registrations[bestRelayRegistrationIndex].vd } + if nextSlot == r.registrationsCacheSlot { + return + } + if nextSlot > r.registrationsCacheSlot { // clear the cache r.registrationsCache = make(map[ValidatorData][]IRelay) From bc9ce29c26496bfce0d658843ab0a2c9e8aec262 Mon Sep 17 00:00:00 2001 From: Mateusz Morusiewicz <11313015+Ruteri@users.noreply.github.com> Date: Sat, 3 Dec 2022 11:12:56 +0100 Subject: [PATCH 2/3] Remove Timestamp from builder validation data as it should be ignored --- builder/builder.go | 7 +++---- builder/builder_test.go | 1 - builder/local_relay.go | 23 +++++++++++++++-------- builder/local_relay_test.go | 4 ++-- builder/relay.go | 1 - builder/relay_aggregator_test.go | 7 +++---- builder/relay_test.go | 3 --- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/builder/builder.go b/builder/builder.go index 0c86eb7846..7a6b1e5aa6 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -25,9 +25,8 @@ type PubkeyHex string type ValidatorData struct { Pubkey PubkeyHex - FeeRecipient boostTypes.Address `json:"feeRecipient"` - GasLimit uint64 `json:"gasLimit"` - Timestamp uint64 `json:"timestamp"` + FeeRecipient boostTypes.Address + GasLimit uint64 } type IBeaconClient interface { @@ -137,7 +136,7 @@ func (b *Builder) onSealedBlock(block *types.Block, ordersClosedAt time.Time, se } if b.dryRun { - err = b.validator.ValidateBuilderSubmissionV1(&blockvalidation.BuilderBlockValidationRequest{blockSubmitReq, vd.GasLimit}) + err = b.validator.ValidateBuilderSubmissionV1(&blockvalidation.BuilderBlockValidationRequest{BuilderSubmitBlockRequest: blockSubmitReq, RegisteredGasLimit: vd.GasLimit}) if err != nil { log.Error("could not validate block", "err", err) } diff --git a/builder/builder_test.go b/builder/builder_test.go index 2069252b5a..7857a82762 100644 --- a/builder/builder_test.go +++ b/builder/builder_test.go @@ -34,7 +34,6 @@ func TestOnPayloadAttributes(t *testing.T) { Pubkey: PubkeyHex(testBeacon.validator.Pk.String()), FeeRecipient: feeRecipient, GasLimit: 10, - Timestamp: 15, }, } diff --git a/builder/local_relay.go b/builder/local_relay.go index 423c4ebe91..513e341559 100644 --- a/builder/local_relay.go +++ b/builder/local_relay.go @@ -25,6 +25,11 @@ type ForkData struct { GenesisValidatorsRoot string } +type FullValidatorData struct { + ValidatorData + Timestamp uint64 +} + type LocalRelay struct { beaconClient IBeaconClient @@ -36,7 +41,7 @@ type LocalRelay struct { proposerSigningDomain boostTypes.Domain validatorsLock sync.RWMutex - validators map[PubkeyHex]ValidatorData + validators map[PubkeyHex]FullValidatorData enableBeaconChecks bool @@ -70,7 +75,7 @@ func NewLocalRelay(sk *bls.SecretKey, beaconClient IBeaconClient, builderSigning proposerSigningDomain: proposerSigningDomain, serializedRelayPubkey: pkBytes, - validators: make(map[PubkeyHex]ValidatorData), + validators: make(map[PubkeyHex]FullValidatorData), enableBeaconChecks: enableBeaconChecks, @@ -161,11 +166,13 @@ func (r *LocalRelay) handleRegisterValidator(w http.ResponseWriter, req *http.Re for _, registerRequest := range payload { pubkeyHex := PubkeyHex(strings.ToLower(registerRequest.Message.Pubkey.String())) - r.validators[pubkeyHex] = ValidatorData{ - Pubkey: pubkeyHex, - FeeRecipient: registerRequest.Message.FeeRecipient, - GasLimit: registerRequest.Message.GasLimit, - Timestamp: registerRequest.Message.Timestamp, + r.validators[pubkeyHex] = FullValidatorData{ + ValidatorData: ValidatorData{ + Pubkey: pubkeyHex, + FeeRecipient: registerRequest.Message.FeeRecipient, + GasLimit: registerRequest.Message.GasLimit, + }, + Timestamp: registerRequest.Message.Timestamp, } log.Info("registered validator", "pubkey", pubkeyHex, "data", r.validators[pubkeyHex]) @@ -183,7 +190,7 @@ func (r *LocalRelay) GetValidatorForSlot(nextSlot uint64) (ValidatorData, error) r.validatorsLock.RLock() if vd, ok := r.validators[pubkeyHex]; ok { r.validatorsLock.RUnlock() - return vd, nil + return vd.ValidatorData, nil } r.validatorsLock.RUnlock() log.Info("no local entry for validator", "validator", pubkeyHex) diff --git a/builder/local_relay_test.go b/builder/local_relay_test.go index 53db30392a..39c202629e 100644 --- a/builder/local_relay_test.go +++ b/builder/local_relay_test.go @@ -69,7 +69,7 @@ func TestValidatorRegistration(t *testing.T) { rr := testRequest(t, relay, "POST", "/eth/v1/builder/validators", payload) require.Equal(t, http.StatusOK, rr.Code) require.Contains(t, relay.validators, PubkeyHex(v.Pk.String())) - require.Equal(t, ValidatorData{Pubkey: PubkeyHex(v.Pk.String()), FeeRecipient: payload[0].Message.FeeRecipient, GasLimit: payload[0].Message.GasLimit, Timestamp: payload[0].Message.Timestamp}, relay.validators[PubkeyHex(v.Pk.String())]) + require.Equal(t, FullValidatorData{ValidatorData: ValidatorData{Pubkey: PubkeyHex(v.Pk.String()), FeeRecipient: payload[0].Message.FeeRecipient, GasLimit: payload[0].Message.GasLimit}, Timestamp: payload[0].Message.Timestamp}, relay.validators[PubkeyHex(v.Pk.String())]) rr = testRequest(t, relay, "POST", "/eth/v1/builder/validators", payload) require.Equal(t, http.StatusOK, rr.Code) @@ -113,7 +113,7 @@ func registerValidator(t *testing.T, v *ValidatorPrivateData, relay *LocalRelay) rr := testRequest(t, relay, "POST", "/eth/v1/builder/validators", payload) require.Equal(t, http.StatusOK, rr.Code) require.Contains(t, relay.validators, PubkeyHex(v.Pk.String())) - require.Equal(t, ValidatorData{Pubkey: PubkeyHex(v.Pk.String()), FeeRecipient: payload[0].Message.FeeRecipient, GasLimit: payload[0].Message.GasLimit, Timestamp: payload[0].Message.Timestamp}, relay.validators[PubkeyHex(v.Pk.String())]) + require.Equal(t, FullValidatorData{ValidatorData: ValidatorData{Pubkey: PubkeyHex(v.Pk.String()), FeeRecipient: payload[0].Message.FeeRecipient, GasLimit: payload[0].Message.GasLimit}, Timestamp: payload[0].Message.Timestamp}, relay.validators[PubkeyHex(v.Pk.String())]) } func TestGetHeader(t *testing.T) { diff --git a/builder/relay.go b/builder/relay.go index 5144a12d4e..5b11c8d9f0 100644 --- a/builder/relay.go +++ b/builder/relay.go @@ -169,7 +169,6 @@ func (r *RemoteRelay) getSlotValidatorMapFromRelay() (map[uint64]ValidatorData, Pubkey: pubkeyHex, FeeRecipient: feeRecipient, GasLimit: data.Entry.Message.GasLimit, - Timestamp: data.Entry.Message.Timestamp, } } diff --git a/builder/relay_aggregator_test.go b/builder/relay_aggregator_test.go index 5465a6d00b..84daed0b8e 100644 --- a/builder/relay_aggregator_test.go +++ b/builder/relay_aggregator_test.go @@ -20,10 +20,9 @@ type testRelay struct { gvsVd ValidatorData gvsErr error - requestedSlot uint64 - submittedMsg *boostTypes.BuilderSubmitBlockRequest - submittedMsgCh chan *boostTypes.BuilderSubmitBlockRequest - submittedRegistration ValidatorData + requestedSlot uint64 + submittedMsg *boostTypes.BuilderSubmitBlockRequest + submittedMsgCh chan *boostTypes.BuilderSubmitBlockRequest } type testRelayAggBackend struct { diff --git a/builder/relay_test.go b/builder/relay_test.go index adc0f9aaba..9b43aedaf7 100644 --- a/builder/relay_test.go +++ b/builder/relay_test.go @@ -52,7 +52,6 @@ func TestRemoteRelay(t *testing.T) { Pubkey: "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", FeeRecipient: boostTypes.Address{0xab, 0xcf, 0x8e, 0xd, 0x4e, 0x95, 0x87, 0x36, 0x9b, 0x23, 0x1, 0xd0, 0x79, 0x3, 0x47, 0x32, 0x3, 0x2, 0xcc, 0x9}, GasLimit: uint64(1), - Timestamp: uint64(1), } require.Equal(t, expectedValidator_123, vd) @@ -98,14 +97,12 @@ func TestRemoteRelay(t *testing.T) { Pubkey: "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", FeeRecipient: boostTypes.Address{0xab, 0xcf, 0x8e, 0xd, 0x4e, 0x95, 0x87, 0x36, 0x9b, 0x23, 0x1, 0xd0, 0x79, 0x3, 0x47, 0x32, 0x3, 0x2, 0xcc, 0x10}, GasLimit: uint64(1), - Timestamp: uint64(1), } expectedValidator_156 := ValidatorData{ Pubkey: "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", FeeRecipient: boostTypes.Address{0xab, 0xcf, 0x8e, 0xd, 0x4e, 0x95, 0x87, 0x36, 0x9b, 0x23, 0x1, 0xd0, 0x79, 0x3, 0x47, 0x32, 0x3, 0x2, 0xcc, 0x11}, GasLimit: uint64(1), - Timestamp: uint64(1), } vd, err = relay.GetValidatorForSlot(155) From d8e0390096755593e13d268662ac2faa3935d74a Mon Sep 17 00:00:00 2001 From: Mateusz Morusiewicz <11313015+Ruteri@users.noreply.github.com> Date: Mon, 5 Dec 2022 11:35:52 +0100 Subject: [PATCH 3/3] Adjust cfg.SecondaryRemoteRelayEndpoints for empty list --- builder/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/service.go b/builder/service.go index b8a131c918..aea8349c13 100644 --- a/builder/service.go +++ b/builder/service.go @@ -160,7 +160,7 @@ func Register(stack *node.Node, backend *eth.Ethereum, cfg *Config) error { return errors.New("neither local nor remote relay specified") } - if len(cfg.SecondaryRemoteRelayEndpoints) > 0 { + if len(cfg.SecondaryRemoteRelayEndpoints) > 0 && !(len(cfg.SecondaryRemoteRelayEndpoints) == 1 && cfg.SecondaryRemoteRelayEndpoints[0] == "") { secondaryRelays := make([]IRelay, len(cfg.SecondaryRemoteRelayEndpoints)) for i, endpoint := range cfg.SecondaryRemoteRelayEndpoints { secondaryRelays[i] = NewRemoteRelay(endpoint, nil)