You are reading content from Scuttlebutt
@aljoscha %ZBzVJhKOYub7bFtZpYCeXPa3O7Me4gftEl80b+ts6Kk=.sha256

This thread will serve as my dev-diary for the #sunrise-choir. General goals:

  • specify the current ssb protocol
  • specify improvements
  • implement stuff in rust
    • with a focus on readability and correctness, not necessarily performance
  • get the improvements rolled out into the wild
@aljoscha %SNbftBoc4Mbq22hbezl5goKOEfoAiHTPN6avqvwRLAg=.sha256

Dev Diary 01/10/2018

Next steps:

Deal with floats (I really hoped I wouldn't have to, but oh well...):

  • Read up on the representation to figure out node's behaviour, do some math if I have to (I'm fine with math in general, it only gets annoying once it involves numbers)
  • Check whether there's a sufficiently configurable rust implementation for float printing. If not, I'll need to implement one myself.
  • Read up on and fully understand the Dragon4 algorithm, check whether the current state of the art is viable.

Next steps that will be actually useful:

  • implement legacy encoding, hash computation and length checking in rust
  • use afl on the rust implementation to generate test cases
  • check whether the js implementation behaves the same way on those test cases, iterate until they match

But yeah, tomorrow's dev diary may very well end up being "I read some papers and scribbled down a lot of notes trying to understand them". Hopefully it won't be more than one day of that.

@aljoscha %ezmzK85DZ5mbG2bQcIFEl7a1kam1IPLM9FCSBfmmq8Q=.sha256

Dev Diary 02/10/2018

  • forked a rust implementation of the Ryū floating point printing algorithm and modified the formatting to implement the ssb legacy float signing format. Most of the work was renaming the crate and modifying the tests. https://github.com/ssbrs/ryu
  • implemented a serializer for json-encoded legacy messages, supporting both the signing format and whitespace-less compact output for replication: https://github.com/ssbrs/legacy-msg/blob/master/src/json/ser.rs
    • this was the hard part of the whole legacy message stuff
  • decided I won't implement legacy (De)Serialize for std types, and I won't provide derive Macros for these traits. The legacy format should only be used for verification/cypherlink computation of old messages, and that is done through a generic Value type.
  • wasted a few hours trying to reuse the serde_json parser
  • started implementing a json parser. At least that minimizes dependencies and gives us full control that the parser does indeed recognize ECMA-404 (minus numbers that are invalid for ssb), the popular rust json parsers don't even bother specifying which standard they implement...

Next goals:

  • finish the json parser
  • implement Deserialize on the legacy Value types
  • implement legacy encoding, hash computation and length checking in rust
  • use afl on the rust implementation to generate test cases
  • check whether the js implementation behaves the same way on those test cases, iterate until they match
  • specify legacy metadata
  • implement legacy metadata
  • hook everything together for message verification

Bonus goal:

  • js bindings to the verification function
@aljoscha %AFLMLHLG/ALnOgljKlPN/AlAfTFO9vfOfmxJ52Q4TM4=.sha256

Dev Diary 03/10/2018

I haven't run a single line of this code, but in theory we can now encode and decode arbitrary json legacy data values.

Next steps:

  • get enough sleep
  • run all the lines of code
  • ideally via afl
  • fix all the errors
  • create a setup to verify identical behavior of nodejs and rust implementation
  • implement hash computation and length computation
  • extend the js compatibility verification for hashes and length
  • extract a test data set
  • prettify rust code, create readable documentation
@aljoscha %8C4muzwvOywlOEeK4UFgsikK5OT8+Tk9BdkGrcX+gsk=.sha256

Dev Diary 04/10/2018

Today was somewhat grindy, chasing a lot of errors.

Fuzzers are magical, this is all the test code I wrote to weed out errors in the json parser:

#![no_main]
#[macro_use]
extern crate libfuzzer_sys;
extern crate ssb_legacy_msg;

use ssb_legacy_msg::json::{from_slice, Value, to_vec};

fuzz_target!(|data: &[u8]| {
    match from_slice::<Value>(data) {
        Ok(val) => {
            let sign_json = to_vec(&val, true);
            let redecoded = from_slice::<Value>(&sign_json[..]).unwrap();
            assert_eq!(val, redecoded);
        }
        Err(_) => {}
    }
});

Next steps:

  • fix the remaining errors so that the rs implementation is compliant with the js one
  • a lot more fuzzing, then minimize the corpus, generate test data, and publish a test suite
  • decide on an order in which to do the remaining legacy message work:
    • spec and impl json metadata
    • clean up the code
    • clean up the specs
    • define and implement cbor encoding for legacy messages
    • js bindings?
@Dominic %L3sTXRyH0N20R4624x1ebJigtn1zMmsvxXtXrcZN3HI=.sha256

hmm is JSON.parse("11111111111111111111111111111111111111111111111111111111111111111111111111e-323") equal to 1.1111111111111111e-250? because that is what node.js interpreted it as

@aljoscha %qHIsyGax1AV3DNPXF4Cjyd7dvqPgPSl8fENxKc6xDoI=.sha256

Yeah, those two are equal. Parsing it may actually result in a different float, but rounding works for both serialization and deserialization.

@aljoscha %TupGHyN+zrXoLesJsmf5fm0pib/kxMH10I3BWjwbL+k=.sha256

Dev Diary 05/10/2018

This was not a fun day of work. The most productive thing might have been the fuzzers running in the background =/

@aljoscha %O8aEFQ3FJQir6ogLs5KA/+BDM+NnceR3eIbzXnlCBEA=.sha256

Dev Diary 06/10/2018

(Not a full day of work)

  • Fun, so much fun! %ZOosXgU...
  • Aside from the two blocking issues on the js side of things (utf8 decoding and object entry order), the rust implementation of json legacy message content is now fully functional and passes the couple of thousand test cases the fuzzer generated.

Next up:

  • bother @Dominic until utf8 decoding and object entry order are resolved in js ssb
    • optional subgoal: create js bindings to the rust json codec for usage by js ssb, if so desired (warning: AGPL code, but I might be willing to relicense it if that helps js ssb to do order-preserving json decoding in rpcs)
  • publish the test data (depends on how utf8 decoding and object entry order get resolved)
  • implement the cbor encoding of legacy message data

I'll do the cleanup, thorough documentation , and actual releases, once both json and cbor legacy message data are fully specified and implemented. I'll tackle legacy metadata afterwards. And when that is done, it's time for #hsdt

@aljoscha %AlSseDWFG+UcKCVyPFXPVMSl84YV17FF9yQFldH6Nyw=.sha256

Dev Diary 07/10/2018

@aljoscha %KpresJXwd6VojMcDUFDDFC6c0sU/40CUIIabX+peK/k=.sha256

Dev Diary 08/10/2018

Next steps depend on how we deal with the signing problem and the cbor feed id encoding. In any case, I'm close to having implemented the full legacy message code in rust, both for json and cbor. When that's fully done and we settled on how to deal with the open problems, I'll do a bunch of clean up and publishing, as well as js binding.

@aljoscha %qXZR406vxMxymxd2jC5g0P2Ij+oOKBlA5XnwtSuM17I=.sha256

Dev Diary 09/10/2018

Today was another of those grindy days. The above doesn't look like I even did a lot, since most of the time went into reconstructing error cases, fiddling around with the rust standard library, and debugging.

But on the plus side, this may have been the last grindy work on legacy message stuff. Json encoding is fully implemented, the precise format is nearly nailed down, cbor encoding appears to be working, and I think I've settled on a compact legacy metadata format to go with the cbor content format (I'm pretty convinced that this is the right way to go for feed metadata, which was the last open problem with the compact legacy metadata).

What remains in this first phase of work is code clean up, documentation, better cbor testing (ideally by checking against other implementations), better cbor spec, specification and implementation of the compact legacy metadata, clean-up of the spec, release of test data, binding creation. All of these are tasks I have full control over, no more bugs in dependencies or protocol weirdness.

I expect to do the first releases of spec, test-suites and rust implementation later this week (leaving cbor stuff for later) :tada:

@aljoscha %dAsf1LY06v2KAOdTf6jAEsQTeivQw1ha8az5Ecnk44c=.sha256

Dev Diary 10/10/2018

This felt unproductive... oh well.

@aljoscha %PW43Ppg8fC29pd0SN4wX35vv1QZOgWRzFkpMjuKY4Lg=.sha256

Dev Diary 11/10/2018

@aljoscha %GKStctEutueJ14zwLhVO69cMCspyfLfmtlkeuQmjycs=.sha256

Dev Diary 12/10/2018

Next up:

  • implementing legacy metadata and its json encoding
  • message validation
  • html version of the spec
  • so, so much code clean up
  • releases
    • not yet on crates.io btw, I want to keep the flexibility of git dependencies until we know what kind of interfaces make sense

I won't manage to finish it this week, but reasonably soon I'll be done with the legacy stuff. And then I can start thinking about protocol improvements again.

@aljoscha %Ry/WwEavJIGalPiDh3AWTvX1rP9VmcMlcvl7CrhIyFU=.sha256

Dev Diary 13/10/2018 and 14/10/2018

Spent a lot of time fighting the compiler and my own traits. I got pretty frustrated, it has taken me ages to write a tiny amount of low-quality code for the metadata implementation. But I think I figured out why: I've misunderstood serde. I wrote a serde-like crate where the supported data model is exactly that of ssb. But the serde data model isn't about json/cbor/whatever, it really is about the rust type system. Data format specific stuff can be done by the Deserializer/Serializer implementations (and most importantly their error type). This was why writing code with my custom traits was so painful - they simply didn't map to the rust types I tried to (de)serialize.

The moment I realized this, I went from having to force myself to do more rust implementation work to actually looking forward to it. But I'm done for the weekend.

Other things:

I can already feel this dev diary declining...

@aljoscha %IvA7g15L0VzwVkDC7qQtoErigUfnl25V7yQ3wLNdUEo=.sha256

Dev Diary 15/10/2018

The problems with serde still persist, there are a few things in the ssb metadata that serde just isn't equipped to deal with. I don't have the energy to push through this right now, I'll take the day off and discuss this in the next sunrise choir call (which luckily happens tomorrow).

@aljoscha %a/sPmkGYYAkpw2pFWo3i7PBsXQ7Q4xM5CrBzTl0U9EI=.sha256

Dev Diary 15/10/2018

@aljoscha %a23cZ8SH7UDMoU65Et0gV8bPGLsb4IvUg0z8CgvlbR0=.sha256

Dev Diary 17/10/2018

@mikey %ymulqy/SgRxO/Cr3YsGomb6FWC9I10FYj2qSKZXtqL4=.sha256

@dinosaur, can you do some magic so that this gets compiled and published at spec.scuttlebutt.nz upon a push to master?

@Aljoscha sure! :gift:

@aljoscha %uFwD/xs0rH0mzP7CbQC+lMFa1HVjUh1FLNA/JJwFe6Q=.sha256

Dev Diary 18/10/2018

  • serde rewrite of the data formats
  • metadata parsing and serialization

Nothing to report, just a bunch of code that needs to be written. Doing both in parallel, neither is done yet. Code is in such a terrible state that I won't bother uploading it.
I'll continue working, but I can already post this, nothing new is going to happen over the next few hours of work...

@aljoscha %oJ9A++vrbxXlCgGLqttaVh5eFmQBA/rqpkBiq5QXHkY=.sha256

Dev Diary 19/10/2018

  • started drafting a post on merkle-trees for ssb logs, but got stuck on the actual implementation details, so I postponed it because I also want to get some programming done today: https://gist.github.com/AljoschaMeyer/a824a410032fcf8ad310cf80c24a185e
    • and prior to drafting, this involved a bunch of reading and thinking
      • I think we can do better than this structure: https://github.com/blockstack/blockstack-core/issues/146
        • this adds quasilinear space overhead to the feed (I think?), a tree-based solution should manage to get it down to linear
      • this is just plain amazing: http://soc1024.ece.illinois.edu/gpads/gpads-full.pdf
        • seriously, I did not expect that searching the web for merkle skip list would lead into such an amazing rabbit hole
          • which I'll have to explore in my free time I guess - back to programming for now
          • but just imagine combinding λ• with Lasp... there's just so much CS still has to explore =)
  • finished the serde json serializer
    • does not yet have a mode for automatically serializing map entries in the correct order though
  • nearly finished a serde json deserializer
  • more merkle trees - no point in fighting my own brain
    • I'm starting to accept the need for a merkle skiplist rather than a pure tree, but I'm still unhappy with the space requirement in the feed itself...
@aljoscha %irDHnh42eR+I94+MLq9JMCwQMjOOmlXJZ8OhIPD5uM0=.sha256

Dev Diary 20/10/2018

  • wrote words: %L9m5nHR...
  • finished the serde message data deserializer
  • adapted the remaining code to work with it
  • passing the full test data set again

Everything is ready to get back to metadata handling. Once that's done and base64#76 is resolved, I can generate test data sets, and then the legacy stuff is over.

@aljoscha %Uqc0CJeEjJ86nbRjS2MAoSoHTWkFB0Cik06T8HGugQs=.sha256

Dev Diary 21/10/2018

@aljoscha %x5jH4DElARkUWnaalO9q6q7L8NVmPc4z201QcRarWc8=.sha256

Dev Diary 22/10/2018

  • put some more time into the merkle-tree thread
  • tidied up the multiformats implementation, added support for serializing directly into a Writer.
  • added encrypted content to the multiformats section of the spec
  • started non-horrible version of the metadata implementation
@aljoscha %aaedvtZsTkRF8mFzdjNwG4u3Aoi5a5pOczeganXq4Qo=.sha256

Dev Diary 23/10/2018 and 24/10/2018

  • started fuzzing the multiformats implementation, needed to fiddle around until I got the (temporary) canonicity check right
  • metadata/message implementation: https://github.com/ssbrs/ssb-legacy-msg
    • yay!
@aljoscha %S9Nt+Hz0BsfI3EkicwbLjppRma+sLMfx31Qp+ruGO/0=.sha256

Dev Diary 25/10/2018 and 26/10/2018

  • put more time into merkle trees, only to realize today that the approach doesn't work: %qZ5dtIH...
  • programming involved a bunch of small additions towards message verification, but the good stuff is blocked on this

The progress feels extremely slow, I have reached the 20 days of work per month (with a lot of those spent completely on sleep, food and ssb), and there's some rl stuff occupying my mind. So I'm going to take it slowly for a couple of days and work mostly when I feel like it, rather than my previous, pretty rigorous schedule.

@aljoscha %TQye2G14ksYc2ked7hFDtQaFlQAKsGHO1dKxBvlUUAI=.sha256

A little bit of clean-up, and then the legacy message stuff is done (well, except for the js bindings).

@aljoscha %P/+NydXsVHg/9xnXTqrJbYsjBWv3EGI//W1XeXDfn3c=.sha256

Dev Diary 29/10/2018

@aljoscha %58xHLWdOGKG79KSxMS1LBJrG7INse0TGO6BXcktRLlc=.sha256

Dev Diary 30/10/2018

@aljoscha %aER5wuLkfTF5LvwwgjRKaURp94/1oDbzR9WzjnzRVd4=.sha256

Dev Diary 31/10/2018

@aljoscha %PSFz5I4macpmCoNtMtZalrdpD9f95WzZCUoJJFDfT68=.sha256

Dev Diary 01/11/2018 and 02/11/2018

  • Implemented clmr deserialization
  • debugged the clmr implementation
  • benchmarked the clmr implementation

Life outside ssb has been somewhat draining these past few days, so I haven't had the energy to engage properly with @keks on multiboxes and @Tim Makarios (on Manyverse) on merkle trees. I haven't forgotten either of you, I'll get back to these discussions once I have the energy.

Note to self: Start discussion about clmr's representation of hashes (explicit sigil or not?) and feed ids (data other than key or not?). Clmr just takes an arbitrary stance on both of these, but we should come to an informed consensus - and I'm honestly not sure which way to go.

@aljoscha %ORYTV6aFYAOpiMRwr7XJjmJEr7R9COGgzdNZVf1ImbQ=.sha256
  • engaged in the aforementioned discussions
    • guess it wouldn't have hurt to have waited a little longer until I was more relaxed, but oh well
  • I'm unhappy with the bpmux-rel spec, so I tried drafting a less complicated approach based on bit-flags and varints: https://gist.github.com/AljoschaMeyer/c02d93cb6d78bcfabe026ed116a45ea4
    • the whole thing is done in my head, but the link doesn't specify all of it
    • just as with the previous draft, I'm having trouble writing this down. The concepts feel rather simple, but I'm unable to express them concisely...
  • changed clmr to explicitly encode the hash target
@aljoscha %Ylf2GxoMLhh5jH1pV8akERmnertAwvFDuEVE6FaXyaQ=.sha256

Dev Diary 05/11/2018

@aljoscha %Y0MKglyq4wkV10GqEsrMSZOXNLZnaMdUJ43eT7NnlrQ=.sha256

Dev Diary 06/11/2018

  • weekly call
  • wrote words, not code
  • read up on multiaddresses, took a bunch of notes, nothing to present yet
    • at this point it's more about finding the right questions to ask than looking for the answers

This felt pretty unproductive, but it was a day of doing stuff, so...

User has not chosen to be hosted publicly
@dan %JbM1uozrpLjBfF4TwvNFnWXl9MNFVKWrdj5YRxahtVo=.sha256

I always imagine it as pouring water into a pool... you might not see it, but the water level is rising and each cup counts :)

@aljoscha %eYszHVzArgPhEdV3OUzqbgyR1FAUhQPOUrKhyLw3IYw=.sha256

Dev Diary 07/11/2018 and 08/11/2018

  • more words
    • feels like the discussions are approaching a point where I can resume work on the encodings soon(ish)
  • code: https://github.com/AljoschaMeyer/varu64-rs/blob/master/src/nb.rs
    • decoding of VarU64s that can deal with partial input, and encoding that can deal with partial output (space)
    • this is the beginning of implementing bpmux/rel in rust
@aljoscha %oS2l3S2sYWlcQxAOtXJO5r5LJ5VqnkFTq+ZlAWaz8oo=.sha256

Dev Diary 09/11/2018

Had my first fights with the borrow checker for this project. State machines that produce some sort of result are annoying in rust: The functions to advance them work by taking mutable references. But when they are done, you want to return the result you have been accumulating by value. The workaround involves putting the accumulating result into an Option, so you can take it at the end. This introduces a bit of runtime overhead and makes the code noisier, but it satisfies the borrow checker.

Technically, the borrow checker is correct, because the type system does not express that the state machine is never used again once the result has been produced. But still, in C you could just write the straightforward code and everything still works as long as the state machine is used correctly. And it is not like the Option-workaround would prevent incorrect usage, it just panics at runtime.

The whole bpmux/rel implementation will consist of composing state machines, so I'll just have to accept this.

@aljoscha %RIjXvqNgVkkg6SvZTJHgIBMtJlJwEcWUE0UX9kyPr84=.sha256

Caught a cold, it'll be a few more days without updates.

@dan %VQ33qhvPghu4MwzSzt8+lYRO1XpDlxVJofIqWZOcEZ4=.sha256

cypherspace bed of restoration for you friend! rest up and take good care.

cypherspace bed of restoration

@aljoscha %OQoUFhCmp7/EH/Lgxi5C1TYf68xNkCmnsy2lLs7h2KU=.sha256

Dev Diary 26/11/2018 and before

I'm mostly back. The cold segued into a phase of really low motivation, and I likely won't get back to my previous schedule of work on all the things all the time, so expect more sporadic/irregular updates. Had a good, open conversation with mikey and piet over this, would definitely recommend them as boss/coworker.

Aside from sunrise choir calls, I also had a call with Dominic where we talked about the future message formats. I'll finish the clmr format, then I'll focus on specifying and implementing hsdt and the new metadata format.

Stuff I did today:

Misc:

Still need to implement the new multibox definition, but then the legcy/clmr block of work should be done.

@Anders %WC2/Y6508efp3LxtDXsJ4hZlj4HPMRXWMKuN4zn1dGg=.sha256
Voted Dev Diary 26/11/2018 and before I'm mostly back. The cold segued into a ph
@aljoscha %I0vGZNgEBWRyninIHVF/F9ZItu46vK8QShIj6ogrn2Q=.sha256

Dev Diary 03/12/2018

This should fully conclude the work on legacy messages. We have a full spec, rust implementations for deserialization, validation and serialization, and a more compact encoding (both a spec and a rust implementation).

Unless the multibox definition changes yet again, the next block of work will be the final definition of #hsdt (and a rust implementation, as usual).

@aljoscha %SlfGcmglfK+kxu+YnEWpqVzPTXButru/5Uxd4jYMnb4=.sha256

Dev Diary 04/12/20

  • fun with map entry order: %7QY10rX...
  • specified logical data model and an signing encoding for hsdt (neither necessarily final): %BTnweXw...
@aljoscha %svxxo2D1B9li5ka+yJslVk2vCyitEb0HWwnfL8LLyKs=.sha256

End of Diary

This is difficult for me to post about, but here we go: I've left the #sunrise-choir team. I managed to burn out, there's been an unhealthy cocktail of:

  • me trying to do too much and not taking good care of myself
  • real life being emotionally draining
  • feeling like the stuff I did did not have a real impact

I'm starting to do better, but I need some time to recharge. I've started out being very passionate about the protocol discussions, but right now I mostly skim them and move on, even if I very much disagree. That's pretty scary, but I'll listen to my brain for now. There'll surely come a time when I'll engage again and can annoy Dominic a bit more.

@dinosaur and @Piet have been absolutely lovely the whole time, while still giving me the freedom to learn this lesson about myself. Thank you guys.


I plan on writing a retrospective on the stuff I did over the two months of choir work. There's been a bunch of specification writing, both for the current protocol and for potential protocol evolution, as well as a few rust implementations. A few things are somewhat hanging in the air, but a lot of them are self-contained and usable. It'll be nice to organize and reflect on them. I'm not in the right state to tackle this yet, but I know I'm going to get to it eventually.

User has not chosen to be hosted publicly
User has not chosen to be hosted publicly
User has not chosen to be hosted publicly
User has not chosen to be hosted publicly
User has chosen not to be hosted publicly
@Anders %C58RKMM/c7GeY3kNEX8DKbL2mtI8KtM7Hx/N6OMl4dQ=.sha256
Voted [@Aljoscha](@zurF8X68ArfRM71dF3mKh36W0xDM8QmOnAS5bYOq8hA=.ed25519) sorry to
User has chosen not to be hosted publicly
User has chosen not to be hosted publicly
User has chosen not to be hosted publicly
@cryPhone📱 %NkE0di9XuWXMFt7NdzQ/3U/3yXEIFBAMt3X1uVkQsTk=.sha256
Voted Dear [@Aljoscha](@zurF8X68ArfRM71dF3mKh36W0xDM8QmOnAS5bYOq8hA=.ed25519) Pl
Join Scuttlebutt now