From dbb47f88c2fc7c5ce123df3a355d9fd210d1a650 Mon Sep 17 00:00:00 2001 From: Xavier Pinsach <10213118+xavi-pinsach@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:16:14 +0200 Subject: [PATCH 1/2] Fix github links in Cargo.toml --- state-machines/main/Cargo.toml | 13 +++++++------ state-machines/mem/Cargo.toml | 12 ++++++------ witness-computation/Cargo.toml | 16 ++++++++-------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/state-machines/main/Cargo.toml b/state-machines/main/Cargo.toml index 30be9248..b8ef15a0 100644 --- a/state-machines/main/Cargo.toml +++ b/state-machines/main/Cargo.toml @@ -5,14 +5,15 @@ edition = "2021" [dependencies] zisk-common = { path = "../../common" } -# common = { git = "https://github.com/0xPolygonHermez/pil2-proofman" } -# proofman = { git = "https://github.com/0xPolygonHermez/pil2-proofman" } -# wchelpers = { git = "https://github.com/0xPolygonHermez/pil2-proofman" } +common = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" } +proofman = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" } +wchelpers = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" } + log = { version = "0.4", default-features = false } p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git", rev = "c3d754ef77b9fce585b46b972af751fe6e7a9803" } p3-field = { git = "https://github.com/Plonky3/Plonky3.git", rev = "c3d754ef77b9fce585b46b972af751fe6e7a9803" } #Local development -common = { path = "../../../pil2-proofman/common" } -proofman = { path = "../../../pil2-proofman/proofman" } -wchelpers = { path = "../../../pil2-proofman/wchelpers" } +# common = { path = "../../../pil2-proofman/common" } +# proofman = { path = "../../../pil2-proofman/proofman" } +# wchelpers = { path = "../../../pil2-proofman/wchelpers" } diff --git a/state-machines/mem/Cargo.toml b/state-machines/mem/Cargo.toml index af0b385e..7032cfdc 100644 --- a/state-machines/mem/Cargo.toml +++ b/state-machines/mem/Cargo.toml @@ -5,14 +5,14 @@ edition = "2021" [dependencies] zisk-common = { path = "../../common" } -# common = { git = "https://github.com/0xPolygonHermez/pil2-proofman" } -# proofman = { git = "https://github.com/0xPolygonHermez/pil2-proofman" } -# wchelpers = { git = "https://github.com/0xPolygonHermez/pil2-proofman" } +common = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" } +proofman = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" } +wchelpers = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" } log = { version = "0.4", default-features = false } p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git", rev = "c3d754ef77b9fce585b46b972af751fe6e7a9803" } p3-field = { git = "https://github.com/Plonky3/Plonky3.git", rev = "c3d754ef77b9fce585b46b972af751fe6e7a9803" } #Local development -common = { path = "../../../pil2-proofman/common" } -proofman = { path = "../../../pil2-proofman/proofman" } -wchelpers = { path = "../../../pil2-proofman/wchelpers" } +# common = { path = "../../../pil2-proofman/common" } +# proofman = { path = "../../../pil2-proofman/proofman" } +# wchelpers = { path = "../../../pil2-proofman/wchelpers" } diff --git a/witness-computation/Cargo.toml b/witness-computation/Cargo.toml index 88c3b84e..826bca67 100644 --- a/witness-computation/Cargo.toml +++ b/witness-computation/Cargo.toml @@ -10,16 +10,16 @@ crate-type = ["dylib"] sm-main = { path = "../state-machines/main" } sm-mem = { path = "../state-machines/mem" } -# common = { git = "https://github.com/0xPolygonHermez/pil2-proofman" } -# proofman = { git = "https://github.com/0xPolygonHermez/pil2-proofman" } -# wchelpers = { git = "https://github.com/0xPolygonHermez/pil2-proofman" } - -#Local development -common = { path = "../../pil2-proofman/common" } -proofman = { path = "../../pil2-proofman/proofman" } -wchelpers = { path = "../../pil2-proofman/wchelpers" } +common = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" } +proofman = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" } +wchelpers = { git = "https://github.com/0xPolygonHermez/pil2-proofman.git", branch ="develop" } log = { version = "0.4", default-features = false } env_logger = "0.11" p3-goldilocks = { git = "https://github.com/Plonky3/Plonky3.git", rev = "c3d754ef77b9fce585b46b972af751fe6e7a9803" } p3-field = { git = "https://github.com/Plonky3/Plonky3.git", rev = "c3d754ef77b9fce585b46b972af751fe6e7a9803" } + +#Local development +# common = { path = "../../pil2-proofman/common" } +# proofman = { path = "../../pil2-proofman/proofman" } +# wchelpers = { path = "../../pil2-proofman/wchelpers" } From 85bbec7b5c388e1f15edfdb281e2bf06ebcb7546 Mon Sep 17 00:00:00 2001 From: Xavier Pinsach <10213118+xavi-pinsach@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:24:31 +0200 Subject: [PATCH 2/2] Removed examples --- Cargo.toml | 1 - examples/fib/.cargo/config.toml | 8 - examples/fib/.cargo/file_size.sh | 16 -- examples/fib/.cargo/sim.sh | 23 -- examples/fib/.gitignore | 1 - examples/fib/.vscode/launch.json | 56 ----- examples/fib/Cargo.lock | 398 ------------------------------ examples/fib/Cargo.toml | 31 --- examples/fib/README.md | 55 ----- examples/fib/build.rs | 19 -- examples/fib/rust-toolchain | 2 - examples/fib/src/bin/fib.rs | 215 ---------------- examples/fib/src/bin/gen_input.rs | 67 ----- examples/fib/src/bin/input.proto | 9 - examples/fib/src/bin/output.proto | 9 - examples/fib/src/lib.rs | 45 ---- examples/fib/src/script.ld | 41 --- 17 files changed, 996 deletions(-) delete mode 100644 examples/fib/.cargo/config.toml delete mode 100755 examples/fib/.cargo/file_size.sh delete mode 100755 examples/fib/.cargo/sim.sh delete mode 100644 examples/fib/.gitignore delete mode 100644 examples/fib/.vscode/launch.json delete mode 100644 examples/fib/Cargo.lock delete mode 100644 examples/fib/Cargo.toml delete mode 100644 examples/fib/README.md delete mode 100644 examples/fib/build.rs delete mode 100644 examples/fib/rust-toolchain delete mode 100644 examples/fib/src/bin/fib.rs delete mode 100644 examples/fib/src/bin/gen_input.rs delete mode 100644 examples/fib/src/bin/input.proto delete mode 100644 examples/fib/src/bin/output.proto delete mode 100644 examples/fib/src/lib.rs delete mode 100644 examples/fib/src/script.ld diff --git a/Cargo.toml b/Cargo.toml index b32b0a17..fbed84a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,6 @@ members = [ "cli", "common", - "examples/fib", "riscv/riscv2zisk", "simulator", "state-machines/main", diff --git a/examples/fib/.cargo/config.toml b/examples/fib/.cargo/config.toml deleted file mode 100644 index 07d44403..00000000 --- a/examples/fib/.cargo/config.toml +++ /dev/null @@ -1,8 +0,0 @@ -[build] -target = ["riscv64ima-polygon-ziskos-elf", "x86_64-unknown-linux-gnu"] - - -[target.riscv64ima-polygon-ziskos-elf] -#linker = "/opt/riscv/bin/riscv64-unknown-elf-ld" -#rustflags = ["-C", "link-arg=-Tsrc/script.ld"] -runner = ".cargo/sim.sh" diff --git a/examples/fib/.cargo/file_size.sh b/examples/fib/.cargo/file_size.sh deleted file mode 100755 index 47573c02..00000000 --- a/examples/fib/.cargo/file_size.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -input_file="input.bin" -output_file="input_size.bin" - -# Verify that the input file exists -if [ ! -f "$input_file" ]; then - echo "Error: The input file '$input_file' does not exist." - exit 1 -fi - -# Get the size of the input file in bytes -size=$(stat -c%s "$input_file") - -# Convert the size to little endian format and write it to a binary file -printf "%08x" "$size" | tac -rs.. | xxd -r -p > "$output_file" diff --git a/examples/fib/.cargo/sim.sh b/examples/fib/.cargo/sim.sh deleted file mode 100755 index dee04873..00000000 --- a/examples/fib/.cargo/sim.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Verificar si la variable de entorno SIM está configurada como true -if [ "$SIM" == "true" ]; then - echo "The SIM environment variable is set to true." - node ../../../ziskjs/src/sim/main.js -e $1 -n 1000000 -i input.bin -t trace.tr -else - echo "The SIM environment variable is set to false. Running the QEMU RISC-V..." - .cargo/file_size.sh - qemu-system-riscv64 \ - -cpu rv64 \ - -machine virt \ - -device loader,file=./input_size.bin,addr=0x90000000 \ - -device loader,file=./input.bin,addr=0x90000008 \ - -m 1G \ - -s \ - -nographic \ - -serial mon:stdio \ - -bios none \ - -kernel $1 -fi - - diff --git a/examples/fib/.gitignore b/examples/fib/.gitignore deleted file mode 100644 index ea8c4bf7..00000000 --- a/examples/fib/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/examples/fib/.vscode/launch.json b/examples/fib/.vscode/launch.json deleted file mode 100644 index c30415cc..00000000 --- a/examples/fib/.vscode/launch.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'hellozisk_rust'", - "cargo": { - "args": [ - "build", - "--bin=hello_host", - "--package=hellozisk_rust" - ], - "filter": { - "name": "hello_host", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug unit tests in executable 'hellozisk_rust'", - "cargo": { - "args": [ - "test", - "--no-run", - "--bin=hello_host", - "--package=hellozisk_rust" - ], - "filter": { - "name": "hello_host", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "gdb", - "request": "attach", - "name": "Attach to gdbserver", - "executable": "${workspaceRoot}/target/riscv64ima-polygon-ziskos-elf/debug/hello_zisk", - "target": "localhost:1234", - "remote": true, - "cwd": "${workspaceRoot}/src", - "valuesFormatting": "parseText", - "gdbpath": "/opt/riscv/bin/riscv64-unknown-elf-gdb" - } - ] -} \ No newline at end of file diff --git a/examples/fib/Cargo.lock b/examples/fib/Cargo.lock deleted file mode 100644 index 397fe7fb..00000000 --- a/examples/fib/Cargo.lock +++ /dev/null @@ -1,398 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "bytes" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "fastrand" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" - -[[package]] -name = "fib" -version = "0.1.0" -dependencies = [ - "bytes", - "prost", - "prost-build", - "prost-types", - "tiny-keccak", -] - -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "linux-raw-sys" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "multimap" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "petgraph" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" -dependencies = [ - "fixedbitset", - "indexmap", -] - -[[package]] -name = "prettyplease" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" -dependencies = [ - "proc-macro2", - "syn", -] - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prost" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" -dependencies = [ - "bytes", - "heck", - "itertools", - "log", - "multimap", - "once_cell", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" -dependencies = [ - "prost", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex" -version = "1.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - -[[package]] -name = "rustix" -version = "0.38.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - -[[package]] -name = "syn" -version = "2.0.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tempfile" -version = "3.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/examples/fib/Cargo.toml b/examples/fib/Cargo.toml deleted file mode 100644 index 935a624c..00000000 --- a/examples/fib/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "fib" -version = "0.1.0" -edition = "2021" -default-run = "fib" -build = "build.rs" - -[features] -default = [] -zisk = [] - -[dependencies] -bytes = "1.6.0" -prost = "0.12.6" -prost-types = "0.12.6" -tiny-keccak = { version = "2.0.2", features = ["keccak", "sha3"] } - - -[build-dependencies] -prost-build = "0.12.6" - -[lib] -name = "fib" - -[[bin]] -name = "fib" -path = "src/bin/fib.rs" - -[[bin]] -name = "input" -path = "src/bin/gen_input.rs" diff --git a/examples/fib/README.md b/examples/fib/README.md deleted file mode 100644 index a26bc79f..00000000 --- a/examples/fib/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# zisk hello world in rust - -## Compile in gost - -```bash -cargo run --target riscv64ima-polygon-ziskos-elf -#or -cargo run --target x86_64-unknown-linux-gnu -``` - -## Compile and run in qemu -```bash -cargo build --bin hello_zisk --target .cargo/riscv64ima-unknown-none-elf.json -Z build-std=core -readelf -l target/riscv64ima-unknown-none-elf/debug/hello_zisk -qemu-system-riscv64 -cpu rv64 -machine virt -m 1G -nographic -bios target/riscv64ima-unknown-none-elf/debug/hello_zisk -S -gdb tcp:localhost:2222 -cp target/riscv64ima-unknown-none-elf/debug/hello_zisk ../ziskjs/work/ -``` - -```bash -cd /home/jbaylina/riscv-gnu-toolchain/gdb/gdb -./gdb - file /home/jbaylina/hellozisk_rust/target/riscv64ima-unknown-none-elf/debug/hello_zisk - target remote localhost:2222 - si - x/10i $pc-16 -``` - -## Trace with qemu -``` -qemu-system-riscv64 -cpu rv64 -machine virt -m 1G -nographic -bios target/riscv64ima-unknown-none-elf/debug/hello_zisk -gdb tcp:localhost:2222 -S -/home/jbaylina/riscv-gnu-toolchain/opt/riscv/bin/riscv64-unknown-elf-gdb --command zisk_trace_gdb.py -``` - -## Trace with ziskjs -``` -/home/jbaylina/n/bin/node src/sim/main.js -r work/hello_zisk.ziskrom -n 10000 -t work/sim.tr -p 100 -``` - -### mvendorid CSR 0xF11 - We may pay for a number - - JEDEC Codes: - https://www.jedec.org/standards-documents/docs/jep-106ab - - JEDEC -> mvendorid - https://github.com/riscv/riscv-isa-manual/issues/32 - -### marchid CSR 0xF12 - Lets use FE here temporally until we open source - RISC-V Architercures - https://github.com/riscv/riscv-isa-manual/blob/main/marchid.md - - - - diff --git a/examples/fib/build.rs b/examples/fib/build.rs deleted file mode 100644 index b1cedad3..00000000 --- a/examples/fib/build.rs +++ /dev/null @@ -1,19 +0,0 @@ -extern crate prost_build; - -use std::env; - -fn main() -> Result<(), Box> { - prost_build::compile_protos(&["src/bin/input.proto"], &["src/"])?; - prost_build::compile_protos(&["src/bin/output.proto"], &["src/"])?; - - // Get the full path to the script.ld file - // The CARGO_MANIFEST_DIR environment variable points to the directory containing the crate's Cargo.toml - let script_path = env::var("CARGO_MANIFEST_DIR").unwrap(); - let script_path = format!("{}/src/script.ld", script_path); - - // Set the linker argument to use the script.ld file - // This tells the Rust compiler to pass the -T script.ld argument to the linker - println!("cargo:rustc-link-arg=-T{}", script_path); - - Ok(()) -} diff --git a/examples/fib/rust-toolchain b/examples/fib/rust-toolchain deleted file mode 100644 index 11f0a668..00000000 --- a/examples/fib/rust-toolchain +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel = "zisk" \ No newline at end of file diff --git a/examples/fib/src/bin/fib.rs b/examples/fib/src/bin/fib.rs deleted file mode 100644 index cc8bbc25..00000000 --- a/examples/fib/src/bin/fib.rs +++ /dev/null @@ -1,215 +0,0 @@ -#![feature(naked_functions)] -#![feature(asm_const)] - -#[cfg(target_os = "ziskos")] -use core::arch::asm; -use prost::Message; -use std::fs::File; -use std::io::{self, Read}; - -const MAX_INPUT: usize = 0x2000; -const MAX_OUTPUT: usize = 0x1_0000; - -#[cfg(target_os = "ziskos")] -mod ziskos_config { - pub static mut SV: u64 = 0xBBBB; - - pub const QEMU_EXIT_ADDR: u64 = 0x100000; - pub const QEMU_EXIT_CODE: u64 = 0x5555; - pub const INPUT_ADDR: u64 = 0x9000_0000; - pub const OUTPUT_ADDR: u64 = 0xa001_0000; - pub const ARCH_ID_ZISK: u64 = 0xFFFEEEE; // TEMPORARY // TODO register one -} -mod input { - include!(concat!(env!("OUT_DIR"), "/inputs.rs")); -} - -#[cfg(target_os = "ziskos")] -use input::Input; - -#[cfg(target_os = "ziskos")] -use ziskos_config::*; - -#[naked] -#[no_mangle] -#[link_section = ".text.init"] -#[cfg(target_os = "ziskos")] -unsafe extern "C" fn _start() -> ! { - asm!( - // before we use the `la` pseudo-instruction for the first time, - // we need to set `gp` (google linker relaxation) - ".option push", - ".option norelax", - "la gp, _global_pointer", - ".option pop", - - // set the stack pointer - "la sp, _init_stack_top", - - // "tail-call" to {entry} - "call {_zisk_main}", - "csrr t0, marchid", - "li t1, {ARCH_ID_ZISK}", - "beq t0, t1, 1f", - - // QEmuu exit - "li t0, {QEMU_EXIT_ADDR}", - "li t1, {QEMU_EXIT_CODE}", - "sw t1, 0(t0)", - "j 2f", - - // Zisk exit - "1: li a7, 93", - "ecall", - - "2: j 2b", - - _zisk_main = sym _zisk_main, // {entry} refers to the function [entry] below - QEMU_EXIT_ADDR = const QEMU_EXIT_ADDR, - QEMU_EXIT_CODE = const QEMU_EXIT_CODE, - ARCH_ID_ZISK = const ARCH_ID_ZISK, - options(noreturn) // we must handle "returning" from assembly - ); -} - -// Function to get the size of the serialized message -unsafe fn get_serialized_size(input: *const u8) -> u32 { - let size_bytes = core::slice::from_raw_parts(input, 4); // Read the first 4 bytes - u32::from_le_bytes([size_bytes[0], size_bytes[1], size_bytes[2], size_bytes[3]]) -} - -#[cfg(target_os = "ziskos")] -#[no_mangle] -extern "C" fn _zisk_main() { - //check if static value works - unsafe { SV += 1 }; - - #[cfg(target_os = "ziskos")] - { - // Create a slice of the first 4 bytes - let bytes = unsafe { core::slice::from_raw_parts(INPUT_ADDR as *const u8, 8) }; - // Convert the slice to a u64 (little-endian) - let size = usize::from_le_bytes([ - bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], - ]); - - println!("Input file size: {} bytes", size); - - let input = - unsafe { core::slice::from_raw_parts((INPUT_ADDR as *const u8).add(8), size) }; - - let output = unsafe { core::slice::from_raw_parts_mut(OUTPUT_ADDR as *mut _, MAX_OUTPUT) }; - - fib::main(input, output); - } -} -const FILENAME: &str = "input.bin"; -fn main() -> io::Result<()> { - let mut file = File::open(FILENAME)?; - let mut buf = Vec::new(); - file.read_to_end(&mut buf)?; - - let mut output: Vec = vec![0; MAX_OUTPUT]; - - // Create a slice of the first 4 bytes - let bytes = unsafe { core::slice::from_raw_parts(buf.as_ptr(), 8) }; - // Convert the slice to a u32 (little-endian) - let size = u32::from_le_bytes([bytes[0], bytes[1], bytes[2], bytes[3]]); - - let input = unsafe { core::slice::from_raw_parts(buf.as_ptr(), buf.len()) }; - - fib::main(input, &mut output); - Ok(()) -} - -#[no_mangle] -#[cfg(target_os = "ziskos")] -extern "C" fn sys_write(_fd: u32, write_ptr: *const u8, nbytes: usize) { - let arch_id_zisk: usize; - let mut addr: *mut u8 = 0x1000_0000 as *mut u8; - - unsafe { - asm!( - "csrr {0}, marchid", - out(reg) arch_id_zisk, - ) - }; - if arch_id_zisk == ARCH_ID_ZISK as usize { - addr = 0xa000_0200 as *mut u8; - } - - for i in 0..nbytes { - unsafe { - core::ptr::write_volatile(addr, *write_ptr.add(i)); - } - } -} - -#[no_mangle] -#[cfg(target_os = "ziskos")] -extern "C" fn sys_getenv() { - //unimplemented!("sys_getenv") -} - -#[no_mangle] -#[cfg(target_os = "ziskos")] - -extern "C" fn sys_alloc_words() { - //unimplemented!("sys_alloc_words") -} - -#[no_mangle] -#[cfg(target_os = "ziskos")] -extern "C" fn sys_argc() { - unimplemented!("sys_argc"); -} - -#[no_mangle] -#[cfg(target_os = "ziskos")] -extern "C" fn sys_argv() { - unimplemented!("sys_argv"); -} - -#[no_mangle] -#[cfg(target_os = "ziskos")] -pub unsafe extern "C" fn sys_alloc_aligned(bytes: usize, align: usize) -> *mut u8 { - use core::arch::asm; - let heap_bottom: usize; - // UNSAFE: This is fine, just loading some constants. - unsafe { - // using inline assembly is easier to access linker constants - asm!( - "la {heap_bottom}, _kernel_heap_bottom", - heap_bottom = out(reg) heap_bottom, - options(nomem) - ) - }; - - // Pointer to next heap address to use, or 0 if the heap has not yet been - // initialized. - static mut HEAP_POS: usize = 0; - - // SAFETY: Single threaded, so nothing else can touch this while we're working. - let mut heap_pos = unsafe { HEAP_POS }; - - if heap_pos == 0 { - heap_pos = heap_bottom; - } - - let offset = heap_pos & (align - 1); - if offset != 0 { - heap_pos += align - offset; - } - - let ptr = heap_pos as *mut u8; - heap_pos += bytes; - - // Check to make sure heap doesn't collide with SYSTEM memory. - //if SYSTEM_START < heap_pos { - // panic!(); - // } - - unsafe { HEAP_POS = heap_pos }; - - ptr -} diff --git a/examples/fib/src/bin/gen_input.rs b/examples/fib/src/bin/gen_input.rs deleted file mode 100644 index 8e846b58..00000000 --- a/examples/fib/src/bin/gen_input.rs +++ /dev/null @@ -1,67 +0,0 @@ -use std::fs::File; -use std::io::{self, Read, Write}; - -extern crate prost; -extern crate prost_types; - -use prost::Message; - -mod input { - include!(concat!(env!("OUT_DIR"), "/inputs.rs")); -} - -use input::Input; - -const FILE_SIZE: usize = 0x2000; -const FILENAME: &str = "input.bin"; - -// Function to serialize the `Input` object to a binary file -fn serialize_input(input: &Input) -> io::Result<()> { - let mut buf = Vec::new(); - buf.reserve(input.encoded_len()); - input.encode(&mut buf)?; - - // Write the vector to a binary file - let mut file = File::create(FILENAME)?; - file.write_all(&buf)?; - - Ok(()) -} - - -// Function to deserialize the `Input` object from a binary file -fn deserialize_input() -> io::Result { - let mut file = File::open(FILENAME)?; - let mut buf = Vec::new(); - file.read_to_end(&mut buf)?; - - // Deserialize the data - let input = Input::decode(&*buf).unwrap_or_else(|_| Input { - msg: "".to_string(), - n: 0, - a: 0, - b: 0, - }); - - Ok(input) -} - -fn main() -> io::Result<()> { - let input = Input { - msg: "Hello, Zisk!! by edu".to_string(), - n: 0, - a: 0, - b: 1, - }; - - // Serialize the `Input` object to a binary file with fixed size - serialize_input(&input)?; - - // Deserialize the `Input` object from the binary file - let input_read = deserialize_input()?; - - // Print the deserialized data - println!("Input: {:?}", input_read); - - Ok(()) -} diff --git a/examples/fib/src/bin/input.proto b/examples/fib/src/bin/input.proto deleted file mode 100644 index 96eadcea..00000000 --- a/examples/fib/src/bin/input.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; -package inputs; - -message Input { - string msg = 1; - uint64 n = 2; - uint64 a = 3; - uint64 b = 4; -} \ No newline at end of file diff --git a/examples/fib/src/bin/output.proto b/examples/fib/src/bin/output.proto deleted file mode 100644 index 8dcb25f3..00000000 --- a/examples/fib/src/bin/output.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; -package output; - -message Input { - string msg = 1; - uint64 n = 2; - uint64 a = 3; - uint64 b = 4; -} \ No newline at end of file diff --git a/examples/fib/src/lib.rs b/examples/fib/src/lib.rs deleted file mode 100644 index 866f4e91..00000000 --- a/examples/fib/src/lib.rs +++ /dev/null @@ -1,45 +0,0 @@ -use prost::Message; -use tiny_keccak::Hasher; -use tiny_keccak::Keccak; - -mod input { - include!(concat!(env!("OUT_DIR"), "/inputs.rs")); -} - -use input::Input; - -pub fn main(input: &[u8], _output: &mut [u8]) { - // Deserializar el vector a un objeto `Input` - let input_read = Input::decode(input).unwrap(); - - println!("Input: {:?}", input.len()); - - - - println!("Input: {:?}", input_read); - - let mut a: u64 = input_read.a; - let mut b: u64 = input_read.b; - - for _ in 0..input_read.n { - let c: u64 = a + b; - a = b; - b = c; - } - - println!("fib({}) = {}", input_read.n, a); - - let hash = __compute_keccak(input_read.msg.as_str()); - println!("keccak256({}) = {:?}", input_read.msg, hash); - -} - -#[no_mangle] -fn __compute_keccak(str: &str) -> [u8; 32] { - let mut keccak = Keccak::v256(); - let mut output = [0; 32]; - - keccak.update(str.as_bytes()); - keccak.finalize(&mut output); - output -} diff --git a/examples/fib/src/script.ld b/examples/fib/src/script.ld deleted file mode 100644 index 7df903c5..00000000 --- a/examples/fib/src/script.ld +++ /dev/null @@ -1,41 +0,0 @@ -OUTPUT_FORMAT("elf64-littleriscv") -OUTPUT_ARCH("riscv") -ENTRY(_start) - -MEMORY { - rom (xa) : ORIGIN = 0x80000000, LENGTH = 0x10000000 - ram (wxa) : ORIGIN = 0xa0020000, LENGTH = 0xFFE0000 -} - -PHDRS { - text PT_LOAD FLAGS(5); - rodata PT_LOAD FLAGS(4); - data PT_LOAD FLAGS(6); - bss PT_LOAD FLAGS(6); -} - -SECTIONS -{ - .text : { *(.text.init) *(.text .text.*)} >rom AT>rom :text - - . = ALIGN(8); - PROVIDE(_global_pointer = .); - .rodata : { *(.rodata .rodata.*)} >rom AT>rom :rodata - - .data : { *(.data .data.* .sdata .sdata.*) } >ram AT>ram :data - - .bss : { - PROVIDE(_bss_start = .); - *(.bss .bss.*); - PROVIDE(_bss_end = .); # ... and one at the end - } >ram AT>ram :bss - - . = ALIGN(8); - PROVIDE(_init_stack_top = . + 0x100000); # reserve 1M bytes for the initialisation stack - - PROVIDE(_kernel_heap_bottom = _init_stack_top); - PROVIDE(_kernel_heap_top = ORIGIN(ram) + LENGTH(ram)); - PROVIDE(_kernel_heap_size = _kernel_heap_top - _kernel_heap_bottom); - - _end = .; -} \ No newline at end of file