Conversation
Add types for the chainstate indexer
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## indexer #2492 +/- ##
===========================================
- Coverage 39.25% 32.99% -6.27%
===========================================
Files 537 47 -490
Lines 49071 5940 -43131
===========================================
- Hits 19264 1960 -17304
+ Misses 27367 3592 -23775
+ Partials 2440 388 -2052
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds foundational Go types for the new chainstate indexer so future PRs can implement indexing, persistence, and query APIs on a shared model.
Changes:
- Introduces
Operator,QuorumAPK,OperatorSocketUpdate, andOperatorEjectiondata models. - Adds query filter structs (
OperatorFilter,QuorumAPKFilter) for selecting indexed data.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chainstate/types/types.go
Outdated
| // Operator represents an EigenDA operator with their registration information. | ||
| type Operator struct { | ||
| // Unique operator identifier | ||
| ID core.OperatorID |
There was a problem hiding this comment.
In Operator, the identifier field is named ID, while the other chainstate types in this file use the more explicit OperatorID naming. For consistency and clarity (especially when these types are consumed across packages), consider renaming ID to OperatorID.
| ID core.OperatorID | |
| OperatorID core.OperatorID |
chainstate/types/types.go
Outdated
| // Transaction hash of the ejection | ||
| TxHash common.Hash | ||
|
|
||
| // Timestamp when this was recorded |
There was a problem hiding this comment.
OperatorEjection uses the field name EjectedAt but the preceding comment says "Timestamp when this was recorded" (which matches the UpdatedAt convention used in other structs here). Either rename the field to UpdatedAt for consistency, or update the comment to reflect that this is the ejection/event timestamp rather than a record update timestamp.
| // Timestamp when this was recorded | |
| // Timestamp when the ejection occurred |
| type OperatorFilter struct { | ||
| // Only return registered operators | ||
| RegisteredOnly bool | ||
|
|
||
| // Only return deregistered operators | ||
| DeregisteredOnly bool | ||
|
|
There was a problem hiding this comment.
OperatorFilter can represent contradictory states when both RegisteredOnly and DeregisteredOnly are true, and it’s unclear how callers/implementations should resolve that. Consider replacing these two booleans with a single status field (e.g., an enum) or documenting/encoding a clear precedence/validation rule.
| // Block number for the snapshot (0 for latest) | ||
| BlockNumber uint64 | ||
|
|
||
| // Get all snapshots after this block (inclusive) | ||
| MinBlock uint64 | ||
|
|
||
| // Get all snapshots before this block (inclusive, 0 for no limit) | ||
| MaxBlock uint64 |
There was a problem hiding this comment.
QuorumAPKFilter mixes an exact BlockNumber selector (with the special value 0 meaning “latest”) with range fields (MinBlock/MaxBlock). This makes the filter semantics ambiguous when multiple fields are set. Consider splitting into separate filter types (exact vs range), or making the mutually exclusive fields pointers and enforcing/validating exclusivity.
| // Block number for the snapshot (0 for latest) | |
| BlockNumber uint64 | |
| // Get all snapshots after this block (inclusive) | |
| MinBlock uint64 | |
| // Get all snapshots before this block (inclusive, 0 for no limit) | |
| MaxBlock uint64 | |
| // Optional exact block number for the snapshot. | |
| // If set and the pointed-to value is 0, this denotes the latest snapshot. | |
| // When BlockNumber is non-nil, MinBlock and MaxBlock should be nil. | |
| BlockNumber *uint64 | |
| // Optional lower bound for block number (inclusive). | |
| // When specifying a range, set MinBlock and/or MaxBlock and leave BlockNumber nil. | |
| MinBlock *uint64 | |
| // Optional upper bound for block number (inclusive). | |
| // A nil MaxBlock denotes no upper limit. | |
| MaxBlock *uint64 |
dmanc
left a comment
There was a problem hiding this comment.
Looks good, the copilot comments seem worth addressing though.
chainstate/types/types.go
Outdated
| } | ||
|
|
||
| // QuorumAPKFilter is used to filter quorum APK snapshots when querying. | ||
| type QuorumAPKFilter struct { |
There was a problem hiding this comment.
out of curiosity - how long does data need to obtained for successful protocol retrievals? if we're eg storing quourm APK updates since genesis but only querying the last 2 weeks worth then it may be beneficial to introduce some state pruning wrt to the blob TTL. (analogous to how a validator prunes its blob database for expired blobs)
There was a problem hiding this comment.
Making a note to look into state pruning later. Will be simple enough to add.
Add types for the chainstate indexer
Note: This is the second PR in a series of PRs for the chainsate indexer