remove expensive logging from function called in prepareBeaconProposer inner loop (#5776)

This commit is contained in:
tersec 2024-01-17 22:58:46 +00:00 committed by GitHub
parent 0775a48420
commit 36545e1d84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 14 deletions

View File

@ -1071,11 +1071,21 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
dres.get()
currentEpoch = node.beaconClock.now.slotOrZero.epoch
var
numUpdated = 0
numRefreshed = 0
for proposerData in body:
node.dynamicFeeRecipientsStore[].addMapping(
proposerData.validator_index,
proposerData.fee_recipient,
currentEpoch)
if node.dynamicFeeRecipientsStore[].addMapping(
proposerData.validator_index,
proposerData.fee_recipient,
currentEpoch):
inc numUpdated
else:
inc numRefreshed
info "Prepared beacon proposers",
numUpdatedFeeRecipients = numUpdated,
numRefreshedFeeRecipients = numRefreshed
return RestApiResponse.response("", Http200, "text/plain")

View File

@ -7,7 +7,7 @@
import
std/tables,
stew/results,
results,
chronicles,
../datatypes/base
@ -24,24 +24,20 @@ type
func init*(T: type DynamicFeeRecipientsStore): T =
T(mappings: initTable[ValidatorIndex, Entry]())
proc addMapping*(store: var DynamicFeeRecipientsStore,
func addMapping*(store: var DynamicFeeRecipientsStore,
validator: ValidatorIndex,
feeRecipient: Eth1Address,
currentEpoch: Epoch) =
currentEpoch: Epoch): bool =
var updated = false
store.mappings.withValue(validator, entry) do:
updated = not (entry[].recipient == feeRecipient)
updated = entry[].recipient != feeRecipient
entry[] = Entry(recipient: feeRecipient, addedAt: currentEpoch)
do:
updated = true
store.mappings[validator] = Entry(recipient: feeRecipient,
addedAt: currentEpoch)
if updated:
info "Updating fee recipient",
validator, feeRecipient = feeRecipient.toHex(), currentEpoch
else:
debug "Refreshing fee recipient",
validator, feeRecipient = feeRecipient.toHex(), currentEpoch
updated
func getDynamicFeeRecipient*(store: var DynamicFeeRecipientsStore,
validator: ValidatorIndex,