Skip to content
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

fix(events): event index unique for tipset during backfill #12567

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

## Bug Fixes

- Fix a bug in the `lotus-shed indexes backfill-events` command that may result in either duplicate events being backfilled where there are existing events (such an operation *should* be idempotent) or events erroneously having duplicate `logIndex` values when queried via ETH APIs. ([filecoin-project/lotus#12567](https://github.com/filecoin-project/lotus/pull/12567))

## Deps

# Node v1.29.2 / 2024-10-03
Expand Down
8 changes: 5 additions & 3 deletions cmd/lotus-shed/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ var backfillEventsCmd = &cli.Command{
return fmt.Errorf("failed to get tipset key cid: %w", err)
}

eventCount := 0
// loop over each message receipt and backfill the events
for idx, receipt := range receipts {
msg := msgs[idx]
Expand All @@ -229,7 +230,7 @@ var backfillEventsCmd = &cli.Command{
return fmt.Errorf("failed to load events for tipset %s: %w", currTs, err)
}

for eventIdx, event := range events {
for _, event := range events {
addr, found := addressLookups[event.Emitter]
if !found {
var ok bool
Expand All @@ -248,7 +249,7 @@ var backfillEventsCmd = &cli.Command{
currTs.Key().Bytes(),
tsKeyCid.Bytes(),
addr.Bytes(),
eventIdx,
eventCount,
msg.Cid.Bytes(),
idx,
).Scan(&entryID)
Expand All @@ -267,7 +268,7 @@ var backfillEventsCmd = &cli.Command{
currTs.Key().Bytes(), // tipset_key
tsKeyCid.Bytes(), // tipset_key_cid
addr.Bytes(), // emitter_addr
eventIdx, // event_index
eventCount, // event_index
msg.Cid.Bytes(), // message_cid
idx, // message_index
false, // reverted
Expand Down Expand Up @@ -307,6 +308,7 @@ var backfillEventsCmd = &cli.Command{
}
entriesAffected += rowsAffected
}
eventCount++
}
}

Expand Down
Loading