Skip to content

Commit

Permalink
Merge pull request #1 from redstone-finance/v1.0.0
Browse files Browse the repository at this point in the history
V1.0.0
  • Loading branch information
Lukasz2891 authored Jul 30, 2024
2 parents 1e8783b + 17ddb8c commit 2ed3cb0
Show file tree
Hide file tree
Showing 43 changed files with 2,739 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .github/workflows/rust-sdk-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Rust SDK CI
on:
workflow_dispatch:
push:

env:
CARGO_TERM_COLOR: always

jobs:
rust-sdk-ci:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Set up Rust PATH
run: echo "$HOME/.cargo/bin:$PATH" >> $GITHUB_PATH
- name: Lint rust
run: make check-lint
- name: Test rust
run: make test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

.idea/
41 changes: 41 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "redstone"
version = "1.0.0"
edition = "2021"
authors = ["RedStone <https://redstone.finance>"]
description = "A Rust implementation of deserializing&decrypting RedStone payload"

[features]
default = ["core", "network"]

# A core functionality of the package.
core = ["sha3/asm"]

# An interface for the network to be extended.
network = []

# An extension for casper network
network_casper = ["casper-contract/wee_alloc", "casper-types", "network"]

# An extension for debug-printing of messages in the Casper extension. Not supported by Casper Contracts deployed to the network.
print_debug = ["casper-contract/test-support"]

# A variant of decrypting the message-signers using secp256k1 library. Cheaper in runtime.
crypto_secp256k1 = ["secp256k1/recovery", "secp256k1/lowmemory", "secp256k1/alloc"]

# A variant of decrypting the message-signers using k256 library. Cheaper during contract deployment.
crypto_k256 = ["k256/alloc", "k256/sha256", "k256/ecdsa"]

# A set of helpers for testing & offline usage.
helpers = ["hex/serde", "hex/alloc", "network"]

[dependencies]
casper-contract = { version = "^4.0.0", default-features = false, features = [], optional = true }
casper-types = { version = "^4.0.1", default-features = false, features = [], optional = true }
sha3 = { version = "^0.10.8", default-features = false, features = [], optional = true }
k256 = { version = "^0.13.3", default-features = false, features = [], optional = true }
secp256k1 = { version = "^0.29.0", default-features = false, features = [], optional = true }
hex = { version = "^0.4.3", default-features = false, features = [], optional = true }

[dev-dependencies]
itertools = { version = "^0.12.1" }
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
CLIPPY=cargo clippy --release --fix --allow-dirty --allow-staged
DOC=cargo doc --no-deps --document-private-items
TEST=RUST_BACKTRACE=full cargo test --features="helpers"
FEATURE_SETS="crypto_k256" "crypto_k256,network_casper" "crypto_secp256k1" "crypto_secp256k1,network_casper"


prepare:
@rustup target add wasm32-unknown-unknown

test:
@for features in $(FEATURE_SETS); do \
echo "Running tests with features: $$features"; \
($(TEST) --features=$$features); \
done

docs:
@for features in $(FEATURE_SETS); do \
echo "Documenting redstone with features: $$features"; \
(rm -rf ./target/doc && $(DOC) --features=$$features && mkdir -p ../target/rust-docs/redstone && cp -r ../target/doc ../target/rust-docs/redstone/$$features); \
done

coverage:
cargo install grcov --version=0.5.15
CARGO_INCREMENTAL=0 \
RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" \
RUSTDOCFLAGS="-Cpanic=abort" cargo build --features="crypto_k256"
CARGO_INCREMENTAL=0 \
RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" \
RUSTDOCFLAGS="-Cpanic=abort" $(TEST) --features="crypto_k256"

clippy: prepare
@for features in $(FEATURE_SETS); do \
($(CLIPPY) --all-targets --features=$$features -- -D warnings); \
done

check-lint: clippy
cargo fmt -- --check

lint: clippy
cargo fmt
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# rust-sdk
# RedStone

## See autogenerated docs for:

1. [`redstone` crate with `crypto_secp256k1` and `network_casper`](https://redstone-docs-git-casper-redstone-finance.vercel.app/rust/casper/redstone/crypto_secp256k1,network_casper/redstone/index.html)
features (the base version for [contracts](../contracts/README.md))
1 change: 1 addition & 0 deletions sample-data/payload.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
45544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003709f35687018d8378f9800000002000000139c69986b10617291f07fe420bd9991de3aca4dd4c1a7e77f075aebbe56221a846649b1083773c945ae89c0074331037eba52b7f57dc634426099a7ec63f45711b45544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003709f2ff20018d8378f980000000200000017dcdb6561923ebea544f9cd51aa32a1d37eba0960bfa9121cef9cdedd3135c88009e6c2e761492d14a4674ff3958a3f1c7b3e7c14b9bc08e107d8bab0a8f5a3d1c45544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003709ed5659018d8378f980000000200000015687773e177cd39b410c06f25bd61e52abe8d8f8dffba822168eb06d9ac86fb947d83779cb9437f74e21359ed09568284da76d92351ee9a80df27ea4e6c8e5cc1b45544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003709ebaa55018d8378f98000000020000001f321c0ca3703cad49fe373d98a4cceba1fad5172fdb0adb47877277328a869867d1d10c8e69e762cf6035983c0504423b2389bd24638c910c16467c4b9c4c4521b455448000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037094b8cc2018d8378f98000000020000001c9fd2f5f1f01612a41c9337e3c1939050284dcc72b091cd4503d75913a38b7773d3bec57a07d95468b29c42504b2bec4546b655a33adbc062eeeeddf275986bb1c4254430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e7316ea122018d8378f9800000002000000156588a1f87423c2675eb6f780b73649beb98ee062fb732ef1521e1b3e6ed366e7c584eab98215a7fb8b0cc136fde92f0f8f76fb49dd8534f44fbaab00b7a7be41b4254430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e73180bb79018d8378f98000000020000001d14781f831df36e6529deb617d17887994092ac5ea7e0ea9c2f12ab84fc6a2952f48411f309aad4b16cc698a3c6dd60a5c998771fca4d08397d84948e6daff721c4254430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e730b34178018d8378f980000000200000017f092d8108b516db8b163b382eb9d828848fe636bb433c8d0420e2451c6a960f5b1c224394b1cba681658c219b208fca2d06d90fa943e625772a3528c5d857d81c4254430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e730580d76018d8378f9800000002000000159dda68806f9c64b9c93c2bb21d079cf3f1d07cae51da8173f9552fa2bcd3cf73758c0e46b1eecc46d12f1876cfbda3360cb1a25a11a38ef21c5f9e539c27c981b4254430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e7318b8ad3018d8378f98000000020000001b4f2c86c5a1300c4f001a6878525afc23f9fe1aefbab7861439fd613f839d04a39caf6a037d4bb3996b90e98c2d2d850691eefe3f67e502f6278aa0a652c2e8a1b415641580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cbc887e2018d8378f980000000200000011001f8291b8b722e939f5aea0a436375d451d79ff5c1e248d2857f8fe341db007d8692a67c0bcf777f624c06da5b16ce30ec03b2fcbd301a3daec708eab215961c415641580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cbc8855a018d8378f980000000200000019ae0e0a4ceb48265b808e42ad2463984f6b4262dacbe34d6d085734177682d7474effb1cc22327b9f4ed31862c8d19868101b6dbed7f0d9579e22824cbe420421b415641580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cbc85b72018d8378f980000000200000017f05693fd3b0b4cae6c9c55507ae69a1682f63c2854215198400549777c7a4fa13d632296e7db0f24de80a4548bc9dfec8c4b82a954294f7cb8295e88006164b1b415641580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cbc84f11018d8378f98000000020000001722670ba61759fd47cb5eeceeda2c69695c2d3a633784af475d9a5c682d03f74250d4de708849ae0fc6eb6d043fa27be75357ace22aef071705d5f1bcbbac7f51b415641580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cbc8878f018d8378f98000000020000001d31cf023168e23772053a48dfbade05535bd2348d6a5e4b42516206037adbe715e8f272703763169a17b65073b88ab5a4201e514d8436f6e169114cf53c709521b000f000000000002ed57011e0000
Loading

0 comments on commit 2ed3cb0

Please sign in to comment.