Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxfee can be configured #4441

Merged
merged 1 commit into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion app/submodule/mpool/mpool_submodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func NewMpoolSubmodule(cfg messagepoolConfig,
if err != nil {
return nil, err
}
mp, err := messagepool.New(mpp, cfg.Repo().MetaDatastore(), cfg.Repo().Config().NetworkParams.ForkUpgradeParam, network.NetworkName, syncer.Consensus, chain.ChainReader, j)
mp, err := messagepool.New(mpp, cfg.Repo().MetaDatastore(), cfg.Repo().Config().NetworkParams.ForkUpgradeParam, cfg.Repo().Config().Mpool,
network.NetworkName, syncer.Consensus, chain.ChainReader, j)
if err != nil {
return nil, xerrors.Errorf("constructing mpool: %s", err)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/mpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
stdbig "math/big"

"github.com/filecoin-project/venus/app/node"
"github.com/filecoin-project/venus/pkg/config"
"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/pkg/messagepool"
"github.com/filecoin-project/venus/pkg/types"
Expand Down Expand Up @@ -326,7 +327,7 @@ var mpoolReplaceCmd = &cmds.Command{
msg.GasFeeCap = big.Max(retm.GasFeeCap, msg.GasPremium)

mff := func() (abi.TokenAmount, error) {
return abi.TokenAmount{Int: types.DefaultDefaultMaxFee.Int}, nil
return abi.TokenAmount{Int: config.DefaultDefaultMaxFee.Int}, nil
}

messagepool.CapGasFee(mff, &msg, mss)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ require (
github.com/filecoin-project/specs-actors/v4 v4.0.0
github.com/filecoin-project/specs-storage v0.1.1-0.20201105051918-5188d9774506
github.com/filecoin-project/test-vectors/schema v0.0.5
github.com/filecoin-project/venus-auth v1.0.2-0.20210507023017-76ce8b64e6db // indirect
github.com/filecoin-project/venus-wallet v1.0.1-0.20210507023531-5dfabaf5606d // indirect
github.com/filecoin-project/venus-auth v1.0.2-0.20210507023017-76ce8b64e6db
github.com/filecoin-project/venus-wallet v1.0.1-0.20210507023531-5dfabaf5606d
github.com/gbrlsnchs/jwt/v3 v3.0.0
github.com/go-errors/errors v1.0.1
github.com/go-kit/kit v0.10.0
Expand Down
14 changes: 11 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ import (
"github.com/pkg/errors"

"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/pkg/types"
)

const (
scryptN = 1 << 15
scryptP = 1
)

var DefaultDefaultMaxFee = types.MustParseFIL("0.007")

// Config is an in memory representation of the filecoin configuration file
type Config struct {
API *APIConfig `json:"api"`
Expand Down Expand Up @@ -208,16 +211,21 @@ func newDefaultTraceConfig() *TraceConfig {

// MessagePoolConfig holds all configuration options related to nodes message pool (mpool).
type MessagePoolConfig struct {
// MaxPoolSize is the maximum number of pending messages will will allow in the message pool at any time
MaxPoolSize uint `json:"maxPoolSize"`
// MaxNonceGap is the maximum nonce of a message past the last received on chain
MaxNonceGap uint64 `json:"maxNonceGap"`
// MaxFee
MaxFee types.FIL `json:"maxFee"`
}

var DefaultMessagePoolParam = &MessagePoolConfig{
MaxNonceGap: 100,
MaxFee: DefaultDefaultMaxFee,
}

func newDefaultMessagePoolConfig() *MessagePoolConfig {
return &MessagePoolConfig{
MaxPoolSize: 1000000,
MaxNonceGap: 100,
MaxFee: DefaultDefaultMaxFee,
}
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/messagepool/messagepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ type MessagePool struct {
GetMaxFee DefaultMaxFeeFunc
}

func newDefaultMaxFeeFunc() DefaultMaxFeeFunc {
func newDefaultMaxFeeFunc(maxFee types.FIL) DefaultMaxFeeFunc {
return func() (out abi.TokenAmount, err error) {
out = abi.TokenAmount{Int: types.DefaultDefaultMaxFee.Int}
out = abi.TokenAmount{Int: maxFee.Int}
return
}
}
Expand Down Expand Up @@ -384,6 +384,7 @@ func (ms *msgSet) getRequiredFunds(nonce uint64) tbig.Int {
func New(api Provider,
ds repo.Datastore,
forkParams *config.ForkUpgradeConfig,
mpoolCfg *config.MessagePoolConfig,
netName string,
gp gasPredictor,
ap actorProvider,
Expand Down Expand Up @@ -429,7 +430,7 @@ func New(api Provider,
journal: j,
forkParams: forkParams,
gasPriceSchedule: gas.NewPricesSchedule(forkParams),
GetMaxFee: newDefaultMaxFeeFunc(),
GetMaxFee: newDefaultMaxFeeFunc(mpoolCfg.MaxFee),
}

// enable initial prunes
Expand Down
12 changes: 6 additions & 6 deletions pkg/messagepool/messagepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func mustAdd(t *testing.T, mp *MessagePool, msg *types.SignedMessage) {
func newWalletAndMpool(t *testing.T, tma *testMpoolAPI) (*wallet.Wallet, *MessagePool) {
ds := datastore.NewMapDatastore()

mp, err := New(tma, ds, config.DefaultForkUpgradeParam, "mptest", nil, nil, nil)
mp, err := New(tma, ds, config.DefaultForkUpgradeParam, config.DefaultMessagePoolParam, "mptest", nil, nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -518,7 +518,7 @@ func TestLoadLocal(t *testing.T) {
tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore()

mp, err := New(tma, ds, config.DefaultForkUpgradeParam, "mptest", nil, nil, nil)
mp, err := New(tma, ds, config.DefaultForkUpgradeParam, config.DefaultMessagePoolParam, "mptest", nil, nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -554,7 +554,7 @@ func TestLoadLocal(t *testing.T) {
t.Fatal(err)
}

mp, err = New(tma, ds, config.DefaultForkUpgradeParam, "mptest", nil, nil, nil)
mp, err = New(tma, ds, config.DefaultForkUpgradeParam, config.DefaultMessagePoolParam, "mptest", nil, nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -585,7 +585,7 @@ func TestClearAll(t *testing.T) {
tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore()

mp, err := New(tma, ds, config.DefaultForkUpgradeParam, "mptest", nil, nil, nil)
mp, err := New(tma, ds, config.DefaultForkUpgradeParam, config.DefaultMessagePoolParam, "mptest", nil, nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -633,7 +633,7 @@ func TestClearNonLocal(t *testing.T) {
tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore()

mp, err := New(tma, ds, config.DefaultForkUpgradeParam, "mptest", nil, nil, nil)
mp, err := New(tma, ds, config.DefaultForkUpgradeParam, config.DefaultMessagePoolParam, "mptest", nil, nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -688,7 +688,7 @@ func TestUpdates(t *testing.T) {
tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore()

mp, err := New(tma, ds, config.DefaultForkUpgradeParam, "mptest", nil, nil, nil)
mp, err := New(tma, ds, config.DefaultForkUpgradeParam, config.DefaultMessagePoolParam, "mptest", nil, nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/messagepool/repub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestRepubMessages(t *testing.T) {
tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore()

mp, err := New(tma, ds, config.DefaultForkUpgradeParam, "mptest", nil, nil, nil)
mp, err := New(tma, ds, config.DefaultForkUpgradeParam, config.DefaultMessagePoolParam, "mptest", nil, nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/messagepool/selection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func makeTestMessage(w *wallet.Wallet, from, to address.Address, nonce uint64, g
func makeTestMpool() (*MessagePool, *testMpoolAPI) {
tma := newTestMpoolAPI()
ds := datastore.NewMapDatastore()
mp, err := New(tma, ds, config.DefaultForkUpgradeParam, "test", nil, nil, nil)
mp, err := New(tma, ds, config.DefaultForkUpgradeParam, config.DefaultMessagePoolParam, "test", nil, nil, nil)
if err != nil {
panic(err)
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/types/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"bytes"
"encoding/json"
"fmt"
specsbig "github.com/filecoin-project/go-state-types/big"
"math/big"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
specsbig "github.com/filecoin-project/go-state-types/big"
cbor2 "github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/go-state-types/network"
Expand All @@ -23,8 +23,6 @@ import (
"github.com/filecoin-project/venus/pkg/crypto"
)

var DefaultDefaultMaxFee = MustParseFIL("1") // 0.007

type MessageSendSpec struct {
MaxFee abi.TokenAmount
}
Expand Down