From b8f5b73bcc6f45bbbde8cf8298c5c78bca66271e Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 11 Oct 2024 15:14:52 +1100 Subject: [PATCH] fixup! feat(events): compare-amt option for lotus-shed indexes inspect-events --- cmd/lotus-shed/indexes.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/lotus-shed/indexes.go b/cmd/lotus-shed/indexes.go index cb4dc0bed30..d4f8c4a3e21 100644 --- a/cmd/lotus-shed/indexes.go +++ b/cmd/lotus-shed/indexes.go @@ -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) } @@ -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 { @@ -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 @@ -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 { @@ -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 @@ -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 }