Skip to content

Commit

Permalink
Merge pull request #29 from ava-labs/prevent-prohibited-addresses-map
Browse files Browse the repository at this point in the history
simplify prevent address set
  • Loading branch information
aaronbuchwald authored Feb 26, 2022
2 parents fe180ed + 0507fb1 commit 50f6233
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,20 @@ import (
"github.com/holiman/uint256"
)

var (
prohibitedAddresses = append(
[]common.Address{constants.BlackholeAddr},
precompile.PrecompileAddresses...,
)
prohibitedAddressesSet map[common.Address]struct{}
)
var prohibitedAddresses = map[common.Address]struct{}{
constants.BlackholeAddr: {},
}

func init() {
prohibitedAddressesSet = make(map[common.Address]struct{})
for _, addr := range prohibitedAddresses {
prohibitedAddressesSet[addr] = struct{}{}
for _, addr := range precompile.PrecompileAddresses {
prohibitedAddresses[addr] = struct{}{}
}
}

// IsProhibited returns true if [addr] is in the prohibited list of addresses which should
// not be allowed as an EOA or newly created contract address.
func IsProhibited(addr common.Address) bool {
_, ok := prohibitedAddressesSet[addr]
_, ok := prohibitedAddresses[addr]
return ok
}

Expand Down

0 comments on commit 50f6233

Please sign in to comment.