Skip to content

Commit 2629728

Browse files
committed
Merge Tester project into ZiskGuest
1 parent 6d95550 commit 2629728

File tree

9 files changed

+45
-68
lines changed

9 files changed

+45
-68
lines changed

.github/workflows/stateless-tests.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ concurrency:
2020
cancel-in-progress: true
2121

2222
env:
23-
EXPECTED_BLOCK_HASH: '0x2528a96c6c16ff80a8c92b84d7202f8250d74c0dd9e520a536179467f7e284b8'
23+
EXPECTED_BLOCK_HASH: "0x2528a96c6c16ff80a8c92b84d7202f8250d74c0dd9e520a536179467f7e284b8"
2424

2525
jobs:
2626
test-zisk:
@@ -37,8 +37,8 @@ jobs:
3737
uses: docker/setup-buildx-action@v3
3838

3939
- name: Prepare input
40-
working-directory: tools/Stateless/Tester
41-
run: dotnet run -c release --project Tester.csproj -- ../ZiskGuest/bin/input.bin
40+
working-directory: tools/Stateless/ZiskGuest
41+
run: dotnet run -c release -- bin/input.bin
4242

4343
- name: Build Nethermind
4444
working-directory: tools/Stateless
@@ -59,7 +59,7 @@ jobs:
5959
fi
6060
6161
- name: Upload guest binary
62-
if: github.event.inputs.upload == 'true'
62+
if: github.event.inputs.upload
6363
uses: actions/upload-artifact@v4
6464
with:
6565
name: nethermind-zisk
@@ -84,22 +84,22 @@ jobs:
8484

8585
- name: Build Nethermind
8686
working-directory: tools/Stateless
87-
run: make build-tester
87+
run: make build-qemu
8888

8989
- name: Test Nethermind
90-
working-directory: tools/Stateless/Tester
90+
working-directory: tools/Stateless/ZiskGuest
9191
run: |
92-
docker build --platform linux/amd64 -t zkevm .
92+
docker build -f Dockerfile.qemu -t zkevm .
9393
block_hash=$(docker run --rm zkevm)
9494
if [[ "$block_hash" != "$EXPECTED_BLOCK_HASH" ]]; then
9595
echo "::error::Unexpected block hash: $block_hash"
9696
exit 1
9797
fi
9898
9999
- name: Upload guest binary
100-
if: github.event.inputs.upload == 'true'
100+
if: github.event.inputs.upload
101101
uses: actions/upload-artifact@v4
102102
with:
103103
name: nethermind-zkevm
104-
path: tools/Stateless/Tester/bin/nethermind
104+
path: tools/Stateless/ZiskGuest/bin/nethermind
105105
if-no-files-found: error

tools/Stateless/Makefile

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
MAKEFILE_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
55
ARTIFACTS_DIR := $(abspath $(MAKEFILE_DIR)/../artifacts/bin)
6-
TESTER_DIR := $(MAKEFILE_DIR)/Tester
7-
ZISK_DIR := $(MAKEFILE_DIR)/ZiskGuest
6+
GUEST_DIR := $(MAKEFILE_DIR)/ZiskGuest
87
BIN_DIR := /nethermind/bin
98
SRC_DIR := /nethermind/src
109

@@ -69,66 +68,58 @@ BFLAT_REFS := \
6968
DOCKER_RUN := docker run --platform linux/amd64 --rm \
7069
-e DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 \
7170
-e DOTNET_TYPELOADER_TRACE_INTERFACE_RESOLUTION=0 \
72-
-w $(SRC_DIR)
71+
-w $(SRC_DIR) \
72+
--mount type=bind,source="$(ARTIFACTS_DIR)/ZiskGuest/release",target=$(BIN_DIR) \
73+
--mount type=bind,source="$(GUEST_DIR)",target=$(SRC_DIR) \
74+
nethermindeth/bflat-riscv64:latest \
75+
$(BFLAT_BUILD) \
76+
$(BFLAT_REFS)
7377

74-
build-dotnet-tester:
75-
dotnet build -c release -p:EnableZkEvm=true $(TESTER_DIR)/Tester.csproj
78+
build-dotnet:
79+
dotnet build -c release -p:EnableZkEvm=true $(GUEST_DIR)/ZiskGuest.csproj
7680

77-
build-dotnet-zisk:
78-
dotnet build -c release -p:EnableZkEvm=true $(ZISK_DIR)/ZiskGuest.csproj
81+
build-qemu: build-dotnet
82+
$(DOCKER_RUN) --libc zisk_sim -d ZK_EVM \
83+
$(SRC_DIR)/TestProgram.cs
84+
mkdir -p $(GUEST_DIR)/bin && \
85+
mv -f $(GUEST_DIR)/TestProgram $(GUEST_DIR)/bin/nethermind
7986

80-
build-tester: build-dotnet-tester
87+
build-zisk: build-dotnet
8188
$(DOCKER_RUN) \
82-
--mount type=bind,source="$(ARTIFACTS_DIR)/Tester/release",target=$(BIN_DIR) \
83-
--mount type=bind,source="$(TESTER_DIR)",target=$(SRC_DIR) \
84-
nethermindeth/bflat-riscv64:latest \
85-
$(BFLAT_BUILD) --libc zisk_sim -d ZK_EVM $(BFLAT_REFS) \
86-
$(SRC_DIR)/Program.cs
87-
mkdir -p $(TESTER_DIR)/bin && \
88-
mv -f $(TESTER_DIR)/Program $(TESTER_DIR)/bin/nethermind
89-
90-
build-zisk: build-dotnet-zisk
91-
$(DOCKER_RUN) \
92-
--mount type=bind,source="$(ARTIFACTS_DIR)/ZiskGuest/release",target=$(BIN_DIR) \
93-
--mount type=bind,source="$(ZISK_DIR)",target=$(SRC_DIR) \
94-
nethermindeth/bflat-riscv64:latest \
95-
$(BFLAT_BUILD) --libc zisk $(BFLAT_REFS) \
89+
--libc zisk \
9690
-r $(BIN_DIR)/Nethermind.ZiskBindings.dll \
9791
--extra-ld $(BIN_DIR)/runtimes/linux-riscv64/native/libziskos.a \
9892
--extlib $(BIN_DIR)/libziskos.bflat.manifest \
9993
$(SRC_DIR)/Program.cs
100-
mkdir -p $(ZISK_DIR)/bin && \
101-
mv -f $(ZISK_DIR)/Program.patched $(ZISK_DIR)/bin/nethermind && \
102-
rm -f $(ZISK_DIR)/Program
94+
mkdir -p $(GUEST_DIR)/bin && \
95+
mv -f $(GUEST_DIR)/Program.patched $(GUEST_DIR)/bin/nethermind && \
96+
rm -f $(GUEST_DIR)/Program
10397

104-
run-tester: build-tester
105-
docker build --platform linux/amd64 -t nethermind-zkevm $(TESTER_DIR)
98+
run-qemu: build-qemu
99+
docker build --platform linux/amd64 -f $(GUEST_DIR)/Dockerfile.qemu -t nethermind-zkevm $(GUEST_DIR)
106100
docker run --rm -it nethermind-zkevm
107101

108102
run-zisk: build-zisk
109-
[ -f "$(ZISK_DIR)/bin/input.bin" ] || \
110-
dotnet run -c release --project $(TESTER_DIR)/Tester.csproj -- $(ZISK_DIR)/bin/input.bin
103+
[ -f "$(GUEST_DIR)/bin/input.bin" ] || \
104+
dotnet run -c release --no-restore --project $(GUEST_DIR)/ZiskGuest.csproj -- $(GUEST_DIR)/bin/input.bin
111105
docker run --rm -it -e RUST_BACKTRACE=full \
112-
--mount type=bind,source="$(ZISK_DIR)/bin",target=/n \
106+
--mount type=bind,source="$(GUEST_DIR)/bin",target=/n \
113107
nethermindeth/zisk@sha256:1b38e92264c30a4109fdb47f3b175324544085e36b9dde0abf7570c2b1e3312b \
114108
ziskemu -e /n/nethermind -i /n/input.bin
115109

116110
clean:
117111
rm -rf \
118-
$(TESTER_DIR)/bin/** \
119-
$(TESTER_DIR)/Program \
120-
$(TESTER_DIR)/Program.o \
121-
$(ZISK_DIR)/bin/** \
122-
$(ZISK_DIR)/Program \
123-
$(ZISK_DIR)/Program.patched \
124-
$(ZISK_DIR)/Program.o
112+
$(GUEST_DIR)/bin/** \
113+
$(GUEST_DIR)/*.o \
114+
$(GUEST_DIR)/Program \
115+
$(GUEST_DIR)/Program.patched \
116+
$(GUEST_DIR)/TestProgram
125117
dotnet clean -c release $(MAKEFILE_DIR)/Stateless.slnx
126118

127119
.PHONY: \
128-
build-dotnet-tester \
129-
build-dotnet-zisk \
130-
build-tester \
120+
build-dotnet \
121+
build-qemu \
131122
build-zisk \
132-
run-tester \
123+
run-qemu \
133124
run-zisk \
134125
clean

tools/Stateless/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Building these projects requires Docker and a Linux environment with .NET instal
55
### Projects
66

77
- [Executor](./Executor/) : The core stateless execution and data serialization
8-
- [Tester](./Tester/) : A testing playground to verify execution on RISC-V
98
- [ZiskGuest](./ZiskGuest/) : The Nethermind guest app intended to run exclusively on Zisk
109

1110
### Build

tools/Stateless/Stateless.slnx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
<Project Path="../../src/Nethermind/Nethermind.TxPool/Nethermind.TxPool.csproj" />
2323
</Folder>
2424
<Project Path="Executor/Executor.csproj" />
25-
<Project Path="Tester/Tester.csproj" />
2625
<Project Path="ZiskGuest/ZiskGuest.csproj" />
2726
</Solution>
2827

tools/Stateless/Tester/Tester.csproj

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
using Nethermind.Specs;
1515
using Nethermind.Stateless.Execution;
1616

17-
namespace Nethermind.Stateless.Tester;
17+
namespace Nethermind.Stateless.ZiskGuest;
1818

19-
class Program
19+
class TestProgram
2020
{
2121
static void Main(
2222
#if !ZK_EVM
@@ -35,7 +35,7 @@ string[] args
3535
// where the input data for the Zisk guest should be written
3636
if (args.Length == 1 && !string.IsNullOrWhiteSpace(args[0]))
3737
{
38-
byte[] data = InputSerializer.Serialize(suggestedBlock, witness, (uint)specProvider.ChainId);
38+
byte[] data = InputSerializer.Serialize(suggestedBlock, witness, specProvider.ChainId);
3939
string? dir = Path.GetDirectoryName(args[0]);
4040

4141
if (dir is not null)

tools/Stateless/ZiskGuest/ZiskGuest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<ImplicitUsings>disable</ImplicitUsings>
77
<RootNamespace>Nethermind.Stateless.ZiskGuest</RootNamespace>
8+
<StartupObject>$(RootNamespace).TestProgram</StartupObject>
89
</PropertyGroup>
910

1011
<ItemGroup>

0 commit comments

Comments
 (0)