-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: conformance & tvx: support ReportConsensusFault messages #8302
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ba408cc
tvx: print out epoch numbers that weren't found.
raulk 92c9716
tvx: widen 'sender' precursor strategy to match against both particip…
raulk 5434cfd
tvx: use addresses when scanning precursors.
raulk 9eb8103
tvx and conformance: use precondition state tree as the lookback tree.
raulk eef436b
go fmt.
raulk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ func doExtractMessage(opts extractOpts) error { | |
return fmt.Errorf("failed to fetch messages in canonical order from inclusion tipset: %w", err) | ||
} | ||
|
||
related, found, err := findMsgAndPrecursors(opts.precursor, mcid, msg.From, msgs) | ||
related, found, err := findMsgAndPrecursors(ctx, opts.precursor, mcid, msg.From, msg.To, msgs) | ||
if err != nil { | ||
return fmt.Errorf("failed while finding message and precursors: %w", err) | ||
} | ||
|
@@ -114,7 +114,7 @@ func doExtractMessage(opts extractOpts) error { | |
log.Printf("applying precursor %d, cid: %s", i, m.Cid()) | ||
_, root, err = driver.ExecuteMessage(pst.Blockstore, conformance.ExecuteMessageParams{ | ||
Preroot: root, | ||
Epoch: execTs.Height(), | ||
Epoch: incTs.Height(), | ||
Message: m, | ||
CircSupply: circSupplyDetail.FilCirculating, | ||
BaseFee: basefee, | ||
|
@@ -139,6 +139,7 @@ func doExtractMessage(opts extractOpts) error { | |
) | ||
|
||
log.Printf("using state retention strategy: %s", retention) | ||
log.Printf("now applying requested message: %s", msg.Cid()) | ||
switch retention { | ||
case "accessed-cids": | ||
tbs, ok := pst.Blockstore.(TracingBlockstore) | ||
|
@@ -151,7 +152,7 @@ func doExtractMessage(opts extractOpts) error { | |
preroot = root | ||
applyret, postroot, err = driver.ExecuteMessage(pst.Blockstore, conformance.ExecuteMessageParams{ | ||
Preroot: preroot, | ||
Epoch: execTs.Height(), | ||
Epoch: incTs.Height(), | ||
Message: msg, | ||
CircSupply: circSupplyDetail.FilCirculating, | ||
BaseFee: basefee, | ||
|
@@ -184,7 +185,7 @@ func doExtractMessage(opts extractOpts) error { | |
} | ||
applyret, postroot, err = driver.ExecuteMessage(pst.Blockstore, conformance.ExecuteMessageParams{ | ||
Preroot: preroot, | ||
Epoch: execTs.Height(), | ||
Epoch: incTs.Height(), | ||
Message: msg, | ||
CircSupply: circSupplyDetail.FilCirculating, | ||
BaseFee: basefee, | ||
|
@@ -299,7 +300,7 @@ func doExtractMessage(opts extractOpts) error { | |
CAR: out.Bytes(), | ||
Pre: &schema.Preconditions{ | ||
Variants: []schema.Variant{ | ||
{ID: codename, Epoch: int64(execTs.Height()), NetworkVersion: uint(nv)}, | ||
{ID: codename, Epoch: int64(incTs.Height()), NetworkVersion: uint(nv)}, | ||
}, | ||
CircSupply: circSupply.Int, | ||
BaseFee: basefee.Int, | ||
|
@@ -368,13 +369,13 @@ func resolveFromChain(ctx context.Context, api v0api.FullNode, mcid cid.Cid, blo | |
// types.EmptyTSK hints to use the HEAD. | ||
execTs, err = api.ChainGetTipSetByHeight(ctx, blk.Height+1, types.EmptyTSK) | ||
if err != nil { | ||
return nil, nil, nil, fmt.Errorf("failed to get message execution tipset: %w", err) | ||
return nil, nil, nil, fmt.Errorf("failed to get message execution tipset (%d) : %w", blk.Height+1, err) | ||
} | ||
|
||
// walk back from the execTs instead of HEAD, to save time. | ||
incTs, err = api.ChainGetTipSetByHeight(ctx, blk.Height, execTs.Key()) | ||
if err != nil { | ||
return nil, nil, nil, fmt.Errorf("failed to get message inclusion tipset: %w", err) | ||
return nil, nil, nil, fmt.Errorf("failed to get message inclusion tipset (%d): %w", blk.Height, err) | ||
} | ||
|
||
return msg, execTs, incTs, nil | ||
|
@@ -403,19 +404,29 @@ func fetchThisAndPrevTipset(ctx context.Context, api v0api.FullNode, target type | |
// findMsgAndPrecursors ranges through the canonical messages slice, locating | ||
// the target message and returning precursors in accordance to the supplied | ||
// mode. | ||
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 | ||
// on selection mode. | ||
for _, other := range msgs { | ||
func findMsgAndPrecursors(ctx context.Context, mode string, msgCid cid.Cid, sender address.Address, recipient address.Address, msgs []api.Message) (related []*types.Message, found bool, err error) { | ||
// Resolve addresses to IDs for canonicality. | ||
senderID := mustResolveAddr(ctx, sender) | ||
recipientID := mustResolveAddr(ctx, recipient) | ||
|
||
// Range through messages, selecting only the precursors based on selection mode. | ||
for _, m := range msgs { | ||
msgSenderID := mustResolveAddr(ctx, m.Message.From) | ||
msgRecipientID := mustResolveAddr(ctx, m.Message.To) | ||
|
||
switch { | ||
case mode == PrecursorSelectAll: | ||
fallthrough | ||
case mode == PrecursorSelectSender && other.Message.From == sender: | ||
related = append(related, other.Message) | ||
case mode == PrecursorSelectParticipants && | ||
msgSenderID == senderID || | ||
msgRecipientID == recipientID || | ||
msgSenderID == recipientID || | ||
msgRecipientID == senderID: | ||
Comment on lines
+420
to
+424
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A parentheses seems to be missing around the OR parts. |
||
related = append(related, m.Message) | ||
Comment on lines
+420
to
+425
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now find precursors by matching on all participants involved. |
||
} | ||
|
||
// this message is the target; we're done. | ||
if other.Cid == msgCid { | ||
if m.Cid == msgCid { | ||
return related, true, nil | ||
} | ||
} | ||
|
@@ -425,3 +436,17 @@ func findMsgAndPrecursors(mode string, msgCid cid.Cid, sender address.Address, m | |
// target). | ||
return related, false, nil | ||
} | ||
|
||
var addressCache = make(map[address.Address]address.Address) | ||
|
||
func mustResolveAddr(ctx context.Context, addr address.Address) address.Address { | ||
if resolved, ok := addressCache[addr]; ok { | ||
return resolved | ||
} | ||
id, err := FullAPI.StateLookupID(ctx, addr, types.EmptyTSK) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to resolve addr: %w", err)) | ||
} | ||
addressCache[addr] = id | ||
return id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The execution epoch was wrong, it should be the inclusion tipset.