diff --git a/action/protocol/poll/protocol.go b/action/protocol/poll/protocol.go index ed2acb5ff5..346daa7491 100644 --- a/action/protocol/poll/protocol.go +++ b/action/protocol/poll/protocol.go @@ -19,13 +19,15 @@ import ( "github.com/iotexproject/iotex-core/action/protocol/execution/evm" "github.com/iotexproject/iotex-core/action/protocol/staking" "github.com/iotexproject/iotex-core/action/protocol/vote" - "github.com/iotexproject/iotex-core/config" + "github.com/iotexproject/iotex-core/blockchain" + "github.com/iotexproject/iotex-core/blockchain/genesis" "github.com/iotexproject/iotex-core/pkg/log" "github.com/iotexproject/iotex-core/state" ) const ( - _protocolID = "poll" + _protocolID = "poll" + _rollDPoSScheme = "ROLLDPOS" ) const ( @@ -122,7 +124,9 @@ func MustGetProtocol(registry *protocol.Registry) Protocol { // NewProtocol instantiates a rewarding protocol instance. func NewProtocol( - cfg config.Config, + scheme string, + chainConfig blockchain.Config, + genesisConfig genesis.Genesis, candidateIndexer *CandidateIndexer, readContract ReadContract, getCandidates GetCandidates, @@ -134,8 +138,7 @@ func NewProtocol( productivity Productivity, getBlockHash evm.GetBlockHash, ) (Protocol, error) { - genesisConfig := cfg.Genesis - if cfg.Consensus.Scheme != config.RollDPoSScheme { + if scheme != _rollDPoSScheme { return nil, nil } @@ -165,9 +168,9 @@ func NewProtocol( if err != nil { return nil, err } - scoreThreshold, ok = new(big.Int).SetString(cfg.Genesis.ScoreThreshold, 10) + scoreThreshold, ok = new(big.Int).SetString(genesisConfig.ScoreThreshold, 10) if !ok { - return nil, errors.Errorf("failed to parse score threshold %s", cfg.Genesis.ScoreThreshold) + return nil, errors.Errorf("failed to parse score threshold %s", genesisConfig.ScoreThreshold) } } @@ -182,7 +185,7 @@ func NewProtocol( electionCommittee, genesisConfig.GravityChainStartHeight, getBlockTimeFunc, - cfg.Chain.PollInitialCandidatesInterval, + chainConfig.PollInitialCandidatesInterval, slasher, ) if err != nil { @@ -192,8 +195,8 @@ func NewProtocol( electionCommittee, governance, readContract, - cfg.Genesis.NativeStakingContractAddress, - cfg.Genesis.NativeStakingContractCode, + genesisConfig.NativeStakingContractAddress, + genesisConfig.NativeStakingContractCode, scoreThreshold, ) if err != nil { diff --git a/action/protocol/poll/protocol_test.go b/action/protocol/poll/protocol_test.go index ec558e5ba1..bbbc799f8b 100644 --- a/action/protocol/poll/protocol_test.go +++ b/action/protocol/poll/protocol_test.go @@ -18,18 +18,20 @@ import ( "github.com/iotexproject/iotex-election/test/mock/mock_committee" "github.com/iotexproject/iotex-core/action/protocol" - "github.com/iotexproject/iotex-core/config" + "github.com/iotexproject/iotex-core/blockchain" + "github.com/iotexproject/iotex-core/blockchain/genesis" ) func TestNewProtocol(t *testing.T) { require := require.New(t) ctrl := gomock.NewController(t) committee := mock_committee.NewMockCommittee(ctrl) - cfg := config.Default - cfg.Consensus.Scheme = config.RollDPoSScheme - cfg.Genesis.ScoreThreshold = "1200000" + g := genesis.Default + g.ScoreThreshold = "1200000" p, err := NewProtocol( - cfg, + _rollDPoSScheme, + blockchain.DefaultConfig, + g, nil, func(context.Context, string, []byte, bool) ([]byte, error) { return nil, nil }, nil, diff --git a/action/protocol/rewarding/reward_test.go b/action/protocol/rewarding/reward_test.go index 5b5ecebaa9..71f554e7df 100644 --- a/action/protocol/rewarding/reward_test.go +++ b/action/protocol/rewarding/reward_test.go @@ -26,8 +26,8 @@ import ( "github.com/iotexproject/iotex-core/action/protocol/poll" "github.com/iotexproject/iotex-core/action/protocol/rewarding/rewardingpb" "github.com/iotexproject/iotex-core/action/protocol/rolldpos" + "github.com/iotexproject/iotex-core/blockchain" "github.com/iotexproject/iotex-core/blockchain/genesis" - "github.com/iotexproject/iotex-core/config" "github.com/iotexproject/iotex-core/db/batch" "github.com/iotexproject/iotex-core/pkg/unit" "github.com/iotexproject/iotex-core/state" @@ -365,7 +365,7 @@ func TestProtocol_NoRewardAddr(t *testing.T) { RewardAddress: identityset.Address(1).String(), }, } - cfg := config.Default + g := genesis.Default committee := mock_committee.NewMockCommittee(ctrl) slasher, err := poll.NewSlasher( func(uint64, uint64) (map[string]uint64, error) { @@ -382,18 +382,18 @@ func TestProtocol_NoRewardAddr(t *testing.T) { nil, 2, 2, - cfg.Genesis.DardanellesNumSubEpochs, - cfg.Genesis.ProductivityThreshold, - cfg.Genesis.ProbationEpochPeriod, - cfg.Genesis.UnproductiveDelegateMaxCacheSize, - cfg.Genesis.ProbationIntensityRate) + g.DardanellesNumSubEpochs, + g.ProductivityThreshold, + g.ProbationEpochPeriod, + g.UnproductiveDelegateMaxCacheSize, + g.ProbationIntensityRate) require.NoError(t, err) pp, err := poll.NewGovernanceChainCommitteeProtocol( nil, committee, uint64(123456), func(uint64) (time.Time, error) { return time.Now(), nil }, - cfg.Chain.PollInitialCandidatesInterval, + blockchain.DefaultConfig.PollInitialCandidatesInterval, slasher, ) require.NoError(t, err) diff --git a/actpool/actpool.go b/actpool/actpool.go index 9d3018ec3a..37673b92b7 100644 --- a/actpool/actpool.go +++ b/actpool/actpool.go @@ -25,7 +25,6 @@ import ( accountutil "github.com/iotexproject/iotex-core/action/protocol/account/util" "github.com/iotexproject/iotex-core/blockchain/block" "github.com/iotexproject/iotex-core/blockchain/genesis" - "github.com/iotexproject/iotex-core/config" "github.com/iotexproject/iotex-core/pkg/log" "github.com/iotexproject/iotex-core/pkg/prometheustimer" "github.com/iotexproject/iotex-core/pkg/tracer" @@ -94,7 +93,7 @@ func EnableExperimentalActions() Option { // actPool implements ActPool interface type actPool struct { mutex sync.RWMutex - cfg config.ActPool + cfg Config g genesis.Genesis sf protocol.StateReader accountActs map[string]ActQueue @@ -108,7 +107,7 @@ type actPool struct { } // NewActPool constructs a new actpool -func NewActPool(g genesis.Genesis, sf protocol.StateReader, cfg config.ActPool, opts ...Option) (ActPool, error) { +func NewActPool(g genesis.Genesis, sf protocol.StateReader, cfg Config, opts ...Option) (ActPool, error) { if sf == nil { return nil, errors.New("Try to attach a nil state reader") } diff --git a/actpool/actpool_test.go b/actpool/actpool_test.go index 3aeb962c52..2a4bea4993 100644 --- a/actpool/actpool_test.go +++ b/actpool/actpool_test.go @@ -31,7 +31,6 @@ import ( accountutil "github.com/iotexproject/iotex-core/action/protocol/account/util" "github.com/iotexproject/iotex-core/action/protocol/rewarding" "github.com/iotexproject/iotex-core/blockchain" - "github.com/iotexproject/iotex-core/config" "github.com/iotexproject/iotex-core/test/identityset" "github.com/iotexproject/iotex-core/testutil" ) @@ -61,28 +60,27 @@ var ( func TestActPool_NewActPool(t *testing.T) { ctrl := gomock.NewController(t) require := require.New(t) - cfg := config.Default //error caused by nil blockchain - _, err := NewActPool(cfg.Genesis, nil, cfg.ActPool, nil) + _, err := NewActPool(genesis.Default, nil, DefaultConfig, nil) require.Error(err) // all good opt := EnableExperimentalActions() - require.Panics(func() { blockchain.NewBlockchain(cfg.Chain, cfg.Genesis, nil, nil, nil) }, "option is nil") + require.Panics(func() { blockchain.NewBlockchain(blockchain.DefaultConfig, genesis.Default, nil, nil, nil) }, "option is nil") sf := mock_chainmanager.NewMockStateReader(ctrl) - act, err := NewActPool(cfg.Genesis, sf, cfg.ActPool, opt) + act, err := NewActPool(genesis.Default, sf, DefaultConfig, opt) require.NoError(err) require.NotNil(act) // panic caused by option is nil - require.Panics(func() { NewActPool(cfg.Genesis, sf, cfg.ActPool, nil) }, "option is nil") + require.Panics(func() { NewActPool(genesis.Default, sf, DefaultConfig, nil) }, "option is nil") // error caused by option opt2 := func(pool *actPool) error { return errors.New("test error") } - _, err = NewActPool(cfg.Genesis, sf, cfg.ActPool, opt2) + _, err = NewActPool(genesis.Default, sf, DefaultConfig, opt2) require.Error(err) // test AddAction nil @@ -92,21 +90,22 @@ func TestActPool_NewActPool(t *testing.T) { func TestValidate(t *testing.T) { require := require.New(t) ctrl := gomock.NewController(t) - cfg := config.Default - cfg.Genesis.InitBalanceMap[_addr1] = "100" + + g := genesis.Default + g.InitBalanceMap[_addr1] = "100" re := protocol.NewRegistry() acc := account.NewProtocol(rewarding.DepositGas) require.NoError(acc.Register(re)) ctx := genesis.WithGenesisContext( protocol.WithRegistry(context.Background(), re), - cfg.Genesis, + g, ) sf := mock_chainmanager.NewMockStateReader(ctrl) sev := mock_sealed_envelope_validator.NewMockSealedEnvelopeValidator(ctrl) mockError := errors.New("mock error") sev.EXPECT().Validate(gomock.Any(), gomock.Any()).Return(mockError).Times(1) apConfig := getActPoolCfg() - Ap, err := NewActPool(cfg.Genesis, sf, apConfig, EnableExperimentalActions()) + Ap, err := NewActPool(g, sf, apConfig, EnableExperimentalActions()) require.NoError(err) ap, ok := Ap.(*actPool) require.True(ok) @@ -166,7 +165,7 @@ func TestActPool_AddActs(t *testing.T) { tsf8, err := action.SignedTransfer(_addr2, _priKey2, uint64(4), big.NewInt(5), []byte{}, uint64(100000), big.NewInt(0)) require.NoError(err) - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) require.NoError(ap.Add(ctx, tsf3)) @@ -294,8 +293,8 @@ func TestActPool_PickActs(t *testing.T) { ctrl := gomock.NewController(t) require := require.New(t) sf := mock_chainmanager.NewMockStateReader(ctrl) - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) - createActPool := func(cfg config.ActPool) (*actPool, []action.SealedEnvelope, []action.SealedEnvelope, []action.SealedEnvelope) { + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + createActPool := func(cfg Config) (*actPool, []action.SealedEnvelope, []action.SealedEnvelope, []action.SealedEnvelope) { // Create actpool Ap, err := NewActPool(genesis.Default, sf, cfg, EnableExperimentalActions()) require.NoError(err) @@ -400,7 +399,7 @@ func TestActPool_removeConfirmedActs(t *testing.T) { return 0, nil }).Times(8) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) require.NoError(ap.Add(ctx, tsf3)) @@ -506,7 +505,7 @@ func TestActPool_Reset(t *testing.T) { tsf9, err := action.SignedTransfer(_addr1, _priKey3, uint64(4), big.NewInt(100), []byte{}, uint64(20000), big.NewInt(0)) require.NoError(err) - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) require.NoError(ap1.Add(ctx, tsf1)) require.NoError(ap1.Add(ctx, tsf2)) err = ap1.Add(ctx, tsf3) @@ -815,7 +814,7 @@ func TestActPool_removeInvalidActs(t *testing.T) { return 0, nil }).Times(8) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) require.NoError(ap.Add(ctx, tsf3)) @@ -862,7 +861,7 @@ func TestActPool_GetPendingNonce(t *testing.T) { }).Times(10) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf3)) require.NoError(ap.Add(ctx, tsf4)) @@ -910,7 +909,7 @@ func TestActPool_GetUnconfirmedActs(t *testing.T) { return 0, nil }).Times(10) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf3)) require.NoError(ap.Add(ctx, tsf4)) @@ -1011,7 +1010,7 @@ func TestActPool_GetSize(t *testing.T) { return 0, nil }).Times(8) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) require.NoError(ap.Add(ctx, tsf3)) @@ -1037,7 +1036,7 @@ func TestActPool_AddActionNotEnoughGasPrice(t *testing.T) { ctrl := gomock.NewController(t) sf := mock_chainmanager.NewMockStateReader(ctrl) - apConfig := config.Default.ActPool + apConfig := DefaultConfig ap, err := NewActPool(genesis.Default, sf, apConfig, EnableExperimentalActions()) require.NoError(t, err) tsf, err := action.SignedTransfer( @@ -1052,7 +1051,7 @@ func TestActPool_AddActionNotEnoughGasPrice(t *testing.T) { require.NoError(t, err) ctx := protocol.WithBlockchainCtx(context.Background(), protocol.BlockchainCtx{}) - ctx = genesis.WithGenesisContext(ctx, config.Default.Genesis) + ctx = genesis.WithGenesisContext(ctx, genesis.Default) require.Error(t, ap.Add(ctx, tsf)) } @@ -1088,7 +1087,7 @@ func TestActPool_SpeedUpAction(t *testing.T) { require.NoError(err) // A send action tsf1 with nonce 1, B send action tsf2 with nonce 1 - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) @@ -1140,7 +1139,7 @@ func (ap *actPool) getPendingNonce(addr string) (uint64, error) { return 0, err } committedState, err := accountutil.AccountState( - genesis.WithGenesisContext(context.Background(), config.Default.Genesis), + genesis.WithGenesisContext(context.Background(), genesis.Default), ap.sf, _addr1, ) @@ -1160,7 +1159,7 @@ func (ap *actPool) getPendingBalance(addr string) (*big.Int, error) { return nil, err } state, err := accountutil.AccountState( - genesis.WithGenesisContext(context.Background(), config.Default.Genesis), + genesis.WithGenesisContext(context.Background(), genesis.Default), ap.sf, _addr1, ) @@ -1171,8 +1170,8 @@ func (ap *actPool) getPendingBalance(addr string) (*big.Int, error) { return state.Balance, nil } -func getActPoolCfg() config.ActPool { - return config.ActPool{ +func getActPoolCfg() Config { + return Config{ MaxNumActsPerPool: _maxNumActsPerPool, MaxGasLimitPerPool: _maxGasLimitPerPool, MaxNumActsPerAcct: _maxNumActsPerAcct, @@ -1196,3 +1195,9 @@ func lenPendingActionMap(acts map[string][]action.SealedEnvelope) int { } return l } + +func TestValidateMinGasPrice(t *testing.T) { + ap := Config{MinGasPriceStr: DefaultConfig.MinGasPriceStr} + mgp := ap.MinGasPrice() + require.IsType(t, &big.Int{}, mgp) +} diff --git a/actpool/actqueue_test.go b/actpool/actqueue_test.go index 3e52da2b5e..cd7a5044c4 100644 --- a/actpool/actqueue_test.go +++ b/actpool/actqueue_test.go @@ -22,7 +22,6 @@ import ( "github.com/iotexproject/iotex-core/action" "github.com/iotexproject/iotex-core/action/protocol" "github.com/iotexproject/iotex-core/blockchain/genesis" - "github.com/iotexproject/iotex-core/config" "github.com/iotexproject/iotex-core/state" "github.com/iotexproject/iotex-core/test/identityset" "github.com/iotexproject/iotex-core/test/mock/mock_chainmanager" @@ -128,14 +127,14 @@ func TestActQueueUpdateNonce(t *testing.T) { func TestActQueuePendingActs(t *testing.T) { ctrl := gomock.NewController(t) require := require.New(t) - cfg := config.Default + sf := mock_chainmanager.NewMockStateReader(ctrl) sf.EXPECT().State(gomock.Any(), gomock.Any()).Do(func(accountState *state.Account, _ protocol.StateOption) { require.NoError(accountState.SetPendingNonce(accountState.PendingNonce() + 1)) }).Return(uint64(0), nil).Times(1) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() - ctx := genesis.WithGenesisContext(context.Background(), config.Default.Genesis) - ap, err := NewActPool(cfg.Genesis, sf, cfg.ActPool, EnableExperimentalActions()) + ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ap, err := NewActPool(genesis.Default, sf, DefaultConfig, EnableExperimentalActions()) require.NoError(err) q := NewActQueue(ap.(*actPool), identityset.Address(0).String()).(*actQueue) tsf1, err := action.SignedTransfer(_addr2, _priKey1, 2, big.NewInt(100), nil, uint64(0), big.NewInt(0)) diff --git a/actpool/config.go b/actpool/config.go new file mode 100644 index 0000000000..4ee79675ef --- /dev/null +++ b/actpool/config.go @@ -0,0 +1,46 @@ +package actpool + +import ( + "math/big" + "time" + + "github.com/iotexproject/iotex-core/pkg/log" + "github.com/iotexproject/iotex-core/pkg/unit" +) + +var ( + // DefaultConfig is the default config for actpool + DefaultConfig = Config{ + MaxNumActsPerPool: 32000, + MaxGasLimitPerPool: 320000000, + MaxNumActsPerAcct: 2000, + ActionExpiry: 10 * time.Minute, + MinGasPriceStr: big.NewInt(unit.Qev).String(), + BlackList: []string{}, + } +) + +// Config is the actpool config +type Config struct { + // MaxNumActsPerPool indicates maximum number of actions the whole actpool can hold + MaxNumActsPerPool uint64 `yaml:"maxNumActsPerPool"` + // MaxGasLimitPerPool indicates maximum gas limit the whole actpool can hold + MaxGasLimitPerPool uint64 `yaml:"maxGasLimitPerPool"` + // MaxNumActsPerAcct indicates maximum number of actions an account queue can hold + MaxNumActsPerAcct uint64 `yaml:"maxNumActsPerAcct"` + // ActionExpiry defines how long an action will be kept in action pool. + ActionExpiry time.Duration `yaml:"actionExpiry"` + // MinGasPriceStr defines the minimal gas price the delegate will accept for an action + MinGasPriceStr string `yaml:"minGasPrice"` + // BlackList lists the account address that are banned from initiating actions + BlackList []string `yaml:"blackList"` +} + +// MinGasPrice returns the minimal gas price threshold +func (ap Config) MinGasPrice() *big.Int { + mgp, ok := new(big.Int).SetString(ap.MinGasPriceStr, 10) + if !ok { + log.S().Panicf("Error when parsing minimal gas price string: %s", ap.MinGasPriceStr) + } + return mgp +} diff --git a/api/serverV2_integrity_test.go b/api/serverV2_integrity_test.go index 1a3f367aed..b06fbf0cd0 100644 --- a/api/serverV2_integrity_test.go +++ b/api/serverV2_integrity_test.go @@ -355,7 +355,7 @@ func setupChain(cfg config.Config) (blockchain.Blockchain, blockdao.BlockDAO, bl return bc, dao, indexer, bfIndexer, sf, ap, registry, testPath, nil } -func setupActPool(g genesis.Genesis, sf factory.Factory, cfg config.ActPool) (actpool.ActPool, error) { +func setupActPool(g genesis.Genesis, sf factory.Factory, cfg actpool.Config) (actpool.ActPool, error) { ap, err := actpool.NewActPool(g, sf, cfg, actpool.EnableExperimentalActions()) if err != nil { return nil, err diff --git a/chainservice/builder.go b/chainservice/builder.go index f118ba42ac..573d1cc3da 100644 --- a/chainservice/builder.go +++ b/chainservice/builder.go @@ -480,7 +480,9 @@ func (builder *Builder) registerRollDPoSProtocol() error { dao := builder.cs.blockdao chain := builder.cs.chain pollProtocol, err := poll.NewProtocol( - builder.cfg, + builder.cfg.Consensus.Scheme, + builder.cfg.Chain, + builder.cfg.Genesis, builder.cs.candidateIndexer, func(ctx context.Context, contract string, params []byte, correctGas bool) ([]byte, error) { gasLimit := uint64(1000000) diff --git a/config/config.go b/config/config.go index f6d8a143a9..a2ce9b4e55 100644 --- a/config/config.go +++ b/config/config.go @@ -7,7 +7,6 @@ package config import ( - "math/big" "os" "strings" "time" @@ -15,6 +14,7 @@ import ( "github.com/pkg/errors" uconfig "go.uber.org/config" + "github.com/iotexproject/iotex-core/actpool" "github.com/iotexproject/iotex-core/blockchain" "github.com/iotexproject/iotex-core/blockchain/genesis" "github.com/iotexproject/iotex-core/db" @@ -61,14 +61,7 @@ var ( SubLogs: make(map[string]log.GlobalConfig), Network: p2p.DefaultConfig, Chain: blockchain.DefaultConfig, - ActPool: ActPool{ - MaxNumActsPerPool: 32000, - MaxGasLimitPerPool: 320000000, - MaxNumActsPerAcct: 2000, - ActionExpiry: 10 * time.Minute, - MinGasPriceStr: big.NewInt(unit.Qev).String(), - BlackList: []string{}, - }, + ActPool: actpool.DefaultConfig, Consensus: Consensus{ Scheme: StandaloneScheme, RollDPoS: RollDPoS{ @@ -244,22 +237,6 @@ type ( SystemLogDBPath string `yaml:"systemLogDBPath"` } - // ActPool is the actpool config - ActPool struct { - // MaxNumActsPerPool indicates maximum number of actions the whole actpool can hold - MaxNumActsPerPool uint64 `yaml:"maxNumActsPerPool"` - // MaxGasLimitPerPool indicates maximum gas limit the whole actpool can hold - MaxGasLimitPerPool uint64 `yaml:"maxGasLimitPerPool"` - // MaxNumActsPerAcct indicates maximum number of actions an account queue can hold - MaxNumActsPerAcct uint64 `yaml:"maxNumActsPerAcct"` - // ActionExpiry defines how long an action will be kept in action pool. - ActionExpiry time.Duration `yaml:"actionExpiry"` - // MinGasPriceStr defines the minimal gas price the delegate will accept for an action - MinGasPriceStr string `yaml:"minGasPrice"` - // BlackList lists the account address that are banned from initiating actions - BlackList []string `yaml:"blackList"` - } - // Indexer is the config for indexer Indexer struct { // RangeBloomFilterNumElements is the number of elements each rangeBloomfilter will store in bloomfilterIndexer @@ -275,7 +252,7 @@ type ( Plugins map[int]interface{} `ymal:"plugins"` Network p2p.Config `yaml:"network"` Chain blockchain.Config `yaml:"chain"` - ActPool ActPool `yaml:"actPool"` + ActPool actpool.Config `yaml:"actPool"` Consensus Consensus `yaml:"consensus"` DardanellesUpgrade DardanellesUpgrade `yaml:"dardanellesUpgrade"` BlockSync BlockSync `yaml:"blockSync"` @@ -374,15 +351,6 @@ func NewSub(configPaths []string, validates ...Validate) (Config, error) { return cfg, nil } -// MinGasPrice returns the minimal gas price threshold -func (ap ActPool) MinGasPrice() *big.Int { - mgp, ok := new(big.Int).SetString(ap.MinGasPriceStr, 10) - if !ok { - log.S().Panicf("Error when parsing minimal gas price string: %s", ap.MinGasPriceStr) - } - return mgp -} - // ValidateDispatcher validates the dispatcher configs func ValidateDispatcher(cfg Config) error { if cfg.Dispatcher.ActionChanSize <= 0 || cfg.Dispatcher.BlockChanSize <= 0 || cfg.Dispatcher.BlockSyncChanSize <= 0 { diff --git a/config/config_test.go b/config/config_test.go index b391a53019..a98020861e 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -8,7 +8,6 @@ package config import ( "fmt" - "math/big" "os" "path/filepath" "strings" @@ -311,13 +310,6 @@ func TestValidateActPool(t *testing.T) { ) } -func TestValidateMinGasPrice(t *testing.T) { - ap := ActPool{MinGasPriceStr: Default.ActPool.MinGasPriceStr} - mgp := ap.MinGasPrice() - fmt.Printf("%T,%v", mgp, mgp) - require.IsType(t, &big.Int{}, mgp) -} - func TestValidateForkHeights(t *testing.T) { r := require.New(t)