Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Maybe to the end bound of proofs (Part 2) #1813

Merged
merged 49 commits into from
Aug 8, 2023
Merged

Add Maybe to the end bound of proofs (Part 2) #1813

merged 49 commits into from
Aug 8, 2023

Conversation

dboehm-avalabs
Copy link
Contributor

@dboehm-avalabs dboehm-avalabs commented Aug 4, 2023

There have been several bugs related to the nil key being confused for no end bound. By converting the end bounds to Maybe[T], it will be more explicit in the code which bound is meant (nil key vs no bound)

See also #1793 #1657

@danlaine danlaine added cleanup Code quality improvement merkledb labels Aug 4, 2023
@dboehm-avalabs dboehm-avalabs changed the base branch from dev to MaybeBounds1 August 7, 2023 13:37
@@ -16,6 +16,13 @@ import (
pb "github.com/ava-labs/avalanchego/proto/pb/sync"
)

func MaybeBytesToMaybe(mb *pb.MaybeBytes) merkledb.Maybe[[]byte] {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should we unexport MaybeBytesToMaybe in both packages if we are replicating this function or should we use one implementation?

Copy link

Choose a reason for hiding this comment

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

I feel like this function should be defined once with the rest of the maybe code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is more of a proto thing though, but you can't define it with protos either

Copy link

Choose a reason for hiding this comment

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

Not sure I follow. Can't we define this in maybe.go?

Copy link
Contributor Author

@dboehm-avalabs dboehm-avalabs Aug 7, 2023

Choose a reason for hiding this comment

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

we could, but it isn't really a maybe functionality thing, it is more a codec/ marshaling thing which primarily lives in proto and codec. It feels weird to have this in the merkledb module since it isn't called anywhere in the merkledb module. There was also talk of moving maybe.go out of merkledb to someplace more common.

Copy link

Choose a reason for hiding this comment

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

This would be in line with the UnmarshalProto and ToProto definitions in merkledb, which also aren't used in merkledb. I feel like it makes sense for an operation defined on Maybe to live with the maybe code. I agree that moving maybe to its own package would make sense in a subsequent PR.

Copy link

Choose a reason for hiding this comment

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

Also related to the above, I think it might make sense to name this UnmarshalProto for parallelism with other similar functions

Copy link
Contributor Author

@dboehm-avalabs dboehm-avalabs Aug 8, 2023

Choose a reason for hiding this comment

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

It isn't a Maybe function, it is a maybebytes function. I'm just going to remove it from the gdb code and leave it unexported in sync.

x/sync/network_server.go Outdated Show resolved Hide resolved
x/sync/network_server.go Outdated Show resolved Hide resolved
Base automatically changed from MaybeBounds1 to dev August 7, 2023 17:52
x/sync/manager.go Outdated Show resolved Hide resolved
@danlaine danlaine merged commit cfb957c into dev Aug 8, 2023
14 checks passed
@danlaine danlaine deleted the MaybeBounds2 branch August 8, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement merkledb
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants