From adf869877892b48542a8e76465d55fd9913b457f Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 18 Aug 2020 00:51:03 +0800 Subject: [PATCH] Update the docs and remove unused code --- .gitattributes | 1 - Makefile | 2 -- solidity_deposit_contract/README.md | 17 +++++++++++------ specs/phase0/deposit-contract.md | 8 ++++---- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.gitattributes b/.gitattributes index 97437110d..52031de51 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -*.vy linguist-language=Python *.sol linguist-language=Solidity diff --git a/Makefile b/Makefile index 1282401e8..3914b7b27 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ TEST_LIBS_DIR = ./tests/core PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec TEST_VECTOR_DIR = ../eth2.0-spec-tests/tests GENERATOR_DIR = ./tests/generators -DEPOSIT_CONTRACT_COMPILER_DIR = ./deposit_contract/compiler SOLIDITY_DEPOSIT_CONTRACT_DIR = ./solidity_deposit_contract SOLIDITY_DEPOSIT_CONTRACT_SOURCE = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/deposit_contract.sol SOLIDITY_FILE_NAME = deposit_contract.json @@ -46,7 +45,6 @@ partial_clean: rm -rf .pytest_cache rm -f .coverage rm -rf $(PY_SPEC_DIR)/.pytest_cache - rm -rf $(DEPOSIT_CONTRACT_COMPILER_DIR)/.pytest_cache rm -rf $(DEPOSIT_CONTRACT_TESTER_DIR)/.pytest_cache rm -rf $(PY_SPEC_DIR)/phase0 rm -rf $(PY_SPEC_DIR)/phase1 diff --git a/solidity_deposit_contract/README.md b/solidity_deposit_contract/README.md index 947eb0f19..88b626521 100644 --- a/solidity_deposit_contract/README.md +++ b/solidity_deposit_contract/README.md @@ -1,20 +1,25 @@ # eth2-deposit-contract -This is a port of the [Vyper Eth 2.0 deposit contract](https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/deposit_contract/contracts/validator_registration.vy) to Solidity. +## History + +This is a rewrite of the [Vyper Eth 2.0 deposit contract](https://github.com/ethereum/eth2.0-specs/blob/v0.12.2/deposit_contract/contracts/validator_registration.vy) to Solidity. The original motivation was to run the SMTChecker and the new Yul IR generator option (`--ir`) in the compiler. -As of June 2020, this contract (the version tagged as `r1`) has been verified and is considered for adoption. +As of June 2020, this contract (the version tagged as [`r1`](https://github.com/axic/eth2-deposit-contract/tree/r1) in GitHub repository [axic/eth2-deposit-contract](https://github.com/axic/eth2-deposit-contract/tree/r1)) has been verified and is considered for adoption. See this [blog post](https://blog.ethereum.org/2020/06/23/eth2-quick-update-no-12/) for more information. +In August 2020, tag [`r2`](https://github.com/axic/eth2-deposit-contract/tree/r2) was released with metadata modifications and relicensed to CC0-1.0. Afterward, this contract has been ported back to `eth2.0-specs` repository and replaced the Vyper deposit contract. + ## 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 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. ## Running randomized `dapp` tests: -Install the latest version of `dapp` by following the instructions at [dapp.tools](https://dapp.tools/). Then run +Install the latest version of `dapp` by following the instructions at [dapp.tools](https://dapp.tools/). Then in the `eth2.0-specs` directory run: + ```sh -make test +make test_deposit_contract ``` diff --git a/specs/phase0/deposit-contract.md b/specs/phase0/deposit-contract.md index b4f8d3036..89c5bb22b 100644 --- a/specs/phase0/deposit-contract.md +++ b/specs/phase0/deposit-contract.md @@ -16,7 +16,7 @@ - [Deposit amount](#deposit-amount) - [Withdrawal credentials](#withdrawal-credentials) - [`DepositEvent` log](#depositevent-log) -- [Vyper code](#vyper-code) +- [Solidity code](#solidity-code) @@ -53,7 +53,7 @@ _Note_: See [here](https://chainid.network/) for a comprehensive list of public ### `deposit` function -The deposit contract has a public `deposit` function to make deposits. It takes as arguments `pubkey: bytes[48], withdrawal_credentials: bytes[32], signature: bytes[96], deposit_data_root: bytes32`. The first three arguments populate a [`DepositData`](./beacon-chain.md#depositdata) object, and `deposit_data_root` is the expected `DepositData` root as a protection against malformatted calldata. +The deposit contract has a public `deposit` function to make deposits. It takes as arguments `bytes calldata pubkey, bytes calldata withdrawal_credentials, bytes calldata signature, bytes32 deposit_data_root`. The first three arguments populate a [`DepositData`](./beacon-chain.md#depositdata) object, and `deposit_data_root` is the expected `DepositData` root as a protection against malformatted calldata. #### Deposit amount @@ -72,8 +72,8 @@ The private key corresponding to `withdrawal_pubkey` will be required to initiat Every Ethereum 1.0 deposit emits a `DepositEvent` log for consumption by the beacon chain. The deposit contract does little validation, pushing most of the validator onboarding logic to the beacon chain. In particular, the proof of possession (a BLS12-381 signature) is not verified by the deposit contract. -## Vyper code +## Solidity code -The deposit contract source code, written in Vyper, is available [here](../../deposit_contract/contracts/validator_registration.vy). +The deposit contract source code, written in Solidity, is available [here](../../solidity_deposit_contract/deposit_contract.sol). *Note*: To save on gas, the deposit contract uses a progressive Merkle root calculation algorithm that requires only O(log(n)) storage. See [here](https://github.com/ethereum/research/blob/master/beacon_chain_impl/progressive_merkle_tree.py) for a Python implementation, and [here](https://github.com/runtimeverification/verified-smart-contracts/blob/master/deposit/formal-incremental-merkle-tree-algorithm.pdf) for a formal correctness proof.