Use current ntwk version in mpool message check
This commit is contained in:
parent
9fc4a25bd1
commit
ed844c5283
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
)
|
)
|
||||||
@ -107,6 +106,8 @@ func (mp *MessagePool) checkMessages(ctx context.Context, msgs []*types.Message,
|
|||||||
curTs := mp.curTs
|
curTs := mp.curTs
|
||||||
mp.curTsLk.Unlock()
|
mp.curTsLk.Unlock()
|
||||||
|
|
||||||
|
epoch := curTs.Height()
|
||||||
|
|
||||||
var baseFee big.Int
|
var baseFee big.Int
|
||||||
if len(curTs.Blocks()) > 0 {
|
if len(curTs.Blocks()) > 0 {
|
||||||
baseFee = curTs.Blocks()[0].ParentBaseFee
|
baseFee = curTs.Blocks()[0].ParentBaseFee
|
||||||
@ -257,8 +258,14 @@ func (mp *MessagePool) checkMessages(ctx context.Context, msgs []*types.Message,
|
|||||||
Code: api.CheckStatusMessageValidity,
|
Code: api.CheckStatusMessageValidity,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
nv, err := mp.getNtwkVersion(epoch)
|
||||||
if err := m.ValidForBlockInclusion(0, build.NewestNetworkVersion); err != nil {
|
if err != nil {
|
||||||
|
check.OK = false
|
||||||
|
check.Err = fmt.Sprintf("error retrieving network version: %s", err.Error())
|
||||||
|
} else {
|
||||||
|
check.OK = true
|
||||||
|
}
|
||||||
|
if err := m.ValidForBlockInclusion(0, nv); err != nil {
|
||||||
check.OK = false
|
check.OK = false
|
||||||
check.Err = fmt.Sprintf("syntactically invalid message: %s", err.Error())
|
check.Err = fmt.Sprintf("syntactically invalid message: %s", err.Error())
|
||||||
} else {
|
} else {
|
||||||
@ -274,7 +281,7 @@ func (mp *MessagePool) checkMessages(ctx context.Context, msgs []*types.Message,
|
|||||||
// gas checks
|
// gas checks
|
||||||
|
|
||||||
// 4. Min Gas
|
// 4. Min Gas
|
||||||
minGas := vm.PricelistByVersion(build.NewestNetworkVersion).OnChainMessage(m.ChainLength())
|
minGas := vm.PricelistByVersion(nv).OnChainMessage(m.ChainLength())
|
||||||
|
|
||||||
check = api.MessageCheckStatus{
|
check = api.MessageCheckStatus{
|
||||||
Cid: m.Cid(),
|
Cid: m.Cid(),
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/go-state-types/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
lru "github.com/hashicorp/golang-lru"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@ -29,6 +30,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
@ -147,6 +149,8 @@ type MessagePool struct {
|
|||||||
|
|
||||||
minGasPrice types.BigInt
|
minGasPrice types.BigInt
|
||||||
|
|
||||||
|
getNtwkVersion func(abi.ChainEpoch) (network.Version, error)
|
||||||
|
|
||||||
currentSize int
|
currentSize int
|
||||||
|
|
||||||
// pruneTrigger is a channel used to trigger a mempool pruning
|
// pruneTrigger is a channel used to trigger a mempool pruning
|
||||||
@ -362,26 +366,31 @@ func New(api Provider, ds dtypes.MetadataDS, netName dtypes.NetworkName, j journ
|
|||||||
if j == nil {
|
if j == nil {
|
||||||
j = journal.NilJournal()
|
j = journal.NilJournal()
|
||||||
}
|
}
|
||||||
|
us := stmgr.DefaultUpgradeSchedule()
|
||||||
|
if err := us.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
mp := &MessagePool{
|
mp := &MessagePool{
|
||||||
ds: ds,
|
ds: ds,
|
||||||
addSema: make(chan struct{}, 1),
|
addSema: make(chan struct{}, 1),
|
||||||
closer: make(chan struct{}),
|
closer: make(chan struct{}),
|
||||||
repubTk: build.Clock.Ticker(RepublishInterval),
|
repubTk: build.Clock.Ticker(RepublishInterval),
|
||||||
repubTrigger: make(chan struct{}, 1),
|
repubTrigger: make(chan struct{}, 1),
|
||||||
localAddrs: make(map[address.Address]struct{}),
|
localAddrs: make(map[address.Address]struct{}),
|
||||||
pending: make(map[address.Address]*msgSet),
|
pending: make(map[address.Address]*msgSet),
|
||||||
keyCache: make(map[address.Address]address.Address),
|
keyCache: make(map[address.Address]address.Address),
|
||||||
minGasPrice: types.NewInt(0),
|
minGasPrice: types.NewInt(0),
|
||||||
pruneTrigger: make(chan struct{}, 1),
|
getNtwkVersion: us.GetNtwkVersion,
|
||||||
pruneCooldown: make(chan struct{}, 1),
|
pruneTrigger: make(chan struct{}, 1),
|
||||||
blsSigCache: cache,
|
pruneCooldown: make(chan struct{}, 1),
|
||||||
sigValCache: verifcache,
|
blsSigCache: cache,
|
||||||
changes: lps.New(50),
|
sigValCache: verifcache,
|
||||||
localMsgs: namespace.Wrap(ds, datastore.NewKey(localMsgsDs)),
|
changes: lps.New(50),
|
||||||
api: api,
|
localMsgs: namespace.Wrap(ds, datastore.NewKey(localMsgsDs)),
|
||||||
netName: netName,
|
api: api,
|
||||||
cfg: cfg,
|
netName: netName,
|
||||||
|
cfg: cfg,
|
||||||
evtTypes: [...]journal.EventType{
|
evtTypes: [...]journal.EventType{
|
||||||
evtTypeMpoolAdd: j.RegisterEventType("mpool", "add"),
|
evtTypeMpoolAdd: j.RegisterEventType("mpool", "add"),
|
||||||
evtTypeMpoolRemove: j.RegisterEventType("mpool", "remove"),
|
evtTypeMpoolRemove: j.RegisterEventType("mpool", "remove"),
|
||||||
|
@ -296,6 +296,18 @@ func (us UpgradeSchedule) Validate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (us UpgradeSchedule) GetNtwkVersion(e abi.ChainEpoch) (network.Version, error) {
|
||||||
|
// Traverse from newest to oldest returning upgrade active during epoch e
|
||||||
|
for i := len(us) - 1; i >= 0; i-- {
|
||||||
|
u := us[i]
|
||||||
|
// u.Height is the last epoch before u.Network becomes the active version
|
||||||
|
if u.Height < e {
|
||||||
|
return u.Network, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return network.Version0, xerrors.Errorf("Epoch %d has no defined network version")
|
||||||
|
}
|
||||||
|
|
||||||
func (sm *StateManager) handleStateForks(ctx context.Context, root cid.Cid, height abi.ChainEpoch, cb ExecMonitor, ts *types.TipSet) (cid.Cid, error) {
|
func (sm *StateManager) handleStateForks(ctx context.Context, root cid.Cid, height abi.ChainEpoch, cb ExecMonitor, ts *types.TipSet) (cid.Cid, error) {
|
||||||
retCid := root
|
retCid := root
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
Reference in New Issue
Block a user