Skip to content

Conversation

alarso16
Copy link
Contributor

@alarso16 alarso16 commented Sep 4, 2025

Why this should be merged

Some of the manager attributes (e.g. hasher, tokenSize) really belong to the database. Additionally, the manager explicitly uses merkledb proof fields for range proof verification and finding the next key.

How this works

Moves range proof verification to a database method. The entire find next key functionality is also moved, with a subtle change to completeWorkItem. All the proto changes are related to the gRPC stuff in x/sync/g_db

How this was tested

Existing UT

Need to be documented in RELEASES.md?

No

@alarso16 alarso16 marked this pull request as ready for review September 5, 2025 17:38
@joshua-kim joshua-kim changed the title refactor: verify range proof on DB Verify range proof on DB Sep 5, 2025
@alarso16 alarso16 changed the title Verify range proof on DB Remove proof details from x/sync Sep 5, 2025
@alarso16 alarso16 removed this from avalanchego Sep 5, 2025
@alarso16 alarso16 self-assigned this Sep 5, 2025
// which means [workItem.end] isn't Nothing. Contradiction.
lastReceivedKey := largestHandledKey.Value()

if len(endProof) == 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All changes this line and below are cut-and-paste from x/sync/manager.go


ctx := context.Background()
syncer, err := NewManager(ManagerConfig{
Copy link
Contributor Author

@alarso16 alarso16 Sep 5, 2025

Choose a reason for hiding this comment

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

All these tests that don't require the manager will be moved to a different package eventually

@alarso16 alarso16 moved this to In Review 🔎 in avalanchego Sep 8, 2025
Base automatically changed from alarso16/proof-marshal to master September 8, 2025 20:35
@Copilot Copilot AI review requested due to automatic review settings September 8, 2025 20:45
@alarso16 alarso16 changed the base branch from master to alarso16/delete-g_db September 8, 2025 20:45
Copy link
Contributor

@Copilot 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

This PR moves proof verification and handling logic from the x/sync package to the x/merkledb package. The main purpose is to improve separation of concerns by moving database-specific operations closer to the database implementation and simplifying the sync manager interface.

  • Removes database configuration attributes (hasher, tokenSize, BranchFactor) from sync manager and uses database methods instead
  • Moves range proof verification and findNextKey functionality to database methods
  • Updates proof marshaling to use binary format instead of protobuf in tests

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
x/sync/sync_test.go Updates tests to call database methods directly instead of sync manager methods
x/sync/network_server_test.go Changes proof marshaling from protobuf to binary format
x/sync/manager.go Removes database configuration fields and moves proof handling to database
x/sync/client_test.go Updates proof handling to use binary marshaling
x/merkledb/proof_test.go Adds maxLength parameter to proof verification methods
x/merkledb/proof.go Updates proof methods to use internal protobuf marshaling
x/merkledb/history_test.go Adds maxLength parameter to verification calls
x/merkledb/db_test.go Updates database tests with new return values from commit methods
x/merkledb/db.go Implements proof verification and findNextKey methods in database
proto/sync/sync.proto Removes unused gRPC service definitions and related messages
proto/pb/sync/sync.pb.go Generated code reflecting protobuf changes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@alarso16 alarso16 force-pushed the alarso16/delete-g_db branch from f51a039 to 8e1c529 Compare September 8, 2025 20:56
Base automatically changed from alarso16/delete-g_db to master September 9, 2025 18:17
@alarso16 alarso16 moved this from In Review 🔎 to In Progress 🏗️ in avalanchego Sep 9, 2025
@alarso16 alarso16 moved this from In Progress 🏗️ to In Review 🔎 in avalanchego Sep 10, 2025
@alarso16 alarso16 requested a review from joshua-kim September 11, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review 🔎
Development

Successfully merging this pull request may close these issues.

3 participants