Merge pull request #4583 from filecoin-project/fix/tvx-msg-cid
tvx extract: make it work with secp messages.
This commit is contained in:
commit
853f9da457
@ -12,6 +12,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
@ -70,6 +71,11 @@ var extractCmd = &cli.Command{
|
|||||||
Usage: "optionally, the block CID the message was included in, to avoid expensive chain scanning",
|
Usage: "optionally, the block CID the message was included in, to avoid expensive chain scanning",
|
||||||
Destination: &extractFlags.block,
|
Destination: &extractFlags.block,
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "exec-block",
|
||||||
|
Usage: "optionally, the block CID of a block where this message was executed, to avoid expensive chain scanning",
|
||||||
|
Destination: &extractFlags.block,
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "cid",
|
Name: "cid",
|
||||||
Usage: "message CID to generate test vector from",
|
Usage: "message CID to generate test vector from",
|
||||||
@ -143,7 +149,7 @@ func doExtract(opts extractOpts) error {
|
|||||||
return fmt.Errorf("failed to fetch messages in canonical order from inclusion tipset: %w", err)
|
return fmt.Errorf("failed to fetch messages in canonical order from inclusion tipset: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
related, found, err := findMsgAndPrecursors(opts.precursor, msg, msgs)
|
related, found, err := findMsgAndPrecursors(opts.precursor, mcid, msg.From, msgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed while finding message and precursors: %w", err)
|
return fmt.Errorf("failed while finding message and precursors: %w", err)
|
||||||
}
|
}
|
||||||
@ -496,19 +502,19 @@ func fetchThisAndPrevTipset(ctx context.Context, api api.FullNode, target types.
|
|||||||
// findMsgAndPrecursors ranges through the canonical messages slice, locating
|
// findMsgAndPrecursors ranges through the canonical messages slice, locating
|
||||||
// the target message and returning precursors in accordance to the supplied
|
// the target message and returning precursors in accordance to the supplied
|
||||||
// mode.
|
// mode.
|
||||||
func findMsgAndPrecursors(mode string, target *types.Message, msgs []api.Message) (related []*types.Message, found bool, err error) {
|
func findMsgAndPrecursors(mode string, msgCid cid.Cid, sender address.Address, msgs []api.Message) (related []*types.Message, found bool, err error) {
|
||||||
// Range through canonicalised messages, selecting only the precursors based
|
// Range through canonicalised messages, selecting only the precursors based
|
||||||
// on selection mode.
|
// on selection mode.
|
||||||
for _, other := range msgs {
|
for _, other := range msgs {
|
||||||
switch {
|
switch {
|
||||||
case mode == PrecursorSelectAll:
|
case mode == PrecursorSelectAll:
|
||||||
fallthrough
|
fallthrough
|
||||||
case mode == PrecursorSelectSender && other.Message.From == target.From:
|
case mode == PrecursorSelectSender && other.Message.From == sender:
|
||||||
related = append(related, other.Message)
|
related = append(related, other.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this message is the target; we're done.
|
// this message is the target; we're done.
|
||||||
if other.Cid == target.Cid() {
|
if other.Cid == msgCid {
|
||||||
return related, true, nil
|
return related, true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user