fix VC builder API registration expiry check sense (#5663)
* fix VC builder API registration expiry check sense * avoid pointlessly recomputing cached registrations * rm unused variable
This commit is contained in:
parent
df902fd00f
commit
61e355639a
|
@ -37,10 +37,9 @@ const
|
||||||
HISTORICAL_DUTIES_EPOCHS* = 2'u64
|
HISTORICAL_DUTIES_EPOCHS* = 2'u64
|
||||||
TIME_DELAY_FROM_SLOT* = 79.milliseconds
|
TIME_DELAY_FROM_SLOT* = 79.milliseconds
|
||||||
SUBSCRIPTION_BUFFER_SLOTS* = 2'u64
|
SUBSCRIPTION_BUFFER_SLOTS* = 2'u64
|
||||||
EPOCHS_BETWEEN_VALIDATOR_REGISTRATION* = 1
|
|
||||||
|
|
||||||
DelayBuckets* = [-Inf, -4.0, -2.0, -1.0, -0.5, -0.1, -0.05,
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/validator.md#constants
|
||||||
0.05, 0.1, 0.5, 1.0, 2.0, 4.0, 8.0, Inf]
|
EPOCHS_BETWEEN_VALIDATOR_REGISTRATION* = 1
|
||||||
|
|
||||||
ZeroTimeDiff* = TimeDiff(nanoseconds: 0'i64)
|
ZeroTimeDiff* = TimeDiff(nanoseconds: 0'i64)
|
||||||
|
|
||||||
|
@ -993,29 +992,29 @@ proc prepareProposersList*(vc: ValidatorClientRef,
|
||||||
proc isDefault*(reg: SignedValidatorRegistrationV1): bool =
|
proc isDefault*(reg: SignedValidatorRegistrationV1): bool =
|
||||||
(reg.message.timestamp == 0'u64) or (reg.message.gas_limit == 0'u64)
|
(reg.message.timestamp == 0'u64) or (reg.message.gas_limit == 0'u64)
|
||||||
|
|
||||||
proc isExpired*(vc: ValidatorClientRef,
|
proc isExpired(vc: ValidatorClientRef,
|
||||||
reg: SignedValidatorRegistrationV1, slot: Slot): bool =
|
reg: SignedValidatorRegistrationV1, slot: Slot): bool =
|
||||||
|
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/validator.md#registration-dissemination
|
||||||
|
# This specification suggests validators re-submit to builder software every
|
||||||
|
# `EPOCHS_PER_VALIDATOR_REGISTRATION_SUBMISSION` epochs.
|
||||||
let
|
let
|
||||||
regTime = fromUnix(int64(reg.message.timestamp))
|
regTime = fromUnix(int64(reg.message.timestamp))
|
||||||
regSlot =
|
regSlot =
|
||||||
block:
|
block:
|
||||||
let res = vc.beaconClock.toSlot(regTime)
|
let res = vc.beaconClock.toSlot(regTime)
|
||||||
if not(res.afterGenesis):
|
if not(res.afterGenesis):
|
||||||
# This case should not be happend, but it could in case of time jumps
|
# This case should not have happened, but it could in case of time
|
||||||
# (time could be modified by admin or ntpd).
|
# jumps (time could be modified by admin or ntpd).
|
||||||
return false
|
return false
|
||||||
uint64(res.slot)
|
uint64(res.slot)
|
||||||
|
|
||||||
if regSlot > slot:
|
if regSlot > slot:
|
||||||
# This case should not be happened, but if it happens (time could be
|
# This case should not have happened, but if it happens (time could be
|
||||||
# modified by admin or ntpd).
|
# modified by admin or ntpd).
|
||||||
false
|
false
|
||||||
else:
|
else:
|
||||||
if (slot - regSlot) div SLOTS_PER_EPOCH >=
|
(slot - regSlot) div SLOTS_PER_EPOCH >=
|
||||||
EPOCHS_BETWEEN_VALIDATOR_REGISTRATION:
|
EPOCHS_BETWEEN_VALIDATOR_REGISTRATION
|
||||||
false
|
|
||||||
else:
|
|
||||||
true
|
|
||||||
|
|
||||||
proc getValidatorRegistration(
|
proc getValidatorRegistration(
|
||||||
vc: ValidatorClientRef,
|
vc: ValidatorClientRef,
|
||||||
|
@ -1039,6 +1038,10 @@ proc getValidatorRegistration(
|
||||||
res.slot
|
res.slot
|
||||||
|
|
||||||
if cached.isDefault() or vc.isExpired(cached, currentSlot):
|
if cached.isDefault() or vc.isExpired(cached, currentSlot):
|
||||||
|
if not cached.isDefault():
|
||||||
|
# Want to send it to relay, but not recompute perfectly fine cache
|
||||||
|
return ok(PendingValidatorRegistration(registration: cached, future: nil))
|
||||||
|
|
||||||
let feeRecipient = vc.getFeeRecipient(validator.pubkey, vindex,
|
let feeRecipient = vc.getFeeRecipient(validator.pubkey, vindex,
|
||||||
currentSlot.epoch())
|
currentSlot.epoch())
|
||||||
if feeRecipient.isNone():
|
if feeRecipient.isNone():
|
||||||
|
|
Loading…
Reference in New Issue