Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cmd/config/config_migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ Version = "1.0.2"
RpcFilterFile = "./.hmy/rpc_filter.txt"

[TxPool]
BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt"
AccountQueue = 64
GlobalQueue = 5120
Expand Down Expand Up @@ -145,7 +144,6 @@ Version = "1.0.3"
RpcFilterFile = "./.hmy/rpc_filter.txt"

[TxPool]
BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt"
AccountQueue = 64
GlobalQueue = 5120
Expand Down Expand Up @@ -232,7 +230,6 @@ Version = "1.0.4"
MinPeers = 6

[TxPool]
BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt"
AccountQueue = 64
GlobalQueue = 5120
Expand Down Expand Up @@ -326,7 +323,6 @@ Version = "1.0.4"
CacheSize = 512

[TxPool]
BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt"
AllowedTxsFile = "./.hmy/allowedtxs.txt"
AccountQueue = 64
Expand Down
1 change: 0 additions & 1 deletion cmd/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ Version = "1.0.4"
ListenAddr = "127.0.0.1:6060"

[TxPool]
BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt"
AllowedTxsFile = "./.hmy/allowedtxs.txt"
AccountQueue = 64
Expand Down
2 changes: 0 additions & 2 deletions cmd/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ var defaultConfig = harmonyconfig.HarmonyConfig{
KMSConfigFile: "",
},
TxPool: harmonyconfig.TxPoolConfig{
BlacklistFile: "./.hmy/blacklist.txt",
AllowedTxsFile: "./.hmy/allowedtxs.txt",
RosettaFixFile: "",
AccountSlots: core.DefaultTxPoolConfig.AccountSlots,
LocalAccountsFile: "./.hmy/locals.txt",
Expand Down
27 changes: 0 additions & 27 deletions cmd/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ var (
tpGlobalQueueFlag,
tpLifetimeFlag,
rosettaFixFileFlag,
tpBlacklistFileFlag,
legacyTPBlacklistFileFlag,
localAccountsFileFlag,
allowedTxsFileFlag,
tpPriceLimitFlag,
tpPriceBumpFlag,
}
Expand Down Expand Up @@ -1292,32 +1289,16 @@ var (
Usage: "number of executable transaction slots guaranteed per account",
DefValue: int(defaultConfig.TxPool.AccountSlots),
}
tpBlacklistFileFlag = cli.StringFlag{
Name: "txpool.blacklist",
Usage: "file of blacklisted wallet addresses",
DefValue: defaultConfig.TxPool.BlacklistFile,
}
rosettaFixFileFlag = cli.StringFlag{
Name: "txpool.rosettafixfile",
Usage: "file of rosetta fix file",
DefValue: defaultConfig.TxPool.RosettaFixFile,
}
legacyTPBlacklistFileFlag = cli.StringFlag{
Name: "blacklist",
Usage: "Path to newline delimited file of blacklisted wallet addresses",
DefValue: defaultConfig.TxPool.BlacklistFile,
Deprecated: "use --txpool.blacklist",
}
localAccountsFileFlag = cli.StringFlag{
Name: "txpool.locals",
Usage: "file of local wallet addresses",
DefValue: defaultConfig.TxPool.LocalAccountsFile,
}
allowedTxsFileFlag = cli.StringFlag{
Name: "txpool.allowedtxs",
Usage: "file of allowed transactions",
DefValue: defaultConfig.TxPool.AllowedTxsFile,
}
tpGlobalSlotsFlag = cli.IntFlag{
Name: "txpool.globalslots",
Usage: "maximum global number of non-executable transactions in the pool",
Expand Down Expand Up @@ -1382,17 +1363,9 @@ func applyTxPoolFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
}
config.TxPool.GlobalQueue = uint64(value)
}
if cli.IsFlagChanged(cmd, tpBlacklistFileFlag) {
config.TxPool.BlacklistFile = cli.GetStringFlagValue(cmd, tpBlacklistFileFlag)
} else if cli.IsFlagChanged(cmd, legacyTPBlacklistFileFlag) {
config.TxPool.BlacklistFile = cli.GetStringFlagValue(cmd, legacyTPBlacklistFileFlag)
}
if cli.IsFlagChanged(cmd, localAccountsFileFlag) {
config.TxPool.LocalAccountsFile = cli.GetStringFlagValue(cmd, localAccountsFileFlag)
}
if cli.IsFlagChanged(cmd, allowedTxsFileFlag) {
config.TxPool.AllowedTxsFile = cli.GetStringFlagValue(cmd, allowedTxsFileFlag)
}
if cli.IsFlagChanged(cmd, tpLifetimeFlag) {
value, err := time.ParseDuration(cli.GetStringFlagValue(cmd, tpLifetimeFlag))
if err != nil {
Expand Down
16 changes: 4 additions & 12 deletions cmd/config/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestHarmonyFlags(t *testing.T) {
"/ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9,/ip4/13.113.101." +
"219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX,/ip4/99.81.170.167/tcp/12019/p" +
"2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj --ip 8.8.8.8 --port 9000 --network_type=mainn" +
"et --dns_zone=t.hmny.io --blacklist=./.hmy/blacklist.txt --min_peers=6 --max_bls_keys_per_node=" +
"et --dns_zone=t.hmny.io --min_peers=6 --max_bls_keys_per_node=" +
"10 --broadcast_invalid_tx=true --verbosity=3 --is_archival=false --shard_id=-1 --staking=true -" +
"-aws-config-source file:config.json --p2p.disc.concurrency 5 --p2p.security.max-conn-per-ip 5 -" +
"-localnet.blocks_per_epoch=64 --localnet.blocks_per_epoch_v2=64",
Expand Down Expand Up @@ -128,7 +128,6 @@ func TestHarmonyFlags(t *testing.T) {
KMSConfigFile: "config.json",
},
TxPool: harmonyconfig.TxPoolConfig{
BlacklistFile: "./.hmy/blacklist.txt",
AllowedTxsFile: "./.hmy/allowedtxs.txt",
RosettaFixFile: "",
AccountSlots: 16,
Expand Down Expand Up @@ -1269,7 +1268,6 @@ func TestTxPoolFlags(t *testing.T) {
{
args: []string{},
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots,
Expand All @@ -1283,9 +1281,8 @@ func TestTxPoolFlags(t *testing.T) {
},
},
{
args: []string{"--txpool.blacklist", "blacklist.file", "--txpool.rosettafixfile", "rosettafix.file", "--txpool.allowedtxs", "allowedtxs.txt"},
args: []string{"--txpool.rosettafixfile", "rosettafix.file"},
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: "blacklist.file",
AllowedTxsFile: "allowedtxs.txt",
RosettaFixFile: "rosettafix.file",
AccountSlots: defaultConfig.TxPool.AccountSlots,
Expand All @@ -1299,9 +1296,8 @@ func TestTxPoolFlags(t *testing.T) {
},
},
{
args: []string{"--blacklist", "blacklist.file", "--txpool.rosettafixfile", "rosettafix.file"},
args: []string{"--txpool.rosettafixfile", "rosettafix.file"},
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: "blacklist.file",
RosettaFixFile: "rosettafix.file",
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
AccountSlots: defaultConfig.TxPool.AccountSlots,
Expand All @@ -1315,10 +1311,9 @@ func TestTxPoolFlags(t *testing.T) {
},
},
{
args: []string{"--txpool.accountslots", "5", "--txpool.blacklist", "blacklist.file", "--txpool.rosettafixfile", "rosettafix.file"},
args: []string{"--txpool.accountslots", "5", "--txpool.rosettafixfile", "rosettafix.file"},
expConfig: harmonyconfig.TxPoolConfig{
AccountSlots: 5,
BlacklistFile: "blacklist.file",
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: "rosettafix.file",
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
Expand All @@ -1333,7 +1328,6 @@ func TestTxPoolFlags(t *testing.T) {
{
args: []string{"--txpool.locals", "locals.txt"},
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots,
Expand All @@ -1349,7 +1343,6 @@ func TestTxPoolFlags(t *testing.T) {
{
args: []string{"--txpool.globalslots", "10240"},
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots,
Expand All @@ -1365,7 +1358,6 @@ func TestTxPoolFlags(t *testing.T) {
{
args: []string{"--txpool.accountqueue", "128", "--txpool.globalqueue", "10240", "--txpool.lifetime", "15m", "--txpool.pricelimit", "100", "--txpool.pricebump", "2"},
expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: defaultConfig.TxPool.BlacklistFile,
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots,
Expand Down
65 changes: 3 additions & 62 deletions cmd/harmony/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import (
node "github.com/harmony-one/harmony/node/harmony"
"github.com/harmony-one/harmony/numeric"
"github.com/harmony-one/harmony/p2p"
rosetta_common "github.com/harmony-one/harmony/rosetta/common"
rpc_common "github.com/harmony-one/harmony/rpc/harmony/common"
"github.com/harmony-one/harmony/shard"
"github.com/harmony-one/harmony/webhooks"
Expand Down Expand Up @@ -710,15 +709,7 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
aggregateSig = defaultConsensusConfig.AggregateSig
}

blacklist, err := setupBlacklist(hc)
if err != nil {
utils.Logger().Warn().Msgf("Blacklist setup error: %s", err.Error())
}
allowedTxs, err := setupAllowedTxs(hc)
if err != nil {
utils.Logger().Warn().Msgf("AllowedTxs setup error: %s", err.Error())
}
localAccounts, err := setupLocalAccounts(hc, blacklist)
localAccounts, err := setupLocalAccounts(hc)
if err != nil {
utils.Logger().Warn().Msgf("local accounts setup error: %s", err.Error())
}
Expand All @@ -741,7 +732,7 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
os.Exit(1)
}

currentNode := node.New(myHost, currentConsensus, blacklist, allowedTxs, localAccounts, &hc, registry)
currentNode := node.New(myHost, currentConsensus, localAccounts, &hc, registry)

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

func setupBlacklist(hc harmonyconfig.HarmonyConfig) (map[ethCommon.Address]struct{}, error) {
rosetta_common.InitRosettaFile(hc.TxPool.RosettaFixFile)

utils.Logger().Debug().Msgf("Using blacklist file at `%s`", hc.TxPool.BlacklistFile)
dat, err := os.ReadFile(hc.TxPool.BlacklistFile)
if err != nil {
return nil, err
}
addrMap := make(map[ethCommon.Address]struct{})
for _, line := range strings.Split(string(dat), "\n") {
if len(line) != 0 { // blacklist file may have trailing empty string line
b32 := strings.TrimSpace(strings.Split(string(line), "#")[0])
addr, err := common.ParseAddr(b32)
if err != nil {
return nil, err
}
addrMap[addr] = struct{}{}
}
}
return addrMap, nil
}

func parseAllowedTxs(data []byte) (map[ethCommon.Address][]core.AllowedTxData, error) {
allowedTxs := make(map[ethCommon.Address][]core.AllowedTxData)
for _, line := range strings.Split(string(data), "\n") {
Expand Down Expand Up @@ -978,30 +947,7 @@ func parseAllowedTxs(data []byte) (map[ethCommon.Address][]core.AllowedTxData, e
return allowedTxs, nil
}

func setupAllowedTxs(hc harmonyconfig.HarmonyConfig) (map[ethCommon.Address][]core.AllowedTxData, error) {
// check if the file exists
if _, err := os.Stat(hc.TxPool.AllowedTxsFile); err == nil {
// read the file and parse allowed transactions
utils.Logger().Debug().Msgf("Using AllowedTxs file at `%s`", hc.TxPool.AllowedTxsFile)
data, err := os.ReadFile(hc.TxPool.AllowedTxsFile)
if err != nil {
return nil, err
}
return parseAllowedTxs(data)
} else if errors.Is(err, os.ErrNotExist) {
// file path does not exist
utils.Logger().Debug().
Str("AllowedTxsFile", hc.TxPool.AllowedTxsFile).
Msg("AllowedTxs file doesn't exist")
return make(map[ethCommon.Address][]core.AllowedTxData), nil
} else {
// some other errors happened
utils.Logger().Error().Err(err).Msg("setup allowedTxs failed")
return nil, err
}
}

func setupLocalAccounts(hc harmonyconfig.HarmonyConfig, blacklist map[ethCommon.Address]struct{}) ([]ethCommon.Address, error) {
func setupLocalAccounts(hc harmonyconfig.HarmonyConfig) ([]ethCommon.Address, error) {
file := hc.TxPool.LocalAccountsFile
// check if file exist
var fileData string
Expand Down Expand Up @@ -1033,11 +979,6 @@ func setupLocalAccounts(hc harmonyconfig.HarmonyConfig, blacklist map[ethCommon.
if err != nil {
return nil, err
}
// skip the blacklisted addresses
if _, exists := blacklist[addr]; exists {
utils.Logger().Warn().Msgf("local account with address %s is blacklisted", addr.String())
continue
}
localAccounts[addr] = struct{}{}
}
uniqueAddresses := make([]ethCommon.Address, 0, len(localAccounts))
Expand Down
3 changes: 0 additions & 3 deletions core/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ var (
// by a transaction is higher than what's left in the block.
ErrGasLimitReached = errors.New("gas limit reached")

// ErrBlacklistedHash is returned if a block to import is on the blacklist.
ErrBlacklistedHash = errors.New("blacklisted hash")

// ErrNonceTooHigh is returned if the nonce of a transaction is higher than the
// next one expected based on the local chain.
ErrNonceTooHigh = errors.New("nonce too high")
Expand Down
Loading
Loading