Wire in Ticket Quality to MpoolSelect
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
2057433f48
commit
b309e80e41
@ -159,7 +159,7 @@ type FullNode interface {
|
|||||||
MpoolPending(context.Context, types.TipSetKey) ([]*types.SignedMessage, error)
|
MpoolPending(context.Context, types.TipSetKey) ([]*types.SignedMessage, error)
|
||||||
|
|
||||||
// MpoolSelect returns a list of pending messages for inclusion in the next block
|
// MpoolSelect returns a list of pending messages for inclusion in the next block
|
||||||
MpoolSelect(context.Context, types.TipSetKey) ([]*types.SignedMessage, error)
|
MpoolSelect(context.Context, types.TipSetKey, float64) ([]*types.SignedMessage, error)
|
||||||
|
|
||||||
// MpoolPush pushes a signed message to mempool.
|
// MpoolPush pushes a signed message to mempool.
|
||||||
MpoolPush(context.Context, *types.SignedMessage) (cid.Cid, error)
|
MpoolPush(context.Context, *types.SignedMessage) (cid.Cid, error)
|
||||||
|
@ -97,9 +97,11 @@ type FullNodeStruct struct {
|
|||||||
SyncMarkBad func(ctx context.Context, bcid cid.Cid) error `perm:"admin"`
|
SyncMarkBad func(ctx context.Context, bcid cid.Cid) error `perm:"admin"`
|
||||||
SyncCheckBad func(ctx context.Context, bcid cid.Cid) (string, error) `perm:"read"`
|
SyncCheckBad func(ctx context.Context, bcid cid.Cid) (string, error) `perm:"read"`
|
||||||
|
|
||||||
MpoolGetConfig func(context.Context) (*types.MpoolConfig, error) `perm:"read"`
|
MpoolGetConfig func(context.Context) (*types.MpoolConfig, error) `perm:"read"`
|
||||||
MpoolSetConfig func(context.Context, *types.MpoolConfig) error `perm:"write"`
|
MpoolSetConfig func(context.Context, *types.MpoolConfig) error `perm:"write"`
|
||||||
MpoolSelect func(context.Context, types.TipSetKey) ([]*types.SignedMessage, error) `perm:"read"`
|
|
||||||
|
MpoolSelect func(context.Context, types.TipSetKey, float64) ([]*types.SignedMessage, error) `perm:"read"`
|
||||||
|
|
||||||
MpoolPending 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"`
|
MpoolPush func(context.Context, *types.SignedMessage) (cid.Cid, error) `perm:"write"`
|
||||||
MpoolPushMessage func(context.Context, *types.Message) (*types.SignedMessage, error) `perm:"sign"`
|
MpoolPushMessage func(context.Context, *types.Message) (*types.SignedMessage, error) `perm:"sign"`
|
||||||
@ -456,8 +458,8 @@ func (c *FullNodeStruct) MpoolSetConfig(ctx context.Context, cfg *types.MpoolCon
|
|||||||
return c.Internal.MpoolSetConfig(ctx, cfg)
|
return c.Internal.MpoolSetConfig(ctx, cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MpoolSelect(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) {
|
func (c *FullNodeStruct) MpoolSelect(ctx context.Context, tsk types.TipSetKey, tq float64) ([]*types.SignedMessage, error) {
|
||||||
return c.Internal.MpoolSelect(ctx, tsk)
|
return c.Internal.MpoolSelect(ctx, tsk, tq)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) {
|
func (c *FullNodeStruct) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) {
|
||||||
|
@ -858,7 +858,7 @@ var stateComputeStateCmd = &cli.Command{
|
|||||||
|
|
||||||
var msgs []*types.Message
|
var msgs []*types.Message
|
||||||
if cctx.Bool("apply-mpool-messages") {
|
if cctx.Bool("apply-mpool-messages") {
|
||||||
pmsgs, err := api.MpoolSelect(ctx, ts.Key())
|
pmsgs, err := api.MpoolSelect(ctx, ts.Key(), 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,12 @@ var mpoolCmd = &cli.Command{
|
|||||||
|
|
||||||
var minerSelectMsgsCmd = &cli.Command{
|
var minerSelectMsgsCmd = &cli.Command{
|
||||||
Name: "miner-select-msgs",
|
Name: "miner-select-msgs",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.Float64Flag{
|
||||||
|
Name: "ticket-quality",
|
||||||
|
Value: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -34,7 +40,7 @@ var minerSelectMsgsCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
msgs, err := api.MpoolSelect(ctx, head.Key())
|
msgs, err := api.MpoolSelect(ctx, head.Key(), cctx.Float64("ticket-quality"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
msgs, err := api.MpoolSelect(ctx, head.Key())
|
msgs, err := api.MpoolSelect(ctx, head.Key(), 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,12 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/big"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/gen/slashfilter"
|
"github.com/filecoin-project/lotus/chain/gen/slashfilter"
|
||||||
|
"github.com/minio/blake2b-simd"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
@ -390,8 +392,14 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg,
|
|||||||
return nil, xerrors.Errorf("failed to compute winning post proof: %w", err)
|
return nil, xerrors.Errorf("failed to compute winning post proof: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ticketHash := blake2b.Sum256(ticket.VRFProof)
|
||||||
|
ticketNum := types.BigFromBytes(ticketHash[:]).Int
|
||||||
|
ticketDenu := big.NewInt(1)
|
||||||
|
ticketDenu.Lsh(ticketDenu, 256)
|
||||||
|
tq, _ := new(big.Rat).SetFrac(ticketNum, ticketDenu).Float64()
|
||||||
|
tq = 1 - tq
|
||||||
// get pending messages early,
|
// get pending messages early,
|
||||||
msgs, err := m.api.MpoolSelect(context.TODO(), base.TipSet.Key())
|
msgs, err := m.api.MpoolSelect(context.TODO(), base.TipSet.Key(), tq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to select messages for block: %w", err)
|
return nil, xerrors.Errorf("failed to select messages for block: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -40,14 +40,14 @@ func (a *MpoolAPI) MpoolSetConfig(ctx context.Context, cfg *types.MpoolConfig) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *MpoolAPI) MpoolSelect(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) {
|
func (a *MpoolAPI) MpoolSelect(ctx context.Context, tsk types.TipSetKey, ticketQuality float64) ([]*types.SignedMessage, error) {
|
||||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO FIXME compute (or pass in) the actual ticket quality!
|
// TODO FIXME compute (or pass in) the actual ticket quality!
|
||||||
return a.Mpool.SelectMessages(ts, 1.0)
|
return a.Mpool.SelectMessages(ts, ticketQuality)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *MpoolAPI) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) {
|
func (a *MpoolAPI) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user