Skip to content
Merged

Dev #35

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e1355a6
add coinspect tests
crivasr Sep 16, 2025
dbb6dbb
merge with dev
crivasr Sep 16, 2025
952c22d
align imm to multiple of 4 in op_conditional fuzzer
crivasr Sep 18, 2025
a82bcfa
increase tables for multiplication again
crivasr Sep 18, 2025
65c028d
fix sign_check for zero quotient
crivasr Sep 18, 2025
22f59df
fix div_rem fuzzer
crivasr Sep 18, 2025
bf1a742
add more sanity checks
crivasr Sep 18, 2025
a6db724
add padding and alignment checks
crivasr Sep 18, 2025
06874c0
return error if unaligned write or read
crivasr Sep 18, 2025
7519416
align reads and writes in tests
crivasr Sep 22, 2025
b51fcdc
fix test_load_word_boundary
crivasr Sep 22, 2025
db35027
clear lsb in test
crivasr Sep 22, 2025
639568b
fix witness tests
crivasr Sep 22, 2025
da1e5f8
fix jalr_enhanced test
crivasr Sep 26, 2025
0e80e35
add no-mapping flag
crivasr Sep 26, 2025
f61dcab
fix NUM_TEST_CASES value
crivasr Sep 26, 2025
bd43103
use stdlib and optimizations
crivasr Sep 26, 2025
1220fba
remove unnecessary moves
crivasr Sep 26, 2025
628a251
reuse common verify_file function
crivasr Sep 26, 2025
016f6ef
remove zero address asserts in input and rom challenges
crivasr Sep 26, 2025
b7763b6
warn about stdlib
crivasr Sep 26, 2025
a8c4346
update docker commit
crivasr Sep 26, 2025
c0326e3
fix address_in_sections when section is empty
crivasr Sep 30, 2025
5068ebc
assert nary value is a valid power of two
crivasr Sep 30, 2025
9357a8b
implement execute only memory protection
crivasr Sep 30, 2025
603b071
update docker commit
crivasr Oct 1, 2025
86b5ce9
increase max steps for some tests
crivasr Oct 1, 2025
c61df5b
fix and use save-non-checkpoint-steps flag
crivasr Oct 1, 2025
4301b85
remove wrong test case
crivasr Oct 2, 2025
894af9c
remove outdated comments
crivasr Oct 2, 2025
b767df1
Merge branch 'main' into dev
crivasr Oct 2, 2025
575574c
limit sections count
crivasr Oct 7, 2025
c95eb8f
add future read challenge
crivasr Oct 8, 2025
84b61b3
add different value test case for read challenge
crivasr Oct 8, 2025
94fe167
enforce ReadValueChallenge is before ConflictStep
crivasr Oct 8, 2025
a85b067
verify address in chunk range
crivasr Oct 8, 2025
9002f9b
improve and rename nibbles_to_number
crivasr Oct 8, 2025
b818b79
separate big test in multiple tests
crivasr Oct 8, 2025
81868a0
update submodule
jonasmartin Oct 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ tests/resources/
# checkpoints
*.json
.DS_Store

# Test error log
_coin/reference_tests/error.log
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It is not production-ready, has not been audited, and future updates may introdu
## Structure

The repository contains three folders
1. **docker-riscv32**: Contains the recipe for an image that allows the compilation of C programs into the RISCV-32i architecture. Currently, the programs must be carefully crafted to be used inside BitVMX, using specific memory layouts, predefined input sections and the lack of support for now of the stdlib.
1. **docker-riscv32**: Contains the recipe for an image that allows the compilation of C programs into the RISCV-32i architecture. Currently, the programs must be carefully crafted to be used inside BitVMX, using specific memory layouts and predefined input sections. There is now the possibility to compile with the stdlib, it is not fully tested and may cause problems if it uses unimplemented syscalls.
There are two subfolders: `compliance` which have the code necessary to create the RISCV compliance verification files, and `verifier` which helps with the compilation of a zero knowledge proof verifier program.
2. **emulator**: The emulator is a library with a command line interface implemented in Rust which is used to execute the binary files compiled. Also this tool helps in the creation of the execution trace, the hash list of the execution necessary for the challenge protocol.
3. **bitocoin-script-riscv**: This library contains the code that allows to verify any of the RISCV instructions on Bitcoin Script, and therefore challenge the execution of the CPU on-chain.
Expand Down
1 change: 1 addition & 0 deletions _coin/compliance_tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
4 changes: 4 additions & 0 deletions _coin/compliance_tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM riscv32:latest

WORKDIR /riscv-tests

44 changes: 44 additions & 0 deletions _coin/compliance_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# RISC-V Compliance Tests

This directory contains compliance tests that extend the tests from [riscv-tests](https://github.com/riscv-software-src/riscv-tests).

## Building and Running Tests

### 1. Build the Docker Image

```bash
docker build -t riscv-coin .
```

### 2. Compile the Tests

```bash
sudo ./docker-run-coin-compliance.sh riscv-coin ./build_all.sh
```

### 3. Run the Tests

```bash
./run_tests.sh
```

To verify that all scripts provide the same result in Bitcoin, use the `--verify` flag:

```bash
./run_tests.sh --verify
```

## Understanding Test Failures

When tests fail, they will output something like `halt(5,200)`. To identify which test is failing:

1. Take the first number (5 in this example)
2. Subtract 1: `5 - 1 = 4`
3. Divide by 2: `4 / 2 = 2`

The result (2) is the test number that is failing.

## Options

- `./run_tests.sh` - Run tests without Bitcoin verification (faster)
- `./run_tests.sh --verify` - Run tests with Bitcoin verification (slower but more thorough)
3 changes: 3 additions & 0 deletions _coin/compliance_tests/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$CC -static -march=rv32g -mabi=ilp32 -nostdlib -nostartfiles -Wl,--no-warn-rwx-segments -I./ -I./../../ -I/riscv-tests/isa/macros/scalar/ -T./linker/link.ld -o build/$1.elf /riscv-tests/isa/rv32ui/$1.S
$QEMU -d in_asm -D build/$1.s build/$1.elf
$DUMP -d build/$1.elf > build/$1_dump.s
17 changes: 17 additions & 0 deletions _coin/compliance_tests/build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
echo "Executing build_all.sh"
chmod +x build.sh
chmod +x build_mul.sh
dos2unix build.sh
dos2unix build_mul.sh

for f in /riscv-tests/isa/rv32ui/*.S; do
filename=$(basename "${f%.*}")
echo $filename
./build.sh $filename
done

for f in /riscv-tests/isa/rv32um/*.S; do
filename=$(basename "${f%.*}")
echo $filename
./build_mul.sh $filename
done
3 changes: 3 additions & 0 deletions _coin/compliance_tests/build_mul.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$CC -static -march=rv32g -mabi=ilp32 -nostdlib -nostartfiles -Wl,--no-warn-rwx-segments -I./ -I./../../ -I/riscv-tests/isa/macros/scalar/ -T./linker/link.ld -o build/$1.elf /riscv-tests/isa/rv32um/$1.S
$QEMU -d in_asm -D build/$1.s build/$1.elf
$DUMP -d build/$1.elf > build/$1_dump.s
21 changes: 21 additions & 0 deletions _coin/compliance_tests/docker-run-coin-compliance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Check if at least two arguments are provided
if [ $# -lt 2 ]; then
echo "Usage: $0 container_name script_name [arguments]"
exit 1
fi

# Extract the first and second arguments
container_name="$1"
script_name="$2"

# Collect all remaining arguments (starting from the third)
arguments="${@:3}"

echo "Using $container_name to execute script $script_name with arguments: $arguments"

docker run --rm -it --name riscv-coin \
-v "$PWD":/riscv-tests \
riscv-coin:latest \
sh -c "chmod +x /riscv-tests/$script_name && /riscv-tests/$script_name $arguments"
24 changes: 24 additions & 0 deletions _coin/compliance_tests/env/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2012-2015, The Regents of the University of California (Regents).
All Rights Reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the Regents nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
Loading