From b1349fb09108b3988ef793e183617cbff5dbb07f Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Tue, 20 Feb 2024 14:47:41 -0600 Subject: [PATCH] Contract stubs --- .gitignore | 3 ++ Cargo.toml | 16 ++++++++++ Makefile | 49 +++++++++++++++++++++++++++++ availability/Cargo.toml | 15 +++++++++ availability/src/entry_points.rs | 4 +++ availability/src/main.rs | 23 ++++++++++++++ rust-toolchain | 1 + validation-pool/Cargo.toml | 17 ++++++++++ validation-pool/src/entry_points.rs | 4 +++ validation-pool/src/main.rs | 23 ++++++++++++++ work-1/Cargo.toml | 15 +++++++++ work-1/README.md | 0 work-1/rust-toolchain | 1 + work-1/src/entry_points.rs | 4 +++ work-1/src/main.rs | 23 ++++++++++++++ 15 files changed, 198 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 Makefile create mode 100644 availability/Cargo.toml create mode 100644 availability/src/entry_points.rs create mode 100644 availability/src/main.rs create mode 100644 rust-toolchain create mode 100644 validation-pool/Cargo.toml create mode 100644 validation-pool/src/entry_points.rs create mode 100644 validation-pool/src/main.rs create mode 100644 work-1/Cargo.toml create mode 100644 work-1/README.md create mode 100644 work-1/rust-toolchain create mode 100644 work-1/src/entry_points.rs create mode 100644 work-1/src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38e0b43 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +Cargo.lock +tests/wasm +target/ \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..089d9bb --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,16 @@ +[workspace] +members = [ + "validation-pool", + "availability", + "work-1", +] +default-members = [ + "validation-pool", + "availability", + "work-1", +] +resolver = "2" + +[profile.release] +codegen-units = 1 +lto = true diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3dfc07e --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +PINNED_TOOLCHAIN := $(shell cat rust-toolchain) + +prepare: + rustup target add wasm32-unknown-unknown + rustup component add clippy --toolchain ${PINNED_TOOLCHAIN} + rustup component add rustfmt --toolchain ${PINNED_TOOLCHAIN} + +.PHONY: build-contract +build-contract: + cargo build --release --target wasm32-unknown-unknown -p validation-pool + cargo build --release --target wasm32-unknown-unknown -p availability + cargo build --release --target wasm32-unknown-unknown -p work-1 + wasm-strip target/wasm32-unknown-unknown/release/validation_pool.wasm + wasm-strip target/wasm32-unknown-unknown/release/availability.wasm + wasm-strip target/wasm32-unknown-unknown/release/work_1.wasm + +setup-test: build-contract + mkdir -p tests/wasm + cp ./target/wasm32-unknown-unknown/release/validation_pool.wasm tests/wasm + cp ./target/wasm32-unknown-unknown/release/availability.wasm tests/wasm + cp ./target/wasm32-unknown-unknown/release/work_1.wasm tests/wasm + +test: setup-test + cd tests && cargo test + +clippy: + cd validation-pool && cargo clippy --all-targets -- -D warnings + cd availability && cargo clippy --all-targets -- -D warnings + cd work-1 && cargo clippy --all-targets -- -D warnings + cd tests && cargo clippy --all-targets -- -D warnings + +check-lint: clippy + cd validation_pool && cargo fmt -- --check + cd availability && cargo fmt -- --check + cd work-1 && cargo fmt -- --check + cd tests && cargo fmt -- --check + +lint: clippy + cd validation-pool && cargo fmt + cd availability && cargo fmt + cd work-1 && cargo fmt + cd tests && cargo fmt + +clean: + cd validation-pool && cargo clean + cd availability && cargo clean + cd work-1 && cargo clean + cd tests && cargo clean + rm -rf tests/wasm diff --git a/availability/Cargo.toml b/availability/Cargo.toml new file mode 100644 index 0000000..64e0801 --- /dev/null +++ b/availability/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "availability" +version = "0.1.0" +edition = "2021" + +[dependencies] +casper-contract = "4.0.0" +casper-types = "4.0.1" + +[[bin]] +name = "availability" +path = "src/main.rs" +bench = false +doctest = false +test = false diff --git a/availability/src/entry_points.rs b/availability/src/entry_points.rs new file mode 100644 index 0000000..bced550 --- /dev/null +++ b/availability/src/entry_points.rs @@ -0,0 +1,4 @@ +// Entry points +// Entry point: Stake availability toward one or more work contracts +// Entry point: Assign work +// Entry point: Get assigned work \ No newline at end of file diff --git a/availability/src/main.rs b/availability/src/main.rs new file mode 100644 index 0000000..b57ef6e --- /dev/null +++ b/availability/src/main.rs @@ -0,0 +1,23 @@ +#![no_std] +#![no_main] + +pub mod entry_points; + +#[no_mangle] +pub extern "C" fn stake_availability() { +} + +#[no_mangle] +pub extern "C" fn assign_work() { +} + +#[no_mangle] +pub extern "C" fn get_assigned_work() { +} + +use core::panic::PanicInfo; + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop {} +} \ No newline at end of file diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..591a4ea --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly-2023-01-09 \ No newline at end of file diff --git a/validation-pool/Cargo.toml b/validation-pool/Cargo.toml new file mode 100644 index 0000000..21a2876 --- /dev/null +++ b/validation-pool/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "validation-pool" +version = "0.1.0" +edition = "2021" + +[dependencies] +casper-contract = "4.0.0" +casper-types = "4.0.1" + +[[bin]] +name = "validation_pool" +path = "src/main.rs" +bench = false +doctest = false +test = false + + diff --git a/validation-pool/src/entry_points.rs b/validation-pool/src/entry_points.rs new file mode 100644 index 0000000..e3510a1 --- /dev/null +++ b/validation-pool/src/entry_points.rs @@ -0,0 +1,4 @@ +// Entry points +// Entry point: Initiate Validation Pool +// Entry point: Stake REP in Validation Pool +// Entry point: Evaluate outcome of Validation Pool diff --git a/validation-pool/src/main.rs b/validation-pool/src/main.rs new file mode 100644 index 0000000..27332bd --- /dev/null +++ b/validation-pool/src/main.rs @@ -0,0 +1,23 @@ +#![no_std] +#![no_main] + +pub mod entry_points; + +#[no_mangle] +pub extern "C" fn initiate_validation_pool() { +} + +#[no_mangle] +pub extern "C" fn stake() { +} + +#[no_mangle] +pub extern "C" fn evaluate_outcome() { +} + +use core::panic::PanicInfo; + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop {} +} \ No newline at end of file diff --git a/work-1/Cargo.toml b/work-1/Cargo.toml new file mode 100644 index 0000000..f69e59a --- /dev/null +++ b/work-1/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "work-1" +version = "0.1.0" +edition = "2021" + +[dependencies] +casper-contract = "4.0.0" +casper-types = "4.0.1" + +[[bin]] +name = "work_1" +path = "src/main.rs" +bench = false +doctest = false +test = false diff --git a/work-1/README.md b/work-1/README.md new file mode 100644 index 0000000..e69de29 diff --git a/work-1/rust-toolchain b/work-1/rust-toolchain new file mode 100644 index 0000000..2bf5ad0 --- /dev/null +++ b/work-1/rust-toolchain @@ -0,0 +1 @@ +stable diff --git a/work-1/src/entry_points.rs b/work-1/src/entry_points.rs new file mode 100644 index 0000000..0db1f46 --- /dev/null +++ b/work-1/src/entry_points.rs @@ -0,0 +1,4 @@ +// Entry points +// Entry point: Customer sends CSPR to request work +// Entry point: Worker submits work evidence +// Entry point: Customer submits satisfied/unsatisfied \ No newline at end of file diff --git a/work-1/src/main.rs b/work-1/src/main.rs new file mode 100644 index 0000000..c4d27f1 --- /dev/null +++ b/work-1/src/main.rs @@ -0,0 +1,23 @@ +#![no_std] +#![no_main] + +pub mod entry_points; + +#[no_mangle] +pub extern "C" fn request_work() { +} + +#[no_mangle] +pub extern "C" fn submit_work_evidence() { +} + +#[no_mangle] +pub extern "C" fn submit_customer_satisfaction() { +} + +use core::panic::PanicInfo; + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop {} +} \ No newline at end of file