Skip to content

Commit

Permalink
fixup! feat(events): compare-amt option for lotus-shed indexes inspec…
Browse files Browse the repository at this point in the history
…t-events
  • Loading branch information
rvagg committed Oct 11, 2024
1 parent eccb10d commit b8f5b73
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions cmd/lotus-shed/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ var inspectEventsCmd = &cli.Command{
return err
}

processHeight := func(ctx context.Context, ts *types.TipSet, messages []lapi.Message, receipts []*types.MessageReceipt) error {
tsKeyCid, err := ts.Key().Cid()
processHeight := func(ctx context.Context, prevTs, curTs *types.TipSet, messages []lapi.Message, receipts []*types.MessageReceipt) error {
tsKeyCid, err := curTs.Key().Cid()
if err != nil {
return xerrors.Errorf("failed to get tipset key cid: %w", err)
}
Expand Down Expand Up @@ -540,11 +540,11 @@ var inspectEventsCmd = &cli.Command{

var actualEvents int
if err := stmtEventCount.QueryRow(tsKeyCid.Bytes()).Scan(&actualEvents); err != nil {
return xerrors.Errorf("failed to count events for epoch %d (tsk CID %s): %w", ts.Height(), tsKeyCid, err)
return xerrors.Errorf("failed to count events for epoch %d (tsk CID %s): %w", curTs.Height(), tsKeyCid, err)
}
var actualEntries int
if err := stmtEntryCount.QueryRow(tsKeyCid.Bytes()).Scan(&actualEntries); err != nil {
return xerrors.Errorf("failed to count entries for epoch %d (tsk CID %s): %w", ts.Height(), tsKeyCid, err)
return xerrors.Errorf("failed to count entries for epoch %d (tsk CID %s): %w", curTs.Height(), tsKeyCid, err)
}

if actualEvents != expectEvents {
Expand Down Expand Up @@ -588,7 +588,7 @@ var inspectEventsCmd = &cli.Command{
actorId = id
} else {
if addr.Protocol() != address.ID {
idAddr, err := api.StateLookupID(ctx, addr, ts.Key())
idAddr, err := api.StateLookupID(ctx, addr, prevTs.Key())
if err != nil {
// TODO: fix this? we should be able to resolve all addresses
return cid.Undef, fmt.Sprintf("failed to resolve address (%s), could not compare amt", addr.String()), nil
Expand Down Expand Up @@ -680,7 +680,7 @@ var inspectEventsCmd = &cli.Command{
return xerrors.Errorf("failed to check if tipset is seen: %w", err)
}
} else {
if seenHeight != int(ts.Height()) {
if seenHeight != int(curTs.Height()) {
problems = append(problems, fmt.Sprintf("events_seen height mismatch (%d)", seenHeight))
}
if seenReverted != 0 {
Expand All @@ -689,9 +689,9 @@ var inspectEventsCmd = &cli.Command{
}

if len(problems) > 0 {
_, _ = fmt.Fprintf(cctx.App.Writer, "✗ Epoch %d (%s): %s\n", ts.Height(), tsKeyCid, strings.Join(problems, ", "))
_, _ = fmt.Fprintf(cctx.App.Writer, "✗ Epoch %d (%s): %s\n", curTs.Height(), tsKeyCid, strings.Join(problems, ", "))
} else if logGood {
_, _ = fmt.Fprintf(cctx.App.Writer, "✓ Epoch %d (%s)\n", ts.Height(), tsKeyCid)
_, _ = fmt.Fprintf(cctx.App.Writer, "✓ Epoch %d (%s)\n", curTs.Height(), tsKeyCid)
}

return nil
Expand All @@ -717,7 +717,7 @@ var inspectEventsCmd = &cli.Command{
return fmt.Errorf("mismatched in message and receipt count: %d != %d", len(messages), len(receipts))
}

err = processHeight(ctx, currTs, messages, receipts)
err = processHeight(ctx, prevTs, currTs, messages, receipts)
if err != nil {
return err
}
Expand Down

0 comments on commit b8f5b73

Please sign in to comment.