From 79cfefc46f9149c56cb51b2d5bdc8a6d7fcaf2ce Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 28 May 2021 17:51:34 +0200 Subject: [PATCH] Release v0.1 --- .github/workflows/build.yml | 24 ++------ Cargo.lock | 120 ++++++++++++++++++------------------ Cargo.toml | 4 +- README.md | 6 +- examples/asm.rs | 5 +- src/instr/bytecode.rs | 7 +-- src/instr/exec.rs | 3 +- src/instr/op_codes.rs | 10 ++- src/runtime.rs | 2 +- 9 files changed, 82 insertions(+), 99 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac16cde..5517cf2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,8 +23,12 @@ jobs: uses: actions-rs/cargo@v1 with: command: check - std: + features: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + feature: [ std, all, secp256k1, curve25519 ] steps: - uses: actions/checkout@v2 - name: Install rust stable @@ -36,7 +40,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: check - args: --features std + args: --features ${{ matrix.feature }} platforms: runs-on: ${{ matrix.os }} strategy: @@ -76,22 +80,6 @@ jobs: with: command: check args: --workspace --all-targets --all-features - ancient: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install rust 1.36.0 - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.36.0 - override: true - - name: Clean Cargo.lock - run: rm -f Cargo.lock - - name: 1.36.0 - uses: actions-rs/cargo@v1 - with: - command: build - args: --all --all-targets --no-default-features --features std dependency: runs-on: ubuntu-latest steps: diff --git a/Cargo.lock b/Cargo.lock index 139b15d..8a0475f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,215 +1,215 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 - [[package]] name = "alure" version = "0.1.0" dependencies = [ - "amplify_derive", - "amplify_num", - "bitcoin_hashes", - "curve25519-dalek", - "paste", - "secp256k1", + "amplify_derive 2.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "amplify_num 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitcoin_hashes 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "paste 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "secp256k1 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "amplify_derive" version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70c25e03c0ab6c756da21a826faf9739e7d31fe0296bcd369e314d49b5c16b23" dependencies = [ - "amplify_syn", - "proc-macro2", - "quote", - "syn", + "amplify_syn 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.72 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "amplify_num" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd849b3d189295214eaf6c8b6f4e35b50c9b0b3f6f1e55c1812b27a1401052e" [[package]] name = "amplify_syn" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbad3362dcdd043fa8cbcc242aea4634d15ff2a79e6a93ea615e6aa38806cef" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.72 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bitcoin_hashes" version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e6d72ba9671cb0929b5620e1bc30cdf5e206ccb3dbaa8964d67f6efc1e16129" [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "curve25519-dalek" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" dependencies = [ - "byteorder", - "digest", - "rand_core", - "subtle", - "zeroize", + "byteorder 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array", + "generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "generic-array" version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ - "typenum", - "version_check", + "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "getrandom" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", - "libc", - "wasi", + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.95 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libc" version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" [[package]] name = "paste" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" [[package]] name = "proc-macro2" version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" dependencies = [ - "unicode-xid", + "unicode-xid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "secp256k1" version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee5070fdc6f26ca5be6dcfc3d07c76fdb974a63a8b246b459854274145f5a258" dependencies = [ - "secp256k1-sys", + "secp256k1-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "secp256k1-sys" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e4b6455ee49f5901c8985b88f98fb0a0e1d90a6661f5a03f4888bd987dad29" dependencies = [ - "cc", + "cc 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "subtle" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" [[package]] name = "syn" version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", + "proc-macro2 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "typenum" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "unicode-xid" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "version_check" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "zeroize" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" + +[metadata] +"checksum amplify_derive 2.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "70c25e03c0ab6c756da21a826faf9739e7d31fe0296bcd369e314d49b5c16b23" +"checksum amplify_num 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edd849b3d189295214eaf6c8b6f4e35b50c9b0b3f6f1e55c1812b27a1401052e" +"checksum amplify_syn 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf296f37a25aa9511edecc6a713361370a857d0dccd808407d7972a66cc91d6a" +"checksum bitcoin_hashes 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3e6d72ba9671cb0929b5620e1bc30cdf5e206ccb3dbaa8964d67f6efc1e16129" +"checksum byteorder 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +"checksum cc 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)" = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +"checksum cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +"checksum curve25519-dalek 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" +"checksum digest 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +"checksum generic-array 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +"checksum getrandom 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +"checksum libc 0.2.95 (registry+https://github.com/rust-lang/crates.io-index)" = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" +"checksum paste 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" +"checksum proc-macro2 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +"checksum quote 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +"checksum secp256k1 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ee5070fdc6f26ca5be6dcfc3d07c76fdb974a63a8b246b459854274145f5a258" +"checksum secp256k1-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67e4b6455ee49f5901c8985b88f98fb0a0e1d90a6661f5a03f4888bd987dad29" +"checksum subtle 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +"checksum syn 1.0.72 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +"checksum typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +"checksum unicode-xid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +"checksum version_check 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +"checksum zeroize 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" diff --git a/Cargo.toml b/Cargo.toml index a5ba0ad..080ab65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" license = "MIT" repository = "https://github.com/internet2-org/alure" homepage = "https://lnp-bp.org" -keywords = ["virtual-machine", "eemulator", "functional-programming", "risc"] +keywords = ["virtual-machine", "emulator", "declarative", "risc"] categories = ["no-std", "embedded", "compilers", "cryptography", "emulators"] readme = "README.md" exclude = [".github", "test"] @@ -24,7 +24,7 @@ secp256k1 = { version = "0.20.2", optional = true } curve25519-dalek = { version = "3.1", optional = true } [features] -default = ["secp256k1", "curve25519"] +default = [] all = ["std", "secp256k1", "curve25519"] std = ["amplify_num/std", "amplify_num/hex"] curve25519 = ["curve25519-dalek"] diff --git a/README.md b/README.md index ca2473f..4467d57 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # Alure: AluVM runtime environment -Rust implementation of AluVM (arithmetic logic unit virtual machine) and compiler from Alu assembly into bytecode +Rust implementation of AluVM (arithmetic logic unit virtual machine) and +compiler from Alu assembly into bytecode. See [AluVM] specification on +more details on AluVM. + +[AluVM]: https://github.com/internet2-org/aluvm-spec diff --git a/examples/asm.rs b/examples/asm.rs index d5c55ec..86063a9 100644 --- a/examples/asm.rs +++ b/examples/asm.rs @@ -8,8 +8,7 @@ // You should have received a copy of the MIT License along with this software. // If not, see . -#![feature(trace_macros)] -#![feature(log_syntax)] +extern crate alloc; #[macro_use] extern crate alure; @@ -28,8 +27,6 @@ use amplify_num::hex::ToHex; use amplify_num::u4; use core::convert::TryFrom; -trace_macros!(true); - fn main() { let code = aluasm! { zero a8[1] ; diff --git a/src/instr/bytecode.rs b/src/instr/bytecode.rs index 7ce6347..7ac2a47 100644 --- a/src/instr/bytecode.rs +++ b/src/instr/bytecode.rs @@ -8,7 +8,6 @@ // You should have received a copy of the MIT License along with this software. // If not, see . -use alloc::boxed::Box; use alloc::vec::Vec; use bitcoin_hashes::Hash; use core::ops::RangeInclusive; @@ -204,9 +203,7 @@ where instr if ControlFlowOp::instr_range().contains(&instr) => { Instr::ControlFlow(ControlFlowOp::read(reader)?) } - instr if PutOp::instr_range().contains(&instr) => { - Instr::Put(Box::new(PutOp::read(reader)?)) - } + instr if PutOp::instr_range().contains(&instr) => Instr::Put(PutOp::read(reader)?), instr if MoveOp::instr_range().contains(&instr) => Instr::Move(MoveOp::read(reader)?), instr if CmpOp::instr_range().contains(&instr) => Instr::Cmp(CmpOp::read(reader)?), instr if ArithmeticOp::instr_range().contains(&instr) => { @@ -216,7 +213,7 @@ where Instr::Bitwise(BitwiseOp::read(reader)?) } instr if BytesOp::instr_range().contains(&instr) => { - Instr::Bytes(Box::new(BytesOp::read(reader)?)) + Instr::Bytes(BytesOp::read(reader)?) } instr if DigestOp::instr_range().contains(&instr) => { Instr::Digest(DigestOp::read(reader)?) diff --git a/src/instr/exec.rs b/src/instr/exec.rs index ec876cb..c5cb5e7 100644 --- a/src/instr/exec.rs +++ b/src/instr/exec.rs @@ -19,8 +19,6 @@ use super::{ }; use crate::reg::{Reg32, RegVal, Registers, Value}; use crate::LibSite; -#[cfg(feature = "std")] -use crate::{RegA, RegR}; /// Turing machine movement after instruction execution #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] @@ -322,6 +320,7 @@ impl InstructionSet for Secp256k1Op { #[cfg(feature = "secp256k1")] fn exec(self, regs: &mut Registers, site: LibSite) -> ExecStep { + use crate::{RegA, RegR}; use secp256k1::{PublicKey, SecretKey}; match self { Secp256k1Op::Gen(src, dst) => { diff --git a/src/instr/op_codes.rs b/src/instr/op_codes.rs index 9e2d200..d3e75ad 100644 --- a/src/instr/op_codes.rs +++ b/src/instr/op_codes.rs @@ -10,8 +10,6 @@ #![allow(clippy::branches_sharing_code)] -use alloc::boxed::Box; - use amplify_num::u4; use crate::instr::{Arithmetics, IncDec, NumType}; @@ -39,7 +37,7 @@ where /// Instructions setting register values // 0b00_001_*** - Put(Box), + Put(PutOp), /// Instructions moving and swapping register values // 0b00_010_*** @@ -59,7 +57,7 @@ where /// Operations on byte strings // 0b00_110_*** - Bytes(Box), + Bytes(BytesOp), /// Cryptographic hashing functions // 0b01_000_*** @@ -135,7 +133,7 @@ pub enum ControlFlowOp { } /// Instructions setting register values -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Display)] +#[derive(Clone, PartialEq, Eq, Hash, Debug, Display)] pub enum PutOp { /// Sets `a` register value to zero #[display("zero\t{0}{1}")] @@ -367,7 +365,7 @@ pub enum BitwiseOp { } /// Operations on byte strings -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Display)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Display)] pub enum BytesOp { /// Put bytestring into a byte string register #[display("put\t\ts16[{0}],{1}")] diff --git a/src/runtime.rs b/src/runtime.rs index 59fc82c..27b0c4a 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -136,7 +136,7 @@ pub struct Blob { pub len: u16, /// Slice bytes - pub bytes: [u8; u16::MAX as usize], + pub bytes: [u8; core::u16::MAX as usize], } impl Default for Blob {