From eaa9fbc560bbbdfbadf712fff1bf68acce26c128 Mon Sep 17 00:00:00 2001 From: peg Date: Sat, 6 Jan 2024 23:52:56 +0100 Subject: [PATCH] Rename to programs - and prefix internal crates with `entropy-programs-` (#52) * Rename to programs * Missed name changes --------- Co-authored-by: jakehemmerle --- CONTRIBUTING.md | 2 +- Cargo.toml | 12 +++++----- README.md | 1 + acl/Cargo.toml | 14 +++++------ acl/README.md | 2 +- acl/src/lib.rs | 6 ++--- acl/src/tests.rs | 20 ++++++++++++---- constraints/Cargo.toml | 23 ------------------- constraints/README.md | 3 --- core/Cargo.toml | 10 ++++---- core/README.md | 6 ++--- core/src/lib.rs | 6 ++--- core/src/{constraints.rs => programs.rs} | 14 +++++------ evm/Cargo.toml | 9 +++----- evm/README.md | 4 ++-- evm/src/lib.rs | 6 +++-- examples/barebones-with-auxilary/Cargo.toml | 8 +++---- examples/barebones-with-auxilary/src/lib.rs | 4 ++-- examples/barebones/Cargo.toml | 6 ++--- examples/barebones/src/lib.rs | 6 ++--- examples/basic-transaction/Cargo.toml | 10 ++++---- examples/basic-transaction/src/lib.rs | 6 ++--- examples/custom-hash/Cargo.toml | 6 ++--- examples/custom-hash/src/lib.rs | 6 +++-- examples/infinite-loop/Cargo.toml | 2 +- examples/infinite-loop/src/lib.rs | 2 +- examples/private-acl/Cargo.toml | 4 ++-- examples/private-acl/src/lib.rs | 9 ++++---- .../risczero-zkvm-verification/Cargo.toml | 8 +++---- .../json/core/Cargo.toml | 2 +- .../json/methods/Cargo.toml | 2 +- .../json/methods/guest/Cargo.toml | 2 +- .../risczero-zkvm-verification/src/lib.rs | 4 ++-- examples/siwe/Cargo.toml | 6 ++--- examples/siwe/src/lib.rs | 7 ++++-- programs/Cargo.toml | 23 +++++++++++++++++++ programs/README.md | 3 +++ {constraints => programs}/src/lib.rs | 12 +++++----- runtime/Cargo.toml | 9 +++----- runtime/README.md | 4 ++-- runtime/tests/runtime.rs | 3 +-- 41 files changed, 146 insertions(+), 146 deletions(-) delete mode 100644 constraints/Cargo.toml delete mode 100644 constraints/README.md rename core/src/{constraints.rs => programs.rs} (70%) create mode 100644 programs/Cargo.toml create mode 100644 programs/README.md rename {constraints => programs}/src/lib.rs (58%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7be08e0..e97384c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,4 +4,4 @@ Thanks for contributing to the project! Please consider the following in PRs. ## Conventions -Packages should use the `ec` prefix, which stands for "Entropy Constraints". For example, `ec-core` is the "Entropy Constraints Core" package, and `ec-acl` is the "Entropy Constraints Access Control List" package. +Packages should use the `entropy-programs` prefix, which stands for "Entropy Programs". For example, `entropy-programs-core` is the "Entropy Programs Core" package, and `entropy-programs-acl` is the "Entropy Programs Access Control List" package. diff --git a/Cargo.toml b/Cargo.toml index e603ce2..e2ed4d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,13 @@ [workspace] -members = ["constraints", "core", "acl", "evm", "runtime", "examples/*"] +members = ["programs", "core", "acl", "evm", "runtime", "examples/*"] resolver = "2" [workspace.dependencies] -ec-constraints = { path = "constraints", default-features = false } -ec-core = { path = "core", default-features = false } -ec-acl = { path = "acl", default-features = false } -ec-evm = { path = "evm", default-features = false } -ec-runtime = { path = "runtime", default-features = false } +entropy-programs = { path = "programs", default-features = false } +entropy-programs-core = { path = "core", default-features = false } +entropy-programs-acl = { path = "acl", default-features = false } +entropy-programs-evm = { path = "evm", default-features = false } +entropy-programs-runtime = { path = "runtime", default-features = false } wit-bindgen = { version = "0.7.0", default_features = false } risc0-zkvm = { git = "https://github.com/risc0/risc0", tag = "v0.18.0", default-features = false } risc0-build = { git = "https://github.com/risc0/risc0", tag = "v0.18.0" } diff --git a/README.md b/README.md index a606f7e..09e1fd7 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This repository contains libraries, toolchains, utilities, and specifications fo ### Build Requirements Besides the latest stable Rust toolchain, you will also need to install: + - [cargo component v0.2.0](https://github.com/bytecodealliance/cargo-component#installation), a Cargo extension for building Wasm components. - [wasm-tools](https://github.com/bytecodealliance/wasm-tools#installation), to be used by `cargo-component`. diff --git a/acl/Cargo.toml b/acl/Cargo.toml index b5b0e8a..0410562 100644 --- a/acl/Cargo.toml +++ b/acl/Cargo.toml @@ -1,17 +1,15 @@ [package] -name = "ec-acl" +name = "entropy-programs-acl" version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "AGPL-3.0-or-later" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -ec-core = { path = "../core", default-features = false } -ec-evm = { path = "../evm", default-features = false, optional = true } +entropy-programs-core = { path = "../core", default-features = false } +entropy-programs-evm = { path = "../evm", default-features = false, optional = true } serde = { version = "1.0", default-features = false } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ @@ -21,5 +19,5 @@ scale-info = { version = "2.1.0", default-features = false } [features] default = ["std"] -evm = ["dep:ec-evm"] -std = ["ec-core/std", "codec/std", "evm"] +evm = ["dep:entropy-programs-evm"] +std = ["entropy-programs-core/std", "codec/std", "evm"] diff --git a/acl/README.md b/acl/README.md index 92860d3..5fe9e45 100644 --- a/acl/README.md +++ b/acl/README.md @@ -1,3 +1,3 @@ -# `evm-acl` +# `entropy-programs-acl` Provides access control list functionality over generic architectures. diff --git a/acl/src/lib.rs b/acl/src/lib.rs index ba5d810..a17ce79 100644 --- a/acl/src/lib.rs +++ b/acl/src/lib.rs @@ -5,10 +5,10 @@ use core::fmt::Debug; use codec::MaxEncodedLen; use codec::{Decode, Encode}; -pub use ec_core::{Architecture, Error as CoreError, SatisfiableForArchitecture}; +pub use entropy_programs_core::{Architecture, Error as CoreError, SatisfiableForArchitecture}; #[cfg(feature = "evm")] -pub use ec_evm::{Evm, NameOrAddress, H160}; +pub use entropy_programs_evm::{Evm, NameOrAddress, H160}; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; @@ -65,7 +65,7 @@ impl Default for Acl { } // TODO This needs to be generic over any architecture (use GetRecipient and GetSender traits) -// TODO Move to `ec-evm` crate? +// TODO Move to `entropy-programs-evm` crate? #[allow(clippy::needless_collect)] #[cfg(feature = "evm")] impl SatisfiableForArchitecture for Acl<::AddressRaw> { diff --git a/acl/src/tests.rs b/acl/src/tests.rs index 6c6dd01..fe33c1e 100644 --- a/acl/src/tests.rs +++ b/acl/src/tests.rs @@ -1,6 +1,6 @@ #![cfg(test)] -use ec_core::{Acl, AclKind}; +use entropy_programs_core::{Acl, AclKind}; use ethers_core::types::{NameOrAddress, TransactionRequest, H160}; use crate::Evaluate; @@ -59,11 +59,21 @@ fn test_acl_functions_properly() { }; // should only block whitelisted and null recipient txs - assert!(denylisted_acl.clone().is_satisfied_by(to_address_2_tx.clone()).is_ok()); - assert!(denylisted_acl.clone().is_satisfied_by(to_address_3_tx.clone()).is_ok()); + assert!(denylisted_acl + .clone() + .is_satisfied_by(to_address_2_tx.clone()) + .is_ok()); + assert!(denylisted_acl + .clone() + .is_satisfied_by(to_address_3_tx.clone()) + .is_ok()); - assert!(denylisted_acl.is_satisfied_by(to_address_1_tx.clone()).is_err()); - assert!(allowlisted_acl.is_satisfied_by(to_null_recipient_tx.clone()).is_err()); + assert!(denylisted_acl + .is_satisfied_by(to_address_1_tx.clone()) + .is_err()); + assert!(allowlisted_acl + .is_satisfied_by(to_null_recipient_tx.clone()) + .is_err()); let allowlisted_acl_with_null_recipient = Acl::<[u8; 20]> { addresses: vec![evm_address_1], diff --git a/constraints/Cargo.toml b/constraints/Cargo.toml deleted file mode 100644 index 30fb093..0000000 --- a/constraints/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "ec-constraints" -version = "0.1.0" -authors = ["Entropy Cryptography "] -homepage = "https://entropy.xyz/" -license = "AGPL-3.0-or-later" -repository = "https://github.com/entropyxyz/constraints" -edition = "2021" - -# [lib] -# crate-type = ["cdylib"] - -[dependencies] -ec-acl = { path = "../acl", default-features = false, features = ["evm"] } -ec-evm = { path = "../evm", default-features = false } -ec-core = { path = "../core", default-features = false } - -[dev-dependencies] -# ec-runtime = { path = "../runtime", default-features = false } - -[features] -default = ["std"] -std = ["ec-acl/std", "ec-evm/std"] diff --git a/constraints/README.md b/constraints/README.md deleted file mode 100644 index bfe9a44..0000000 --- a/constraints/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `ec-constraints` - -This is the main library for writing constraints. Currently, it is boilerplate and will re-export all constraints and architectures. diff --git a/core/Cargo.toml b/core/Cargo.toml index 77cb57f..f51d1cb 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,14 +1,12 @@ [package] -name = "ec-core" +name = "entropy-programs-core" version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "AGPL-3.0-or-later" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] getrandom = { version = "0.2", default-features = false, features = ["custom"] } witgen = "0.15.0" @@ -21,8 +19,8 @@ wit-bindgen = { version = "0.7.0" } # wasmtime ={ version = "10.0.1", default-features = false, features = ["component-model"] } [dev-dependencies] -ec-acl = { path = "../acl", default-features = false, features = ["evm"] } -ec-evm = { path = "../evm", default-features = false } +entropy-programs-acl = { path = "../acl", default-features = false, features = ["evm"] } +entropy-programs-evm = { path = "../evm", default-features = false } [features] default = ["std"] diff --git a/core/README.md b/core/README.md index 9f34600..391e499 100644 --- a/core/README.md +++ b/core/README.md @@ -1,10 +1,10 @@ -# `ec-core` +# `entropy-programs-core` -This contains core traits and types for writing modular constraints code, including constraints, runtimes, architectures (for writing architecture-agnostic constraints and dynamic parsing) and signature-request interfaces. +This contains core traits and types for writing modular programs code, including programs, runtimes, architectures (for writing architecture-agnostic programs and dynamic parsing) and signature-request interfaces. ## `.wit` User applications can generate and use the required WITs in two ways: 1. `cargo component` - prefered, since this doesn't require the user to build the wasm-component manually; -2. reexported from `ec-core` via `wit-bindgen` - this is a fallback for when `cargo component` is not available. +2. reexported from `entropy-programs-core` via `wit-bindgen` - this is a fallback for when `cargo component` is not available. diff --git a/core/src/lib.rs b/core/src/lib.rs index af34833..73e54e7 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -1,4 +1,4 @@ -//! This supports core traits and types for supporting new architectures and constraints, and interfacing with them. +//! This supports core traits and types for supporting new architectures and programs, and interfacing with them. /// See the [`wit-bindgen` Rust guest example](https://github.com/bytecodealliance/wit-bindgen#guest-rust) for information on how to use this. pub mod bindgen { @@ -11,10 +11,10 @@ pub mod bindgen { pub use bindgen::Error; -pub mod constraints; +pub mod programs; pub use architecture::*; -pub use constraints::*; +pub use programs::*; /// Each transaction-like architecture should implement these. pub mod architecture { diff --git a/core/src/constraints.rs b/core/src/programs.rs similarity index 70% rename from core/src/constraints.rs rename to core/src/programs.rs index c50fd78..5833c86 100644 --- a/core/src/constraints.rs +++ b/core/src/programs.rs @@ -1,23 +1,23 @@ -//! Contains traits that constraints should implement, including Architecture-agnostic constraints and generic constraints. +//! Contains traits that programs should implement, including Architecture-agnostic programs and generic programs. //! -//! For runtime and binary size optimizations, constraint construction should be done at compile time by using `const` types, if possible. This can be done by using `const` generic parameters, +//! For runtime and binary size optimizations, program construction should be done at compile time by using `const` types, if possible. This can be done by using `const` generic parameters, //! or by using a `const` builder. Both methods are described nicely here: https://wapl.es/rust/2022/07/03/const-builder-pattern.html use crate::architecture::Architecture; use crate::bindgen::Error; -/// Constraints on binary (or other unserialized) data must implement this. This is the most barebones trait for constraints. +/// Programs using binary (or other unserialized) data must implement this. This is the most barebones trait for programs. pub trait Satisfiable { /// Indicates that the data satisfies the constraint. fn is_satisfied_by(self, data: &[u8]) -> Result<(), Error>; } -/// Any constraint on transaction-like/architecture-agnostic signature requests must implement this. +/// Any program using transaction-like/architecture-agnostic signature requests must implement this. /// -/// For example, a constraint that checks that the recipient is not a blacklisted address would implement this trait for EVM, and would be similar to this: +/// For example, a program that checks that the recipient is not a blacklisted address would implement this trait for EVM, and would be similar to this: /// ``` -/// use ec_acl::*; -/// use ec_evm::*; +/// use entropy_programs_acl::*; +/// use entropy_programs_evm::*; /// /// let non_blacklisted_addr: [u8; 20] = [1u8; 20]; /// let blacklisted_addr_1: [u8; 20] = [2u8; 20]; diff --git a/evm/Cargo.toml b/evm/Cargo.toml index 4ab804c..99c7406 100644 --- a/evm/Cargo.toml +++ b/evm/Cargo.toml @@ -1,16 +1,14 @@ [package] -name = "ec-evm" +name = "entropy-programs-evm" version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "AGPL-3.0-or-later" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -ec-core = { path = "../core" } +entropy-programs-core = { path = "../core" } # EVM ethers-core = { version = "2.0.6", default-features = false } @@ -24,7 +22,6 @@ primitive-types = { version = "0.12.1", default-features = false, features = [ serde = { version = "1.0", default-features = false } # ethereum = { version = "0.14.0", default-features = false, features = ["with-serde"]} - [features] default = [] # std = ["rlp/std", "primitive-types/std", "getrandom", "getrandom/std", "ethereum/std"] diff --git a/evm/README.md b/evm/README.md index 15b4b10..a8f5f1b 100644 --- a/evm/README.md +++ b/evm/README.md @@ -1,3 +1,3 @@ -# `ec-evm` +# `entropy-programs-evm` -Provides the EVM `Architecture`, adding EVM support to generic constraints (not specific to Ethereum Mainnet). +Provides the EVM `Architecture`, adding EVM support to generic programs (not specific to Ethereum Mainnet). diff --git a/evm/src/lib.rs b/evm/src/lib.rs index 9cdfeb4..f03d694 100644 --- a/evm/src/lib.rs +++ b/evm/src/lib.rs @@ -1,10 +1,12 @@ -//! This module contains the EVM architecture and its associated types. Since it implements Architecture, constraints written around the Architecture trait can be used with EVM. +//! This module contains the EVM architecture and its associated types. Since it implements Architecture, programs written around the Architecture trait can be used with EVM. extern crate alloc; use alloc::string::String; -use ec_core::{Architecture, Error as CoreError, GetReceiver, GetSender, Parse, TryParse}; +use entropy_programs_core::{ + Architecture, Error as CoreError, GetReceiver, GetSender, Parse, TryParse, +}; pub use ethers_core::types::transaction::request::TransactionRequest as EvmTransactionRequest; pub use ethers_core::types::{NameOrAddress, H160}; use rlp::Rlp; diff --git a/examples/barebones-with-auxilary/Cargo.toml b/examples/barebones-with-auxilary/Cargo.toml index 785e0f0..aa9216a 100644 --- a/examples/barebones-with-auxilary/Cargo.toml +++ b/examples/barebones-with-auxilary/Cargo.toml @@ -4,17 +4,15 @@ version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "Unlicense" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -# This is required to compile constraints to a wasm module +# This is required to compile programs to a wasm module [lib] crate-type = ["cdylib"] [dependencies] -ec-core = { workspace = true } +entropy-programs-core = { workspace = true } # These are used by `cargo component` [package.metadata.component] diff --git a/examples/barebones-with-auxilary/src/lib.rs b/examples/barebones-with-auxilary/src/lib.rs index 1242f27..20db224 100644 --- a/examples/barebones-with-auxilary/src/lib.rs +++ b/examples/barebones-with-auxilary/src/lib.rs @@ -6,7 +6,7 @@ extern crate alloc; use alloc::{string::ToString, vec::Vec}; -use ec_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; +use entropy_programs_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; // TODO confirm this isn't an issue for audit register_custom_getrandom!(always_fail); @@ -22,7 +22,7 @@ impl Program for BarebonesWithAuxilary { auxilary_data, } = signature_request; - // our constraint just checks that the length of the signature request is greater than 10 + // our program just checks that the length of the signature request is greater than 10 if message.len() < 10 { return Err(Error::Evaluation( "Length of message is too short.".to_string(), diff --git a/examples/barebones/Cargo.toml b/examples/barebones/Cargo.toml index adec509..11e1da8 100644 --- a/examples/barebones/Cargo.toml +++ b/examples/barebones/Cargo.toml @@ -4,17 +4,17 @@ version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "Unlicense" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -# This is required to compile constraints to a wasm module +# This is required to compile programs to a wasm module [lib] crate-type = ["cdylib"] [dependencies] -ec-core = { workspace = true } +entropy-programs-core = { workspace = true } # These are used by `cargo component` [package.metadata.component] diff --git a/examples/barebones/src/lib.rs b/examples/barebones/src/lib.rs index e51a6a5..c36fbf2 100644 --- a/examples/barebones/src/lib.rs +++ b/examples/barebones/src/lib.rs @@ -1,4 +1,4 @@ -//! This example shows how to write a contrieved and basic constraint: checking the length of the data to be signed. +//! This example shows how to write a contrieved and basic program: checking the length of the data to be signed. #![no_std] @@ -6,7 +6,7 @@ extern crate alloc; use alloc::{string::ToString, vec::Vec}; -use ec_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; +use entropy_programs_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; // TODO confirm this isn't an issue for audit register_custom_getrandom!(always_fail); @@ -19,7 +19,7 @@ impl Program for BarebonesProgram { fn evaluate(signature_request: SignatureRequest) -> Result<(), Error> { let message: Vec = signature_request.message; - // our constraint just checks that the length of the message is greater than 10 + // our program just checks that the length of the message is greater than 10 if message.len() < 10 { return Err(Error::Evaluation( "Length of message is too short.".to_string(), diff --git a/examples/basic-transaction/Cargo.toml b/examples/basic-transaction/Cargo.toml index 899faf8..aa45907 100644 --- a/examples/basic-transaction/Cargo.toml +++ b/examples/basic-transaction/Cargo.toml @@ -4,18 +4,16 @@ version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "Unlicense" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -# This is required to compile constraints to a wasm module +# This is required to compile programs to a wasm module [lib] crate-type = ["cdylib"] [dependencies] -ec-constraints = { workspace = true } -# TODO move hex parsing into the ec-evm crate +entropy-programs = { workspace = true } +# TODO move hex parsing into the entropy-programs-evm crate hex = { version = "0.4.3", default-features = false } # These are used by `cargo component` diff --git a/examples/basic-transaction/src/lib.rs b/examples/basic-transaction/src/lib.rs index 41ae0ca..e24933c 100644 --- a/examples/basic-transaction/src/lib.rs +++ b/examples/basic-transaction/src/lib.rs @@ -2,9 +2,9 @@ extern crate alloc; -use ec_constraints::{ - constraints::acl::*, +use entropy_programs::{ core::{bindgen::*, export_program, prelude::*, SatisfiableForArchitecture, TryParse}, + programs::acl::*, }; use alloc::{vec, vec::Vec}; @@ -15,7 +15,7 @@ pub struct BasicTransaction; register_custom_getrandom!(always_fail); impl Program for BasicTransaction { - /// This is the function that the constraints engine will runtime esecute. signature_request is the preimage of the curve element to be + /// This is the function that the programs engine will runtime esecute. signature_request is the preimage of the curve element to be /// signed, eg. RLP-serialized Ethereum transaction request, raw x86_64 executable, etc. // #[no_mangle] fn evaluate(state: SignatureRequest) -> Result<(), CoreError> { diff --git a/examples/custom-hash/Cargo.toml b/examples/custom-hash/Cargo.toml index 8f755e2..4898578 100644 --- a/examples/custom-hash/Cargo.toml +++ b/examples/custom-hash/Cargo.toml @@ -3,15 +3,13 @@ name = "example-custom-hash" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -# This is required to compile constraints to a wasm module +# This is required to compile programs to a wasm module [lib] crate-type = ["cdylib"] [dependencies] blake3 = "1.5.0" -ec-core = { workspace = true } +entropy-programs-core = { workspace = true } # These are used by `cargo component` [package.metadata.component] diff --git a/examples/custom-hash/src/lib.rs b/examples/custom-hash/src/lib.rs index d69fea2..eeb686c 100644 --- a/examples/custom-hash/src/lib.rs +++ b/examples/custom-hash/src/lib.rs @@ -6,7 +6,7 @@ extern crate alloc; use alloc::{string::ToString, vec::Vec}; -use ec_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; +use entropy_programs_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; use blake3; @@ -18,7 +18,9 @@ pub struct CustomHashExample; impl Program for CustomHashExample { fn evaluate(signature_request: SignatureRequest) -> Result<(), Error> { if signature_request.message.len() < 1 { - return Err(Error::Evaluation("You need to give me SOME data to sign!".to_string())); + return Err(Error::Evaluation( + "You need to give me SOME data to sign!".to_string(), + )); } // By immediately returning Ok, we sign any data that is passed to us. Ok(()) diff --git a/examples/infinite-loop/Cargo.toml b/examples/infinite-loop/Cargo.toml index 040f2a3..5a880aa 100644 --- a/examples/infinite-loop/Cargo.toml +++ b/examples/infinite-loop/Cargo.toml @@ -14,7 +14,7 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -ec-core = { workspace = true } +entropy-programs-core = { workspace = true } # These are used by `cargo component` [package.metadata.component] diff --git a/examples/infinite-loop/src/lib.rs b/examples/infinite-loop/src/lib.rs index 54468a1..baabd51 100644 --- a/examples/infinite-loop/src/lib.rs +++ b/examples/infinite-loop/src/lib.rs @@ -2,7 +2,7 @@ extern crate alloc; use alloc::vec::Vec; -use ec_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; +use entropy_programs_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; // TODO confirm this isn't an issue for audit register_custom_getrandom!(always_fail); diff --git a/examples/private-acl/Cargo.toml b/examples/private-acl/Cargo.toml index b307443..19ae1bd 100644 --- a/examples/private-acl/Cargo.toml +++ b/examples/private-acl/Cargo.toml @@ -3,13 +3,13 @@ name = "example-private-acl" version = "0.1.0" edition = "2021" -# This is required to compile constraints to a wasm module +# This is required to compile programs to a wasm module [lib] crate-type = ["cdylib"] [dependencies] blake2 = "0.10.6" -ec-constraints = { workspace = true } +entropy-programs = { workspace = true } [build-dependencies] hex = "0.4.3" diff --git a/examples/private-acl/src/lib.rs b/examples/private-acl/src/lib.rs index a516758..c0f5bf6 100644 --- a/examples/private-acl/src/lib.rs +++ b/examples/private-acl/src/lib.rs @@ -8,10 +8,10 @@ extern crate alloc; use alloc::string::ToString; use alloc::vec::Vec; use blake2::{Blake2s256, Digest}; -use ec_constraints::{ +use entropy_programs::{ arch::evm::NameOrAddress, - constraints::acl::*, core::{bindgen::*, export_program, prelude::*, TryParse}, + programs::acl::*, }; pub struct PrivateTransactionAcl; @@ -26,8 +26,9 @@ impl Program for PrivateTransactionAcl { // #[no_mangle] fn evaluate(signature_request: SignatureRequest) -> Result<(), CoreError> { // parse the raw tx into some type - let parsed_tx = - ::TransactionRequest::try_parse(signature_request.message.as_slice())?; + let parsed_tx = ::TransactionRequest::try_parse( + signature_request.message.as_slice(), + )?; let name_or_address: NameOrAddress = parsed_tx.to.ok_or(Error::Evaluation( "No recipient given in transaction".to_string(), diff --git a/examples/risczero-zkvm-verification/Cargo.toml b/examples/risczero-zkvm-verification/Cargo.toml index a3cad5f..3d31b3c 100644 --- a/examples/risczero-zkvm-verification/Cargo.toml +++ b/examples/risczero-zkvm-verification/Cargo.toml @@ -4,17 +4,15 @@ version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "Apache-2.0" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -# This is required to compile constraints to a wasm module +# This is required to compile programs to a wasm module [lib] crate-type = ["cdylib"] [dependencies] -ec-core = { workspace = true } +entropy-programs-core = { workspace = true } serde = { version = "1.0", default-features = false, features = ["derive"] } bincode = "1.3.3" # json-example = { path = "json" } diff --git a/examples/risczero-zkvm-verification/json/core/Cargo.toml b/examples/risczero-zkvm-verification/json/core/Cargo.toml index 5c8eda6..eecfa00 100644 --- a/examples/risczero-zkvm-verification/json/core/Cargo.toml +++ b/examples/risczero-zkvm-verification/json/core/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "Apache-2.0" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" [dependencies] diff --git a/examples/risczero-zkvm-verification/json/methods/Cargo.toml b/examples/risczero-zkvm-verification/json/methods/Cargo.toml index d9c150c..d995c83 100644 --- a/examples/risczero-zkvm-verification/json/methods/Cargo.toml +++ b/examples/risczero-zkvm-verification/json/methods/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "Apache-2.0" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" [build-dependencies] diff --git a/examples/risczero-zkvm-verification/json/methods/guest/Cargo.toml b/examples/risczero-zkvm-verification/json/methods/guest/Cargo.toml index d2ebd86..d4009b6 100644 --- a/examples/risczero-zkvm-verification/json/methods/guest/Cargo.toml +++ b/examples/risczero-zkvm-verification/json/methods/guest/Cargo.toml @@ -4,7 +4,7 @@ version = "0.12.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "Apache-2.0" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" [workspace] diff --git a/examples/risczero-zkvm-verification/src/lib.rs b/examples/risczero-zkvm-verification/src/lib.rs index 006df06..37df6fe 100644 --- a/examples/risczero-zkvm-verification/src/lib.rs +++ b/examples/risczero-zkvm-verification/src/lib.rs @@ -1,4 +1,4 @@ -//! This example shows how to write a contrieved and basic constraint: checking the length of the data to be signed. +//! This example shows how to write a contrieved and basic program: checking the length of the data to be signed. #![cfg_attr(not(test), no_std)] @@ -6,7 +6,7 @@ extern crate alloc; use alloc::{string::ToString, vec::Vec}; -use ec_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; +use entropy_programs_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; use bincode; use risc0_zkvm::Receipt; diff --git a/examples/siwe/Cargo.toml b/examples/siwe/Cargo.toml index 02ecf16..f7e7670 100644 --- a/examples/siwe/Cargo.toml +++ b/examples/siwe/Cargo.toml @@ -4,15 +4,15 @@ version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "Unlicense" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" -# This is required to compile constraints to a wasm module +# This is required to compile programs to a wasm module [lib] crate-type = ["cdylib"] [dependencies] -ec-core = { workspace = true } +entropy-programs-core = { workspace = true } siwe = "0.6.0" # These are used by `cargo component` diff --git a/examples/siwe/src/lib.rs b/examples/siwe/src/lib.rs index ceacfbf..97047d1 100644 --- a/examples/siwe/src/lib.rs +++ b/examples/siwe/src/lib.rs @@ -7,9 +7,12 @@ extern crate alloc; -use alloc::{string::{String, ToString}, vec::Vec}; +use alloc::{ + string::{String, ToString}, + vec::Vec, +}; -use ec_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; +use entropy_programs_core::{bindgen::Error, bindgen::*, export_program, prelude::*}; use siwe::Message; // TODO confirm this isn't an issue for audit diff --git a/programs/Cargo.toml b/programs/Cargo.toml new file mode 100644 index 0000000..d05489c --- /dev/null +++ b/programs/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "entropy-programs" +version = "0.1.0" +authors = ["Entropy Cryptography "] +homepage = "https://entropy.xyz/" +license = "AGPL-3.0-or-later" +repository = "https://github.com/entropyxyz/programs" +edition = "2021" + +# [lib] +# crate-type = ["cdylib"] + +[dependencies] +entropy-programs-acl = { path = "../acl", default-features = false, features = ["evm"] } +entropy-programs-evm = { path = "../evm", default-features = false } +entropy-programs-core = { path = "../core", default-features = false } + +[dev-dependencies] +# entropy-programs-runtime = { path = "../runtime", default-features = false } + +[features] +default = ["std"] +std = ["entropy-programs-acl/std", "entropy-programs-evm/std"] diff --git a/programs/README.md b/programs/README.md new file mode 100644 index 0000000..01a4165 --- /dev/null +++ b/programs/README.md @@ -0,0 +1,3 @@ +# `entropy-programs` + +This is the main library for writing programs. Currently, it is boilerplate and will re-export all programs and architectures. diff --git a/constraints/src/lib.rs b/programs/src/lib.rs similarity index 58% rename from constraints/src/lib.rs rename to programs/src/lib.rs index e93c375..19d52b4 100644 --- a/constraints/src/lib.rs +++ b/programs/src/lib.rs @@ -1,17 +1,17 @@ -//! Includes types and interfaces that are foundational to the core of constraints. +//! Includes types and interfaces that are foundational to the core of programs. #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; -pub use ec_core as core; -/// All architecture-agnostic constraints should be re-exported from this module -pub mod constraints { - pub use ec_acl as acl; +pub use entropy_programs_core as core; +/// All architecture-agnostic programs should be re-exported from this module +pub mod programs { + pub use entropy_programs_acl as acl; } /// All architectures that implement the `ec_core::Architecture` trait should be re-exported from here. pub mod arch { - pub use ec_evm as evm; + pub use entropy_programs_evm as evm; } /// Dynamic parsing allows for easily hooking transactions into diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 0275177..c461994 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,19 +1,16 @@ [package] -name = "ec-runtime" +name = "entropy-programs-runtime" version = "0.1.0" authors = ["Entropy Cryptography "] homepage = "https://entropy.xyz/" license = "AGPL-3.0-or-later" -repository = "https://github.com/entropyxyz/constraints" +repository = "https://github.com/entropyxyz/programs" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] wasmtime = { version = "12.0.1", features = ["component-model"] } -ec-core = { path = "../core" } +entropy-programs-core = { path = "../core" } thiserror = "1.0.47" [dev-dependencies] blake3 = "1.5.0" -# anyhow = "1.0.71" diff --git a/runtime/README.md b/runtime/README.md index 3df87fd..a95cd99 100644 --- a/runtime/README.md +++ b/runtime/README.md @@ -1,6 +1,6 @@ -# `ec-runtime` +# `entropy-programs-runtime` -This contains the Wasm runtime for evaluaing, testing, and simulating constraints as *Wasm Components*. +This contains the Wasm runtime for evaluaing, testing, and simulating programs as *Wasm Components*. ## Running Tests diff --git a/runtime/tests/runtime.rs b/runtime/tests/runtime.rs index 6ac2f53..8bbe652 100644 --- a/runtime/tests/runtime.rs +++ b/runtime/tests/runtime.rs @@ -3,13 +3,12 @@ const BAREBONES_COMPONENT_WASM: &[u8] = include_bytes!("../../target/wasm32-unknown-unknown/release/template_barebones.wasm"); const CUSTOM_HASH_COMPONENT_WASM: &[u8] = include_bytes!("../../target/wasm32-unknown-unknown/release/example_custom_hash.wasm"); - /// Points to the `infinite-loop` program binary. const INFINITE_LOOP_WASM: &[u8] = include_bytes!("../../target/wasm32-unknown-unknown/release/infinite_loop.wasm"); -use ec_runtime::{Runtime, SignatureRequest}; use blake3; +use entropy_programs_runtime::{Runtime, SignatureRequest}; #[test] fn test_barebones_component() {