Skip to content

refactor(indexer): reorganize discovery-core, prepare for state sync - #407

Merged
m-kus merged 1 commit into
mainfrom
02-04-refactor_indexer_reorganize_discovery-core_prepare_for_state_sync
Feb 11, 2026
Merged

m-kus merged 1 commit into
mainfrom
02-04-refactor_indexer_reorganize_discovery-core_prepare_for_state_sync

Conversation

@m-kus

@m-kus m-kus commented Feb 4, 2026 •

Copy link
Copy Markdown

TL;DR

Restructured the discovery-core crate to improve organization and reduce dependencies.

What changed?

  • Removed the anyhow dependency from discovery-core
  • Reorganized the codebase by moving privacy pool-specific modules into a dedicated privacy_pool namespace
  • Refactored the discovery API to separate channel count fetching from channel discovery
  • Renamed DiscoveryResult to ChannelDiscoveryResult for clarity
  • Changed result fields from total_n_channels/subchannels/notes to last_index to better represent their purpose
  • Simplified storage slot computation by removing unnecessary error handling
  • Moved I/O budget constants from io_budget.rs to discovery/mod.rs
  • Consolidated storage-related traits into a new storage_backend module

How to test?

  • Run the existing test suite to verify all functionality works as expected
  • Verify that the discovery API still works correctly with the new parameter structure
  • Check that the mock backend still functions properly with the reorganized code

Why make this change?

This refactoring improves code organization by clearly separating privacy pool-specific code from the general discovery framework. It also makes the API more explicit by separating the channel count fetching from the discovery process, which allows for better error handling and budget management. Removing the anyhow dependency reduces the dependency footprint of the crate.


This change is Reviewable

m-kus commented Feb 4, 2026 •

Copy link
Copy Markdown
Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@m-kus
m-kus marked this pull request as ready for review February 4, 2026 18:20
@m-kus
m-kus requested a review from Yoni-Starkware February 4, 2026 18:21
@m-kus
m-kus force-pushed the 02-04-refactor_indexer_reorganize_discovery-core_prepare_for_state_sync branch from e8f1cb5 to b7bd5d0 Compare February 4, 2026 19:57
@m-kus
m-kus changed the base branch from main to graphite-base/407 February 4, 2026 21:00
@m-kus
m-kus force-pushed the 02-04-refactor_indexer_reorganize_discovery-core_prepare_for_state_sync branch from b7bd5d0 to d828a86 Compare February 4, 2026 21:01
@m-kus
m-kus changed the base branch from graphite-base/407 to 02-04-feat_ci_speed_up_rust_workflow February 4, 2026 21:01
@m-kus
m-kus force-pushed the 02-04-feat_ci_speed_up_rust_workflow branch from 4efbe71 to 288a85b Compare February 5, 2026 11:40
Base automatically changed from 02-04-feat_ci_speed_up_rust_workflow to main February 5, 2026 11:41
@m-kus
m-kus force-pushed the 02-04-refactor_indexer_reorganize_discovery-core_prepare_for_state_sync branch from d828a86 to dd9ee93 Compare February 5, 2026 14:19
@m-kus
m-kus force-pushed the 02-04-refactor_indexer_reorganize_discovery-core_prepare_for_state_sync branch 2 times, most recently from 0591199 to 9aafdbc Compare February 5, 2026 21:29

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Yoni-Starkware partially reviewed 9 files and all commit messages, and made 1 comment.
Reviewable status: 9 of 20 files reviewed, 1 unresolved discussion (waiting on @m-kus).


crates/discovery-core/src/discovery/subchannels.rs line 31 at r4 (raw file):

    /// Index of the last discovered subchannel, or `None` if no
    /// subchannels were discovered.
    pub last_index: Option<u64>,

Since it's a function of subchannels, WDYT about removing this field? on all responses.
(you can add a method)

Code quote:

    /// Index of the last discovered subchannel, or `None` if no
    /// subchannels were discovered.
    pub last_index: Option<u64>,

@m-kus m-kus left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@m-kus made 1 comment.
Reviewable status: 9 of 20 files reviewed, 1 unresolved discussion (waiting on @Yoni-Starkware).


crates/discovery-core/src/discovery/subchannels.rs line 31 at r4 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Since it's a function of subchannels, WDYT about removing this field? on all responses.
(you can add a method)

last index is start index + number of all newly discovered subchannels. If we complete discovery in a single request then we could derive last index but in general case we cannot.

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@Yoni-Starkware partially reviewed 11 files and made 4 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @m-kus).


crates/discovery-core/src/discovery/subchannels.rs line 31 at r4 (raw file):

Previously, m-kus (Michael Zaikin) wrote…

last index is start index + number of all newly discovered subchannels. If we complete discovery in a single request then we could derive last index but in general case we cannot.

I don't understand - I see that last_index = subchannels.last().map(|s| s.index);, and that's the only flow, whether you ran out of budget or not.

Anyway, non-blocking for the stack, but seems redundant


crates/discovery-core/src/privacy_pool/hashes.rs line 162 at r4 (raw file):

    #[test]
    fn test_compute_enc_amount_hash() {
        use crate::privacy_pool::types::felt_low_u128;

Non-blocking (don't fix in this stack): our convention is to put all imports in the top of the file

Code quote:

    fn test_compute_enc_amount_hash() {
        use crate::privacy_pool::types::felt_low_u128;

crates/discovery-core/src/privacy_pool/decryption.rs line 9 at r4 (raw file):

use thiserror::Error;

use super::hashes::{

Non-blocking (don't fix in this stack): our convention is to avoid super

Code quote:

use super::hashes::{

@m-kus m-kus left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@m-kus made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Yoni-Starkware).


crates/discovery-core/src/discovery/subchannels.rs line 31 at r4 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

I don't understand - I see that last_index = subchannels.last().map(|s| s.index);, and that's the only flow, whether you ran out of budget or not.

Anyway, non-blocking for the stack, but seems redundant

Ah right! You are correct, it's currently redundant, but semantically it's better to separate because generally subchannel discovery is not obliged to return everything it found, e.g. sdk now supports filtering by token (which discovery service does not yet implement)


crates/discovery-core/src/privacy_pool/decryption.rs line 9 at r4 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Non-blocking (don't fix in this stack): our convention is to avoid super

Noted


crates/discovery-core/src/privacy_pool/hashes.rs line 162 at r4 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

Non-blocking (don't fix in this stack): our convention is to put all imports in the top of the file

Noted, I'll do mass refactoring wrt imports afterwards

@m-kus
m-kus force-pushed the 02-04-refactor_indexer_reorganize_discovery-core_prepare_for_state_sync branch from 9f5c504 to 07a46a6 Compare February 11, 2026 12:04
@m-kus
m-kus merged commit ce9beb5 into main Feb 11, 2026
5 of 6 checks passed
@m-kus
m-kus deleted the 02-04-refactor_indexer_reorganize_discovery-core_prepare_for_state_sync branch February 11, 2026 12:07
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.

2 participants