Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akaladarshi committed Sep 25, 2024
1 parent 197c3bb commit 6c0b88d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions build/openrpc/full.json
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,7 @@
"Height": 42,
"IndexedMessagesCount": 42,
"IndexedEventsCount": 42,
"IndexedEventEntriesCount": 42,
"Backfilled": true,
"IsNullRound": true
}
Expand All @@ -2079,6 +2080,10 @@
"title": "number",
"type": "number"
},
"IndexedEventEntriesCount": {
"title": "number",
"type": "number"
},
"IndexedEventsCount": {
"title": "number",
"type": "number"
Expand Down
4 changes: 1 addition & 3 deletions chain/index/ddls.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ var ddls = []string{
`CREATE INDEX IF NOT EXISTS idx_height ON tipset_message (height)`,

`CREATE INDEX IF NOT EXISTS event_entry_event_id ON event_entry(event_id)`,

`CREATE INDEX IF NOT EXISTS idx_tipset_key_reverted_message_id ON tipset_message (tipset_key_cid, reverted, message_id)`,
}

// preparedStatementMapping returns a map of fields of the preparedStatements struct to the SQL
Expand Down Expand Up @@ -85,7 +83,7 @@ func preparedStatementMapping(ps *preparedStatements) map[**sql.Stmt]string {
&ps.countTipsetsAtHeightStmt: "SELECT COUNT(CASE WHEN reverted = 1 THEN 1 END) AS reverted_count, COUNT(CASE WHEN reverted = 0 THEN 1 END) AS non_reverted_count FROM (SELECT tipset_key_cid, MAX(reverted) AS reverted FROM tipset_message WHERE height = ? GROUP BY tipset_key_cid) AS unique_tipsets",
&ps.getNonRevertedTipsetMessageCountStmt: "SELECT COUNT(*) FROM tipset_message WHERE tipset_key_cid = ? AND reverted = 0 AND message_cid IS NOT NULL",
&ps.getNonRevertedTipsetEventCountStmt: "SELECT COUNT(*) FROM event WHERE reverted = 0 AND message_id IN (SELECT message_id FROM tipset_message WHERE tipset_key_cid = ? AND reverted = 0)",
&ps.getNonRevertedTipsetEventEntriesCountStmt: "SELECT COUNT(ee.event_id) AS event_entry_count FROM tipset_message AS t INNER JOIN event AS ev ON t.message_id = ev.message_id INNER JOIN event_entry AS ee ON ev.event_id = ee.event_id WHERE t.tipset_key_cid = ? AND t.reverted = 0",
&ps.hasRevertedEventsInTipsetStmt: "SELECT EXISTS(SELECT 1 FROM event WHERE reverted = 1 AND message_id IN (SELECT message_id FROM tipset_message WHERE tipset_key_cid = ?))",
&ps.getNonRevertedTipsetEventEntriesCountStmt: "SELECT COUNT(ee.event_id) AS entry_count FROM event_entry ee JOIN event e ON ee.event_id = e.event_id JOIN tipset_message tm ON e.message_id = tm.message_id WHERE tm.tipset_key_cid = ? AND tm.reverted = 0",
}
}
1 change: 1 addition & 0 deletions documentation/en/api-v1-unstable-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ Response:
"Height": 42,
"IndexedMessagesCount": 42,
"IndexedEventsCount": 42,
"IndexedEventEntriesCount": 42,
"Backfilled": true,
"IsNullRound": true
}
Expand Down
5 changes: 5 additions & 0 deletions itests/eth_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ func TestEthGetLogsBasic(t *testing.T) {

totalMessageCount := 0
totalEventCount := 0
totalEventEntriesCount := 0
messages, err := client.ChainGetMessagesInTipset(ctx, ts.Key())
require.NoError(err)
totalMessageCount = len(messages)
Expand All @@ -555,6 +556,9 @@ func TestEthGetLogsBasic(t *testing.T) {
events, err := client.ChainGetEvents(ctx, *receipt.Receipt.EventsRoot)
require.NoError(err)
totalEventCount += len(events)
for _, event := range events {
totalEventEntriesCount += len(event.Entries)
}
}
}
t.Logf("tipset %d: %d messages, %d events", height, totalMessageCount, totalEventCount)
Expand All @@ -566,6 +570,7 @@ func TestEthGetLogsBasic(t *testing.T) {
require.EqualValues(height, iv.Height)
require.EqualValues(totalMessageCount, iv.IndexedMessagesCount)
require.EqualValues(totalEventCount, iv.IndexedEventsCount)
require.EqualValues(totalEventEntriesCount, iv.IndexedEventEntriesCount)
require.False(iv.Backfilled)
}
}
Expand Down

0 comments on commit 6c0b88d

Please sign in to comment.