WIP: add solidity deposit contract CI workflow

Export `DAPP_LIB`

Fix .gitmodules

update CI solc version

Kick cache

Make metadata remain the same
This commit is contained in:
Hsiao-Wei Wang 2020-07-23 22:16:40 +08:00
parent 487d19ccb1
commit 80fb126401
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
5 changed files with 122 additions and 62 deletions

View File

@ -145,54 +145,95 @@ jobs:
- run:
name: Run linter
command: make lint
install_deposit_contract_compiler:
# install_deposit_contract_compiler:
# docker:
# # The deposit contract compiler is pinned to python 3.7 because of the vyper version pin.
# - image: circleci/python:3.7
# working_directory: ~/specs-repo
# steps:
# - restore_cache:
# key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
# - restore_deposit_contract_compiler_cached_venv
# - run:
# name: Install deposit contract compiler requirements
# command: make install_deposit_contract_compiler
# - save_deposit_contract_compiler_cached_venv
# install_deposit_contract_tester:
# docker:
# - image: circleci/python:3.8
# working_directory: ~/specs-repo
# steps:
# - restore_cache:
# key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
# - restore_deposit_contract_tester_cached_venv
# - run:
# name: Install deposit contract tester requirements
# command: make install_deposit_contract_tester
# - save_deposit_contract_tester_cached_venv
# test_compile_deposit_contract:
# docker:
# - image: circleci/python:3.7
# working_directory: ~/specs-repo
# steps:
# - restore_cache:
# key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
# - restore_deposit_contract_compiler_cached_venv
# - run:
# name: Run deposit contract compile test
# command: make test_compile_deposit_contract
# test_deposit_contract:
# docker:
# - image: circleci/python:3.8
# working_directory: ~/specs-repo
# steps:
# - restore_cache:
# key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
# - restore_deposit_contract_tester_cached_venv
# - run:
# name: Run deposit contract test
# command: make test_deposit_contract
build_deposit_contract:
docker:
# The deposit contract compiler is pinned to python 3.7 because of the vyper version pin.
- image: circleci/python:3.7
working_directory: ~/specs-repo
- image: ethereum/solc:0.6.11-alpine
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_deposit_contract_compiler_cached_venv
- checkout
- run:
name: Install deposit contract compiler requirements
command: make install_deposit_contract_compiler
- save_deposit_contract_compiler_cached_venv
install_deposit_contract_tester:
docker:
- image: circleci/python:3.8
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_deposit_contract_tester_cached_venv
name: Install build essentials
command: |
apk update
apk add git make
- run:
name: Install deposit contract tester requirements
command: make install_deposit_contract_tester
- save_deposit_contract_tester_cached_venv
test_compile_deposit_contract:
docker:
- image: circleci/python:3.7
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_deposit_contract_compiler_cached_venv
- run:
name: Run deposit contract compile test
command: make test_compile_deposit_contract
name: Compile the contract
command: |
make compile_deposit_contract
git diff --color --exit-code
- persist_to_workspace:
root: .
paths:
- ./solidity_deposit_contract/deposit_contract.json
- ./build/combined.json
- ./solidity_deposit_contract/lib
test_deposit_contract:
docker:
- image: circleci/python:3.8
working_directory: ~/specs-repo
- image: nixorg/nix:circleci
steps:
- checkout
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_deposit_contract_tester_cached_venv
key: nix-store-test-v2
- attach_workspace:
at: /tmp/
- run:
name: Run deposit contract test
command: make test_deposit_contract
name: Test the contract
command: |
mkdir build
cp -r /tmp/build/* build
cp -r /tmp/solidity_deposit_contract/lib/* ./solidity_deposit_contract/lib
cp -r /tmp/solidity_deposit_contract/deposit_contract.json ./solidity_deposit_contract/deposit_contract.json
nix-shell --command 'make test_deposit_contract' ./solidity_deposit_contract/shell.nix
- save_cache:
key: nix-store-test-v2
paths:
- /nix
workflows:
version: 2.1
test_spec:
@ -209,15 +250,21 @@ workflows:
- lint:
requires:
- test
- install_deposit_contract_compiler:
requires:
- checkout_specs
- test_compile_deposit_contract:
requires:
- install_deposit_contract_compiler
- install_deposit_contract_tester:
requires:
- checkout_specs
# - install_deposit_contract_compiler:
# requires:
# - checkout_specs
# - test_compile_deposit_contract:
# requires:
# - install_deposit_contract_compiler
# - install_deposit_contract_tester:
# requires:
# - checkout_specs
# - test_deposit_contract:
# requires:
# - install_deposit_contract_tester
build_and_test_deposit_contract:
jobs:
- build_deposit_contract
- test_deposit_contract:
requires:
- install_deposit_contract_tester
- build_deposit_contract

1
.gitattributes vendored
View File

@ -1 +1,2 @@
*.vy linguist-language=Python
*.sol linguist-language=Solidity

View File

@ -1,3 +1,3 @@
[submodule "lib/ds-test"]
path = lib/ds-test
path = solidity_deposit_contract/lib/ds-test
url = https://github.com/dapphub/ds-test

View File

@ -6,6 +6,9 @@ TEST_VECTOR_DIR = ../eth2.0-spec-tests/tests
GENERATOR_DIR = ./tests/generators
DEPOSIT_CONTRACT_COMPILER_DIR = ./deposit_contract/compiler
DEPOSIT_CONTRACT_TESTER_DIR = ./deposit_contract/tester
SOLIDITY_DEPOSIT_CONTRACT_DIR = ./solidity_deposit_contract
SOLIDITY_DEPOSIT_CONTRACT_SOURCE = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/deposit_contract.sol
SOLIDITY_FILE_NAME = deposit_contract.json
CONFIGS_DIR = ./configs
# Collect a list of generator names
@ -25,6 +28,11 @@ COV_INDEX_FILE=$(PY_SPEC_DIR)/$(COV_HTML_OUT)/index.html
CURRENT_DIR = ${CURDIR}
LINTER_CONFIG_FILE = $(CURRENT_DIR)/linter.ini
export DAPP_SKIP_BUILD:=1
export DAPP_SRC:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)
export DAPP_LIB:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)/lib
export DAPP_JSON:=build/combined.json
.PHONY: clean partial_clean all test citest lint generate_tests pyspec install_test open_cov \
install_deposit_contract_tester test_deposit_contract install_deposit_contract_compiler \
compile_deposit_contract test_compile_deposit_contract check_toc
@ -107,23 +115,28 @@ lint: pyspec
flake8 --config $(LINTER_CONFIG_FILE) ./eth2spec \
&& mypy --config-file $(LINTER_CONFIG_FILE) -p eth2spec.phase0 -p eth2spec.phase1
install_deposit_contract_tester:
cd $(DEPOSIT_CONTRACT_TESTER_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt
# install_deposit_contract_tester:
# cd $(DEPOSIT_CONTRACT_TESTER_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt
test_deposit_contract:
cd $(DEPOSIT_CONTRACT_TESTER_DIR); . venv/bin/activate; \
python -m pytest .
dapp test -v --fuzz-runs 5
install_deposit_contract_compiler:
cd $(DEPOSIT_CONTRACT_COMPILER_DIR); python3.7 -m venv venv; . venv/bin/activate; pip3.7 install -r requirements.txt
# install_deposit_contract_compiler:
# cd $(DEPOSIT_CONTRACT_COMPILER_DIR); python3.7 -m venv venv; . venv/bin/activate; pip3.7 install -r requirements.txt
compile_deposit_contract:
cd $(DEPOSIT_CONTRACT_COMPILER_DIR); . venv/bin/activate; \
python3.7 deposit_contract/compile.py ../contracts/validator_registration.vy
@cd $(SOLIDITY_DEPOSIT_CONTRACT_DIR)
@git submodule update --recursive --init
@solc --metadata-literal --optimize --optimize-runs 5000000 --bin --abi --combined-json=abi,bin,bin-runtime,srcmap,srcmap-runtime,ast,metadata,storage-layout --overwrite -o build $(SOLIDITY_DEPOSIT_CONTRACT_SOURCE) $(SOLIDITY_DEPOSIT_CONTRACT_DIR)/tests/deposit_contract.t.sol
@/bin/echo -n '{"abi": ' > $(SOLIDITY_FILE_NAME)
@cat build/DepositContract.abi >> $(SOLIDITY_FILE_NAME)
@/bin/echo -n ', "bytecode": "0x' >> $(SOLIDITY_FILE_NAME)
@cat build/DepositContract.bin >> $(SOLIDITY_FILE_NAME)
@/bin/echo -n '"}' >> $(SOLIDITY_FILE_NAME)
test_compile_deposit_contract:
cd $(DEPOSIT_CONTRACT_COMPILER_DIR); . venv/bin/activate; \
python3.7 -m pytest .
# test_compile_deposit_contract:
# cd $(DEPOSIT_CONTRACT_COMPILER_DIR); . venv/bin/activate; \
# python3.7 -m pytest .
# Runs a generator, identified by param 1
define run_generator

View File

@ -1 +0,0 @@
*.sol linguist-language=Solidity