Skip to content

Commit

Permalink
Rename to programs - and prefix internal crates with `entropy-program…
Browse files Browse the repository at this point in the history
…s-` (#52)

* Rename to programs

* Missed name changes

---------

Co-authored-by: jakehemmerle <[email protected]>
  • Loading branch information
ameba23 and jakehemmerle authored Jan 6, 2024
1 parent 0db40ea commit eaa9fbc
Show file tree
Hide file tree
Showing 41 changed files with 146 additions and 146 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
14 changes: 6 additions & 8 deletions acl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
[package]
name = "ec-acl"
name = "entropy-programs-acl"
version = "0.1.0"
authors = ["Entropy Cryptography <[email protected]>"]
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 = [
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion acl/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# `evm-acl`
# `entropy-programs-acl`

Provides access control list functionality over generic architectures.
6 changes: 3 additions & 3 deletions acl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -65,7 +65,7 @@ impl<A: Default> Default for Acl<A> {
}

// 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<Evm> for Acl<<Evm as Architecture>::AddressRaw> {
Expand Down
20 changes: 15 additions & 5 deletions acl/src/tests.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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],
Expand Down
23 changes: 0 additions & 23 deletions constraints/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions constraints/README.md

This file was deleted.

10 changes: 4 additions & 6 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
[package]
name = "ec-core"
name = "entropy-programs-core"
version = "0.1.0"
authors = ["Entropy Cryptography <[email protected]>"]
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"
Expand All @@ -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"]
Expand Down
6 changes: 3 additions & 3 deletions core/README.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions core/src/constraints.rs → core/src/programs.rs
Original file line number Diff line number Diff line change
@@ -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];
Expand Down
9 changes: 3 additions & 6 deletions evm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[package]
name = "ec-evm"
name = "entropy-programs-evm"
version = "0.1.0"
authors = ["Entropy Cryptography <[email protected]>"]
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 }
Expand All @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions evm/README.md
Original file line number Diff line number Diff line change
@@ -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).
6 changes: 4 additions & 2 deletions evm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 3 additions & 5 deletions examples/barebones-with-auxilary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ version = "0.1.0"
authors = ["Entropy Cryptography <[email protected]>"]
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]
Expand Down
4 changes: 2 additions & 2 deletions examples/barebones-with-auxilary/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions examples/barebones/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ version = "0.1.0"
authors = ["Entropy Cryptography <[email protected]>"]
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]
Expand Down
6 changes: 3 additions & 3 deletions examples/barebones/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! 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]

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);
Expand All @@ -19,7 +19,7 @@ impl Program for BarebonesProgram {
fn evaluate(signature_request: SignatureRequest) -> Result<(), Error> {
let message: Vec<u8> = 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(),
Expand Down
Loading

0 comments on commit eaa9fbc

Please sign in to comment.