Skip to content

Conversation

@alarso16
Copy link
Contributor

@alarso16 alarso16 commented Sep 9, 2025

Why this should be merged

Redundant field, closes #4256

How this works

Use nil as Nothing.

How this was tested

Existing UT

Need to be documented in RELEASES.md?

No

@alarso16 alarso16 self-assigned this Sep 9, 2025
@alarso16 alarso16 added the cleanup Code quality improvement label Sep 9, 2025
@alarso16 alarso16 moved this to In Progress 🏗️ in avalanchego Sep 9, 2025
@alarso16 alarso16 marked this pull request as ready for review September 9, 2025 21:25
@Copilot Copilot AI review requested due to automatic review settings September 9, 2025 21:25
@alarso16 alarso16 moved this from In Progress 🏗️ to In Review 🔎 in avalanchego Sep 9, 2025
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

This PR simplifies the MaybeBytes protobuf message by removing the redundant IsNothing boolean field and using nil to represent the "Nothing" state instead. This change streamlines the protocol by using the natural protobuf pattern where nil messages represent absent values.

Key changes:

  • Removed IsNothing field from MaybeBytes protobuf definition
  • Updated conversion logic to use nil/non-nil patterns instead of boolean flags
  • Cleaned up validation code that previously checked for invalid state combinations

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
proto/sync/sync.proto Removed is_nothing field from MaybeBytes message and added clarifying comment
proto/pb/sync/sync.pb.go Generated protobuf code reflecting the field removal
x/sync/network_server.go Updated conversion functions and removed validation for invalid state combinations
x/sync/manager.go Simplified request building to use new conversion helper function
x/merkledb/proof.go Updated ProofNode and ChangeProof serialization to use nil pattern
x/merkledb/proof_test.go Removed tests for invalid state combinations that are no longer possible

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

Comment on lines +12 to +26
func MaybeToProto(m maybe.Maybe[[]byte]) *pb.MaybeBytes {
if m.IsNothing() {
return nil
}
return &pb.MaybeBytes{
Value: m.Value(),
}
}

func ProtoToMaybe(mb *pb.MaybeBytes) maybe.Maybe[[]byte] {
if mb == nil {
return maybe.Nothing[[]byte]()
}
return maybe.Some(mb.Value)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The cost of copy-paste here isn't bad and avoids the awkward utils package (which typically ends up becoming a trashcan package without a clear abstraction boundary). Even if the cost of copy and paste was worse, we're not maintaining merkledb long-term anyways.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this aligns reasonably with grpcutils

@joshua-kim joshua-kim added this pull request to the merge queue Sep 10, 2025
Merged via the queue into master with commit 2823d83 Sep 10, 2025
35 checks passed
@joshua-kim joshua-kim deleted the alarso16/remove-maybe-bytes-proto branch September 10, 2025 19:07
@github-project-automation github-project-automation bot moved this from In Review 🔎 to Done 🎉 in avalanchego Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Code quality improvement

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Remove exists field from MaybeBytes

3 participants