Skip to content

Commit

Permalink
Merge pull request #26 from zama-ai/chore/use-ethermint-dev-image
Browse files Browse the repository at this point in the history
feat(fhevm): use dev image
  • Loading branch information
leventdem authored Jul 15, 2024
2 parents f167184 + f763206 commit ee042c4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 126 deletions.
121 changes: 9 additions & 112 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,12 @@ KEY_GEN = false
BINDIR ?= $(GOPATH)/bin
ETHERMINT_BINARY = ethermintd
ETHERMINT_DIR = ethermint
BUILDDIR ?= $(CURDIR)/build



WORKDIR ?= $(CURDIR)/work_dir
SUDO := $(shell which sudo)



# This version must the same as in docker-compose-full.yml
# TODO add check
KMS_DEV_VERSION ?= v0.7.1

FHEVM_SOLIDITY_REPO ?= fhevm
FHEVM_SOLIDITY_PATH ?= $(WORKDIR)/$(FHEVM_SOLIDITY_REPO)
FHEVM_SOLIDITY_PATH_EXISTS := $(shell test -d $(FHEVM_SOLIDITY_PATH)/.git && echo "true" || echo "false")
FHEVM_SOLIDITY_VERSION ?= V0.5.1

export GO111MODULE = on

# Default target executed when no arguments are given to make.
Expand All @@ -33,121 +21,30 @@ default_target: all

# process build tags



###############################################################################
### Single validator ###
###############################################################################


$(WORKDIR)/:
$(info WORKDIR)
mkdir -p $(WORKDIR)

clone-fhevm-solidity: $(WORKDIR)/
$(info Cloning fhevm-solidity version $(FHEVM_SOLIDITY_VERSION))
cd $(WORKDIR) && git clone https://github.com/zama-ai/fhevm.git
cd $(FHEVM_SOLIDITY_PATH) && git checkout $(FHEVM_SOLIDITY_VERSION)

check-fhevm-solidity: $(WORKDIR)/
$(info check-fhevm-solidity)
ifeq ($(FHEVM_SOLIDITY_PATH_EXISTS), true)
@echo "fhevm-solidity exists in $(FHEVM_SOLIDITY_PATH)"
@if [ ! -d $(WORKDIR)/fhevm ]; then \
echo 'fhevm-solidity is not available in $(WORKDIR)'; \
echo "FHEVM_SOLIDITY_PATH is set to a custom value"; \
else \
echo 'fhevm-solidity is already available in $(WORKDIR)'; \
fi
else
@echo "fhevm-solidity does not exist"
echo "We clone it for you!"
echo "If you want your own version please update FHEVM_SOLIDITY_PATH pointing to your fhevm-solidity folder!"
$(MAKE) clone-fhevm-solidity
endif


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


change-running-node-owner:
@$(SUDO) chown -R $(USER): running_node/


init-ethermint-node:
@$(MAKE) init-ethermint-node-from-registry

init-ethermint-node-from-registry:
@docker compose -f docker-compose/docker-compose-full.yml run fhevm-validator bash /config/setup.sh
$(MAKE) change-running-node-owner
$(MAKE) generate-fhe-keys-registry

generate-fhe-keys-registry:
ifeq ($(KEY_GEN),false)
@echo "KEY_GEN is false, executing corresponding commands..."
@bash ./scripts/copy_fhe_keys.sh $(KMS_DEV_VERSION) $(PWD)/running_node/node2/.ethermintd/zama/keys/network-fhe-keys $(PWD)/running_node/node2/.ethermintd/zama/keys/kms-fhe-keys
else ifeq ($(KEY_GEN),true)
@echo "KEY_GEN is true, executing corresponding commands..."
@bash ./scripts/prepare_volumes_from_kms_core.sh $(KMS_DEV_VERSION) $(PWD)/running_node/node2/.ethermintd/zama/keys/network-fhe-keys $(PWD)/running_node/node2/.ethermintd/zama/keys/kms-fhe-keys
else
@echo "KEY_GEN is set to an unrecognized value: $(KEY_GEN)"
endif


generate-fhe-keys:
@bash ./scripts/copy_fhe_keys.sh $(KMS_DEV_VERSION) $(PWD)/network-fhe-keys $(PWD)/kms-fhe-keys

run-full:
@docker compose -f docker-compose/docker-compose-full.yml -f docker-compose/docker-compose-full.override.yml up --detach
$(MAKE) generate-fhe-keys
@docker compose -f docker-compose/docker-compose-full.yml up --detach
@echo 'sleep a little to let the docker start up'
sleep 10
sleep 5

stop-full:
@docker compose -f docker-compose/docker-compose-full.yml down

TEST_FILE := run_tests.sh
TEST_IF_FROM_REGISTRY :=

run-e2e-test: check-all-test-repo
@cd $(FHEVM_SOLIDITY_PATH) && npm ci
@sleep 5
@./scripts/fund_test_addresses_docker.sh
@cd $(FHEVM_SOLIDITY_PATH) && cp .env.example .env
@cd $(FHEVM_SOLIDITY_PATH) && npm i
@cd $(FHEVM_SOLIDITY_PATH) && ./setup-local-fhevm.sh
@cd $(FHEVM_SOLIDITY_PATH) && npx hardhat test


prepare-e2e-test: check-all-test-repo
@cd $(FHEVM_SOLIDITY_PATH) && npm ci
@sleep 5
@./scripts/fund_test_addresses_docker.sh
@cd $(FHEVM_SOLIDITY_PATH) && cp .env.example .env
@cd $(FHEVM_SOLIDITY_PATH) && npm i
@cd $(FHEVM_SOLIDITY_PATH) && ./setup-local-fhevm.sh

run-async-test:
@cd $(FHEVM_SOLIDITY_PATH) && npx hardhat test --grep 'test async decrypt uint8'

run-true-input-async-test:
@cd $(FHEVM_SOLIDITY_PATH) && npx hardhat test --grep 'test async decrypt uint64 non-trivial'

e2e-test:
@$(MAKE) check-all-test-repo
@$(MAKE) init-ethermint-node-from-registry
$(MAKE) run-full
$(MAKE) run-e2e-test
$(MAKE) stop-full


clean-node-storage:
@echo 'clean node storage'
sudo rm -rf running_node

clean: clean-node-storage
clean:
$(MAKE) stop-full
rm -rf $(BUILDDIR)/
rm -rf $(WORKDIR)/
rm -rf network-fhe-keys
rm -rf kms-fhe-keys


print-info:
@echo 'KMS_DEV_VERSION: $(KMS_DEV_VERSION) for KEY_GEN---extracted from Makefile'
@echo 'FHEVM_SOLIDITY_VERSION: $(FHEVM_SOLIDITY_VERSION) ---extracted from Makefile'
@bash scripts/get_repository_info.sh fhevm $(FHEVM_SOLIDITY_PATH)
11 changes: 0 additions & 11 deletions docker-compose/docker-compose-full.override.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docker-compose/docker-compose-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ services:
fhevm-validator:
environment:
- TFHE_EXECUTOR_CONTRACT_ADDRESS=0x05fD9B5EFE0a996095f42Ed7e77c390810CF660c
image: ghcr.io/zama-ai/ethermint-node:v0.5.0
image: ghcr.io/zama-ai/ethermint-dev-node:v0.5.0-2
ports:
- "26656-26657:26656-26657"
- "8545-8546:8545-8546"
volumes:
- ../running_node/node2:/root:Z
- $PWD/network-fhe-keys:/network-fhe-keys:Z
- ../setup.sh:/config/setup.sh:Z
security_opt:
- no-new-privileges:true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"task:getEthereumAddress": "hardhat task:getEthereumAddress",
"task:deployERC20": "hardhat task:deployERC20",
"task:accounts": "hardhat task:accounts",
"fhevm:start": "make init-ethermint-node && make run-full && ./scripts/fund_test_addresses_docker.sh && ./launch-fhevm.sh",
"fhevm:start": "make run-full && ./scripts/fund_test_addresses_docker.sh && ./launch-fhevm.sh",
"fhevm:stop": "make clean",
"fhevm:restart": "fhevm:stop && fhevm:start",
"fhevm:faucet": "npm run fhevm:faucet:alice && sleep 5 && npm run fhevm:faucet:bob && sleep 5 && npm run fhevm:faucet:carol && sleep 5 && npm run fhevm:faucet:dave && sleep 5 && npm run fhevm:faucet:eve",
Expand Down

0 comments on commit ee042c4

Please sign in to comment.