diff --git a/api/api_full.go b/api/api_full.go index 4dc39581f..bac0caaaf 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -144,8 +144,12 @@ type FullNode interface { // manages all incoming and outgoing 'messages' going over the network. // MpoolPending returns pending mempool messages. + // Deprecated: use MpoolSelect instead MpoolPending(context.Context, types.TipSetKey) ([]*types.SignedMessage, error) + // MpoolSelect returns a list of pending messages for inclusion in the next block + MpoolSelect(context.Context, types.TipSetKey) ([]*types.SignedMessage, error) + // MpoolPush pushes a signed message to mempool. MpoolPush(context.Context, *types.SignedMessage) (cid.Cid, error) diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 3e2285648..de107ac42 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -94,6 +94,7 @@ type FullNodeStruct struct { SyncMarkBad func(ctx context.Context, bcid cid.Cid) error `perm:"admin"` SyncCheckBad func(ctx context.Context, bcid cid.Cid) (string, error) `perm:"read"` + MpoolSelect func(context.Context, types.TipSetKey) ([]*types.SignedMessage, error) `perm:"read"` MpoolPending func(context.Context, types.TipSetKey) ([]*types.SignedMessage, error) `perm:"read"` MpoolPush func(context.Context, *types.SignedMessage) (cid.Cid, error) `perm:"write"` MpoolPushMessage func(context.Context, *types.Message) (*types.SignedMessage, error) `perm:"sign"` @@ -433,6 +434,10 @@ func (c *FullNodeStruct) GasEstimateGasLimit(ctx context.Context, msg *types.Mes return c.Internal.GasEstimateGasLimit(ctx, msg, tsk) } +func (c *FullNodeStruct) MpoolSelect(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) { + return c.Internal.MpoolSelect(ctx, tsk) +} + func (c *FullNodeStruct) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) { return c.Internal.MpoolPending(ctx, tsk) } diff --git a/cli/state.go b/cli/state.go index 3495b4301..86c2f314d 100644 --- a/cli/state.go +++ b/cli/state.go @@ -36,7 +36,6 @@ import ( "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/miner" ) var stateCmd = &cli.Command{ @@ -857,12 +856,7 @@ var stateComputeStateCmd = &cli.Command{ var msgs []*types.Message if cctx.Bool("apply-mpool-messages") { - pmsgs, err := api.MpoolPending(ctx, ts.Key()) - if err != nil { - return err - } - - pmsgs, err = miner.SelectMessages(ctx, api.StateGetActor, ts, pmsgs) + pmsgs, err := api.MpoolSelect(ctx, ts.Key()) if err != nil { return err } @@ -942,7 +936,7 @@ var compStateTemplate = ` font-size: 12px; border-collapse: collapse; } - tr { + tr { border-top: 1px solid black; border-bottom: 1px solid black; } @@ -961,7 +955,7 @@ var compStateTemplate = ` /** Checked State **/ - + .ellipsis-toggle input:checked + .ellipsis { display: none; } @@ -1014,7 +1008,7 @@ var compStateMsg = `
{{JsonParams ($code) (.Msg.Method) (.Msg.Params) | html}}
{{end}}
Took {{.Duration}}, Exit: {{.MsgRct.ExitCode}}{{if gt (len .MsgRct.Return) 0}}, Return{{end}}
- + {{if gt (len .MsgRct.Return) 0}}
{{JsonReturn ($code) (.Msg.Method) (.MsgRct.Return) | html}}
{{end}} diff --git a/miner/miner.go b/miner/miner.go index 49d6217c0..537758972 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -347,15 +347,15 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg, } // get pending messages early, - pending, err := m.api.MpoolPending(context.TODO(), base.TipSet.Key()) + msgs, err := m.api.MpoolSelect(context.TODO(), base.TipSet.Key()) if err != nil { - return nil, xerrors.Errorf("failed to get pending messages: %w", err) + return nil, xerrors.Errorf("failed to select messages for block: %w", err) } tPending := build.Clock.Now() // TODO: winning post proof - b, err := m.createBlock(base, m.address, ticket, winner, bvals, postProof, pending) + b, err := m.createBlock(base, m.address, ticket, winner, bvals, postProof, msgs) if err != nil { return nil, xerrors.Errorf("failed to create block: %w", err) } @@ -412,17 +412,7 @@ func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, bas } func (m *Miner) createBlock(base *MiningBase, addr address.Address, ticket *types.Ticket, - eproof *types.ElectionProof, bvals []types.BeaconEntry, wpostProof []abi.PoStProof, pending []*types.SignedMessage) (*types.BlockMsg, error) { - msgs, err := SelectMessages(context.TODO(), m.api.StateGetActor, base.TipSet, pending) - if err != nil { - return nil, xerrors.Errorf("message filtering failed: %w", err) - } - - if len(msgs) > build.BlockMessageLimit { - log.Error("SelectMessages returned too many messages: ", len(msgs)) - msgs = msgs[:build.BlockMessageLimit] - } - + eproof *types.ElectionProof, bvals []types.BeaconEntry, wpostProof []abi.PoStProof, msgs []*types.SignedMessage) (*types.BlockMsg, error) { uts := base.TipSet.MinTimestamp() + build.BlockDelaySecs*(uint64(base.NullRounds)+1) nheight := base.TipSet.Height() + base.NullRounds + 1 diff --git a/node/impl/full/mpool.go b/node/impl/full/mpool.go index a6fd4ba6b..df4428801 100644 --- a/node/impl/full/mpool.go +++ b/node/impl/full/mpool.go @@ -25,6 +25,15 @@ type MpoolAPI struct { Mpool *messagepool.MessagePool } +func (a *MpoolAPI) MpoolSelect(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) { + ts, err := a.Chain.GetTipSetFromKey(tsk) + if err != nil { + return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) + } + + return a.Mpool.SelectMessages(ts) +} + func (a *MpoolAPI) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) { ts, err := a.Chain.GetTipSetFromKey(tsk) if err != nil {