Config for default max gas fee
This commit is contained in:
@@ -268,6 +268,7 @@ func Online() Option {
|
||||
Override(new(*chain.Syncer), modules.NewSyncer),
|
||||
Override(new(exchange.Client), exchange.NewClient),
|
||||
Override(new(*messagepool.MessagePool), modules.MessagePool),
|
||||
Override(new(dtypes.DefaultMaxFeeFunc), modules.NewDefaultMaxFeeFunc),
|
||||
|
||||
Override(new(modules.Genesis), modules.ErrorGenesis),
|
||||
Override(new(dtypes.AfterGenesisSet), modules.SetGenesis),
|
||||
|
||||
@@ -23,6 +23,7 @@ type FullNode struct {
|
||||
Client Client
|
||||
Metrics Metrics
|
||||
Wallet Wallet
|
||||
Fees FeeConfig
|
||||
}
|
||||
|
||||
// // Common
|
||||
@@ -115,6 +116,10 @@ type Wallet struct {
|
||||
DisableLocal bool
|
||||
}
|
||||
|
||||
type FeeConfig struct {
|
||||
DefaultMaxFee types.FIL
|
||||
}
|
||||
|
||||
func defCommon() Common {
|
||||
return Common{
|
||||
API: API{
|
||||
@@ -142,10 +147,15 @@ func defCommon() Common {
|
||||
|
||||
}
|
||||
|
||||
var DefaultDefaultMaxFee = types.MustParseFIL("0.007")
|
||||
|
||||
// DefaultFullNode returns the default config
|
||||
func DefaultFullNode() *FullNode {
|
||||
return &FullNode{
|
||||
Common: defCommon(),
|
||||
Fees: FeeConfig{
|
||||
DefaultMaxFee: DefaultDefaultMaxFee,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
)
|
||||
|
||||
type GasModuleAPI interface {
|
||||
@@ -34,9 +35,10 @@ type GasModuleAPI interface {
|
||||
// Injection (for example with a thin RPC client).
|
||||
type GasModule struct {
|
||||
fx.In
|
||||
Stmgr *stmgr.StateManager
|
||||
Chain *store.ChainStore
|
||||
Mpool *messagepool.MessagePool
|
||||
Stmgr *stmgr.StateManager
|
||||
Chain *store.ChainStore
|
||||
Mpool *messagepool.MessagePool
|
||||
GetMaxFee dtypes.DefaultMaxFeeFunc
|
||||
}
|
||||
|
||||
var _ GasModuleAPI = (*GasModule)(nil)
|
||||
@@ -291,7 +293,7 @@ func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Messag
|
||||
msg.GasFeeCap = feeCap
|
||||
}
|
||||
|
||||
messagepool.CapGasFee(msg, spec.Get().MaxFee)
|
||||
messagepool.CapGasFee(m.GetMaxFee, msg, spec.Get().MaxFee)
|
||||
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/api/apistruct"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/addrutil"
|
||||
"github.com/filecoin-project/lotus/node/config"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
)
|
||||
@@ -105,3 +107,28 @@ func DrandBootstrap(ds dtypes.DrandSchedule) (dtypes.DrandBootstrap, error) {
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func NewDefaultMaxFeeFunc(r repo.LockedRepo) dtypes.DefaultMaxFeeFunc {
|
||||
return func() (out abi.TokenAmount, err error) {
|
||||
err = readNodeCfg(r, func(cfg *config.FullNode) {
|
||||
out = abi.TokenAmount(cfg.Fees.DefaultMaxFee)
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func readNodeCfg(r repo.LockedRepo, accessor func(node *config.FullNode)) error {
|
||||
raw, err := r.Config()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cfg, ok := raw.(*config.FullNode)
|
||||
if !ok {
|
||||
return xerrors.New("expected config.FullNode")
|
||||
}
|
||||
|
||||
accessor(cfg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
)
|
||||
|
||||
type MpoolLocker struct {
|
||||
@@ -33,3 +34,5 @@ func (ml *MpoolLocker) TakeLock(ctx context.Context, a address.Address) (func(),
|
||||
<-lk
|
||||
}, nil
|
||||
}
|
||||
|
||||
type DefaultMaxFeeFunc func() (abi.TokenAmount, error)
|
||||
|
||||
Reference in New Issue
Block a user