diff --git a/api/api_full.go b/api/api_full.go index e8e8dcb2e..fed9cece5 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -253,7 +253,7 @@ type FullNode interface { MpoolBatchPushMessage(context.Context, []*types.Message, *MessageSendSpec) ([]*types.SignedMessage, error) //perm:sign // MpoolCheckMessages performs logical checks on a batch of messages - MpoolCheckMessages(context.Context, []*types.Message) ([][]MessageCheckStatus, error) //perm:read + MpoolCheckMessages(context.Context, []*MessagePrototype) ([][]MessageCheckStatus, error) //perm:read // MpoolCheckPendingMessages performs logical checks for all pending messages from a given address MpoolCheckPendingMessages(context.Context, address.Address) ([][]MessageCheckStatus, error) //perm:read // MpoolCheckReplaceMessages performs logical checks on pending messages with replacement diff --git a/api/mocks/mock_full.go b/api/mocks/mock_full.go index a14336537..6feee64f7 100644 --- a/api/mocks/mock_full.go +++ b/api/mocks/mock_full.go @@ -1069,7 +1069,7 @@ func (mr *MockFullNodeMockRecorder) MpoolBatchPushUntrusted(arg0, arg1 interface } // MpoolCheckMessages mocks base method -func (m *MockFullNode) MpoolCheckMessages(arg0 context.Context, arg1 []*types.Message) ([][]api.MessageCheckStatus, error) { +func (m *MockFullNode) MpoolCheckMessages(arg0 context.Context, arg1 []*api.MessagePrototype) ([][]api.MessageCheckStatus, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MpoolCheckMessages", arg0, arg1) ret0, _ := ret[0].([][]api.MessageCheckStatus) diff --git a/api/proxy_gen.go b/api/proxy_gen.go index f285f1ce6..2d4d41503 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -235,7 +235,7 @@ type FullNodeStruct struct { MpoolBatchPushUntrusted func(p0 context.Context, p1 []*types.SignedMessage) ([]cid.Cid, error) `perm:"write"` - MpoolCheckMessages func(p0 context.Context, p1 []*types.Message) ([][]MessageCheckStatus, error) `perm:"read"` + MpoolCheckMessages func(p0 context.Context, p1 []*MessagePrototype) ([][]MessageCheckStatus, error) `perm:"read"` MpoolCheckPendingMessages func(p0 context.Context, p1 address.Address) ([][]MessageCheckStatus, error) `perm:"read"` @@ -1515,11 +1515,11 @@ func (s *FullNodeStub) MpoolBatchPushUntrusted(p0 context.Context, p1 []*types.S return *new([]cid.Cid), xerrors.New("method not supported") } -func (s *FullNodeStruct) MpoolCheckMessages(p0 context.Context, p1 []*types.Message) ([][]MessageCheckStatus, error) { +func (s *FullNodeStruct) MpoolCheckMessages(p0 context.Context, p1 []*MessagePrototype) ([][]MessageCheckStatus, error) { return s.Internal.MpoolCheckMessages(p0, p1) } -func (s *FullNodeStub) MpoolCheckMessages(p0 context.Context, p1 []*types.Message) ([][]MessageCheckStatus, error) { +func (s *FullNodeStub) MpoolCheckMessages(p0 context.Context, p1 []*MessagePrototype) ([][]MessageCheckStatus, error) { return *new([][]MessageCheckStatus), xerrors.New("method not supported") } diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index cb781bec9..d628685e5 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/chain/messagepool/check.go b/chain/messagepool/check.go index 7cb99ff15..71389d9e2 100644 --- a/chain/messagepool/check.go +++ b/chain/messagepool/check.go @@ -19,8 +19,14 @@ import ( var baseFeeUpperBoundFactor = types.NewInt(10) // CheckMessages performs a set of logic checks for a list of messages, prior to submitting it to the mpool -func (mp *MessagePool) CheckMessages(msgs []*types.Message) ([][]api.MessageCheckStatus, error) { - return mp.checkMessages(msgs, false) +func (mp *MessagePool) CheckMessages(protos []*api.MessagePrototype) ([][]api.MessageCheckStatus, error) { + flex := make([]bool, len(protos)) + msgs := make([]*types.Message, len(protos)) + for i, p := range protos { + flex[i] = !p.ValidNonce + msgs[i] = &p.Message + } + return mp.checkMessages(msgs, false, flex) } // CheckPendingMessages performs a set of logical sets for all messages pending from a given actor @@ -43,7 +49,7 @@ func (mp *MessagePool) CheckPendingMessages(from address.Address) ([][]api.Messa return msgs[i].Nonce < msgs[j].Nonce }) - return mp.checkMessages(msgs, true) + return mp.checkMessages(msgs, true, nil) } // CheckReplaceMessages performs a set of logical checks for related messages while performing a @@ -88,10 +94,12 @@ func (mp *MessagePool) CheckReplaceMessages(replace []*types.Message) ([][]api.M start = end } - return mp.checkMessages(msgs, true) + return mp.checkMessages(msgs, true, nil) } -func (mp *MessagePool) checkMessages(msgs []*types.Message, interned bool) (result [][]api.MessageCheckStatus, err error) { +// flexibleNonces should be either nil or of len(msgs), it signifies that message at given index +// has non-determied nonce at this point +func (mp *MessagePool) checkMessages(msgs []*types.Message, interned bool, flexibleNonces []bool) (result [][]api.MessageCheckStatus, err error) { mp.curTsLk.Lock() curTs := mp.curTs mp.curTsLk.Unlock() @@ -381,7 +389,7 @@ func (mp *MessagePool) checkMessages(msgs []*types.Message, interned bool) (resu }, } - if st.nextNonce != m.Nonce { + if (flexibleNonces == nil || !flexibleNonces[i]) && st.nextNonce != m.Nonce { check.OK = false check.Err = fmt.Sprintf("message nonce doesn't match next nonce (%d)", st.nextNonce) } else { diff --git a/cli/multisig.go b/cli/multisig.go index 0baed5a93..9ddfcdfc1 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -161,7 +161,7 @@ var msigCreateCmd = &cli.Command{ msgCid := sm.Cid() // wait for it to get mined into a block - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -451,7 +451,7 @@ var msigProposeCmd = &cli.Command{ fmt.Println("send proposal in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -600,7 +600,7 @@ var msigApproveCmd = &cli.Command{ fmt.Println("sent approval in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -680,7 +680,7 @@ var msigRemoveProposeCmd = &cli.Command{ fmt.Println("sent remove proposal in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -767,7 +767,7 @@ var msigAddProposeCmd = &cli.Command{ fmt.Fprintln(cctx.App.Writer, "sent add proposal in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -858,7 +858,7 @@ var msigAddApproveCmd = &cli.Command{ fmt.Println("sent add approval in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -944,7 +944,7 @@ var msigAddCancelCmd = &cli.Command{ fmt.Println("sent add cancellation in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -1025,7 +1025,7 @@ var msigSwapProposeCmd = &cli.Command{ fmt.Println("sent swap proposal in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -1116,7 +1116,7 @@ var msigSwapApproveCmd = &cli.Command{ fmt.Println("sent swap approval in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -1202,7 +1202,7 @@ var msigSwapCancelCmd = &cli.Command{ fmt.Println("sent swap cancellation in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -1298,7 +1298,7 @@ var msigLockProposeCmd = &cli.Command{ fmt.Println("sent lock proposal in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -1404,7 +1404,7 @@ var msigLockApproveCmd = &cli.Command{ fmt.Println("sent lock approval in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -1505,7 +1505,7 @@ var msigLockCancelCmd = &cli.Command{ fmt.Println("sent lock cancellation in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } @@ -1651,7 +1651,7 @@ var msigProposeThresholdCmd = &cli.Command{ fmt.Println("sent change threshold proposal in message: ", msgCid) - wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence"))) + wait, err := api.StateWaitMsg(ctx, msgCid, uint64(cctx.Int("confidence")), build.Finality, true) if err != nil { return err } diff --git a/cli/services.go b/cli/services.go index a69dab655..0923680aa 100644 --- a/cli/services.go +++ b/cli/services.go @@ -114,17 +114,8 @@ type CheckInfo struct { var ErrCheckFailed = fmt.Errorf("check has failed") func (s *ServicesImpl) RunChecksForPrototype(ctx context.Context, prototype *api.MessagePrototype) ([][]api.MessageCheckStatus, error) { - if !prototype.ValidNonce { - nonce, err := s.api.MpoolGetNonce(ctx, prototype.Message.From) - if err != nil { - return nil, xerrors.Errorf("mpool get nonce: %w", err) - } - prototype.Message.Nonce = nonce - prototype.ValidNonce = true - } - var outChecks [][]api.MessageCheckStatus - checks, err := s.api.MpoolCheckMessages(ctx, []*types.Message{&prototype.Message}) + checks, err := s.api.MpoolCheckMessages(ctx, []*api.MessagePrototype{prototype}) if err != nil { return nil, xerrors.Errorf("message check: %w", err) } diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index a3ac4d487..1b32ffe50 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -35,6 +35,8 @@ COMMANDS: status Check node status GLOBAL OPTIONS: + --interactive setting to false will disable interactive functionality of commands (default: false) + --force-send if true, will ignore pre-send checks (default: false) --help, -h show help (default: false) --version, -v print the version (default: false) ``` @@ -138,7 +140,7 @@ OPTIONS: --method value specify method to invoke (default: 0) --params-json value specify invocation parameters in json --params-hex value specify invocation parameters in hex - --force must be specified for the action to take effect if maybe SysErrInsufficientFunds etc (default: false) + --force Deprecated: use global 'force-send' (default: false) --help, -h show help (default: false) ``` @@ -1301,6 +1303,7 @@ COMMANDS: find find a message in the mempool config get or set current mpool configuration gas-perf Check gas performance of messages in mempool + manage help, h Shows a list of commands or help for one command OPTIONS: @@ -1414,6 +1417,9 @@ OPTIONS: --help, -h show help (default: false) ``` +# nage +``` +``` ## lotus state ``` diff --git a/node/impl/full/mpool.go b/node/impl/full/mpool.go index 099fb45b8..63d3c7d58 100644 --- a/node/impl/full/mpool.go +++ b/node/impl/full/mpool.go @@ -225,8 +225,8 @@ func (a *MpoolAPI) MpoolBatchPushMessage(ctx context.Context, msgs []*types.Mess return smsgs, nil } -func (a *MpoolAPI) MpoolCheckMessages(ctx context.Context, msgs []*types.Message) ([][]api.MessageCheckStatus, error) { - return a.Mpool.CheckMessages(msgs) +func (a *MpoolAPI) MpoolCheckMessages(ctx context.Context, protos []*api.MessagePrototype) ([][]api.MessageCheckStatus, error) { + return a.Mpool.CheckMessages(protos) } func (a *MpoolAPI) MpoolCheckPendingMessages(ctx context.Context, from address.Address) ([][]api.MessageCheckStatus, error) {