Damus
Rusty Russell profile picture
Rusty Russell
@Rusty Russell

Lead Core Lightning, Standards Wrangler, Bitcoin Script Restoration ponderer, coder. Full time employed on Free and Open Source Software since 1998. Joyous hacking with others for over 25 years.

npub179e9tp4yqtqx4myp35283fz64gxuzmr6n3yxnktux5pnd5t03eps0elz4s@npub.cashlnurl
Relays (7)
  • wss://nostr.bitcoiner.social/ – write
  • wss://nostr.oxtr.dev/ – write
  • wss://sgl.rustcorp.com.au/ – write
  • wss://relay.mutinywallet.com/ – write
  • wss://nostr.wine/ – write
  • wss://nos.lol/ – read
  • wss://nostr.bitcoiner.socoal/ – read

Recent Notes

Rusty Russell profile picture
1. No, I'm not reading your article on quantum.
2. Yes, all choices are bad. That's what "breaking" means.
3. I'm glad smart people are thinking about technical mitigations.
Rusty Russell profile picture
I love this pattern: excellent advice. I asked ChatGPT how to do this in Rust, and it suggested a template using a phantom type was idiomatic Rust:

pub struct ReadOnly;
pub struct Writable;

pub struct Store<Mode> {
file: File,
_mode: PhantomData<Mode>,
}

Then implement write() only in the writable specialization.

I've deferred this change for now, but congratulations: you are responsible for my first refactoring (once the implementation is complete!) 🧡
Rusty Russell profile picture
Leaning into the type system is one of the distinctive traits of my C code, too (and something which I really miss in Python, with its tacked-on type annotations). But Rust certainly lends itself well to this style!
Rusty Russell profile picture
Since I'm taking a few weeks vacation, I've decided to seriously try to learn rust. My method in this case is to ask ChatGPT to guide me (but not write for me!) a library ("crate") that I've always wanted to write and never got around to.

Of course, I get a lot of feedback on appropriate rust styling, but some of it veers into things I feel are deeper constraints. In this case, I had an open function, which took a struct containing some flags, such as "writeable", "create if didn't exist".

It didn't like the fact that I asserted if you set create and didn't set writeable. Here is my response:

---

Re: assert!(). I dislike APIs which allow misuse. Callers of a library should not rely on such checks in the library, in fact the concept of adding an InvalidOptions error type is offensive. A recoverable error is strictly a worse api than an unignorable error. But a compile time error is better.

We should use an enum READONLY, WRITE_MUST_EXIST, WRITE_MAY_CREATE.

---

Of course, it's a waste of time for me to lecture it on style, but I can't help myself!!
Rusty Russell profile picture
Damn, right before I closed my laptop for the afternoon I had uncovered a weird bug, which git bisect says is triggered by a trivial commit.

But I really should record myself tracking it down, for my Intro to CLN Development series, so I am having to resist the urge to look at it tonight...