Inspiration

I think it's not very convinient to write hooks in C and deals with raw pointers, buffer lenghts, tricky macros, segfaults. This is a wide area to commit errors. So the inspiration was to reduce the cognitive load, which, in turn, leads to a happier life :)

What it does

This allows you to write hooks in Rust, leveraging Rust's zero-cost abstractions, going up one level of abstraction and not worry too much about low-level api. The less worries the fewer errors.

How we built it

From simple to complex. It all started with the simplest hook. When it turned out that it worked, I moved on to more complicated things. There were obstacles at each stage, but after they were tinkered with, they disappeared.

Challenges we ran into

  • The compiler was trying so hard to inject forbidden function calls
  • The compiler was trying so hard to underoptimize or overoptimize the wasm binary
  • Rust forbids by default uninitialized variables
  • Rust in some cases generate "memset", "memcpy" functions and don't inline them
  • Rust std lib panic!() macro stuff don't inline function calls
  • Only "while" loop can guarantee that _g() call to be the first call in it
  • If you don't use macroses then providing a unique guard ID is quite a tricky task. But it's possible. Thanks, Generics.

Accomplishments that we're proud of

I'm proud to have provided the community with another tool for writing XRPL hooks.

What we learned

A lot! See challenges :)

What's next for XRPL Hooks Rust

There is still a lot of work to do:

  • Full Api
  • Docs
  • Test
  • More examples

Built With

Share this project:

Updates