Skip to content

Commit

Permalink
fix(events): event index unique for tipset during backfill
Browse files Browse the repository at this point in the history
This was left undone as part of the original fix for unique event indexes and
shows up as a bug (e.g. "duplicate logIndex" for ETH APIs) where backfilling
is involved.

Ref: #11952
Ref: #12549
  • Loading branch information
rvagg committed Oct 9, 2024
1 parent a0d5292 commit 10ac174
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit 10ac174

Please sign in to comment.