diff --git a/beacon_chain/spec/eth2_apis/dynamic_fee_recipients.nim b/beacon_chain/spec/eth2_apis/dynamic_fee_recipients.nim index 79df5a607..f3fef5949 100644 --- a/beacon_chain/spec/eth2_apis/dynamic_fee_recipients.nim +++ b/beacon_chain/spec/eth2_apis/dynamic_fee_recipients.nim @@ -19,10 +19,21 @@ proc addMapping*(store: var DynamicFeeRecipientsStore, validator: ValidatorIndex, feeRecipient: Eth1Address, currentEpoch: Epoch) = - info "Updating fee recipient", - validator, feeRecipient = feeRecipient.toHex(), currentEpoch - store.mappings[validator] = Entry(recipient: feeRecipient, - addedAt: currentEpoch) + var + found, updated = false + store.mappings.withValue(validator, entry) do: + updated = not (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 func getDynamicFeeRecipient*(store: var DynamicFeeRecipientsStore, validator: ValidatorIndex, diff --git a/beacon_chain/spec/presets.nim b/beacon_chain/spec/presets.nim index 91de88002..0053dbf46 100644 --- a/beacon_chain/spec/presets.nim +++ b/beacon_chain/spec/presets.nim @@ -17,7 +17,7 @@ import export constants -export stint, ethtypes.toHex +export stint, ethtypes.toHex, ethtypes.`==` const # https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/phase0/beacon-chain.md#withdrawal-prefixes