Giter VIP home page Giter VIP logo

kairos's Introduction

Kairos

Development

To get started developing on this repository you can leverage Nix. The following sections explain how to obtain a development shell and how to build the project.

Development Shell

You have two options here, you can configure and leverage direnv to automatically drop you in a development shell (recommended) or do it manually.

Automatic Development Shell using direnv

First, you will have to install direnv, by adding it to your Nix/NixOS configuration or using your package manager. Afterward, run:

touch .envrc
echo "use flake" >> .envrc
direnv allow

Manual Development Shell

Run:

nix develop

Risc0 Development Shell

Because risc0 projects require a fork of rustc, we decided to detach the development shell for kairos-prover from the other crates. To enter a development shell when working with the kairos-prover/risc0 projects, run:

If you don't use direnv, you will first need to enter the default development shell, if you didn't before:

nix develop 

Afterward (the only command you need when you use direnv):

nix develop .#risczero

Inside a Development Shell

Inside the development shell, you can use cargo as usual during development.

Formatting

Code for the whole project tree can be formatted by running nix fmt from the project's root or anywhere in the tree, but be warned that it will only format code inside the sub-tree.

The nix fmt command currently formats all the Rust and Nix code in the tree. To add support for more languages you'll have to adjust the treefmt attribute-set in the flake.nix accordingly. A list of already supported formatters can be found here. Note that any formatting tool can be added trivially, if stuck contact your Nix expert.

Build

You can explore the buildable outputs of this project easily by running:

nix flake show

To build e.g. kairos you can then run:

nix build .#kairos

Check

To run all the "checks" of this project, like formatting, lint, audit, etc. checks, run:

nix flake check

To run a single check e.g. the format check, run:

nix build .#checks.<system>.treefmt

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

kairos's People

Contributors

marijanp avatar koxu1996 avatar avi-d-coder avatar jonas089 avatar rom3dius avatar

Stargazers

Morgan Thomas avatar  avatar

Watchers

Matthew Doty avatar Chloe Kever avatar Mark A. Greenslade avatar  avatar  avatar

kairos's Issues

create cctl test hook

Motivation

In order to integration test our L2 request handlers once we implement the interaction with the L1, we will need to establish connections to the L1 using casper-client-rs's library.
These tests will potentially be executed in parallel, thus we have to be able to spawn multiple networks in isolation, such that each test-case has access to a clean state network.

Steps towards a working harness

We will implement a cctl network hook that launches a network. To ensure proper functioning of this hook, we will need a basic test doing the following steps:

  • launch network via cctl
  • await network launch
  • establish node connection via casper-client-rs
  • execute a deploy transfering funds
  • await transaction settlement

Contracts are built with unstable Rust

Since we wanted contract to be no_std (smaller WASM), panic handler and global allocator has to be implemented additionally. We just relied on no-std-helpers features from casper_contract, which unnecessarily enforced use to use nightly toolchain.

I would like to build contracts with stable Rust.

Improve test reporting

  • report code coverage
  • report number of tests i.e. visualize cargo test results
  • report benchmarks for critical functions/ parts of the system

Integrate `kairos-tx` with smart contract events

As discussed during the latest Smart Contract deep dive, we should include details of L2 transaction in deposit event:

  • payload - SigningPayload from kairos-tx,
  • public key,
  • signature.

Furthermore, smart contract must check that given transaction details are correct, i.e.:

  • Given public key is matching with contract caller (depositor).
  • Signature is valid for payload.
  • Payload details are matching with deposit amount.

That would allow to us to fully trust deposit events, without additional interactions with L1.

Use rkyv for zero copy deserialization

Use https://github.com/rkyv/rkyv for inner messages that appear in a ZK context.
Json is quite expensive should we should use a more efficient format like rkyv's archive or flatbuffers. We only need this on inner messages we can wrap it in JSON for communicating with the server, and base64 the payload.

There is some security risk in using a rkyv since it's devs may have made a mistake and it uses unsafe extensively. Hence we may only want to use it where needed or use the more mature flatbuffers.

Shared library for client requests and payload construction.

The CLI and any future SDKs should use a Rust library to identify L2 endpoints and construct/sign payloads.
The library should be WASM compatible for use in TypeScript and Python SDKs.

This logic needs live in Rust to allow the use of efficient formats like rkyv in the signed payload that needs to be checked in ZK.

kairos-cli: deposit integration

The following PR's implement the kairos-cli deposit integration. The PR's can be reviewed in any order but merged in the following order:

  • 1. #89 is needed for the kairos-test-utils to achieve a more congruent configuration with the actual CLI binary. All of the logic is now in kairos_server::run
  • 2. #90 then uses the kairos_server::run instead of the binary-cli to solve a chicken and egg-problem.
  • 3. #91 implements the integration with the kairos-server. kairos-test-utils is then used in an integration test to verify that submitting to the kairos-server works
  • 4. #94 submit the deposit deploy to L1
  • 5. update end-to-end to await deposit deploy, after it was submitted through the CLI
    • 5.1 NEEDS_REVIEW: #110
    • 5.2 NEXT: create a mock data availability layer, circumvent the batch submission and verification, and query whether the deposit was added correctly

Nix: False positives in E2E tests

Nix's e2e tests relying on curl SHOULD be already broken at least twice - for example the following PRs successfully passed CI checks, even they changed request body in incompatible way:

SSE client for Casper

For deposits routed through Kairos, we should subscribe for Casper's DeployProcessed server-side event in order to get notification once deployment was processed. Relevant design part:

image

Notably there is no Rust client/SDK available for Casper's SSE.

Fix use of deprecated function in kairos-cli

kairos> warning: use of deprecated function `<common::args::AmountArg as clap::Args>::augment_args::id_is_only_for_arg`: `#[arg(name)] was allowed by mistake, instead use `#[arg(id
)]` or `#[arg(value_name)]`                                                                                                                                                         
kairos>  --> kairos-cli/src/common/args.rs:7:11                                                                                                                                     
kairos>   |                                                                                                                                                                         
kairos> 7 |     #[arg(name = "amount", long, short, value_name = "NUM_MOTES")]                                                                                                      
kairos>   |           ^^^^                                                                                                                                                          
kairos>   |                                                                                                                                                                         
kairos>   = note: `#[warn(deprecated)]` on by default                                                                                                                               
kairos> warning: use of deprecated function `<common::args::PrivateKeyPathArg as clap::Args>::augment_args::id_is_only_for_arg`: `#[arg(name)] was allowed by mistake, instead use `
#[arg(id)]` or `#[arg(value_name)]`                                                                                                                                                 
kairos>   --> kairos-cli/src/common/args.rs:13:11                                                                                                                                   
kairos>    |                                                                                                                                                                        
kairos> 13 |     #[arg(name = "private-key", long, short = 'k', value_name = "FILE_PATH")]                                                                                          
kairos>    |           ^^^^                                                                      

Autogenerate client SDKs

Besides CLI for users, we want to provide set of SDKs for developers.

Since server is accessible via REST API, we can leverage OpenAPI spec to autogenerate clients (a.k.a. SDKs).

Fix broken e2e tests for server requests

Broken e2e tests was detected after CI was fixed:

Exception: command `curl --fail-with-body -X POST http://kairos/api/v1/deposit -H 'Content-Type: application/json' -d '{"public_key": "publickey", "amount": 10}'` failed (exit code 22)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.