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() dres.get()
currentEpoch = node.beaconClock.now.slotOrZero.epoch currentEpoch = node.beaconClock.now.slotOrZero.epoch
var
numUpdated = 0
numRefreshed = 0
for proposerData in body: for proposerData in body:
node.dynamicFeeRecipientsStore[].addMapping( if node.dynamicFeeRecipientsStore[].addMapping(
proposerData.validator_index, proposerData.validator_index,
proposerData.fee_recipient, proposerData.fee_recipient,
currentEpoch) currentEpoch):
inc numUpdated
else:
inc numRefreshed
info "Prepared beacon proposers",
numUpdatedFeeRecipients = numUpdated,
numRefreshedFeeRecipients = numRefreshed
return RestApiResponse.response("", Http200, "text/plain") return RestApiResponse.response("", Http200, "text/plain")

View File

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