From 6c0b88daf2127a8e16eaf9d50d31206c4933dc83 Mon Sep 17 00:00:00 2001 From: Aryan Tikarya Date: Mon, 23 Sep 2024 20:02:11 +0530 Subject: [PATCH] address comments --- build/openrpc/full.json | 5 +++++ chain/index/ddls.go | 4 +--- documentation/en/api-v1-unstable-methods.md | 1 + itests/eth_filter_test.go | 5 +++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/build/openrpc/full.json b/build/openrpc/full.json index 7cbfef87d27..12328f8f0f2 100644 --- a/build/openrpc/full.json +++ b/build/openrpc/full.json @@ -2066,6 +2066,7 @@ "Height": 42, "IndexedMessagesCount": 42, "IndexedEventsCount": 42, + "IndexedEventEntriesCount": 42, "Backfilled": true, "IsNullRound": true } @@ -2079,6 +2080,10 @@ "title": "number", "type": "number" }, + "IndexedEventEntriesCount": { + "title": "number", + "type": "number" + }, "IndexedEventsCount": { "title": "number", "type": "number" diff --git a/chain/index/ddls.go b/chain/index/ddls.go index 90df97bdab5..5acfb8b87be 100644 --- a/chain/index/ddls.go +++ b/chain/index/ddls.go @@ -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 @@ -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", } } diff --git a/documentation/en/api-v1-unstable-methods.md b/documentation/en/api-v1-unstable-methods.md index 3ac41f9eb14..2eb784ec94a 100644 --- a/documentation/en/api-v1-unstable-methods.md +++ b/documentation/en/api-v1-unstable-methods.md @@ -1261,6 +1261,7 @@ Response: "Height": 42, "IndexedMessagesCount": 42, "IndexedEventsCount": 42, + "IndexedEventEntriesCount": 42, "Backfilled": true, "IsNullRound": true } diff --git a/itests/eth_filter_test.go b/itests/eth_filter_test.go index 430e5ff90fd..5e18e8c0773 100644 --- a/itests/eth_filter_test.go +++ b/itests/eth_filter_test.go @@ -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) @@ -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) @@ -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) } }