Skip to content

Create a Rust runtime for LB Prelude #105

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

Merged
merged 29 commits into from
Oct 18, 2023
Merged

Create a Rust runtime for LB Prelude #105

merged 29 commits into from
Oct 18, 2023

Conversation

szg251
Copy link
Collaborator

@szg251 szg251 commented Oct 2, 2023

Closes: #103

Some notes on the implementaton:

nix integration

I used nix-cargo-integration (which builds on dream2nix). This hides a lot of complexity with reasonable default configurations. It also uses flake-parts, so making the build.nix a flake module seemed like a natural choice, but it diverges from the current status quo, so there's a separate issue to bring everything to the same conventions.

Types

Integer: num_bigint is used in cardano_serialisation_lib
ByteString: &[u8] or Vec<u8> are the obvious choices, I'm not sure if there's too much difference from the end-user standpoint.

Json serialisers

I followed the same principles that we used in Hs and Ps packages: to_json instances serialise to a Value (intermediary JSON representation). However I'm not sure, if this is the most convenient way from the end-user perspective, we will have to experiment with this later.

Another question mark is error messages: I'm still not familiar with the messages serde returns, so I basically copied the error messages from the Haskell implementation. To make this library feel more natural, I think these should be adjusted in the future.

Property testing

There are two popular options in Rust for property testing: quickcheck and proptest.
The former is a simple library, mostly following the Haskell implementation and design principles. proptest is a more robust (and a little bit slower) tool, with a lot of nice features.
I decided to go with the latter one, as it allowed me to write simply implement BigInt generators. Also, I simply liked the API of the library.
One area which is still not clear to me is proptest-regressions. When a proptest fails, the input values are stored in the project directory, and used in later tests. I decided to put this into .gitignore, I'm not exactly sure if this is working exactly as I desired (e.g. these tests logs remain even if I change the tests).

Links to related issues

@szg251 szg251 marked this pull request as ready for review October 10, 2023 07:18
@bladyjoker bladyjoker added runtime enhancement New feature or request labels Oct 10, 2023
Copy link
Contributor

@bladyjoker bladyjoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great freaking job! Left some comments, let me know wdyt.

@bladyjoker bladyjoker changed the title Create a Rust prelude Create a Rust runtime for LB Prelude Oct 10, 2023
Copy link
Contributor

@bladyjoker bladyjoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is lovely!

Let me know if you need help syncing this with main.

@szg251 szg251 added this pull request to the merge queue Oct 18, 2023
Merged via the queue into main with commit 938e56d Oct 18, 2023
@szg251 szg251 deleted the szg251/rust-prelude branch October 18, 2023 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a Rust runtime for LB Prelude
2 participants