From 8f0fe91d26380ee46918da512ae68eea9eacce66 Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Thu, 3 Apr 2025 23:29:32 +0100 Subject: [PATCH 01/12] Admin controls for fee currency blocklist --- eth/api_admin.go | 33 ++++++++++++++++++ miner/currency_blocklist.go | 69 +++++++++++++++++++++++++++++++++++-- miner/miner.go | 33 ++++++++++++++++++ miner/worker.go | 12 ++++--- 4 files changed, 140 insertions(+), 7 deletions(-) diff --git a/eth/api_admin.go b/eth/api_admin.go index 4a3ccb84e8..468f22b7df 100644 --- a/eth/api_admin.go +++ b/eth/api_admin.go @@ -24,6 +24,7 @@ import ( "os" "strings" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" @@ -141,3 +142,35 @@ func (api *AdminAPI) ImportChain(file string) (bool, error) { } return true, nil } + +// GetBlocklistFeeCurrencies returns the fee currencies in the blocklist mapped +// to their expiry Unix timestamp. Note that the parameter 'includeDisabled' +// determines if the map should contain fee currencies for which blocking has +// been manually disabled. +func (api *AdminAPI) GetBlocklistFeeCurrencies(includeDisabled bool) map[common.Address]uint64 { + return api.eth.Miner().BlocklistFeeCurrencies(includeDisabled) +} + +// DisableBlocklistFeeCurrencies disables blocking on the given currencies, for currencies that +// are already disabled this is a no-op. +func (api *AdminAPI) DisableBlocklistFeeCurrencies(currencies []common.Address) { + api.eth.Miner().DisableBlocklistFeeCurrencies(currencies) +} + +// EnableBlocklistFeeCurrencies enables blocking on the given currencies, for currencies that +// are already enabled this is a no-op. +func (api *AdminAPI) EnableBlocklistFeeCurrencies(currencies []common.Address) { + api.eth.Miner().EnableBlocklistFeeCurrencies(currencies) +} + +// GetDisabledBlocklistFeeCurrencies returns the currencies for which blocking is currently +// manually disabled. +func (api *AdminAPI) GetDisabledBlocklistFeeCurrencies() []common.Address { + return api.eth.Miner().DisabledBlocklistFeeCurrencies() +} + +// UnblockFeeCurrency removes a fee currency from the fee currency blocklist, +// if the currency was present true is returned. +func (api *AdminAPI) UnblockFeeCurrency(address common.Address) bool { + return api.eth.Miner().UnblockFeeCurrency(address) +} diff --git a/miner/currency_blocklist.go b/miner/currency_blocklist.go index 4081a2eb81..49dd75a75b 100644 --- a/miner/currency_blocklist.go +++ b/miner/currency_blocklist.go @@ -18,24 +18,89 @@ type AddressBlocklist struct { // will get evicted when evict() is called headerEvictionTimeoutSeconds uint64 oldestHeader *types.Header + + // disabledCurrencies is the set of currencies for which the blocklist + // functionality has been manually disabled. + disabledCurrencies map[common.Address]struct{} } func NewAddressBlocklist() *AddressBlocklist { - return &AddressBlocklist{ + bl := &AddressBlocklist{ mux: &sync.RWMutex{}, currencies: map[common.Address]*types.Header{}, headerEvictionTimeoutSeconds: EvictionTimeoutSeconds, oldestHeader: nil, + disabledCurrencies: make(map[common.Address]struct{}), } + return bl +} + +// BlocklistFeeCurrencies returns the current blocklist, a set of fee currency +// addresses mapped to their expiry Unix timestamp. Note that the parameter +// 'includeDisabled' determines if the map should contain fee currencies for +// which blocking has been manually disabled. +func (b *AddressBlocklist) Blocklist(includeDisabled bool) map[common.Address]uint64 { + b.mux.RLock() + defer b.mux.RUnlock() + result := make(map[common.Address]uint64, len(b.currencies)) + for currency, addedHeader := range b.currencies { + result[currency] = addedHeader.Time + b.headerEvictionTimeoutSeconds + } + return result +} + +// EnableBlocking enables blocking on the given currencies, for currencies that +// are already enabled this is a no-op. +func (b *AddressBlocklist) EnableBlocking(currencies []common.Address) { + b.mux.Lock() + defer b.mux.Unlock() + for _, currency := range currencies { + b.disabledCurrencies[currency] = struct{}{} + } +} + +// DisableBlocking disables blocking on the given currencies, for currencies that +// are already disabled this is a no-op. +func (b *AddressBlocklist) DisableBlocking(currencies []common.Address) { + b.mux.Lock() + defer b.mux.Unlock() + for _, currency := range currencies { + delete(b.disabledCurrencies, currency) + } +} + +// DisabledCurrencies returns the currencies for which blocking is currently +// manually disabled. +func (b *AddressBlocklist) DisabledCurencies() []common.Address { + b.mux.RLock() + defer b.mux.RUnlock() + result := make([]common.Address, 0, len(b.disabledCurrencies)) + for currency := range b.disabledCurrencies { + result = append(result, currency) + } + return result +} + +// BlockingEnabled returns whether blocking is enabled for the given currency. +func (b *AddressBlocklist) BlockingEnabled(currency common.Address) bool { + b.mux.RLock() + defer b.mux.RUnlock() + _, disabled := b.disabledCurrencies[currency] + return !disabled } +// FilterAllowlist returns allowlist with any blocked and not disabled +// currencies removed. It accepts the latest header so that it may update the +// blocklist by evicting any blocked fee currencies that have exceeded their +// timeout before it proceeds to filter the allowlist. func (b *AddressBlocklist) FilterAllowlist(allowlist common.AddressSet, latest *types.Header) common.AddressSet { b.mux.RLock() defer b.mux.RUnlock() filtered := common.AddressSet{} for a := range allowlist { - if !b.isBlocked(a, latest) { + _, disabled := b.disabledCurrencies[a] + if !b.isBlocked(a, latest) && !disabled { filtered[a] = struct{}{} } } diff --git a/miner/miner.go b/miner/miner.go index 080000a530..ab742bb4fd 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -231,6 +231,39 @@ func (miner *Miner) getPending() *newPayloadResult { return ret } +// BlocklistFeeCurrencies returns the fee currencies in the blocklist mapped to +// their expiry Unix timestamp. Note that the parameter 'includeDisabled' +// determines if the map should contain fee currencies for which blocking has +// been manually disabled. +func (miner *Miner) BlocklistFeeCurrencies(includeDisabled bool) map[common.Address]uint64 { + return miner.feeCurrencyBlocklist.Blocklist(includeDisabled) +} + +// DisableBlocklistFeeCurrencies disables blocking on the given currencies, for currencies that +// are already disabled this is a no-op. +func (miner *Miner) DisableBlocklistFeeCurrencies(currencies []common.Address) { + miner.feeCurrencyBlocklist.DisableBlocking(currencies) +} + +// DisabledBlocklistFeeCurrencies returns the currencies for which blocking is currently +// manually disabled. +func (miner *Miner) DisabledBlocklistFeeCurrencies() []common.Address { + return miner.feeCurrencyBlocklist.DisabledCurencies() +} + +// EnableBlocklistFeeCurrencies enables blocking on the given currencies, for currencies that +// are already enabled this is a no-op. +func (miner *Miner) EnableBlocklistFeeCurrencies(currencies []common.Address) { + miner.feeCurrencyBlocklist.EnableBlocking(currencies) +} + +// UnblockFeeCurrency removes a fee currency from the fee currency blocklist, +// if the currency was present true is returned. +func (miner *Miner) UnblockFeeCurrency(address common.Address) bool { + removed := miner.feeCurrencyBlocklist.Remove(address) + return removed +} + func (miner *Miner) Close() { miner.lifeCtxCancel() } diff --git a/miner/worker.go b/miner/worker.go index 2515c99c1a..e111e04018 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -424,7 +424,7 @@ func (miner *Miner) commitTransaction(env *environment, tx *types.Transaction) e "fee-currency", tx.FeeCurrency(), "error", err.Error(), ) - miner.blockFeeCurrency(env, *tx.FeeCurrency(), err) + miner.registerFeeCurrencyTxFailure(env, tx, err) } return err } @@ -834,14 +834,16 @@ func (miner *Miner) validateParams(genParams *generateParams) (time.Duration, er return time.Duration(blockTime) * time.Second, nil } -func (miner *Miner) blockFeeCurrency(env *environment, feeCurrency common.Address, err error) { +func (miner *Miner) registerFeeCurrencyTxFailure(env *environment, tx *types.Transaction, err error) { // the fee-currency is still in the allowlist of this environment, // so set the fee-currency block gas limit to 0 to prevent other // transactions. - pool := env.multiGasPool.PoolFor(&feeCurrency) - pool.SetGas(0) + if miner.feeCurrencyBlocklist.BlockingEnabled(*tx.FeeCurrency()) { + pool := env.multiGasPool.PoolFor(tx.FeeCurrency()) + pool.SetGas(0) + } // also add the fee-currency to a worker-wide blocklist, // so that they are not allowlisted in the following blocks // (only locally in the txpool, not consensus-critical) - miner.feeCurrencyBlocklist.Add(feeCurrency, *env.header) + miner.feeCurrencyBlocklist.Add(*tx.FeeCurrency(), *env.header) } From cd4f54370392bd1371a494ff2ed2f17f3878ec53 Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Fri, 4 Apr 2025 00:29:41 +0100 Subject: [PATCH 02/12] Add metrics for blocklist --- miner/currency_blocklist.go | 4 +++- miner/miner.go | 3 +++ miner/worker.go | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/miner/currency_blocklist.go b/miner/currency_blocklist.go index 49dd75a75b..327f377543 100644 --- a/miner/currency_blocklist.go +++ b/miner/currency_blocklist.go @@ -129,14 +129,16 @@ func (b *AddressBlocklist) Remove(currency common.Address) bool { return ok } -func (b *AddressBlocklist) Add(currency common.Address, head types.Header) { +func (b *AddressBlocklist) Add(currency common.Address, head types.Header) bool { b.mux.Lock() defer b.mux.Unlock() + _, existed := b.currencies[currency] if b.oldestHeader == nil || b.oldestHeader.Time > head.Time { b.oldestHeader = &head } b.currencies[currency] = &head + return !existed } func (b *AddressBlocklist) Evict(latest *types.Header) []common.Address { diff --git a/miner/miner.go b/miner/miner.go index ab742bb4fd..4a494a2143 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -261,6 +261,9 @@ func (miner *Miner) EnableBlocklistFeeCurrencies(currencies []common.Address) { // if the currency was present true is returned. func (miner *Miner) UnblockFeeCurrency(address common.Address) bool { removed := miner.feeCurrencyBlocklist.Remove(address) + if removed { + feeCurrenciesInBlocklistCounter.Dec(1) + } return removed } diff --git a/miner/worker.go b/miner/worker.go index e111e04018..da607529f2 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -61,6 +61,8 @@ var ( txConditionalMinedTimer = metrics.NewRegisteredTimer("miner/transactionConditional/elapsedtime", nil) txInteropRejectedCounter = metrics.NewRegisteredCounter("miner/transactionInterop/rejected", nil) + + feeCurrenciesInBlocklistCounter = metrics.NewRegisteredCounter("miner/blocklist/feeCurrency/blocked", nil) ) // environment is the worker's current environment and holds all @@ -340,6 +342,7 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir "evicted-fee-currencies", evicted, "eviction-timeout-seconds", EvictionTimeoutSeconds, ) + feeCurrenciesInBlocklistCounter.Dec(int64(len(evicted))) } env.feeCurrencyAllowlist = miner.feeCurrencyBlocklist.FilterAllowlist( common.CurrencyAllowlist(env.feeCurrencyContext.ExchangeRates), @@ -845,5 +848,7 @@ func (miner *Miner) registerFeeCurrencyTxFailure(env *environment, tx *types.Tra // also add the fee-currency to a worker-wide blocklist, // so that they are not allowlisted in the following blocks // (only locally in the txpool, not consensus-critical) - miner.feeCurrencyBlocklist.Add(*tx.FeeCurrency(), *env.header) + if miner.feeCurrencyBlocklist.Add(*tx.FeeCurrency(), *env.header) { + feeCurrenciesInBlocklistCounter.Inc(1) + } } From 11371e85fb12620b6d6d06b837cb4e98a161d55c Mon Sep 17 00:00:00 2001 From: piersy Date: Fri, 4 Apr 2025 13:55:07 +0100 Subject: [PATCH 03/12] Update miner/currency_blocklist.go Co-authored-by: Seola Oh --- miner/currency_blocklist.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/currency_blocklist.go b/miner/currency_blocklist.go index 327f377543..bfd790576d 100644 --- a/miner/currency_blocklist.go +++ b/miner/currency_blocklist.go @@ -35,7 +35,7 @@ func NewAddressBlocklist() *AddressBlocklist { return bl } -// BlocklistFeeCurrencies returns the current blocklist, a set of fee currency +// Blocklist returns the current blocklist, a set of fee currency // addresses mapped to their expiry Unix timestamp. Note that the parameter // 'includeDisabled' determines if the map should contain fee currencies for // which blocking has been manually disabled. From dfffb19e46d0f3a828ba83fe3f2fb5e975ca73ab Mon Sep 17 00:00:00 2001 From: piersy Date: Fri, 4 Apr 2025 13:58:08 +0100 Subject: [PATCH 04/12] Update miner/currency_blocklist.go Co-authored-by: Seola Oh --- miner/currency_blocklist.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/currency_blocklist.go b/miner/currency_blocklist.go index bfd790576d..8016ac1b36 100644 --- a/miner/currency_blocklist.go +++ b/miner/currency_blocklist.go @@ -71,7 +71,7 @@ func (b *AddressBlocklist) DisableBlocking(currencies []common.Address) { // DisabledCurrencies returns the currencies for which blocking is currently // manually disabled. -func (b *AddressBlocklist) DisabledCurencies() []common.Address { +func (b *AddressBlocklist) DisabledCurrencies() []common.Address { b.mux.RLock() defer b.mux.RUnlock() result := make([]common.Address, 0, len(b.disabledCurrencies)) From 6372d4c631704b3916b1c5d9dff7562c828734e4 Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Fri, 4 Apr 2025 14:00:15 +0100 Subject: [PATCH 05/12] Swap enable/disable blocking, their implementations were swapped. --- miner/currency_blocklist.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/miner/currency_blocklist.go b/miner/currency_blocklist.go index 8016ac1b36..c68b6a380d 100644 --- a/miner/currency_blocklist.go +++ b/miner/currency_blocklist.go @@ -49,9 +49,9 @@ func (b *AddressBlocklist) Blocklist(includeDisabled bool) map[common.Address]ui return result } -// EnableBlocking enables blocking on the given currencies, for currencies that -// are already enabled this is a no-op. -func (b *AddressBlocklist) EnableBlocking(currencies []common.Address) { +// DisableBlocking disables blocking on the given currencies, for currencies that +// are already disabled this is a no-op. +func (b *AddressBlocklist) DisableBlocking(currencies []common.Address) { b.mux.Lock() defer b.mux.Unlock() for _, currency := range currencies { @@ -59,9 +59,9 @@ func (b *AddressBlocklist) EnableBlocking(currencies []common.Address) { } } -// DisableBlocking disables blocking on the given currencies, for currencies that -// are already disabled this is a no-op. -func (b *AddressBlocklist) DisableBlocking(currencies []common.Address) { +// EnableBlocking enables blocking on the given currencies, for currencies that +// are already enabled this is a no-op. +func (b *AddressBlocklist) EnableBlocking(currencies []common.Address) { b.mux.Lock() defer b.mux.Unlock() for _, currency := range currencies { From 21c364ee28eef876f922fe5e7820ada4f7d9ed5a Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Fri, 4 Apr 2025 14:04:19 +0100 Subject: [PATCH 06/12] Take into account includeDisabled when returning blocklist --- miner/currency_blocklist.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/miner/currency_blocklist.go b/miner/currency_blocklist.go index c68b6a380d..ef058d3044 100644 --- a/miner/currency_blocklist.go +++ b/miner/currency_blocklist.go @@ -44,6 +44,9 @@ func (b *AddressBlocklist) Blocklist(includeDisabled bool) map[common.Address]ui defer b.mux.RUnlock() result := make(map[common.Address]uint64, len(b.currencies)) for currency, addedHeader := range b.currencies { + if _, disabled := b.disabledCurrencies[currency]; disabled && !includeDisabled { + continue + } result[currency] = addedHeader.Time + b.headerEvictionTimeoutSeconds } return result From aad2830ff00f4f57e77bed21999ca13b1133f7a1 Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Fri, 4 Apr 2025 14:06:53 +0100 Subject: [PATCH 07/12] Fix method rename --- miner/miner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/miner.go b/miner/miner.go index 4a494a2143..cc04a7de07 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -248,7 +248,7 @@ func (miner *Miner) DisableBlocklistFeeCurrencies(currencies []common.Address) { // DisabledBlocklistFeeCurrencies returns the currencies for which blocking is currently // manually disabled. func (miner *Miner) DisabledBlocklistFeeCurrencies() []common.Address { - return miner.feeCurrencyBlocklist.DisabledCurencies() + return miner.feeCurrencyBlocklist.DisabledCurrencies() } // EnableBlocklistFeeCurrencies enables blocking on the given currencies, for currencies that From 6e2dc304e3078455363af4c8fb282442883fdb25 Mon Sep 17 00:00:00 2001 From: piersy Date: Fri, 4 Apr 2025 14:15:07 +0100 Subject: [PATCH 08/12] Update miner/currency_blocklist.go Co-authored-by: Seola Oh --- miner/currency_blocklist.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/currency_blocklist.go b/miner/currency_blocklist.go index ef058d3044..1e2f089e62 100644 --- a/miner/currency_blocklist.go +++ b/miner/currency_blocklist.go @@ -103,7 +103,7 @@ func (b *AddressBlocklist) FilterAllowlist(allowlist common.AddressSet, latest * filtered := common.AddressSet{} for a := range allowlist { _, disabled := b.disabledCurrencies[a] - if !b.isBlocked(a, latest) && !disabled { + if !b.isBlocked(a, latest) || disabled { filtered[a] = struct{}{} } } From 9b32109d0b85fd59620c2e254f7779155a33d574 Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Fri, 4 Apr 2025 14:19:22 +0100 Subject: [PATCH 09/12] Update comment --- miner/currency_blocklist.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/miner/currency_blocklist.go b/miner/currency_blocklist.go index 1e2f089e62..60d5b46aa9 100644 --- a/miner/currency_blocklist.go +++ b/miner/currency_blocklist.go @@ -93,9 +93,8 @@ func (b *AddressBlocklist) BlockingEnabled(currency common.Address) bool { } // FilterAllowlist returns allowlist with any blocked and not disabled -// currencies removed. It accepts the latest header so that it may update the -// blocklist by evicting any blocked fee currencies that have exceeded their -// timeout before it proceeds to filter the allowlist. +// currencies removed. It accepts the latest header so that it may provide a +// view of the blocklist consistent with that header. func (b *AddressBlocklist) FilterAllowlist(allowlist common.AddressSet, latest *types.Header) common.AddressSet { b.mux.RLock() defer b.mux.RUnlock() From 4f72b46e1834fa44731bbda0e62854c518c1fb52 Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Fri, 4 Apr 2025 15:48:36 +0100 Subject: [PATCH 10/12] Add tests for AddressBlocklist --- miner/currency_blocklist_test.go | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/miner/currency_blocklist_test.go b/miner/currency_blocklist_test.go index a26d7392ae..60ea771a01 100644 --- a/miner/currency_blocklist_test.go +++ b/miner/currency_blocklist_test.go @@ -70,6 +70,8 @@ func TestBlocklistAddAfterEviction(t *testing.T) { func TestBlocklistRemove(t *testing.T) { bl := NewAddressBlocklist() + + bl.Remove(feeCurrency1) bl.Add(feeCurrency1, header) bl.Add(feeCurrency2, header) bl.Remove(feeCurrency1) @@ -91,3 +93,64 @@ func TestBlocklistAddAfterRemove(t *testing.T) { assert.True(t, bl.IsBlocked(feeCurrency2, HeaderAfter(*header2, int64(EvictionTimeoutSeconds)-1))) assert.False(t, bl.IsBlocked(feeCurrency2, HeaderAfter(*header2, int64(EvictionTimeoutSeconds)+1))) } + +func TestDisableEnableBlocking(t *testing.T) { + bl := NewAddressBlocklist() + bl.Add(feeCurrency1, header) + bl.Add(feeCurrency2, header) + + assert.True(t, bl.BlockingEnabled(feeCurrency1)) + assert.True(t, bl.BlockingEnabled(feeCurrency2)) + + allowlist := common.NewAddressSet(feeCurrency1, feeCurrency2) + + assert.Equal(t, common.NewAddressSet(), bl.FilterAllowlist(allowlist, &header)) + + bl.DisableBlocking([]common.Address{feeCurrency1}) + assert.False(t, bl.BlockingEnabled(feeCurrency1)) + assert.Equal(t, common.NewAddressSet(feeCurrency1), bl.FilterAllowlist(allowlist, &header)) + + bl.DisableBlocking([]common.Address{feeCurrency2}) + assert.False(t, bl.BlockingEnabled(feeCurrency2)) + assert.Equal(t, allowlist, bl.FilterAllowlist(allowlist, &header)) + + bl.EnableBlocking([]common.Address{feeCurrency2, feeCurrency1}) + assert.True(t, bl.BlockingEnabled(feeCurrency2)) + assert.True(t, bl.BlockingEnabled(feeCurrency1)) + assert.Equal(t, common.NewAddressSet(), bl.FilterAllowlist(allowlist, &header)) +} + +func TestBlocklistRetrieval(t *testing.T) { + bl := NewAddressBlocklist() + bl.Add(feeCurrency1, header) + bl.Add(feeCurrency2, header) + + expiryTime := header.Time + EvictionTimeoutSeconds + + allCurrencies := map[common.Address]uint64{ + feeCurrency1: expiryTime, + feeCurrency2: expiryTime, + } + assert.Equal(t, allCurrencies, bl.Blocklist(true)) + assert.Equal(t, allCurrencies, bl.Blocklist(false)) + + bl.DisableBlocking([]common.Address{feeCurrency1}) + assert.Equal(t, allCurrencies, bl.Blocklist(true)) + oneCurrency := map[common.Address]uint64{ + feeCurrency2: expiryTime, + } + assert.Equal(t, oneCurrency, bl.Blocklist(false)) +} + +func TestDisabledCurrenciesRetrieval(t *testing.T) { + bl := NewAddressBlocklist() + disabledCurrencies := []common.Address{feeCurrency1, feeCurrency2} + + assert.Empty(t, bl.DisabledCurrencies()) + + bl.DisableBlocking(disabledCurrencies) + assert.ElementsMatch(t, disabledCurrencies, bl.DisabledCurrencies()) + + bl.EnableBlocking([]common.Address{feeCurrency1}) + assert.ElementsMatch(t, []common.Address{feeCurrency2}, bl.DisabledCurrencies()) +} From 5dd4136df43955a6aa702d88742eb25199473668 Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Mon, 7 Apr 2025 13:02:08 +0100 Subject: [PATCH 11/12] Add explanatory comments --- miner/currency_blocklist_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/miner/currency_blocklist_test.go b/miner/currency_blocklist_test.go index 60ea771a01..50c92771d7 100644 --- a/miner/currency_blocklist_test.go +++ b/miner/currency_blocklist_test.go @@ -71,7 +71,10 @@ func TestBlocklistAddAfterEviction(t *testing.T) { func TestBlocklistRemove(t *testing.T) { bl := NewAddressBlocklist() + // Check that removing a fee currency from an empty blocklist doesn't panic. bl.Remove(feeCurrency1) + + // Check that removal of existing fee currency works. bl.Add(feeCurrency1, header) bl.Add(feeCurrency2, header) bl.Remove(feeCurrency1) From b356f6e1b5bb62a7549abb9d4019d85c71cdfa5e Mon Sep 17 00:00:00 2001 From: Piers Powlesland Date: Mon, 7 Apr 2025 13:09:22 +0100 Subject: [PATCH 12/12] Fix typo --- miner/currency_blocklist_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/currency_blocklist_test.go b/miner/currency_blocklist_test.go index 50c92771d7..b070945af5 100644 --- a/miner/currency_blocklist_test.go +++ b/miner/currency_blocklist_test.go @@ -71,7 +71,7 @@ func TestBlocklistAddAfterEviction(t *testing.T) { func TestBlocklistRemove(t *testing.T) { bl := NewAddressBlocklist() - // Check that removing a fee currency from an empty blocklist doesn't panic. + // Check that removing a fee currency from an empty blocklist doesn't panic. bl.Remove(feeCurrency1) // Check that removal of existing fee currency works.