Skip to content

Commit 0473884

Browse files
committed
fixup! feat(emulator): bump emulator (v0.21.0) and rootfs (v0.18.0). make it build
1 parent 6c1659b commit 0473884

7 files changed

Lines changed: 52 additions & 14 deletions

File tree

Dockerfile

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

44
# syntax=docker.io/docker/dockerfile:1
55

6-
ARG EMULATOR_VERSION=0.21.0-test5
6+
ARG EMULATOR_VERSION=0.21.0-test6
77

88
# Build directories.
99
ARG GO_BUILD_PATH=/build/cartesi/go
@@ -29,8 +29,8 @@ RUN <<EOF
2929
ARCH=$(dpkg --print-architecture)
3030
wget -O /tmp/cartesi-machine-emulator.deb "https://github.com/cartesi/machine-emulator/releases/download/v${EMULATOR_VERSION}/machine-emulator_${ARCH}.deb"
3131
case "$ARCH" in
32-
amd64) echo "ab6e93c9bb7b9911c59a2ea8ed879f5f8d54b8c9cfa577534f7d3df2d87fdd5b /tmp/cartesi-machine-emulator.deb" | sha256sum --check ;;
33-
arm64) echo "aaae49bc9362e81c00f081e09ad5ad16c9916dd32d355ea016494b7d4e6cee26 /tmp/cartesi-machine-emulator.deb" | sha256sum --check ;;
32+
amd64) echo "df61b4ce4cfef1783dc378ad7647a83a337ac83ba2c78988b0717449d8b9f941 /tmp/cartesi-machine-emulator.deb" | sha256sum --check ;;
33+
arm64) echo "29cea4a43416c4c173c3db7b7892878c5968928c753779e9f0aebdc7524f9759 /tmp/cartesi-machine-emulator.deb" | sha256sum --check ;;
3434
*) echo "unsupported architecture: $ARCH"; exit 1 ;;
3535
esac
3636
apt-get install -y --no-install-recommends /tmp/cartesi-machine-emulator.deb

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,13 @@ withdraw-wallet: cartesi-rollups-cli ## Send a test withdrawal request from the
414414

415415
# Temporary test dependencies target while we are not using distribution packages
416416
DOWNLOADS_DIR = test/downloads
417-
CARTESI_TEST_MACHINE_IMAGES = $(DOWNLOADS_DIR)/linux.bin
417+
CARTESI_TEST_MACHINE_IMAGES = $(DOWNLOADS_DIR)/linux.bin $(DOWNLOADS_DIR)/rootfs.ext2
418418
$(CARTESI_TEST_MACHINE_IMAGES):
419419
@mkdir -p $(DOWNLOADS_DIR)
420420
@wget -nc -i test/dependencies -P $(DOWNLOADS_DIR)
421421
@shasum -ca 256 test/dependencies.sha256
422422
@cd $(DOWNLOADS_DIR) && ln -s rootfs-tools.ext2 rootfs.ext2
423-
@cd $(DOWNLOADS_DIR) && ln -s linux-6.5.13-ctsi-1-v0.20.0.bin linux.bin
423+
@cd $(DOWNLOADS_DIR) && ln -s linux-6.5.13-ctsi-2-uio-test1-v0.21.0.bin linux.bin
424424

425425
download-test-dependencies: | $(CARTESI_TEST_MACHINE_IMAGES)
426426

cmd/cartesi-rollups-machine-tool/main.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package main
66
import (
77
"bytes"
88
"context"
9+
"encoding/base64"
910
"encoding/json"
1011
"errors"
1112
"fmt"
@@ -19,6 +20,7 @@ import (
1920
"github.com/cartesi/rollups-node/internal/model"
2021
"github.com/cartesi/rollups-node/internal/repository"
2122
"github.com/cartesi/rollups-node/internal/repository/factory"
23+
//"github.com/davecgh/go-spew/spew"
2224
"github.com/ethereum/go-ethereum/common"
2325
"github.com/ethereum/go-ethereum/common/hexutil"
2426
"github.com/spf13/cobra"
@@ -392,6 +394,23 @@ func generateMachineProof(
392394
if err := json.Unmarshal(raw, &proof); err != nil {
393395
return nil, fmt.Errorf("parse machine proof: %w", err)
394396
}
397+
398+
// convert the file hashes from base64 to hex
399+
proof.RootHash, err = base64ToHex(proof.RootHash)
400+
if err != nil {
401+
return nil, err
402+
}
403+
proof.TargetHash, err = base64ToHex(proof.TargetHash)
404+
if err != nil {
405+
return nil, err
406+
}
407+
for i := range proof.SiblingHashes {
408+
proof.SiblingHashes[i], err = base64ToHex(proof.SiblingHashes[i])
409+
if err != nil {
410+
return nil, err
411+
}
412+
}
413+
395414
return &proof, nil
396415
}
397416

@@ -478,3 +497,11 @@ func ensure0x(s string) string {
478497
func strip0x(s string) string {
479498
return strings.TrimPrefix(strings.TrimPrefix(s, "0x"), "0X")
480499
}
500+
501+
func base64ToHex(s string) (string, error) {
502+
raw, err := base64.StdEncoding.DecodeString(s)
503+
if err != nil {
504+
return "", fmt.Errorf("expected %s to be a hash in base64. %w", s, err)
505+
}
506+
return common.Hash(raw).Hex(), nil
507+
}

cmd/cartesi-rollups-machine-tool/replay_dave.lua

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

44
local cartesi = require("cartesi")
55

6-
local checkpoint_address = 0xfe0
7-
86
local function usage(message)
97
if message then io.stderr:write(message, "\n") end
108
io.stderr:write(
@@ -75,16 +73,15 @@ end
7573

7674
local function advance_one(machine, input_path, input_number)
7775
local checkpoint = machine:get_root_hash()
78-
machine:write_memory(checkpoint_address, checkpoint)
79-
machine:send_cmio_response(cartesi.CMIO_YIELD_REASON_ADVANCE_STATE, read_all(input_path))
76+
machine:send_cmio_response(checkpoint, cartesi.HTIF_YIELD_REASON_ADVANCE_STATE, read_all(input_path))
8077
run_until_manual_yield(machine)
8178

8279
local _, reason, data = machine:receive_cmio_request()
83-
if reason == cartesi.CMIO_YIELD_MANUAL_REASON_RX_REJECTED then
80+
if reason == cartesi.HTIF_YIELD_MANUAL_REASON_RX_REJECTED then
8481
error(string.format("Dave replay input %d was rejected", input_number))
85-
elseif reason == cartesi.CMIO_YIELD_MANUAL_REASON_TX_EXCEPTION then
82+
elseif reason == cartesi.HTIF_YIELD_MANUAL_REASON_TX_EXCEPTION then
8683
error(string.format("Dave replay input %d raised an exception", input_number))
87-
elseif reason ~= cartesi.CMIO_YIELD_MANUAL_REASON_RX_ACCEPTED then
84+
elseif reason ~= cartesi.HTIF_YIELD_MANUAL_REASON_RX_ACCEPTED then
8885
error(string.format("Dave replay input %d ended with unexpected yield reason %s", input_number, tostring(reason)))
8986
end
9087
if #data ~= 32 then

test/dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
https://github.com/cartesi/image-kernel/releases/download/v0.20.0/linux-6.5.13-ctsi-1-v0.20.0.bin
1+
https://github.com/cartesi/image-kernel/releases/download/v0.21.0-test1/linux-6.5.13-ctsi-2-uio-test1-v0.21.0.bin
22
https://github.com/cartesi/machine-guest-tools/releases/download/v0.18.0-test7/rootfs-tools.ext2

test/dependencies.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
65dd100ff6204346ac2f50f772721358b5c1451450ceb39a154542ee27b4c947 test/downloads/linux-6.5.13-ctsi-1-v0.20.0.bin
1+
9fb5aaa623f35c0ef2138c8dadf1b0a1e388e0f51758cb6a5477ec5cecd3a029 test/downloads/linux-6.5.13-ctsi-2-uio-test1-v0.21.0.bin
22
274b92629d5568fcb62a309398c7ab95bf6e2c6538c346eaf41e59b8f39f4035 test/downloads/rootfs-tools.ext2

test/integration/withdrawal_lifecycle_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"bytes"
1010
"context"
1111
"encoding/json"
12+
"encoding/base64"
1213
"errors"
1314
"fmt"
1415
"math/big"
@@ -28,6 +29,7 @@ import (
2829
"github.com/cartesi/rollups-node/pkg/contracts/ierc20metadata"
2930
"github.com/cartesi/rollups-node/pkg/contracts/iquorum"
3031
"github.com/cartesi/rollups-node/pkg/ethutil"
32+
"github.com/davecgh/go-spew/spew"
3133
"github.com/ethereum/go-ethereum/accounts/abi"
3234
"github.com/ethereum/go-ethereum/accounts/abi/bind"
3335
"github.com/ethereum/go-ethereum/common"
@@ -580,7 +582,9 @@ func (s *WithdrawalLifecycleSuite) generateWithdrawalProofs(
580582
var replaySummary struct {
581583
MachineRoot string `json:"machine_root"`
582584
}
585+
fmt.Print("1.", string(replayOut))
583586
r.NoError(json.Unmarshal([]byte(replayOut), &replaySummary), "parse machine replay summary")
587+
spew.Dump(replaySummary)
584588
r.Equal(strings.ToLower(finalEpoch.MachineHash.Hex()), strings.ToLower(replaySummary.MachineRoot),
585589
"replayed machine root must match finalized epoch machine hash")
586590

@@ -600,7 +604,9 @@ func (s *WithdrawalLifecycleSuite) generateWithdrawalProofs(
600604
AccountIndex string `json:"account_index"`
601605
MachineRoot string `json:"machine_root"`
602606
}
607+
fmt.Print("2.", string(proveOut))
603608
r.NoError(json.Unmarshal([]byte(proveOut), &proveSummary), "parse accounts-drive proof summary")
609+
spew.Dump(proveSummary)
604610
r.Equal(strings.ToLower(finalEpoch.MachineHash.Hex()), strings.ToLower(proveSummary.MachineRoot),
605611
"proof machine root must match finalized epoch machine hash")
606612
r.NotEmpty(proveSummary.AccountIndex, "proof summary must include account index")
@@ -827,3 +833,11 @@ func listWithdrawals(
827833
}
828834
return rpcResp.Result, nil
829835
}
836+
837+
func base64ToHex(s string) (string, error) {
838+
raw, err := base64.StdEncoding.DecodeString(s)
839+
if err != nil {
840+
return "", fmt.Errorf("expected %s to be a hash in base64. %w", s, err)
841+
}
842+
return common.Hash(raw).Hex(), nil
843+
}

0 commit comments

Comments
 (0)