Skip to content

Commit

Permalink
Rename whitelist to allowlist
Browse files Browse the repository at this point in the history
  • Loading branch information
ezdac committed Aug 15, 2024
1 parent be9fd59 commit 8bf5f3c
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions common/celo_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func CurrencyIntrinsicGasCost(i IntrinsicGasCosts, feeCurrency *Address) (uint64
return gasCost, true
}

func CurrencyWhitelist(exchangeRates ExchangeRates) []Address {
func CurrencyAllowlist(exchangeRates ExchangeRates) []Address {
addrs := make([]Address, len(exchangeRates))
i := 0
for k := range exchangeRates {
Expand All @@ -51,7 +51,7 @@ func CurrencyWhitelist(exchangeRates ExchangeRates) []Address {
return addrs
}

func IsCurrencyWhitelisted(exchangeRates ExchangeRates, feeCurrency *Address) bool {
func IsCurrencyAllowed(exchangeRates ExchangeRates, feeCurrency *Address) bool {
if feeCurrency == nil {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion common/celo_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestIsWhitelisted(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsCurrencyWhitelisted(exchangeRates, tt.feeCurrency); got != tt.want {
if got := IsCurrencyAllowed(exchangeRates, tt.feeCurrency); got != tt.want {
t.Errorf("IsWhitelisted() = %v, want %v", got, tt.want)
}
})
Expand Down
8 changes: 4 additions & 4 deletions core/celo_multi_gaspool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ type FeeCurrencyLimitMapping = map[FeeCurrency]float64
// pool for CELO
func NewMultiGasPool(
blockGasLimit uint64,
whitelist []FeeCurrency,
allowlist []FeeCurrency,
defaultLimit float64,
limitsMapping FeeCurrencyLimitMapping,
) *MultiGasPool {
pools := make(map[FeeCurrency]*GasPool, len(whitelist))
pools := make(map[FeeCurrency]*GasPool, len(allowlist))

for i := range whitelist {
currency := whitelist[i]
for i := range allowlist {
currency := allowlist[i]
fraction, ok := limitsMapping[currency]
if !ok {
fraction = defaultLimit
Expand Down
18 changes: 9 additions & 9 deletions core/celo_multi_gaspool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestMultiCurrencyGasPool(t *testing.T) {
testCases := []struct {
name string
feeCurrency *FeeCurrency
whitelist []FeeCurrency
allowlist []FeeCurrency
defaultLimit float64
limits FeeCurrencyLimitMapping
defaultPoolExpected bool
Expand All @@ -25,7 +25,7 @@ func TestMultiCurrencyGasPool(t *testing.T) {
{
name: "Empty whitelist, empty mapping, CELO uses default pool",
feeCurrency: nil,
whitelist: []FeeCurrency{},
allowlist: []FeeCurrency{},
defaultLimit: 0.9,
limits: map[FeeCurrency]float64{},
defaultPoolExpected: true,
Expand All @@ -34,7 +34,7 @@ func TestMultiCurrencyGasPool(t *testing.T) {
{
name: "Non-empty whitelist, non-empty mapping, CELO uses default pool",
feeCurrency: nil,
whitelist: []FeeCurrency{
allowlist: []FeeCurrency{
cUSDToken,
},
defaultLimit: 0.9,
Expand All @@ -47,7 +47,7 @@ func TestMultiCurrencyGasPool(t *testing.T) {
{
name: "Empty whitelist, empty mapping, non-whitelisted currency fallbacks to the default pool",
feeCurrency: &cUSDToken,
whitelist: []FeeCurrency{},
allowlist: []FeeCurrency{},
defaultLimit: 0.9,
limits: map[FeeCurrency]float64{},
defaultPoolExpected: true,
Expand All @@ -56,7 +56,7 @@ func TestMultiCurrencyGasPool(t *testing.T) {
{
name: "Non-empty whitelist, non-empty mapping, non-whitelisted currency uses default pool",
feeCurrency: &cEURToken,
whitelist: []FeeCurrency{
allowlist: []FeeCurrency{
cUSDToken,
},
defaultLimit: 0.9,
Expand All @@ -69,7 +69,7 @@ func TestMultiCurrencyGasPool(t *testing.T) {
{
name: "Non-empty whitelist, empty mapping, whitelisted currency uses default limit",
feeCurrency: &cUSDToken,
whitelist: []FeeCurrency{
allowlist: []FeeCurrency{
cUSDToken,
},
defaultLimit: 0.9,
Expand All @@ -80,7 +80,7 @@ func TestMultiCurrencyGasPool(t *testing.T) {
{
name: "Non-empty whitelist, non-empty mapping, configured whitelisted currency uses configured limits",
feeCurrency: &cUSDToken,
whitelist: []FeeCurrency{
allowlist: []FeeCurrency{
cUSDToken,
},
defaultLimit: 0.9,
Expand All @@ -93,7 +93,7 @@ func TestMultiCurrencyGasPool(t *testing.T) {
{
name: "Non-empty whitelist, non-empty mapping, unconfigured whitelisted currency uses default limit",
feeCurrency: &cEURToken,
whitelist: []FeeCurrency{
allowlist: []FeeCurrency{
cUSDToken,
cEURToken,
},
Expand All @@ -110,7 +110,7 @@ func TestMultiCurrencyGasPool(t *testing.T) {
t.Run(c.name, func(t *testing.T) {
mgp := NewMultiGasPool(
blockGasLimit,
c.whitelist,
c.allowlist,
c.defaultLimit,
c.limits,
)
Expand Down
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (st *StateTransition) preCheck() error {
if !st.evm.ChainConfig().IsCel2(st.evm.Context.Time) {
return ErrCel2NotEnabled
} else {
isWhiteListed := common.IsCurrencyWhitelisted(st.evm.Context.FeeCurrencyContext.ExchangeRates, msg.FeeCurrency)
isWhiteListed := common.IsCurrencyAllowed(st.evm.Context.FeeCurrencyContext.ExchangeRates, msg.FeeCurrency)
if !isWhiteListed {
log.Trace("fee currency not whitelisted", "fee currency address", msg.FeeCurrency)
return exchange.ErrNonWhitelistedFeeCurrency
Expand Down
2 changes: 1 addition & 1 deletion core/txpool/celo_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func CeloValidateTransaction(tx *types.Transaction, head *types.Header,
if err := ValidateTransaction(tx, head, signer, opts, currencyCtx); err != nil {
return err
}
if !common.IsCurrencyWhitelisted(currencyCtx.ExchangeRates, tx.FeeCurrency()) {
if !common.IsCurrencyAllowed(currencyCtx.ExchangeRates, tx.FeeCurrency()) {
return exchange.ErrNonWhitelistedFeeCurrency
}

Expand Down
2 changes: 1 addition & 1 deletion core/txpool/legacypool/celo_legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// and gasLimit. Returns drops and invalid txs.
func (pool *LegacyPool) filter(list *list, addr common.Address, gasLimit uint64) (types.Transactions, types.Transactions) {
// CELO: drop all transactions that no longer have a whitelisted currency
dropsWhitelist, invalidsWhitelist := list.FilterWhitelisted(pool.feeCurrencyContext.ExchangeRates)
dropsWhitelist, invalidsWhitelist := list.FilterAllowlisted(pool.feeCurrencyContext.ExchangeRates)
// Check from which currencies we need to get balances
currenciesInList := list.FeeCurrencies()
drops, invalids := list.Filter(pool.getBalances(addr, currenciesInList), gasLimit)
Expand Down
4 changes: 2 additions & 2 deletions core/txpool/legacypool/celo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/holiman/uint256"
)

func (l *list) FilterWhitelisted(rates common.ExchangeRates) (types.Transactions, types.Transactions) {
func (l *list) FilterAllowlisted(rates common.ExchangeRates) (types.Transactions, types.Transactions) {
removed := l.txs.Filter(func(tx *types.Transaction) bool {
return !common.IsCurrencyWhitelisted(rates, tx.FeeCurrency())
return !common.IsCurrencyAllowed(rates, tx.FeeCurrency())
})

if len(removed) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions core/txpool/legacypool/celo_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestFilterWhitelisted(t *testing.T) {
list.Add(txC(9, 1, 1, 10000, &curr1), DefaultConfig.PriceBump, nil, rates)
assert.Equal(t, uint64(30000), list.TotalCostFor(&curr2).Uint64())

removed, invalids := list.FilterWhitelisted(common.ExchangeRates{curr1: nil, curr3: nil})
removed, invalids := list.FilterAllowlisted(common.ExchangeRates{curr1: nil, curr3: nil})
assert.Len(t, removed, 1)
assert.Len(t, invalids, 0)
assert.Equal(t, removed[0], toBeRemoved)
Expand All @@ -101,7 +101,7 @@ func TestFilterWhitelistedStrict(t *testing.T) {
toBeInvalid := txC(9, 1, 1, 10000, &curr3)
list.Add(toBeInvalid, DefaultConfig.PriceBump, nil, rates)

removed, invalids := list.FilterWhitelisted(common.ExchangeRates{curr1: nil, curr3: nil})
removed, invalids := list.FilterAllowlisted(common.ExchangeRates{curr1: nil, curr3: nil})
assert.Len(t, removed, 1)
assert.Len(t, invalids, 1)
assert.Equal(t, removed[0], toBeRemoved)
Expand Down
8 changes: 4 additions & 4 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type environment struct {
tcount int // tx count in cycle
gasPool *core.GasPool // available gas used to pack transactions
multiGasPool *core.MultiGasPool // available per-fee-currency gas used to pack transactions
feeCurrencyWhitelist []common.Address
feeCurrencyAllowlist []common.Address
coinbase common.Address

header *types.Header
Expand Down Expand Up @@ -859,7 +859,7 @@ func (w *worker) commitTransactions(env *environment, plainTxs, blobTxs *transac
if env.multiGasPool == nil {
env.multiGasPool = core.NewMultiGasPool(
env.header.GasLimit,
env.feeCurrencyWhitelist,
env.feeCurrencyAllowlist,
w.config.FeeCurrencyDefault,
w.config.FeeCurrencyLimits,
)
Expand Down Expand Up @@ -1137,7 +1137,7 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
return nil, err
}
context := core.NewEVMBlockContext(header, w.chain, nil, w.chainConfig, env.state)
env.feeCurrencyWhitelist = common.CurrencyWhitelist(context.FeeCurrencyContext.ExchangeRates)
env.feeCurrencyAllowlist = common.CurrencyAllowlist(context.FeeCurrencyContext.ExchangeRates)
if header.ParentBeaconRoot != nil {
vmenv := vm.NewEVM(context, vm.TxContext{}, env.state, w.chainConfig, vm.Config{})
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, env.state)
Expand Down Expand Up @@ -1220,7 +1220,7 @@ func (w *worker) generateWork(genParams *generateParams) *newPayloadResult {
if work.multiGasPool == nil {
work.multiGasPool = core.NewMultiGasPool(
work.header.GasLimit,
work.feeCurrencyWhitelist,
work.feeCurrencyAllowlist,
w.config.FeeCurrencyDefault,
w.config.FeeCurrencyLimits,
)
Expand Down

0 comments on commit 8bf5f3c

Please sign in to comment.