unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.76k stars 269 forks source link

Add version info to Hashes #466

Open pchiusano opened 5 years ago

pchiusano commented 5 years ago

See #459

pchiusano commented 5 years ago

I'm moving this off of M1 (but open to PRs from new contributors!!). The codebase format is already going to be versioned separately, so it's less important that the base58-encoded hashes of that format include Unison version information (and the hash algorithm) now. We could choose to add this info in a later version of the codebase format, or not, since it will be redundant - within a version of the codebase format, all the hashes will be of the same type.

I see this as being more useful when displaying hashes to users and when sharing copy-pastable hashes that can have an unambiguous meaning even as Unison evolves. It might also prove useful in the implementation of the Unison inter-node protocol so we can keep that in mind, too.

Here's a proposed self-describing hash, using multiformats:

<multibase><unison-multicodec-id><unison-version-id><multihash>

Notes:

I'd be open to a PR for this, I would just edit the Unison.Hash module. Some implementation notes (assuming the above sounds good):

tysonzero commented 4 years ago

Will this be a path towards allowing people to seamlessly store all their public Unison code on IPFS?

I'm a huge fan of all these CAS-focused projects, as I think it is absolutely the future, however I think a huge chunk of the benefit is being able to store all public CAS content on a single decentralized network.

zipper97412 commented 4 years ago

Hi, newcomer here! I am also a huge fan of CAS (ipfs and ipld mostly) as I see things, the AST could be represented as an ipld object, linking with other code by CID, we could use an ipld store as backend (ipfs) for ucm to handle burden of storing artefacts. Also, we get code sync and tests results sync for free just by resolving CIDs on ipfs first Todo:

Ipld also defines an archive format that can be used in future as binary format for standalone executables and/or library just by providing an ipld store implementation for ucm

I will probably open an issue for this later for comments :)

jphastings commented 2 years ago

Did you get anywhere with this @zipper97412?

solomon-b commented 2 years ago

I can try to take a stab at this if @zipper97412 is busy.

tysonzero commented 2 years ago

@pchiusano What's the reason for using a custom unison-multicodec over dag-cbor? Filecoin for example uses dag-cbor. This will give you a lot more interop with existing and future tooling, as dag-cbor is more or less the preferred multicodec outside of some dag-pb for files and folders.