Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

- name: Create artifact archive
run: |
cd snapshot && tar -czf ../honeypot-snapshot-${{ matrix.config }}.tar.gz * && cd ..
cd .cartesi/image && tar -czf ../../honeypot-snapshot-${{ matrix.config }}.tar.gz * && cd ../..
sha256sum honeypot-snapshot-${{ matrix.config }}.tar.gz > honeypot-snapshot-${{ matrix.config }}.tar.gz.sha256

- name: Upload build artifacts
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
*.bin
honeypot
.cartesi
/snapshot
/libcmt
35 changes: 7 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ HARDEN_LDFLAGS = \
-Wl,-z,now
LDFLAGS += -Wl,--build-id=none $(HARDEN_LDFLAGS)

# Machine entrypoint
MACHINE_ENTRYPOINT = /home/dapp/honeypot

# Machine initial kernel and flash drives
MACHINE_FLAGS = \
--ram-image=linux.bin \
--flash-drive=label:root,filename:rootfs.ext2 \
--flash-drive=label:state,length:4096

HONEYPOT_CONFIG = localhost

# Current architecture
Expand All @@ -68,21 +59,11 @@ endif
honeypot: $(SOURCES) $(HEADERS) ## Build honeypot binary
$(CXX) $(CXXFLAGS) $(HARDEN_CXXFLAGS) $(INCS) -o $@ $< $(LDFLAGS) $(LIBS)

snapshot: rootfs.ext2 linux.bin ## Generate cartesi machine genesis snapshot
rm -rf snapshot
cartesi-machine $(MACHINE_FLAGS) --assert-rolling-template --final-hash --store=$@ -- $(MACHINE_ENTRYPOINT)

rootfs.ext2: rootfs.tar ## Generate cartesi machine rootfs EXT2 filesystem
xgenext2fs --block-size 4096 --faketime --readjustment +4096 --tarball $< $@
snapshot: rootfs.Dockerfile $(SOURCES) $(HEADERS) ## Generate cartesi machine genesis snapshot
cartesi-dev build -c cartesi.toml -c cartesi.${HONEYPOT_CONFIG}.toml

rootfs.tar: rootfs.Dockerfile $(SOURCES) $(HEADERS) ## Generate cartesi machine rootfs filesystem using Docker
docker buildx build --progress plain --output type=tar,dest=$@ --file rootfs.Dockerfile --build-arg HONEYPOT_CONFIG=${HONEYPOT_CONFIG} .

linux.bin: ## Download cartesi machine Linux kernel
wget -O linux.bin https://github.com/cartesi/machine-linux-image/releases/download/v0.20.0/linux-6.5.13-ctsi-1-v0.20.0.bin

shell: rootfs.ext2 linux.bin ## Spawn a cartesi machine guest shell for debugging
cartesi-machine $(MACHINE_FLAGS) -v=.:/mnt -u=root -i -- /bin/bash
shell: snapshot ## Spawn a cartesi machine guest shell for debugging
cartesi-dev shell

lint: lint-cpp lint-lua ## Lint C++ and Lua code

Expand All @@ -109,10 +90,8 @@ test-stress: snapshot ## Run stress tests
cd tests && HONEYPOT_CONFIG=${HONEYPOT_CONFIG} lua5.4 honeypot-stress-tests.lua

clean: ## Clean generated files
rm -rf snapshot rootfs.ext2 rootfs.tar honeypot

distclean: clean ## Clean generated and downloaded files
rm -rf linux.bin
cartesi-dev clean
rm -rf honeypot

help: ## Show this help
@sed \
Expand All @@ -121,4 +100,4 @@ help: ## Show this help
-e 's/^\(.\+\):\(.*\)/$(shell tput setaf 6)\1$(shell tput sgr0):\2/' \
$(MAKEFILE_LIST) | column -c2 -t -s :

.PHONY: all shell lint lint-cpp lint-lua format format-cpp format-lua test test-stress clean distclean help
.PHONY: all shell lint lint-cpp lint-lua format format-cpp format-lua test test-stress clean help
2 changes: 2 additions & 0 deletions cartesi.localhost.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[drives.root]
build_args = ["HONEYPOT_CONFIG=localhost"]
2 changes: 2 additions & 0 deletions cartesi.mainnet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[drives.root]
build_args = ["HONEYPOT_CONFIG=mainnet"]
2 changes: 2 additions & 0 deletions cartesi.sepolia.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[drives.root]
build_args = ["HONEYPOT_CONFIG=sepolia"]
16 changes: 16 additions & 0 deletions cartesi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[machine]
entrypoint = "/home/dapp/honeypot"
use_docker_env = false
use_docker_workdir = false

[drives.root]
builder = "docker"
dockerfile = "rootfs.Dockerfile"
tags = ["honeypot:cli"]
extra_size = "16Mb"

[drives.state]
builder = "empty"
size = 4096
format = "raw"
mount = false
2 changes: 1 addition & 1 deletion tests/honeypot-stress-tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local lester = require("third-party.lester")
local bint256 = require("third-party.bint")(256)
local describe, it, expect = lester.describe, lester.it, lester.expect

local MACHINE_STORED_DIR = "../snapshot"
local MACHINE_STORED_DIR = "../.cartesi/image"
local MACHINE_RUNTIME_CONFIG = {
htif = { no_console_putchar = true },
skip_root_hash_check = true,
Expand Down
2 changes: 1 addition & 1 deletion tests/honeypot-tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local lester = require("third-party.lester")
local describe, it, expect = lester.describe, lester.it, lester.expect

local ERC20_ALICE_ADDRESS = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
local MACHINE_STORED_DIR = "../snapshot"
local MACHINE_STORED_DIR = "../.cartesi/image"
local MACHINE_RUNTIME_CONFIG = { skip_root_hash_check = true }

describe("honeypot basic", function()
Expand Down
Loading