Merge pull request #3940 from jtraglia/move-depcon-make-rules
Move deposit contract rules to its own Makefile
This commit is contained in:
commit
7922b62482
|
@ -44,19 +44,6 @@ commands:
|
|||
venv_name: v25-pyspec
|
||||
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "requirements_preinstallation.txt" }}
|
||||
venv_path: ./venv
|
||||
restore_deposit_contract_tester_cached_venv:
|
||||
description: "Restore the venv from cache for the deposit contract tester"
|
||||
steps:
|
||||
- restore_cached_venv:
|
||||
venv_name: v23-deposit-contract-tester
|
||||
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "requirements_preinstallation.txt" }}-{{ checksum "solidity_deposit_contract/web3_tester/requirements.txt" }}
|
||||
save_deposit_contract_tester_cached_venv:
|
||||
description: "Save the venv to cache for later use of the deposit contract tester"
|
||||
steps:
|
||||
- save_cached_venv:
|
||||
venv_name: v23-deposit-contract-tester
|
||||
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "requirements_preinstallation.txt" }}-{{ checksum "solidity_deposit_contract/web3_tester/requirements.txt" }}
|
||||
venv_path: ./solidity_deposit_contract/web3_tester/venv
|
||||
jobs:
|
||||
checkout_specs:
|
||||
docker:
|
||||
|
@ -226,71 +213,6 @@ jobs:
|
|||
- run:
|
||||
name: Run linter for test generators
|
||||
command: make lint_generators
|
||||
build_deposit_contract:
|
||||
docker:
|
||||
- image: ethereum/solc:0.6.11-alpine
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install build essentials
|
||||
command: |
|
||||
apk update
|
||||
apk add git make
|
||||
- run:
|
||||
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: nixorg/nix:circleci
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: nix-store-test-v2
|
||||
- attach_workspace:
|
||||
at: /tmp/
|
||||
- run:
|
||||
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
|
||||
install_deposit_contract_web3_tester:
|
||||
docker:
|
||||
- image: cimg/python:3.12.4
|
||||
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_web3_tester
|
||||
- save_deposit_contract_tester_cached_venv
|
||||
test_deposit_contract_web3_tests:
|
||||
docker:
|
||||
- image: cimg/python:3.12.4
|
||||
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 with web3.py
|
||||
command: make test_deposit_contract_web3_tests
|
||||
workflows:
|
||||
version: 2.1
|
||||
test_spec:
|
||||
|
@ -328,17 +250,3 @@ workflows:
|
|||
- lint:
|
||||
requires:
|
||||
- install_pyspec_test
|
||||
# NOTE: Since phase 0 has been launched, we disabled the deposit contract tests.
|
||||
# - install_deposit_contract_web3_tester:
|
||||
# requires:
|
||||
# - checkout_specs
|
||||
# - test_deposit_contract_web3_tests:
|
||||
# requires:
|
||||
# - install_deposit_contract_web3_tester
|
||||
build_and_test_deposit_contract:
|
||||
jobs:
|
||||
- build_deposit_contract
|
||||
# NOTE: Since phase 0 has been launched, we disabled the deposit contract tests.
|
||||
# - test_deposit_contract:
|
||||
# requires:
|
||||
# - build_deposit_contract
|
||||
|
|
33
Makefile
33
Makefile
|
@ -8,10 +8,6 @@ ETH2SPEC_MODULE_DIR = $(PY_SPEC_DIR)/eth2spec
|
|||
TEST_REPORT_DIR = $(PY_SPEC_DIR)/test-reports
|
||||
TEST_VECTOR_DIR = ../consensus-spec-tests/tests
|
||||
GENERATOR_DIR = ./tests/generators
|
||||
SOLIDITY_DEPOSIT_CONTRACT_DIR = ./solidity_deposit_contract
|
||||
SOLIDITY_DEPOSIT_CONTRACT_SOURCE = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/deposit_contract.sol
|
||||
SOLIDITY_FILE_NAME = deposit_contract.json
|
||||
DEPOSIT_CONTRACT_TESTER_DIR = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/web3_tester
|
||||
CONFIGS_DIR = ./configs
|
||||
TEST_PRESET_TYPE ?= minimal
|
||||
# Collect a list of generator names
|
||||
|
@ -50,15 +46,8 @@ GENERATOR_ERROR_LOG_FILE = $(CURRENT_DIR)/$(TEST_VECTOR_DIR)/testgen_error_log.t
|
|||
|
||||
SCRIPTS_DIR = ${CURRENT_DIR}/scripts
|
||||
|
||||
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 \
|
||||
detect_generator_incomplete detect_generator_error_log
|
||||
check_toc detect_generator_incomplete detect_generator_error_log
|
||||
|
||||
all: $(PY_SPEC_ALL_TARGETS)
|
||||
|
||||
|
@ -170,26 +159,6 @@ lint_generators: pyspec
|
|||
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
|
||||
flake8 --config $(LINTER_CONFIG_FILE)
|
||||
|
||||
compile_deposit_contract:
|
||||
@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_deposit_contract:
|
||||
dapp test -v --fuzz-runs 5
|
||||
|
||||
install_deposit_contract_web3_tester:
|
||||
cd $(DEPOSIT_CONTRACT_TESTER_DIR); python3 -m venv venv; . venv/bin/activate; python3 -m pip install -r requirements.txt
|
||||
|
||||
test_deposit_contract_web3_tests:
|
||||
cd $(DEPOSIT_CONTRACT_TESTER_DIR); . venv/bin/activate; \
|
||||
python3 -m pytest .
|
||||
|
||||
# Runs a generator, identified by param 1
|
||||
define run_generator
|
||||
# Started!
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
SOLIDITY_FILE_NAME = deposit_contract.json
|
||||
SOLIDITY_DEPOSIT_CONTRACT_SOURCE = deposit_contract.sol
|
||||
DEPOSIT_CONTRACT_TESTER_DIR = web3_tester
|
||||
|
||||
export DAPP_SKIP_BUILD:=1
|
||||
export DAPP_SRC:=$(CURDIR)
|
||||
export DAPP_LIB:=$(CURDIR)/lib
|
||||
export DAPP_JSON:=build/combined.json
|
||||
|
||||
all: \
|
||||
compile_deposit_contract \
|
||||
install_deposit_contract_web3_tester \
|
||||
test_deposit_contract_web3_tests
|
||||
|
||||
compile_deposit_contract:
|
||||
@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) 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_deposit_contract:
|
||||
@dapp test -v --fuzz-runs 5
|
||||
|
||||
install_deposit_contract_web3_tester:
|
||||
@cd $(DEPOSIT_CONTRACT_TESTER_DIR); \
|
||||
python3 -m venv venv; \
|
||||
source venv/bin/activate; \
|
||||
python3 -m pip install -r ../../requirements_preinstallation.txt; \
|
||||
python3 -m pip install -r requirements.txt
|
||||
|
||||
test_deposit_contract_web3_tests:
|
||||
@cd $(DEPOSIT_CONTRACT_TESTER_DIR); \
|
||||
source venv/bin/activate; \
|
||||
python3 -m pytest .
|
||||
|
||||
clean:
|
||||
@git clean -fdx
|
|
@ -13,7 +13,7 @@ In August 2020, version `r2` was released with metadata modifications and relice
|
|||
|
||||
## Compiling solidity deposit contract
|
||||
|
||||
In the `eth2.0-specs` directory run:
|
||||
In this directory run:
|
||||
```sh
|
||||
make compile_deposit_contract
|
||||
```
|
||||
|
@ -31,8 +31,8 @@ solc --optimize --optimize-runs 5000000 --metadata-literal --bin deposit_contrac
|
|||
|
||||
## Running web3 tests
|
||||
|
||||
1. In the `eth2.0-specs` directory run `make install_deposit_contract_web3_tester` to install the tools needed (make sure to have Python 3.7 and pip installed).
|
||||
2. In the `eth2.0-specs` directory run `make test_deposit_contract_web3_tests` to execute the tests.
|
||||
1. In this directory run `make install_deposit_contract_web3_tester` to install the tools needed (make sure to have Python 3 and pip installed).
|
||||
2. In this directory run `make test_deposit_contract_web3_tests` to execute the tests.
|
||||
|
||||
## Running randomized `dapp` tests:
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eth-tester[py-evm]>=0.3.0b1,<0.4
|
||||
web3==5.4.0
|
||||
pytest==3.6.1
|
||||
eth-tester[py-evm]>=0.12.0b1
|
||||
web3>=6.11.0
|
||||
pytest>=4.4
|
||||
# The eth2spec
|
||||
../../
|
||||
|
|
|
@ -51,7 +51,7 @@ def registration_contract(w3, tester):
|
|||
abi=contract_abi,
|
||||
bytecode=contract_bytecode)
|
||||
tx_hash = registration.constructor().transact()
|
||||
tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)
|
||||
tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
|
||||
registration_deployed = w3.eth.contract(
|
||||
address=tx_receipt.contractAddress,
|
||||
abi=contract_abi
|
||||
|
|
|
@ -2,7 +2,7 @@ from random import randint
|
|||
import pytest
|
||||
import eth_utils
|
||||
|
||||
from eth2spec.phase0.spec import DepositData
|
||||
from eth2spec.phase0.mainnet import DepositData
|
||||
from eth2spec.utils.ssz.ssz_typing import List
|
||||
from eth2spec.utils.ssz.ssz_impl import hash_tree_root
|
||||
|
||||
|
@ -119,7 +119,7 @@ def test_deposit_inputs(registration_contract,
|
|||
|
||||
|
||||
def test_deposit_event_log(registration_contract, a0, w3):
|
||||
log_filter = registration_contract.events.DepositEvent.createFilter(
|
||||
log_filter = registration_contract.events.DepositEvent.create_filter(
|
||||
fromBlock='latest',
|
||||
)
|
||||
deposit_amount_list = [randint(MIN_DEPOSIT_AMOUNT, FULL_DEPOSIT_AMOUNT * 2) for _ in range(3)]
|
||||
|
@ -154,7 +154,7 @@ def test_deposit_event_log(registration_contract, a0, w3):
|
|||
|
||||
|
||||
def test_deposit_tree(registration_contract, w3, assert_tx_failed):
|
||||
log_filter = registration_contract.events.DepositEvent.createFilter(
|
||||
log_filter = registration_contract.events.DepositEvent.create_filter(
|
||||
fromBlock='latest',
|
||||
)
|
||||
|
||||
|
@ -178,7 +178,7 @@ def test_deposit_tree(registration_contract, w3, assert_tx_failed):
|
|||
tx_hash = registration_contract.functions.deposit(
|
||||
*deposit_input,
|
||||
).transact({"value": deposit_amount_list[i] * eth_utils.denoms.gwei})
|
||||
receipt = w3.eth.getTransactionReceipt(tx_hash)
|
||||
receipt = w3.eth.get_transaction_receipt(tx_hash)
|
||||
print("deposit transaction consumes %d gas" % receipt['gasUsed'])
|
||||
|
||||
logs = log_filter.get_new_entries()
|
||||
|
|
Loading…
Reference in New Issue