Skip to content

feat(chainstate): Add indexer config#2491

Open
iquidus wants to merge 7 commits intomasterfrom
indexer
Open

feat(chainstate): Add indexer config#2491
iquidus wants to merge 7 commits intomasterfrom
indexer

Conversation

@iquidus
Copy link
Contributor

@iquidus iquidus commented Feb 6, 2026

Adds indexer config utilizing the documented/verifiable config framework

Note: This is the first PR in a series of indexer related PRs in order to split up the new indexer code into more digestible chunks.

Adds indexer config utilizing the documented/verifiable config
framework
Copilot AI review requested due to automatic review settings February 6, 2026 17:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an initial configuration surface for a new Chainstate indexer using the repo’s documented/verifiable config framework, setting defaults and providing Verify() methods to validate config at startup.

Changes:

  • Introduces RootIndexerConfig to split public vs. secret config.
  • Adds IndexerConfig / IndexerSecretConfig structs with defaults and verification logic.
  • Implements config-framework hooks (GetName, GetEnvVarPrefix, GetPackagePaths) for doc generation and env parsing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 0% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.25%. Comparing base (9da1a02) to head (965d2b7).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
chainstate/config.go 0.00% 66 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2491      +/-   ##
==========================================
- Coverage   40.31%   39.25%   -1.07%     
==========================================
  Files         505      537      +32     
  Lines       45150    49071    +3921     
==========================================
+ Hits        18204    19264    +1060     
- Misses      24791    27367    +2576     
- Partials     2155     2440     +285     
Flag Coverage Δ
litt-tests 32.99% <ø> (?)
unit-tests 40.11% <0.00%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

// Starting block number for indexing. If 0, starts from contract deployment block.
StartBlockNumber uint64

// Number of blocks to process in each batch during indexing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this be the maximum number of blocks that can be in a batch during indexing? assuming once its synced to head it only asses the diff from head and the last block it went up-to in the last event loop iteration

Comment on lines +37 to +41
// Path to JSON file for persisting indexed state to disk.
PersistencePath string `docs:"required"`

// Interval for persisting state snapshots to disk.
PersistInterval time.Duration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

knit:

Suggested change
// Path to JSON file for persisting indexed state to disk.
PersistencePath string `docs:"required"`
// Interval for persisting state snapshots to disk.
PersistInterval time.Duration
// Path to JSON file for persisting indexed state to disk.
SnapshotPath string `docs:"required"`
// Interval for persisting state snapshots to disk.
SnapshotInterval time.Duration

// DefaultIndexerConfig returns a default configuration with sensible values.
func DefaultIndexerConfig() *IndexerConfig {
return &IndexerConfig{
StartBlockNumber: 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any reason we'd default 0 vs starting at now - blob_ttl? in practice having to update a StartBlockNumber every-time we do a fresh deployment could become tedious

if port < 1 || port > 65535 {
return fmt.Errorf("HTTP port must be between 1 and 65535, got %d", port)
}
if c.BlockBatchSize <= 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's some relationship here between BlockBatchSize and PollInterval where they can be mis-expressed in-ways that affects the reliability of core service logic

}

// Verify validates the configuration and returns an error if invalid.
func (c *IndexerConfig) Verify() error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a check for this Verify function for brevity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants