diff --git a/core/txpool/immutable/accesscontrol/contract_creation_controller.go b/core/txpool/immutable/accesscontrol/contract_creation_controller.go
deleted file mode 100644
index a1d565183..000000000
--- a/core/txpool/immutable/accesscontrol/contract_creation_controller.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2024 The Immutable go-ethereum Authors
-// This file is part of the Immutable go-ethereum library.
-//
-// The Immutable go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The Immutable go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the Immutable go-ethereum library. If not, see .
-
-package accesscontrol
-
-import (
- "fmt"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
-)
-
-// ContractCreation is a an access controller that specifically targets transactions which is a contract creation transactions.
-type ContractCreation struct {
- // Map of filename to address provider
- providers map[string]AddressProvider
- // isAnAllowList indicates that it is an allowlist otherwise the inverse is a blocklist
- isAnAllowList bool
-}
-
-// NewContractCreation initializes an access controller that specifically controls contract creation txs.
-//
-// Parameters:
-// - filePaths: A slice of strings containing file paths to blocklist
-// files, usually an sdn file that comes in the format of xml
-// - isAnAllowList: Indicates if the controller is an allow controller or
-// a block controller.
-func NewContractCreation(filePaths []string, isAnAllowList bool) (*ContractCreation, error) {
- providers := make(map[string]AddressProvider, len(filePaths))
-
- for _, filename := range filePaths {
- sdnProvider, err := newCSVProvider(filename)
- if err != nil {
- return nil, fmt.Errorf("couldn't initialize access controller provider: %w", err)
- }
- providers[filename] = sdnProvider
- }
-
- return &ContractCreation{
- providers: providers,
- isAnAllowList: isAnAllowList,
- }, nil
-}
-
-func (c *ContractCreation) IsBlocklist() bool {
- return !c.isAnAllowList
-}
-
-func (c *ContractCreation) IsAllowed(addr common.Address, tx *types.Transaction) bool {
- // Only control contract creation transactions,
- // By definition contract creation has its tx.To() as nil.
- if tx.To() != nil {
- return true
- }
- for _, list := range c.providers {
- addresses := list.Provide()
- if _, exist := addresses[addr]; exist {
- return c.isAnAllowList
- }
- }
-
- // If the address is not in the list and it's not an allow list, return true
- return !c.isAnAllowList
-}
diff --git a/core/txpool/immutable/accesscontrol/contract_creation_controller_test.go b/core/txpool/immutable/accesscontrol/contract_creation_controller_test.go
deleted file mode 100644
index 9c86dea04..000000000
--- a/core/txpool/immutable/accesscontrol/contract_creation_controller_test.go
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2024 The Immutable go-ethereum Authors
-// This file is part of the Immutable go-ethereum library.
-//
-// The Immutable go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The Immutable go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the Immutable go-ethereum library. If not, see .
-
-package accesscontrol
-
-import (
- "testing"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
-)
-
-func TestImmutableAccessControl_ContractCreationController_IsAllowed(t *testing.T) {
- key, _ := crypto.GenerateKey()
- tests := []struct {
- name string
- providers map[string]AddressProvider
- addressToCheck common.Address
- tx *types.Transaction
- isAnAllowList bool
- expectedAllowed bool
- }{
- {
- name: "Address is in block list and tx is of contract creation",
- isAnAllowList: false,
- providers: map[string]AddressProvider{
- "list": &MockAddressProvider{
- addresses: map[common.Address]struct{}{
- common.HexToAddress("0x1234567890123456789012345678901234567890"): {},
- },
- },
- },
- tx: contractCreation(1234, 123, key),
- addressToCheck: common.HexToAddress("0x1234567890123456789012345678901234567890"),
- expectedAllowed: false,
- },
- {
- name: "Address is in block list and tx is not of contract creation",
- isAnAllowList: false,
- providers: map[string]AddressProvider{
- "list": &MockAddressProvider{
- addresses: map[common.Address]struct{}{
- common.HexToAddress("0x1234567890123456789012345678901234567890"): {},
- },
- },
- },
- tx: transaction(1234, 123, key),
- addressToCheck: common.HexToAddress("0x1234567890123456789012345678901234567890"),
- expectedAllowed: true,
- },
- {
- name: "Empty blocklist but tx is of contract creation",
- isAnAllowList: false,
- providers: map[string]AddressProvider{
- "list": &MockAddressProvider{
- addresses: map[common.Address]struct{}{},
- },
- },
- tx: contractCreation(1234, 123, key),
- addressToCheck: common.HexToAddress("0x11111111111111111111111111"),
- expectedAllowed: true,
- },
- {
- name: "Nil blocklist sets but tx is of contract creation",
- isAnAllowList: false,
- providers: map[string]AddressProvider{
- "list": &MockAddressProvider{
- addresses: nil,
- },
- },
- tx: contractCreation(1234, 123, key),
- addressToCheck: common.HexToAddress("0x11111111111111111111111111"),
- expectedAllowed: true,
- },
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- controller := &ContractCreation{
- providers: test.providers,
- isAnAllowList: test.isAnAllowList,
- }
-
- allowed := controller.IsAllowed(test.addressToCheck, test.tx)
-
- if allowed != test.expectedAllowed {
- t.Errorf("Expected allowed=%t, got allowed=%t", test.expectedAllowed, allowed)
- }
- })
- }
-}
diff --git a/core/txpool/immutable/accesscontrol/controller_test.go b/core/txpool/immutable/accesscontrol/controller_test.go
index 6840d5f55..81e235dfb 100644
--- a/core/txpool/immutable/accesscontrol/controller_test.go
+++ b/core/txpool/immutable/accesscontrol/controller_test.go
@@ -81,6 +81,19 @@ func TestImmutableAccessControl_Controller_IsAllowed(t *testing.T) {
addressToCheck: common.HexToAddress("0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefab"),
expectedAllowed: true,
},
+ {
+ name: "AddressIsEmpty",
+ isAnAllowList: false,
+ providers: map[string]AddressProvider{
+ "list": &MockAddressProvider{
+ addresses: map[common.Address]struct{}{
+ common.HexToAddress("0x1234567890123456789012345678901234567890"): {},
+ },
+ },
+ },
+ addressToCheck: common.Address{},
+ expectedAllowed: true,
+ },
{
name: "AddressInAllowedAddresses",
isAnAllowList: true,
diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go
index 8da35413a..761133119 100644
--- a/core/txpool/legacypool/legacypool.go
+++ b/core/txpool/legacypool/legacypool.go
@@ -324,7 +324,8 @@ func (pool *LegacyPool) FilterWithError(tx *types.Transaction) error {
// Check for every access controllers that this transaction is allowed to go through
for _, accessControl := range pool.accessControllers {
if !accessControl.IsAllowed(from, tx) {
- log.Warn("Transaction is not allowed by access control", "from", from, "tx", tx.Hash(), "isBlockList", accessControl.IsBlocklist())
+ log.Warn("Transaction is not allowed by access control",
+ "from", from, "to", tx.To(), "tx", tx.Hash(), "isBlockList", accessControl.IsBlocklist())
// If any access control doesn't allow
return txpool.ErrTxIsUnauthorized
}