Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build/improvements evmos build #169

Closed
wants to merge 4 commits into from
Closed
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
5 changes: 4 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
# ZBC_FHE_TOOL_PATH=../zbc-fhe-tool
#LOCAL_BUILD=false
LOCAL_BUILD=true
GOPRIVATE=github.com/zama-ai/*

# If false, FHEVM_TFHE_CLI_VERSION version will be cloned,
# built and used, docker image otherwise
USE_DOCKER_FOR_FHE_KEYS=true
26 changes: 11 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ TFHE_RS_PATH ?= $(WORKDIR)/tfhe-rs
TFHE_RS_EXISTS := $(shell test -d $(TFHE_RS_PATH)/.git && echo "true" || echo "false")
TFHE_RS_VERSION ?= 0.3.0-beta.0


USE_DOCKER_FOR_FHE_KEYS ?= true
FHEVM_TFHE_CLI_PATH ?= $(WORKDIR)/fhevm-tfhe-cli
FHEVM_TFHE_CLI_PATH_EXISTS := $(shell test -d $(FHEVM_TFHE_CLI_PATH)/.git && echo "true" || echo "false")
FHEVM_TFHE_CLI_VERSION ?= v0.1.1-renaming
FHEVM_TFHE_CLI_VERSION ?= v0.1.2

FHEVM_REQUIRES_DB_PATH ?= $(WORKDIR)/fhevm-requires-db
FHEVM_REQUIRES_DB_PATH_EXISTS := $(shell test -d $(FHEVM_REQUIRES_DB_PATH)/.git && echo "true" || echo "false")
FHEVM_REQUIRES_DB_VERSION ?= v0.1.0

FHEVM_SOLIDITY_PATH ?= $(WORKDIR)/fhevm-solidity
FHEVM_SOLIDITY_PATH_EXISTS := $(shell test -d $(FHEVM_SOLIDITY_PATH)/.git && echo "true" || echo "false")
FHEVM_SOLIDITY_VERSION ?= ci/use-fhevm-tfhe-cli-multiarch
FHEVM_SOLIDITY_VERSION ?= main

ETHERMINT_VERSION := $(shell ./scripts/get_module_version.sh go.mod zama.ai/ethermint)
GO_ETHEREUM_VERSION := $(shell ./scripts/get_module_version.sh go.mod zama.ai/go-ethereum)
Expand Down Expand Up @@ -321,7 +321,7 @@ $(WORKDIR)/:
$(info WORKDIR)
mkdir -p $(WORKDIR)

check-all-test-repo: check-fhevm-tfhe-cli check-fhevm-solidity
check-all-test-repo: check-fhevm-solidity

update-go-mod:
@cp go.mod $(UPDATE_GO_MOD)
Expand All @@ -339,15 +339,6 @@ build-base-image:


build-local-docker:
ifeq ($(GITHUB_ACTIONS),true)
$(info Running in a GitHub Actions workflow)
else
$(info Not running in a GitHub Actions workflow)
@$(MAKE) build-base-image
@$(MAKE) clone_go_ethereum
@$(MAKE) clone_ethermint
endif
$(MAKE) update-go-mod
$(MAKE) check-tfhe-rs
@docker compose -f docker-compose/docker-compose.local.yml build evmosnodelocal

Expand All @@ -368,9 +359,14 @@ build-from-registry:


generate_fhe_keys:
@echo 'generate_fhe_keys'
# Generate fhe global keys and copy into volumes
ifeq ($(USE_DOCKER_FOR_FHE_KEYS),true)
$(info USE_DOCKER_FOR_FHE_KEYS is set, use docker)
@bash ./scripts/prepare_volumes_from_fhe_tool_docker.sh $(FHEVM_TFHE_CLI_VERSION)
else
$(info USE_DOCKER_FOR_FHE_KEYS is not set, build from sources)
@$(MAKE) check-fhevm-tfhe-cli
@bash ./scripts/prepare_volumes_from_fhe_tool.sh $(FHEVM_TFHE_CLI_PATH)/target/release
endif


run_evmos:
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ To execute the e2e test, here are the dependencies:
| Name | Type | Variable name | where it is defined |
| ------------- | ---------- | --------------------- | ------------------- |
| evmos | repository | LOCAL_BUILD | .env |
| zbc-solidity | repository | ZBC_SOLIDITY_VERSION | Makefile/.env |
| zbc-fhe-tool | repository | ZBC_FHE_TOOL_VERSION | Makefile/.env |
| fhevm-solidity| repository | ZBC_SOLIDITY_VERSION | Makefile/.env |
| fhevm-tfhe-cli | repository | ZBC_FHE_TOOL_VERSION | Makefile/.env |
| zbc-oracle-db | repository | ZBC_ORACLE_DB_VERSION | Makefile/.env |


Expand All @@ -164,11 +164,11 @@ make stop_evmos


- check you have all the needed repositories
- zbc-fhe-tool
- zbc-solidity
- fhevm-tfhe-cli
- fhevm-solidity
- zbc-oracledb
- init evmos node by calling /config/setup.sh file
- generate fhe keys using zbc-fhe-tool based on scripts/prepare_volumes_from_fhe_tool.sh script
- generate fhe keys using fhevm-tfhe-cli based on scripts/prepare_volumes_from_fhe_tool.sh script
- copy them at the right folder using scripts/prepare_demo_local.sh script
- start evmosnodelocal0 and oracledb (local build) using docker-compose/docker-compose.local.yml file
- run the e2e test
Expand Down Expand Up @@ -222,8 +222,8 @@ make stop_evmos
| evmos | evmos | LOCAL_BUILD | .env |
| ghcr.io/zama-ai/evmos-node | docker image name | hard-coded | docker-compose.validator.yml |
| oracle-db-service | docker image name | hard-coded | docker-compose.validator.yml |
| zbc-solidity | repository | ZBC_SOLIDITY_VERSION | Makefile/.env |
| zbc-fhe-tool | repository | ZBC_FHE_TOOL_VERSION | Makefile/.env |
| fhevm-solidity | repository | ZBC_SOLIDITY_VERSION | Makefile/.env |
| fhevm-tfhe-cli | repository | ZBC_FHE_TOOL_VERSION | Makefile/.env |
| zbc-oracle-db | repository | ZBC_ORACLE_DB_VERSION | Makefile/.env |


Expand All @@ -236,7 +236,7 @@ Note:
<details>
<summary>Troubleshoot ghcr.io</summary>

Here is a tutorial on [how to manage ghcr.io access](https://github.com/zama-ai/zbc-fhe-tool#using-the-published-image-easiest-way).
Here is a tutorial on [how to manage ghcr.io access](https://github.com/zama-ai/fhevm-tfhe-cli#using-the-published-image-easiest-way).

If you get trouble to pull image from ghcri.io, one can build it locally with
```bash
Expand Down
6 changes: 2 additions & 4 deletions docker/Dockerfile.evmos-node.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/zama-ai/zama-zbc-build:latest AS build-env
FROM ghcr.io/zama-ai/zama-zbc-build:v0.1.3 AS build-env

ENV LD_LIBRARY_PATH=/usr/lib/tfhe
ADD . /src/evmos
Expand All @@ -7,16 +7,14 @@ WORKDIR /src/evmos

RUN mkdir -p /usr/include

RUN cp go.mod.updated /src/evmos/go.mod

RUN tail /src/evmos/go.mod

RUN make build
RUN ls /src/evmos
RUN ls /src/evmos/build
RUN mkdir -p /src/evmos/build

FROM ghcr.io/zama-ai/zama-zbc-build:latest
FROM ghcr.io/zama-ai/zama-zbc-build:v0.1.3

RUN apt-get update -y
RUN apt-get install ca-certificates jq -y
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ replace (
replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0

// TODO: Remove once our forks are public.
replace github.com/ethereum/go-ethereum v1.10.19 => github.com/zama-ai/go-ethereum v0.1.7
replace github.com/ethereum/go-ethereum v1.10.19 => github.com/zama-ai/go-ethereum v0.1.8-beta

replace github.com/evmos/ethermint v0.19.3 => github.com/zama-ai/ethermint v0.1.2
replace github.com/evmos/ethermint v0.19.3 => github.com/zama-ai/ethermint v0.1.3-beta
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -862,10 +862,10 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/zama-ai/ethermint v1.0.0-test h1:x00Rxncw8qhzvV75S9lPbcmYBumGZ8ZZ8lGWgDawjHY=
github.com/zama-ai/ethermint v1.0.0-test/go.mod h1:JEqkvu6ZC6GV0nq7txpzmaRQdfDzwFay1SRumKsEkg8=
github.com/zama-ai/go-ethereum v1.0.1-test h1:WpTU7WP2W9fyZZYD+n0t26S1Njk6lzb3szKVgvVZ/SE=
github.com/zama-ai/go-ethereum v1.0.1-test/go.mod h1:IJBNMtzKcNHPtllYihy6BL2IgK1u+32JriaTbdt4v+w=
github.com/zama-ai/ethermint v0.1.2 h1:Zs7X5o6cb2hiZmWIrZICPqv5sK8QtackTaA2tK0djI0=
github.com/zama-ai/ethermint v0.1.2/go.mod h1:JEqkvu6ZC6GV0nq7txpzmaRQdfDzwFay1SRumKsEkg8=
github.com/zama-ai/go-ethereum v0.1.7 h1:krnwfFJajqn7lROjkt8wbCcthl2XTpGQCzkANjEnUig=
github.com/zama-ai/go-ethereum v0.1.7/go.mod h1:IJBNMtzKcNHPtllYihy6BL2IgK1u+32JriaTbdt4v+w=
github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8=
github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand Down
5 changes: 0 additions & 5 deletions scripts/prepare_volumes_from_fhe_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,4 @@ echo "Copying $key to $NETWORK_KEYS_PRIVATE_PATH, please wait ..."
cp $KEYS_FULL_PATH/$key $NETWORK_KEYS_PRIVATE_PATH/cks


echo "###########################################################"
echo "If you want to execute a local test using the same keys,"
echo "please run the following command in zbc-solidity:"
echo "prepare_fhe_keys_from_fhe_tool.sh $KEYS_FULL_PATH"
echo "###########################################################"

67 changes: 67 additions & 0 deletions scripts/prepare_volumes_from_fhe_tool_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# This bash script creates global fhe keys
# and copy them to the right folder in volumes directory.
# It accepts the versin of fhevm-tfhe-cli as parameter.

set -Eeuo pipefail

if [ "$#" -ne 1 ]; then
echo "Please give the version of fhevm-tfhe-cli"
echo "Example: $(basename $0) v0.1.2"
exit
fi

FHEVM_TFHE_CLI_VERSION=$1
BINARY_NAME="fhevm-tfhe-cli"
DOCKER_IMAGE=ghcr.io/zama-ai/fhevm-tfhe-cli:$FHEVM_TFHE_CLI_VERSION
CURRENT_FOLDER=$PWD


KEYS_FULL_PATH=$CURRENT_FOLDER/res/keys
mkdir -p $KEYS_FULL_PATH

docker run -v $PWD:/usr/local/app $DOCKER_IMAGE $BINARY_NAME generate-keys -d res/keys


echo "###########################################################"
echo "Keys creation is done, they are stored in $KEYS_FULL_PATH"
echo "###########################################################"


NETWORK_KEYS_PUBLIC_PATH=./volumes/network-public-fhe-keys
NETWORK_KEYS_PRIVATE_PATH=./volumes/network-private-fhe-keys

MANDATORY_KEYS_LIST=('sks' 'cks' 'pks')

for key in "${MANDATORY_KEYS_LIST[@]}"
do
if [ ! -f "$KEYS_FULL_PATH/$key" ]; then
echo "#####ATTENTION######"
echo "$key does not exist in $KEYS_FULL_PATH!"
echo "####################"
exit
fi
done

echo "###########################################################"
echo "All the required keys exist in $KEYS_FULL_PATH"
echo "###########################################################"

mkdir -p $NETWORK_KEYS_PUBLIC_PATH
mkdir -p $NETWORK_KEYS_PRIVATE_PATH

key="sks"
echo "Copying $key to $NETWORK_KEYS_PUBLIC_PATH, please wait ..."
cp $KEYS_FULL_PATH/$key $NETWORK_KEYS_PUBLIC_PATH/sks

key="pks"
echo "Copying $key to $NETWORK_KEYS_PUBLIC_PATH, please wait ..."
cp $KEYS_FULL_PATH/$key $NETWORK_KEYS_PUBLIC_PATH/pks

key="cks"
echo "Copying $key to $NETWORK_KEYS_PRIVATE_PATH, please wait ..."
cp $KEYS_FULL_PATH/$key $NETWORK_KEYS_PRIVATE_PATH/cks



Loading