Skip to content

Commit 262fffe

Browse files
committed
remove blacklist functionality from transaction pool
1 parent 394d36f commit 262fffe

File tree

15 files changed

+13
-226
lines changed

15 files changed

+13
-226
lines changed

cmd/config/config_migrations_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ Version = "1.0.2"
7070
RpcFilterFile = "./.hmy/rpc_filter.txt"
7171
7272
[TxPool]
73-
BlacklistFile = "./.hmy/blacklist.txt"
7473
LocalAccountsFile = "./.hmy/locals.txt"
7574
AccountQueue = 64
7675
GlobalQueue = 5120
@@ -145,7 +144,6 @@ Version = "1.0.3"
145144
RpcFilterFile = "./.hmy/rpc_filter.txt"
146145
147146
[TxPool]
148-
BlacklistFile = "./.hmy/blacklist.txt"
149147
LocalAccountsFile = "./.hmy/locals.txt"
150148
AccountQueue = 64
151149
GlobalQueue = 5120
@@ -232,7 +230,6 @@ Version = "1.0.4"
232230
MinPeers = 6
233231
234232
[TxPool]
235-
BlacklistFile = "./.hmy/blacklist.txt"
236233
LocalAccountsFile = "./.hmy/locals.txt"
237234
AccountQueue = 64
238235
GlobalQueue = 5120
@@ -326,7 +323,6 @@ Version = "1.0.4"
326323
CacheSize = 512
327324
328325
[TxPool]
329-
BlacklistFile = "./.hmy/blacklist.txt"
330326
LocalAccountsFile = "./.hmy/locals.txt"
331327
AllowedTxsFile = "./.hmy/allowedtxs.txt"
332328
AccountQueue = 64

cmd/config/config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ Version = "1.0.4"
8383
ListenAddr = "127.0.0.1:6060"
8484
8585
[TxPool]
86-
BlacklistFile = "./.hmy/blacklist.txt"
8786
LocalAccountsFile = "./.hmy/locals.txt"
8887
AllowedTxsFile = "./.hmy/allowedtxs.txt"
8988
AccountQueue = 64

cmd/config/default.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ var defaultConfig = harmonyconfig.HarmonyConfig{
9292
KMSConfigFile: "",
9393
},
9494
TxPool: harmonyconfig.TxPoolConfig{
95-
BlacklistFile: "./.hmy/blacklist.txt",
96-
AllowedTxsFile: "./.hmy/allowedtxs.txt",
9795
RosettaFixFile: "",
9896
AccountSlots: core.DefaultTxPoolConfig.AccountSlots,
9997
LocalAccountsFile: "./.hmy/locals.txt",

cmd/config/flags.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ var (
159159
tpGlobalQueueFlag,
160160
tpLifetimeFlag,
161161
rosettaFixFileFlag,
162-
tpBlacklistFileFlag,
163-
legacyTPBlacklistFileFlag,
164162
localAccountsFileFlag,
165-
allowedTxsFileFlag,
166163
tpPriceLimitFlag,
167164
tpPriceBumpFlag,
168165
}
@@ -1292,32 +1289,16 @@ var (
12921289
Usage: "number of executable transaction slots guaranteed per account",
12931290
DefValue: int(defaultConfig.TxPool.AccountSlots),
12941291
}
1295-
tpBlacklistFileFlag = cli.StringFlag{
1296-
Name: "txpool.blacklist",
1297-
Usage: "file of blacklisted wallet addresses",
1298-
DefValue: defaultConfig.TxPool.BlacklistFile,
1299-
}
13001292
rosettaFixFileFlag = cli.StringFlag{
13011293
Name: "txpool.rosettafixfile",
13021294
Usage: "file of rosetta fix file",
13031295
DefValue: defaultConfig.TxPool.RosettaFixFile,
13041296
}
1305-
legacyTPBlacklistFileFlag = cli.StringFlag{
1306-
Name: "blacklist",
1307-
Usage: "Path to newline delimited file of blacklisted wallet addresses",
1308-
DefValue: defaultConfig.TxPool.BlacklistFile,
1309-
Deprecated: "use --txpool.blacklist",
1310-
}
13111297
localAccountsFileFlag = cli.StringFlag{
13121298
Name: "txpool.locals",
13131299
Usage: "file of local wallet addresses",
13141300
DefValue: defaultConfig.TxPool.LocalAccountsFile,
13151301
}
1316-
allowedTxsFileFlag = cli.StringFlag{
1317-
Name: "txpool.allowedtxs",
1318-
Usage: "file of allowed transactions",
1319-
DefValue: defaultConfig.TxPool.AllowedTxsFile,
1320-
}
13211302
tpGlobalSlotsFlag = cli.IntFlag{
13221303
Name: "txpool.globalslots",
13231304
Usage: "maximum global number of non-executable transactions in the pool",
@@ -1382,17 +1363,9 @@ func applyTxPoolFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
13821363
}
13831364
config.TxPool.GlobalQueue = uint64(value)
13841365
}
1385-
if cli.IsFlagChanged(cmd, tpBlacklistFileFlag) {
1386-
config.TxPool.BlacklistFile = cli.GetStringFlagValue(cmd, tpBlacklistFileFlag)
1387-
} else if cli.IsFlagChanged(cmd, legacyTPBlacklistFileFlag) {
1388-
config.TxPool.BlacklistFile = cli.GetStringFlagValue(cmd, legacyTPBlacklistFileFlag)
1389-
}
13901366
if cli.IsFlagChanged(cmd, localAccountsFileFlag) {
13911367
config.TxPool.LocalAccountsFile = cli.GetStringFlagValue(cmd, localAccountsFileFlag)
13921368
}
1393-
if cli.IsFlagChanged(cmd, allowedTxsFileFlag) {
1394-
config.TxPool.AllowedTxsFile = cli.GetStringFlagValue(cmd, allowedTxsFileFlag)
1395-
}
13961369
if cli.IsFlagChanged(cmd, tpLifetimeFlag) {
13971370
value, err := time.ParseDuration(cli.GetStringFlagValue(cmd, tpLifetimeFlag))
13981371
if err != nil {

cmd/config/flags_test.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestHarmonyFlags(t *testing.T) {
3131
"/ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9,/ip4/13.113.101." +
3232
"219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX,/ip4/99.81.170.167/tcp/12019/p" +
3333
"2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj --ip 8.8.8.8 --port 9000 --network_type=mainn" +
34-
"et --dns_zone=t.hmny.io --blacklist=./.hmy/blacklist.txt --min_peers=6 --max_bls_keys_per_node=" +
34+
"et --dns_zone=t.hmny.io --min_peers=6 --max_bls_keys_per_node=" +
3535
"10 --broadcast_invalid_tx=true --verbosity=3 --is_archival=false --shard_id=-1 --staking=true -" +
3636
"-aws-config-source file:config.json --p2p.disc.concurrency 5 --p2p.security.max-conn-per-ip 5 -" +
3737
"-localnet.blocks_per_epoch=64 --localnet.blocks_per_epoch_v2=64",
@@ -128,7 +128,6 @@ func TestHarmonyFlags(t *testing.T) {
128128
KMSConfigFile: "config.json",
129129
},
130130
TxPool: harmonyconfig.TxPoolConfig{
131-
BlacklistFile: "./.hmy/blacklist.txt",
132131
AllowedTxsFile: "./.hmy/allowedtxs.txt",
133132
RosettaFixFile: "",
134133
AccountSlots: 16,
@@ -1269,7 +1268,6 @@ func TestTxPoolFlags(t *testing.T) {
12691268
{
12701269
args: []string{},
12711270
expConfig: harmonyconfig.TxPoolConfig{
1272-
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
12731271
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
12741272
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
12751273
AccountSlots: defaultConfig.TxPool.AccountSlots,
@@ -1283,9 +1281,8 @@ func TestTxPoolFlags(t *testing.T) {
12831281
},
12841282
},
12851283
{
1286-
args: []string{"--txpool.blacklist", "blacklist.file", "--txpool.rosettafixfile", "rosettafix.file", "--txpool.allowedtxs", "allowedtxs.txt"},
1284+
args: []string{"--txpool.rosettafixfile", "rosettafix.file"},
12871285
expConfig: harmonyconfig.TxPoolConfig{
1288-
BlacklistFile: "blacklist.file",
12891286
AllowedTxsFile: "allowedtxs.txt",
12901287
RosettaFixFile: "rosettafix.file",
12911288
AccountSlots: defaultConfig.TxPool.AccountSlots,
@@ -1299,9 +1296,8 @@ func TestTxPoolFlags(t *testing.T) {
12991296
},
13001297
},
13011298
{
1302-
args: []string{"--blacklist", "blacklist.file", "--txpool.rosettafixfile", "rosettafix.file"},
1299+
args: []string{"--txpool.rosettafixfile", "rosettafix.file"},
13031300
expConfig: harmonyconfig.TxPoolConfig{
1304-
BlacklistFile: "blacklist.file",
13051301
RosettaFixFile: "rosettafix.file",
13061302
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
13071303
AccountSlots: defaultConfig.TxPool.AccountSlots,
@@ -1315,10 +1311,9 @@ func TestTxPoolFlags(t *testing.T) {
13151311
},
13161312
},
13171313
{
1318-
args: []string{"--txpool.accountslots", "5", "--txpool.blacklist", "blacklist.file", "--txpool.rosettafixfile", "rosettafix.file"},
1314+
args: []string{"--txpool.accountslots", "5", "--txpool.rosettafixfile", "rosettafix.file"},
13191315
expConfig: harmonyconfig.TxPoolConfig{
13201316
AccountSlots: 5,
1321-
BlacklistFile: "blacklist.file",
13221317
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
13231318
RosettaFixFile: "rosettafix.file",
13241319
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
@@ -1333,7 +1328,6 @@ func TestTxPoolFlags(t *testing.T) {
13331328
{
13341329
args: []string{"--txpool.locals", "locals.txt"},
13351330
expConfig: harmonyconfig.TxPoolConfig{
1336-
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
13371331
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
13381332
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
13391333
AccountSlots: defaultConfig.TxPool.AccountSlots,
@@ -1349,7 +1343,6 @@ func TestTxPoolFlags(t *testing.T) {
13491343
{
13501344
args: []string{"--txpool.globalslots", "10240"},
13511345
expConfig: harmonyconfig.TxPoolConfig{
1352-
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
13531346
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
13541347
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
13551348
AccountSlots: defaultConfig.TxPool.AccountSlots,
@@ -1365,7 +1358,6 @@ func TestTxPoolFlags(t *testing.T) {
13651358
{
13661359
args: []string{"--txpool.accountqueue", "128", "--txpool.globalqueue", "10240", "--txpool.lifetime", "15m", "--txpool.pricelimit", "100", "--txpool.pricebump", "2"},
13671360
expConfig: harmonyconfig.TxPoolConfig{
1368-
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
13691361
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
13701362
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
13711363
AccountSlots: defaultConfig.TxPool.AccountSlots,

cmd/harmony/main.go

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import (
4848
node "github.com/harmony-one/harmony/node/harmony"
4949
"github.com/harmony-one/harmony/numeric"
5050
"github.com/harmony-one/harmony/p2p"
51-
rosetta_common "github.com/harmony-one/harmony/rosetta/common"
5251
rpc_common "github.com/harmony-one/harmony/rpc/harmony/common"
5352
"github.com/harmony-one/harmony/shard"
5453
"github.com/harmony-one/harmony/webhooks"
@@ -710,15 +709,7 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
710709
aggregateSig = defaultConsensusConfig.AggregateSig
711710
}
712711

713-
blacklist, err := setupBlacklist(hc)
714-
if err != nil {
715-
utils.Logger().Warn().Msgf("Blacklist setup error: %s", err.Error())
716-
}
717-
allowedTxs, err := setupAllowedTxs(hc)
718-
if err != nil {
719-
utils.Logger().Warn().Msgf("AllowedTxs setup error: %s", err.Error())
720-
}
721-
localAccounts, err := setupLocalAccounts(hc, blacklist)
712+
localAccounts, err := setupLocalAccounts(hc)
722713
if err != nil {
723714
utils.Logger().Warn().Msgf("local accounts setup error: %s", err.Error())
724715
}
@@ -741,7 +732,7 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
741732
os.Exit(1)
742733
}
743734

744-
currentNode := node.New(myHost, currentConsensus, blacklist, allowedTxs, localAccounts, &hc, registry)
735+
currentNode := node.New(myHost, currentConsensus, localAccounts, &hc, registry)
745736

746737
if hc.Legacy != nil && hc.Legacy.TPBroadcastInvalidTxn != nil {
747738
currentNode.BroadcastInvalidTx = *hc.Legacy.TPBroadcastInvalidTxn
@@ -925,28 +916,6 @@ func setupSyncService(node *node.Node, host p2p.Host, hc harmonyconfig.HarmonyCo
925916
}
926917
}
927918

928-
func setupBlacklist(hc harmonyconfig.HarmonyConfig) (map[ethCommon.Address]struct{}, error) {
929-
rosetta_common.InitRosettaFile(hc.TxPool.RosettaFixFile)
930-
931-
utils.Logger().Debug().Msgf("Using blacklist file at `%s`", hc.TxPool.BlacklistFile)
932-
dat, err := os.ReadFile(hc.TxPool.BlacklistFile)
933-
if err != nil {
934-
return nil, err
935-
}
936-
addrMap := make(map[ethCommon.Address]struct{})
937-
for _, line := range strings.Split(string(dat), "\n") {
938-
if len(line) != 0 { // blacklist file may have trailing empty string line
939-
b32 := strings.TrimSpace(strings.Split(string(line), "#")[0])
940-
addr, err := common.ParseAddr(b32)
941-
if err != nil {
942-
return nil, err
943-
}
944-
addrMap[addr] = struct{}{}
945-
}
946-
}
947-
return addrMap, nil
948-
}
949-
950919
func parseAllowedTxs(data []byte) (map[ethCommon.Address][]core.AllowedTxData, error) {
951920
allowedTxs := make(map[ethCommon.Address][]core.AllowedTxData)
952921
for _, line := range strings.Split(string(data), "\n") {
@@ -978,30 +947,7 @@ func parseAllowedTxs(data []byte) (map[ethCommon.Address][]core.AllowedTxData, e
978947
return allowedTxs, nil
979948
}
980949

981-
func setupAllowedTxs(hc harmonyconfig.HarmonyConfig) (map[ethCommon.Address][]core.AllowedTxData, error) {
982-
// check if the file exists
983-
if _, err := os.Stat(hc.TxPool.AllowedTxsFile); err == nil {
984-
// read the file and parse allowed transactions
985-
utils.Logger().Debug().Msgf("Using AllowedTxs file at `%s`", hc.TxPool.AllowedTxsFile)
986-
data, err := os.ReadFile(hc.TxPool.AllowedTxsFile)
987-
if err != nil {
988-
return nil, err
989-
}
990-
return parseAllowedTxs(data)
991-
} else if errors.Is(err, os.ErrNotExist) {
992-
// file path does not exist
993-
utils.Logger().Debug().
994-
Str("AllowedTxsFile", hc.TxPool.AllowedTxsFile).
995-
Msg("AllowedTxs file doesn't exist")
996-
return make(map[ethCommon.Address][]core.AllowedTxData), nil
997-
} else {
998-
// some other errors happened
999-
utils.Logger().Error().Err(err).Msg("setup allowedTxs failed")
1000-
return nil, err
1001-
}
1002-
}
1003-
1004-
func setupLocalAccounts(hc harmonyconfig.HarmonyConfig, blacklist map[ethCommon.Address]struct{}) ([]ethCommon.Address, error) {
950+
func setupLocalAccounts(hc harmonyconfig.HarmonyConfig) ([]ethCommon.Address, error) {
1005951
file := hc.TxPool.LocalAccountsFile
1006952
// check if file exist
1007953
var fileData string
@@ -1033,11 +979,6 @@ func setupLocalAccounts(hc harmonyconfig.HarmonyConfig, blacklist map[ethCommon.
1033979
if err != nil {
1034980
return nil, err
1035981
}
1036-
// skip the blacklisted addresses
1037-
if _, exists := blacklist[addr]; exists {
1038-
utils.Logger().Warn().Msgf("local account with address %s is blacklisted", addr.String())
1039-
continue
1040-
}
1041982
localAccounts[addr] = struct{}{}
1042983
}
1043984
uniqueAddresses := make([]ethCommon.Address, 0, len(localAccounts))

core/error.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ var (
2828
// by a transaction is higher than what's left in the block.
2929
ErrGasLimitReached = errors.New("gas limit reached")
3030

31-
// ErrBlacklistedHash is returned if a block to import is on the blacklist.
32-
ErrBlacklistedHash = errors.New("blacklisted hash")
33-
3431
// ErrNonceTooHigh is returned if the nonce of a transaction is higher than the
3532
// next one expected based on the local chain.
3633
ErrNonceTooHigh = errors.New("nonce too high")

0 commit comments

Comments
 (0)