[txpool] fix #4215, support allowed transaction list. (#4218)

* [txpool] fix #4215, support allowed transaction list.

* test: fix node tests for allowlist of txs

* add error checking of tx.data

* recover test scripts

* config migration

* add tx.data to error info

* [pool] refactor: log more if `from` in denylist

* reject tx if it does not pass the allowed whiltelist check

Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
pull/4235/head
PeekPI 2 years ago committed by GitHub
parent 1445223b5a
commit 7ae12b14b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      cmd/harmony/config_migrations.go
  2. 1
      cmd/harmony/config_migrations_test.go
  3. 1
      cmd/harmony/config_test.go
  4. 3
      cmd/harmony/default.go
  5. 9
      cmd/harmony/flags.go
  6. 8
      cmd/harmony/flags_test.go
  7. 49
      cmd/harmony/main.go
  8. 50
      cmd/harmony/main_test.go
  9. 31
      core/tx_pool.go
  10. 1
      internal/configs/harmony/harmony.go
  11. 2
      node/node.go
  12. 6
      node/node_handler_test.go
  13. 2
      node/node_newblock_test.go
  14. 4
      node/node_test.go
  15. 36
      rosetta/infra/harmony-mainnet.conf
  16. 35
      rosetta/infra/harmony-pstn.conf

@ -259,5 +259,12 @@ func init() {
confTree.Set("Version", "2.5.3") confTree.Set("Version", "2.5.3")
return confTree return confTree
} }
migrations["2.5.3"] = func(confTree *toml.Tree) *toml.Tree {
if confTree.Get("TxPool.AllowedTxsFile") == nil {
confTree.Set("TxPool.AllowedTxsFile", defaultConfig.TxPool.AllowedTxsFile)
}
confTree.Set("Version", "2.5.4")
return confTree
}
} }

@ -313,6 +313,7 @@ Version = "1.0.4"
[TxPool] [TxPool]
BlacklistFile = "./.hmy/blacklist.txt" BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt" LocalAccountsFile = "./.hmy/locals.txt"
AllowedTxsFile = "./.hmy/allowedtxs.txt"
[WS] [WS]
Enabled = true Enabled = true

@ -84,6 +84,7 @@ Version = "1.0.4"
[TxPool] [TxPool]
BlacklistFile = "./.hmy/blacklist.txt" BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt" LocalAccountsFile = "./.hmy/locals.txt"
AllowedTxsFile = "./.hmy/allowedtxs.txt"
[Sync] [Sync]
Downloader = false Downloader = false

@ -5,7 +5,7 @@ import (
nodeconfig "github.com/harmony-one/harmony/internal/configs/node" nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
) )
const tomlConfigVersion = "2.5.3" // bump from 2.5.2 for rpc filters const tomlConfigVersion = "2.5.4" // bump from 2.5.2 for rpc filters
const ( const (
defNetworkType = nodeconfig.Mainnet defNetworkType = nodeconfig.Mainnet
@ -70,6 +70,7 @@ var defaultConfig = harmonyconfig.HarmonyConfig{
}, },
TxPool: harmonyconfig.TxPoolConfig{ TxPool: harmonyconfig.TxPoolConfig{
BlacklistFile: "./.hmy/blacklist.txt", BlacklistFile: "./.hmy/blacklist.txt",
AllowedTxsFile: "./.hmy/allowedtxs.txt",
RosettaFixFile: "", RosettaFixFile: "",
AccountSlots: 16, AccountSlots: 16,
LocalAccountsFile: "./.hmy/locals.txt", LocalAccountsFile: "./.hmy/locals.txt",

@ -135,6 +135,7 @@ var (
tpBlacklistFileFlag, tpBlacklistFileFlag,
legacyTPBlacklistFileFlag, legacyTPBlacklistFileFlag,
localAccountsFileFlag, localAccountsFileFlag,
allowedTxsFileFlag,
} }
pprofFlags = []cli.Flag{ pprofFlags = []cli.Flag{
@ -1080,6 +1081,11 @@ var (
Usage: "file of local wallet addresses", Usage: "file of local wallet addresses",
DefValue: defaultConfig.TxPool.LocalAccountsFile, DefValue: defaultConfig.TxPool.LocalAccountsFile,
} }
allowedTxsFileFlag = cli.StringFlag{
Name: "txpool.allowedtxs",
Usage: "file of allowed transactions",
DefValue: defaultConfig.TxPool.AllowedTxsFile,
}
) )
func applyTxPoolFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) { func applyTxPoolFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
@ -1101,6 +1107,9 @@ func applyTxPoolFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
if cli.IsFlagChanged(cmd, localAccountsFileFlag) { if cli.IsFlagChanged(cmd, localAccountsFileFlag) {
config.TxPool.LocalAccountsFile = cli.GetStringFlagValue(cmd, localAccountsFileFlag) config.TxPool.LocalAccountsFile = cli.GetStringFlagValue(cmd, localAccountsFileFlag)
} }
if cli.IsFlagChanged(cmd, allowedTxsFileFlag) {
config.TxPool.AllowedTxsFile = cli.GetStringFlagValue(cmd, allowedTxsFileFlag)
}
} }
// pprof flags // pprof flags

@ -106,6 +106,7 @@ func TestHarmonyFlags(t *testing.T) {
}, },
TxPool: harmonyconfig.TxPoolConfig{ TxPool: harmonyconfig.TxPoolConfig{
BlacklistFile: "./.hmy/blacklist.txt", BlacklistFile: "./.hmy/blacklist.txt",
AllowedTxsFile: "./.hmy/allowedtxs.txt",
RosettaFixFile: "", RosettaFixFile: "",
AccountSlots: 16, AccountSlots: 16,
LocalAccountsFile: "./.hmy/locals.txt", LocalAccountsFile: "./.hmy/locals.txt",
@ -875,15 +876,17 @@ func TestTxPoolFlags(t *testing.T) {
args: []string{}, args: []string{},
expConfig: harmonyconfig.TxPoolConfig{ expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: defaultConfig.TxPool.BlacklistFile, BlacklistFile: defaultConfig.TxPool.BlacklistFile,
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile, RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots, AccountSlots: defaultConfig.TxPool.AccountSlots,
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile, LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
}, },
}, },
{ {
args: []string{"--txpool.blacklist", "blacklist.file", "--txpool.rosettafixfile", "rosettafix.file"}, args: []string{"--txpool.blacklist", "blacklist.file", "--txpool.rosettafixfile", "rosettafix.file", "--txpool.allowedtxs", "allowedtxs.txt"},
expConfig: harmonyconfig.TxPoolConfig{ expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: "blacklist.file", BlacklistFile: "blacklist.file",
AllowedTxsFile: "allowedtxs.txt",
RosettaFixFile: "rosettafix.file", RosettaFixFile: "rosettafix.file",
AccountSlots: 16, // default AccountSlots: 16, // default
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile, LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
@ -894,6 +897,7 @@ func TestTxPoolFlags(t *testing.T) {
expConfig: harmonyconfig.TxPoolConfig{ expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: "blacklist.file", BlacklistFile: "blacklist.file",
RosettaFixFile: "rosettafix.file", RosettaFixFile: "rosettafix.file",
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
AccountSlots: 16, // default AccountSlots: 16, // default
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile, LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
}, },
@ -903,6 +907,7 @@ func TestTxPoolFlags(t *testing.T) {
expConfig: harmonyconfig.TxPoolConfig{ expConfig: harmonyconfig.TxPoolConfig{
AccountSlots: 5, AccountSlots: 5,
BlacklistFile: "blacklist.file", BlacklistFile: "blacklist.file",
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: "rosettafix.file", RosettaFixFile: "rosettafix.file",
LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile, LocalAccountsFile: defaultConfig.TxPool.LocalAccountsFile,
}, },
@ -911,6 +916,7 @@ func TestTxPoolFlags(t *testing.T) {
args: []string{"--txpool.locals", "locals.txt"}, args: []string{"--txpool.locals", "locals.txt"},
expConfig: harmonyconfig.TxPoolConfig{ expConfig: harmonyconfig.TxPoolConfig{
BlacklistFile: defaultConfig.TxPool.BlacklistFile, BlacklistFile: defaultConfig.TxPool.BlacklistFile,
AllowedTxsFile: defaultConfig.TxPool.AllowedTxsFile,
RosettaFixFile: defaultConfig.TxPool.RosettaFixFile, RosettaFixFile: defaultConfig.TxPool.RosettaFixFile,
AccountSlots: defaultConfig.TxPool.AccountSlots, AccountSlots: defaultConfig.TxPool.AccountSlots,
LocalAccountsFile: "locals.txt", LocalAccountsFile: "locals.txt",

@ -22,6 +22,7 @@ import (
rpc_common "github.com/harmony-one/harmony/rpc/common" rpc_common "github.com/harmony-one/harmony/rpc/common"
ethCommon "github.com/ethereum/go-ethereum/common" ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -667,6 +668,10 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
if err != nil { if err != nil {
utils.Logger().Warn().Msgf("Blacklist setup error: %s", err.Error()) 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, blacklist)
if err != nil { if err != nil {
@ -687,7 +692,7 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
chainDBFactory = &shardchain.LDBFactory{RootDir: nodeConfig.DBDir} chainDBFactory = &shardchain.LDBFactory{RootDir: nodeConfig.DBDir}
} }
currentNode := node.New(myHost, currentConsensus, chainDBFactory, blacklist, localAccounts, nodeConfig.ArchiveModes(), &hc) currentNode := node.New(myHost, currentConsensus, chainDBFactory, blacklist, allowedTxs, localAccounts, nodeConfig.ArchiveModes(), &hc)
if hc.Legacy != nil && hc.Legacy.TPBroadcastInvalidTxn != nil { if hc.Legacy != nil && hc.Legacy.TPBroadcastInvalidTxn != nil {
currentNode.BroadcastInvalidTx = *hc.Legacy.TPBroadcastInvalidTxn currentNode.BroadcastInvalidTx = *hc.Legacy.TPBroadcastInvalidTxn
@ -842,7 +847,7 @@ func setupBlacklist(hc harmonyconfig.HarmonyConfig) (map[ethCommon.Address]struc
for _, line := range strings.Split(string(dat), "\n") { for _, line := range strings.Split(string(dat), "\n") {
if len(line) != 0 { // blacklist file may have trailing empty string line if len(line) != 0 { // blacklist file may have trailing empty string line
b32 := strings.TrimSpace(strings.Split(string(line), "#")[0]) b32 := strings.TrimSpace(strings.Split(string(line), "#")[0])
addr, err := common.Bech32ToAddress(b32) addr, err := common.ParseAddr(b32)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -852,6 +857,46 @@ func setupBlacklist(hc harmonyconfig.HarmonyConfig) (map[ethCommon.Address]struc
return addrMap, nil 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") {
line = strings.TrimSpace(line)
if len(line) != 0 { // AllowedTxs file may have trailing empty string line
substrings := strings.Split(string(line), "->")
fromStr := strings.TrimSpace(substrings[0])
txSubstrings := strings.Split(substrings[1], ":")
toStr := strings.TrimSpace(txSubstrings[0])
dataStr := strings.TrimSpace(txSubstrings[1])
from, err := common.ParseAddr(fromStr)
if err != nil {
return nil, err
}
to, err := common.ParseAddr(toStr)
if err != nil {
return nil, err
}
data, err := hexutil.Decode(dataStr)
if err != nil {
return nil, err
}
allowedTxs[from] = core.AllowedTxData{
To: to,
Data: data,
}
}
}
return allowedTxs, nil
}
func setupAllowedTxs(hc harmonyconfig.HarmonyConfig) (map[ethCommon.Address]core.AllowedTxData, error) {
utils.Logger().Debug().Msgf("Using AllowedTxs file at `%s`", hc.TxPool.AllowedTxsFile)
data, err := ioutil.ReadFile(hc.TxPool.AllowedTxsFile)
if err != nil {
return nil, err
}
return parseAllowedTxs(data)
}
func setupLocalAccounts(hc harmonyconfig.HarmonyConfig, blacklist map[ethCommon.Address]struct{}) ([]ethCommon.Address, error) { func setupLocalAccounts(hc harmonyconfig.HarmonyConfig, blacklist map[ethCommon.Address]struct{}) ([]ethCommon.Address, error) {
file := hc.TxPool.LocalAccountsFile file := hc.TxPool.LocalAccountsFile
// check if file exist // check if file exist

@ -0,0 +1,50 @@
package main
import (
"bytes"
"testing"
"github.com/ethereum/go-ethereum/common"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/harmony/core"
)
func TestAllowedTxsParse(t *testing.T) {
testData := []byte(`
0x7A6Ed0a905053A21C15cB5b4F39b561B6A3FE50f->0x855Ac656956AF761439f4a451c872E812E3900a4:0x
0x7A6Ed0a905053A21C15cB5b4F39b561B6A3FE50f->one1np293efrmv74xyjcz0kk3sn53x0fm745f2hsuc:0xa9059cbb
one1s4dvv454dtmkzsulffz3epewsyhrjq9y0g3fqz->0x985458E523dB3d53125813eD68c274899e9DfAb4:0xa9059cbb
one1s4dvv454dtmkzsulffz3epewsyhrjq9y0g3fqz->one10fhdp2g9q5azrs2ukk608x6krd4rleg0ueskug:0x
`)
expected := map[ethCommon.Address]core.AllowedTxData{
common.HexToAddress("0x7A6Ed0a905053A21C15cB5b4F39b561B6A3FE50f"): core.AllowedTxData{
To: common.HexToAddress("0x855Ac656956AF761439f4a451c872E812E3900a4"),
Data: common.FromHex("0x"),
},
common.HexToAddress("0x7A6Ed0a905053A21C15cB5b4F39b561B6A3FE50f"): core.AllowedTxData{
To: common.HexToAddress("0x985458E523dB3d53125813eD68c274899e9DfAb4"),
Data: common.FromHex("0xa9059cbb"),
},
common.HexToAddress("0x855Ac656956AF761439f4a451c872E812E3900a4"): core.AllowedTxData{
To: common.HexToAddress("0x985458E523dB3d53125813eD68c274899e9DfAb4"),
Data: common.FromHex("0xa9059cbb"),
},
common.HexToAddress("0x855Ac656956AF761439f4a451c872E812E3900a4"): core.AllowedTxData{
To: common.HexToAddress("0x7A6Ed0a905053A21C15cB5b4F39b561B6A3FE50f"),
Data: common.FromHex("0x"),
},
}
got, err := parseAllowedTxs(testData)
if err != nil {
t.Fatal(err)
}
if len(got) != len(expected) {
t.Errorf("lenght of allowed transactions not equal, got: %d expected: %d", len(got), len(expected))
}
for from, txData := range got {
expectedTxData := expected[from]
if expectedTxData.To != txData.To || !bytes.Equal(expectedTxData.Data, txData.Data) {
t.Errorf("txData not equal: got: %v expected: %v", txData, expectedTxData)
}
}
}

@ -17,6 +17,7 @@
package core package core
import ( import (
"bytes"
"fmt" "fmt"
"math" "math"
"math/big" "math/big"
@ -95,10 +96,12 @@ var (
ErrInvalidMsgForStakingDirective = errors.New("staking message does not match directive message") ErrInvalidMsgForStakingDirective = errors.New("staking message does not match directive message")
// ErrBlacklistFrom is returned if a transaction's from/source address is blacklisted // ErrBlacklistFrom is returned if a transaction's from/source address is blacklisted
ErrBlacklistFrom = errors.New("`from` address of transaction in blacklist") ErrBlacklistFrom = errors.New("`from` address of transaction in blacklist and not in allowlist")
// ErrBlacklistTo is returned if a transaction's to/destination address is blacklisted // ErrBlacklistTo is returned if a transaction's to/destination address is blacklisted
ErrBlacklistTo = errors.New("`to` address of transaction in blacklist") ErrBlacklistTo = errors.New("`to` address of transaction in blacklist")
ErrAllowedTxs = errors.New("transaction allowed whitelist check failed.")
) )
var ( var (
@ -145,6 +148,11 @@ type blockChain interface {
SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Subscription SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Subscription
} }
type AllowedTxData struct {
To common.Address
Data []byte
}
// TxPoolConfig are the configuration parameters of the transaction pool. // TxPoolConfig are the configuration parameters of the transaction pool.
type TxPoolConfig struct { type TxPoolConfig struct {
Locals []common.Address // Addresses that should be treated by default as local Locals []common.Address // Addresses that should be treated by default as local
@ -163,6 +171,7 @@ type TxPoolConfig struct {
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
Blacklist map[common.Address]struct{} // Set of accounts that cannot be a part of any transaction Blacklist map[common.Address]struct{} // Set of accounts that cannot be a part of any transaction
AllowedTxs map[common.Address]AllowedTxData // Set of allowed transactions can break the blocklist
} }
// DefaultTxPoolConfig contains the default configurations for the transaction // DefaultTxPoolConfig contains the default configurations for the transaction
@ -182,6 +191,7 @@ var DefaultTxPoolConfig = TxPoolConfig{
Lifetime: 30 * time.Minute, Lifetime: 30 * time.Minute,
Blacklist: map[common.Address]struct{}{}, Blacklist: map[common.Address]struct{}{},
AllowedTxs: map[common.Address]AllowedTxData{},
} }
// sanitize checks the provided user configurations and changes anything that's // sanitize checks the provided user configurations and changes anything that's
@ -213,6 +223,10 @@ func (config *TxPoolConfig) sanitize() TxPoolConfig {
utils.Logger().Warn().Msg("Sanitizing nil blacklist set") utils.Logger().Warn().Msg("Sanitizing nil blacklist set")
conf.Blacklist = DefaultTxPoolConfig.Blacklist conf.Blacklist = DefaultTxPoolConfig.Blacklist
} }
if conf.AllowedTxs == nil {
utils.Logger().Warn().Msg("Sanitizing nil allowedTxs set")
conf.AllowedTxs = DefaultTxPoolConfig.AllowedTxs
}
if conf.AccountSlots == 0 { if conf.AccountSlots == 0 {
utils.Logger().Warn(). utils.Logger().Warn().
Uint64("provided", conf.AccountSlots). Uint64("provided", conf.AccountSlots).
@ -707,6 +721,18 @@ func (pool *TxPool) validateTx(tx types.PoolTransaction, local bool) error {
} }
return ErrInvalidSender return ErrInvalidSender
} }
// do whitelist check first, if tx not in whitelist, do blacklist check
if allowedTx, exists := pool.config.AllowedTxs[from]; exists {
if to := tx.To(); to == nil || *to != allowedTx.To || !bytes.Equal(tx.Data(), allowedTx.Data) {
toAddr := common.Address{}
if to != nil {
toAddr = *to
}
return errors.WithMessagef(ErrAllowedTxs, "transaction sender: %x, receiver: %x, input: %x", tx.From(), toAddr, tx.Data())
}
} else {
// do blacklist check
// Make sure transaction does not have blacklisted addresses // Make sure transaction does not have blacklisted addresses
if _, exists := (pool.config.Blacklist)[from]; exists { if _, exists := (pool.config.Blacklist)[from]; exists {
if b32, err := hmyCommon.AddressToBech32(from); err == nil { if b32, err := hmyCommon.AddressToBech32(from); err == nil {
@ -718,11 +744,12 @@ func (pool *TxPool) validateTx(tx types.PoolTransaction, local bool) error {
if tx.To() != nil { if tx.To() != nil {
if _, exists := (pool.config.Blacklist)[*tx.To()]; exists { if _, exists := (pool.config.Blacklist)[*tx.To()]; exists {
if b32, err := hmyCommon.AddressToBech32(*tx.To()); err == nil { if b32, err := hmyCommon.AddressToBech32(*tx.To()); err == nil {
return errors.WithMessagef(ErrBlacklistTo, "transaction receiver is %s", b32) return errors.WithMessagef(ErrBlacklistTo, "transaction receiver is %s with data: %x", b32, tx.Data())
} }
return ErrBlacklistTo return ErrBlacklistTo
} }
} }
}
// Drop non-local transactions under our own minimal accepted gas price // Drop non-local transactions under our own minimal accepted gas price
local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network local = local || pool.locals.contains(from) // account may be local even if the transaction arrived from the network
if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 { if !local && pool.gasPrice.Cmp(tx.GasPrice()) > 0 {

@ -98,6 +98,7 @@ type BlsConfig struct {
type TxPoolConfig struct { type TxPoolConfig struct {
BlacklistFile string BlacklistFile string
AllowedTxsFile string
RosettaFixFile string RosettaFixFile string
AccountSlots uint64 AccountSlots uint64
LocalAccountsFile string LocalAccountsFile string

@ -956,6 +956,7 @@ func New(
consensusObj *consensus.Consensus, consensusObj *consensus.Consensus,
chainDBFactory shardchain.DBFactory, chainDBFactory shardchain.DBFactory,
blacklist map[common.Address]struct{}, blacklist map[common.Address]struct{},
allowedTxs map[common.Address]core.AllowedTxData,
localAccounts []common.Address, localAccounts []common.Address,
isArchival map[uint32]bool, isArchival map[uint32]bool,
harmonyconfig *harmonyconfig.HarmonyConfig, harmonyconfig *harmonyconfig.HarmonyConfig,
@ -1031,6 +1032,7 @@ func New(
} }
txPoolConfig.Blacklist = blacklist txPoolConfig.Blacklist = blacklist
txPoolConfig.AllowedTxs = allowedTxs
txPoolConfig.Journal = fmt.Sprintf("%v/%v", node.NodeConfig.DBDir, txPoolConfig.Journal) txPoolConfig.Journal = fmt.Sprintf("%v/%v", node.NodeConfig.DBDir, txPoolConfig.Journal)
node.TxPool = core.NewTxPool(txPoolConfig, node.Blockchain().Config(), blockchain, node.TransactionErrorSink) node.TxPool = core.NewTxPool(txPoolConfig, node.Blockchain().Config(), blockchain, node.TransactionErrorSink)
node.CxPool = core.NewCxPool(core.CxPoolSize) node.CxPool = core.NewCxPool(core.CxPoolSize)

@ -39,7 +39,7 @@ func TestAddNewBlock(t *testing.T) {
t.Fatalf("Cannot craeate consensus: %v", err) t.Fatalf("Cannot craeate consensus: %v", err)
} }
nodeconfig.SetNetworkType(nodeconfig.Devnet) nodeconfig.SetNetworkType(nodeconfig.Devnet)
node := New(host, consensus, testDBFactory, nil, nil, nil, nil) node := New(host, consensus, testDBFactory, nil, nil, nil, nil, nil)
txs := make(map[common.Address]types.Transactions) txs := make(map[common.Address]types.Transactions)
stks := staking.StakingTransactions{} stks := staking.StakingTransactions{}
@ -88,7 +88,7 @@ func TestVerifyNewBlock(t *testing.T) {
archiveMode := make(map[uint32]bool) archiveMode := make(map[uint32]bool)
archiveMode[0] = true archiveMode[0] = true
archiveMode[1] = false archiveMode[1] = false
node := New(host, consensus, testDBFactory, nil, nil, archiveMode, nil) node := New(host, consensus, testDBFactory, nil, nil, nil, archiveMode, nil)
txs := make(map[common.Address]types.Transactions) txs := make(map[common.Address]types.Transactions)
stks := staking.StakingTransactions{} stks := staking.StakingTransactions{}
@ -134,7 +134,7 @@ func TestVerifyVRF(t *testing.T) {
archiveMode := make(map[uint32]bool) archiveMode := make(map[uint32]bool)
archiveMode[0] = true archiveMode[0] = true
archiveMode[1] = false archiveMode[1] = false
node := New(host, consensus, testDBFactory, nil, nil, archiveMode, nil) node := New(host, consensus, testDBFactory, nil, nil, nil, archiveMode, nil)
consensus.Blockchain = node.Blockchain() consensus.Blockchain = node.Blockchain()
txs := make(map[common.Address]types.Transactions) txs := make(map[common.Address]types.Transactions)

@ -40,7 +40,7 @@ func TestFinalizeNewBlockAsync(t *testing.T) {
t.Fatalf("Cannot craeate consensus: %v", err) t.Fatalf("Cannot craeate consensus: %v", err)
} }
var testDBFactory = &shardchain.MemDBFactory{} var testDBFactory = &shardchain.MemDBFactory{}
node := New(host, consensus, testDBFactory, nil, nil, nil, nil) node := New(host, consensus, testDBFactory, nil, nil, nil, nil, nil)
node.Worker.UpdateCurrent() node.Worker.UpdateCurrent()

@ -39,7 +39,7 @@ func TestNewNode(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Cannot craeate consensus: %v", err) t.Fatalf("Cannot craeate consensus: %v", err)
} }
node := New(host, consensus, testDBFactory, nil, nil, nil, nil) node := New(host, consensus, testDBFactory, nil, nil, nil, nil, nil)
if node.Consensus == nil { if node.Consensus == nil {
t.Error("Consensus is not initialized for the node") t.Error("Consensus is not initialized for the node")
} }
@ -216,7 +216,7 @@ func TestAddBeaconPeer(t *testing.T) {
archiveMode := make(map[uint32]bool) archiveMode := make(map[uint32]bool)
archiveMode[0] = true archiveMode[0] = true
archiveMode[1] = false archiveMode[1] = false
node := New(host, consensus, testDBFactory, nil, nil, archiveMode, nil) node := New(host, consensus, testDBFactory, nil, nil, nil, archiveMode, nil)
for _, p := range peers1 { for _, p := range peers1 {
ret := node.AddBeaconPeer(p) ret := node.AddBeaconPeer(p)
if ret { if ret {

@ -1,4 +1,4 @@
Version = "2.5.3" Version = "2.5.4"
[BLSKeys] [BLSKeys]
KMSConfigFile = "" KMSConfigFile = ""
@ -12,6 +12,10 @@ Version = "2.5.3"
PassSrcType = "auto" PassSrcType = "auto"
SavePassphrase = false SavePassphrase = false
[Consensus]
AggregateSig = false
MinPeers = 5
[DNSSync] [DNSSync]
Client = true Client = true
LegacySyncing = false LegacySyncing = false
@ -22,6 +26,7 @@ Version = "2.5.3"
[General] [General]
DataDir = "/data" DataDir = "/data"
EnablePruneBeaconChain = false
IsArchival = true IsArchival = true
IsBackup = false IsBackup = false
IsBeaconArchival = true IsBeaconArchival = true
@ -29,9 +34,7 @@ Version = "2.5.3"
NoStaking = true NoStaking = true
NodeType = "explorer" NodeType = "explorer"
ShardID = 0 ShardID = 0
TraceEnable = false
[Consensus]
MinPeers = 5
[HTTP] [HTTP]
AuthPort = 9501 AuthPort = 9501
@ -57,12 +60,12 @@ Version = "2.5.3"
NetworkType = "mainnet" NetworkType = "mainnet"
[P2P] [P2P]
DisablePrivateIPScan = false
DiscConcurrency = 0 DiscConcurrency = 0
IP = "0.0.0.0" IP = "0.0.0.0"
KeyFile = "./.hmykey" KeyFile = "./.hmykey"
MaxConnsPerIP = 10 MaxConnsPerIP = 10
Port = 9000 Port = 9000
DisablePrivateIPScan = false
[Pprof] [Pprof]
Enabled = false Enabled = false
@ -75,11 +78,18 @@ Version = "2.5.3"
[RPCOpt] [RPCOpt]
DebugEnabled = false DebugEnabled = false
EthRPCsEnabled = true EthRPCsEnabled = true
StakingRPCsEnabled = true
LegacyRPCsEnabled = true LegacyRPCsEnabled = true
RpcFilterFile = "./.hmy/rpc_filter.txt"
RateLimterEnabled = true RateLimterEnabled = true
RequestsPerSecond = 1000 RequestsPerSecond = 1000
RpcFilterFile = "./.hmy/rpc_filter.txt"
StakingRPCsEnabled = true
[ShardData]
CacheSize = 512
CacheTime = 10
DiskCount = 8
EnableShardData = true
ShardCount = 4
[Sync] [Sync]
Concurrency = 7 Concurrency = 7
@ -93,17 +103,11 @@ Version = "2.5.3"
MinPeers = 5 MinPeers = 5
[TxPool] [TxPool]
BlacklistFile = "./.hmy/blacklist.txt"
RosettaFixFile = "./rosetta_local_fix.csv"
AccountSlots = 16 AccountSlots = 16
AllowedTxsFile = "./.hmy/allowedtxs.txt"
BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt" LocalAccountsFile = "./.hmy/locals.txt"
RosettaFixFile = "./rosetta_local_fix.csv"
[ShardData]
EnableShardData = true
DiskCount = 8
ShardCount = 4
CacheTime = 10
CacheSize = 512
[WS] [WS]
AuthPort = 9801 AuthPort = 9801

@ -1,4 +1,4 @@
Version = "2.5.3" Version = "2.5.4"
[BLSKeys] [BLSKeys]
KMSConfigFile = "" KMSConfigFile = ""
@ -12,6 +12,10 @@ Version = "2.5.3"
PassSrcType = "auto" PassSrcType = "auto"
SavePassphrase = false SavePassphrase = false
[Consensus]
AggregateSig = false
MinPeers = 2
[DNSSync] [DNSSync]
Client = true Client = true
LegacySyncing = false LegacySyncing = false
@ -22,6 +26,7 @@ Version = "2.5.3"
[General] [General]
DataDir = "/data" DataDir = "/data"
EnablePruneBeaconChain = false
IsArchival = true IsArchival = true
IsBackup = false IsBackup = false
IsBeaconArchival = true IsBeaconArchival = true
@ -29,9 +34,7 @@ Version = "2.5.3"
NoStaking = true NoStaking = true
NodeType = "explorer" NodeType = "explorer"
ShardID = 0 ShardID = 0
TraceEnable = false
[Consensus]
MinPeers = 2
[HTTP] [HTTP]
AuthPort = 9501 AuthPort = 9501
@ -57,12 +60,12 @@ Version = "2.5.3"
NetworkType = "partner" NetworkType = "partner"
[P2P] [P2P]
DisablePrivateIPScan = false
DiscConcurrency = 0 DiscConcurrency = 0
IP = "0.0.0.0" IP = "0.0.0.0"
KeyFile = "./.hmykey" KeyFile = "./.hmykey"
MaxConnsPerIP = 10 MaxConnsPerIP = 10
Port = 9000 Port = 9000
DisablePrivateIPScan = false
[Pprof] [Pprof]
Enabled = false Enabled = false
@ -75,11 +78,18 @@ Version = "2.5.3"
[RPCOpt] [RPCOpt]
DebugEnabled = false DebugEnabled = false
EthRPCsEnabled = true EthRPCsEnabled = true
StakingRPCsEnabled = true
LegacyRPCsEnabled = true LegacyRPCsEnabled = true
RpcFilterFile = "./.hmy/rpc_filter.txt"
RateLimterEnabled = true RateLimterEnabled = true
RequestsPerSecond = 1000 RequestsPerSecond = 1000
RpcFilterFile = "./.hmy/rpc_filter.txt"
StakingRPCsEnabled = true
[ShardData]
CacheSize = 512
CacheTime = 10
DiskCount = 8
EnableShardData = false
ShardCount = 4
[Sync] [Sync]
Concurrency = 7 Concurrency = 7
@ -93,16 +103,11 @@ Version = "2.5.3"
MinPeers = 2 MinPeers = 2
[TxPool] [TxPool]
BlacklistFile = "./.hmy/blacklist.txt"
AccountSlots = 16 AccountSlots = 16
AllowedTxsFile = "./.hmy/allowedtxs.txt"
BlacklistFile = "./.hmy/blacklist.txt"
LocalAccountsFile = "./.hmy/locals.txt" LocalAccountsFile = "./.hmy/locals.txt"
RosettaFixFile = ""
[ShardData]
EnableShardData = false
DiskCount = 8
ShardCount = 4
CacheTime = 10
CacheSize = 512
[WS] [WS]
AuthPort = 9801 AuthPort = 9801

Loading…
Cancel
Save