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

canonicalize protobufs somehow. #5

Open
zenhack opened this issue Aug 28, 2020 · 4 comments
Open

canonicalize protobufs somehow. #5

zenhack opened this issue Aug 28, 2020 · 4 comments

Comments

@zenhack
Copy link
Contributor

zenhack commented Aug 28, 2020

It would be nice if we could canonicalize typed objects somehow, so that logically identical values produce byte-for-byte identical blobs, allowing them to be correctly de-duped. I don't know if there's a standard way of canonicalizing protobufs? I wasn't able to find anything after a bit of searching.

Relatedly: @bobg, how wedded are you to protobufs in particular? If there is indeed no standard canonicalization algorithm, it may be worth considering other formats (I'm somewhat partial to capnproto).

@bobg
Copy link
Owner

bobg commented Aug 29, 2020

Can't believe I've gotten this far without having heard about (a) capnproto or (b) the non-determinism of protobuf encoding.

I am now educating myself on these subjects. Thanks, and stay tuned.

@bobg
Copy link
Owner

bobg commented Oct 28, 2020

I'm finally back to looking at this. I like the deterministic encoding of capnproto, but I hate the unidiomatic, type-unsafe Go produced by the capnproto Go compiler - everything is a capn.Struct. That makes it a non-starter as far as I'm concerned.

There are proposals out there for making protobuf encoding deterministic; e.g. https://docs.cosmos.network/master/architecture/adr-027-deterministic-protobuf-serialization.html. Maybe that's the way to go?

@zenhack
Copy link
Contributor Author

zenhack commented Oct 28, 2020

type-unsafe Go produced by the capnproto Go compiler - everything is a capn.Struct

Not sure what your referring to? It should generate typed wrappers? I will grant that having to use getters & setters is less ergonomic than being able to just use struct literals though...

But if there is a canonicalization algorithm for pb out there that does what is needed, then that solves the problem too.

@bobg
Copy link
Owner

bobg commented Aug 11, 2021

I have done away with the idea of typing blobs, and so protobufs are no longer first-class objects in BS. There are convenience functions for putting and getting them, and some structures (hashsplit trees, maps, etc) are defined using them, but they are no longer intrinsic to the BS data model.

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

No branches or pull requests

2 participants