Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akaladarshi committed Sep 24, 2024
1 parent 78a5c0a commit 6259731
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
6 changes: 4 additions & 2 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ type FullNode interface {
// TipSetKey TipSetKey
// // Height is the epoch height at which the validation is performed.
// Height uint64
// // IndexedMessagesCount indicates the number of indexed messages for the canonical tipset at this epoch.
// // IndexedMessagesCount is the number of indexed messages for the canonical tipset at this epoch.
// IndexedMessagesCount uint64
// // IndexedEventsCount signifies the number of indexed events for the canonical tipset at this epoch.
// // IndexedEventsCount is the number of indexed events for the canonical tipset at this epoch.
// IndexedEventsCount uint64
// // IndexedEventEntriesCount is the number of indexed event entries for the canonical tipset at this epoch.
// IndexedEventEntriesCount uint64
// // Backfilled denotes whether missing data was successfully backfilled into the index during validation.
// Backfilled bool
// // IsNullRound indicates if the epoch corresponds to a null round and therefore does not have any indexed messages or events.
Expand Down
7 changes: 6 additions & 1 deletion build/openrpc/full.json
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@
{
"name": "Filecoin.ChainValidateIndex",
"description": "```go\nfunc (s *FullNodeStruct) ChainValidateIndex(p0 context.Context, p1 abi.ChainEpoch, p2 bool) (*types.IndexValidation, error) {\n\tif s.Internal.ChainValidateIndex == nil {\n\t\treturn nil, ErrNotSupported\n\t}\n\treturn s.Internal.ChainValidateIndex(p0, p1, p2)\n}\n```",
"summary": "IndexValidation contains detailed information about the validation status of a specific chain epoch.\ntype IndexValidation struct {\n\t// TipSetKey is the key of the canonical tipset for this epoch.\n\tTipSetKey TipSetKey\n\t// Height is the epoch height at which the validation is performed.\n\tHeight uint64\n\t// IndexedMessagesCount indicates the number of indexed messages for the canonical tipset at this epoch.\n\tIndexedMessagesCount uint64\n\t// IndexedEventsCount signifies the number of indexed events for the canonical tipset at this epoch.\n\tIndexedEventsCount uint64\n\t// Backfilled denotes whether missing data was successfully backfilled into the index during validation.\n\tBackfilled bool\n\t// IsNullRound indicates if the epoch corresponds to a null round and therefore does not have any indexed messages or events.\n\tIsNullRound bool\n}\n\nChainValidateIndex validates the integrity of the chain index at a specified epoch and also optionally backfills missing data.\n\nParameters:\n - epoch: The specific chain epoch for which to validate/backfill the index.\n - backfill: A boolean flag indicating whether to attempt backfilling of missing data if the index does not have data for the\n specified epoch.\n\nReturns:\n - *types.IndexValidation: A pointer to an IndexValidation struct containing the results of the validation/backfill.\n - error: An error object if the validation/backfill fails. The error message will contain details about the index\n corruption if the call fails because of an incosistency between indexed data and the actual chain state.\n\nNote: The API returns an error if the index does not have data for the specified epoch and backfill is set to false.\n\nThe `ChainValidateIndex` API serves multiple purposes:\n\n1. Validates the chain index at a specific epoch:\n - Ensures consistency between indexed data and actual chain state\n - Reports any errors found during validation (i.e. the indexed data does not match the actual chain state, missing data, etc.)\n\n2. Optionally backfills missing data:\n - Backfills data if the index is missing information for the specified epoch\n - Backfilling only occurs when the `backfill` parameter is set to `true`\n\n3. Detects \"holes\" in the index:\n - If `backfill` is `false` and the index lacks data for the specified epoch, the API returns an error indicating missing data\n",
"summary": "IndexValidation contains detailed information about the validation status of a specific chain epoch.\ntype IndexValidation struct {\n\t// TipSetKey is the key of the canonical tipset for this epoch.\n\tTipSetKey TipSetKey\n\t// Height is the epoch height at which the validation is performed.\n\tHeight uint64\n\t// IndexedMessagesCount is the number of indexed messages for the canonical tipset at this epoch.\n\tIndexedMessagesCount uint64\n\t// IndexedEventsCount is the number of indexed events for the canonical tipset at this epoch.\n\tIndexedEventsCount uint64\n\t// IndexedEventEntriesCount is the number of indexed event entries for the canonical tipset at this epoch.\n\tIndexedEventEntriesCount uint64\n\t// Backfilled denotes whether missing data was successfully backfilled into the index during validation.\n\tBackfilled bool\n\t// IsNullRound indicates if the epoch corresponds to a null round and therefore does not have any indexed messages or events.\n\tIsNullRound bool\n}\n\nChainValidateIndex validates the integrity of the chain index at a specified epoch and also optionally backfills missing data.\n\nParameters:\n - epoch: The specific chain epoch for which to validate/backfill the index.\n - backfill: A boolean flag indicating whether to attempt backfilling of missing data if the index does not have data for the\n specified epoch.\n\nReturns:\n - *types.IndexValidation: A pointer to an IndexValidation struct containing the results of the validation/backfill.\n - error: An error object if the validation/backfill fails. The error message will contain details about the index\n corruption if the call fails because of an incosistency between indexed data and the actual chain state.\n\nNote: The API returns an error if the index does not have data for the specified epoch and backfill is set to false.\n\nThe `ChainValidateIndex` API serves multiple purposes:\n\n1. Validates the chain index at a specific epoch:\n - Ensures consistency between indexed data and actual chain state\n - Reports any errors found during validation (i.e. the indexed data does not match the actual chain state, missing data, etc.)\n\n2. Optionally backfills missing data:\n - Backfills data if the index is missing information for the specified epoch\n - Backfilling only occurs when the `backfill` parameter is set to `true`\n\n3. Detects \"holes\" in the index:\n - If `backfill` is `false` and the index lacks data for the specified epoch, the API returns an error indicating missing data\n",
"paramStructure": "by-position",
"params": [
{
Expand Down 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.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",
&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 = ?))",
}
}
7 changes: 5 additions & 2 deletions documentation/en/api-v1-unstable-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -1241,10 +1241,12 @@ type IndexValidation struct {
TipSetKey TipSetKey
// Height is the epoch height at which the validation is performed.
Height uint64
// IndexedMessagesCount indicates the number of indexed messages for the canonical tipset at this epoch.
// IndexedMessagesCount is the number of indexed messages for the canonical tipset at this epoch.
IndexedMessagesCount uint64
// IndexedEventsCount signifies the number of indexed events for the canonical tipset at this epoch.
// IndexedEventsCount is the number of indexed events for the canonical tipset at this epoch.
IndexedEventsCount uint64
// IndexedEventEntriesCount is the number of indexed event entries for the canonical tipset at this epoch.
IndexedEventEntriesCount uint64
// Backfilled denotes whether missing data was successfully backfilled into the index during validation.
Backfilled bool
// IsNullRound indicates if the epoch corresponds to a null round and therefore does not have any indexed messages or events.
Expand Down Expand Up @@ -1303,6 +1305,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 6259731

Please sign in to comment.