diff --git a/.cargo/config b/.cargo/config
index a160c8eab7..c497d8e4ef 100644
--- a/.cargo/config
+++ b/.cargo/config
@@ -1,3 +1,3 @@
[target.x86_64-pc-windows-msvc]
-# Link the C runtime statically ; https://github.com/openethereum/openethereum/issues/6643
+# Link the C runtime statically ; https://github.com/openethereum/parity-ethereum/issues/6643
rustflags = ["-Ctarget-feature=+crt-static"]
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 6aa2d8f698..eb48b425fc 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -2,7 +2,7 @@
## Do you have a question?
-Check out our [Basic Usage](https://openethereum.github.io/wiki/Basic-Usage), [Configuration](https://openethereum.github.io/wiki/Configuring-OpenEthereum), and [FAQ](https://openethereum.github.io/wiki/FAQ) articles on our [wiki](https://openethereum.github.io/wiki)!
+Check out our [Beginner Introduction](https://openethereum.github.io/Beginner-Introduction), [Configuration](https://openethereum.github.io//Configuring-OpenEthereum), and [FAQ](https://openethereum.github.io/FAQ) articles on our [wiki](https://openethereum.github.io/)!
See also frequently asked questions [tagged with `parity`](https://ethereum.stackexchange.com/questions/tagged/parity?sort=votes&pageSize=50) on Stack Exchange.
@@ -35,7 +35,7 @@ There are a few basic ground-rules for contributors (including the maintainer(s)
* **No pushing directly to the master branch**.
* **All modifications** must be made in a **pull-request** to solicit feedback from other contributors.
* Pull-requests cannot be merged before CI runs green and two reviewers have given their approval.
-* Contributors should adhere to the [Parity Ethereum Style Guide](https://openethereum.github.io/wiki/Parity-Ethereum-Style-Guide).
+* All code changed should be formated by running `cargo fmt -- --config=merge_imports=true`
### Recommendations
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 9308be5bca..890cdb2516 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,6 +1,8 @@
+For questions please use https://discord.io/openethereum, issues are for bugs and feature requests.
+
_Before filing a new issue, please **provide the following information**._
-- **OpenEthereum version**: 0.0.0
+- **OpenEthereum version (>=3.1.0)**: 0.0.0
- **Operating system**: Windows / MacOS / Linux
- **Installation**: homebrew / one-line installer / built from source
- **Fully synchronized**: no / yes
diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml
new file mode 100644
index 0000000000..a3983eec3f
--- /dev/null
+++ b/.github/workflows/build-test-windows.yml
@@ -0,0 +1,33 @@
+name: Build and Test Suite on Windows
+
+on:
+ push:
+ branches:
+ - main
+ - dev
+jobs:
+ build-tests:
+ name: Test and Build
+ strategy:
+ matrix:
+ platform:
+ - windows2019 # custom runner
+ toolchain:
+ - stable
+ runs-on: ${{ matrix.platform }}
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@main
+ with:
+ submodules: true
+ - name: Install toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ toolchain: ${{ matrix.toolchain }}
+ profile: minimal
+ override: true
+ - name: Build tests
+ uses: actions-rs/cargo@v1
+ with:
+ command: test
+ args: --locked --all --release --features "json-tests" --verbose --no-run
diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index a8357e5e96..344591c0a0 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -4,26 +4,22 @@ on:
pull_request:
push:
branches:
- - master
- - stable
+ - main
+ - dev
jobs:
build-tests:
name: Test and Build
- env:
- SCCACHE_CACHE_SIZE: "1G"
- SCCACHE_IDLE_TIMEOUT: 0
strategy:
matrix:
platform:
- - ubuntu-20.04
+ - ubuntu-16.04
- macos-latest
- - windows-latest
toolchain:
- stable
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout sources
- uses: actions/checkout@master
+ uses: actions/checkout@main
with:
submodules: true
- name: Install toolchain
@@ -32,68 +28,13 @@ jobs:
toolchain: ${{ matrix.toolchain }}
profile: minimal
override: true
- - name: Cache cargo registry
- uses: actions/cache@v2
- with:
- path: ~/.cargo/registry
- key: ${{ runner.os }}-cargo-registry-build-tests-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v2
- with:
- path: ~/.cargo/git
- key: ${{ runner.os }}-cargo-git-build-tests-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo build
- uses: actions/cache@v2
- with:
- path: target
- key: ${{ runner.os }}-cargo-build-target-build-tests-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache sccache linux
- if: matrix.platform == 'ubuntu-20.04'
- uses: actions/cache@v2
- with:
- path: "/home/runner/.cache/sccache"
- key: ${{ runner.os }}-sccache-build-tests-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache sccache MacOS
- if: matrix.platform == 'macos-latest'
- uses: actions/cache@v2
- with:
- path: "/Users/runner/Library/Caches/Mozilla.sccache"
- key: ${{ runner.os }}-sccache-build-tests-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache sccache Windows
- if: matrix.platform == 'windows-latest'
- uses: actions/cache@v2
- with:
- path: "C:\\Users\\runneradmin\\AppData\\Local\\Mozilla\\sccache\\cache"
- key: ${{ runner.os }}-sccache-build-tests-${{ hashFiles('**/Cargo.lock') }}
- - name: Install sccache for ${{ matrix.platform }}
- shell: pwsh
- run: pwsh scripts/actions/install-sccache.ps1 ${{ runner.os}}
- - name: Install LLVM for Windows
- if: matrix.platform == 'windows-latest'
- run: choco install llvm
- - name: Sccache statistics
- run: sccache --show-stats
- name: Build tests
uses: actions-rs/cargo@v1
with:
command: test
args: --locked --all --release --features "json-tests" --verbose --no-run
- - name: Run tests for ${{ matrix.platform }}
- if: matrix.platform == 'windows-latest'
- continue-on-error: true #Skip step if Windows tests failure
- uses: actions-rs/cargo@v1
- with:
- command: test
- args: --locked --all --release --features "json-tests" --verbose
- - name: Run tests for ${{ matrix.platform }}
- if: matrix.platform != 'windows-latest'
- uses: actions-rs/cargo@v1
- with:
- command: test
+ - name: Run tests for ${{ matrix.platform }}
+ uses: actions-rs/cargo@v1
+ with:
+ command: test
args: --locked --all --release --features "json-tests" --verbose
- - name: Stop sccache
- if: always()
- run: sccache --stop-server
- - name: Prepare build directory for cache
- shell: bash
- run: bash scripts/actions/clean-target.sh
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 610cfe488a..fae328913b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -2,107 +2,66 @@ name: Build Release Suite
on:
push:
- branches:
- - stable
tags:
- v*
+# Global vars
+env:
+ AWS_REGION: "us-east-1"
+ AWS_S3_ARTIFACTS_BUCKET: "openethereum-releases"
+ ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+
jobs:
build:
name: Build Release
- env:
- SCCACHE_CACHE_SIZE: "1G"
- SCCACHE_IDLE_TIMEOUT: 0
- AWS_S3_ARTIFACTS_BUCKET: "openethereum-releases"
- AWS_REGION: "us-east-1"
strategy:
matrix:
platform:
- - ubuntu-20.04
+ - ubuntu-16.04
- macos-latest
- - windows-latest
toolchain:
- stable
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout sources
- uses: actions/checkout@master
+ uses: actions/checkout@main
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
profile: minimal
override: true
- - name: Cache cargo registry
- uses: actions/cache@v2
- with:
- path: ~/.cargo/registry
- key: ${{ runner.os }}-cargo-registry-build-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v2
- with:
- path: ~/.cargo/git
- key: ${{ runner.os }}-cargo-git-build-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo build
- uses: actions/cache@v2
- with:
- path: target
- key: ${{ runner.os }}-cargo-build-target-build-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache sccache linux
- if: matrix.platform == 'ubuntu-20.04'
- uses: actions/cache@v2
- with:
- path: "/home/runner/.cache/sccache"
- key: ${{ runner.os }}-sccache-build-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache sccache MacOS
- if: matrix.platform == 'macos-latest'
- uses: actions/cache@v2
- with:
- path: "/Users/runner/Library/Caches/Mozilla.sccache"
- key: ${{ runner.os }}-sccache-build-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache sccache Windows
- if: matrix.platform == 'windows-latest'
- uses: actions/cache@v2
- with:
- path: "C:\\Users\\runneradmin\\AppData\\Local\\Mozilla\\sccache\\cache"
- key: ${{ runner.os }}-sccache-build-${{ hashFiles('**/Cargo.lock') }}
- - name: Install sccache for ${{ matrix.platform }}
- shell: pwsh
- run: pwsh scripts/actions/install-sccache.ps1 ${{ runner.os}}
# ==============================
# Windows Build
# ==============================
- - name: Install LLVM for Windows
- if: matrix.platform == 'windows-latest'
- run: choco install llvm
+ # - name: Install LLVM for Windows
+ # if: matrix.platform == 'windows2019'
+ # run: choco install llvm
- - name: Sccache statistics
- run: sccache --show-stats
+ # - name: Build OpenEthereum for Windows
+ # if: matrix.platform == 'windows2019'
+ # run: sh scripts/actions/build-windows.sh ${{matrix.platform}}
- - name: Build OpenEthereum for Windows
- if: matrix.platform == 'windows-latest'
- run: sh scripts/actions/build-windows.sh ${{matrix.platform}}
-
- - name: Upload Windows build
- uses: actions/upload-artifact@v2
- if: matrix.platform == 'windows-latest'
- with:
- name: windows-artifacts
- path: artifacts
+ # - name: Upload Windows build
+ # uses: actions/upload-artifact@v2
+ # if: matrix.platform == 'windows2019'
+ # with:
+ # name: windows-artifacts
+ # path: artifacts
# ==============================
# Linux/Macos Build
# ==============================
-
+
- name: Build OpenEthereum for ${{matrix.platform}}
- if: matrix.platform != 'windows-latest'
+ if: matrix.platform != 'windows2019'
run: sh scripts/actions/build-linux.sh ${{matrix.platform}}
- name: Upload Linux build
uses: actions/upload-artifact@v2
- if: matrix.platform == 'ubuntu-20.04'
+ if: matrix.platform == 'ubuntu-16.04'
with:
name: linux-artifacts
path: artifacts
@@ -114,35 +73,23 @@ jobs:
name: macos-artifacts
path: artifacts
- # ==============================
- # End builds
- # ==============================
-
- - name: Stop sccache
- if: always()
- run: sccache --stop-server
-
- - name: Prepare build directory for cache
- shell: bash
- run: bash scripts/actions/clean-target.sh
-
zip-artifacts-creator:
name: Create zip artifacts
needs: build
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-16.04
steps:
- name: Set env
- run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
+ run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# ==============================
# Create ZIP files
# ==============================
- - name: Download Windows artifacts
- uses: actions/download-artifact@v2
- with:
- name: windows-artifacts
- path: windows-artifacts
+ # - name: Download Windows artifacts
+ # uses: actions/download-artifact@v2
+ # with:
+ # name: windows-artifacts
+ # path: windows-artifacts
- name: Download Linux artifacts
uses: actions/download-artifact@v2
@@ -185,18 +132,18 @@ jobs:
echo ::set-output name=MACOS_ARTIFACT::openethereum-macos-${{ env.RELEASE_VERSION }}.zip
echo ::set-output name=MACOS_SHASUM::$(shasum -a 256 openethereum-macos-${{ env.RELEASE_VERSION }}.zip | awk '{print $1}')
- - name: Create zip Windows
- id: create_zip_windows
- run: |
- cd windows-artifacts/
- zip -rT openethereum-windows-${{ env.RELEASE_VERSION }}.zip *
- ls openethereum-windows-${{ env.RELEASE_VERSION }}.zip
- cd ..
- mv windows-artifacts/openethereum-windows-${{ env.RELEASE_VERSION }}.zip .
+ # - name: Create zip Windows
+ # id: create_zip_windows
+ # run: |
+ # cd windows-artifacts/
+ # zip -rT openethereum-windows-${{ env.RELEASE_VERSION }}.zip *
+ # ls openethereum-windows-${{ env.RELEASE_VERSION }}.zip
+ # cd ..
+ # mv windows-artifacts/openethereum-windows-${{ env.RELEASE_VERSION }}.zip .
- echo "Setting outputs..."
- echo ::set-output name=WINDOWS_ARTIFACT::openethereum-windows-${{ env.RELEASE_VERSION }}.zip
- echo ::set-output name=WINDOWS_SHASUM::$(shasum -a 256 openethereum-windows-${{ env.RELEASE_VERSION }}.zip | awk '{print $1}')
+ # echo "Setting outputs..."
+ # echo ::set-output name=WINDOWS_ARTIFACT::openethereum-windows-${{ env.RELEASE_VERSION }}.zip
+ # echo ::set-output name=WINDOWS_SHASUM::$(shasum -a 256 openethereum-windows-${{ env.RELEASE_VERSION }}.zip | awk '{print $1}')
# =======================================================================
# Upload artifacts
@@ -215,11 +162,11 @@ jobs:
name: openethereum-macos-${{ env.RELEASE_VERSION }}.zip
path: openethereum-macos-${{ env.RELEASE_VERSION }}.zip
- - name: Upload artifacts
- uses: actions/upload-artifact@v2
- with:
- name: openethereum-windows-${{ env.RELEASE_VERSION }}.zip
- path: openethereum-windows-${{ env.RELEASE_VERSION }}.zip
+ # - name: Upload artifacts
+ # uses: actions/upload-artifact@v2
+ # with:
+ # name: openethereum-windows-${{ env.RELEASE_VERSION }}.zip
+ # path: openethereum-windows-${{ env.RELEASE_VERSION }}.zip
# =======================================================================
# Upload artifacts to S3
@@ -237,23 +184,23 @@ jobs:
run: |
# Deploy zip artifacts to S3 bucket to a directory whose name is the tagged release version.
# Deploy macos binary artifact (if required, add more `aws s3 cp` commands to deploy specific OS versions)
- aws s3 cp macos-artifacts/openethereum s3://${{ env.AWS_S3_ARTIFACTS_BUCKET }}/${{ env.RELEASE_VERSION }}/macos/
+ aws s3 cp macos-artifacts/openethereum s3://${{ env.AWS_S3_ARTIFACTS_BUCKET }}/${{ env.RELEASE_VERSION }}/macos/ --region ${{ env.AWS_REGION }}
outputs:
linux-artifact: ${{ steps.create_zip_linux.outputs.LINUX_ARTIFACT }}
linux-shasum: ${{ steps.create_zip_linux.outputs.LINUX_SHASUM }}
macos-artifact: ${{ steps.create_zip_macos.outputs.MACOS_ARTIFACT }}
macos-shasum: ${{ steps.create_zip_macos.outputs.MACOS_SHASUM }}
- windows-artifact: ${{ steps.create_zip_windows.outputs.WINDOWS_ARTIFACT }}
- windows-shasum: ${{ steps.create_zip_windows.outputs.WINDOWS_SHASUM }}
+ # windows-artifact: ${{ steps.create_zip_windows.outputs.WINDOWS_ARTIFACT }}
+ # windows-shasum: ${{ steps.create_zip_windows.outputs.WINDOWS_SHASUM }}
draft-release:
name: Draft Release
needs: zip-artifacts-creator
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-16.04
steps:
- name: Set env
- run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
+ run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# ==============================
# Download artifacts
@@ -269,10 +216,10 @@ jobs:
with:
name: openethereum-macos-${{ env.RELEASE_VERSION }}.zip
- - name: Download artifacts
- uses: actions/download-artifact@v2
- with:
- name: openethereum-windows-${{ env.RELEASE_VERSION }}.zip
+ # - name: Download artifacts
+ # uses: actions/download-artifact@v2
+ # with:
+ # name: openethereum-windows-${{ env.RELEASE_VERSION }}.zip
- name: Display structure of downloaded files
run: ls
@@ -326,13 +273,13 @@ jobs:
asset_name: openethereum-macos-${{ env.RELEASE_VERSION }}.zip
asset_content_type: application/zip
- - name: Upload Release Asset - Windows
- id: upload_release_asset_windows
- uses: actions/upload-release-asset@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ steps.create_release_draft.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
- asset_path: ./openethereum-windows-${{ env.RELEASE_VERSION }}.zip
- asset_name: openethereum-windows-${{ env.RELEASE_VERSION }}.zip
- asset_content_type: application/zip
+ # - name: Upload Release Asset - Windows
+ # id: upload_release_asset_windows
+ # uses: actions/upload-release-asset@v1
+ # env:
+ # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ # with:
+ # upload_url: ${{ steps.create_release_draft.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
+ # asset_path: ./openethereum-windows-${{ env.RELEASE_VERSION }}.zip
+ # asset_name: openethereum-windows-${{ env.RELEASE_VERSION }}.zip
+ # asset_content_type: application/zip
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
index 03edc614fd..7c9b9c6e04 100644
--- a/.github/workflows/check.yml
+++ b/.github/workflows/check.yml
@@ -4,18 +4,15 @@ on:
pull_request:
push:
branches:
- - master
- - stable
+ - main
+ - dev
jobs:
check:
name: Check
- runs-on: ubuntu-20.04
- env:
- SCCACHE_CACHE_SIZE: "1G"
- SCCACHE_IDLE_TIMEOUT: 0
+ runs-on: ubuntu-16.04
steps:
- name: Checkout sources
- uses: actions/checkout@master
+ uses: actions/checkout@main
with:
submodules: true
- name: Install stable toolchain
@@ -24,32 +21,6 @@ jobs:
toolchain: stable
profile: minimal
override: true
- - name: Cache cargo registry
- uses: actions/cache@v2
- with:
- path: ~/.cargo/registry
- key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo index
- uses: actions/cache@v2
- with:
- path: ~/.cargo/git
- key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
- - name: Cache cargo build
- uses: actions/cache@v2
- with:
- path: target
- key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- # Install sccache based on https://github.com/denoland/rusty_v8/blob/master/.github/workflows/ci.yml#L69
- - name: Cache sccache
- uses: actions/cache@v2
- with:
- path: "/home/runner/.cache/sccache"
- key: ${{ runner.os }}-sccache-check-${{ hashFiles('**/Cargo.lock') }}
- - name: Install sccache for Linux
- shell: pwsh
- run: pwsh scripts/actions/install-sccache.ps1 ${{ runner.os}}
- - name: Sccache statistics
- run: sccache --show-stats
- name: Run cargo check 1/3
uses: actions-rs/cargo@v1
with:
@@ -59,12 +30,12 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: check
- args: --locked --manifest-path util/io/Cargo.toml --no-default-features --verbose
+ args: --locked --manifest-path crates/runtime/io/Cargo.toml --no-default-features --verbose
- name: Run cargo check 3/3
uses: actions-rs/cargo@v1
with:
command: check
- args: --locked --manifest-path util/io/Cargo.toml --features "mio" --verbose
+ args: --locked --manifest-path crates/runtime/io/Cargo.toml --features "mio" --verbose
- name: Run cargo check evmbin
uses: actions-rs/cargo@v1
with:
@@ -77,10 +48,3 @@ jobs:
args: --locked --all --benches --verbose
- name: Run validate chainspecs
run: ./scripts/actions/validate-chainspecs.sh
- - name: Stop sccache
- if: always()
- run: sccache --stop-server
- continue-on-error: true
- - name: Prepare build directory for cache
- shell: bash
- run: bash scripts/actions/clean-target.sh
diff --git a/.github/workflows/crunch42-analysis.yml b/.github/workflows/crunch42-analysis.yml
new file mode 100644
index 0000000000..2c71f6f35e
--- /dev/null
+++ b/.github/workflows/crunch42-analysis.yml
@@ -0,0 +1,49 @@
+'pollyramos'
+# This workflow locates REST API file contracts
+# (Swagger or OpenAPI format, v2 and v3, JSON and YAML)
+# and runs 200+ security checks on them using 42Crunch Security Audit technology.
+#
+# Documentation is located here: https://docs.42crunch.com/latest/content/tasks/integrate_github_actions.htm
+#
+# To use this workflow, you will need to complete the following setup steps.
+#
+# 1. Create a free 42Crunch account at https://platform.42crunch.com/register
+#
+# 2. Follow steps at https://docs.42crunch.com/latest/content/tasks/integrate_github_actions.htm
+# to create an API Token on the 42Crunch platform
+#
+# 3. Add a secret in GitHub as explained in https://docs.42crunch.com/latest/content/tasks/integrate_github_actions.htm,
+# store the 42Crunch API Token in that secret, and supply the secret's name as api-token parameter in this workflow
+#
+# If you have any questions or need help contact https://support.42crunch.com
+
+name: "42Crunch REST API Static Security Testing"
+
+# follow standard Code Scanning triggers
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ main ]
+ schedule:
+ - cron: '22 14 * * 1'
+
+jobs:
+ rest-api-static-security-testing:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: 42Crunch REST API Static Security Testing
+ uses: 42Crunch/api-security-audit-action@v1
+ with:
+ # Please create free account at https://platform.42crunch.com/register
+ # Follow these steps to configure API_TOKEN https://docs.42crunch.com/latest/content/tasks/integrate_github_actions.htm
+ api-token: ${{ secrets.API_TOKEN }}
+ # Fail if any OpenAPI file scores lower than 75
+ min-score: 75
+ # Upload results to Github code scanning
+ upload-to-code-scanning: true
+ # Github token for uploading the results
+ github-token: ${{ github.token }}
diff --git a/.github/workflows/deploy-docker-nightly.yml b/.github/workflows/deploy-docker-nightly.yml
new file mode 100644
index 0000000000..5edea37968
--- /dev/null
+++ b/.github/workflows/deploy-docker-nightly.yml
@@ -0,0 +1,29 @@
+name: Docker Image Nightly Release
+
+# Run "nightly" build on each commit to "dev" branch.
+on:
+ push:
+ branches:
+ - dev
+
+jobs:
+ deploy-docker:
+ name: Build Release
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@master
+ - name: Install toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ toolchain: stable
+ profile: minimal
+ override: true
+ - name: Deploy to docker hub
+ uses: elgohr/Publish-Docker-Github-Action@v5
+ with:
+ name: openethereum/openethereum
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ dockerfile: scripts/docker/alpine/Dockerfile
+ tags: "nightly"
diff --git a/.github/workflows/deploy-docker-tag.yml b/.github/workflows/deploy-docker-tag.yml
new file mode 100644
index 0000000000..2407be60a9
--- /dev/null
+++ b/.github/workflows/deploy-docker-tag.yml
@@ -0,0 +1,30 @@
+name: Docker Image Tag and Latest Release
+
+on:
+ push:
+ tags:
+ - v*
+
+jobs:
+ deploy-docker:
+ name: Build Release
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@master
+ - name: Set env
+ run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
+ - name: Install toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ toolchain: stable
+ profile: minimal
+ override: true
+ - name: Deploy to docker hub
+ uses: elgohr/Publish-Docker-Github-Action@v5
+ with:
+ name: openethereum/openethereum
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ dockerfile: scripts/docker/alpine/Dockerfile
+ tags: "latest,${{ env.RELEASE_VERSION }}"
diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml
new file mode 100644
index 0000000000..e645b9822e
--- /dev/null
+++ b/.github/workflows/deploy-docker.yml
@@ -0,0 +1,30 @@
+name: Docker Image Release
+
+on:
+ push:
+ branches:
+ - main
+ tags:
+ - v*
+
+jobs:
+ deploy-docker:
+ name: Build Release
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@master
+ - name: Install toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ toolchain: stable
+ profile: minimal
+ override: true
+ - name: Deploy to docker hub
+ uses: elgohr/Publish-Docker-Github-Action@v5
+ with:
+ name: openethereum/openethereum
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ dockerfile: scripts/docker/alpine/Dockerfile
+ tag_names: true
diff --git a/.gitmodules b/.gitmodules
index b49256b4df..2789e41fb5 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,7 +1,3 @@
-[submodule "ethcore/res/ethereum/tests"]
- path = ethcore/res/ethereum/tests
+[submodule "crates/ethcore/res/json_tests"]
+ path = crates/ethcore/res/json_tests
url = https://github.com/ethereum/tests.git
- branch = develop
-[submodule "ethcore/res/wasm-tests"]
- path = ethcore/res/wasm-tests
- url = https://github.com/paritytech/wasm-tests
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6fdf1b30ae..824ca01b40 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,34 +1,45 @@
-## OpenEthereum v3.1RC1
+## OpenEthereum v3.2.2-rc.1
-OpenEthereum 3.1rc1 is a candidate release based on v2.5.13 which is the last stable version known of the client that does not include any of the issues introduced in v2.7.
-It removes non core features like Ethereum Classic, Private Transactions, Light Client, Updater, IPFS and Swarm support, currently deprecated flags such as expanse, kotti, mordor testnets.
+Bug fixes:
+* Backport: Block sync stopped without any errors. #277 (#286)
+* Strict memory order (#306)
-Database migration utility currently in beta: https://github.com/openethereum/3.1-db-upgrade-tool
+Enhancements:
+* Executable queue for ancient blocks inclusion (#208)
+* Backport AuRa commits for xdai (#330)
+* Add Nethermind to clients that accept service transactions (#324)
+* Implement the filter argument in parity_pendingTransactions (#295)
+* Ethereum-types and various libs upgraded (#315)
+* Bump ethereum/tests to v8.0.2
+* [evmbin] Omit storage output, now for std-json (#311)
+* Freeze pruning while creating snapshot (#205)
+* AuRa multi block reward (#290)
+* Improved metrics. DB read/write. prometheus prefix config (#240)
+* Send RLPx auth in EIP-8 format (#287)
+* rpc module reverted for RPC JSON api (#284)
+* Revert "Remove eth/63 protocol version (#252)"
-The full list of included changes from v2.5.13 to v3.1:
+devops:
+* Upgrade docker alpine to `v1.13.2`. for rust `v1.47`.
+* Send SIGTERM instead of SIGHUP to OE daemon (#317)
-- Remove classic, kotti, mordor, expanse (#52)
-- Added bad block header hash for ropsten (#49)
-- Remove accounts bloom (#33)
-- Bump jsonrpc-- to v15
-- Implement eth/64, remove eth/62 (#46)
-- No snapshotting by default (#11814)
-- Update Ellaism chainspec
-- Prometheus, heavy memory calls removed (#27)
-- Update ethereum/tests
-- Implement JSON test suite (#11801)
-- Fix issues during block sync (#11265)
-- Fix race same block (#11400)
-- EIP-2537: Precompile for BLS12-381 curve operations (#11707)
-- Remove private transactions
-- Remove GetNodeData
-- Remove IPFS integration (#11532)
-- Remove updater
-- Remove light client
-- Remove C and Java bindings (#11346)
-- Remove whisper (#10855)
-- EIP-2315: Simple Subroutines for the EVM (#11629)
-- Remove deprecated flags (removal of --geth flag)
-- Remove support for hardware wallets (#10678)
-- Update bootnodes
+## OpenEthereum v3.2.1
+Hot fix issue, related to initial sync:
+* Initial sync gets stuck. (#318)
+## OpenEthereum v3.2.0
+
+Bug fixes:
+* Update EWF's chains with Istanbul transition block numbers (#11482) (#254)
+* fix Supplied instant is later than self (#169)
+* ethcore/snapshot: fix double-lock in Service::feed_chunk (#289)
+
+Enhancements:
+* Berlin hardfork blocks: mainnet (12,244,000), goerli (4,460,644), rinkeby (8,290,928) and ropsten (9,812,189)
+* yolo3x spec (#241)
+* EIP-2930 RPC support
+* Remove eth/63 protocol version (#252)
+* Snapshot manifest block added to prometheus (#232)
+* EIP-1898: Allow default block parameter to be blockHash
+* Change ProtocolId to U64
+* Update ethereum/tests
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index e9fe52db71..bf43a6f2ca 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,5 +1,11 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
+[[package]]
+name = "adler32"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
+
[[package]]
name = "aes"
version = "0.3.2"
@@ -45,6 +51,21 @@ dependencies = [
"stream-cipher",
]
+[[package]]
+name = "ahash"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29661b60bec623f0586702976ff4d0c9942dcb6723161c2df0eea78455cfedfb"
+dependencies = [
+ "const-random",
+]
+
+[[package]]
+name = "ahash"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217"
+
[[package]]
name = "aho-corasick"
version = "0.6.10"
@@ -89,12 +110,6 @@ dependencies = [
"xdg",
]
-[[package]]
-name = "arrayref"
-version = "0.3.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"
-
[[package]]
name = "arrayvec"
version = "0.4.12"
@@ -145,7 +160,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea"
dependencies = [
"backtrace-sys",
- "cfg-if",
+ "cfg-if 0.1.10",
"libc",
"rustc-demangle",
]
@@ -216,16 +231,6 @@ dependencies = [
"radium",
]
-[[package]]
-name = "block-buffer"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab"
-dependencies = [
- "arrayref",
- "byte-tools 0.2.0",
-]
-
[[package]]
name = "block-buffer"
version = "0.7.3"
@@ -233,9 +238,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
dependencies = [
"block-padding",
- "byte-tools 0.3.1",
+ "byte-tools",
"byteorder",
- "generic-array 0.12.3",
+ "generic-array",
]
[[package]]
@@ -244,7 +249,7 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774"
dependencies = [
- "generic-array 0.12.3",
+ "generic-array",
]
[[package]]
@@ -263,7 +268,7 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09"
dependencies = [
- "byte-tools 0.3.1",
+ "byte-tools",
]
[[package]]
@@ -272,7 +277,7 @@ version = "0.1.0"
dependencies = [
"byteorder",
"criterion 0.3.0",
- "ethbloom 0.5.0",
+ "ethbloom",
"parking_lot 0.7.1",
"tempdir",
"tiny-keccak 1.5.0",
@@ -287,7 +292,7 @@ dependencies = [
"crunchy 0.2.2",
"lazy_static",
"rand 0.5.6",
- "rustc-hex 2.0.1",
+ "rustc-hex 2.1.0",
]
[[package]]
@@ -314,12 +319,6 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3"
-[[package]]
-name = "byte-tools"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
-
[[package]]
name = "byte-tools"
version = "0.3.1"
@@ -360,9 +359,9 @@ checksum = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427"
[[package]]
name = "cc"
-version = "1.0.47"
+version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8"
+checksum = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff"
[[package]]
name = "cfg-if"
@@ -370,6 +369,12 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
[[package]]
name = "chainspec"
version = "0.1.0"
@@ -409,7 +414,7 @@ dependencies = [
name = "cli-signer"
version = "1.4.0"
dependencies = [
- "ethereum-types 0.4.2",
+ "ethereum-types",
"futures",
"parity-rpc",
"parity-rpc-client",
@@ -438,23 +443,44 @@ dependencies = [
name = "common-types"
version = "0.1.0"
dependencies = [
- "ethereum-types 0.4.2",
- "ethjson",
+ "ethereum-types",
"ethkey",
- "heapsize",
+ "hex",
+ "inflate",
"keccak-hash",
"parity-bytes",
- "rlp 0.3.0",
+ "parity-crypto",
+ "parity-util-mem",
+ "rlp",
"rlp_derive",
"rustc-hex 1.0.0",
+ "serde",
+ "serde_json",
+ "serde_repr",
"unexpected",
]
[[package]]
-name = "constant_time_eq"
-version = "0.1.4"
+name = "const-random"
+version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120"
+checksum = "f590d95d011aa80b063ffe3253422ed5aa462af4e9867d43ce8337562bac77c4"
+dependencies = [
+ "const-random-macro",
+ "proc-macro-hack",
+]
+
+[[package]]
+name = "const-random-macro"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "615f6e27d000a2bffbc7f2f6a8669179378fa27ee4d0a509e985dfc0a7defb40"
+dependencies = [
+ "getrandom 0.2.2",
+ "lazy_static",
+ "proc-macro-hack",
+ "tiny-keccak 2.0.2",
+]
[[package]]
name = "crc"
@@ -565,11 +591,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9"
dependencies = [
"arrayvec 0.4.12",
- "cfg-if",
+ "cfg-if 0.1.10",
"crossbeam-utils 0.6.6",
"lazy_static",
"memoffset",
- "scopeguard 1.0.0",
+ "scopeguard 1.1.0",
]
[[package]]
@@ -587,7 +613,7 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"crossbeam-utils 0.7.2",
"maybe-uninit",
]
@@ -598,7 +624,7 @@ version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"lazy_static",
]
@@ -609,7 +635,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg 1.0.0",
- "cfg-if",
+ "cfg-if 0.1.10",
"lazy_static",
]
@@ -625,23 +651,13 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
-[[package]]
-name = "crypto-mac"
-version = "0.6.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7afa06d05a046c7a47c3a849907ec303504608c927f4e85f7bfff22b7180d971"
-dependencies = [
- "constant_time_eq",
- "generic-array 0.9.0",
-]
-
[[package]]
name = "crypto-mac"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5"
dependencies = [
- "generic-array 0.12.3",
+ "generic-array",
"subtle 1.0.0",
]
@@ -713,22 +729,13 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8"
-[[package]]
-name = "digest"
-version = "0.7.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90"
-dependencies = [
- "generic-array 0.9.0",
-]
-
[[package]]
name = "digest"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
dependencies = [
- "generic-array 0.12.3",
+ "generic-array",
]
[[package]]
@@ -736,7 +743,7 @@ name = "dir"
version = "0.1.2"
dependencies = [
"app_dirs",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"home 0.3.4",
"journaldb",
]
@@ -763,7 +770,7 @@ checksum = "bbbaaaf38131deb9ca518a274a45bfdb8771f139517b073b16c2d3d32ae5037b"
name = "eip-152"
version = "0.1.0"
dependencies = [
- "rustc-hex 2.0.1",
+ "rustc-hex 2.1.0",
]
[[package]]
@@ -771,7 +778,7 @@ name = "eip-712"
version = "0.1.0"
dependencies = [
"ethabi",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"failure",
"indexmap",
"itertools 0.7.11",
@@ -779,7 +786,7 @@ dependencies = [
"lazy_static",
"lunarity-lexer",
"regex 1.3.9",
- "rustc-hex 2.0.1",
+ "rustc-hex 2.1.0",
"serde",
"serde_derive",
"serde_json",
@@ -837,12 +844,12 @@ dependencies = [
[[package]]
name = "eth-secp256k1"
version = "0.5.7"
-source = "git+https://github.com/paritytech/rust-secp256k1?rev=ccc06e7480148b723eb44ac56cf4d20eec380b6f#ccc06e7480148b723eb44ac56cf4d20eec380b6f"
+source = "git+https://github.com/paritytech/rust-secp256k1?rev=9791e79f21a5309dcb6e0bd254b1ef88fca2f1f4#9791e79f21a5309dcb6e0bd254b1ef88fca2f1f4"
dependencies = [
"arrayvec 0.4.12",
"cc",
- "cfg-if",
- "rand 0.4.6",
+ "cfg-if 0.1.10",
+ "rand 0.6.5",
]
[[package]]
@@ -873,36 +880,35 @@ dependencies = [
[[package]]
name = "ethabi"
-version = "6.1.0"
+version = "12.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8eb362fde43ed0b50b258bb0c72b72b3dccfd29f8de9506295eaf9251c49ca31"
+checksum = "052a565e3de82944527d6d10a465697e6bb92476b772ca7141080c901f6a63c6"
dependencies = [
- "error-chain",
- "ethereum-types 0.4.2",
- "rustc-hex 2.0.1",
+ "ethereum-types",
+ "rustc-hex 2.1.0",
"serde",
- "serde_derive",
"serde_json",
"tiny-keccak 1.5.0",
+ "uint",
]
[[package]]
name = "ethabi-contract"
-version = "6.0.0"
+version = "11.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "795e25fd868e12a59ca235dbe1f6cc8f1eba8f67d6a39438b29535e0126e0c27"
+checksum = "88d4002f1f77d8233685dafd8589efe1c9dfa63e21ca6c11134372acc7f68032"
[[package]]
name = "ethabi-derive"
-version = "6.0.2"
+version = "12.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "66a587250c8190be9d6ae28d67b8957ed97cb9eee2e272173a20593ab054a075"
+checksum = "b7c0fe66618e0cfcf111afc863e7940413f2a88240cf63b38cc61206fe7be025"
dependencies = [
"ethabi",
"heck",
- "proc-macro2 0.4.30",
- "quote 0.6.13",
- "syn 0.15.26",
+ "proc-macro2 1.0.20",
+ "quote 1.0.7",
+ "syn 1.0.40",
]
[[package]]
@@ -912,7 +918,7 @@ dependencies = [
"criterion 0.2.11",
"crunchy 0.1.6",
"either",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"keccak-hash",
"log",
"memmap",
@@ -921,19 +927,7 @@ dependencies = [
"rustc-hex 1.0.0",
"serde_json",
"tempdir",
-]
-
-[[package]]
-name = "ethbloom"
-version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a93a43ce2e9f09071449da36bfa7a1b20b950ee344b6904ff23de493b03b386"
-dependencies = [
- "crunchy 0.1.6",
- "ethereum-types-serialize",
- "fixed-hash 0.2.2",
- "serde",
- "tiny-keccak 1.5.0",
+ "tiny-keccak 2.0.2",
]
[[package]]
@@ -943,7 +937,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df"
dependencies = [
"crunchy 0.2.2",
- "fixed-hash 0.6.1",
+ "fixed-hash",
"impl-rlp",
"impl-serde",
"tiny-keccak 2.0.2",
@@ -958,6 +952,7 @@ dependencies = [
"common-types",
"criterion 0.2.11",
"crossbeam-utils 0.6.6",
+ "derive_more",
"eip-152",
"env_logger",
"error-chain",
@@ -974,14 +969,13 @@ dependencies = [
"ethcore-io",
"ethcore-miner",
"ethcore-stratum",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethjson",
"ethkey",
"evm",
"fetch",
"globset",
- "hash-db",
- "heapsize",
+ "hash-db 0.11.0",
"hex-literal",
"itertools 0.5.10",
"journaldb",
@@ -1000,17 +994,22 @@ dependencies = [
"memory-db 0.11.0",
"num_cpus",
"parity-bytes",
+ "parity-crypto",
"parity-runtime",
"parity-snappy",
+ "parity-util-mem",
"parking_lot 0.7.1",
"patricia-trie-ethereum",
- "rand 0.4.6",
+ "rand 0.7.3",
+ "rand_xorshift 0.2.0",
"rayon",
"regex 1.3.9",
- "rlp 0.3.0",
+ "reth-util",
+ "rlp",
"rlp_compress",
"rlp_derive",
"rustc-hex 1.0.0",
+ "scopeguard 1.1.0",
"serde",
"serde_derive",
"serde_json",
@@ -1034,10 +1033,11 @@ name = "ethcore-accounts"
version = "0.1.0"
dependencies = [
"common-types",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethkey",
"ethstore",
"log",
+ "parity-crypto",
"parking_lot 0.7.1",
"serde",
"serde_derive",
@@ -1054,22 +1054,24 @@ dependencies = [
"common-types",
"env_logger",
"ethcore-db",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethkey",
- "heapsize",
"itertools 0.5.10",
"keccak-hash",
"kvdb",
"kvdb-memorydb",
"log",
"parity-bytes",
+ "parity-crypto",
+ "parity-util-mem",
"parking_lot 0.7.1",
- "rand 0.6.5",
+ "rand 0.7.3",
"rayon",
- "rlp 0.3.0",
+ "rlp",
"rlp_compress",
"rlp_derive",
"rustc-hex 1.0.0",
+ "stats",
"tempdir",
"triehash-ethereum",
]
@@ -1089,7 +1091,7 @@ dependencies = [
"byteorder",
"eip-152",
"eth_pairings",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethjson",
"ethkey",
"hex-literal",
@@ -1099,7 +1101,8 @@ dependencies = [
"maplit",
"num",
"parity-bytes",
- "parity-crypto 0.4.2",
+ "parity-crypto",
+ "rustc-hex 1.0.0",
]
[[package]]
@@ -1107,7 +1110,7 @@ name = "ethcore-call-contract"
version = "0.1.0"
dependencies = [
"common-types",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"parity-bytes",
]
@@ -1116,12 +1119,15 @@ name = "ethcore-db"
version = "0.1.0"
dependencies = [
"common-types",
- "ethereum-types 0.4.2",
- "heapsize",
+ "ethereum-types",
"kvdb",
+ "kvdb-memorydb",
+ "kvdb-rocksdb",
+ "parity-util-mem",
"parking_lot 0.7.1",
- "rlp 0.3.0",
+ "rlp",
"rlp_derive",
+ "stats",
]
[[package]]
@@ -1169,20 +1175,24 @@ dependencies = [
"ethabi-derive",
"ethash",
"ethcore-call-contract",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethkey",
"fetch",
"futures",
- "heapsize",
"hyper 0.12.35",
"keccak-hash",
"linked-hash-map",
"log",
+ "parity-crypto",
"parity-runtime",
+ "parity-util-mem",
"parking_lot 0.7.1",
"price-info",
- "rlp 0.3.0",
+ "rlp",
"rustc-hex 1.0.0",
+ "serde",
+ "serde_derive",
+ "serde_json",
"trace-time",
"transaction-pool",
"url 2.1.0",
@@ -1195,14 +1205,14 @@ dependencies = [
"assert_matches",
"error-chain",
"ethcore-io",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethkey",
"ipnetwork",
"lazy_static",
"libc",
- "parity-crypto 0.3.1",
+ "parity-crypto",
"parity-snappy",
- "rlp 0.3.0",
+ "rlp",
"semver",
"serde",
"serde_derive",
@@ -1219,7 +1229,7 @@ dependencies = [
"error-chain",
"ethcore-io",
"ethcore-network",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethkey",
"igd",
"ipnetwork",
@@ -1229,12 +1239,12 @@ dependencies = [
"lru-cache",
"mio",
"parity-bytes",
- "parity-crypto 0.3.1",
+ "parity-crypto",
"parity-path",
"parity-snappy",
"parking_lot 0.7.1",
- "rand 0.4.6",
- "rlp 0.3.0",
+ "rand 0.7.3",
+ "rlp",
"rust-crypto",
"rustc-hex 1.0.0",
"serde",
@@ -1245,47 +1255,6 @@ dependencies = [
"tiny-keccak 1.5.0",
]
-[[package]]
-name = "ethcore-secretstore"
-version = "1.0.0"
-dependencies = [
- "byteorder",
- "common-types",
- "env_logger",
- "ethabi",
- "ethabi-contract",
- "ethabi-derive",
- "ethcore",
- "ethcore-accounts",
- "ethcore-call-contract",
- "ethcore-sync",
- "ethereum-types 0.4.2",
- "ethkey",
- "futures",
- "hyper 0.12.35",
- "jsonrpc-server-utils",
- "keccak-hash",
- "kvdb",
- "kvdb-rocksdb",
- "lazy_static",
- "log",
- "parity-bytes",
- "parity-crypto 0.3.1",
- "parity-runtime",
- "parking_lot 0.7.1",
- "percent-encoding 2.1.0",
- "rustc-hex 1.0.0",
- "serde",
- "serde_derive",
- "serde_json",
- "tempdir",
- "tiny-keccak 1.5.0",
- "tokio",
- "tokio-io",
- "tokio-service",
- "url 2.1.0",
-]
-
[[package]]
name = "ethcore-service"
version = "0.1.0"
@@ -1297,7 +1266,7 @@ dependencies = [
"ethcore-db",
"ethcore-io",
"ethcore-sync",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"kvdb",
"kvdb-rocksdb",
"log",
@@ -1310,7 +1279,7 @@ name = "ethcore-stratum"
version = "1.12.0"
dependencies = [
"env_logger",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"jsonrpc-core",
"jsonrpc-tcp-server",
"keccak-hash",
@@ -1333,12 +1302,11 @@ dependencies = [
"ethcore-network",
"ethcore-network-devp2p",
"ethereum-forkid",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethkey",
"ethstore",
"fastmap",
- "hash-db",
- "heapsize",
+ "hash-db 0.11.0",
"keccak-hash",
"keccak-hasher 0.1.1",
"kvdb",
@@ -1346,11 +1314,13 @@ dependencies = [
"log",
"macros",
"parity-bytes",
+ "parity-crypto",
+ "parity-util-mem",
"parking_lot 0.7.1",
"primitive-types",
- "rand 0.4.6",
- "rlp 0.3.0",
- "rlp 0.4.5",
+ "rand 0.7.3",
+ "rand_xorshift 0.2.0",
+ "rlp",
"rustc-hex 1.0.0",
"stats",
"trace-time",
@@ -1364,57 +1334,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3010d8372e3a76d4e2c44de0a080257ab62b6d108857ee7bd70fe8dfb2815f13"
dependencies = [
"crc",
- "ethereum-types 0.9.2",
+ "ethereum-types",
"maplit",
"parity-util-mem",
- "rlp 0.4.5",
+ "rlp",
"rlp-derive",
]
-[[package]]
-name = "ethereum-types"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e742184dc63a01c8ea0637369f8faa27c40f537949908a237f95c05e68d2c96"
-dependencies = [
- "crunchy 0.1.6",
- "ethbloom 0.5.0",
- "ethereum-types-serialize",
- "fixed-hash 0.2.2",
- "serde",
- "uint 0.4.1",
-]
-
[[package]]
name = "ethereum-types"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0"
dependencies = [
- "ethbloom 0.9.2",
- "fixed-hash 0.6.1",
+ "ethbloom",
+ "fixed-hash",
"impl-rlp",
"impl-serde",
"primitive-types",
- "uint 0.8.5",
-]
-
-[[package]]
-name = "ethereum-types-serialize"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1873d77b32bc1891a79dad925f2acbc318ee942b38b9110f9dbc5fbeffcea350"
-dependencies = [
- "serde",
+ "uint",
]
[[package]]
name = "ethjson"
version = "0.1.0"
dependencies = [
- "ethereum-types 0.4.2",
+ "common-types",
+ "ethereum-types",
"macros",
"maplit",
+ "parity-crypto",
"rustc-hex 1.0.0",
"serde",
"serde_derive",
@@ -1427,14 +1376,14 @@ version = "0.3.0"
dependencies = [
"edit-distance",
"eth-secp256k1",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"lazy_static",
"log",
"memzero",
- "parity-crypto 0.3.1",
+ "parity-crypto",
"parity-wordlist",
"quick-error",
- "rand 0.4.6",
+ "rand 0.7.3",
"rustc-hex 1.0.0",
"serde",
"serde_derive",
@@ -1449,6 +1398,7 @@ dependencies = [
"env_logger",
"ethkey",
"panic_hook",
+ "parity-crypto",
"parity-wordlist",
"rustc-hex 1.0.0",
"serde",
@@ -1460,18 +1410,17 @@ dependencies = [
name = "ethstore"
version = "0.2.1"
dependencies = [
- "dir",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethkey",
"itertools 0.5.10",
"lazy_static",
"libc",
"log",
"matches",
- "parity-crypto 0.3.1",
+ "parity-crypto",
"parity-wordlist",
"parking_lot 0.7.1",
- "rand 0.4.6",
+ "rand 0.7.3",
"rustc-hex 1.0.0",
"serde",
"serde_derive",
@@ -1479,7 +1428,6 @@ dependencies = [
"smallvec 0.6.13",
"tempdir",
"time",
- "tiny-keccak 1.5.0",
]
[[package]]
@@ -1505,8 +1453,8 @@ version = "0.1.0"
dependencies = [
"bit-set",
"criterion 0.2.11",
- "ethereum-types 0.4.2",
- "heapsize",
+ "ethcore-builtin",
+ "ethereum-types",
"hex-literal",
"keccak-hash",
"lazy_static",
@@ -1514,6 +1462,7 @@ dependencies = [
"memory-cache",
"num-bigint 0.2.3",
"parity-bytes",
+ "parity-util-mem",
"parking_lot 0.7.1",
"rustc-hex 1.0.0",
"vm",
@@ -1528,7 +1477,7 @@ dependencies = [
"docopt",
"env_logger",
"ethcore",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethjson",
"evm",
"panic_hook",
@@ -1561,7 +1510,7 @@ dependencies = [
"proc-macro2 1.0.20",
"quote 1.0.7",
"syn 1.0.40",
- "synstructure 0.12.2",
+ "synstructure",
]
[[package]]
@@ -1583,7 +1532,7 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
name = "fastmap"
version = "0.1.0"
dependencies = [
- "ethereum-types 0.4.2",
+ "ethereum-types",
"plain_hasher",
]
@@ -1610,18 +1559,6 @@ dependencies = [
"url 2.1.0",
]
-[[package]]
-name = "fixed-hash"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d5ec8112f00ea8a483e04748a85522184418fd1cf02890b626d8fc28683f7de"
-dependencies = [
- "heapsize",
- "libc",
- "rand 0.4.6",
- "rustc-hex 1.0.0",
-]
-
[[package]]
name = "fixed-hash"
version = "0.6.1"
@@ -1629,8 +1566,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c"
dependencies = [
"byteorder",
- "rand 0.7.2",
- "rustc-hex 2.0.1",
+ "rand 0.7.3",
+ "rustc-hex 2.1.0",
"static_assertions",
]
@@ -1674,12 +1611,6 @@ dependencies = [
"winapi 0.3.8",
]
-[[package]]
-name = "fs_extra"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
-
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
@@ -1733,15 +1664,6 @@ version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
-[[package]]
-name = "generic-array"
-version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
-dependencies = [
- "typenum",
-]
-
[[package]]
name = "generic-array"
version = "0.12.3"
@@ -1766,9 +1688,20 @@ version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
+ "libc",
+ "wasi 0.7.0",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
+dependencies = [
+ "cfg-if 1.0.0",
"libc",
- "wasi",
+ "wasi 0.10.2+wasi-snapshot-preview1",
]
[[package]]
@@ -1814,6 +1747,12 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03501f6e1a2a97f1618879aba3156f14ca2847faa530c4e28859638bd11483"
+[[package]]
+name = "hash-db"
+version = "0.15.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a"
+
[[package]]
name = "hash256-std-hasher"
version = "0.11.0"
@@ -1823,12 +1762,41 @@ dependencies = [
"crunchy 0.2.2",
]
+[[package]]
+name = "hash256-std-hasher"
+version = "0.15.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2"
+dependencies = [
+ "crunchy 0.2.2",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead"
+dependencies = [
+ "ahash 0.2.19",
+ "autocfg 0.1.7",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25"
+dependencies = [
+ "ahash 0.3.8",
+ "autocfg 1.0.0",
+]
+
[[package]]
name = "heapsize"
version = "0.4.2"
-source = "git+https://github.com/cheme/heapsize.git?branch=ec-macfix#c07ffe843acb9da570682e290a48540741afdce1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461"
dependencies = [
- "jemallocator",
"winapi 0.3.8",
]
@@ -1850,6 +1818,12 @@ dependencies = [
"libc",
]
+[[package]]
+name = "hex"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+
[[package]]
name = "hex-literal"
version = "0.2.1"
@@ -1869,24 +1843,14 @@ dependencies = [
"proc-macro-hack",
]
-[[package]]
-name = "hmac"
-version = "0.6.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "733e1b3ac906631ca01ebb577e9bb0f5e37a454032b9036b5eaea4013ed6f99a"
-dependencies = [
- "crypto-mac 0.6.2",
- "digest 0.7.6",
-]
-
[[package]]
name = "hmac"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695"
dependencies = [
- "crypto-mac 0.7.0",
- "digest 0.8.1",
+ "crypto-mac",
+ "digest",
]
[[package]]
@@ -1905,7 +1869,7 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3753954f7bd71f0e671afb8b5a992d1724cf43b7f95a563cd4a0bde94659ca8"
dependencies = [
- "scopeguard 1.0.0",
+ "scopeguard 1.1.0",
"winapi 0.3.8",
]
@@ -2080,7 +2044,7 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5"
dependencies = [
- "rlp 0.4.5",
+ "rlp",
]
[[package]]
@@ -2112,6 +2076,15 @@ dependencies = [
"autocfg 0.1.7",
]
+[[package]]
+name = "inflate"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
+dependencies = [
+ "adler32",
+]
+
[[package]]
name = "interleaved-ordered"
version = "0.1.1"
@@ -2166,36 +2139,15 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
-[[package]]
-name = "jemalloc-sys"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae"
-dependencies = [
- "cc",
- "fs_extra",
- "libc",
-]
-
-[[package]]
-name = "jemallocator"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3"
-dependencies = [
- "jemalloc-sys",
- "libc",
-]
-
[[package]]
name = "journaldb"
version = "0.2.0"
dependencies = [
"env_logger",
- "ethereum-types 0.4.2",
+ "ethcore-db",
+ "ethereum-types",
"fastmap",
- "hash-db",
- "heapsize",
+ "hash-db 0.11.0",
"keccak-hash",
"keccak-hasher 0.1.1",
"kvdb",
@@ -2203,8 +2155,9 @@ dependencies = [
"log",
"memory-db 0.11.0",
"parity-bytes",
+ "parity-util-mem",
"parking_lot 0.7.1",
- "rlp 0.3.0",
+ "rlp",
]
[[package]]
@@ -2270,7 +2223,7 @@ dependencies = [
"jsonrpc-core",
"log",
"parking_lot 0.10.2",
- "rand 0.7.2",
+ "rand 0.7.3",
"serde",
]
@@ -2319,20 +2272,20 @@ dependencies = [
[[package]]
name = "keccak-hash"
-version = "0.1.2"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "253bbe643c32c816bf58fa5a88248fafedeebb139705ad17a62add3517854a86"
+checksum = "1f58a51ef3df9398cf2434bea8d4eb61fb748d0feb1571f87388579a120a4c8f"
dependencies = [
- "ethereum-types 0.4.2",
- "tiny-keccak 1.5.0",
+ "primitive-types",
+ "tiny-keccak 2.0.2",
]
[[package]]
name = "keccak-hasher"
version = "0.1.1"
dependencies = [
- "ethereum-types 0.4.2",
- "hash-db",
+ "ethereum-types",
+ "hash-db 0.11.0",
"plain_hasher",
"tiny-keccak 1.5.0",
]
@@ -2343,11 +2296,22 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb9d3670023f4c04153d90b8a557a822d1b27ed702bb015a87cf7bffead5b611"
dependencies = [
- "hash-db",
- "hash256-std-hasher",
+ "hash-db 0.11.0",
+ "hash256-std-hasher 0.11.0",
"tiny-keccak 1.5.0",
]
+[[package]]
+name = "keccak-hasher"
+version = "0.15.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "711adba9940a039f4374fc5724c0a5eaca84a2d558cce62256bfe26f0dbef05e"
+dependencies = [
+ "hash-db 0.15.2",
+ "hash256-std-hasher 0.15.2",
+ "tiny-keccak 2.0.2",
+]
+
[[package]]
name = "kernel32-sys"
version = "0.2.2"
@@ -2438,9 +2402,9 @@ dependencies = [
[[package]]
name = "linked-hash-map"
-version = "0.5.2"
+version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
+checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
[[package]]
name = "local-encoding"
@@ -2469,7 +2433,7 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75"
dependencies = [
- "scopeguard 1.0.0",
+ "scopeguard 1.1.0",
]
[[package]]
@@ -2478,7 +2442,7 @@ version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
]
[[package]]
@@ -2504,6 +2468,15 @@ dependencies = [
"utf8-ranges",
]
+[[package]]
+name = "lru"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35c456c123957de3a220cd03786e0d86aa542a88b46029973b542f426da6ef34"
+dependencies = [
+ "hashbrown 0.6.3",
+]
+
[[package]]
name = "lru-cache"
version = "0.1.2"
@@ -2576,8 +2549,8 @@ dependencies = [
name = "memory-cache"
version = "0.1.0"
dependencies = [
- "heapsize",
"lru-cache",
+ "parity-util-mem",
]
[[package]]
@@ -2585,9 +2558,9 @@ name = "memory-db"
version = "0.11.0"
dependencies = [
"criterion 0.2.11",
- "hash-db",
- "heapsize",
+ "hash-db 0.11.0",
"keccak-hasher 0.11.0",
+ "parity-util-mem",
]
[[package]]
@@ -2596,7 +2569,7 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94da53143d45f6bad3753f532e56ad57a6a26c0ca6881794583310c7cb4c885f"
dependencies = [
- "hash-db",
+ "hash-db 0.11.0",
"heapsize",
]
@@ -2633,7 +2606,7 @@ version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
@@ -2715,7 +2688,7 @@ version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"libc",
"winapi 0.3.8",
]
@@ -2731,7 +2704,7 @@ dependencies = [
"ethcore-io",
"ethcore-network",
"ethcore-network-devp2p",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"kvdb-memorydb",
"log",
"lru-cache",
@@ -2862,7 +2835,7 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "openethereum"
-version = "3.1.0-rc1"
+version = "3.2.2-rc.1"
dependencies = [
"ansi_term 0.10.2",
"atty",
@@ -2882,10 +2855,9 @@ dependencies = [
"ethcore-logger",
"ethcore-miner",
"ethcore-network",
- "ethcore-secretstore",
"ethcore-service",
"ethcore-sync",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethkey",
"ethstore",
"fake-fetch",
@@ -2907,6 +2879,7 @@ dependencies = [
"number_prefix",
"panic_hook",
"parity-bytes",
+ "parity-crypto",
"parity-daemonize",
"parity-local-store",
"parity-path",
@@ -2917,8 +2890,7 @@ dependencies = [
"pretty_assertions",
"prometheus",
"regex 1.3.9",
- "registrar",
- "rlp 0.3.0",
+ "rlp",
"rpassword",
"rustc-hex 1.0.0",
"rustc_version",
@@ -2970,41 +2942,26 @@ checksum = "0c276d76c5333b8c2579e02d49a06733a55b8282d2d9b13e8d53b6406bd7e30a"
[[package]]
name = "parity-crypto"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf1b9c063d87e1507cb3807493c8d21859ef23b5414b39f81c53f0ba267d64c1"
-dependencies = [
- "aes",
- "aes-ctr",
- "block-modes",
- "digest 0.8.1",
- "quick-error",
- "ring",
- "ripemd160",
- "scrypt 0.1.2",
- "sha2 0.8.0",
- "tiny-keccak 1.5.0",
-]
-
-[[package]]
-name = "parity-crypto"
-version = "0.4.2"
+version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "27a9c2b525c93d717a234eb220c26474f8d97b08ac50d79faeac4cb6c74bf0b9"
+checksum = "88e15b5e11d7a4829490630a797c537a68c9e864a139f56fe7a1e6a51f0da25d"
dependencies = [
"aes",
"aes-ctr",
"block-modes",
- "digest 0.8.1",
- "hmac 0.7.1",
- "pbkdf2 0.3.0",
- "rand 0.7.2",
+ "digest",
+ "ethereum-types",
+ "hmac",
+ "lazy_static",
+ "pbkdf2",
+ "rand 0.7.3",
"ripemd160",
- "rustc-hex 2.0.1",
- "scrypt 0.2.0",
- "sha2 0.8.0",
- "subtle 2.1.0",
- "tiny-keccak 1.5.0",
+ "rustc-hex 2.1.0",
+ "scrypt",
+ "secp256k1",
+ "sha2",
+ "subtle 2.3.0",
+ "tiny-keccak 2.0.2",
"zeroize",
]
@@ -3026,12 +2983,14 @@ name = "parity-local-store"
version = "0.1.0"
dependencies = [
"common-types",
+ "ethcore-db",
"ethcore-io",
"ethkey",
"kvdb",
"kvdb-memorydb",
"log",
- "rlp 0.3.0",
+ "parity-crypto",
+ "rlp",
"serde",
"serde_derive",
"serde_json",
@@ -3084,7 +3043,7 @@ dependencies = [
"ethcore-miner",
"ethcore-network",
"ethcore-sync",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethjson",
"ethkey",
"ethstore",
@@ -3103,13 +3062,14 @@ dependencies = [
"macros",
"order-stat",
"parity-bytes",
- "parity-crypto 0.3.1",
+ "parity-crypto",
"parity-runtime",
"parity-version",
"parking_lot 0.7.1",
"pretty_assertions",
- "rand 0.4.6",
- "rlp 0.3.0",
+ "rand 0.7.3",
+ "rand_xorshift 0.2.0",
+ "rlp",
"rustc-hex 1.0.0",
"serde",
"serde_derive",
@@ -3127,7 +3087,7 @@ dependencies = [
name = "parity-rpc-client"
version = "1.4.0"
dependencies = [
- "ethereum-types 0.4.2",
+ "ethereum-types",
"futures",
"jsonrpc-core",
"jsonrpc-ws-server",
@@ -3193,7 +3153,7 @@ dependencies = [
"log",
"mio-named-pipes",
"miow 0.3.3",
- "rand 0.7.2",
+ "rand 0.7.3",
"tokio",
"tokio-named-pipes",
"tokio-uds",
@@ -3206,11 +3166,15 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "297ff91fa36aec49ce183484b102f6b75b46776822bd81525bfc4cc9b0dd0f5c"
dependencies = [
- "cfg-if",
- "ethereum-types 0.9.2",
+ "cfg-if 0.1.10",
+ "ethereum-types",
+ "hashbrown 0.8.2",
"impl-trait-for-tuples",
+ "lru",
"parity-util-mem-derive",
+ "parking_lot 0.10.2",
"primitive-types",
+ "smallvec 1.4.2",
"winapi 0.3.8",
]
@@ -3222,15 +3186,15 @@ checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2"
dependencies = [
"proc-macro2 1.0.20",
"syn 1.0.40",
- "synstructure 0.12.2",
+ "synstructure",
]
[[package]]
name = "parity-version"
-version = "3.1.0-rc1"
+version = "3.2.2-rc.1"
dependencies = [
"parity-bytes",
- "rlp 0.3.0",
+ "rlp",
"rustc_version",
"target_info",
"toml 0.4.10",
@@ -3268,7 +3232,7 @@ dependencies = [
"log",
"mio",
"mio-extras",
- "rand 0.7.2",
+ "rand 0.7.3",
"sha-1",
"slab 0.4.2",
"url 2.1.0",
@@ -3350,7 +3314,7 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"cloudabi",
"libc",
"redox_syscall",
@@ -3365,7 +3329,7 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"cloudabi",
"libc",
"redox_syscall",
@@ -3378,28 +3342,17 @@ name = "patricia-trie-ethereum"
version = "0.1.0"
dependencies = [
"elastic-array",
- "ethereum-types 0.4.2",
- "hash-db",
+ "ethereum-types",
+ "hash-db 0.11.0",
"journaldb",
"keccak-hash",
"keccak-hasher 0.1.1",
"memory-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes",
- "rlp 0.3.0",
+ "rlp",
"trie-db",
]
-[[package]]
-name = "pbkdf2"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c09cddfbfc98de7f76931acf44460972edb4023eb14d0c6d4018800e552d8e0"
-dependencies = [
- "byteorder",
- "crypto-mac 0.6.2",
- "generic-array 0.9.0",
-]
-
[[package]]
name = "pbkdf2"
version = "0.3.0"
@@ -3408,10 +3361,10 @@ checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9"
dependencies = [
"base64 0.9.3",
"byteorder",
- "crypto-mac 0.7.0",
- "hmac 0.7.1",
+ "crypto-mac",
+ "hmac",
"rand 0.5.6",
- "sha2 0.8.0",
+ "sha2",
"subtle 1.0.0",
]
@@ -3527,11 +3480,11 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c55c21c64d0eaa4d7ed885d959ef2d62d9e488c27c0e02d9aa5ce6c877b7d5f8"
dependencies = [
- "fixed-hash 0.6.1",
+ "fixed-hash",
"impl-codec",
"impl-rlp",
"impl-serde",
- "uint 0.8.5",
+ "uint",
]
[[package]]
@@ -3545,14 +3498,9 @@ dependencies = [
[[package]]
name = "proc-macro-hack"
-version = "0.5.11"
+version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5"
-dependencies = [
- "proc-macro2 1.0.20",
- "quote 1.0.7",
- "syn 1.0.40",
-]
+checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]]
name = "proc-macro2"
@@ -3578,7 +3526,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0ced56dee39a6e960c15c74dc48849d614586db2eaada6497477af7c7811cd"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"fnv",
"lazy_static",
"protobuf",
@@ -3601,22 +3549,6 @@ dependencies = [
"getopts",
]
-[[package]]
-name = "pwasm-run-test"
-version = "0.1.0"
-dependencies = [
- "clap",
- "env_logger",
- "ethereum-types 0.4.2",
- "ethjson",
- "rustc-hex 1.0.0",
- "serde",
- "serde_derive",
- "serde_json",
- "vm",
- "wasm",
-]
-
[[package]]
name = "pwasm-utils"
version = "0.6.2"
@@ -3709,17 +3641,17 @@ dependencies = [
"rand_jitter",
"rand_os 0.1.3",
"rand_pcg",
- "rand_xorshift",
+ "rand_xorshift 0.1.1",
"winapi 0.3.8",
]
[[package]]
name = "rand"
-version = "0.7.2"
+version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412"
+checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
- "getrandom",
+ "getrandom 0.1.13",
"libc",
"rand_chacha 0.2.1",
"rand_core 0.5.1",
@@ -3767,7 +3699,7 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
- "getrandom",
+ "getrandom 0.1.13",
]
[[package]]
@@ -3828,7 +3760,7 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a788ae3edb696cfcba1c19bfd388cc4b8c21f8a408432b199c072825084da58a"
dependencies = [
- "getrandom",
+ "getrandom 0.1.13",
"rand_core 0.5.1",
]
@@ -3851,6 +3783,15 @@ dependencies = [
"rand_core 0.3.1",
]
+[[package]]
+name = "rand_xorshift"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8"
+dependencies = [
+ "rand_core 0.5.1",
+]
+
[[package]]
name = "rand_xoshiro"
version = "0.1.0"
@@ -3958,17 +3899,6 @@ version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
-[[package]]
-name = "registrar"
-version = "0.0.1"
-dependencies = [
- "ethabi",
- "ethabi-contract",
- "ethabi-derive",
- "futures",
- "keccak-hash",
-]
-
[[package]]
name = "relay"
version = "0.1.1"
@@ -3987,6 +3917,11 @@ dependencies = [
"winapi 0.3.8",
]
+[[package]]
+name = "reth-util"
+version = "0.1.0"
+source = "git+https://github.com/gnosis/reth.git?rev=573e128#573e128487d5651f301e21faa97fc8e80f91dee8"
+
[[package]]
name = "ring"
version = "0.14.6"
@@ -4007,41 +3942,18 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a"
dependencies = [
- "block-buffer 0.7.3",
- "digest 0.8.1",
+ "block-buffer",
+ "digest",
"opaque-debug",
]
[[package]]
name = "rlp"
-version = "0.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "524c5ad554859785dfc8469df3ed5e0b5784d4d335877ed47c8d90fc0eb238fe"
-dependencies = [
- "byteorder",
- "elastic-array",
- "ethereum-types 0.4.2",
- "rustc-hex 2.0.1",
-]
-
-[[package]]
-name = "rlp"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16d1effe9845d54f90e7be8420ee49e5c94623140b97ee4bc6fb5bfddb745720"
-dependencies = [
- "byteorder",
- "ethereum-types 0.4.2",
- "rustc-hex 2.0.1",
-]
-
-[[package]]
-name = "rlp"
-version = "0.4.5"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a7d3f9bed94764eac15b8f14af59fac420c236adaff743b7bcc88e265cb4345"
+checksum = "1190dcc8c3a512f1eef5d09bb8c84c7f39e1054e174d1795482e18f5272f2e73"
dependencies = [
- "rustc-hex 2.0.1",
+ "rustc-hex 2.1.0",
]
[[package]]
@@ -4061,7 +3973,7 @@ version = "0.1.0"
dependencies = [
"elastic-array",
"lazy_static",
- "rlp 0.3.0",
+ "rlp",
]
[[package]]
@@ -4070,7 +3982,7 @@ version = "0.1.0"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
- "rlp 0.3.0",
+ "rlp",
"syn 0.15.26",
]
@@ -4119,9 +4031,9 @@ checksum = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e"
[[package]]
name = "rustc-hex"
-version = "2.0.1"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8"
+checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6"
[[package]]
name = "rustc-serialize"
@@ -4187,22 +4099,9 @@ checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
[[package]]
name = "scopeguard"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
-
-[[package]]
-name = "scrypt"
-version = "0.1.2"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8570c5e2fa69cb29d492fd4e9974b6b5facb5a888e1c6da630d4a3cd7ebfef4a"
-dependencies = [
- "byte-tools 0.3.1",
- "byteorder",
- "hmac 0.6.3",
- "pbkdf2 0.2.3",
- "sha2 0.7.1",
-]
+checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "scrypt"
@@ -4210,11 +4109,11 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "656c79d0e90d0ab28ac86bf3c3d10bfbbac91450d3f190113b4e76d9fec3cfdd"
dependencies = [
- "byte-tools 0.3.1",
+ "byte-tools",
"byteorder",
- "hmac 0.7.1",
- "pbkdf2 0.3.0",
- "sha2 0.8.0",
+ "hmac",
+ "pbkdf2",
+ "sha2",
]
[[package]]
@@ -4227,6 +4126,25 @@ dependencies = [
"untrusted",
]
+[[package]]
+name = "secp256k1"
+version = "0.17.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2932dc07acd2066ff2e3921a4419606b220ba6cd03a9935123856cc534877056"
+dependencies = [
+ "rand 0.6.5",
+ "secp256k1-sys",
+]
+
+[[package]]
+name = "secp256k1-sys"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ab2c26f0d3552a0f12e639ae8a64afc2e3db9c52fe32f5fc6c289d38519f220"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "semver"
version = "0.9.0"
@@ -4275,27 +4193,26 @@ dependencies = [
]
[[package]]
-name = "sha-1"
-version = "0.8.1"
+name = "serde_repr"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68"
+checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76"
dependencies = [
- "block-buffer 0.7.3",
- "digest 0.8.1",
- "fake-simd",
- "opaque-debug",
+ "proc-macro2 1.0.20",
+ "quote 1.0.7",
+ "syn 1.0.40",
]
[[package]]
-name = "sha2"
-version = "0.7.1"
+name = "sha-1"
+version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0"
+checksum = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68"
dependencies = [
- "block-buffer 0.3.3",
- "byte-tools 0.2.0",
- "digest 0.7.6",
+ "block-buffer",
+ "digest",
"fake-simd",
+ "opaque-debug",
]
[[package]]
@@ -4304,8 +4221,8 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d"
dependencies = [
- "block-buffer 0.7.3",
- "digest 0.8.1",
+ "block-buffer",
+ "digest",
"fake-simd",
"opaque-debug",
]
@@ -4327,7 +4244,7 @@ source = "git+https://github.com/matter-labs/eip1962.git?rev=ece6cbabc41948db420
dependencies = [
"byteorder",
"crunchy 0.2.2",
- "rustc-hex 2.0.1",
+ "rustc-hex 2.1.0",
"static_assertions",
]
@@ -4386,7 +4303,7 @@ version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"libc",
"redox_syscall",
"winapi 0.3.8",
@@ -4424,7 +4341,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c"
dependencies = [
- "generic-array 0.12.3",
+ "generic-array",
]
[[package]]
@@ -4456,9 +4373,9 @@ checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee"
[[package]]
name = "subtle"
-version = "2.1.0"
+version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829"
+checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd"
[[package]]
name = "syn"
@@ -4482,18 +4399,6 @@ dependencies = [
"unicode-xid 0.2.0",
]
-[[package]]
-name = "synstructure"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
-dependencies = [
- "proc-macro2 0.4.30",
- "quote 0.6.13",
- "syn 0.15.26",
- "unicode-xid 0.1.0",
-]
-
[[package]]
name = "synstructure"
version = "0.12.2"
@@ -4528,9 +4433,9 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"libc",
- "rand 0.7.2",
+ "rand 0.7.3",
"redox_syscall",
"remove_dir_all",
"winapi 0.3.8",
@@ -5012,38 +4917,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c7319e28ca295f27359d944a682f7f65b419158bf1590c92cadc0000258d788"
dependencies = [
"elastic-array",
- "hash-db",
+ "hash-db 0.11.0",
"log",
"rand 0.6.5",
]
[[package]]
name = "trie-standardmap"
-version = "0.1.1"
+version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e26f52976a57a0859616d6fcec87092ac35d08eabbd78dc3dabee93b480ea5f"
+checksum = "c3161ba520ab28cd8e6b68e1126f1009f6e335339d1a73b978139011703264c8"
dependencies = [
- "ethereum-types 0.4.2",
- "keccak-hash",
- "parity-bytes",
- "rlp 0.2.4",
+ "hash-db 0.15.2",
+ "keccak-hasher 0.15.3",
]
[[package]]
name = "triehash"
-version = "0.4.0"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d26efb4ddf87870fc08dc9a6580dc3061be350d7b9d0eb30aef1c8b4227aa46"
+checksum = "92148b4d8d55eff71bc8c9e3c5f714e266c2a05e724dce5405a10deabbf449a8"
dependencies = [
- "hash-db",
- "rlp 0.3.0",
+ "hash-db 0.11.0",
+ "rlp",
]
[[package]]
name = "triehash-ethereum"
version = "0.2.0"
dependencies = [
- "ethereum-types 0.4.2",
+ "ethereum-types",
"keccak-hasher 0.1.1",
"triehash",
]
@@ -5072,18 +4975,6 @@ version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c85f514e095d348c279b1e5cd76795082cf15bd59b93207832abe0b1d8fed236"
-[[package]]
-name = "uint"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "754ba11732b9161b94c41798e5197e5e75388d012f760c42adb5000353e98646"
-dependencies = [
- "byteorder",
- "crunchy 0.1.6",
- "heapsize",
- "rustc-hex 2.0.1",
-]
-
[[package]]
name = "uint"
version = "0.8.5"
@@ -5092,7 +4983,7 @@ checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177"
dependencies = [
"byteorder",
"crunchy 0.2.2",
- "rustc-hex 2.0.1",
+ "rustc-hex 2.1.0",
"static_assertions",
]
@@ -5245,12 +5136,12 @@ checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
name = "vm"
version = "0.1.0"
dependencies = [
- "ethereum-types 0.4.2",
+ "ethereum-types",
"ethjson",
"keccak-hash",
"parity-bytes",
"patricia-trie-ethereum",
- "rlp 0.3.0",
+ "rlp",
]
[[package]]
@@ -5292,13 +5183,19 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"
+[[package]]
+name = "wasi"
+version = "0.10.2+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
+
[[package]]
name = "wasm"
version = "0.1.0"
dependencies = [
"byteorder",
"env_logger",
- "ethereum-types 0.4.2",
+ "ethereum-types",
"libc",
"log",
"parity-wasm",
@@ -5428,21 +5325,6 @@ dependencies = [
[[package]]
name = "zeroize"
-version = "0.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86"
-dependencies = [
- "zeroize_derive",
-]
-
-[[package]]
-name = "zeroize_derive"
-version = "0.9.3"
+version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "080616bd0e31f36095288bb0acdf1f78ef02c2fa15527d7e993f2a6c7591643e"
-dependencies = [
- "proc-macro2 0.4.30",
- "quote 0.6.13",
- "syn 0.15.26",
- "synstructure 0.10.1",
-]
+checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36"
diff --git a/Cargo.toml b/Cargo.toml
index c2eccb9792..07b8c3e4d9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
description = "OpenEthereum"
name = "openethereum"
# NOTE Make sure to update util/version/Cargo.toml as well
-version = "3.1.0-rc1"
+version = "3.2.2-rc.1"
license = "GPL-3.0"
authors = [
"OpenEthereum developers",
@@ -10,7 +10,7 @@ authors = [
]
[dependencies]
-blooms-db = { path = "util/blooms-db" }
+blooms-db = { path = "crates/db/blooms-db" }
log = "0.4"
rustc-hex = "1.0"
docopt = "1.0"
@@ -35,44 +35,43 @@ fdlimit = "0.1"
ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" }
jsonrpc-core = "15.0.0"
parity-bytes = "0.1"
-common-types = { path = "ethcore/types" }
-ethcore = { path = "ethcore", features = ["parity"] }
-ethcore-accounts = { path = "accounts", optional = true }
-ethcore-blockchain = { path = "ethcore/blockchain" }
-ethcore-call-contract = { path = "ethcore/call-contract"}
-ethcore-db = { path = "ethcore/db" }
-ethcore-io = { path = "util/io" }
-ethcore-logger = { path = "parity/logger" }
-ethcore-miner = { path = "miner" }
-ethcore-network = { path = "util/network" }
-ethcore-service = { path = "ethcore/service" }
-ethcore-sync = { path = "ethcore/sync" }
-ethereum-types = "0.4"
-ethkey = { path = "accounts/ethkey" }
-ethstore = { path = "accounts/ethstore" }
-fetch = { path = "util/fetch" }
-node-filter = { path = "ethcore/node-filter" }
-rlp = { version = "0.3.0", features = ["ethereum"] }
-cli-signer= { path = "cli-signer" }
+common-types = { path = "crates/ethcore/types" }
+ethcore = { path = "crates/ethcore", features = ["parity"] }
+ethcore-accounts = { path = "crates/accounts", optional = true }
+ethcore-blockchain = { path = "crates/ethcore/blockchain" }
+ethcore-call-contract = { path = "crates/vm/call-contract"}
+ethcore-db = { path = "crates/db/db" }
+ethcore-io = { path = "crates/runtime/io" }
+ethcore-logger = { path = "bin/oe/logger" }
+ethcore-miner = { path = "crates/concensus/miner" }
+ethcore-network = { path = "crates/net/network" }
+ethcore-service = { path = "crates/ethcore/service" }
+ethcore-sync = { path = "crates/ethcore/sync" }
+ethereum-types = "0.9.2"
+ethkey = { path = "crates/accounts/ethkey" }
+ethstore = { path = "crates/accounts/ethstore" }
+fetch = { path = "crates/net/fetch" }
+node-filter = { path = "crates/net/node-filter" }
+parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
+rlp = { version = "0.4.6" }
+cli-signer= { path = "crates/util/cli-signer" }
parity-daemonize = "0.3"
-parity-local-store = { path = "miner/local-store" }
-parity-runtime = { path = "util/runtime" }
-parity-rpc = { path = "rpc" }
-parity-version = { path = "util/version" }
+parity-local-store = { path = "crates/concensus/miner/local-store" }
+parity-runtime = { path = "crates/runtime/runtime" }
+parity-rpc = { path = "crates/rpc" }
+parity-version = { path = "crates/util/version" }
parity-path = "0.1"
-dir = { path = "util/dir" }
-panic_hook = { path = "util/panic-hook" }
-keccak-hash = "0.1"
-migration-rocksdb = { path = "util/migration-rocksdb" }
+dir = { path = "crates/util/dir" }
+panic_hook = { path = "crates/util/panic-hook" }
+keccak-hash = "0.5.0"
+migration-rocksdb = { path = "crates/db/migration-rocksdb" }
kvdb = "0.1"
kvdb-rocksdb = "0.1.3"
-journaldb = { path = "util/journaldb" }
-stats = { path = "util/stats" }
+journaldb = { path = "crates/db/journaldb" }
+stats = { path = "crates/util/stats" }
prometheus = "0.9.0"
-ethcore-secretstore = { path = "secret-store", optional = true }
-
-registrar = { path = "util/registrar" }
+# ethcore-secretstore = { path = "crates/util/secret-store", optional = true }
[build-dependencies]
rustc_version = "0.2"
@@ -81,7 +80,7 @@ rustc_version = "0.2"
pretty_assertions = "0.1"
ipnetwork = "0.12.6"
tempdir = "0.3"
-fake-fetch = { path = "util/fake-fetch" }
+fake-fetch = { path = "crates/net/fake-fetch" }
lazy_static = "1.2.0"
[target.'cfg(windows)'.dependencies]
@@ -97,7 +96,6 @@ test-heavy = ["ethcore/test-heavy"]
evm-debug = ["ethcore/evm-debug"]
evm-debug-tests = ["ethcore/evm-debug-tests"]
slow-blocks = ["ethcore/slow-blocks"]
-secretstore = ["ethcore-secretstore", "ethcore-secretstore/accounts"]
final = ["parity-version/final"]
deadlock_detection = ["parking_lot/deadlock_detection"]
# to create a memory profile (requires nightly rust), use e.g.
@@ -109,10 +107,10 @@ deadlock_detection = ["parking_lot/deadlock_detection"]
memory_profiling = []
[lib]
-path = "parity/lib.rs"
+path = "bin/oe/lib.rs"
[[bin]]
-path = "parity/main.rs"
+path = "bin/oe/main.rs"
name = "openethereum"
[profile.test]
@@ -128,17 +126,8 @@ lto = true
# in the dependency tree in any other way
# (i.e. pretty much only standalone CLI tools)
members = [
- "accounts/ethkey/cli",
- "accounts/ethstore/cli",
- "chainspec",
- "ethcore/wasm/run",
- "evmbin",
- "util/triehash-ethereum",
- "util/keccak-hasher",
- "util/patricia-trie-ethereum",
- "util/fastmap",
- "util/time-utils"
+ "bin/ethkey",
+ "bin/ethstore",
+ "bin/evmbin",
+ "bin/chainspec"
]
-
-[patch.crates-io]
-heapsize = { git = "https://github.com/cheme/heapsize.git", branch = "ec-macfix" }
diff --git a/README.md b/README.md
index d8e03fa8e9..588b25bb33 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@ OpenEthereum's goal is to be the fastest, lightest, and most secure Ethereum cli
By default, OpenEthereum runs a JSON-RPC HTTP server on port `:8545` and a Web-Sockets server on port `:8546`. This is fully configurable and supports a number of APIs.
-If you run into problems while using OpenEthereum, check out the [old wiki for documentation](https://openethereum.github.io/wiki/), feel free to [file an issue in this repository](https://github.com/openethereum/openethereum/issues/new), or hop on our [Discord](https://discord.io/openethereum) chat room to ask a question. We are glad to help!
+If you run into problems while using OpenEthereum, check out the [old wiki for documentation](https://openethereum.github.io/), feel free to [file an issue in this repository](https://github.com/openethereum/openethereum/issues/new), or hop on our [Discord](https://discord.io/openethereum) chat room to ask a question. We are glad to help!
You can download OpenEthereum's latest release at [the releases page](https://github.com/openethereum/openethereum/releases) or follow the instructions below to build from source. Read the [CHANGELOG.md](CHANGELOG.md) for a list of all changes between different versions.
@@ -135,7 +135,7 @@ To start OpenEthereum as a regular user using `systemd` init:
1. Copy `./scripts/openethereum.service` to your
`systemd` user directory (usually `~/.config/systemd/user`).
2. Copy release to bin folder, write `sudo install ./target/release/openethereum /usr/bin/openethereum`
-3. To configure OpenEthereum, see [our old wiki](https://openethereum.github.io/wiki/Configuring-OpenEthereum) for details.
+3. To configure OpenEthereum, see [our wiki](https://openethereum.github.io/Configuring-OpenEthereum) for details.
## 4. Testing
@@ -157,7 +157,7 @@ You can show your logs in the test output by passing `--nocapture` (i.e. `cargo
## 5. Documentation
-Be sure to [check out our old wiki](https://openethereum.github.io/wiki/) for more information.
+Be sure to [check out our wiki](https://openethereum.github.io/) for more information.
### Viewing documentation for OpenEthereum packages
@@ -297,9 +297,9 @@ Caching, Importing Blocks, and Block Information
In addition to the OpenEthereum client, there are additional tools in this repository available:
-- [evmbin](./evmbin) - OpenEthereum EVM Implementation.
-- [ethstore](./accounts/ethstore) - OpenEthereum Key Management.
-- [ethkey](./accounts/ethkey) - OpenEthereum Keys Generator.
+- [evmbin](./bin/evmbin) - OpenEthereum EVM Implementation.
+- [ethstore](./crates/accounts/ethstore) - OpenEthereum Key Management.
+- [ethkey](./crates/accounts/ethkey) - OpenEthereum Keys Generator.
The following tools are available in a separate repository:
- [ethabi](https://github.com/openethereum/ethabi) - OpenEthereum Encoding of Function Calls. [Docs here](https://crates.io/crates/ethabi)
diff --git a/accounts/ethkey/src/crypto.rs b/accounts/ethkey/src/crypto.rs
deleted file mode 100644
index 4fa1ee6900..0000000000
--- a/accounts/ethkey/src/crypto.rs
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright 2015-2020 Parity Technologies (UK) Ltd.
-// This file is part of OpenEthereum.
-
-// OpenEthereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// OpenEthereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with OpenEthereum. If not, see .
-
-#![allow(deprecated)]
-
-use parity_crypto::error::SymmError;
-use secp256k1;
-use std::io;
-
-quick_error! {
- #[derive(Debug)]
- pub enum Error {
- Secp(e: secp256k1::Error) {
- display("secp256k1 error: {}", e)
- cause(e)
- from()
- }
- Io(e: io::Error) {
- display("i/o error: {}", e)
- cause(e)
- from()
- }
- InvalidMessage {
- display("invalid message")
- }
- Symm(e: SymmError) {
- cause(e)
- from()
- }
- }
-}
-
-/// ECDH functions
-pub mod ecdh {
- use super::Error;
- use secp256k1::{self, ecdh, key};
- use Public;
- use Secret;
- use SECP256K1;
-
- /// Agree on a shared secret
- pub fn agree(secret: &Secret, public: &Public) -> Result {
- let context = &SECP256K1;
- let pdata = {
- let mut temp = [4u8; 65];
- (&mut temp[1..65]).copy_from_slice(&public[0..64]);
- temp
- };
-
- let publ = key::PublicKey::from_slice(context, &pdata)?;
- let sec = key::SecretKey::from_slice(context, &secret)?;
- let shared = ecdh::SharedSecret::new_raw(context, &publ, &sec);
-
- Secret::from_unsafe_slice(&shared[0..32])
- .map_err(|_| Error::Secp(secp256k1::Error::InvalidSecretKey))
- }
-}
-
-/// ECIES function
-pub mod ecies {
- use super::{ecdh, Error};
- use ethereum_types::H128;
- use parity_crypto::{aes, digest, hmac, is_equal};
- use Generator;
- use Public;
- use Random;
- use Secret;
-
- /// Encrypt a message with a public key, writing an HMAC covering both
- /// the plaintext and authenticated data.
- ///
- /// Authenticated data may be empty.
- pub fn encrypt(public: &Public, auth_data: &[u8], plain: &[u8]) -> Result, Error> {
- let r = Random.generate()?;
- let z = ecdh::agree(r.secret(), public)?;
- let mut key = [0u8; 32];
- kdf(&z, &[0u8; 0], &mut key);
-
- let ekey = &key[0..16];
- let mkey = hmac::SigKey::sha256(&digest::sha256(&key[16..32]));
-
- let mut msg = vec![0u8; 1 + 64 + 16 + plain.len() + 32];
- msg[0] = 0x04u8;
- {
- let msgd = &mut msg[1..];
- msgd[0..64].copy_from_slice(r.public());
- let iv = H128::random();
- msgd[64..80].copy_from_slice(&iv);
- {
- let cipher = &mut msgd[(64 + 16)..(64 + 16 + plain.len())];
- aes::encrypt_128_ctr(ekey, &iv, plain, cipher)?;
- }
- let mut hmac = hmac::Signer::with(&mkey);
- {
- let cipher_iv = &msgd[64..(64 + 16 + plain.len())];
- hmac.update(cipher_iv);
- }
- hmac.update(auth_data);
- let sig = hmac.sign();
- msgd[(64 + 16 + plain.len())..].copy_from_slice(&sig);
- }
- Ok(msg)
- }
-
- /// Decrypt a message with a secret key, checking HMAC for ciphertext
- /// and authenticated data validity.
- pub fn decrypt(secret: &Secret, auth_data: &[u8], encrypted: &[u8]) -> Result, Error> {
- let meta_len = 1 + 64 + 16 + 32;
- if encrypted.len() < meta_len || encrypted[0] < 2 || encrypted[0] > 4 {
- return Err(Error::InvalidMessage); //invalid message: publickey
- }
-
- let e = &encrypted[1..];
- let p = Public::from_slice(&e[0..64]);
- let z = ecdh::agree(secret, &p)?;
- let mut key = [0u8; 32];
- kdf(&z, &[0u8; 0], &mut key);
-
- let ekey = &key[0..16];
- let mkey = hmac::SigKey::sha256(&digest::sha256(&key[16..32]));
-
- let clen = encrypted.len() - meta_len;
- let cipher_with_iv = &e[64..(64 + 16 + clen)];
- let cipher_iv = &cipher_with_iv[0..16];
- let cipher_no_iv = &cipher_with_iv[16..];
- let msg_mac = &e[(64 + 16 + clen)..];
-
- // Verify tag
- let mut hmac = hmac::Signer::with(&mkey);
- hmac.update(cipher_with_iv);
- hmac.update(auth_data);
- let mac = hmac.sign();
-
- if !is_equal(&mac.as_ref()[..], msg_mac) {
- return Err(Error::InvalidMessage);
- }
-
- let mut msg = vec![0u8; clen];
- aes::decrypt_128_ctr(ekey, cipher_iv, cipher_no_iv, &mut msg[..])?;
- Ok(msg)
- }
-
- fn kdf(secret: &Secret, s1: &[u8], dest: &mut [u8]) {
- // SEC/ISO/Shoup specify counter size SHOULD be equivalent
- // to size of hash output, however, it also notes that
- // the 4 bytes is okay. NIST specifies 4 bytes.
- let mut ctr = 1u32;
- let mut written = 0usize;
- while written < dest.len() {
- let mut hasher = digest::Hasher::sha256();
- let ctrs = [
- (ctr >> 24) as u8,
- (ctr >> 16) as u8,
- (ctr >> 8) as u8,
- ctr as u8,
- ];
- hasher.update(&ctrs);
- hasher.update(secret);
- hasher.update(s1);
- let d = hasher.finish();
- &mut dest[written..(written + 32)].copy_from_slice(&d);
- written += 32;
- ctr += 1;
- }
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::ecies;
- use Generator;
- use Random;
-
- #[test]
- fn ecies_shared() {
- let kp = Random.generate().unwrap();
- let message = b"So many books, so little time";
-
- let shared = b"shared";
- let wrong_shared = b"incorrect";
- let encrypted = ecies::encrypt(kp.public(), shared, message).unwrap();
- assert!(encrypted[..] != message[..]);
- assert_eq!(encrypted[0], 0x04);
-
- assert!(ecies::decrypt(kp.secret(), wrong_shared, &encrypted).is_err());
- let decrypted = ecies::decrypt(kp.secret(), shared, &encrypted).unwrap();
- assert_eq!(decrypted[..message.len()], message[..]);
- }
-}
diff --git a/accounts/ethkey/src/extended.rs b/accounts/ethkey/src/extended.rs
deleted file mode 100644
index 663f555e7a..0000000000
--- a/accounts/ethkey/src/extended.rs
+++ /dev/null
@@ -1,589 +0,0 @@
-// Copyright 2015-2020 Parity Technologies (UK) Ltd.
-// This file is part of OpenEthereum.
-
-// OpenEthereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// OpenEthereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with OpenEthereum. If not, see .
-
-//! Extended keys
-
-pub use self::derivation::Error as DerivationError;
-use ethereum_types::H256;
-use secret::Secret;
-use Public;
-
-/// Represents label that can be stored as a part of key derivation
-pub trait Label {
- /// Length of the data that label occupies
- fn len() -> usize;
-
- /// Store label data to the key derivation sequence
- /// Must not use more than `len()` bytes from slice
- fn store(&self, target: &mut [u8]);
-}
-
-impl Label for u32 {
- fn len() -> usize {
- 4
- }
-
- fn store(&self, target: &mut [u8]) {
- let bytes = self.to_be_bytes();
- target[0..4].copy_from_slice(&bytes);
- }
-}
-
-/// Key derivation over generic label `T`
-pub enum Derivation {
- /// Soft key derivation (allow proof of parent)
- Soft(T),
- /// Hard key derivation (does not allow proof of parent)
- Hard(T),
-}
-
-impl From for Derivation {
- fn from(index: u32) -> Self {
- if index < (2 << 30) {
- Derivation::Soft(index)
- } else {
- Derivation::Hard(index)
- }
- }
-}
-
-impl Label for H256 {
- fn len() -> usize {
- 32
- }
-
- fn store(&self, target: &mut [u8]) {
- self.copy_to(&mut target[0..32]);
- }
-}
-
-/// Extended secret key, allows deterministic derivation of subsequent keys.
-pub struct ExtendedSecret {
- secret: Secret,
- chain_code: H256,
-}
-
-impl ExtendedSecret {
- /// New extended key from given secret and chain code.
- pub fn with_code(secret: Secret, chain_code: H256) -> ExtendedSecret {
- ExtendedSecret {
- secret: secret,
- chain_code: chain_code,
- }
- }
-
- /// New extended key from given secret with the random chain code.
- pub fn new_random(secret: Secret) -> ExtendedSecret {
- ExtendedSecret::with_code(secret, H256::random())
- }
-
- /// New extended key from given secret.
- /// Chain code will be derived from the secret itself (in a deterministic way).
- pub fn new(secret: Secret) -> ExtendedSecret {
- let chain_code = derivation::chain_code(*secret);
- ExtendedSecret::with_code(secret, chain_code)
- }
-
- /// Derive new private key
- pub fn derive(&self, index: Derivation) -> ExtendedSecret
- where
- T: Label,
- {
- let (derived_key, next_chain_code) =
- derivation::private(*self.secret, self.chain_code, index);
-
- let derived_secret = Secret::from(derived_key.0);
-
- ExtendedSecret::with_code(derived_secret, next_chain_code)
- }
-
- /// Private key component of the extended key.
- pub fn as_raw(&self) -> &Secret {
- &self.secret
- }
-}
-
-/// Extended public key, allows deterministic derivation of subsequent keys.
-pub struct ExtendedPublic {
- public: Public,
- chain_code: H256,
-}
-
-impl ExtendedPublic {
- /// New extended public key from known parent and chain code
- pub fn new(public: Public, chain_code: H256) -> Self {
- ExtendedPublic {
- public: public,
- chain_code: chain_code,
- }
- }
-
- /// Create new extended public key from known secret
- pub fn from_secret(secret: &ExtendedSecret) -> Result {
- Ok(ExtendedPublic::new(
- derivation::point(**secret.as_raw())?,
- secret.chain_code.clone(),
- ))
- }
-
- /// Derive new public key
- /// Operation is defined only for index belongs [0..2^31)
- pub fn derive(&self, index: Derivation) -> Result
- where
- T: Label,
- {
- let (derived_key, next_chain_code) =
- derivation::public(self.public, self.chain_code, index)?;
- Ok(ExtendedPublic::new(derived_key, next_chain_code))
- }
-
- pub fn public(&self) -> &Public {
- &self.public
- }
-}
-
-pub struct ExtendedKeyPair {
- secret: ExtendedSecret,
- public: ExtendedPublic,
-}
-
-impl ExtendedKeyPair {
- pub fn new(secret: Secret) -> Self {
- let extended_secret = ExtendedSecret::new(secret);
- let extended_public = ExtendedPublic::from_secret(&extended_secret)
- .expect("Valid `Secret` always produces valid public; qed");
- ExtendedKeyPair {
- secret: extended_secret,
- public: extended_public,
- }
- }
-
- pub fn with_code(secret: Secret, public: Public, chain_code: H256) -> Self {
- ExtendedKeyPair {
- secret: ExtendedSecret::with_code(secret, chain_code.clone()),
- public: ExtendedPublic::new(public, chain_code),
- }
- }
-
- pub fn with_secret(secret: Secret, chain_code: H256) -> Self {
- let extended_secret = ExtendedSecret::with_code(secret, chain_code);
- let extended_public = ExtendedPublic::from_secret(&extended_secret)
- .expect("Valid `Secret` always produces valid public; qed");
- ExtendedKeyPair {
- secret: extended_secret,
- public: extended_public,
- }
- }
-
- pub fn with_seed(seed: &[u8]) -> Result {
- let (master_key, chain_code) = derivation::seed_pair(seed);
- Ok(ExtendedKeyPair::with_secret(
- Secret::from_unsafe_slice(&*master_key).map_err(|_| DerivationError::InvalidSeed)?,
- chain_code,
- ))
- }
-
- pub fn secret(&self) -> &ExtendedSecret {
- &self.secret
- }
-
- pub fn public(&self) -> &ExtendedPublic {
- &self.public
- }
-
- pub fn derive(&self, index: Derivation) -> Result
- where
- T: Label,
- {
- let derived = self.secret.derive(index);
-
- Ok(ExtendedKeyPair {
- public: ExtendedPublic::from_secret(&derived)?,
- secret: derived,
- })
- }
-}
-
-// Derivation functions for private and public keys
-// Work is based on BIP0032
-// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
-mod derivation {
- use super::{Derivation, Label};
- use ethereum_types::{H256, H512, U256, U512};
- use keccak;
- use math::curve_order;
- use parity_crypto::hmac;
- use secp256k1::key::{PublicKey, SecretKey};
- use SECP256K1;
-
- #[derive(Debug)]
- pub enum Error {
- InvalidHardenedUse,
- InvalidPoint,
- MissingIndex,
- InvalidSeed,
- }
-
- // Deterministic derivation of the key using secp256k1 elliptic curve.
- // Derivation can be either hardened or not.
- // For hardened derivation, pass u32 index at least 2^31 or custom Derivation::Hard(T) enum
- //
- // Can panic if passed `private_key` is not a valid secp256k1 private key
- // (outside of (0..curve_order()]) field
- pub fn private(private_key: H256, chain_code: H256, index: Derivation) -> (H256, H256)
- where
- T: Label,
- {
- match index {
- Derivation::Soft(index) => private_soft(private_key, chain_code, index),
- Derivation::Hard(index) => private_hard(private_key, chain_code, index),
- }
- }
-
- fn hmac_pair(data: &[u8], private_key: H256, chain_code: H256) -> (H256, H256) {
- let private: U256 = private_key.into();
-
- // produces 512-bit derived hmac (I)
- let skey = hmac::SigKey::sha512(&*chain_code);
- let i_512 = hmac::sign(&skey, &data[..]);
-
- // left most 256 bits are later added to original private key
- let hmac_key: U256 = H256::from_slice(&i_512[0..32]).into();
- // right most 256 bits are new chain code for later derivations
- let next_chain_code = H256::from(&i_512[32..64]);
-
- let child_key = private_add(hmac_key, private).into();
- (child_key, next_chain_code)
- }
-
- // Can panic if passed `private_key` is not a valid secp256k1 private key
- // (outside of (0..curve_order()]) field
- fn private_soft(private_key: H256, chain_code: H256, index: T) -> (H256, H256)
- where
- T: Label,
- {
- let mut data = vec![0u8; 33 + T::len()];
-
- let sec_private = SecretKey::from_slice(&SECP256K1, &*private_key)
- .expect("Caller should provide valid private key");
- let sec_public = PublicKey::from_secret_key(&SECP256K1, &sec_private)
- .expect("Caller should provide valid private key");
- let public_serialized = sec_public.serialize_vec(&SECP256K1, true);
-
- // curve point (compressed public key) -- index
- // 0.33 -- 33..end
- data[0..33].copy_from_slice(&public_serialized);
- index.store(&mut data[33..]);
-
- hmac_pair(&data, private_key, chain_code)
- }
-
- // Deterministic derivation of the key using secp256k1 elliptic curve
- // This is hardened derivation and does not allow to associate
- // corresponding public keys of the original and derived private keys
- fn private_hard(private_key: H256, chain_code: H256, index: T) -> (H256, H256)
- where
- T: Label,
- {
- let mut data: Vec = vec![0u8; 33 + T::len()];
- let private: U256 = private_key.into();
-
- // 0x00 (padding) -- private_key -- index
- // 0 -- 1..33 -- 33..end
- private.to_big_endian(&mut data[1..33]);
- index.store(&mut data[33..(33 + T::len())]);
-
- hmac_pair(&data, private_key, chain_code)
- }
-
- fn private_add(k1: U256, k2: U256) -> U256 {
- let sum = U512::from(k1) + U512::from(k2);
- modulo(sum, curve_order())
- }
-
- // todo: surely can be optimized
- fn modulo(u1: U512, u2: U256) -> U256 {
- let dv = u1 / U512::from(u2);
- let md = u1 - (dv * U512::from(u2));
- md.into()
- }
-
- pub fn public(
- public_key: H512,
- chain_code: H256,
- derivation: Derivation,
- ) -> Result<(H512, H256), Error>
- where
- T: Label,
- {
- let index = match derivation {
- Derivation::Soft(index) => index,
- Derivation::Hard(_) => {
- return Err(Error::InvalidHardenedUse);
- }
- };
-
- let mut public_sec_raw = [0u8; 65];
- public_sec_raw[0] = 4;
- public_sec_raw[1..65].copy_from_slice(&*public_key);
- let public_sec =
- PublicKey::from_slice(&SECP256K1, &public_sec_raw).map_err(|_| Error::InvalidPoint)?;
- let public_serialized = public_sec.serialize_vec(&SECP256K1, true);
-
- let mut data = vec![0u8; 33 + T::len()];
- // curve point (compressed public key) -- index
- // 0.33 -- 33..end
- data[0..33].copy_from_slice(&public_serialized);
- index.store(&mut data[33..(33 + T::len())]);
-
- // HMAC512SHA produces [derived private(256); new chain code(256)]
- let skey = hmac::SigKey::sha512(&*chain_code);
- let i_512 = hmac::sign(&skey, &data[..]);
-
- let new_private = H256::from(&i_512[0..32]);
- let new_chain_code = H256::from(&i_512[32..64]);
-
- // Generated private key can (extremely rarely) be out of secp256k1 key field
- if curve_order() <= new_private.clone().into() {
- return Err(Error::MissingIndex);
- }
- let new_private_sec = SecretKey::from_slice(&SECP256K1, &*new_private)
- .expect("Private key belongs to the field [0..CURVE_ORDER) (checked above); So initializing can never fail; qed");
- let mut new_public = PublicKey::from_secret_key(&SECP256K1, &new_private_sec)
- .expect("Valid private key produces valid public key");
-
- // Adding two points on the elliptic curves (combining two public keys)
- new_public
- .add_assign(&SECP256K1, &public_sec)
- .expect("Addition of two valid points produce valid point");
-
- let serialized = new_public.serialize_vec(&SECP256K1, false);
-
- Ok((H512::from(&serialized[1..65]), new_chain_code))
- }
-
- fn sha3(slc: &[u8]) -> H256 {
- keccak::Keccak256::keccak256(slc).into()
- }
-
- pub fn chain_code(secret: H256) -> H256 {
- // 10,000 rounds of sha3
- let mut running_sha3 = sha3(&*secret);
- for _ in 0..99999 {
- running_sha3 = sha3(&*running_sha3);
- }
- running_sha3
- }
-
- pub fn point(secret: H256) -> Result {
- let sec = SecretKey::from_slice(&SECP256K1, &*secret).map_err(|_| Error::InvalidPoint)?;
- let public_sec =
- PublicKey::from_secret_key(&SECP256K1, &sec).map_err(|_| Error::InvalidPoint)?;
- let serialized = public_sec.serialize_vec(&SECP256K1, false);
- Ok(H512::from(&serialized[1..65]))
- }
-
- pub fn seed_pair(seed: &[u8]) -> (H256, H256) {
- let skey = hmac::SigKey::sha512(b"Bitcoin seed");
- let i_512 = hmac::sign(&skey, seed);
-
- let master_key = H256::from_slice(&i_512[0..32]);
- let chain_code = H256::from_slice(&i_512[32..64]);
-
- (master_key, chain_code)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::{derivation, Derivation, ExtendedKeyPair, ExtendedPublic, ExtendedSecret};
- use ethereum_types::{H128, H256};
- use secret::Secret;
- use std::str::FromStr;
-
- fn master_chain_basic() -> (H256, H256) {
- let seed = H128::from_str("000102030405060708090a0b0c0d0e0f")
- .expect("Seed should be valid H128")
- .to_vec();
-
- derivation::seed_pair(&*seed)
- }
-
- fn test_extended(f: F, test_private: H256)
- where
- F: Fn(ExtendedSecret) -> ExtendedSecret,
- {
- let (private_seed, chain_code) = master_chain_basic();
- let extended_secret = ExtendedSecret::with_code(Secret::from(private_seed.0), chain_code);
- let derived = f(extended_secret);
- assert_eq!(**derived.as_raw(), test_private);
- }
-
- #[test]
- fn smoky() {
- let secret =
- Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65")
- .unwrap();
- let extended_secret = ExtendedSecret::with_code(secret.clone(), 0u64.into());
-
- // hardened
- assert_eq!(&**extended_secret.as_raw(), &*secret);
- assert_eq!(
- &**extended_secret.derive(2147483648.into()).as_raw(),
- &"0927453daed47839608e414a3738dfad10aed17c459bbd9ab53f89b026c834b6".into()
- );
- assert_eq!(
- &**extended_secret.derive(2147483649.into()).as_raw(),
- &"44238b6a29c6dcbe9b401364141ba11e2198c289a5fed243a1c11af35c19dc0f".into()
- );
-
- // normal
- assert_eq!(
- &**extended_secret.derive(0.into()).as_raw(),
- &"bf6a74e3f7b36fc4c96a1e12f31abc817f9f5904f5a8fc27713163d1f0b713f6".into()
- );
- assert_eq!(
- &**extended_secret.derive(1.into()).as_raw(),
- &"bd4fca9eb1f9c201e9448c1eecd66e302d68d4d313ce895b8c134f512205c1bc".into()
- );
- assert_eq!(
- &**extended_secret.derive(2.into()).as_raw(),
- &"86932b542d6cab4d9c65490c7ef502d89ecc0e2a5f4852157649e3251e2a3268".into()
- );
-
- let extended_public = ExtendedPublic::from_secret(&extended_secret)
- .expect("Extended public should be created");
- let derived_public = extended_public
- .derive(0.into())
- .expect("First derivation of public should succeed");
- assert_eq!(&*derived_public.public(), &"f7b3244c96688f92372bfd4def26dc4151529747bab9f188a4ad34e141d47bd66522ff048bc6f19a0a4429b04318b1a8796c000265b4fa200dae5f6dda92dd94".into());
-
- let keypair = ExtendedKeyPair::with_secret(
- Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65")
- .unwrap(),
- 064.into(),
- );
- assert_eq!(
- &**keypair
- .derive(2147483648u32.into())
- .expect("Derivation of keypair should succeed")
- .secret()
- .as_raw(),
- &"edef54414c03196557cf73774bc97a645c9a1df2164ed34f0c2a78d1375a930c".into()
- );
- }
-
- #[test]
- fn h256_soft_match() {
- let secret =
- Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65")
- .unwrap();
- let derivation_secret =
- H256::from_str("51eaf04f9dbbc1417dc97e789edd0c37ecda88bac490434e367ea81b71b7b015")
- .unwrap();
-
- let extended_secret = ExtendedSecret::with_code(secret.clone(), 0u64.into());
- let extended_public = ExtendedPublic::from_secret(&extended_secret)
- .expect("Extended public should be created");
-
- let derived_secret0 = extended_secret.derive(Derivation::Soft(derivation_secret));
- let derived_public0 = extended_public
- .derive(Derivation::Soft(derivation_secret))
- .expect("First derivation of public should succeed");
-
- let public_from_secret0 = ExtendedPublic::from_secret(&derived_secret0)
- .expect("Extended public should be created");
-
- assert_eq!(public_from_secret0.public(), derived_public0.public());
- }
-
- #[test]
- fn h256_hard() {
- let secret =
- Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65")
- .unwrap();
- let derivation_secret =
- H256::from_str("51eaf04f9dbbc1417dc97e789edd0c37ecda88bac490434e367ea81b71b7b015")
- .unwrap();
- let extended_secret = ExtendedSecret::with_code(secret.clone(), 1u64.into());
-
- assert_eq!(
- &**extended_secret
- .derive(Derivation::Hard(derivation_secret))
- .as_raw(),
- &"2bc2d696fb744d77ff813b4a1ef0ad64e1e5188b622c54ba917acc5ebc7c5486".into()
- );
- }
-
- #[test]
- fn match_() {
- let secret =
- Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65")
- .unwrap();
- let extended_secret = ExtendedSecret::with_code(secret.clone(), 1.into());
- let extended_public = ExtendedPublic::from_secret(&extended_secret)
- .expect("Extended public should be created");
-
- let derived_secret0 = extended_secret.derive(0.into());
- let derived_public0 = extended_public
- .derive(0.into())
- .expect("First derivation of public should succeed");
-
- let public_from_secret0 = ExtendedPublic::from_secret(&derived_secret0)
- .expect("Extended public should be created");
-
- assert_eq!(public_from_secret0.public(), derived_public0.public());
- }
-
- #[test]
- fn test_seeds() {
- let seed = H128::from_str("000102030405060708090a0b0c0d0e0f")
- .expect("Seed should be valid H128")
- .to_vec();
-
- // private key from bitcoin test vector
- // xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu53Kw1UmYPxLgboyZQaXwTCg8MSY3H2EU4pWcQDnRnrVA1xe8fs
- let test_private =
- H256::from_str("e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35")
- .expect("Private should be decoded ok");
-
- let (private_seed, _) = derivation::seed_pair(&*seed);
-
- assert_eq!(private_seed, test_private);
- }
-
- #[test]
- fn test_vector_1() {
- // xprv9uHRZZhk6KAJC1avXpDAp4MDc3sQKNxDiPvvkX8Br5ngLNv1TxvUxt4cV1rGL5hj6KCesnDYUhd7oWgT11eZG7XnxHrnYeSvkzY7d2bhkJ7
- // H(0)
- test_extended(
- |secret| secret.derive(2147483648.into()),
- H256::from_str("edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea")
- .expect("Private should be decoded ok"),
- );
- }
-
- #[test]
- fn test_vector_2() {
- // xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu53Kw1UmYPxLgboyZQaXwTCg8MSY3H2EU4pWcQDnRnrVA1xe8fs
- // H(0)/1
- test_extended(
- |secret| secret.derive(2147483648.into()).derive(1.into()),
- H256::from_str("3c6cb8d0f6a264c91ea8b5030fadaa8e538b020f0a387421a12de9319dc93368")
- .expect("Private should be decoded ok"),
- );
- }
-}
diff --git a/accounts/ethkey/src/keypair.rs b/accounts/ethkey/src/keypair.rs
deleted file mode 100644
index 7f97e03fb8..0000000000
--- a/accounts/ethkey/src/keypair.rs
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2015-2020 Parity Technologies (UK) Ltd.
-// This file is part of OpenEthereum.
-
-// OpenEthereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// OpenEthereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with OpenEthereum. If not, see .
-
-use super::{Address, Error, Public, Secret, SECP256K1};
-use keccak::Keccak256;
-use rustc_hex::ToHex;
-use secp256k1::key;
-use std::fmt;
-
-pub fn public_to_address(public: &Public) -> Address {
- let hash = public.keccak256();
- let mut result = Address::default();
- result.copy_from_slice(&hash[12..]);
- result
-}
-
-#[derive(Debug, Clone, PartialEq)]
-/// secp256k1 key pair
-pub struct KeyPair {
- secret: Secret,
- public: Public,
-}
-
-impl fmt::Display for KeyPair {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- writeln!(f, "secret: {}", self.secret.to_hex())?;
- writeln!(f, "public: {}", self.public.to_hex())?;
- write!(f, "address: {}", self.address().to_hex())
- }
-}
-
-impl KeyPair {
- /// Create a pair from secret key
- pub fn from_secret(secret: Secret) -> Result {
- let context = &SECP256K1;
- let s: key::SecretKey = key::SecretKey::from_slice(context, &secret[..])?;
- let pub_key = key::PublicKey::from_secret_key(context, &s)?;
- let serialized = pub_key.serialize_vec(context, false);
-
- let mut public = Public::default();
- public.copy_from_slice(&serialized[1..65]);
-
- let keypair = KeyPair {
- secret: secret,
- public: public,
- };
-
- Ok(keypair)
- }
-
- pub fn from_secret_slice(slice: &[u8]) -> Result {
- Self::from_secret(Secret::from_unsafe_slice(slice)?)
- }
-
- pub fn from_keypair(sec: key::SecretKey, publ: key::PublicKey) -> Self {
- let context = &SECP256K1;
- let serialized = publ.serialize_vec(context, false);
- let secret = Secret::from(sec);
- let mut public = Public::default();
- public.copy_from_slice(&serialized[1..65]);
-
- KeyPair {
- secret: secret,
- public: public,
- }
- }
-
- pub fn secret(&self) -> &Secret {
- &self.secret
- }
-
- pub fn public(&self) -> &Public {
- &self.public
- }
-
- pub fn address(&self) -> Address {
- public_to_address(&self.public)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use std::str::FromStr;
- use KeyPair;
- use Secret;
-
- #[test]
- fn from_secret() {
- let secret =
- Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65")
- .unwrap();
- let _ = KeyPair::from_secret(secret).unwrap();
- }
-
- #[test]
- fn keypair_display() {
- let expected =
-"secret: a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65
-public: 8ce0db0b0359ffc5866ba61903cc2518c3675ef2cf380a7e54bde7ea20e6fa1ab45b7617346cd11b7610001ee6ae5b0155c41cad9527cbcdff44ec67848943a4
-address: 5b073e9233944b5e729e46d618f0d8edf3d9c34a".to_owned();
- let secret =
- Secret::from_str("a100df7a048e50ed308ea696dc600215098141cb391e9527329df289f9383f65")
- .unwrap();
- let kp = KeyPair::from_secret(secret).unwrap();
- assert_eq!(format!("{}", kp), expected);
- }
-}
diff --git a/accounts/ethkey/src/lib.rs b/accounts/ethkey/src/lib.rs
deleted file mode 100644
index 4aa436dc25..0000000000
--- a/accounts/ethkey/src/lib.rs
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2015-2020 Parity Technologies (UK) Ltd.
-// This file is part of OpenEthereum.
-
-// OpenEthereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// OpenEthereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with OpenEthereum. If not, see .
-
-// #![warn(missing_docs)]
-
-extern crate edit_distance;
-extern crate ethereum_types;
-extern crate memzero;
-extern crate parity_crypto;
-extern crate parity_wordlist;
-#[macro_use]
-extern crate quick_error;
-extern crate rand;
-extern crate rustc_hex;
-extern crate secp256k1;
-extern crate serde;
-extern crate tiny_keccak;
-
-#[macro_use]
-extern crate lazy_static;
-#[macro_use]
-extern crate log;
-#[macro_use]
-extern crate serde_derive;
-
-mod brain;
-mod brain_prefix;
-mod error;
-mod extended;
-mod keccak;
-mod keypair;
-mod password;
-mod prefix;
-mod random;
-mod secret;
-mod signature;
-
-pub mod brain_recover;
-pub mod crypto;
-pub mod math;
-
-pub use self::{
- brain::Brain,
- brain_prefix::BrainPrefix,
- error::Error,
- extended::{Derivation, DerivationError, ExtendedKeyPair, ExtendedPublic, ExtendedSecret},
- keypair::{public_to_address, KeyPair},
- math::public_is_valid,
- parity_wordlist::Error as WordlistError,
- password::Password,
- prefix::Prefix,
- random::Random,
- secret::Secret,
- signature::{recover, sign, verify_address, verify_public, Signature},
-};
-
-use ethereum_types::H256;
-
-pub use ethereum_types::{Address, Public};
-pub type Message = H256;
-
-lazy_static! {
- pub static ref SECP256K1: secp256k1::Secp256k1 = secp256k1::Secp256k1::new();
-}
-
-/// Uninstantiatable error type for infallible generators.
-#[derive(Debug)]
-pub enum Void {}
-
-/// Generates new keypair.
-pub trait Generator {
- type Error;
-
- /// Should be called to generate new keypair.
- fn generate(&mut self) -> Result;
-}
diff --git a/accounts/ethkey/src/math.rs b/accounts/ethkey/src/math.rs
deleted file mode 100644
index 5b61cd05dd..0000000000
--- a/accounts/ethkey/src/math.rs
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2015-2020 Parity Technologies (UK) Ltd.
-// This file is part of OpenEthereum.
-
-// OpenEthereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// OpenEthereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with OpenEthereum. If not, see .
-
-use super::{Error, Public, Secret, SECP256K1};
-use ethereum_types::{H256, U256};
-use secp256k1::{
- constants::{CURVE_ORDER, GENERATOR_X, GENERATOR_Y},
- key,
-};
-
-/// Whether the public key is valid.
-pub fn public_is_valid(public: &Public) -> bool {
- to_secp256k1_public(public)
- .ok()
- .map_or(false, |p| p.is_valid())
-}
-
-/// Inplace multiply public key by secret key (EC point * scalar)
-pub fn public_mul_secret(public: &mut Public, secret: &Secret) -> Result<(), Error> {
- let key_secret = secret.to_secp256k1_secret()?;
- let mut key_public = to_secp256k1_public(public)?;
- key_public.mul_assign(&SECP256K1, &key_secret)?;
- set_public(public, &key_public);
- Ok(())
-}
-
-/// Inplace add one public key to another (EC point + EC point)
-pub fn public_add(public: &mut Public, other: &Public) -> Result<(), Error> {
- let mut key_public = to_secp256k1_public(public)?;
- let other_public = to_secp256k1_public(other)?;
- key_public.add_assign(&SECP256K1, &other_public)?;
- set_public(public, &key_public);
- Ok(())
-}
-
-/// Inplace sub one public key from another (EC point - EC point)
-pub fn public_sub(public: &mut Public, other: &Public) -> Result<(), Error> {
- let mut key_neg_other = to_secp256k1_public(other)?;
- key_neg_other.mul_assign(&SECP256K1, &key::MINUS_ONE_KEY)?;
-
- let mut key_public = to_secp256k1_public(public)?;
- key_public.add_assign(&SECP256K1, &key_neg_other)?;
- set_public(public, &key_public);
- Ok(())
-}
-
-/// Replace public key with its negation (EC point = - EC point)
-pub fn public_negate(public: &mut Public) -> Result<(), Error> {
- let mut key_public = to_secp256k1_public(public)?;
- key_public.mul_assign(&SECP256K1, &key::MINUS_ONE_KEY)?;
- set_public(public, &key_public);
- Ok(())
-}
-
-/// Return base point of secp256k1
-pub fn generation_point() -> Public {
- let mut public_sec_raw = [0u8; 65];
- public_sec_raw[0] = 4;
- public_sec_raw[1..33].copy_from_slice(&GENERATOR_X);
- public_sec_raw[33..65].copy_from_slice(&GENERATOR_Y);
-
- let public_key = key::PublicKey::from_slice(&SECP256K1, &public_sec_raw)
- .expect("constructing using predefined constants; qed");
- let mut public = Public::default();
- set_public(&mut public, &public_key);
- public
-}
-
-/// Return secp256k1 elliptic curve order
-pub fn curve_order() -> U256 {
- H256::from_slice(&CURVE_ORDER).into()
-}
-
-fn to_secp256k1_public(public: &Public) -> Result {
- let public_data = {
- let mut temp = [4u8; 65];
- (&mut temp[1..65]).copy_from_slice(&public[0..64]);
- temp
- };
-
- Ok(key::PublicKey::from_slice(&SECP256K1, &public_data)?)
-}
-
-fn set_public(public: &mut Public, key_public: &key::PublicKey) {
- let key_public_serialized = key_public.serialize_vec(&SECP256K1, false);
- public.copy_from_slice(&key_public_serialized[1..65]);
-}
-
-#[cfg(test)]
-mod tests {
- use super::{
- super::{Generator, Random},
- public_add, public_sub,
- };
-
- #[test]
- fn public_addition_is_commutative() {
- let public1 = Random.generate().unwrap().public().clone();
- let public2 = Random.generate().unwrap().public().clone();
-
- let mut left = public1.clone();
- public_add(&mut left, &public2).unwrap();
-
- let mut right = public2.clone();
- public_add(&mut right, &public1).unwrap();
-
- assert_eq!(left, right);
- }
-
- #[test]
- fn public_addition_is_reversible_with_subtraction() {
- let public1 = Random.generate().unwrap().public().clone();
- let public2 = Random.generate().unwrap().public().clone();
-
- let mut sum = public1.clone();
- public_add(&mut sum, &public2).unwrap();
- public_sub(&mut sum, &public2).unwrap();
-
- assert_eq!(sum, public1);
- }
-}
diff --git a/accounts/ethkey/src/random.rs b/accounts/ethkey/src/random.rs
deleted file mode 100644
index 6bf833d276..0000000000
--- a/accounts/ethkey/src/random.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2015-2020 Parity Technologies (UK) Ltd.
-// This file is part of OpenEthereum.
-
-// OpenEthereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// OpenEthereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with OpenEthereum. If not, see .
-
-use super::{Generator, KeyPair, SECP256K1};
-use rand::os::OsRng;
-
-/// Randomly generates new keypair, instantiating the RNG each time.
-pub struct Random;
-
-impl Generator for Random {
- type Error = ::std::io::Error;
-
- fn generate(&mut self) -> Result {
- let mut rng = OsRng::new()?;
- match rng.generate() {
- Ok(pair) => Ok(pair),
- Err(void) => match void {}, // LLVM unreachable
- }
- }
-}
-
-impl Generator for OsRng {
- type Error = ::Void;
-
- fn generate(&mut self) -> Result {
- let (sec, publ) = SECP256K1
- .generate_keypair(self)
- .expect("context always created with full capabilities; qed");
-
- Ok(KeyPair::from_keypair(sec, publ))
- }
-}
diff --git a/accounts/ethkey/src/secret.rs b/accounts/ethkey/src/secret.rs
deleted file mode 100644
index ab78e494d6..0000000000
--- a/accounts/ethkey/src/secret.rs
+++ /dev/null
@@ -1,322 +0,0 @@
-// Copyright 2015-2020 Parity Technologies (UK) Ltd.
-// This file is part of OpenEthereum.
-
-// OpenEthereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// OpenEthereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with OpenEthereum. If not, see .
-
-use ethereum_types::H256;
-use memzero::Memzero;
-use rustc_hex::ToHex;
-use secp256k1::{constants::SECRET_KEY_SIZE as SECP256K1_SECRET_KEY_SIZE, key};
-use std::{fmt, ops::Deref, str::FromStr};
-use Error;
-use SECP256K1;
-
-#[derive(Clone, PartialEq, Eq)]
-pub struct Secret {
- inner: Memzero,
-}
-
-impl ToHex for Secret {
- fn to_hex(&self) -> String {
- format!("{:x}", *self.inner)
- }
-}
-
-impl fmt::LowerHex for Secret {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(fmt)
- }
-}
-
-impl fmt::Debug for Secret {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- self.inner.fmt(fmt)
- }
-}
-
-impl fmt::Display for Secret {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- write!(
- fmt,
- "Secret: 0x{:x}{:x}..{:x}{:x}",
- self.inner[0], self.inner[1], self.inner[30], self.inner[31]
- )
- }
-}
-
-impl Secret {
- /// Creates a `Secret` from the given slice, returning `None` if the slice length != 32.
- pub fn from_slice(key: &[u8]) -> Option {
- if key.len() != 32 {
- return None;
- }
- let mut h = H256::default();
- h.copy_from_slice(&key[0..32]);
- Some(Secret {
- inner: Memzero::from(h),
- })
- }
-
- /// Creates zero key, which is invalid for crypto operations, but valid for math operation.
- pub fn zero() -> Self {
- Secret {
- inner: Memzero::from(H256::default()),
- }
- }
-
- /// Imports and validates the key.
- pub fn from_unsafe_slice(key: &[u8]) -> Result {
- let secret = key::SecretKey::from_slice(&super::SECP256K1, key)?;
- Ok(secret.into())
- }
-
- /// Checks validity of this key.
- pub fn check_validity(&self) -> Result<(), Error> {
- self.to_secp256k1_secret().map(|_| ())
- }
-
- /// Inplace add one secret key to another (scalar + scalar)
- pub fn add(&mut self, other: &Secret) -> Result<(), Error> {
- match (self.is_zero(), other.is_zero()) {
- (true, true) | (false, true) => Ok(()),
- (true, false) => {
- *self = other.clone();
- Ok(())
- }
- (false, false) => {
- let mut key_secret = self.to_secp256k1_secret()?;
- let other_secret = other.to_secp256k1_secret()?;
- key_secret.add_assign(&SECP256K1, &other_secret)?;
-
- *self = key_secret.into();
- Ok(())
- }
- }
- }
-
- /// Inplace subtract one secret key from another (scalar - scalar)
- pub fn sub(&mut self, other: &Secret) -> Result<(), Error> {
- match (self.is_zero(), other.is_zero()) {
- (true, true) | (false, true) => Ok(()),
- (true, false) => {
- *self = other.clone();
- self.neg()
- }
- (false, false) => {
- let mut key_secret = self.to_secp256k1_secret()?;
- let mut other_secret = other.to_secp256k1_secret()?;
- other_secret.mul_assign(&SECP256K1, &key::MINUS_ONE_KEY)?;
- key_secret.add_assign(&SECP256K1, &other_secret)?;
-
- *self = key_secret.into();
- Ok(())
- }
- }
- }
-
- /// Inplace decrease secret key (scalar - 1)
- pub fn dec(&mut self) -> Result<(), Error> {
- match self.is_zero() {
- true => {
- *self = key::MINUS_ONE_KEY.into();
- Ok(())
- }
- false => {
- let mut key_secret = self.to_secp256k1_secret()?;
- key_secret.add_assign(&SECP256K1, &key::MINUS_ONE_KEY)?;
-
- *self = key_secret.into();
- Ok(())
- }
- }
- }
-
- /// Inplace multiply one secret key to another (scalar * scalar)
- pub fn mul(&mut self, other: &Secret) -> Result<(), Error> {
- match (self.is_zero(), other.is_zero()) {
- (true, true) | (true, false) => Ok(()),
- (false, true) => {
- *self = Self::zero();
- Ok(())
- }
- (false, false) => {
- let mut key_secret = self.to_secp256k1_secret()?;
- let other_secret = other.to_secp256k1_secret()?;
- key_secret.mul_assign(&SECP256K1, &other_secret)?;
-
- *self = key_secret.into();
- Ok(())
- }
- }
- }
-
- /// Inplace negate secret key (-scalar)
- pub fn neg(&mut self) -> Result<(), Error> {
- match self.is_zero() {
- true => Ok(()),
- false => {
- let mut key_secret = self.to_secp256k1_secret()?;
- key_secret.mul_assign(&SECP256K1, &key::MINUS_ONE_KEY)?;
-
- *self = key_secret.into();
- Ok(())
- }
- }
- }
-
- /// Inplace inverse secret key (1 / scalar)
- pub fn inv(&mut self) -> Result<(), Error> {
- let mut key_secret = self.to_secp256k1_secret()?;
- key_secret.inv_assign(&SECP256K1)?;
-
- *self = key_secret.into();
- Ok(())
- }
-
- /// Compute power of secret key inplace (secret ^ pow).
- /// This function is not intended to be used with large powers.
- pub fn pow(&mut self, pow: usize) -> Result<(), Error> {
- if self.is_zero() {
- return Ok(());
- }
-
- match pow {
- 0 => *self = key::ONE_KEY.into(),
- 1 => (),
- _ => {
- let c = self.clone();
- for _ in 1..pow {
- self.mul(&c)?;
- }
- }
- }
-
- Ok(())
- }
-
- /// Create `secp256k1::key::SecretKey` based on this secret
- pub fn to_secp256k1_secret(&self) -> Result {
- Ok(key::SecretKey::from_slice(&SECP256K1, &self[..])?)
- }
-}
-
-impl FromStr for Secret {
- type Err = Error;
- fn from_str(s: &str) -> Result {
- Ok(H256::from_str(s)
- .map_err(|e| Error::Custom(format!("{:?}", e)))?
- .into())
- }
-}
-
-impl From<[u8; 32]> for Secret {
- fn from(k: [u8; 32]) -> Self {
- Secret {
- inner: Memzero::from(H256(k)),
- }
- }
-}
-
-impl From for Secret {
- fn from(s: H256) -> Self {
- s.0.into()
- }
-}
-
-impl From<&'static str> for Secret {
- fn from(s: &'static str) -> Self {
- s.parse().expect(&format!(
- "invalid string literal for {}: '{}'",
- stringify!(Self),
- s
- ))
- }
-}
-
-impl From for Secret {
- fn from(key: key::SecretKey) -> Self {
- let mut a = [0; SECP256K1_SECRET_KEY_SIZE];
- a.copy_from_slice(&key[0..SECP256K1_SECRET_KEY_SIZE]);
- a.into()
- }
-}
-
-impl Deref for Secret {
- type Target = H256;
-
- fn deref(&self) -> &Self::Target {
- &self.inner
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::{
- super::{Generator, Random},
- Secret,
- };
- use std::str::FromStr;
-
- #[test]
- fn multiplicating_secret_inversion_with_secret_gives_one() {
- let secret = Random.generate().unwrap().secret().clone();
- let mut inversion = secret.clone();
- inversion.inv().unwrap();
- inversion.mul(&secret).unwrap();
- assert_eq!(
- inversion,
- Secret::from_str("0000000000000000000000000000000000000000000000000000000000000001")
- .unwrap()
- );
- }
-
- #[test]
- fn secret_inversion_is_reversible_with_inversion() {
- let secret = Random.generate().unwrap().secret().clone();
- let mut inversion = secret.clone();
- inversion.inv().unwrap();
- inversion.inv().unwrap();
- assert_eq!(inversion, secret);
- }
-
- #[test]
- fn secret_pow() {
- let secret = Random.generate().unwrap().secret().clone();
-
- let mut pow0 = secret.clone();
- pow0.pow(0).unwrap();
- assert_eq!(
- pow0,
- Secret::from_str("0000000000000000000000000000000000000000000000000000000000000001")
- .unwrap()
- );
-
- let mut pow1 = secret.clone();
- pow1.pow(1).unwrap();
- assert_eq!(pow1, secret);
-
- let mut pow2 = secret.clone();
- pow2.pow(2).unwrap();
- let mut pow2_expected = secret.clone();
- pow2_expected.mul(&secret).unwrap();
- assert_eq!(pow2, pow2_expected);
-
- let mut pow3 = secret.clone();
- pow3.pow(3).unwrap();
- let mut pow3_expected = secret.clone();
- pow3_expected.mul(&secret).unwrap();
- pow3_expected.mul(&secret).unwrap();
- assert_eq!(pow3, pow3_expected);
- }
-}
diff --git a/accounts/ethkey/src/signature.rs b/accounts/ethkey/src/signature.rs
deleted file mode 100644
index fdb7b4c106..0000000000
--- a/accounts/ethkey/src/signature.rs
+++ /dev/null
@@ -1,325 +0,0 @@
-// Copyright 2015-2020 Parity Technologies (UK) Ltd.
-// This file is part of OpenEthereum.
-
-// OpenEthereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// OpenEthereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with OpenEthereum. If not, see .
-
-use ethereum_types::{H256, H520};
-use public_to_address;
-use rustc_hex::{FromHex, ToHex};
-use secp256k1::{
- key::{PublicKey, SecretKey},
- Error as SecpError, Message as SecpMessage, RecoverableSignature, RecoveryId,
-};
-use std::{
- cmp::PartialEq,
- fmt,
- hash::{Hash, Hasher},
- ops::{Deref, DerefMut},
- str::FromStr,
-};
-use Address;
-use Error;
-use Message;
-use Public;
-use Secret;
-use SECP256K1;
-
-/// Signature encoded as RSV components
-#[repr(C)]
-pub struct Signature([u8; 65]);
-
-impl Signature {
- /// Get a slice into the 'r' portion of the data.
- pub fn r(&self) -> &[u8] {
- &self.0[0..32]
- }
-
- /// Get a slice into the 's' portion of the data.
- pub fn s(&self) -> &[u8] {
- &self.0[32..64]
- }
-
- /// Get the recovery byte.
- pub fn v(&self) -> u8 {
- self.0[64]
- }
-
- /// Encode the signature into RSV array (V altered to be in "Electrum" notation).
- pub fn into_electrum(mut self) -> [u8; 65] {
- self.0[64] += 27;
- self.0
- }
-
- /// Parse bytes as a signature encoded as RSV (V in "Electrum" notation).
- /// May return empty (invalid) signature if given data has invalid length.
- pub fn from_electrum(data: &[u8]) -> Self {
- if data.len() != 65 || data[64] < 27 {
- // fallback to empty (invalid) signature
- return Signature::default();
- }
-
- let mut sig = [0u8; 65];
- sig.copy_from_slice(data);
- sig[64] -= 27;
- Signature(sig)
- }
-
- /// Create a signature object from the sig.
- pub fn from_rsv(r: &H256, s: &H256, v: u8) -> Self {
- let mut sig = [0u8; 65];
- sig[0..32].copy_from_slice(&r);
- sig[32..64].copy_from_slice(&s);
- sig[64] = v;
- Signature(sig)
- }
-
- /// Check if this is a "low" signature.
- pub fn is_low_s(&self) -> bool {
- H256::from_slice(self.s())
- <= "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0".into()
- }
-
- /// Check if each component of the signature is in range.
- pub fn is_valid(&self) -> bool {
- self.v() <= 1
- && H256::from_slice(self.r())
- < "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141".into()
- && H256::from_slice(self.r()) >= 1.into()
- && H256::from_slice(self.s())
- < "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141".into()
- && H256::from_slice(self.s()) >= 1.into()
- }
-}
-
-// manual implementation large arrays don't have trait impls by default.
-// remove when integer generics exist
-impl PartialEq for Signature {
- fn eq(&self, other: &Self) -> bool {
- &self.0[..] == &other.0[..]
- }
-}
-
-// manual implementation required in Rust 1.13+, see `std::cmp::AssertParamIsEq`.
-impl Eq for Signature {}
-
-// also manual for the same reason, but the pretty printing might be useful.
-impl fmt::Debug for Signature {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- f.debug_struct("Signature")
- .field("r", &self.0[0..32].to_hex())
- .field("s", &self.0[32..64].to_hex())
- .field("v", &self.0[64..65].to_hex())
- .finish()
- }
-}
-
-impl fmt::Display for Signature {
- fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- write!(f, "{}", self.to_hex())
- }
-}
-
-impl FromStr for Signature {
- type Err = Error;
-
- fn from_str(s: &str) -> Result {
- match s.from_hex() {
- Ok(ref hex) if hex.len() == 65 => {
- let mut data = [0; 65];
- data.copy_from_slice(&hex[0..65]);
- Ok(Signature(data))
- }
- _ => Err(Error::InvalidSignature),
- }
- }
-}
-
-impl Default for Signature {
- fn default() -> Self {
- Signature([0; 65])
- }
-}
-
-impl Hash for Signature {
- fn hash(&self, state: &mut H) {
- H520::from(self.0).hash(state);
- }
-}
-
-impl Clone for Signature {
- fn clone(&self) -> Self {
- Signature(self.0)
- }
-}
-
-impl From<[u8; 65]> for Signature {
- fn from(s: [u8; 65]) -> Self {
- Signature(s)
- }
-}
-
-impl Into<[u8; 65]> for Signature {
- fn into(self) -> [u8; 65] {
- self.0
- }
-}
-
-impl From for H520 {
- fn from(s: Signature) -> Self {
- H520::from(s.0)
- }
-}
-
-impl From for Signature {
- fn from(bytes: H520) -> Self {
- Signature(bytes.into())
- }
-}
-
-impl Deref for Signature {
- type Target = [u8; 65];
-
- fn deref(&self) -> &Self::Target {
- &self.0
- }
-}
-
-impl DerefMut for Signature {
- fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.0
- }
-}
-
-pub fn sign(secret: &Secret, message: &Message) -> Result {
- let context = &SECP256K1;
- let sec = SecretKey::from_slice(context, &secret)?;
- let s = context.sign_recoverable(&SecpMessage::from_slice(&message[..])?, &sec)?;
- let (rec_id, data) = s.serialize_compact(context);
- let mut data_arr = [0; 65];
-
- // no need to check if s is low, it always is
- data_arr[0..64].copy_from_slice(&data[0..64]);
- data_arr[64] = rec_id.to_i32() as u8;
- Ok(Signature(data_arr))
-}
-
-pub fn verify_public(
- public: &Public,
- signature: &Signature,
- message: &Message,
-) -> Result {
- let context = &SECP256K1;
- let rsig = RecoverableSignature::from_compact(
- context,
- &signature[0..64],
- RecoveryId::from_i32(signature[64] as i32)?,
- )?;
- let sig = rsig.to_standard(context);
-
- let pdata: [u8; 65] = {
- let mut temp = [4u8; 65];
- temp[1..65].copy_from_slice(&**public);
- temp
- };
-
- let publ = PublicKey::from_slice(context, &pdata)?;
- match context.verify(&SecpMessage::from_slice(&message[..])?, &sig, &publ) {
- Ok(_) => Ok(true),
- Err(SecpError::IncorrectSignature) => Ok(false),
- Err(x) => Err(Error::from(x)),
- }
-}
-
-pub fn verify_address(
- address: &Address,
- signature: &Signature,
- message: &Message,
-) -> Result {
- let public = recover(signature, message)?;
- let recovered_address = public_to_address(&public);
- Ok(address == &recovered_address)
-}
-
-pub fn recover(signature: &Signature, message: &Message) -> Result {
- let context = &SECP256K1;
- let rsig = RecoverableSignature::from_compact(
- context,
- &signature[0..64],
- RecoveryId::from_i32(signature[64] as i32)?,
- )?;
- let pubkey = context.recover(&SecpMessage::from_slice(&message[..])?, &rsig)?;
- let serialized = pubkey.serialize_vec(context, false);
-
- let mut public = Public::default();
- public.copy_from_slice(&serialized[1..65]);
- Ok(public)
-}
-
-#[cfg(test)]
-mod tests {
- use super::{recover, sign, verify_address, verify_public, Signature};
- use std::str::FromStr;
- use Generator;
- use Message;
- use Random;
-
- #[test]
- fn vrs_conversion() {
- // given
- let keypair = Random.generate().unwrap();
- let message = Message::default();
- let signature = sign(keypair.secret(), &message).unwrap();
-
- // when
- let vrs = signature.clone().into_electrum();
- let from_vrs = Signature::from_electrum(&vrs);
-
- // then
- assert_eq!(signature, from_vrs);
- }
-
- #[test]
- fn signature_to_and_from_str() {
- let keypair = Random.generate().unwrap();
- let message = Message::default();
- let signature = sign(keypair.secret(), &message).unwrap();
- let string = format!("{}", signature);
- let deserialized = Signature::from_str(&string).unwrap();
- assert_eq!(signature, deserialized);
- }
-
- #[test]
- fn sign_and_recover_public() {
- let keypair = Random.generate().unwrap();
- let message = Message::default();
- let signature = sign(keypair.secret(), &message).unwrap();
- assert_eq!(keypair.public(), &recover(&signature, &message).unwrap());
- }
-
- #[test]
- fn sign_and_verify_public() {
- let keypair = Random.generate().unwrap();
- let message = Message::default();
- let signature = sign(keypair.secret(), &message).unwrap();
- assert!(verify_public(keypair.public(), &signature, &message).unwrap());
- }
-
- #[test]
- fn sign_and_verify_address() {
- let keypair = Random.generate().unwrap();
- let message = Message::default();
- let signature = sign(keypair.secret(), &message).unwrap();
- assert!(verify_address(&keypair.address(), &signature, &message).unwrap());
- }
-}
diff --git a/chainspec/Cargo.toml b/bin/chainspec/Cargo.toml
similarity index 80%
rename from chainspec/Cargo.toml
rename to bin/chainspec/Cargo.toml
index c0308edd32..f990a81ddd 100644
--- a/chainspec/Cargo.toml
+++ b/bin/chainspec/Cargo.toml
@@ -5,5 +5,5 @@ version = "0.1.0"
authors = ["Marek Kotewicz "]
[dependencies]
-ethjson = { path = "../json" }
+ethjson = { path = "../../crates/ethjson" }
serde_json = "1.0"
diff --git a/chainspec/src/main.rs b/bin/chainspec/src/main.rs
similarity index 100%
rename from chainspec/src/main.rs
rename to bin/chainspec/src/main.rs
diff --git a/accounts/ethkey/cli/Cargo.toml b/bin/ethkey/Cargo.toml
similarity index 67%
rename from accounts/ethkey/cli/Cargo.toml
rename to bin/ethkey/Cargo.toml
index c1d44897cc..d5af93f26b 100644
--- a/accounts/ethkey/cli/Cargo.toml
+++ b/bin/ethkey/Cargo.toml
@@ -7,8 +7,9 @@ authors = ["Parity Technologies "]
[dependencies]
docopt = "1.0"
env_logger = "0.5"
-ethkey = { path = "../" }
-panic_hook = { path = "../../../util/panic-hook" }
+ethkey = { path = "../../crates/accounts/ethkey" }
+panic_hook = { path = "../../crates/util/panic-hook" }
+parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
parity-wordlist="1.3"
rustc-hex = "1.0"
serde = "1.0"
diff --git a/accounts/ethkey/cli/src/main.rs b/bin/ethkey/src/main.rs
similarity index 96%
rename from accounts/ethkey/cli/src/main.rs
rename to bin/ethkey/src/main.rs
index 7327553e19..230351ef4d 100644
--- a/accounts/ethkey/cli/src/main.rs
+++ b/bin/ethkey/src/main.rs
@@ -18,6 +18,7 @@ extern crate docopt;
extern crate env_logger;
extern crate ethkey;
extern crate panic_hook;
+extern crate parity_crypto as crypto;
extern crate parity_wordlist;
extern crate rustc_hex;
extern crate serde;
@@ -28,11 +29,11 @@ extern crate serde_derive;
use std::{env, fmt, io, num::ParseIntError, process, sync};
-use docopt::Docopt;
-use ethkey::{
- brain_recover, sign, verify_address, verify_public, Brain, BrainPrefix, Error as EthkeyError,
- Generator, KeyPair, Prefix, Random,
+use crypto::publickey::{
+ sign, verify_address, verify_public, Error as EthkeyError, Generator, KeyPair, Random,
};
+use docopt::Docopt;
+use ethkey::{brain_recover, Brain, BrainPrefix, Prefix};
use rustc_hex::{FromHex, FromHexError};
const USAGE: &'static str = r#"
@@ -202,15 +203,13 @@ where
let result = if args.flag_brain {
let phrase = args.arg_secret_or_phrase;
let phrase_info = validate_phrase(&phrase);
- let keypair = Brain::new(phrase)
- .generate()
- .expect("Brain wallet generator is infallible; qed");
+ let keypair = Brain::new(phrase).generate();
(keypair, Some(phrase_info))
} else {
let secret = args
.arg_secret_or_phrase
.parse()
- .map_err(|_| EthkeyError::InvalidSecret)?;
+ .map_err(|_| EthkeyError::InvalidSecretKey)?;
(KeyPair::from_secret(secret)?, None)
};
Ok(display(result, display_mode))
@@ -223,7 +222,7 @@ where
let phrase = format!("recovery phrase: {}", brain.phrase());
(keypair, Some(phrase))
} else {
- (Random.generate()?, None)
+ (Random.generate(), None)
}
} else if args.cmd_prefix {
let prefix = args.arg_prefix.from_hex()?;
@@ -254,7 +253,7 @@ where
let secret = args
.arg_secret
.parse()
- .map_err(|_| EthkeyError::InvalidSecret)?;
+ .map_err(|_| EthkeyError::InvalidSecretKey)?;
let message = args
.arg_message
.parse()
@@ -274,7 +273,7 @@ where
let public = args
.arg_public
.parse()
- .map_err(|_| EthkeyError::InvalidPublic)?;
+ .map_err(|_| EthkeyError::InvalidPublicKey)?;
verify_public(&public, &signature, &message)?
} else if args.cmd_address {
let address = args
@@ -301,7 +300,7 @@ where
while let Some(phrase) = it.next() {
i += 1;
- let keypair = Brain::new(phrase.clone()).generate().unwrap();
+ let keypair = Brain::new(phrase.clone()).generate();
if keypair.address() == address {
return Ok(Some((phrase, keypair)));
}
diff --git a/accounts/ethstore/cli/Cargo.toml b/bin/ethstore/Cargo.toml
similarity index 72%
rename from accounts/ethstore/cli/Cargo.toml
rename to bin/ethstore/Cargo.toml
index 9578a75377..6ad76cb0ad 100644
--- a/accounts/ethstore/cli/Cargo.toml
+++ b/bin/ethstore/Cargo.toml
@@ -12,9 +12,9 @@ rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
parking_lot = "0.7"
-ethstore = { path = "../" }
-dir = { path = '../../../util/dir' }
-panic_hook = { path = "../../../util/panic-hook" }
+ethstore = { path = "../../crates/accounts/ethstore" }
+dir = { path = '../../crates/util/dir' }
+panic_hook = { path = "../../crates/util/panic-hook" }
[[bin]]
name = "ethstore"
diff --git a/accounts/ethstore/cli/src/crack.rs b/bin/ethstore/src/crack.rs
similarity index 100%
rename from accounts/ethstore/cli/src/crack.rs
rename to bin/ethstore/src/crack.rs
diff --git a/accounts/ethstore/cli/src/main.rs b/bin/ethstore/src/main.rs
similarity index 100%
rename from accounts/ethstore/cli/src/main.rs
rename to bin/ethstore/src/main.rs
diff --git a/evmbin/Cargo.toml b/bin/evmbin/Cargo.toml
similarity index 55%
rename from evmbin/Cargo.toml
rename to bin/evmbin/Cargo.toml
index 18d0b3e8e0..d6b8960519 100644
--- a/evmbin/Cargo.toml
+++ b/bin/evmbin/Cargo.toml
@@ -9,20 +9,20 @@ name = "openethereum-evm"
path = "./src/main.rs"
[dependencies]
-common-types = { path = "../ethcore/types", features = ["test-helpers"] }
+common-types = { path = "../../crates/ethcore/types", features = ["test-helpers"] }
docopt = "1.0"
env_logger = "0.5"
-ethcore = { path = "../ethcore", features = ["test-helpers", "json-tests", "to-pod-full"] }
-ethereum-types = "0.4"
-ethjson = { path = "../json" }
-evm = { path = "../ethcore/evm" }
-panic_hook = { path = "../util/panic-hook" }
+ethcore = { path = "../../crates/ethcore", features = ["test-helpers", "json-tests", "to-pod-full"] }
+ethereum-types = "0.9.2"
+ethjson = { path = "../../crates/ethjson" }
+evm = { path = "../../crates/vm/evm" }
+panic_hook = { path = "../../crates/util/panic-hook" }
parity-bytes = "0.1"
rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
-vm = { path = "../ethcore/vm" }
+vm = { path = "../../crates/vm/vm" }
[dev-dependencies]
criterion = "0.3.0"
diff --git a/evmbin/README.md b/bin/evmbin/README.md
similarity index 65%
rename from evmbin/README.md
rename to bin/evmbin/README.md
index 1610187b41..e6f62de3c7 100644
--- a/evmbin/README.md
+++ b/bin/evmbin/README.md
@@ -5,11 +5,11 @@ EVM implementation for OpenEthereum.
### Usage
```
-EVM implementation for OpenEthereum.
+EVM implementation for Parity.
Copyright 2015-2020 Parity Technologies (UK) Ltd.
Usage:
- openethereum-evm state-test [--json --std-json --std-dump-json --only NAME --chain CHAIN --std-out-only --std-err-only]
+ openethereum-evm state-test [--json --std-json --std-dump-json --only NAME --chain CHAIN --std-out-only --std-err-only --omit-storage-output --omit-memory-output]
openethereum-evm stats [options]
openethereum-evm stats-jsontests-vm
openethereum-evm [options]
@@ -30,16 +30,22 @@ Transaction options:
--gas-price WEI Supplied gas price as hex (without 0x).
State test options:
+ --chain CHAIN Run only from specific chain name (i.e. one of EIP150, EIP158,
+ Frontier, Homestead, Byzantium, Constantinople,
+ ConstantinopleFix, Istanbul, EIP158ToByzantiumAt5, FrontierToHomesteadAt5,
+ HomesteadToDaoAt5, HomesteadToEIP150At5, Berlin, Yolo3).
--only NAME Runs only a single test matching the name.
- --chain CHAIN Run only tests from specific chain.
General options:
- --json Display verbose results in JSON.
- --std-json Display results in standardized JSON format.
- --std-err-only With --std-json redirect to err output only.
- --std-out-only With --std-json redirect to out output only.
- --std-dump-json Display results in standardized JSON format
- with additional state dump.
+ --json Display verbose results in JSON.
+ --std-json Display results in standardized JSON format.
+ --std-err-only With --std-json redirect to err output only.
+ --std-out-only With --std-json redirect to out output only.
+ --omit-storage-output With --std-json omit storage output.
+ --omit-memory-output With --std-json omit memory output.
+ --std-dump-json Display results in standardized JSON format
+ with additional state dump.
+
Display result state dump in standardized JSON format.
--chain CHAIN Chain spec file path.
-h, --help Display this message and exit.
diff --git a/evmbin/benches/mod.rs b/bin/evmbin/benches/mod.rs
similarity index 100%
rename from evmbin/benches/mod.rs
rename to bin/evmbin/benches/mod.rs
diff --git a/evmbin/res/testchain.json b/bin/evmbin/res/testchain.json
similarity index 100%
rename from evmbin/res/testchain.json
rename to bin/evmbin/res/testchain.json
diff --git a/bin/evmbin/src/display/config.rs b/bin/evmbin/src/display/config.rs
new file mode 100644
index 0000000000..128c2eeccb
--- /dev/null
+++ b/bin/evmbin/src/display/config.rs
@@ -0,0 +1,40 @@
+// Copyright 2015-2020 Parity Technologies (UK) Ltd.
+// This file is part of OpenEthereum.
+
+// OpenEthereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// OpenEthereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with OpenEthereum. If not, see .
+
+//! Config used by display informants
+
+#[derive(Default, Copy, Clone, Debug)]
+pub struct Config {
+ omit_storage_output: bool,
+ omit_memory_output: bool,
+}
+
+impl Config {
+ pub fn new(omit_storage_output: bool, omit_memory_output: bool) -> Config {
+ Config {
+ omit_storage_output,
+ omit_memory_output,
+ }
+ }
+
+ pub fn omit_storage_output(&self) -> bool {
+ self.omit_storage_output
+ }
+
+ pub fn omit_memory_output(&self) -> bool {
+ self.omit_memory_output
+ }
+}
diff --git a/evmbin/src/display/json.rs b/bin/evmbin/src/display/json.rs
similarity index 88%
rename from evmbin/src/display/json.rs
rename to bin/evmbin/src/display/json.rs
index f8e3ebae0d..08658abf0f 100644
--- a/evmbin/src/display/json.rs
+++ b/bin/evmbin/src/display/json.rs
@@ -18,11 +18,11 @@
use std::{collections::HashMap, mem};
+use super::config::Config;
use bytes::ToPretty;
-use ethcore::trace;
-use ethereum_types::{H256, U256};
-
use display;
+use ethcore::trace;
+use ethereum_types::{BigEndianHash, H256, U256};
use info as vm;
/// JSON formatting informant.
@@ -44,9 +44,16 @@ pub struct Informant {
subinfos: Vec,
subdepth: usize,
unmatched: bool,
+ config: Config,
}
impl Informant {
+ pub fn new(config: Config) -> Informant {
+ let mut def = Informant::default();
+ def.config = config;
+ def
+ }
+
fn with_informant_in_depth(
informant: &mut Informant,
depth: usize,
@@ -67,17 +74,26 @@ impl Informant {
}
fn informant_trace(informant: &Informant, gas_used: U256) -> String {
+ let memory = if informant.config.omit_memory_output() {
+ "".to_string()
+ } else {
+ format!("0x{}", informant.memory.to_hex())
+ };
+ let storage = if informant.config.omit_storage_output() {
+ None
+ } else {
+ Some(&informant.storage)
+ };
let info = ::evm::Instruction::from_u8(informant.instruction).map(|i| i.info());
-
json!({
"pc": informant.pc,
"op": informant.instruction,
"opName": info.map(|i| i.name).unwrap_or(""),
"gas": format!("{:#x}", gas_used.saturating_add(informant.gas_cost)),
"gasCost": format!("{:#x}", informant.gas_cost),
- "memory": format!("0x{}", informant.memory.to_hex()),
+ "memory": memory,
"stack": informant.stack,
- "storage": informant.storage,
+ "storage": storage,
"depth": informant.depth,
})
.to_string()
@@ -85,7 +101,7 @@ impl Informant {
}
impl vm::Informant for Informant {
- type Sink = ();
+ type Sink = Config;
fn before_test(&mut self, name: &str, action: &str) {
println!("{}", json!({"action": action, "test": name}));
@@ -96,10 +112,10 @@ impl vm::Informant for Informant {
}
fn clone_sink(&self) -> Self::Sink {
- ()
+ self.config
}
- fn finish(result: vm::RunResult, _sink: &mut Self::Sink) {
+ fn finish(result: vm::RunResult, config: &mut Self::Sink) {
match result {
Ok(success) => {
for trace in success.traces.unwrap_or_else(Vec::new) {
@@ -115,8 +131,10 @@ impl vm::Informant for Informant {
println!("{}", success_msg)
}
Err(failure) => {
- for trace in failure.traces.unwrap_or_else(Vec::new) {
- println!("{}", trace);
+ if !config.omit_storage_output() {
+ for trace in failure.traces.unwrap_or_else(Vec::new) {
+ println!("{}", trace);
+ }
}
let failure_msg = json!({
@@ -190,7 +208,10 @@ impl trace::VMTracer for Informant {
}
if let Some((pos, val)) = store_diff {
- informant.storage.insert(pos.into(), val.into());
+ informant.storage.insert(
+ BigEndianHash::from_uint(&pos),
+ BigEndianHash::from_uint(&val),
+ );
}
if !informant.subtraces.is_empty() {
@@ -205,6 +226,7 @@ impl trace::VMTracer for Informant {
let subdepth = self.subdepth;
Self::with_informant_in_depth(self, subdepth, |informant: &mut Informant| {
let mut vm = Informant::default();
+ vm.config = informant.config;
vm.depth = informant.depth + 1;
vm.code = code.to_vec();
vm.gas_used = informant.gas_used;
@@ -265,7 +287,7 @@ mod tests {
gas_cost: U256,
memory: String,
stack: Vec,
- storage: HashMap,
+ storage: Option>,
depth: usize,
}
@@ -380,6 +402,23 @@ mod tests {
{"pc":1,"op":96,"opName":"PUSH1","gas":"0xfffd","gasCost":"0x3","memory":"0x","stack":["0x0"],"storage":{},"depth":1}
{"pc":3,"op":85,"opName":"SSTORE","gas":"0xfffa","gasCost":"0x1388","memory":"0x","stack":["0x0","0xd8"],"storage":{},"depth":1}
{"pc":4,"op":84,"opName":"SLOAD","gas":"0xec72","gasCost":"0x0","memory":"0x","stack":[],"storage":{"0x00000000000000000000000000000000000000000000000000000000000000d8":"0x0000000000000000000000000000000000000000000000000000000000000000"},"depth":1}
+"#,
+ );
+ }
+
+ #[test]
+ fn should_omit_storage_and_memory_flag() {
+ // should omit storage
+ run_test(
+ Informant::new(Config::new(true, true)),
+ &compare_json,
+ "3260D85554",
+ 0xffff,
+ r#"
+{"pc":0,"op":50,"opName":"ORIGIN","gas":"0xffff","gasCost":"0x2","memory":"","stack":[],"storage":null,"depth":1}
+{"pc":1,"op":96,"opName":"PUSH1","gas":"0xfffd","gasCost":"0x3","memory":"","stack":["0x0"],"storage":null,"depth":1}
+{"pc":3,"op":85,"opName":"SSTORE","gas":"0xfffa","gasCost":"0x1388","memory":"","stack":["0x0","0xd8"],"storage":null,"depth":1}
+{"pc":4,"op":84,"opName":"SLOAD","gas":"0xec72","gasCost":"0x0","memory":"","stack":[],"storage":null,"depth":1}
"#,
)
}
diff --git a/evmbin/src/display/mod.rs b/bin/evmbin/src/display/mod.rs
similarity index 98%
rename from evmbin/src/display/mod.rs
rename to bin/evmbin/src/display/mod.rs
index 9131f436cf..abd9c42ca9 100644
--- a/evmbin/src/display/mod.rs
+++ b/bin/evmbin/src/display/mod.rs
@@ -18,6 +18,7 @@
use std::time::Duration;
+pub mod config;
pub mod json;
pub mod simple;
pub mod std_json;
diff --git a/evmbin/src/display/simple.rs b/bin/evmbin/src/display/simple.rs
similarity index 89%
rename from evmbin/src/display/simple.rs
rename to bin/evmbin/src/display/simple.rs
index 264205768a..76043d54ea 100644
--- a/evmbin/src/display/simple.rs
+++ b/bin/evmbin/src/display/simple.rs
@@ -16,6 +16,7 @@
//! Simple VM output.
+use super::config::Config;
use bytes::ToPretty;
use ethcore::trace;
@@ -24,17 +25,25 @@ use info as vm;
/// Simple formatting informant.
#[derive(Default)]
-pub struct Informant;
+pub struct Informant {
+ config: Config,
+}
+
+impl Informant {
+ pub fn new(config: Config) -> Informant {
+ Informant { config }
+ }
+}
impl vm::Informant for Informant {
- type Sink = ();
+ type Sink = Config;
fn before_test(&mut self, name: &str, action: &str) {
println!("Test: {} ({})", name, action);
}
fn clone_sink(&self) -> Self::Sink {
- ()
+ self.config
}
fn finish(result: vm::RunResult, _sink: &mut Self::Sink) {
diff --git a/evmbin/src/display/std_json.rs b/bin/evmbin/src/display/std_json.rs
similarity index 82%
rename from evmbin/src/display/std_json.rs
rename to bin/evmbin/src/display/std_json.rs
index 33638aa8ed..4114f719cc 100644
--- a/evmbin/src/display/std_json.rs
+++ b/bin/evmbin/src/display/std_json.rs
@@ -18,11 +18,11 @@
use std::{collections::HashMap, io};
+use super::config::Config;
use bytes::ToPretty;
-use ethcore::{pod_state, trace};
-use ethereum_types::{H256, U256};
-
use display;
+use ethcore::{pod_state, trace};
+use ethereum_types::{BigEndianHash, H256, U256};
use info as vm;
pub trait Writer: io::Write + Send + Sized {
@@ -61,30 +61,39 @@ pub struct Informant {
subdepth: usize,
trace_sink: Trace,
out_sink: Out,
+ config: Config,
}
impl Default for Informant {
fn default() -> Self {
- Self::new(io::stderr(), io::stdout())
+ Self::new(io::stderr(), io::stdout(), Config::default())
}
}
impl Informant {
/// std json informant using out only.
- pub fn out_only() -> Self {
- Self::new(io::stdout(), io::stdout())
+ pub fn out_only(config: Config) -> Self {
+ Self::new(io::stdout(), io::stdout(), config)
}
}
impl Informant {
/// std json informant using err only.
- pub fn err_only() -> Self {
- Self::new(io::stderr(), io::stderr())
+ pub fn err_only(config: Config) -> Self {
+ Self::new(io::stderr(), io::stderr(), config)
+ }
+}
+
+impl Informant {
+ pub fn new_default(config: Config) -> Self {
+ let mut informant = Self::default();
+ informant.config = config;
+ informant
}
}
impl Informant {
- pub fn new(trace_sink: Trace, out_sink: Out) -> Self {
+ pub fn new(trace_sink: Trace, out_sink: Out, config: Config) -> Self {
Informant {
code: Default::default(),
instruction: Default::default(),
@@ -95,6 +104,7 @@ impl Informant {
subdepth: 0,
trace_sink,
out_sink,
+ config,
}
}
@@ -133,7 +143,7 @@ impl Informant {
}
impl vm::Informant for Informant {
- type Sink = (Trace, Out);
+ type Sink = (Trace, Out, Config);
fn before_test(&mut self, name: &str, action: &str) {
let out_data = json!({
@@ -147,11 +157,15 @@ impl vm::Informant for Informant {
fn set_gas(&mut self, _gas: U256) {}
fn clone_sink(&self) -> Self::Sink {
- (self.trace_sink.clone(), self.out_sink.clone())
+ (
+ self.trace_sink.clone(),
+ self.out_sink.clone(),
+ self.config.clone(),
+ )
}
fn finish(
result: vm::RunResult<::Output>,
- (ref mut trace_sink, ref mut out_sink): &mut Self::Sink,
+ (ref mut trace_sink, ref mut out_sink, _): &mut Self::Sink,
) {
match result {
Ok(success) => {
@@ -189,6 +203,11 @@ impl trace::VMTracer for Informant {
fn trace_next_instruction(&mut self, pc: usize, instruction: u8, current_gas: U256) -> bool {
let subdepth = self.subdepth;
Self::with_informant_in_depth(self, subdepth, |informant: &mut Informant| {
+ let storage = if informant.config.omit_storage_output() {
+ None
+ } else {
+ Some(&informant.storage)
+ };
let info = ::evm::Instruction::from_u8(instruction).map(|i| i.info());
informant.instruction = instruction;
let trace_data = json!({
@@ -197,7 +216,7 @@ impl trace::VMTracer for Informant {
"opName": info.map(|i| i.name).unwrap_or(""),
"gas": format!("{:#x}", current_gas),
"stack": informant.stack,
- "storage": informant.storage,
+ "storage": storage,
"depth": informant.depth,
});
@@ -218,7 +237,10 @@ impl trace::VMTracer for Informant {
let subdepth = self.subdepth;
Self::with_informant_in_depth(self, subdepth, |informant: &mut Informant| {
if let Some((pos, val)) = store_written {
- informant.storage.insert(pos.into(), val.into());
+ informant.storage.insert(
+ BigEndianHash::from_uint(&pos),
+ BigEndianHash::from_uint(&val),
+ );
}
});
}
@@ -240,7 +262,11 @@ impl trace::VMTracer for Informant {
fn prepare_subtrace(&mut self, code: &[u8]) {
let subdepth = self.subdepth;
Self::with_informant_in_depth(self, subdepth, |informant: &mut Informant| {
- let mut vm = Informant::new(informant.trace_sink.clone(), informant.out_sink.clone());
+ let mut vm = Informant::new(
+ informant.trace_sink.clone(),
+ informant.out_sink.clone(),
+ informant.config,
+ );
vm.depth = informant.depth + 1;
vm.code = code.to_vec();
informant.subinfos.push(vm);
@@ -289,16 +315,16 @@ pub mod tests {
}
}
- pub fn informant() -> (Informant, Arc>>) {
+ pub fn informant(config: Config) -> (Informant, Arc>>) {
let trace_writer: TestWriter = Default::default();
let out_writer: TestWriter = Default::default();
let res = trace_writer.0.clone();
- (Informant::new(trace_writer, out_writer), res)
+ (Informant::new(trace_writer, out_writer, config), res)
}
#[test]
fn should_trace_failure() {
- let (inf, res) = informant();
+ let (inf, res) = informant(Config::default());
run_test(
inf,
move |_, expected| {
@@ -312,7 +338,7 @@ pub mod tests {
"#,
);
- let (inf, res) = informant();
+ let (inf, res) = informant(Config::default());
run_test(
inf,
move |_, expected| {
@@ -328,7 +354,7 @@ pub mod tests {
#[test]
fn should_trace_create_correctly() {
- let (informant, res) = informant();
+ let (informant, res) = informant(Config::default());
run_test(
informant,
move |_, expected| {
@@ -361,6 +387,26 @@ pub mod tests {
{"depth":2,"gas":"0x2102","op":88,"opName":"PC","pc":5,"stack":["0x0","0x0","0x0","0x0","0x0"],"storage":{}}
{"depth":2,"gas":"0x2100","op":48,"opName":"ADDRESS","pc":6,"stack":["0x0","0x0","0x0","0x0","0x0","0x5"],"storage":{}}
{"depth":2,"gas":"0x20fe","op":241,"opName":"CALL","pc":7,"stack":["0x0","0x0","0x0","0x0","0x0","0x5","0xbd770416a3345f91e4b34576cb804a576fa48eb1"],"storage":{}}
+"#,
+ )
+ }
+
+ #[test]
+ fn should_omit_storage_and_memory_flag() {
+ // should omit storage
+ let (informant, res) = informant(Config::new(true, true));
+ run_test(
+ informant,
+ move |_, expected| {
+ let bytes = res.lock().unwrap();
+ assert_eq!(expected, &String::from_utf8_lossy(&**bytes))
+ },
+ "3260D85554",
+ 0xffff,
+ r#"{"depth":1,"gas":"0xffff","op":50,"opName":"ORIGIN","pc":0,"stack":[],"storage":null}
+{"depth":1,"gas":"0xfffd","op":96,"opName":"PUSH1","pc":1,"stack":["0x0"],"storage":null}
+{"depth":1,"gas":"0xfffa","op":85,"opName":"SSTORE","pc":3,"stack":["0x0","0xd8"],"storage":null}
+{"depth":1,"gas":"0xec72","op":84,"opName":"SLOAD","pc":4,"stack":[],"storage":null}
"#,
)
}
diff --git a/evmbin/src/info.rs b/bin/evmbin/src/info.rs
similarity index 96%
rename from evmbin/src/info.rs
rename to bin/evmbin/src/info.rs
index d2b0b6bc78..4e308d264f 100644
--- a/evmbin/src/info.rs
+++ b/bin/evmbin/src/info.rs
@@ -103,7 +103,7 @@ pub fn run_action(
Ok(r) => (Ok(r.return_data.to_vec()), Some(r.gas_left)),
Err(err) => (Err(err), None),
};
- (result.0, 0.into(), None, result.1, informant.drain())
+ (result.0, H256::zero(), None, result.1, informant.drain())
},
)
}
@@ -141,7 +141,7 @@ pub fn run_transaction(
let result = run(
&spec,
trie_spec,
- transaction.gas,
+ transaction.tx().gas,
pre_state,
|mut client| {
let result = client.transact(env_info, transaction, trace::NoopTracer, informant);
@@ -262,6 +262,7 @@ where
#[cfg(test)]
pub mod tests {
use super::*;
+ use ethereum_types::Address;
use rustc_hex::FromHex;
use std::sync::Arc;
use tempdir::TempDir;
@@ -287,11 +288,11 @@ pub mod tests {
#[test]
fn should_call_account_from_spec() {
- use display::std_json::tests::informant;
+ use display::{config::Config, std_json::tests::informant};
- let (inf, res) = informant();
+ let (inf, res) = informant(Config::default());
let mut params = ActionParams::default();
- params.code_address = 0x20.into();
+ params.code_address = Address::from_low_u64_be(0x20);
params.gas = 0xffff.into();
let spec = ::ethcore::ethereum::load(None, include_bytes!("../res/testchain.json"));
diff --git a/evmbin/src/main.rs b/bin/evmbin/src/main.rs
similarity index 84%
rename from evmbin/src/main.rs
rename to bin/evmbin/src/main.rs
index 7853788c71..c6a7f987ec 100644
--- a/evmbin/src/main.rs
+++ b/bin/evmbin/src/main.rs
@@ -57,10 +57,10 @@ use info::Informant;
const USAGE: &'static str = r#"
EVM implementation for Parity.
- Copyright 2015-2019 Parity Technologies (UK) Ltd.
+ Copyright 2015-2020 Parity Technologies (UK) Ltd.
Usage:
- openethereum-evm state-test [--json --std-json --std-dump-json --only NAME --chain CHAIN --std-out-only --std-err-only]
+ openethereum-evm state-test [--json --std-json --std-dump-json --only NAME --chain CHAIN --std-out-only --std-err-only --omit-storage-output --omit-memory-output]
openethereum-evm stats [options]
openethereum-evm stats-jsontests-vm
openethereum-evm [options]
@@ -84,16 +84,19 @@ State test options:
--chain CHAIN Run only from specific chain name (i.e. one of EIP150, EIP158,
Frontier, Homestead, Byzantium, Constantinople,
ConstantinopleFix, Istanbul, EIP158ToByzantiumAt5, FrontierToHomesteadAt5,
- HomesteadToDaoAt5, HomesteadToEIP150At5).
+ HomesteadToDaoAt5, HomesteadToEIP150At5, Berlin, Yolo3).
--only NAME Runs only a single test matching the name.
General options:
- --json Display verbose results in JSON.
- --std-json Display results in standardized JSON format.
- --std-err-only With --std-json redirect to err output only.
- --std-out-only With --std-json redirect to out output only.
- --std-dump-json Display results in standardized JSON format
- with additional state dump.
+ --json Display verbose results in JSON.
+ --std-json Display results in standardized JSON format.
+ --std-err-only With --std-json redirect to err output only.
+ --std-out-only With --std-json redirect to out output only.
+ --omit-storage-output With --std-json omit storage output.
+ --omit-memory-output With --std-json omit memory output.
+ --std-dump-json Display results in standardized JSON format
+ with additional state dump.
+
Display result state dump in standardized JSON format.
--chain CHAIN Chain spec file path.
-h, --help Display this message and exit.
@@ -107,22 +110,24 @@ fn main() {
.and_then(|d| d.deserialize())
.unwrap_or_else(|e| e.exit());
+ let config = args.config();
+
if args.cmd_state_test {
run_state_test(args)
} else if args.cmd_stats_jsontests_vm {
run_stats_jsontests_vm(args)
} else if args.flag_json {
- run_call(args, display::json::Informant::default())
+ run_call(args, display::json::Informant::new(config))
} else if args.flag_std_dump_json || args.flag_std_json {
if args.flag_std_err_only {
- run_call(args, display::std_json::Informant::err_only())
+ run_call(args, display::std_json::Informant::err_only(config))
} else if args.flag_std_out_only {
- run_call(args, display::std_json::Informant::out_only())
+ run_call(args, display::std_json::Informant::out_only(config))
} else {
- run_call(args, display::std_json::Informant::default())
+ run_call(args, display::std_json::Informant::new_default(config))
};
} else {
- run_call(args, display::simple::Informant::default())
+ run_call(args, display::simple::Informant::new(config))
}
}
@@ -165,7 +170,7 @@ fn run_stats_jsontests_vm(args: Args) {
fn run_state_test(args: Args) {
use ethjson::state::test::Test;
-
+ let config = args.config();
let file = args.arg_file.expect("FILE is required");
let mut file = match fs::File::open(&file) {
Err(err) => die(format!("Unable to open: {:?}: {}", file, err)),
@@ -197,10 +202,9 @@ fn run_state_test(args: Args) {
{
continue;
}
-
for (idx, state) in states.into_iter().enumerate() {
let post_root = state.hash.into();
- let transaction = multitransaction.select(&state.indexes).into();
+ let transaction = multitransaction.select(&state.indexes);
let trie_spec = if args.flag_std_dump_json {
TrieSpec::Fat
@@ -216,7 +220,7 @@ fn run_state_test(args: Args) {
post_root,
&env_info,
transaction,
- display::json::Informant::default(),
+ display::json::Informant::new(config),
trie_spec,
)
} else if args.flag_std_dump_json || args.flag_std_json {
@@ -229,7 +233,7 @@ fn run_state_test(args: Args) {
post_root,
&env_info,
transaction,
- display::std_json::Informant::err_only(),
+ display::std_json::Informant::err_only(config),
trie_spec,
)
} else if args.flag_std_out_only {
@@ -241,7 +245,7 @@ fn run_state_test(args: Args) {
post_root,
&env_info,
transaction,
- display::std_json::Informant::out_only(),
+ display::std_json::Informant::out_only(config),
trie_spec,
)
} else {
@@ -253,7 +257,7 @@ fn run_state_test(args: Args) {
post_root,
&env_info,
transaction,
- display::std_json::Informant::default(),
+ display::std_json::Informant::new_default(config),
trie_spec,
)
}
@@ -266,7 +270,7 @@ fn run_state_test(args: Args) {
post_root,
&env_info,
transaction,
- display::simple::Informant::default(),
+ display::simple::Informant::new(config),
trie_spec,
)
}
@@ -287,8 +291,16 @@ fn run_call(args: Args, informant: T) {
if code.is_none() && to == Address::default() {
die("Either --code or --to is required.");
}
-
let mut params = ActionParams::default();
+ if spec.engine.params().eip2929_transition == 0 {
+ params.access_list.enable();
+ params.access_list.insert_address(from);
+ params.access_list.insert_address(to);
+ for (builtin, _) in spec.engine.builtins() {
+ params.access_list.insert_address(*builtin);
+ }
+ }
+
params.call_type = if code.is_none() {
CallType::Call
} else {
@@ -331,6 +343,8 @@ struct Args {
flag_std_dump_json: bool,
flag_std_err_only: bool,
flag_std_out_only: bool,
+ flag_omit_storage_output: bool,
+ flag_omit_memory_output: bool,
}
impl Args {
@@ -378,13 +392,24 @@ impl Args {
pub fn spec(&self) -> Result {
Ok(match self.flag_chain {
- Some(ref filename) => {
- let file = fs::File::open(filename).map_err(|e| format!("{}", e))?;
- spec::Spec::load(&::std::env::temp_dir(), file)?
+ Some(ref spec_name) => {
+ let fork_spec: Result =
+ serde_json::from_str(&format!("{:?}", spec_name));
+ if let Ok(fork_spec) = fork_spec {
+ ethcore::client::EvmTestClient::spec_from_json(&fork_spec)
+ .expect("this forkspec is not defined")
+ } else {
+ let file = fs::File::open(spec_name).map_err(|e| format!("{}", e))?;
+ spec::Spec::load(&::std::env::temp_dir(), file)?
+ }
}
None => ethcore::ethereum::new_foundation(&::std::env::temp_dir()),
})
}
+
+ pub fn config(&self) -> display::config::Config {
+ display::config::Config::new(self.flag_omit_storage_output, self.flag_omit_memory_output)
+ }
}
fn arg(v: Result, param: &str) -> T {
@@ -404,6 +429,7 @@ fn die(msg: T) -> ! {
mod tests {
use super::{Args, USAGE};
use docopt::Docopt;
+ use ethereum_types::Address;
fn run>(args: &[T]) -> Args {
Docopt::new(USAGE)
@@ -443,8 +469,8 @@ mod tests {
assert_eq!(args.flag_std_out_only, true);
assert_eq!(args.gas(), Ok(1.into()));
assert_eq!(args.gas_price(), Ok(2.into()));
- assert_eq!(args.from(), Ok(3.into()));
- assert_eq!(args.to(), Ok(4.into()));
+ assert_eq!(args.from(), Ok(Address::from_low_u64_be(3)));
+ assert_eq!(args.to(), Ok(Address::from_low_u64_be(4)));
assert_eq!(args.code(), Ok(Some(vec![05])));
assert_eq!(args.data(), Ok(Some(vec![06])));
assert_eq!(args.flag_chain, Some("./testfile".to_owned()));
diff --git a/parity/account.rs b/bin/oe/account.rs
similarity index 96%
rename from parity/account.rs
rename to bin/oe/account.rs
index 430dd2a19f..0bd87cdbd8 100644
--- a/parity/account.rs
+++ b/bin/oe/account.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use params::SpecType;
+use crate::params::SpecType;
use std::num::NonZeroU32;
#[derive(Debug, PartialEq)]
@@ -53,9 +53,11 @@ pub fn execute(_cmd: AccountCmd) -> Result {
#[cfg(feature = "accounts")]
mod command {
use super::*;
- use accounts::{AccountProvider, AccountProviderSettings};
+ use crate::{
+ accounts::{AccountProvider, AccountProviderSettings},
+ helpers::{password_from_file, password_prompt},
+ };
use ethstore::{accounts_dir::RootDiskDirectory, import_account, import_accounts, EthStore};
- use helpers::{password_from_file, password_prompt};
use std::path::PathBuf;
pub fn execute(cmd: AccountCmd) -> Result {
diff --git a/parity/account_utils.rs b/bin/oe/account_utils.rs
similarity index 91%
rename from parity/account_utils.rs
rename to bin/oe/account_utils.rs
index 36a91a06e1..4b9415466b 100644
--- a/parity/account_utils.rs
+++ b/bin/oe/account_utils.rs
@@ -16,11 +16,12 @@
use std::sync::Arc;
+use crypto::publickey;
use dir::Directories;
-use ethereum_types::Address;
+use ethereum_types::{Address, H160};
use ethkey::Password;
-use params::{AccountsConfig, SpecType};
+use crate::params::{AccountsConfig, SpecType};
#[cfg(not(feature = "accounts"))]
mod accounts {
@@ -70,9 +71,10 @@ mod accounts {
#[cfg(feature = "accounts")]
mod accounts {
use super::*;
- use upgrade::upgrade_key_location;
+ use crate::{ethereum_types::H256, upgrade::upgrade_key_location};
+ use std::str::FromStr;
- pub use accounts::AccountProvider;
+ pub use crate::accounts::AccountProvider;
/// Pops along with error messages when a password is missing or invalid.
const VERIFY_PASSWORD_HINT: &str = "Make sure valid password is present in files passed using `--password` or in the configuration file.";
@@ -85,7 +87,7 @@ mod accounts {
cfg: AccountsConfig,
passwords: &[Password],
) -> Result {
- use accounts::AccountProviderSettings;
+ use crate::accounts::AccountProviderSettings;
use ethstore::{accounts_dir::RootDiskDirectory, EthStore};
let path = dirs.keys_path(data_dir);
@@ -103,7 +105,8 @@ mod accounts {
| SpecType::Goerli
| SpecType::Sokol
| SpecType::Dev => vec![],
- _ => vec!["00a329c0648769a73afac7f9381e08fb43dbea72".into()],
+ _ => vec![H160::from_str("00a329c0648769a73afac7f9381e08fb43dbea72")
+ .expect("the string is valid hex; qed")],
},
};
@@ -195,7 +198,8 @@ mod accounts {
engine_signer,
password.clone(),
);
- if signer.sign(Default::default()).is_ok() {
+ // sign dummy msg to check if password and account can be used.
+ if signer.sign(H256::from_low_u64_be(1)).is_ok() {
author = Some(::ethcore::miner::Author::Sealer(Box::new(signer)));
}
}
@@ -216,9 +220,11 @@ mod accounts {
}
fn insert_dev_account(account_provider: &AccountProvider) {
- let secret: ethkey::Secret =
- "4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7".into();
- let dev_account = ethkey::KeyPair::from_secret(secret.clone())
+ let secret = publickey::Secret::from_str(
+ "4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7",
+ )
+ .expect("Valid account;qed");
+ let dev_account = publickey::KeyPair::from_secret(secret.clone())
.expect("Valid secret produces valid key;qed");
if !account_provider.has_account(dev_account.address()) {
match account_provider.insert_account(secret, &Password::from(String::new())) {
diff --git a/parity/blockchain.rs b/bin/oe/blockchain.rs
similarity index 97%
rename from parity/blockchain.rs
rename to bin/oe/blockchain.rs
index f101aa8690..d7f585758b 100644
--- a/parity/blockchain.rs
+++ b/bin/oe/blockchain.rs
@@ -16,10 +16,18 @@
use std::{fs, io, sync::Arc, time::Instant};
+use crate::{
+ bytes::ToPretty,
+ cache::CacheConfig,
+ db,
+ hash::{keccak, KECCAK_NULL_RLP},
+ helpers::{execute_upgrades, to_client_config},
+ informant::{FullNodeInformantData, Informant, MillisecondDuration},
+ params::{fatdb_switch_to_bool, tracing_switch_to_bool, Pruning, SpecType, Switch},
+ types::data_format::DataFormat,
+ user_defaults::UserDefaults,
+};
use ansi_term::Colour;
-use bytes::ToPretty;
-use cache::CacheConfig;
-use db;
use dir::Directories;
use ethcore::{
client::{
@@ -31,12 +39,6 @@ use ethcore::{
};
use ethcore_service::ClientService;
use ethereum_types::{Address, H256, U256};
-use hash::{keccak, KECCAK_NULL_RLP};
-use helpers::{execute_upgrades, to_client_config};
-use informant::{FullNodeInformantData, Informant, MillisecondDuration};
-use params::{fatdb_switch_to_bool, tracing_switch_to_bool, Pruning, SpecType, Switch};
-use types::data_format::DataFormat;
-use user_defaults::UserDefaults;
#[derive(Debug, PartialEq)]
pub enum BlockchainCmd {
diff --git a/parity/cache.rs b/bin/oe/cache.rs
similarity index 100%
rename from parity/cache.rs
rename to bin/oe/cache.rs
diff --git a/parity/cli/mod.rs b/bin/oe/cli/mod.rs
similarity index 97%
rename from parity/cli/mod.rs
rename to bin/oe/cli/mod.rs
index 207e7db3b0..216b7177cf 100644
--- a/parity/cli/mod.rs
+++ b/bin/oe/cli/mod.rs
@@ -248,7 +248,7 @@ usage! {
ARG arg_chain: (String) = "foundation", or |c: &Config| c.parity.as_ref()?.chain.clone(),
"--chain=[CHAIN]",
- "Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, poacore, xdai, volta, ewc, musicoin, ellaism, mix, callisto, morden, ropsten, kovan, rinkeby, goerli, poasokol, testnet, or dev.",
+ "Specify the blockchain type. CHAIN may be either a JSON chain specification file or ethereum, poacore, xdai, volta, ewc, musicoin, ellaism, mix, callisto, morden, ropsten, kovan, rinkeby, goerli, poasokol, testnet, yolo3 or dev.",
ARG arg_keys_path: (String) = "$BASE/keys", or |c: &Config| c.parity.as_ref()?.keys_path.clone(),
"--keys-path=[PATH]",
@@ -409,9 +409,9 @@ usage! {
"--jsonrpc-interface=[IP]",
"Specify the hostname portion of the HTTP JSON-RPC API server, IP should be an interface's IP address, or all (all interfaces) or local.",
- ARG arg_jsonrpc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,traces", or |c: &Config| c.rpc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
+ ARG arg_jsonrpc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,traces,rpc", or |c: &Config| c.rpc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
"--jsonrpc-apis=[APIS]",
- "Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces",
+ "Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc",
ARG arg_jsonrpc_hosts: (String) = "none", or |c: &Config| c.rpc.as_ref()?.hosts.as_ref().map(|vec| vec.join(",")),
"--jsonrpc-hosts=[HOSTS]",
@@ -450,9 +450,9 @@ usage! {
"--ws-interface=[IP]",
"Specify the hostname portion of the WebSockets JSON-RPC server, IP should be an interface's IP address, or all (all interfaces) or local.",
- ARG arg_ws_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,traces", or |c: &Config| c.websockets.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
+ ARG arg_ws_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,traces,rpc", or |c: &Config| c.websockets.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
"--ws-apis=[APIS]",
- "Specify the JSON-RPC APIs available through the WebSockets interface using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces",
+ "Specify the JSON-RPC APIs available through the WebSockets interface using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc",
ARG arg_ws_origins: (String) = "parity://*,chrome-extension://*,moz-extension://*", or |c: &Config| c.websockets.as_ref()?.origins.as_ref().map(|vec| vec.join(",")),
"--ws-origins=[URL]",
@@ -466,11 +466,19 @@ usage! {
"--ws-max-connections=[CONN]",
"Maximum number of allowed concurrent WebSockets JSON-RPC connections.",
+ ARG arg_ws_max_payload: (usize) = 5usize, or |c: &Config| c.websockets.as_ref()?.max_payload,
+ "--ws-max-payload=[MB]",
+ "Specify maximum size for WS JSON-RPC requests in megabytes.",
+
["Metrics"]
FLAG flag_metrics: (bool) = false, or |c: &Config| c.metrics.as_ref()?.enable.clone(),
"--metrics",
"Enable prometheus metrics (only full client).",
+ ARG arg_metrics_prefix: (String) = "", or |c: &Config| c.metrics.as_ref()?.prefix.clone(),
+ "--metrics-prefix=[prefix]",
+ "Prepend the specified prefix to the exported metrics names.",
+
ARG arg_metrics_port: (u16) = 3000u16, or |c: &Config| c.metrics.as_ref()?.port.clone(),
"--metrics-port=[PORT]",
"Specify the port portion of the metrics server.",
@@ -488,9 +496,9 @@ usage! {
"--ipc-path=[PATH]",
"Specify custom path for JSON-RPC over IPC service.",
- ARG arg_ipc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,parity_accounts,traces", or |c: &Config| c.ipc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
+ ARG arg_ipc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,parity_accounts,traces,rpc", or |c: &Config| c.ipc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
"--ipc-apis=[APIS]",
- "Specify custom API set available via JSON-RPC over IPC using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces",
+ "Specify custom API set available via JSON-RPC over IPC using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc",
["Secret Store Options"]
FLAG flag_no_secretstore: (bool) = false, or |c: &Config| c.secretstore.as_ref()?.disable.clone(),
@@ -706,7 +714,7 @@ usage! {
"--stratum-secret=[STRING]",
"Secret for authorizing Stratum server for peers.",
- ARG arg_max_round_blocks_to_import: (usize) = 12usize, or |c: &Config| c.mining.as_ref()?.max_round_blocks_to_import.clone(),
+ ARG arg_max_round_blocks_to_import: (usize) = 1usize, or |c: &Config| c.mining.as_ref()?.max_round_blocks_to_import.clone(),
"--max-round-blocks-to-import=[S]",
"Maximal number of blocks to import for each import round.",
@@ -903,6 +911,7 @@ struct Ws {
origins: Option>,
hosts: Option>,
max_connections: Option,
+ max_payload: Option,
}
#[derive(Default, Debug, PartialEq, Deserialize)]
@@ -917,6 +926,7 @@ struct Ipc {
#[serde(deny_unknown_fields)]
struct Metrics {
enable: Option,
+ prefix: Option,
port: Option,
interface: Option,
}
@@ -1307,7 +1317,7 @@ mod tests {
arg_jsonrpc_port: 8545u16,
arg_jsonrpc_interface: "local".into(),
arg_jsonrpc_cors: "null".into(),
- arg_jsonrpc_apis: "web3,eth,net,parity,traces,secretstore".into(),
+ arg_jsonrpc_apis: "web3,eth,net,parity,traces,rpc,secretstore".into(),
arg_jsonrpc_hosts: "none".into(),
arg_jsonrpc_server_threads: None,
arg_jsonrpc_threads: 4,
@@ -1319,19 +1329,21 @@ mod tests {
flag_no_ws: false,
arg_ws_port: 8546u16,
arg_ws_interface: "local".into(),
- arg_ws_apis: "web3,eth,net,parity,traces,secretstore".into(),
+ arg_ws_apis: "web3,eth,net,parity,traces,rpc,secretstore".into(),
arg_ws_origins: "none".into(),
arg_ws_hosts: "none".into(),
arg_ws_max_connections: 100,
+ arg_ws_max_payload: 5,
// IPC
flag_no_ipc: false,
arg_ipc_path: "$HOME/.parity/jsonrpc.ipc".into(),
- arg_ipc_apis: "web3,eth,net,parity,parity_accounts,personal,traces,secretstore"
+ arg_ipc_apis: "web3,eth,net,parity,parity_accounts,personal,traces,rpc,secretstore"
.into(),
// METRICS
flag_metrics: false,
+ arg_metrics_prefix: "".into(),
arg_metrics_port: 3000u16,
arg_metrics_interface: "local".into(),
@@ -1386,7 +1398,7 @@ mod tests {
arg_notify_work: Some("http://localhost:3001".into()),
flag_refuse_service_transactions: false,
flag_infinite_pending_block: false,
- arg_max_round_blocks_to_import: 12usize,
+ arg_max_round_blocks_to_import: 1usize,
flag_stratum: false,
arg_stratum_interface: "local".to_owned(),
@@ -1512,6 +1524,7 @@ mod tests {
origins: Some(vec!["none".into()]),
hosts: None,
max_connections: None,
+ max_payload: None,
}),
rpc: Some(Rpc {
disable: Some(true),
@@ -1535,6 +1548,7 @@ mod tests {
}),
metrics: Some(Metrics {
enable: Some(true),
+ prefix: Some("oe".to_string()),
interface: Some("local".to_string()),
port: Some(4000),
}),
diff --git a/parity/cli/presets/config.dev-insecure.toml b/bin/oe/cli/presets/config.dev-insecure.toml
similarity index 100%
rename from parity/cli/presets/config.dev-insecure.toml
rename to bin/oe/cli/presets/config.dev-insecure.toml
diff --git a/parity/cli/presets/config.dev.toml b/bin/oe/cli/presets/config.dev.toml
similarity index 100%
rename from parity/cli/presets/config.dev.toml
rename to bin/oe/cli/presets/config.dev.toml
diff --git a/parity/cli/presets/config.insecure.toml b/bin/oe/cli/presets/config.insecure.toml
similarity index 100%
rename from parity/cli/presets/config.insecure.toml
rename to bin/oe/cli/presets/config.insecure.toml
diff --git a/parity/cli/presets/config.mining.toml b/bin/oe/cli/presets/config.mining.toml
similarity index 100%
rename from parity/cli/presets/config.mining.toml
rename to bin/oe/cli/presets/config.mining.toml
diff --git a/parity/cli/presets/config.non-standard-ports.toml b/bin/oe/cli/presets/config.non-standard-ports.toml
similarity index 100%
rename from parity/cli/presets/config.non-standard-ports.toml
rename to bin/oe/cli/presets/config.non-standard-ports.toml
diff --git a/parity/cli/presets/mod.rs b/bin/oe/cli/presets/mod.rs
similarity index 100%
rename from parity/cli/presets/mod.rs
rename to bin/oe/cli/presets/mod.rs
diff --git a/parity/cli/tests/config.full.toml b/bin/oe/cli/tests/config.full.toml
similarity index 93%
rename from parity/cli/tests/config.full.toml
rename to bin/oe/cli/tests/config.full.toml
index 37b01cafc7..0d0f7aec1d 100644
--- a/parity/cli/tests/config.full.toml
+++ b/bin/oe/cli/tests/config.full.toml
@@ -39,7 +39,7 @@ disable = false
port = 8545
interface = "local"
cors = ["null"]
-apis = ["web3", "eth", "net", "parity", "traces", "secretstore"]
+apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
hosts = ["none"]
allow_missing_blocks = false
@@ -48,13 +48,13 @@ disable = false
port = 8546
interface = "local"
origins = ["none"]
-apis = ["web3", "eth", "net", "parity", "traces", "secretstore"]
+apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
hosts = ["none"]
[ipc]
disable = false
path = "$HOME/.parity/jsonrpc.ipc"
-apis = ["web3", "eth", "net", "parity", "parity_accounts", "personal", "traces", "secretstore"]
+apis = ["web3", "eth", "net", "parity", "parity_accounts", "personal", "traces", "rpc", "secretstore"]
[secretstore]
disable = false
diff --git a/parity/cli/tests/config.invalid1.toml b/bin/oe/cli/tests/config.invalid1.toml
similarity index 100%
rename from parity/cli/tests/config.invalid1.toml
rename to bin/oe/cli/tests/config.invalid1.toml
diff --git a/parity/cli/tests/config.invalid2.toml b/bin/oe/cli/tests/config.invalid2.toml
similarity index 100%
rename from parity/cli/tests/config.invalid2.toml
rename to bin/oe/cli/tests/config.invalid2.toml
diff --git a/parity/cli/tests/config.invalid3.toml b/bin/oe/cli/tests/config.invalid3.toml
similarity index 100%
rename from parity/cli/tests/config.invalid3.toml
rename to bin/oe/cli/tests/config.invalid3.toml
diff --git a/parity/cli/tests/config.invalid4.toml b/bin/oe/cli/tests/config.invalid4.toml
similarity index 100%
rename from parity/cli/tests/config.invalid4.toml
rename to bin/oe/cli/tests/config.invalid4.toml
diff --git a/parity/cli/tests/config.toml b/bin/oe/cli/tests/config.toml
similarity index 98%
rename from parity/cli/tests/config.toml
rename to bin/oe/cli/tests/config.toml
index 581a59af53..d9b01a05de 100644
--- a/parity/cli/tests/config.toml
+++ b/bin/oe/cli/tests/config.toml
@@ -36,7 +36,7 @@ apis = ["rpc", "eth"]
enable = true
interface = "local"
port = 4000
-
+prefix = "oe"
[secretstore]
http_port = 8082
diff --git a/parity/cli/usage.rs b/bin/oe/cli/usage.rs
similarity index 100%
rename from parity/cli/usage.rs
rename to bin/oe/cli/usage.rs
diff --git a/parity/cli/usage_header.txt b/bin/oe/cli/usage_header.txt
similarity index 100%
rename from parity/cli/usage_header.txt
rename to bin/oe/cli/usage_header.txt
diff --git a/parity/cli/version.txt b/bin/oe/cli/version.txt
similarity index 100%
rename from parity/cli/version.txt
rename to bin/oe/cli/version.txt
diff --git a/parity/configuration.rs b/bin/oe/configuration.rs
similarity index 96%
rename from parity/configuration.rs
rename to bin/oe/configuration.rs
index 7416bfa8c8..1e3743c5cf 100644
--- a/parity/configuration.rs
+++ b/bin/oe/configuration.rs
@@ -14,9 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
+use crate::{
+ bytes::Bytes,
+ cli::{Args, ArgsError},
+ hash::keccak,
+ metrics::MetricsConfiguration,
+ miner::pool,
+ sync::{self, validate_node_url, NetworkConfiguration},
+};
use ansi_term::Colour;
-use bytes::Bytes;
-use cli::{Args, ArgsError};
+
+use crypto::publickey::{Public, Secret};
use ethcore::{
client::VMType,
miner::{stratum, MinerOptions},
@@ -24,10 +32,7 @@ use ethcore::{
verification::queue::VerifierSettings,
};
use ethereum_types::{Address, H256, U256};
-use ethkey::{Public, Secret};
-use hash::keccak;
-use metrics::MetricsConfiguration;
-use miner::pool;
+
use num_cpus;
use parity_version::{version, version_data};
use std::{
@@ -40,35 +45,37 @@ use std::{
path::PathBuf,
time::Duration,
};
-use sync::{self, validate_node_url, NetworkConfiguration};
-use account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount};
-use blockchain::{
- BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain, KillBlockchain, ResetBlockchain,
+use crate::{
+ account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount},
+ blockchain::{
+ BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain, KillBlockchain,
+ ResetBlockchain,
+ },
+ cache::CacheConfig,
+ helpers::{
+ parity_ipc_path, to_address, to_addresses, to_block_id, to_bootnodes, to_duration, to_mode,
+ to_pending_set, to_price, to_queue_penalization, to_queue_strategy, to_u256,
+ },
+ network::IpFilter,
+ params::{AccountsConfig, GasPricerConfig, MinerExtras, ResealPolicy, SpecType},
+ presale::ImportWallet,
+ rpc::{HttpConfiguration, IpcConfiguration, WsConfiguration},
+ run::RunCmd,
+ secretstore::{
+ Configuration as SecretStoreConfiguration, ContractAddress as SecretStoreContractAddress,
+ NodeSecretKey,
+ },
+ snapshot::{self, SnapshotCommand},
+ types::data_format::DataFormat,
};
-use cache::CacheConfig;
use dir::{
self, default_data_path, default_local_path,
helpers::{replace_home, replace_home_and_local},
Directories,
};
use ethcore_logger::Config as LogConfig;
-use helpers::{
- parity_ipc_path, to_address, to_addresses, to_block_id, to_bootnodes, to_duration, to_mode,
- to_pending_set, to_price, to_queue_penalization, to_queue_strategy, to_u256,
-};
-use network::IpFilter;
-use params::{AccountsConfig, GasPricerConfig, MinerExtras, ResealPolicy, SpecType};
use parity_rpc::NetworkSettings;
-use presale::ImportWallet;
-use rpc::{HttpConfiguration, IpcConfiguration, WsConfiguration};
-use run::RunCmd;
-use secretstore::{
- Configuration as SecretStoreConfiguration, ContractAddress as SecretStoreContractAddress,
- NodeSecretKey,
-};
-use snapshot::{self, SnapshotCommand};
-use types::data_format::DataFormat;
const DEFAULT_MAX_PEERS: u16 = 50;
const DEFAULT_MIN_PEERS: u16 = 25;
@@ -166,7 +173,7 @@ impl Configuration {
let cmd = if self.args.flag_version {
Cmd::Version
} else if self.args.cmd_signer {
- let authfile = ::signer::codes_path(&ws_conf.signer_path);
+ let authfile = crate::signer::codes_path(&ws_conf.signer_path);
if self.args.cmd_signer_new_token {
Cmd::SignerToken(ws_conf, logger_config.clone())
@@ -518,10 +525,8 @@ impl Configuration {
}
fn ip_filter(&self) -> Result {
- match IpFilter::parse(self.args.arg_allow_ips.as_str()) {
- Ok(allow_ip) => Ok(allow_ip),
- Err(_) => Err("Invalid IP filter value".to_owned()),
- }
+ IpFilter::parse(self.args.arg_allow_ips.as_str())
+ .map_err(|_| "Invalid IP filter value".to_owned())
}
fn min_peers(&self) -> u32 {
@@ -812,7 +817,7 @@ impl Configuration {
ret.public_address = public.map(|p| format!("{}", p));
ret.use_secret = match self.args.arg_node_key.as_ref().map(|s| {
s.parse::()
- .or_else(|_| Secret::from_unsafe_slice(&keccak(s)))
+ .or_else(|_| Secret::import_key(keccak(s).as_bytes()))
.map_err(|e| format!("Invalid key: {:?}", e))
}) {
None => None,
@@ -951,6 +956,7 @@ impl Configuration {
signer_path: self.directories().signer.into(),
support_token_api,
max_connections: self.args.arg_ws_max_connections,
+ max_payload: self.args.arg_ws_max_payload,
};
Ok(conf)
@@ -959,6 +965,7 @@ impl Configuration {
fn metrics_config(&self) -> Result {
let conf = MetricsConfiguration {
enabled: self.metrics_enabled(),
+ prefix: self.metrics_prefix(),
interface: self.metrics_interface(),
port: self.args.arg_ports_shift + self.args.arg_metrics_port,
};
@@ -1148,6 +1155,10 @@ impl Configuration {
self.args.flag_metrics
}
+ fn metrics_prefix(&self) -> String {
+ self.args.arg_metrics_prefix.clone()
+ }
+
fn secretstore_enabled(&self) -> bool {
!self.args.flag_no_secretstore && cfg!(feature = "secretstore")
}
@@ -1239,23 +1250,25 @@ fn into_secretstore_service_contract_address(
mod tests {
use std::{fs::File, io::Write, str::FromStr};
- use account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount};
- use blockchain::{BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain};
- use cli::Args;
+ use crate::{
+ account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount},
+ blockchain::{BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain},
+ cli::Args,
+ helpers::default_network_config,
+ miner::pool::PrioritizationStrategy,
+ params::SpecType,
+ presale::ImportWallet,
+ rpc::WsConfiguration,
+ rpc_apis::ApiSet,
+ run::RunCmd,
+ types::{data_format::DataFormat, ids::BlockId},
+ };
use dir::Directories;
use ethcore::{client::VMType, miner::MinerOptions};
- use helpers::default_network_config;
- use miner::pool::PrioritizationStrategy;
- use params::SpecType;
use parity_rpc::NetworkSettings;
- use presale::ImportWallet;
- use rpc::WsConfiguration;
- use rpc_apis::ApiSet;
- use run::RunCmd;
use tempdir::TempDir;
- use types::{data_format::DataFormat, ids::BlockId};
- use network::{AllowIP, IpFilter};
+ use crate::network::{AllowIP, IpFilter};
extern crate ipnetwork;
use self::ipnetwork::IpNetwork;
@@ -1369,7 +1382,7 @@ mod tests {
check_seal: true,
with_color: !cfg!(windows),
verifier_settings: Default::default(),
- max_round_blocks_to_import: 12,
+ max_round_blocks_to_import: 1,
}))
);
}
@@ -1395,7 +1408,7 @@ mod tests {
from_block: BlockId::Number(1),
to_block: BlockId::Latest,
check_seal: true,
- max_round_blocks_to_import: 12,
+ max_round_blocks_to_import: 1,
}))
);
}
@@ -1423,7 +1436,7 @@ mod tests {
code: true,
min_balance: None,
max_balance: None,
- max_round_blocks_to_import: 12,
+ max_round_blocks_to_import: 1,
}))
);
}
@@ -1456,7 +1469,7 @@ mod tests {
from_block: BlockId::Number(1),
to_block: BlockId::Latest,
check_seal: true,
- max_round_blocks_to_import: 12,
+ max_round_blocks_to_import: 1,
}))
);
}
@@ -1483,6 +1496,7 @@ mod tests {
signer_path: expected.into(),
support_token_api: true,
max_connections: 100,
+ max_payload: 5,
},
LogConfig {
color: !cfg!(windows),
@@ -1550,7 +1564,7 @@ mod tests {
download_old_blocks: true,
verifier_settings: Default::default(),
no_persistent_txqueue: false,
- max_round_blocks_to_import: 12,
+ max_round_blocks_to_import: 1,
metrics_conf: MetricsConfiguration::default(),
};
expected.secretstore_conf.enabled = cfg!(feature = "secretstore");
@@ -1741,7 +1755,7 @@ mod tests {
ApiSet::List(set) => assert_eq!(set, ApiSet::All.list_apis()),
_ => panic!("Incorrect rpc apis"),
}
- // "web3,eth,net,personal,parity,parity_set,traces,parity_accounts");
+ // "web3,eth,net,personal,parity,parity_set,traces,rpc,parity_accounts");
assert_eq!(c.http_conf.hosts, None);
}
_ => panic!("Should be Cmd::Run"),
@@ -1762,7 +1776,7 @@ mod tests {
ApiSet::List(set) => assert_eq!(set, ApiSet::All.list_apis()),
_ => panic!("Incorrect rpc apis"),
}
- // "web3,eth,net,personal,parity,parity_set,traces,parity_accounts");
+ // "web3,eth,net,personal,parity,parity_set,traces,rpc,parity_accounts");
assert_eq!(c.http_conf.hosts, None);
}
_ => panic!("Should be Cmd::Run"),
diff --git a/parity/db/mod.rs b/bin/oe/db/mod.rs
similarity index 100%
rename from parity/db/mod.rs
rename to bin/oe/db/mod.rs
diff --git a/parity/db/rocksdb/blooms.rs b/bin/oe/db/rocksdb/blooms.rs
similarity index 100%
rename from parity/db/rocksdb/blooms.rs
rename to bin/oe/db/rocksdb/blooms.rs
diff --git a/parity/db/rocksdb/helpers.rs b/bin/oe/db/rocksdb/helpers.rs
similarity index 100%
rename from parity/db/rocksdb/helpers.rs
rename to bin/oe/db/rocksdb/helpers.rs
diff --git a/parity/db/rocksdb/migration.rs b/bin/oe/db/rocksdb/migration.rs
similarity index 100%
rename from parity/db/rocksdb/migration.rs
rename to bin/oe/db/rocksdb/migration.rs
diff --git a/parity/db/rocksdb/mod.rs b/bin/oe/db/rocksdb/mod.rs
similarity index 90%
rename from parity/db/rocksdb/mod.rs
rename to bin/oe/db/rocksdb/mod.rs
index c923cba2fa..e5789f89a9 100644
--- a/parity/db/rocksdb/mod.rs
+++ b/bin/oe/db/rocksdb/mod.rs
@@ -24,7 +24,8 @@ use self::{
};
use blooms_db;
use ethcore::client::ClientConfig;
-use kvdb::KeyValueDB;
+use ethcore_db::KeyValueDB;
+use stats::PrometheusMetrics;
use std::{fs, io, path::Path, sync::Arc};
mod blooms;
@@ -53,6 +54,10 @@ impl BlockChainDB for AppDB {
}
}
+impl PrometheusMetrics for AppDB {
+ fn prometheus_metrics(&self, _: &mut stats::PrometheusRegistry) {}
+}
+
/// Open a secret store DB using the given secret store data path. The DB path is one level beneath the data path.
#[cfg(feature = "secretstore")]
pub fn open_secretstore_db(data_path: &str) -> Result, String> {
@@ -101,8 +106,11 @@ pub fn open_database(
fs::create_dir_all(&blooms_path)?;
fs::create_dir_all(&trace_blooms_path)?;
+ let db = Database::open(&config, client_path)?;
+ let db_with_metrics = ethcore_db::DatabaseWithMetrics::new(db);
+
let db = AppDB {
- key_value: Arc::new(Database::open(&config, client_path)?),
+ key_value: Arc::new(db_with_metrics),
blooms: blooms_db::Database::open(blooms_path)?,
trace_blooms: blooms_db::Database::open(trace_blooms_path)?,
};
diff --git a/parity/helpers.rs b/bin/oe/helpers.rs
similarity index 96%
rename from parity/helpers.rs
rename to bin/oe/helpers.rs
index 76d28defd3..688ba25e4f 100644
--- a/parity/helpers.rs
+++ b/bin/oe/helpers.rs
@@ -14,17 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use cache::CacheConfig;
-use db::migrate;
+use crate::{
+ cache::CacheConfig,
+ db::migrate,
+ miner::pool::PrioritizationStrategy,
+ sync::{self, validate_node_url},
+ upgrade::{upgrade, upgrade_data_paths},
+};
use dir::{helpers::replace_home, DatabaseDirectories};
use ethcore::{
client::{BlockId, ClientConfig, DatabaseCompactionProfile, Mode, VMType, VerifierType},
miner::{Penalization, PendingSet},
};
-use ethereum_types::{clean_0x, Address, U256};
+use ethereum_types::{Address, U256};
use ethkey::Password;
use journaldb::Algorithm;
-use miner::pool::PrioritizationStrategy;
use std::{
collections::HashSet,
fs::File,
@@ -32,13 +36,19 @@ use std::{
io::{BufRead, BufReader, Write},
time::Duration,
};
-use sync::{self, validate_node_url};
-use upgrade::{upgrade, upgrade_data_paths};
pub fn to_duration(s: &str) -> Result {
to_seconds(s).map(Duration::from_secs)
}
+fn clean_0x(s: &str) -> &str {
+ if s.starts_with("0x") {
+ &s[2..]
+ } else {
+ s
+ }
+}
+
fn to_seconds(s: &str) -> Result {
let bad = |_| {
format!(
@@ -105,10 +115,10 @@ pub fn to_block_id(s: &str) -> Result {
pub fn to_u256(s: &str) -> Result {
if let Ok(decimal) = U256::from_dec_str(s) {
Ok(decimal)
- } else if let Ok(hex) = clean_0x(s).parse() {
- Ok(hex)
} else {
- Err(format!("Invalid numeric value: {}", s))
+ clean_0x(s)
+ .parse()
+ .map_err(|_| format!("Invalid numeric value: {}", s))
}
}
@@ -171,15 +181,12 @@ pub fn to_price(s: &str) -> Result {
}
pub fn join_set(set: Option<&HashSet>) -> Option {
- match set {
- Some(s) => Some(
- s.iter()
- .map(|s| s.as_str())
- .collect::>()
- .join(","),
- ),
- None => None,
- }
+ set.map(|s| {
+ s.iter()
+ .map(|s| s.as_str())
+ .collect::>()
+ .join(",")
+ })
}
/// Flush output buffer.
@@ -218,9 +225,9 @@ pub fn to_bootnodes(bootnodes: &Option) -> Result, String> {
}
#[cfg(test)]
-pub fn default_network_config() -> ::sync::NetworkConfiguration {
+pub fn default_network_config() -> crate::sync::NetworkConfiguration {
use super::network::IpFilter;
- use sync::NetworkConfiguration;
+ use crate::sync::NetworkConfiguration;
NetworkConfiguration {
config_path: Some(replace_home(&::dir::default_data_path(), "$BASE/network")),
net_config_path: None,
diff --git a/parity/informant.rs b/bin/oe/informant.rs
similarity index 93%
rename from parity/informant.rs
rename to bin/oe/informant.rs
index 4f09c137a5..ae205f6fc5 100644
--- a/parity/informant.rs
+++ b/bin/oe/informant.rs
@@ -29,6 +29,11 @@ use std::{
time::{Duration, Instant},
};
+use crate::{
+ io::{IoContext, IoHandler, TimerToken},
+ sync::{ManageNetwork, SyncProvider},
+ types::BlockNumber,
+};
use atty;
use ethcore::{
client::{
@@ -37,12 +42,9 @@ use ethcore::{
},
snapshot::{service::Service as SnapshotService, RestorationStatus, SnapshotService as SS},
};
-use io::{IoContext, IoHandler, TimerToken};
use number_prefix::{binary_prefix, Prefixed, Standalone};
use parity_rpc::{informant::RpcStats, is_major_importing_or_waiting};
use parking_lot::{Mutex, RwLock};
-use sync::{ManageNetwork, SyncProvider};
-use types::BlockNumber;
/// Format byte counts to standard denominations.
pub fn format_bytes(b: usize) -> String {
@@ -92,7 +94,7 @@ impl CacheSizes {
pub struct SyncInfo {
last_imported_block_number: BlockNumber,
- last_imported_old_block_number: Option,
+ last_imported_ancient_number: Option,
num_peers: usize,
max_peers: u32,
snapshot_sync: bool,
@@ -160,7 +162,7 @@ impl InformantData for FullNodeInformantData {
last_imported_block_number: status
.last_imported_block_number
.unwrap_or(chain_info.best_block_number),
- last_imported_old_block_number: status.last_imported_old_block_number,
+ last_imported_ancient_number: status.last_imported_old_block_number,
num_peers: status.num_peers,
max_peers: status
.current_max_peers(*num_peers_range.start(), *num_peers_range.end()),
@@ -224,7 +226,14 @@ impl Informant {
pub fn tick(&self) {
let now = Instant::now();
- let elapsed = now.duration_since(*self.last_tick.read());
+ let elapsed;
+ {
+ let last_tick = self.last_tick.read();
+ if now < *last_tick + Duration::from_millis(1500) {
+ return;
+ }
+ elapsed = now - *last_tick;
+ }
let (client_report, full_report) = {
let last_report = self.last_report.lock();
@@ -265,7 +274,7 @@ impl Informant {
false => t,
};
- info!(target: "import", "{} {} {} {}",
+ info!(target: "import", "{}{} {} {} {}",
match importing {
true => match snapshot_sync {
false => format!("Syncing {} {} {} {}+{} Qed",
@@ -301,18 +310,22 @@ impl Informant {
},
false => String::new(),
},
+ match chain_info.ancient_block_number {
+ Some(ancient_number) => format!(" Ancient:#{}", ancient_number),
+ None => String::new(),
+ },
match sync_info.as_ref() {
Some(ref sync_info) => format!("{}{}/{} peers",
match importing {
true => format!("{}",
if self.target.executes_transactions() {
- paint(Green.bold(), format!("{:>8} ", format!("#{}", sync_info.last_imported_block_number)))
+ paint(Green.bold(), format!("{:>8} ", format!("LI:#{}", sync_info.last_imported_block_number)))
} else {
String::new()
}
),
- false => match sync_info.last_imported_old_block_number {
- Some(number) => format!("{} ", paint(Yellow.bold(), format!("{:>8}", format!("#{}", number)))),
+ false => match sync_info.last_imported_ancient_number {
+ Some(number) => format!("{} ", paint(Yellow.bold(), format!("{:>8}", format!("AB:#{}", number)))),
None => String::new(),
}
},
@@ -336,6 +349,7 @@ impl Informant {
}
impl ChainNotify for Informant {
+ // t_nb 11.2 Informant. Prints new block inclusiong to console/log.
fn new_blocks(&self, new_blocks: NewBlocks) {
if new_blocks.has_more_blocks_to_import {
return;
diff --git a/parity/lib.rs b/bin/oe/lib.rs
similarity index 98%
rename from parity/lib.rs
rename to bin/oe/lib.rs
index 3f811826d6..4c7a596b1a 100644
--- a/parity/lib.rs
+++ b/bin/oe/lib.rs
@@ -61,13 +61,13 @@ extern crate keccak_hash as hash;
extern crate kvdb;
extern crate node_filter;
extern crate parity_bytes as bytes;
+extern crate parity_crypto as crypto;
extern crate parity_local_store as local_store;
extern crate parity_path as path;
extern crate parity_rpc;
extern crate parity_runtime;
extern crate parity_version;
extern crate prometheus;
-extern crate registrar;
extern crate stats;
#[macro_use]
@@ -114,9 +114,11 @@ mod user_defaults;
use std::{fs::File, io::BufReader, sync::Arc};
-use cli::Args;
-use configuration::{Cmd, Execute};
-use hash::keccak_buffer;
+use crate::{
+ cli::Args,
+ configuration::{Cmd, Execute},
+ hash::keccak_buffer,
+};
#[cfg(feature = "memory_profiling")]
use std::alloc::System;
diff --git a/parity/logger/Cargo.toml b/bin/oe/logger/Cargo.toml
similarity index 100%
rename from parity/logger/Cargo.toml
rename to bin/oe/logger/Cargo.toml
diff --git a/parity/logger/src/lib.rs b/bin/oe/logger/src/lib.rs
similarity index 96%
rename from parity/logger/src/lib.rs
rename to bin/oe/logger/src/lib.rs
index 44412a05a5..11465225a4 100644
--- a/parity/logger/src/lib.rs
+++ b/bin/oe/logger/src/lib.rs
@@ -157,10 +157,11 @@ pub fn setup_log(config: &Config) -> Result, String> {
Ok(logs)
})
// couldn't create new logger - try to fall back on previous logger.
- .or_else(|err| match ROTATING_LOGGER.lock().upgrade() {
- Some(l) => Ok(l),
- // no previous logger. fatal.
- None => Err(format!("{:?}", err)),
+ .or_else(|err| {
+ ROTATING_LOGGER
+ .lock()
+ .upgrade()
+ .ok_or_else(|| format!("{:?}", err))
})
}
diff --git a/parity/logger/src/rotating.rs b/bin/oe/logger/src/rotating.rs
similarity index 100%
rename from parity/logger/src/rotating.rs
rename to bin/oe/logger/src/rotating.rs
diff --git a/parity/main.rs b/bin/oe/main.rs
similarity index 100%
rename from parity/main.rs
rename to bin/oe/main.rs
diff --git a/parity/metrics.rs b/bin/oe/metrics.rs
similarity index 80%
rename from parity/metrics.rs
rename to bin/oe/metrics.rs
index da083bd8d7..7c7119bcf7 100644
--- a/parity/metrics.rs
+++ b/bin/oe/metrics.rs
@@ -8,13 +8,15 @@ use hyper::{service::service_fn_ok, Body, Method, Request, Response, Server, Sta
use stats::{
prometheus::{self, Encoder},
- prometheus_gauge, PrometheusMetrics,
+ PrometheusMetrics, PrometheusRegistry,
};
#[derive(Debug, Clone, PartialEq)]
pub struct MetricsConfiguration {
/// Are metrics enabled (default is false)?
pub enabled: bool,
+ /// Prefix
+ pub prefix: String,
/// The IP of the network interface used (default is 127.0.0.1).
pub interface: String,
/// The network port (default is 3000).
@@ -25,6 +27,7 @@ impl Default for MetricsConfiguration {
fn default() -> Self {
MetricsConfiguration {
enabled: false,
+ prefix: "".into(),
interface: "127.0.0.1".into(),
port: 3000,
}
@@ -35,19 +38,22 @@ struct State {
rpc_apis: Arc,
}
-fn handle_request(req: Request, state: Arc>) -> Response {
+fn handle_request(
+ req: Request,
+ conf: Arc,
+ state: Arc>,
+) -> Response {
let (parts, _body) = req.into_parts();
match (parts.method, parts.uri.path()) {
(Method::GET, "/metrics") => {
let start = Instant::now();
- let mut reg = prometheus::Registry::new();
+ let mut reg = PrometheusRegistry::new(conf.prefix.clone());
let state = state.lock();
state.rpc_apis.client.prometheus_metrics(&mut reg);
state.rpc_apis.sync.prometheus_metrics(&mut reg);
let elapsed = start.elapsed();
- prometheus_gauge(
- &mut reg,
+ reg.register_gauge(
"metrics_time",
"Time to perform rpc metrics",
elapsed.as_millis() as i64,
@@ -55,7 +61,7 @@ fn handle_request(req: Request, state: Arc>) -> Response| handle_request(req, state.clone()))
+ let conf = conf.clone();
+ service_fn_ok(move |req: Request| {
+ handle_request(req, conf.clone(), state.clone())
+ })
})
.map_err(|e| eprintln!("server error: {}", e));
- println!("Listening on http://{}", addr);
+ info!("Started prometeus metrics at http://{}/metrics", addr);
deps.executor.spawn(server);
diff --git a/parity/modules.rs b/bin/oe/modules.rs
similarity index 91%
rename from parity/modules.rs
rename to bin/oe/modules.rs
index 5cf6971d67..8e80635219 100644
--- a/parity/modules.rs
+++ b/bin/oe/modules.rs
@@ -16,14 +16,16 @@
use std::sync::{mpsc, Arc};
+use crate::{
+ sync::{self, ConnectionFilter, NetworkConfiguration, Params, SyncConfig},
+ types::BlockNumber,
+};
use ethcore::{client::BlockChainClient, snapshot::SnapshotService};
use std::collections::BTreeSet;
-use sync::{self, ConnectionFilter, NetworkConfiguration, Params, SyncConfig};
-use types::BlockNumber;
+pub use crate::sync::{EthSync, ManageNetwork, SyncProvider};
pub use ethcore::client::ChainNotify;
use ethcore_logger::Config as LogConfig;
-pub use sync::{EthSync, ManageNetwork, SyncProvider};
pub type SyncModules = (
Arc,
diff --git a/parity/params.rs b/bin/oe/params.rs
similarity index 97%
rename from parity/params.rs
rename to bin/oe/params.rs
index 3d3163b19e..af2747ab17 100644
--- a/parity/params.rs
+++ b/bin/oe/params.rs
@@ -16,6 +16,13 @@
use std::{collections::HashSet, fmt, fs, num::NonZeroU32, str, time::Duration};
+use crate::{
+ miner::{
+ gas_price_calibrator::{GasPriceCalibrator, GasPriceCalibratorOptions},
+ gas_pricer::GasPricer,
+ },
+ user_defaults::UserDefaults,
+};
use ethcore::{
client::Mode,
ethereum,
@@ -24,13 +31,8 @@ use ethcore::{
use ethereum_types::{Address, U256};
use fetch::Client as FetchClient;
use journaldb::Algorithm;
-use miner::{
- gas_price_calibrator::{GasPriceCalibrator, GasPriceCalibratorOptions},
- gas_pricer::GasPricer,
-};
use parity_runtime::Executor;
use parity_version::version_data;
-use user_defaults::UserDefaults;
use crate::configuration;
@@ -51,6 +53,7 @@ pub enum SpecType {
Rinkeby,
Goerli,
Sokol,
+ Yolo3,
Dev,
Custom(String),
}
@@ -81,6 +84,7 @@ impl str::FromStr for SpecType {
"rinkeby" => SpecType::Rinkeby,
"goerli" | "görli" | "testnet" => SpecType::Goerli,
"sokol" | "poasokol" => SpecType::Sokol,
+ "yolo3" => SpecType::Yolo3,
"dev" => SpecType::Dev,
other => SpecType::Custom(other.into()),
};
@@ -106,6 +110,7 @@ impl fmt::Display for SpecType {
SpecType::Rinkeby => "rinkeby",
SpecType::Goerli => "goerli",
SpecType::Sokol => "sokol",
+ SpecType::Yolo3 => "yolo3",
SpecType::Dev => "dev",
SpecType::Custom(ref custom) => custom,
})
@@ -131,6 +136,7 @@ impl SpecType {
SpecType::Rinkeby => Ok(ethereum::new_rinkeby(params)),
SpecType::Goerli => Ok(ethereum::new_goerli(params)),
SpecType::Sokol => Ok(ethereum::new_sokol(params)),
+ SpecType::Yolo3 => Ok(ethereum::new_yolo3(params)),
SpecType::Dev => Ok(Spec::new_instant()),
SpecType::Custom(ref filename) => {
let file = fs::File::open(filename).map_err(|e| {
@@ -370,8 +376,8 @@ pub fn mode_switch_to_bool(
#[cfg(test)]
mod tests {
use super::{tracing_switch_to_bool, Pruning, ResealPolicy, SpecType, Switch};
+ use crate::user_defaults::UserDefaults;
use journaldb::Algorithm;
- use user_defaults::UserDefaults;
#[test]
fn test_spec_type_parsing() {
diff --git a/parity/presale.rs b/bin/oe/presale.rs
similarity index 87%
rename from parity/presale.rs
rename to bin/oe/presale.rs
index b160ab7744..c44c9fd1cf 100644
--- a/parity/presale.rs
+++ b/bin/oe/presale.rs
@@ -14,10 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
+use crate::{
+ helpers::{password_from_file, password_prompt},
+ params::SpecType,
+};
+use crypto::publickey;
+
use ethkey::Password;
use ethstore::PresaleWallet;
-use helpers::{password_from_file, password_prompt};
-use params::SpecType;
use std::num::NonZeroU32;
#[derive(Debug, PartialEq)]
@@ -44,7 +48,8 @@ pub fn execute(cmd: ImportWallet) -> Result {
}
#[cfg(feature = "accounts")]
-pub fn import_account(cmd: &ImportWallet, kp: ethkey::KeyPair, password: Password) {
+
+pub fn import_account(cmd: &ImportWallet, kp: publickey::KeyPair, password: Password) {
use accounts::{AccountProvider, AccountProviderSettings};
use ethstore::{accounts_dir::RootDiskDirectory, EthStore};
@@ -57,4 +62,4 @@ pub fn import_account(cmd: &ImportWallet, kp: ethkey::KeyPair, password: Passwor
}
#[cfg(not(feature = "accounts"))]
-pub fn import_account(_cmd: &ImportWallet, _kp: ethkey::KeyPair, _password: Password) {}
+pub fn import_account(_cmd: &ImportWallet, _kp: publickey::KeyPair, _password: Password) {}
diff --git a/parity/rpc.rs b/bin/oe/rpc.rs
similarity index 97%
rename from parity/rpc.rs
rename to bin/oe/rpc.rs
index 1022cfc9cb..3d90b812ea 100644
--- a/parity/rpc.rs
+++ b/bin/oe/rpc.rs
@@ -16,8 +16,11 @@
use std::{collections::HashSet, io, path::PathBuf, sync::Arc};
+use crate::{
+ helpers::parity_ipc_path,
+ rpc_apis::{self, ApiSet},
+};
use dir::{default_data_path, helpers::replace_home};
-use helpers::parity_ipc_path;
use jsonrpc_core::MetaIoHandler;
use parity_rpc::{
self as rpc,
@@ -25,7 +28,6 @@ use parity_rpc::{
DomainsValidation, Metadata,
};
use parity_runtime::Executor;
-use rpc_apis::{self, ApiSet};
pub use parity_rpc::{HttpServer, IpcServer, RequestMiddleware};
//pub use parity_rpc::ws::Server as WsServer;
@@ -97,6 +99,7 @@ pub struct WsConfiguration {
pub hosts: Option>,
pub signer_path: PathBuf,
pub support_token_api: bool,
+ pub max_payload: usize,
}
impl Default for WsConfiguration {
@@ -116,6 +119,7 @@ impl Default for WsConfiguration {
hosts: Some(Vec::new()),
signer_path: replace_home(&data_dir, "$BASE/signer").into(),
support_token_api: true,
+ max_payload: 5,
}
}
}
@@ -180,7 +184,7 @@ pub fn new_ws(
let signer_path;
let path = match conf.support_token_api {
true => {
- signer_path = ::signer::codes_path(&conf.signer_path);
+ signer_path = crate::signer::codes_path(&conf.signer_path);
Some(signer_path.as_path())
}
false => None,
@@ -194,6 +198,7 @@ pub fn new_ws(
rpc::WsExtractor::new(path.clone()),
rpc::WsExtractor::new(path.clone()),
rpc::WsStats::new(deps.stats.clone()),
+ conf.max_payload,
);
// match start_result {
diff --git a/parity/rpc_apis.rs b/bin/oe/rpc_apis.rs
similarity index 91%
rename from parity/rpc_apis.rs
rename to bin/oe/rpc_apis.rs
index 0de19f7685..50db479cb6 100644
--- a/parity/rpc_apis.rs
+++ b/bin/oe/rpc_apis.rs
@@ -14,16 +14,24 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use std::{cmp::PartialEq, collections::HashSet, str::FromStr, sync::Arc};
+use std::{
+ cmp::PartialEq,
+ collections::{BTreeMap, HashSet},
+ str::FromStr,
+ sync::Arc,
+};
pub use parity_rpc::signer::SignerService;
-use account_utils::{self, AccountProvider};
+use crate::{
+ account_utils::{self, AccountProvider},
+ miner::external::ExternalMiner,
+ sync::{ManageNetwork, SyncProvider},
+};
use ethcore::{client::Client, miner::Miner, snapshot::SnapshotService};
use ethcore_logger::RotatingLogger;
use fetch::Client as FetchClient;
use jsonrpc_core::{self as core, MetaIoHandler};
-use miner::external::ExternalMiner;
use parity_rpc::{
dispatch::FullDispatcher,
informant::{ActivityNotifier, ClientNotifier},
@@ -31,7 +39,6 @@ use parity_rpc::{
};
use parity_runtime::Executor;
use parking_lot::Mutex;
-use sync::{ManageNetwork, SyncProvider};
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
pub enum Api {
@@ -51,6 +58,8 @@ pub enum Api {
Parity,
/// Traces (Safe)
Traces,
+ /// Rpc (Safe)
+ Rpc,
/// Parity PubSub - Generic Publish-Subscriber (Safety depends on other APIs exposed).
ParityPubSub,
/// Parity Accounts extensions (UNSAFE: Passwords, Side Effects (new account))
@@ -80,6 +89,7 @@ impl FromStr for Api {
"parity_set" => Ok(ParitySet),
"personal" => Ok(Personal),
"pubsub" => Ok(EthPubSub),
+ "rpc" => Ok(Rpc),
"secretstore" => Ok(SecretStore),
"signer" => Ok(Signer),
"traces" => Ok(Traces),
@@ -146,6 +156,30 @@ impl FromStr for ApiSet {
}
}
+fn to_modules(apis: &HashSet) -> BTreeMap {
+ let mut modules = BTreeMap::new();
+ for api in apis {
+ let (name, version) = match *api {
+ Api::Debug => ("debug", "1.0"),
+ Api::Eth => ("eth", "1.0"),
+ Api::EthPubSub => ("pubsub", "1.0"),
+ Api::Net => ("net", "1.0"),
+ Api::Parity => ("parity", "1.0"),
+ Api::ParityAccounts => ("parity_accounts", "1.0"),
+ Api::ParityPubSub => ("parity_pubsub", "1.0"),
+ Api::ParitySet => ("parity_set", "1.0"),
+ Api::Personal => ("personal", "1.0"),
+ Api::Rpc => ("rpc", "1.0"),
+ Api::SecretStore => ("secretstore", "1.0"),
+ Api::Signer => ("signer", "1.0"),
+ Api::Traces => ("traces", "1.0"),
+ Api::Web3 => ("web3", "1.0"),
+ };
+ modules.insert(name.into(), version.into());
+ }
+ modules
+}
+
macro_rules! add_signing_methods {
($namespace:ident, $handler:expr, $deps:expr, $dispatch:expr) => {{
let deps = &$deps;
@@ -376,6 +410,10 @@ impl FullDependencies {
);
}
Api::Traces => handler.extend_with(TracesClient::new(&self.client).to_delegate()),
+ Api::Rpc => {
+ let modules = to_modules(&apis);
+ handler.extend_with(RpcClient::new(modules).to_delegate());
+ }
Api::SecretStore => {
#[cfg(feature = "accounts")]
handler.extend_with(SecretStoreClient::new(&self.accounts).to_delegate());
@@ -409,11 +447,17 @@ impl ApiSet {
}
pub fn list_apis(&self) -> HashSet {
- let mut public_list: HashSet =
- [Api::Web3, Api::Net, Api::Eth, Api::EthPubSub, Api::Parity]
- .iter()
- .cloned()
- .collect();
+ let mut public_list: HashSet = [
+ Api::Web3,
+ Api::Net,
+ Api::Eth,
+ Api::EthPubSub,
+ Api::Parity,
+ Api::Rpc,
+ ]
+ .iter()
+ .cloned()
+ .collect();
match *self {
ApiSet::List(ref apis) => apis.clone(),
@@ -470,6 +514,7 @@ mod test {
assert_eq!(Api::ParityAccounts, "parity_accounts".parse().unwrap());
assert_eq!(Api::ParitySet, "parity_set".parse().unwrap());
assert_eq!(Api::Traces, "traces".parse().unwrap());
+ assert_eq!(Api::Rpc, "rpc".parse().unwrap());
assert_eq!(Api::SecretStore, "secretstore".parse().unwrap());
assert!("rp".parse::().is_err());
}
@@ -498,6 +543,7 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
+ Api::Rpc,
]
.into_iter()
.collect();
@@ -515,6 +561,7 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
+ Api::Rpc,
// semi-safe
Api::ParityAccounts,
]
@@ -536,6 +583,7 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
+ Api::Rpc,
Api::SecretStore,
Api::ParityAccounts,
Api::ParitySet,
@@ -562,6 +610,7 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
+ Api::Rpc,
Api::SecretStore,
Api::ParityAccounts,
Api::ParitySet,
@@ -587,6 +636,7 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
+ Api::Rpc,
]
.into_iter()
.collect()
diff --git a/parity/run.rs b/bin/oe/run.rs
similarity index 92%
rename from parity/run.rs
rename to bin/oe/run.rs
index 59548bf700..503524c8b2 100644
--- a/parity/run.rs
+++ b/bin/oe/run.rs
@@ -16,15 +16,30 @@
use std::{
any::Any,
+ str::FromStr,
sync::{atomic, Arc, Weak},
thread,
time::{Duration, Instant},
};
-use account_utils;
+use crate::{
+ account_utils,
+ cache::CacheConfig,
+ db,
+ helpers::{execute_upgrades, passwords_from_files, to_client_config},
+ informant::{FullNodeInformantData, Informant},
+ metrics::{start_prometheus_metrics, MetricsConfiguration},
+ miner::{external::ExternalMiner, work_notify::WorkPoster},
+ modules,
+ params::{
+ fatdb_switch_to_bool, mode_switch_to_bool, tracing_switch_to_bool, AccountsConfig,
+ GasPricerConfig, MinerExtras, Pruning, SpecType, Switch,
+ },
+ rpc, rpc_apis, secretstore, signer,
+ sync::{self, SyncConfig},
+ user_defaults::UserDefaults,
+};
use ansi_term::Colour;
-use cache::CacheConfig;
-use db;
use dir::{DatabaseDirectories, Directories};
use ethcore::{
client::{BlockChainClient, BlockInfo, Client, DatabaseCompactionProfile, Mode, VMType},
@@ -34,37 +49,22 @@ use ethcore::{
};
use ethcore_logger::{Config as LogConfig, RotatingLogger};
use ethcore_service::ClientService;
-use ethereum_types::H256;
-use helpers::{execute_upgrades, passwords_from_files, to_client_config};
-use informant::{FullNodeInformantData, Informant};
+use ethereum_types::{H256, U64};
use journaldb::Algorithm;
use jsonrpc_core;
-use metrics::{start_prometheus_metrics, MetricsConfiguration};
-use miner::{external::ExternalMiner, work_notify::WorkPoster};
-use modules;
use node_filter::NodeFilter;
-use params::{
- fatdb_switch_to_bool, mode_switch_to_bool, tracing_switch_to_bool, AccountsConfig,
- GasPricerConfig, MinerExtras, Pruning, SpecType, Switch,
-};
use parity_rpc::{
informant, is_major_importing, FutureOutput, FutureResponse, FutureResult, Metadata,
NetworkSettings, Origin, PubSubSession,
};
use parity_runtime::Runtime;
use parity_version::version;
-use rpc;
-use rpc_apis;
-use secretstore;
-use signer;
-use sync::{self, SyncConfig};
-use user_defaults::UserDefaults;
-// how often to take periodic snapshots.
-const SNAPSHOT_PERIOD: u64 = 5000;
+// How often we attempt to take a snapshot: only snapshot on blocknumbers that are multiples of this.
+const SNAPSHOT_PERIOD: u64 = 20000;
-// how many blocks to wait before starting a periodic snapshot.
-const SNAPSHOT_HISTORY: u64 = 100;
+// Start snapshoting from `tip`-`history, with this we want to bypass reorgs. Should be smaller than prunning history.
+const SNAPSHOT_HISTORY: u64 = 50;
// Full client number of DNS threads
const FETCH_FULL_NUM_DNS_THREADS: usize = 4;
@@ -119,8 +119,8 @@ struct FullNodeInfo {
miner: Option>, // TODO: only TXQ needed, just use that after decoupling.
}
-impl ::local_store::NodeInfo for FullNodeInfo {
- fn pending_transactions(&self) -> Vec<::types::transaction::PendingTransaction> {
+impl crate::local_store::NodeInfo for FullNodeInfo {
+ fn pending_transactions(&self) -> Vec {
let miner = match self.miner.as_ref() {
Some(m) => m,
None => return Vec::new(),
@@ -130,7 +130,7 @@ impl ::local_store::NodeInfo for FullNodeInfo {
.local_transactions()
.values()
.filter_map(|status| match *status {
- ::miner::pool::local_transactions::Status::Pending(ref tx) => {
+ crate::miner::pool::local_transactions::Status::Pending(ref tx) => {
Some(tx.pending().clone())
}
_ => None,
@@ -227,12 +227,10 @@ pub fn execute(cmd: RunCmd, logger: Arc) -> Result id,
None => spec.network_id(),
};
- if spec.subprotocol_name().len() != 3 {
- warn!("Your chain specification's subprotocol length is not 3. Ignoring.");
+ if spec.subprotocol_name().len() > 8 {
+ warn!("Your chain specification's subprotocol length is more then 8. Ignoring.");
} else {
- sync_config
- .subprotocol_name
- .clone_from_slice(spec.subprotocol_name().as_bytes());
+ sync_config.subprotocol_name = U64::from(spec.subprotocol_name().as_bytes())
}
sync_config.fork_block = spec.fork_block();
@@ -388,7 +386,7 @@ pub fn execute(cmd: RunCmd, logger: Arc) -> Result) -> Result) -> Result Vec {
match *spec {
SpecType::Ropsten => {
- vec!["1eac3d16c642411f13c287e29144c6f58fda859407c8f24c38deb168e1040714".into()]
+ vec![
+ H256::from_str("1eac3d16c642411f13c287e29144c6f58fda859407c8f24c38deb168e1040714")
+ .expect("Valid hex string"),
+ ]
}
_ => vec![],
}
diff --git a/parity/secretstore.rs b/bin/oe/secretstore.rs
similarity index 98%
rename from parity/secretstore.rs
rename to bin/oe/secretstore.rs
index a55bfd90b0..d62cd844f2 100644
--- a/parity/secretstore.rs
+++ b/bin/oe/secretstore.rs
@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use account_utils::AccountProvider;
+use crate::{account_utils::AccountProvider, sync::SyncProvider};
+use crypto::publickey::{Public, Secret};
use dir::{default_data_path, helpers::replace_home};
use ethcore::{client::Client, miner::Miner};
use ethereum_types::Address;
-use ethkey::{Password, Public, Secret};
+use ethkey::Password;
use parity_runtime::Executor;
use std::{collections::BTreeMap, sync::Arc};
-use sync::SyncProvider;
/// This node secret key.
#[derive(Debug, PartialEq, Clone)]
diff --git a/parity/signer.rs b/bin/oe/signer.rs
similarity index 97%
rename from parity/signer.rs
rename to bin/oe/signer.rs
index 7dd00f728f..ff30c11f2b 100644
--- a/parity/signer.rs
+++ b/bin/oe/signer.rs
@@ -19,12 +19,10 @@ use std::{
path::{Path, PathBuf},
};
+use crate::{path::restrict_permissions_owner, rpc, rpc_apis};
use ansi_term::Colour::White;
use ethcore_logger::Config as LogConfig;
use parity_rpc;
-use path::restrict_permissions_owner;
-use rpc;
-use rpc_apis;
pub const CODES_FILENAME: &'static str = "authcodes";
diff --git a/parity/snapshot.rs b/bin/oe/snapshot.rs
similarity index 96%
rename from parity/snapshot.rs
rename to bin/oe/snapshot.rs
index 1cd4bbf991..3ed7f0f24c 100644
--- a/parity/snapshot.rs
+++ b/bin/oe/snapshot.rs
@@ -22,6 +22,7 @@ use std::{
time::Duration,
};
+use crate::{hash::keccak, types::ids::BlockId};
use ethcore::{
client::{DatabaseCompactionProfile, Mode, VMType},
miner::Miner,
@@ -32,15 +33,15 @@ use ethcore::{
},
};
use ethcore_service::ClientService;
-use hash::keccak;
-use types::ids::BlockId;
-use cache::CacheConfig;
-use db;
+use crate::{
+ cache::CacheConfig,
+ db,
+ helpers::{execute_upgrades, to_client_config},
+ params::{fatdb_switch_to_bool, tracing_switch_to_bool, Pruning, SpecType, Switch},
+ user_defaults::UserDefaults,
+};
use dir::Directories;
-use helpers::{execute_upgrades, to_client_config};
-use params::{fatdb_switch_to_bool, tracing_switch_to_bool, Pruning, SpecType, Switch};
-use user_defaults::UserDefaults;
/// Kinds of snapshot commands.
#[derive(Debug, PartialEq, Clone, Copy)]
@@ -303,7 +304,7 @@ impl SnapshotCommand {
let cur_size = p.size();
if cur_size != last_size {
last_size = cur_size;
- let bytes = ::informant::format_bytes(cur_size as usize);
+ let bytes = crate::informant::format_bytes(cur_size as usize);
info!(
"Snapshot: {} accounts {} blocks {}",
p.accounts(),
diff --git a/parity/stratum.rs b/bin/oe/stratum.rs
similarity index 98%
rename from parity/stratum.rs
rename to bin/oe/stratum.rs
index 14e54aa908..d3bd6cc3a7 100644
--- a/parity/stratum.rs
+++ b/bin/oe/stratum.rs
@@ -39,7 +39,7 @@ struct StratumControlService {
impl ControlService for StratumControlService {
fn shutdown(&self) -> bool {
trace!(target: "hypervisor", "Received shutdown from control service");
- self.stop.store(true, ::std::sync::atomic::Ordering::Relaxed);
+ self.stop.store(true, ::std::sync::atomic::Ordering::SeqCst);
true
}
}
diff --git a/parity/upgrade.rs b/bin/oe/upgrade.rs
similarity index 100%
rename from parity/upgrade.rs
rename to bin/oe/upgrade.rs
diff --git a/parity/user_defaults.rs b/bin/oe/user_defaults.rs
similarity index 100%
rename from parity/user_defaults.rs
rename to bin/oe/user_defaults.rs
diff --git a/accounts/Cargo.toml b/crates/accounts/Cargo.toml
similarity index 84%
rename from accounts/Cargo.toml
rename to crates/accounts/Cargo.toml
index e88d77683a..56ad94278f 100644
--- a/accounts/Cargo.toml
+++ b/crates/accounts/Cargo.toml
@@ -12,11 +12,12 @@ common-types = { path = "../ethcore/types" }
ethkey = { path = "ethkey" }
ethstore = { path = "ethstore" }
log = "0.4"
+parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
parking_lot = "0.7"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
[dev-dependencies]
-ethereum-types = "0.4"
+ethereum-types = "0.9.2"
tempdir = "0.3"
diff --git a/accounts/ethkey/.gitignore b/crates/accounts/ethkey/.gitignore
similarity index 100%
rename from accounts/ethkey/.gitignore
rename to crates/accounts/ethkey/.gitignore
diff --git a/accounts/ethkey/.travis.yml b/crates/accounts/ethkey/.travis.yml
similarity index 100%
rename from accounts/ethkey/.travis.yml
rename to crates/accounts/ethkey/.travis.yml
diff --git a/accounts/ethkey/Cargo.toml b/crates/accounts/ethkey/Cargo.toml
similarity index 64%
rename from accounts/ethkey/Cargo.toml
rename to crates/accounts/ethkey/Cargo.toml
index e432a11820..5b32bbaa2e 100644
--- a/accounts/ethkey/Cargo.toml
+++ b/crates/accounts/ethkey/Cargo.toml
@@ -6,15 +6,15 @@ authors = ["Parity Technologies "]
[dependencies]
edit-distance = "2.0"
-parity-crypto = "0.3.0"
-eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1", rev = "ccc06e7480148b723eb44ac56cf4d20eec380b6f" }
-ethereum-types = "0.4"
+parity-crypto = { version = "0.6.2", features = ["publickey"] }
+eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1", rev = "9791e79f21a5309dcb6e0bd254b1ef88fca2f1f4" }
+ethereum-types = "0.9.2"
lazy_static = "1.0"
log = "0.4"
-memzero = { path = "../../util/memzero" }
+memzero = { path = "../../../crates/util/memzero" }
parity-wordlist = "1.3"
quick-error = "1.2.2"
-rand = "0.4"
+rand = "0.7.3"
rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
diff --git a/accounts/ethkey/README.md b/crates/accounts/ethkey/README.md
similarity index 100%
rename from accounts/ethkey/README.md
rename to crates/accounts/ethkey/README.md
diff --git a/accounts/ethkey/src/brain.rs b/crates/accounts/ethkey/src/brain.rs
similarity index 81%
rename from accounts/ethkey/src/brain.rs
rename to crates/accounts/ethkey/src/brain.rs
index 9d835f1180..2cb6806fc5 100644
--- a/accounts/ethkey/src/brain.rs
+++ b/crates/accounts/ethkey/src/brain.rs
@@ -14,8 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use super::{Generator, KeyPair, Secret};
-use keccak::Keccak256;
+use parity_crypto::{
+ publickey::{KeyPair, Secret},
+ Keccak256,
+};
use parity_wordlist;
/// Simple brainwallet.
@@ -29,12 +31,8 @@ impl Brain {
pub fn validate_phrase(phrase: &str, expected_words: usize) -> Result<(), ::WordlistError> {
parity_wordlist::validate_phrase(phrase, expected_words)
}
-}
-
-impl Generator for Brain {
- type Error = ::Void;
- fn generate(&mut self) -> Result {
+ pub fn generate(&mut self) -> KeyPair {
let seed = self.0.clone();
let mut secret = seed.into_bytes().keccak256();
@@ -45,12 +43,10 @@ impl Generator for Brain {
match i > 16384 {
false => i += 1,
true => {
- if let Ok(pair) =
- Secret::from_unsafe_slice(&secret).and_then(KeyPair::from_secret)
- {
+ if let Ok(pair) = Secret::import_key(&secret).and_then(KeyPair::from_secret) {
if pair.address()[0] == 0 {
trace!("Testing: {}, got: {:?}", self.0, pair.address());
- return Ok(pair);
+ return pair;
}
}
}
@@ -62,13 +58,12 @@ impl Generator for Brain {
#[cfg(test)]
mod tests {
use Brain;
- use Generator;
#[test]
fn test_brain() {
let words = "this is sparta!".to_owned();
- let first_keypair = Brain::new(words.clone()).generate().unwrap();
- let second_keypair = Brain::new(words.clone()).generate().unwrap();
+ let first_keypair = Brain::new(words.clone()).generate();
+ let second_keypair = Brain::new(words.clone()).generate();
assert_eq!(first_keypair.secret(), second_keypair.secret());
}
}
diff --git a/accounts/ethkey/src/brain_prefix.rs b/crates/accounts/ethkey/src/brain_prefix.rs
similarity index 83%
rename from accounts/ethkey/src/brain_prefix.rs
rename to crates/accounts/ethkey/src/brain_prefix.rs
index cc25a03f21..819dce564e 100644
--- a/accounts/ethkey/src/brain_prefix.rs
+++ b/crates/accounts/ethkey/src/brain_prefix.rs
@@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use super::{Brain, Error, Generator, KeyPair};
+use super::Brain;
+use parity_crypto::publickey::{Error, KeyPair};
use parity_wordlist as wordlist;
/// Tries to find brain-seed keypair with address starting with given prefix.
@@ -38,16 +39,12 @@ impl BrainPrefix {
pub fn phrase(&self) -> &str {
&self.last_phrase
}
-}
-
-impl Generator for BrainPrefix {
- type Error = Error;
- fn generate(&mut self) -> Result {
+ pub fn generate(&mut self) -> Result {
for _ in 0..self.iterations {
let phrase = wordlist::random_phrase(self.no_of_words);
- let keypair = Brain::new(phrase.clone()).generate().unwrap();
- if keypair.address().starts_with(&self.prefix) {
+ let keypair = Brain::new(phrase.clone()).generate();
+ if keypair.address().as_ref().starts_with(&self.prefix) {
self.last_phrase = phrase;
return Ok(keypair);
}
@@ -60,7 +57,6 @@ impl Generator for BrainPrefix {
#[cfg(test)]
mod tests {
use BrainPrefix;
- use Generator;
#[test]
fn prefix_generator() {
@@ -68,6 +64,6 @@ mod tests {
let keypair = BrainPrefix::new(prefix.clone(), usize::max_value(), 12)
.generate()
.unwrap();
- assert!(keypair.address().starts_with(&prefix));
+ assert!(keypair.address().as_bytes().starts_with(&prefix));
}
}
diff --git a/accounts/ethkey/src/brain_recover.rs b/crates/accounts/ethkey/src/brain_recover.rs
similarity index 96%
rename from accounts/ethkey/src/brain_recover.rs
rename to crates/accounts/ethkey/src/brain_recover.rs
index 92cd7df1e3..611893f4ab 100644
--- a/accounts/ethkey/src/brain_recover.rs
+++ b/crates/accounts/ethkey/src/brain_recover.rs
@@ -17,9 +17,10 @@
use std::collections::HashSet;
use edit_distance::edit_distance;
+use parity_crypto::publickey::Address;
use parity_wordlist;
-use super::{Address, Brain, Generator};
+use super::Brain;
/// Tries to find a phrase for address, given the number
/// of expected words and a partial phrase.
@@ -32,9 +33,7 @@ pub fn brain_recover(
) -> Option {
let it = PhrasesIterator::from_known_phrase(known_phrase, expected_words);
for phrase in it {
- let keypair = Brain::new(phrase.clone())
- .generate()
- .expect("Brain wallets are infallible; qed");
+ let keypair = Brain::new(phrase.clone()).generate();
trace!("Testing: {}, got: {:?}", phrase, keypair.address());
if &keypair.address() == address {
return Some(phrase);
diff --git a/accounts/ethkey/src/error.rs b/crates/accounts/ethkey/src/error.rs
similarity index 92%
rename from accounts/ethkey/src/error.rs
rename to crates/accounts/ethkey/src/error.rs
index 3e66a905d2..6d26c1fbe1 100644
--- a/accounts/ethkey/src/error.rs
+++ b/crates/accounts/ethkey/src/error.rs
@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
+use crypto::Error as CryptoError;
use std::{error, fmt};
#[derive(Debug)]
@@ -53,7 +54,7 @@ impl fmt::Display for Error {
impl error::Error for Error {
fn description(&self) -> &str {
- "Crypto error"
+ format!("{:?}", &self)
}
}
@@ -63,6 +64,12 @@ impl Into for Error {
}
}
+impl From for Error {
+ fn from(e: CryptoError) -> Error {
+ Error::Custom(e.to_string())
+ }
+}
+
impl From<::secp256k1::Error> for Error {
fn from(e: ::secp256k1::Error) -> Error {
match e {
diff --git a/util/registrar/src/lib.rs b/crates/accounts/ethkey/src/lib.rs
similarity index 65%
rename from util/registrar/src/lib.rs
rename to crates/accounts/ethkey/src/lib.rs
index 79b70d3c9f..19accc4e1a 100644
--- a/util/registrar/src/lib.rs
+++ b/crates/accounts/ethkey/src/lib.rs
@@ -14,14 +14,26 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-extern crate ethabi;
-extern crate futures;
-extern crate keccak_hash;
+// #![warn(missing_docs)]
+
+extern crate edit_distance;
+extern crate parity_crypto;
+extern crate parity_wordlist;
+extern crate serde;
#[macro_use]
-extern crate ethabi_derive;
+extern crate log;
#[macro_use]
-extern crate ethabi_contract;
+extern crate serde_derive;
+
+mod brain;
+mod brain_prefix;
+mod password;
+mod prefix;
+
+pub mod brain_recover;
-mod registrar;
-pub use registrar::{Asynchronous, Registrar, RegistrarClient, Synchronous};
+pub use self::{
+ brain::Brain, brain_prefix::BrainPrefix, parity_wordlist::Error as WordlistError,
+ password::Password, prefix::Prefix,
+};
diff --git a/accounts/ethkey/src/password.rs b/crates/accounts/ethkey/src/password.rs
similarity index 100%
rename from accounts/ethkey/src/password.rs
rename to crates/accounts/ethkey/src/password.rs
diff --git a/accounts/ethkey/src/prefix.rs b/crates/accounts/ethkey/src/prefix.rs
similarity index 75%
rename from accounts/ethkey/src/prefix.rs
rename to crates/accounts/ethkey/src/prefix.rs
index 61382e721f..e037c41fe2 100644
--- a/accounts/ethkey/src/prefix.rs
+++ b/crates/accounts/ethkey/src/prefix.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use super::{Error, Generator, KeyPair, Random};
+use parity_crypto::publickey::{Error, Generator, KeyPair, Random};
/// Tries to find keypair with address starting with given prefix.
pub struct Prefix {
@@ -24,20 +24,13 @@ pub struct Prefix {
impl Prefix {
pub fn new(prefix: Vec, iterations: usize) -> Self {
- Prefix {
- prefix: prefix,
- iterations: iterations,
- }
+ Prefix { prefix, iterations }
}
-}
-
-impl Generator for Prefix {
- type Error = Error;
- fn generate(&mut self) -> Result {
+ pub fn generate(&mut self) -> Result {
for _ in 0..self.iterations {
- let keypair = Random.generate()?;
- if keypair.address().starts_with(&self.prefix) {
+ let keypair = Random.generate();
+ if keypair.address().as_ref().starts_with(&self.prefix) {
return Ok(keypair);
}
}
@@ -48,7 +41,6 @@ impl Generator for Prefix {
#[cfg(test)]
mod tests {
- use Generator;
use Prefix;
#[test]
@@ -57,6 +49,6 @@ mod tests {
let keypair = Prefix::new(prefix.clone(), usize::max_value())
.generate()
.unwrap();
- assert!(keypair.address().starts_with(&prefix));
+ assert!(keypair.address().as_bytes().starts_with(&prefix));
}
}
diff --git a/accounts/ethstore/.editorconfig b/crates/accounts/ethstore/.editorconfig
similarity index 100%
rename from accounts/ethstore/.editorconfig
rename to crates/accounts/ethstore/.editorconfig
diff --git a/accounts/ethstore/.gitignore b/crates/accounts/ethstore/.gitignore
similarity index 100%
rename from accounts/ethstore/.gitignore
rename to crates/accounts/ethstore/.gitignore
diff --git a/accounts/ethstore/.travis.yml b/crates/accounts/ethstore/.travis.yml
similarity index 100%
rename from accounts/ethstore/.travis.yml
rename to crates/accounts/ethstore/.travis.yml
diff --git a/accounts/ethstore/Cargo.toml b/crates/accounts/ethstore/Cargo.toml
similarity index 80%
rename from accounts/ethstore/Cargo.toml
rename to crates/accounts/ethstore/Cargo.toml
index af497bcff3..3f2f22f1f4 100644
--- a/accounts/ethstore/Cargo.toml
+++ b/crates/accounts/ethstore/Cargo.toml
@@ -7,19 +7,17 @@ authors = ["Parity Technologies "]
[dependencies]
log = "0.4"
libc = "0.2"
-rand = "0.4"
+rand = "0.7.3"
ethkey = { path = "../ethkey" }
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
rustc-hex = "1.0"
-tiny-keccak = "1.4"
time = "0.1.34"
itertools = "0.5"
parking_lot = "0.7"
-parity-crypto = "0.3.0"
-ethereum-types = "0.4"
-dir = { path = "../../util/dir" }
+parity-crypto = { version = "0.6.2", features = [ "publickey"] }
+ethereum-types = "0.9.2"
smallvec = "0.6"
parity-wordlist = "1.3"
tempdir = "0.3"
diff --git a/accounts/ethstore/README.md b/crates/accounts/ethstore/README.md
similarity index 100%
rename from accounts/ethstore/README.md
rename to crates/accounts/ethstore/README.md
diff --git a/accounts/ethstore/src/account/cipher.rs b/crates/accounts/ethstore/src/account/cipher.rs
similarity index 100%
rename from accounts/ethstore/src/account/cipher.rs
rename to crates/accounts/ethstore/src/account/cipher.rs
diff --git a/accounts/ethstore/src/account/crypto.rs b/crates/accounts/ethstore/src/account/crypto.rs
similarity index 95%
rename from accounts/ethstore/src/account/crypto.rs
rename to crates/accounts/ethstore/src/account/crypto.rs
index 5b30dbbba0..ea5149c8ff 100644
--- a/accounts/ethstore/src/account/crypto.rs
+++ b/crates/accounts/ethstore/src/account/crypto.rs
@@ -15,8 +15,8 @@
// along with OpenEthereum. If not, see .
use account::{Aes128Ctr, Cipher, Kdf, Pbkdf2, Prf};
-use crypto::{self, Keccak256};
-use ethkey::{Password, Secret};
+use crypto::{self, publickey::Secret, Keccak256};
+use ethkey::Password;
use json;
use random::Random;
use smallvec::SmallVec;
@@ -79,7 +79,7 @@ impl Crypto {
password: &Password,
iterations: NonZeroU32,
) -> Result {
- Crypto::with_plain(&*secret, password, iterations)
+ Crypto::with_plain(secret.as_bytes(), password, iterations)
}
/// Encrypt custom plain data
@@ -94,7 +94,7 @@ impl Crypto {
// two parts of derived key
// DK = [ DK[0..15] DK[16..31] ] = [derived_left_bits, derived_right_bits]
let (derived_left_bits, derived_right_bits) =
- crypto::derive_key_iterations(password.as_bytes(), &salt, iterations);
+ crypto::derive_key_iterations(password.as_bytes(), &salt, iterations.get());
// preallocated (on-stack in case of `Secret`) buffer to hold cipher
// length = length(plain) as we are using CTR-approach
@@ -127,7 +127,7 @@ impl Crypto {
}
let secret = self.do_decrypt(password, 32)?;
- Ok(Secret::from_unsafe_slice(&secret)?)
+ Ok(Secret::import_key(&secret)?)
}
/// Try to decrypt and return result as is
@@ -139,7 +139,7 @@ impl Crypto {
fn do_decrypt(&self, password: &Password, expected_len: usize) -> Result, Error> {
let (derived_left_bits, derived_right_bits) = match self.kdf {
Kdf::Pbkdf2(ref params) => {
- crypto::derive_key_iterations(password.as_bytes(), ¶ms.salt, params.c)
+ crypto::derive_key_iterations(password.as_bytes(), ¶ms.salt, params.c.get())
}
Kdf::Scrypt(ref params) => crypto::scrypt::derive_key(
password.as_bytes(),
@@ -179,7 +179,7 @@ impl Crypto {
#[cfg(test)]
mod tests {
use super::{Crypto, Error, NonZeroU32};
- use ethkey::{Generator, Random};
+ use crypto::publickey::{Generator, Random};
lazy_static! {
static ref ITERATIONS: NonZeroU32 = NonZeroU32::new(10240).expect("10240 > 0; qed");
@@ -187,7 +187,7 @@ mod tests {
#[test]
fn crypto_with_secret_create() {
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let passwd = "this is sparta".into();
let crypto = Crypto::with_secret(keypair.secret(), &passwd, *ITERATIONS).unwrap();
let secret = crypto.secret(&passwd).unwrap();
@@ -196,7 +196,7 @@ mod tests {
#[test]
fn crypto_with_secret_invalid_password() {
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let crypto =
Crypto::with_secret(keypair.secret(), &"this is sparta".into(), *ITERATIONS).unwrap();
assert_matches!(
diff --git a/accounts/ethstore/src/account/kdf.rs b/crates/accounts/ethstore/src/account/kdf.rs
similarity index 100%
rename from accounts/ethstore/src/account/kdf.rs
rename to crates/accounts/ethstore/src/account/kdf.rs
diff --git a/accounts/ethstore/src/account/mod.rs b/crates/accounts/ethstore/src/account/mod.rs
similarity index 100%
rename from accounts/ethstore/src/account/mod.rs
rename to crates/accounts/ethstore/src/account/mod.rs
diff --git a/accounts/ethstore/src/account/safe_account.rs b/crates/accounts/ethstore/src/account/safe_account.rs
similarity index 95%
rename from accounts/ethstore/src/account/safe_account.rs
rename to crates/accounts/ethstore/src/account/safe_account.rs
index a6f3d007d7..89b4d17a51 100644
--- a/accounts/ethstore/src/account/safe_account.rs
+++ b/crates/accounts/ethstore/src/account/safe_account.rs
@@ -16,10 +16,11 @@
use super::crypto::Crypto;
use account::Version;
-use crypto;
-use ethkey::{
- self, crypto::ecdh::agree, sign, Address, KeyPair, Message, Password, Public, Secret, Signature,
+use crypto::{
+ self,
+ publickey::{ecdh::agree, sign, Address, KeyPair, Message, Public, Secret, Signature},
};
+use ethkey::Password;
use json;
use std::num::NonZeroU32;
use Error;
@@ -193,7 +194,7 @@ impl SafeAccount {
message: &[u8],
) -> Result, Error> {
let secret = self.crypto.secret(password)?;
- ethkey::crypto::ecies::decrypt(&secret, shared_mac, message).map_err(From::from)
+ crypto::publickey::ecies::decrypt(&secret, shared_mac, message).map_err(From::from)
}
/// Agree on shared key.
@@ -237,7 +238,7 @@ impl SafeAccount {
#[cfg(test)]
mod tests {
use super::{NonZeroU32, SafeAccount};
- use ethkey::{verify_public, Generator, Message, Random};
+ use crypto::publickey::{verify_public, Generator, Random};
lazy_static! {
static ref ITERATIONS: NonZeroU32 = NonZeroU32::new(10240).expect("10240 > 0; qed");
@@ -245,9 +246,9 @@ mod tests {
#[test]
fn sign_and_verify_public() {
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let password = "hello world".into();
- let message = Message::default();
+ let message = [1u8; 32].into();
let account = SafeAccount::create(
&keypair,
[0u8; 16],
@@ -262,10 +263,10 @@ mod tests {
#[test]
fn change_password() {
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let first_password = "hello world".into();
let sec_password = "this is sparta".into();
- let message = Message::default();
+ let message = [1u8; 32].into();
let account = SafeAccount::create(
&keypair,
[0u8; 16],
diff --git a/accounts/ethstore/src/account/version.rs b/crates/accounts/ethstore/src/account/version.rs
similarity index 100%
rename from accounts/ethstore/src/account/version.rs
rename to crates/accounts/ethstore/src/account/version.rs
diff --git a/accounts/ethstore/src/accounts_dir/disk.rs b/crates/accounts/ethstore/src/accounts_dir/disk.rs
similarity index 99%
rename from accounts/ethstore/src/accounts_dir/disk.rs
rename to crates/accounts/ethstore/src/accounts_dir/disk.rs
index c981f6949c..13a8b7c288 100644
--- a/accounts/ethstore/src/accounts_dir/disk.rs
+++ b/crates/accounts/ethstore/src/accounts_dir/disk.rs
@@ -420,7 +420,7 @@ mod test {
use self::tempdir::TempDir;
use super::{KeyDirectory, RootDiskDirectory, VaultKey};
use account::SafeAccount;
- use ethkey::{Generator, Random};
+ use crypto::publickey::{Generator, Random};
use std::{env, fs, num::NonZeroU32};
lazy_static! {
@@ -432,7 +432,7 @@ mod test {
// given
let mut dir = env::temp_dir();
dir.push("ethstore_should_create_new_account");
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let password = "hello world".into();
let directory = RootDiskDirectory::create(dir.clone()).unwrap();
@@ -463,7 +463,7 @@ mod test {
// given
let mut dir = env::temp_dir();
dir.push("ethstore_should_handle_duplicate_filenames");
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let password = "hello world".into();
let directory = RootDiskDirectory::create(dir.clone()).unwrap();
@@ -582,7 +582,7 @@ mod test {
.expect("Files hash should be calculated ok");
assert_eq!(hash, 15130871412783076140);
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let password = "test pass".into();
let account = SafeAccount::create(
&keypair,
diff --git a/accounts/ethstore/src/accounts_dir/memory.rs b/crates/accounts/ethstore/src/accounts_dir/memory.rs
similarity index 97%
rename from accounts/ethstore/src/accounts_dir/memory.rs
rename to crates/accounts/ethstore/src/accounts_dir/memory.rs
index 80ecb66764..73f48ef7c3 100644
--- a/accounts/ethstore/src/accounts_dir/memory.rs
+++ b/crates/accounts/ethstore/src/accounts_dir/memory.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use ethkey::Address;
+use crypto::publickey::Address;
use itertools;
use parking_lot::RwLock;
use std::collections::HashMap;
@@ -70,7 +70,7 @@ impl KeyDirectory for MemoryDirectory {
let mut val = 0u64;
let accounts = self.accounts.read();
for acc in accounts.keys() {
- val = val ^ acc.low_u64()
+ val = val ^ acc.to_low_u64_be()
}
Ok(val)
}
diff --git a/accounts/ethstore/src/accounts_dir/mod.rs b/crates/accounts/ethstore/src/accounts_dir/mod.rs
similarity index 100%
rename from accounts/ethstore/src/accounts_dir/mod.rs
rename to crates/accounts/ethstore/src/accounts_dir/mod.rs
diff --git a/accounts/ethstore/src/accounts_dir/vault.rs b/crates/accounts/ethstore/src/accounts_dir/vault.rs
similarity index 100%
rename from accounts/ethstore/src/accounts_dir/vault.rs
rename to crates/accounts/ethstore/src/accounts_dir/vault.rs
diff --git a/accounts/ethstore/src/error.rs b/crates/accounts/ethstore/src/error.rs
similarity index 82%
rename from accounts/ethstore/src/error.rs
rename to crates/accounts/ethstore/src/error.rs
index 72372db87d..646f47339a 100644
--- a/accounts/ethstore/src/error.rs
+++ b/crates/accounts/ethstore/src/error.rs
@@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use crypto::{self, Error as EthCryptoError};
-use ethkey::{self, DerivationError, Error as EthKeyError};
+use crypto::publickey::DerivationError;
use std::{fmt, io::Error as IoError};
/// Account-related errors.
@@ -45,12 +44,10 @@ pub enum Error {
VaultNotFound,
/// Account creation failed.
CreationFailed,
- /// `EthKey` error
- EthKey(EthKeyError),
- /// `ethkey::crypto::Error`
- EthKeyCrypto(ethkey::crypto::Error),
+ /// `crypto::publickey::Error`
+ EthCrypto(crypto::Error),
/// `EthCrypto` error
- EthCrypto(EthCryptoError),
+ EthCryptoPublicKey(crypto::publickey::Error),
/// Derivation error
Derivation(DerivationError),
/// Custom error
@@ -72,9 +69,8 @@ impl fmt::Display for Error {
Error::InvalidVaultName => "Invalid vault name".into(),
Error::VaultNotFound => "Vault not found".into(),
Error::CreationFailed => "Account creation failed".into(),
- Error::EthKey(ref err) => err.to_string(),
- Error::EthKeyCrypto(ref err) => err.to_string(),
Error::EthCrypto(ref err) => err.to_string(),
+ Error::EthCryptoPublicKey(ref err) => err.to_string(),
Error::Derivation(ref err) => format!("Derivation error: {:?}", err),
Error::Custom(ref s) => s.clone(),
};
@@ -89,20 +85,14 @@ impl From for Error {
}
}
-impl From for Error {
- fn from(err: EthKeyError) -> Self {
- Error::EthKey(err)
+impl From for Error {
+ fn from(err: crypto::publickey::Error) -> Self {
+ Error::EthCryptoPublicKey(err)
}
}
-impl From for Error {
- fn from(err: ethkey::crypto::Error) -> Self {
- Error::EthKeyCrypto(err)
- }
-}
-
-impl From for Error {
- fn from(err: EthCryptoError) -> Self {
+impl From for Error {
+ fn from(err: crypto::Error) -> Self {
Error::EthCrypto(err)
}
}
diff --git a/accounts/ethstore/src/ethkey.rs b/crates/accounts/ethstore/src/ethkey.rs
similarity index 97%
rename from accounts/ethstore/src/ethkey.rs
rename to crates/accounts/ethstore/src/ethkey.rs
index dc08af4191..aed0695bb3 100644
--- a/accounts/ethstore/src/ethkey.rs
+++ b/crates/accounts/ethstore/src/ethkey.rs
@@ -16,6 +16,7 @@
//! ethkey reexport to make documentation look pretty.
pub use _ethkey::*;
+pub use crypto::publickey::Address;
use json;
impl Into for Address {
diff --git a/accounts/ethstore/src/ethstore.rs b/crates/accounts/ethstore/src/ethstore.rs
similarity index 98%
rename from accounts/ethstore/src/ethstore.rs
rename to crates/accounts/ethstore/src/ethstore.rs
index 3de0d13802..bf674e4581 100644
--- a/accounts/ethstore/src/ethstore.rs
+++ b/crates/accounts/ethstore/src/ethstore.rs
@@ -24,9 +24,10 @@ use std::{
use account::SafeAccount;
use accounts_dir::{KeyDirectory, SetKeyError, VaultKey, VaultKeyDirectory};
-use ethkey::{
- self, Address, ExtendedKeyPair, KeyPair, Message, Password, Public, Secret, Signature,
+use crypto::publickey::{
+ self, Address, ExtendedKeyPair, KeyPair, Message, Public, Secret, Signature,
};
+use ethkey::Password;
use json::{self, OpaqueKeyFile, Uuid};
use presale::PresaleWallet;
use random::Random;
@@ -554,17 +555,17 @@ impl EthMultiStore {
Derivation::Hierarchical(path) => {
for path_item in path {
extended = extended.derive(if path_item.soft {
- ethkey::Derivation::Soft(path_item.index)
+ publickey::Derivation::Soft(path_item.index)
} else {
- ethkey::Derivation::Hard(path_item.index)
+ publickey::Derivation::Hard(path_item.index)
})?;
}
}
Derivation::SoftHash(h256) => {
- extended = extended.derive(ethkey::Derivation::Soft(h256))?;
+ extended = extended.derive(publickey::Derivation::Soft(h256))?;
}
Derivation::HardHash(h256) => {
- extended = extended.derive(ethkey::Derivation::Hard(h256))?;
+ extended = extended.derive(publickey::Derivation::Hard(h256))?;
}
}
Ok(extended)
@@ -615,7 +616,7 @@ impl SimpleSecretStore for EthMultiStore {
let accounts = self.get_matching(&account_ref, password)?;
for account in accounts {
let extended = self.generate(account.crypto.secret(password)?, derivation)?;
- return Ok(ethkey::public_to_address(extended.public().public()));
+ return Ok(publickey::public_to_address(extended.public().public()));
}
Err(Error::InvalidPassword)
}
@@ -631,7 +632,7 @@ impl SimpleSecretStore for EthMultiStore {
for account in accounts {
let extended = self.generate(account.crypto.secret(password)?, derivation)?;
let secret = extended.secret().as_raw();
- return Ok(ethkey::sign(&secret, message)?);
+ return Ok(publickey::sign(&secret, message)?);
}
Err(Error::InvalidPassword)
}
@@ -898,14 +899,14 @@ mod tests {
use self::tempdir::TempDir;
use super::{EthMultiStore, EthStore};
use accounts_dir::{KeyDirectory, MemoryDirectory, RootDiskDirectory};
+ use crypto::publickey::{Generator, KeyPair, Random};
use ethereum_types::H256;
- use ethkey::{Generator, KeyPair, Random};
use secret_store::{
Derivation, SecretStore, SecretVaultRef, SimpleSecretStore, StoreAccountRef,
};
fn keypair() -> KeyPair {
- Random.generate().unwrap()
+ Random.generate()
}
fn store() -> EthStore {
@@ -1051,6 +1052,7 @@ mod tests {
let passwd2 = "xzy".into();
let multi_store = multi_store();
let keypair = keypair();
+ let message = [1u8; 32].into();
let address = store
.insert_account(SecretVaultRef::Root, keypair.secret().clone(), &passwd1)
.unwrap();
@@ -1073,9 +1075,7 @@ mod tests {
"First password should work for store."
);
assert!(
- multi_store
- .sign(&address, &passwd2, &Default::default())
- .is_ok(),
+ multi_store.sign(&address, &passwd2, &message).is_ok(),
"Second password should work for second store."
);
assert_eq!(multi_store.accounts().unwrap().len(), 1);
@@ -1462,7 +1462,7 @@ mod tests {
SecretVaultRef::Root,
&address,
&"test".into(),
- Derivation::HardHash(H256::from(0)),
+ Derivation::HardHash(H256::zero()),
)
.unwrap();
@@ -1470,11 +1470,10 @@ mod tests {
let accounts = store.accounts().unwrap();
assert_eq!(accounts.len(), 2);
+ let message = [1u8; 32].into();
// and we can sign with the derived contract
assert!(
- store
- .sign(&derived, &"test".into(), &Default::default())
- .is_ok(),
+ store.sign(&derived, &"test".into(), &message).is_ok(),
"Second password should work for second store."
);
}
diff --git a/accounts/ethstore/src/import.rs b/crates/accounts/ethstore/src/import.rs
similarity index 98%
rename from accounts/ethstore/src/import.rs
rename to crates/accounts/ethstore/src/import.rs
index 949d37db7b..20cbcd787b 100644
--- a/accounts/ethstore/src/import.rs
+++ b/crates/accounts/ethstore/src/import.rs
@@ -17,7 +17,7 @@
use std::{collections::HashSet, fs, path::Path};
use accounts_dir::{DiskKeyFileManager, KeyDirectory, KeyFileManager};
-use ethkey::Address;
+use crypto::publickey::Address;
use Error;
/// Import an account from a file.
diff --git a/accounts/ethstore/src/json/bytes.rs b/crates/accounts/ethstore/src/json/bytes.rs
similarity index 100%
rename from accounts/ethstore/src/json/bytes.rs
rename to crates/accounts/ethstore/src/json/bytes.rs
diff --git a/accounts/ethstore/src/json/cipher.rs b/crates/accounts/ethstore/src/json/cipher.rs
similarity index 100%
rename from accounts/ethstore/src/json/cipher.rs
rename to crates/accounts/ethstore/src/json/cipher.rs
diff --git a/accounts/ethstore/src/json/crypto.rs b/crates/accounts/ethstore/src/json/crypto.rs
similarity index 95%
rename from accounts/ethstore/src/json/crypto.rs
rename to crates/accounts/ethstore/src/json/crypto.rs
index 2afe5bbd15..74d17daa5b 100644
--- a/accounts/ethstore/src/json/crypto.rs
+++ b/crates/accounts/ethstore/src/json/crypto.rs
@@ -159,10 +159,7 @@ impl<'a> Visitor<'a> for CryptoVisitor {
(Some(_), None) => return Err(V::Error::missing_field("cipherparams")),
};
- let ciphertext = match ciphertext {
- Some(ciphertext) => ciphertext,
- None => return Err(V::Error::missing_field("ciphertext")),
- };
+ let ciphertext = ciphertext.ok_or_else(|| V::Error::missing_field("ciphertext"))?;
let kdf = match (kdf, kdfparams) {
(Some(KdfSer::Pbkdf2), Some(KdfSerParams::Pbkdf2(params))) => Kdf::Pbkdf2(params),
@@ -172,10 +169,7 @@ impl<'a> Visitor<'a> for CryptoVisitor {
(Some(_), None) => return Err(V::Error::missing_field("kdfparams")),
};
- let mac = match mac {
- Some(mac) => mac,
- None => return Err(V::Error::missing_field("mac")),
- };
+ let mac = mac.ok_or_else(|| V::Error::missing_field("mac"))?;
let result = Crypto {
cipher: cipher,
diff --git a/accounts/ethstore/src/json/error.rs b/crates/accounts/ethstore/src/json/error.rs
similarity index 100%
rename from accounts/ethstore/src/json/error.rs
rename to crates/accounts/ethstore/src/json/error.rs
diff --git a/accounts/ethstore/src/json/hash.rs b/crates/accounts/ethstore/src/json/hash.rs
similarity index 100%
rename from accounts/ethstore/src/json/hash.rs
rename to crates/accounts/ethstore/src/json/hash.rs
diff --git a/accounts/ethstore/src/json/id.rs b/crates/accounts/ethstore/src/json/id.rs
similarity index 100%
rename from accounts/ethstore/src/json/id.rs
rename to crates/accounts/ethstore/src/json/id.rs
diff --git a/accounts/ethstore/src/json/kdf.rs b/crates/accounts/ethstore/src/json/kdf.rs
similarity index 100%
rename from accounts/ethstore/src/json/kdf.rs
rename to crates/accounts/ethstore/src/json/kdf.rs
diff --git a/accounts/ethstore/src/json/key_file.rs b/crates/accounts/ethstore/src/json/key_file.rs
similarity index 95%
rename from accounts/ethstore/src/json/key_file.rs
rename to crates/accounts/ethstore/src/json/key_file.rs
index 480493a9cd..9c2aec51e0 100644
--- a/accounts/ethstore/src/json/key_file.rs
+++ b/crates/accounts/ethstore/src/json/key_file.rs
@@ -169,20 +169,11 @@ impl<'a> Visitor<'a> for KeyFileVisitor {
}
}
- let id = match id {
- Some(id) => id,
- None => return Err(V::Error::missing_field("id")),
- };
+ let id = id.ok_or_else(|| V::Error::missing_field("id"))?;
- let version = match version {
- Some(version) => version,
- None => return Err(V::Error::missing_field("version")),
- };
+ let version = version.ok_or_else(|| V::Error::missing_field("version"))?;
- let crypto = match crypto {
- Some(crypto) => crypto,
- None => return Err(V::Error::missing_field("crypto")),
- };
+ let crypto = crypto.ok_or_else(|| V::Error::missing_field("crypto"))?;
let result = KeyFile {
id: id,
diff --git a/accounts/ethstore/src/json/mod.rs b/crates/accounts/ethstore/src/json/mod.rs
similarity index 100%
rename from accounts/ethstore/src/json/mod.rs
rename to crates/accounts/ethstore/src/json/mod.rs
diff --git a/accounts/ethstore/src/json/presale.rs b/crates/accounts/ethstore/src/json/presale.rs
similarity index 100%
rename from accounts/ethstore/src/json/presale.rs
rename to crates/accounts/ethstore/src/json/presale.rs
diff --git a/accounts/ethstore/src/json/vault_file.rs b/crates/accounts/ethstore/src/json/vault_file.rs
similarity index 100%
rename from accounts/ethstore/src/json/vault_file.rs
rename to crates/accounts/ethstore/src/json/vault_file.rs
diff --git a/accounts/ethstore/src/json/vault_key_file.rs b/crates/accounts/ethstore/src/json/vault_key_file.rs
similarity index 100%
rename from accounts/ethstore/src/json/vault_key_file.rs
rename to crates/accounts/ethstore/src/json/vault_key_file.rs
diff --git a/accounts/ethstore/src/json/version.rs b/crates/accounts/ethstore/src/json/version.rs
similarity index 100%
rename from accounts/ethstore/src/json/version.rs
rename to crates/accounts/ethstore/src/json/version.rs
diff --git a/accounts/ethstore/src/lib.rs b/crates/accounts/ethstore/src/lib.rs
similarity index 95%
rename from accounts/ethstore/src/lib.rs
rename to crates/accounts/ethstore/src/lib.rs
index 0197229ca2..5abfdf2ae3 100644
--- a/accounts/ethstore/src/lib.rs
+++ b/crates/accounts/ethstore/src/lib.rs
@@ -18,7 +18,6 @@
#![warn(missing_docs)]
-extern crate dir;
extern crate itertools;
extern crate libc;
extern crate parking_lot;
@@ -29,7 +28,6 @@ extern crate serde_json;
extern crate smallvec;
extern crate tempdir;
extern crate time;
-extern crate tiny_keccak;
extern crate ethereum_types;
extern crate ethkey as _ethkey;
@@ -76,4 +74,4 @@ pub use self::{
};
/// An opaque wrapper for secret.
-pub struct OpaqueSecret(::ethkey::Secret);
+pub struct OpaqueSecret(crypto::publickey::Secret);
diff --git a/accounts/ethstore/src/presale.rs b/crates/accounts/ethstore/src/presale.rs
similarity index 92%
rename from accounts/ethstore/src/presale.rs
rename to crates/accounts/ethstore/src/presale.rs
index 0bf5905a90..45cc0de5d6 100644
--- a/accounts/ethstore/src/presale.rs
+++ b/crates/accounts/ethstore/src/presale.rs
@@ -14,8 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use crypto::{self, pbkdf2, Keccak256};
-use ethkey::{Address, KeyPair, Password, Secret};
+use crypto::{
+ self, pbkdf2,
+ publickey::{Address, KeyPair, Secret},
+ Keccak256,
+};
+use ethkey::Password;
use json;
use std::{fs, num::NonZeroU32, path::Path};
use Error;
@@ -61,7 +65,7 @@ impl PresaleWallet {
let salt = pbkdf2::Salt(password.as_bytes());
let sec = pbkdf2::Secret(password.as_bytes());
let iter = NonZeroU32::new(2000).expect("2000 > 0; qed");
- pbkdf2::sha256(iter, salt, sec, &mut derived_key);
+ pbkdf2::sha256(iter.get(), salt, sec, &mut derived_key);
let mut key = vec![0; self.ciphertext.len()];
let len =
@@ -69,7 +73,7 @@ impl PresaleWallet {
.map_err(|_| Error::InvalidPassword)?;
let unpadded = &key[..len];
- let secret = Secret::from_unsafe_slice(&unpadded.keccak256())?;
+ let secret = Secret::import_key(&unpadded.keccak256())?;
if let Ok(kp) = KeyPair::from_secret(secret) {
if kp.address() == self.address {
return Ok(kp);
diff --git a/accounts/ethstore/src/random.rs b/crates/accounts/ethstore/src/random.rs
similarity index 82%
rename from accounts/ethstore/src/random.rs
rename to crates/accounts/ethstore/src/random.rs
index c50abf85fd..405873c94e 100644
--- a/accounts/ethstore/src/random.rs
+++ b/crates/accounts/ethstore/src/random.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use rand::{OsRng, Rng};
+use rand::{distributions::Alphanumeric, rngs::OsRng, Rng, RngCore};
pub trait Random {
fn random() -> Self
@@ -25,7 +25,7 @@ pub trait Random {
impl Random for [u8; 16] {
fn random() -> Self {
let mut result = [0u8; 16];
- let mut rng = OsRng::new().unwrap();
+ let mut rng = OsRng;
rng.fill_bytes(&mut result);
result
}
@@ -34,7 +34,7 @@ impl Random for [u8; 16] {
impl Random for [u8; 32] {
fn random() -> Self {
let mut result = [0u8; 32];
- let mut rng = OsRng::new().unwrap();
+ let mut rng = OsRng;
rng.fill_bytes(&mut result);
result
}
@@ -42,6 +42,6 @@ impl Random for [u8; 32] {
/// Generate a random string of given length.
pub fn random_string(length: usize) -> String {
- let mut rng = OsRng::new().expect("Not able to operate without random source.");
- rng.gen_ascii_chars().take(length).collect()
+ let rng = OsRng;
+ rng.sample_iter(&Alphanumeric).take(length).collect()
}
diff --git a/accounts/ethstore/src/secret_store.rs b/crates/accounts/ethstore/src/secret_store.rs
similarity index 98%
rename from accounts/ethstore/src/secret_store.rs
rename to crates/accounts/ethstore/src/secret_store.rs
index b9c098c46f..36c6f9ed57 100644
--- a/accounts/ethstore/src/secret_store.rs
+++ b/crates/accounts/ethstore/src/secret_store.rs
@@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
+use crypto::publickey::{Address, Message, Public, Secret, Signature};
use ethereum_types::H256;
-use ethkey::{Address, Message, Password, Public, Secret, Signature};
+use ethkey::Password;
use json::{OpaqueKeyFile, Uuid};
use std::{
cmp::Ordering,
@@ -174,7 +175,7 @@ pub trait SecretStore: SimpleSecretStore {
secret: &OpaqueSecret,
message: &Message,
) -> Result {
- Ok(::ethkey::sign(&secret.0, message)?)
+ Ok(crypto::publickey::sign(&secret.0, message)?)
}
/// Imports presale wallet
diff --git a/accounts/ethstore/tests/api.rs b/crates/accounts/ethstore/tests/api.rs
similarity index 74%
rename from accounts/ethstore/tests/api.rs
rename to crates/accounts/ethstore/tests/api.rs
index c37100c223..1eb2fa7f0e 100644
--- a/accounts/ethstore/tests/api.rs
+++ b/crates/accounts/ethstore/tests/api.rs
@@ -14,15 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
+extern crate ethereum_types;
extern crate ethstore;
+extern crate parity_crypto as crypto;
extern crate rand;
mod util;
+use std::str::FromStr;
+
+use crypto::publickey::{verify_address, Generator, KeyPair, Random, Secret};
+use ethereum_types::H160;
use ethstore::{
- accounts_dir::RootDiskDirectory,
- ethkey::{verify_address, Generator, KeyPair, Random, Secret},
- EthStore, SecretVaultRef, SimpleSecretStore, StoreAccountRef,
+ accounts_dir::RootDiskDirectory, EthStore, SecretVaultRef, SimpleSecretStore, StoreAccountRef,
};
use util::TransientDir;
@@ -40,7 +44,7 @@ fn secret_store_open_not_existing() {
}
fn random_secret() -> Secret {
- Random.generate().unwrap().secret().clone()
+ Random.generate().secret().clone()
}
#[test]
@@ -66,13 +70,10 @@ fn secret_store_sign() {
.insert_account(SecretVaultRef::Root, random_secret(), &"".into())
.is_ok());
let accounts = store.accounts().unwrap();
+ let message = [1u8; 32].into();
assert_eq!(accounts.len(), 1);
- assert!(store
- .sign(&accounts[0], &"".into(), &Default::default())
- .is_ok());
- assert!(store
- .sign(&accounts[0], &"1".into(), &Default::default())
- .is_err());
+ assert!(store.sign(&accounts[0], &"".into(), &message).is_ok());
+ assert!(store.sign(&accounts[0], &"1".into(), &message).is_err());
}
#[test]
@@ -83,19 +84,14 @@ fn secret_store_change_password() {
.insert_account(SecretVaultRef::Root, random_secret(), &"".into())
.is_ok());
let accounts = store.accounts().unwrap();
+ let message = [1u8; 32].into();
assert_eq!(accounts.len(), 1);
- assert!(store
- .sign(&accounts[0], &"".into(), &Default::default())
- .is_ok());
+ assert!(store.sign(&accounts[0], &"".into(), &message).is_ok());
assert!(store
.change_password(&accounts[0], &"".into(), &"1".into())
.is_ok());
- assert!(store
- .sign(&accounts[0], &"".into(), &Default::default())
- .is_err());
- assert!(store
- .sign(&accounts[0], &"1".into(), &Default::default())
- .is_ok());
+ assert!(store.sign(&accounts[0], &"".into(), &message).is_err());
+ assert!(store.sign(&accounts[0], &"1".into(), &message).is_ok());
}
#[test]
@@ -140,9 +136,15 @@ fn secret_store_laod_geth_files() {
assert_eq!(
store.accounts().unwrap(),
vec![
- StoreAccountRef::root("3f49624084b67849c7b4e805c5988c21a430f9d9".into()),
- StoreAccountRef::root("5ba4dcf897e97c2bdf8315b9ef26c13c085988cf".into()),
- StoreAccountRef::root("63121b431a52f8043c16fcf0d1df9cb7b5f66649".into()),
+ StoreAccountRef::root(
+ H160::from_str("3f49624084b67849c7b4e805c5988c21a430f9d9").unwrap()
+ ),
+ StoreAccountRef::root(
+ H160::from_str("5ba4dcf897e97c2bdf8315b9ef26c13c085988cf").unwrap()
+ ),
+ StoreAccountRef::root(
+ H160::from_str("63121b431a52f8043c16fcf0d1df9cb7b5f66649").unwrap()
+ ),
]
);
}
@@ -154,8 +156,12 @@ fn secret_store_load_pat_files() {
assert_eq!(
store.accounts().unwrap(),
vec![
- StoreAccountRef::root("3f49624084b67849c7b4e805c5988c21a430f9d9".into()),
- StoreAccountRef::root("5ba4dcf897e97c2bdf8315b9ef26c13c085988cf".into()),
+ StoreAccountRef::root(
+ H160::from_str("3f49624084b67849c7b4e805c5988c21a430f9d9").unwrap()
+ ),
+ StoreAccountRef::root(
+ H160::from_str("5ba4dcf897e97c2bdf8315b9ef26c13c085988cf").unwrap()
+ ),
]
);
}
@@ -182,12 +188,16 @@ fn test_decrypting_files_with_short_ciphertext() {
assert_eq!(
accounts,
vec![
- StoreAccountRef::root("31e9d1e6d844bd3a536800ef8d8be6a9975db509".into()),
- StoreAccountRef::root("d1e64e5480bfaf733ba7d48712decb8227797a4e".into()),
+ StoreAccountRef::root(
+ H160::from_str("31e9d1e6d844bd3a536800ef8d8be6a9975db509").unwrap()
+ ),
+ StoreAccountRef::root(
+ H160::from_str("d1e64e5480bfaf733ba7d48712decb8227797a4e").unwrap()
+ ),
]
);
- let message = Default::default();
+ let message = [1u8; 32].into();
let s1 = store.sign(&accounts[0], &"foo".into(), &message).unwrap();
let s2 = store.sign(&accounts[1], &"foo".into(), &message).unwrap();
diff --git a/accounts/ethstore/tests/res/ciphertext/30.json b/crates/accounts/ethstore/tests/res/ciphertext/30.json
similarity index 100%
rename from accounts/ethstore/tests/res/ciphertext/30.json
rename to crates/accounts/ethstore/tests/res/ciphertext/30.json
diff --git a/accounts/ethstore/tests/res/ciphertext/31.json b/crates/accounts/ethstore/tests/res/ciphertext/31.json
similarity index 100%
rename from accounts/ethstore/tests/res/ciphertext/31.json
rename to crates/accounts/ethstore/tests/res/ciphertext/31.json
diff --git a/accounts/ethstore/tests/res/geth_keystore/UTC--2016-02-17T09-20-45.721400158Z--3f49624084b67849c7b4e805c5988c21a430f9d9 b/crates/accounts/ethstore/tests/res/geth_keystore/UTC--2016-02-17T09-20-45.721400158Z--3f49624084b67849c7b4e805c5988c21a430f9d9
similarity index 100%
rename from accounts/ethstore/tests/res/geth_keystore/UTC--2016-02-17T09-20-45.721400158Z--3f49624084b67849c7b4e805c5988c21a430f9d9
rename to crates/accounts/ethstore/tests/res/geth_keystore/UTC--2016-02-17T09-20-45.721400158Z--3f49624084b67849c7b4e805c5988c21a430f9d9
diff --git a/accounts/ethstore/tests/res/geth_keystore/UTC--2016-02-20T09-33-03.984382741Z--5ba4dcf897e97c2bdf8315b9ef26c13c085988cf b/crates/accounts/ethstore/tests/res/geth_keystore/UTC--2016-02-20T09-33-03.984382741Z--5ba4dcf897e97c2bdf8315b9ef26c13c085988cf
similarity index 100%
rename from accounts/ethstore/tests/res/geth_keystore/UTC--2016-02-20T09-33-03.984382741Z--5ba4dcf897e97c2bdf8315b9ef26c13c085988cf
rename to crates/accounts/ethstore/tests/res/geth_keystore/UTC--2016-02-20T09-33-03.984382741Z--5ba4dcf897e97c2bdf8315b9ef26c13c085988cf
diff --git a/accounts/ethstore/tests/res/geth_keystore/UTC--2016-04-03T08-58-49.834202900Z--63121b431a52f8043c16fcf0d1df9cb7b5f66649 b/crates/accounts/ethstore/tests/res/geth_keystore/UTC--2016-04-03T08-58-49.834202900Z--63121b431a52f8043c16fcf0d1df9cb7b5f66649
similarity index 100%
rename from accounts/ethstore/tests/res/geth_keystore/UTC--2016-04-03T08-58-49.834202900Z--63121b431a52f8043c16fcf0d1df9cb7b5f66649
rename to crates/accounts/ethstore/tests/res/geth_keystore/UTC--2016-04-03T08-58-49.834202900Z--63121b431a52f8043c16fcf0d1df9cb7b5f66649
diff --git a/accounts/ethstore/tests/res/pat/p1.json b/crates/accounts/ethstore/tests/res/pat/p1.json
similarity index 100%
rename from accounts/ethstore/tests/res/pat/p1.json
rename to crates/accounts/ethstore/tests/res/pat/p1.json
diff --git a/accounts/ethstore/tests/res/pat/p2.json b/crates/accounts/ethstore/tests/res/pat/p2.json
similarity index 100%
rename from accounts/ethstore/tests/res/pat/p2.json
rename to crates/accounts/ethstore/tests/res/pat/p2.json
diff --git a/accounts/ethstore/tests/util/mod.rs b/crates/accounts/ethstore/tests/util/mod.rs
similarity index 100%
rename from accounts/ethstore/tests/util/mod.rs
rename to crates/accounts/ethstore/tests/util/mod.rs
diff --git a/accounts/ethstore/tests/util/transient_dir.rs b/crates/accounts/ethstore/tests/util/transient_dir.rs
similarity index 97%
rename from accounts/ethstore/tests/util/transient_dir.rs
rename to crates/accounts/ethstore/tests/util/transient_dir.rs
index 88fb755c1b..5f22e7efdf 100644
--- a/accounts/ethstore/tests/util/transient_dir.rs
+++ b/crates/accounts/ethstore/tests/util/transient_dir.rs
@@ -18,11 +18,11 @@ use ethstore::{
accounts_dir::{KeyDirectory, RootDiskDirectory},
Error, SafeAccount,
};
-use rand::{OsRng, Rng};
+use rand::{rngs::OsRng, RngCore};
use std::{env, fs, path::PathBuf};
pub fn random_dir() -> PathBuf {
- let mut rng = OsRng::new().unwrap();
+ let mut rng = OsRng;
let mut dir = env::temp_dir();
dir.push(format!("{:x}-{:x}", rng.next_u64(), rng.next_u64()));
dir
diff --git a/accounts/src/account_data.rs b/crates/accounts/src/account_data.rs
similarity index 97%
rename from accounts/src/account_data.rs
rename to crates/accounts/src/account_data.rs
index 5bb41daf26..2c9c3bd32f 100644
--- a/accounts/src/account_data.rs
+++ b/crates/accounts/src/account_data.rs
@@ -18,7 +18,8 @@
use std::{collections::HashMap, time::Instant};
-use ethkey::{Address, Password};
+use crypto::publickey::Address;
+use ethkey::Password;
use serde_derive::{Deserialize, Serialize};
use serde_json;
diff --git a/accounts/src/error.rs b/crates/accounts/src/error.rs
similarity index 100%
rename from accounts/src/error.rs
rename to crates/accounts/src/error.rs
diff --git a/accounts/src/lib.rs b/crates/accounts/src/lib.rs
similarity index 93%
rename from accounts/src/lib.rs
rename to crates/accounts/src/lib.rs
index d7003d56c9..d68ba61f05 100644
--- a/accounts/src/lib.rs
+++ b/crates/accounts/src/lib.rs
@@ -18,6 +18,8 @@
//! Account management.
+extern crate parity_crypto as crypto;
+
mod account_data;
mod error;
mod stores;
@@ -32,7 +34,8 @@ use std::{
time::{Duration, Instant},
};
-use ethkey::{Address, Generator, Message, Password, Public, Random, Secret};
+use crypto::publickey::{Address, Generator, Message, Public, Random, Secret};
+use ethkey::Password;
use ethstore::{
accounts_dir::MemoryDirectory, random_string, EthMultiStore, EthStore, OpaqueSecret,
SecretStore, SecretVaultRef, SimpleSecretStore, StoreAccountRef,
@@ -40,7 +43,7 @@ use ethstore::{
use log::*;
use parking_lot::RwLock;
-pub use ethkey::Signature;
+pub use crypto::publickey::Signature;
pub use ethstore::{Derivation, Error, IndexDerivation, KeyFile};
pub use self::{account_data::AccountMeta, error::SignError};
@@ -134,9 +137,7 @@ impl AccountProvider {
/// Creates new random account and returns address and public key
pub fn new_account_and_public(&self, password: &Password) -> Result<(Address, Public), Error> {
- let acc = Random
- .generate()
- .expect("secp context has generation capabilities; qed");
+ let acc = Random.generate();
let public = acc.public().clone();
let secret = acc.secret().clone();
let account = self
@@ -355,7 +356,8 @@ impl AccountProvider {
} else {
// verify password by signing dump message
// result may be discarded
- let _ = self.sstore.sign(&account, &password, &Default::default())?;
+ let dummy_msg = [1u8; 32].into();
+ let _ = self.sstore.sign(&account, &password, &dummy_msg)?;
}
let data = AccountData {
@@ -632,15 +634,16 @@ impl AccountProvider {
#[cfg(test)]
mod tests {
use super::{AccountProvider, Unlock};
+ use crypto::publickey::{Address, Generator, Random};
use ethereum_types::H256;
- use ethkey::{Address, Generator, Random};
use ethstore::{Derivation, StoreAccountRef};
use std::time::{Duration, Instant};
#[test]
fn unlock_account_temp() {
- let kp = Random.generate().unwrap();
+ let kp = Random.generate();
let ap = AccountProvider::transient_provider();
+ let dummy_msg = [1u8; 32].into();
assert!(ap
.insert_account(kp.secret().clone(), &"test".into())
.is_ok());
@@ -650,13 +653,13 @@ mod tests {
assert!(ap
.unlock_account_temporarily(kp.address(), "test".into())
.is_ok());
- assert!(ap.sign(kp.address(), None, Default::default()).is_ok());
- assert!(ap.sign(kp.address(), None, Default::default()).is_err());
+ assert!(ap.sign(kp.address(), None, dummy_msg).is_ok());
+ assert!(ap.sign(kp.address(), None, dummy_msg).is_err());
}
#[test]
fn derived_account_nosave() {
- let kp = Random.generate().unwrap();
+ let kp = Random.generate();
let ap = AccountProvider::transient_provider();
assert!(ap
.insert_account(kp.secret().clone(), &"base".into())
@@ -669,7 +672,7 @@ mod tests {
.derive_account(
&kp.address(),
None,
- Derivation::SoftHash(H256::from(999)),
+ Derivation::SoftHash(H256::from_low_u64_be(999)),
false,
)
.expect("Derivation should not fail");
@@ -683,7 +686,7 @@ mod tests {
#[test]
fn derived_account_save() {
- let kp = Random.generate().unwrap();
+ let kp = Random.generate();
let ap = AccountProvider::transient_provider();
assert!(ap
.insert_account(kp.secret().clone(), &"base".into())
@@ -696,7 +699,7 @@ mod tests {
.derive_account(
&kp.address(),
None,
- Derivation::SoftHash(H256::from(999)),
+ Derivation::SoftHash(H256::from_low_u64_be(999)),
true,
)
.expect("Derivation should not fail");
@@ -716,7 +719,7 @@ mod tests {
#[test]
fn derived_account_sign() {
- let kp = Random.generate().unwrap();
+ let kp = Random.generate();
let ap = AccountProvider::transient_provider();
assert!(ap
.insert_account(kp.secret().clone(), &"base".into())
@@ -729,14 +732,14 @@ mod tests {
.derive_account(
&kp.address(),
None,
- Derivation::SoftHash(H256::from(1999)),
+ Derivation::SoftHash(H256::from_low_u64_be(1999)),
true,
)
.expect("Derivation should not fail");
ap.unlock_account_permanently(derived_addr, "base".into())
.expect("Should be ok because account is saved and password is valid");
- let msg = Default::default();
+ let msg = [2u8; 32].into();
let signed_msg1 = ap
.sign(derived_addr, None, msg)
.expect("Signing with existing unlocked account should not fail");
@@ -744,7 +747,7 @@ mod tests {
.sign_derived(
&kp.address(),
None,
- Derivation::SoftHash(H256::from(1999)),
+ Derivation::SoftHash(H256::from_low_u64_be(1999)),
msg,
)
.expect("Derived signing with existing unlocked account should not fail");
@@ -754,8 +757,9 @@ mod tests {
#[test]
fn unlock_account_perm() {
- let kp = Random.generate().unwrap();
+ let kp = Random.generate();
let ap = AccountProvider::transient_provider();
+ let dummy_msg = [1u8; 32].into();
assert!(ap
.insert_account(kp.secret().clone(), &"test".into())
.is_ok());
@@ -765,19 +769,20 @@ mod tests {
assert!(ap
.unlock_account_permanently(kp.address(), "test".into())
.is_ok());
- assert!(ap.sign(kp.address(), None, Default::default()).is_ok());
- assert!(ap.sign(kp.address(), None, Default::default()).is_ok());
+ assert!(ap.sign(kp.address(), None, dummy_msg).is_ok());
+ assert!(ap.sign(kp.address(), None, dummy_msg).is_ok());
assert!(ap
.unlock_account_temporarily(kp.address(), "test".into())
.is_ok());
- assert!(ap.sign(kp.address(), None, Default::default()).is_ok());
- assert!(ap.sign(kp.address(), None, Default::default()).is_ok());
+ assert!(ap.sign(kp.address(), None, dummy_msg).is_ok());
+ assert!(ap.sign(kp.address(), None, dummy_msg).is_ok());
}
#[test]
fn unlock_account_timer() {
- let kp = Random.generate().unwrap();
+ let kp = Random.generate();
let ap = AccountProvider::transient_provider();
+ let dummy_msg = [1u8; 32].into();
assert!(ap
.insert_account(kp.secret().clone(), &"test".into())
.is_ok());
@@ -787,35 +792,35 @@ mod tests {
assert!(ap
.unlock_account_timed(kp.address(), "test".into(), Duration::from_secs(60))
.is_ok());
- assert!(ap.sign(kp.address(), None, Default::default()).is_ok());
+ assert!(ap.sign(kp.address(), None, dummy_msg).is_ok());
ap.unlocked
.write()
.get_mut(&StoreAccountRef::root(kp.address()))
.unwrap()
.unlock = Unlock::Timed(Instant::now());
- assert!(ap.sign(kp.address(), None, Default::default()).is_err());
+ assert!(ap.sign(kp.address(), None, dummy_msg).is_err());
}
#[test]
fn should_sign_and_return_token() {
// given
- let kp = Random.generate().unwrap();
+ let kp = Random.generate();
let ap = AccountProvider::transient_provider();
+ let dummy_msg = [1u8; 32].into();
assert!(ap
.insert_account(kp.secret().clone(), &"test".into())
.is_ok());
// when
let (_signature, token) = ap
- .sign_with_token(kp.address(), "test".into(), Default::default())
+ .sign_with_token(kp.address(), "test".into(), dummy_msg)
.unwrap();
// then
- ap.sign_with_token(kp.address(), token.clone(), Default::default())
+ ap.sign_with_token(kp.address(), token.clone(), dummy_msg)
.expect("First usage of token should be correct.");
assert!(
- ap.sign_with_token(kp.address(), token, Default::default())
- .is_err(),
+ ap.sign_with_token(kp.address(), token, dummy_msg).is_err(),
"Second usage of the same token should fail."
);
}
diff --git a/accounts/src/stores.rs b/crates/accounts/src/stores.rs
similarity index 92%
rename from accounts/src/stores.rs
rename to crates/accounts/src/stores.rs
index 63a551be1f..f6accb66d8 100644
--- a/accounts/src/stores.rs
+++ b/crates/accounts/src/stores.rs
@@ -22,7 +22,7 @@ use std::{
path::{Path, PathBuf},
};
-use ethkey::Address;
+use crypto::publickey::Address;
use log::{trace, warn};
use crate::AccountMeta;
@@ -172,6 +172,7 @@ impl DiskMap {
mod tests {
use super::AddressBook;
use crate::account_data::AccountMeta;
+ use ethereum_types::H160;
use std::collections::HashMap;
use tempdir::TempDir;
@@ -179,8 +180,8 @@ mod tests {
fn should_save_and_reload_address_book() {
let tempdir = TempDir::new("").unwrap();
let mut b = AddressBook::new(tempdir.path());
- b.set_name(1.into(), "One".to_owned());
- b.set_meta(1.into(), "{1:1}".to_owned());
+ b.set_name(H160::from_low_u64_be(1), "One".to_owned());
+ b.set_meta(H160::from_low_u64_be(1), "{1:1}".to_owned());
let b = AddressBook::new(tempdir.path());
assert_eq!(
b.get(),
@@ -193,7 +194,7 @@ mod tests {
}
)]
.into_iter()
- .map(|(a, b)| (a.into(), b))
+ .map(|(a, b)| (H160::from_low_u64_be(a), b))
.collect::>()
);
}
@@ -203,10 +204,10 @@ mod tests {
let tempdir = TempDir::new("").unwrap();
let mut b = AddressBook::new(tempdir.path());
- b.set_name(1.into(), "One".to_owned());
- b.set_name(2.into(), "Two".to_owned());
- b.set_name(3.into(), "Three".to_owned());
- b.remove(2.into());
+ b.set_name(H160::from_low_u64_be(1), "One".to_owned());
+ b.set_name(H160::from_low_u64_be(2), "Two".to_owned());
+ b.set_name(H160::from_low_u64_be(3), "Three".to_owned());
+ b.remove(H160::from_low_u64_be(2));
let b = AddressBook::new(tempdir.path());
assert_eq!(
@@ -230,7 +231,7 @@ mod tests {
),
]
.into_iter()
- .map(|(a, b)| (a.into(), b))
+ .map(|(a, b)| (H160::from_low_u64_be(a), b))
.collect::>()
);
}
diff --git a/ethash/Cargo.toml b/crates/concensus/ethash/Cargo.toml
similarity index 88%
rename from ethash/Cargo.toml
rename to crates/concensus/ethash/Cargo.toml
index 06ee93f889..9ae4ff7f5c 100644
--- a/ethash/Cargo.toml
+++ b/crates/concensus/ethash/Cargo.toml
@@ -7,8 +7,9 @@ authors = ["Parity Technologies "]
[dependencies]
crunchy = "0.1.0"
either = "1.0.0"
-ethereum-types = "0.4"
-keccak-hash = "0.1"
+ethereum-types = "0.9.2"
+keccak-hash = "0.5.0"
+tiny-keccak = "2.0.2"
log = "0.4"
memmap = "0.6"
parking_lot = "0.7"
diff --git a/ethash/benches/basic.rs b/crates/concensus/ethash/benches/basic.rs
similarity index 100%
rename from ethash/benches/basic.rs
rename to crates/concensus/ethash/benches/basic.rs
diff --git a/ethash/benches/progpow.rs b/crates/concensus/ethash/benches/progpow.rs
similarity index 100%
rename from ethash/benches/progpow.rs
rename to crates/concensus/ethash/benches/progpow.rs
diff --git a/ethash/res/progpow_testvectors.json b/crates/concensus/ethash/res/progpow_testvectors.json
similarity index 100%
rename from ethash/res/progpow_testvectors.json
rename to crates/concensus/ethash/res/progpow_testvectors.json
diff --git a/ethash/src/cache.rs b/crates/concensus/ethash/src/cache.rs
similarity index 92%
rename from ethash/src/cache.rs
rename to crates/concensus/ethash/src/cache.rs
index ab3407a07e..38b2b2de65 100644
--- a/ethash/src/cache.rs
+++ b/crates/concensus/ethash/src/cache.rs
@@ -21,7 +21,7 @@ use memmap::MmapMut;
use parking_lot::Mutex;
use seed_compute::SeedHashCompute;
-use shared::{epoch, get_cache_size, to_hex, Node, ETHASH_CACHE_ROUNDS, NODE_BYTES, NODE_DWORDS};
+use shared::{epoch, get_cache_size, to_hex, Node, ETHASH_CACHE_ROUNDS, NODE_BYTES};
use std::{
borrow::Cow,
@@ -318,27 +318,22 @@ impl AsRef<[Node]> for NodeCache {
// out. It counts as a read and causes all writes afterwards to be elided. Yes, really. I know, I
// want to refactor this to use less `unsafe` as much as the next rustacean.
unsafe fn initialize_memory(memory: *mut Node, num_nodes: usize, ident: &H256) {
- let dst = memory as *mut u8;
+ // We use raw pointers here, see above
+ let dst = slice::from_raw_parts_mut(memory as *mut u8, NODE_BYTES);
debug_assert_eq!(ident.len(), 32);
- keccak_512::unchecked(dst, NODE_BYTES, ident.as_ptr(), ident.len());
+ keccak_512::write(&ident[..], dst);
for i in 1..num_nodes {
// We use raw pointers here, see above
- let dst = memory.offset(i as _) as *mut u8;
- let src = memory.offset(i as isize - 1) as *mut u8;
-
- keccak_512::unchecked(dst, NODE_BYTES, src, NODE_BYTES);
+ let dst = slice::from_raw_parts_mut(memory.offset(i as _) as *mut u8, NODE_BYTES);
+ let src = slice::from_raw_parts(memory.offset(i as isize - 1) as *mut u8, NODE_BYTES);
+ keccak_512::write(src, dst);
}
// Now this is initialized, we can treat it as a slice.
let nodes: &mut [Node] = slice::from_raw_parts_mut(memory, num_nodes);
- // For `unroll!`, see below. If the literal in `unroll!` is not the same as the RHS here then
- // these have got out of sync! Don't let this happen!
- debug_assert_eq!(NODE_DWORDS, 8);
-
- // This _should_ get unrolled by the compiler, since it's not using the loop variable.
for _ in 0..ETHASH_CACHE_ROUNDS {
for i in 0..num_nodes {
let data_idx = (num_nodes - 1 + i) % num_nodes;
@@ -348,11 +343,8 @@ unsafe fn initialize_memory(memory: *mut Node, num_nodes: usize, ident: &H256) {
let mut data: Node = nodes.get_unchecked(data_idx).clone();
let rhs: &Node = nodes.get_unchecked(idx);
- unroll! {
- for w in 0..8 {
- *data.as_dwords_mut().get_unchecked_mut(w) ^=
- *rhs.as_dwords().get_unchecked(w);
- }
+ for (a, b) in data.as_dwords_mut().iter_mut().zip(rhs.as_dwords()) {
+ *a ^= *b;
}
data
diff --git a/ethash/src/compute.rs b/crates/concensus/ethash/src/compute.rs
similarity index 76%
rename from ethash/src/compute.rs
rename to crates/concensus/ethash/src/compute.rs
index c378c754f7..00bbcd96d8 100644
--- a/ethash/src/compute.rs
+++ b/crates/concensus/ethash/src/compute.rs
@@ -26,7 +26,7 @@ use seed_compute::SeedHashCompute;
use shared::*;
use std::io;
-use std::{mem, path::Path, ptr};
+use std::{mem, path::Path};
const MIX_WORDS: usize = ETHASH_MIX_BYTES / 4;
const MIX_NODES: usize = MIX_WORDS / NODE_WORDS;
@@ -141,31 +141,24 @@ pub fn quick_get_difficulty(
mix_hash: &H256,
progpow: bool,
) -> H256 {
- unsafe {
- if progpow {
- let seed = keccak_f800_short(*header_hash, nonce, [0u32; 8]);
- keccak_f800_long(*header_hash, seed, mem::transmute(*mix_hash))
- } else {
- // This is safe - the `keccak_512` call below reads the first 40 bytes (which we explicitly set
- // with two `copy_nonoverlapping` calls) but writes the first 64, and then we explicitly write
- // the next 32 bytes before we read the whole thing with `keccak_256`.
- //
- // This cannot be elided by the compiler as it doesn't know the implementation of
- // `keccak_512`.
- let mut buf: [u8; 64 + 32] = ::mem::MaybeUninit::uninit().assume_init();
+ if progpow {
+ let seed = keccak_f800_short(*header_hash, nonce, [0u32; 8]);
+ keccak_f800_long(*header_hash, seed, unsafe { mem::transmute(*mix_hash) })
+ } else {
+ let mut buf = [0u8; 64 + 32];
- ptr::copy_nonoverlapping(header_hash.as_ptr(), buf.as_mut_ptr(), 32);
- ptr::copy_nonoverlapping(&nonce as *const u64 as *const u8, buf[32..].as_mut_ptr(), 8);
+ let hash_len = header_hash.len();
+ buf[..hash_len].copy_from_slice(header_hash);
+ let end = hash_len + mem::size_of::();
+ buf[hash_len..end].copy_from_slice(&nonce.to_ne_bytes());
- keccak_512::unchecked(buf.as_mut_ptr(), 64, buf.as_ptr(), 40);
- ptr::copy_nonoverlapping(mix_hash.as_ptr(), buf[64..].as_mut_ptr(), 32);
+ keccak_512::inplace_range(&mut buf, 0..end);
+ buf[64..].copy_from_slice(mix_hash);
- // This is initialized in `keccak_256`
- let mut hash: [u8; 32] = ::mem::MaybeUninit::uninit().assume_init();
- keccak_256::unchecked(hash.as_mut_ptr(), hash.len(), buf.as_ptr(), buf.len());
+ let mut hash = [0u8; 32];
+ keccak_256::write(&buf, &mut hash);
- hash
- }
+ hash
}
}
@@ -198,7 +191,7 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
struct MixBuf {
half_mix: Node,
compress_bytes: [u8; MIX_WORDS],
- };
+ }
if full_size % MIX_WORDS != 0 {
panic!("Unaligned full size");
@@ -214,32 +207,21 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
// improvements, since I can't imagine that 3-5% of our runtime is taken up by catting two
// arrays together.
let mut buf: MixBuf = MixBuf {
- half_mix: unsafe {
+ half_mix: {
// Pack `header_hash` and `nonce` together
- // We explicitly write the first 40 bytes, leaving the last 24 as uninitialized. Then
- // `keccak_512` reads the first 40 bytes (4th parameter) and overwrites the entire array,
- // leaving it fully initialized.
- let mut out: [u8; NODE_BYTES] = ::mem::MaybeUninit::uninit().assume_init();
-
- ptr::copy_nonoverlapping(header_hash.as_ptr(), out.as_mut_ptr(), header_hash.len());
- ptr::copy_nonoverlapping(
- &nonce as *const u64 as *const u8,
- out[header_hash.len()..].as_mut_ptr(),
- mem::size_of::(),
- );
+ let mut out = [0u8; NODE_BYTES];
+
+ let hash_len = header_hash.len();
+ out[..hash_len].copy_from_slice(header_hash);
+ let end = hash_len + mem::size_of::();
+ out[hash_len..end].copy_from_slice(&nonce.to_ne_bytes());
// compute keccak-512 hash and replicate across mix
- keccak_512::unchecked(
- out.as_mut_ptr(),
- NODE_BYTES,
- out.as_ptr(),
- header_hash.len() + mem::size_of::(),
- );
+ keccak_512::inplace_range(&mut out, 0..end);
Node { bytes: out }
},
- // This is fully initialized before being read, see `let mut compress = ...` below
- compress_bytes: unsafe { ::mem::MaybeUninit::uninit().assume_init() },
+ compress_bytes: [0u8; MIX_WORDS],
};
let mut mix: [_; MIX_NODES] = [buf.half_mix.clone(), buf.half_mix.clone()];
@@ -263,24 +245,13 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
fnv_hash(first_val ^ i, mix_words[i as usize % MIX_WORDS]) % num_full_pages
};
- unroll! {
- // MIX_NODES
- for n in 0..2 {
- let tmp_node = calculate_dag_item(
- index * MIX_NODES as u32 + n as u32,
- cache,
- );
+ // MIX_NODES
+ for n in 0..2 {
+ let tmp_node = calculate_dag_item(index * MIX_NODES as u32 + n as u32, cache);
- unroll! {
- // NODE_WORDS
- for w in 0..16 {
- mix[n].as_words_mut()[w] =
- fnv_hash(
- mix[n].as_words()[w],
- tmp_node.as_words()[w],
- );
- }
- }
+ // NODE_WORDS
+ for (a, b) in mix[n].as_words_mut().iter_mut().zip(tmp_node.as_words()) {
+ *a = fnv_hash(*a, *b);
}
}
}
@@ -288,25 +259,27 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
let mix_words: [u32; MIX_WORDS] = unsafe { mem::transmute(mix) };
{
- // This is an uninitialized buffer to begin with, but we iterate precisely `compress.len()`
- // times and set each index, leaving the array fully initialized. THIS ONLY WORKS ON LITTLE-
- // ENDIAN MACHINES. See a future PR to make this and the rest of the code work correctly on
+ // We iterate precisely `compress.len()` times and set each index,
+ // leaving the array fully initialized. THIS ONLY WORKS ON LITTLE-ENDIAN MACHINES.
+ // See a future PR to make this and the rest of the code work correctly on
// big-endian arches like mips.
let compress: &mut [u32; MIX_WORDS / 4] =
unsafe { make_const_array!(MIX_WORDS / 4, &mut buf.compress_bytes) };
+ #[cfg(target_endian = "big")]
+ {
+ compile_error!("OpenEthereum currently only supports little-endian targets");
+ }
// Compress mix
debug_assert_eq!(MIX_WORDS / 4, 8);
- unroll! {
- for i in 0..8 {
- let w = i * 4;
-
- let mut reduction = mix_words[w + 0];
- reduction = reduction.wrapping_mul(FNV_PRIME) ^ mix_words[w + 1];
- reduction = reduction.wrapping_mul(FNV_PRIME) ^ mix_words[w + 2];
- reduction = reduction.wrapping_mul(FNV_PRIME) ^ mix_words[w + 3];
- compress[i] = reduction;
- }
+ for i in 0..8 {
+ let w = i * 4;
+
+ let mut reduction = mix_words[w + 0];
+ reduction = reduction.wrapping_mul(FNV_PRIME) ^ mix_words[w + 1];
+ reduction = reduction.wrapping_mul(FNV_PRIME) ^ mix_words[w + 2];
+ reduction = reduction.wrapping_mul(FNV_PRIME) ^ mix_words[w + 3];
+ compress[i] = reduction;
}
}
@@ -315,24 +288,20 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
let value: H256 = {
// We can interpret the buffer as an array of `u8`s, since it's `repr(C)`.
let read_ptr: *const u8 = &buf as *const MixBuf as *const u8;
- // We overwrite the second half since `keccak_256` has an internal buffer and so allows
- // overlapping arrays as input.
- let write_ptr: *mut u8 = &mut buf.compress_bytes as *mut [u8; 32] as *mut u8;
- unsafe {
- keccak_256::unchecked(
- write_ptr,
- buf.compress_bytes.len(),
+ let buffer = unsafe {
+ core::slice::from_raw_parts(
read_ptr,
buf.half_mix.bytes.len() + buf.compress_bytes.len(),
- );
- }
+ )
+ };
+ // We overwrite the buf.compress_bytes since `keccak_256` has an internal buffer and so allows
+ // overlapping arrays as input.
+ keccak_256::write(buffer, &mut buf.compress_bytes);
+
buf.compress_bytes
};
- ProofOfWork {
- mix_hash: mix_hash,
- value: value,
- }
+ ProofOfWork { mix_hash, value }
}
// TODO: Use the `simd` crate
diff --git a/accounts/ethkey/src/keccak.rs b/crates/concensus/ethash/src/keccak.rs
similarity index 65%
rename from accounts/ethkey/src/keccak.rs
rename to crates/concensus/ethash/src/keccak.rs
index e3c67b34d1..134a11fb2a 100644
--- a/accounts/ethkey/src/keccak.rs
+++ b/crates/concensus/ethash/src/keccak.rs
@@ -14,20 +14,22 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
-use tiny_keccak::Keccak;
+extern crate keccak_hash as hash;
-pub trait Keccak256 {
- fn keccak256(&self) -> T
- where
- T: Sized;
+pub type H256 = [u8; 32];
+
+pub mod keccak_512 {
+ use super::hash;
+
+ pub use self::hash::{
+ keccak512 as inplace, keccak512_range as inplace_range, keccak_512 as write,
+ };
}
-impl Keccak256<[u8; 32]> for [u8] {
- fn keccak256(&self) -> [u8; 32] {
- let mut keccak = Keccak::new_keccak256();
- let mut result = [0u8; 32];
- keccak.update(self);
- keccak.finalize(&mut result);
- result
- }
+pub mod keccak_256 {
+ use super::hash;
+
+ pub use self::hash::{
+ keccak256 as inplace, keccak256_range as inplace_range, keccak_256 as write,
+ };
}
diff --git a/ethash/src/lib.rs b/crates/concensus/ethash/src/lib.rs
similarity index 90%
rename from ethash/src/lib.rs
rename to crates/concensus/ethash/src/lib.rs
index e56b09358e..2232d24319 100644
--- a/ethash/src/lib.rs
+++ b/crates/concensus/ethash/src/lib.rs
@@ -19,6 +19,7 @@ extern crate ethereum_types;
extern crate memmap;
extern crate parking_lot;
extern crate primal;
+extern crate tiny_keccak;
#[macro_use]
extern crate crunchy;
@@ -52,12 +53,13 @@ mod progpow;
pub use cache::{NodeCacheBuilder, OptimizeFor};
use compute::Light;
pub use compute::{quick_get_difficulty, slow_hash_block_number, ProofOfWork};
-use ethereum_types::{U256, U512};
+use ethereum_types::{BigEndianHash, U256, U512};
use keccak::H256;
use parking_lot::Mutex;
pub use seed_compute::SeedHashCompute;
pub use shared::ETHASH_EPOCH_LENGTH;
use std::{
+ convert::TryFrom,
mem,
path::{Path, PathBuf},
};
@@ -168,12 +170,12 @@ impl EthashManager {
/// Convert an Ethash boundary to its original difficulty. Basically just `f(x) = 2^256 / x`.
pub fn boundary_to_difficulty(boundary: ðereum_types::H256) -> U256 {
- difficulty_to_boundary_aux(&**boundary)
+ difficulty_to_boundary_aux(&boundary.into_uint())
}
/// Convert an Ethash difficulty to the target boundary. Basically just `f(x) = 2^256 / x`.
pub fn difficulty_to_boundary(difficulty: &U256) -> ethereum_types::H256 {
- difficulty_to_boundary_aux(difficulty).into()
+ BigEndianHash::from_uint(&difficulty_to_boundary_aux(difficulty))
}
fn difficulty_to_boundary_aux>(difficulty: T) -> ethereum_types::U256 {
@@ -184,8 +186,8 @@ fn difficulty_to_boundary_aux>(difficulty: T) -> ethereum_types::U
if difficulty == U512::one() {
U256::max_value()
} else {
- // difficulty > 1, so result should never overflow 256 bits
- U256::from((U512::one() << 256) / difficulty)
+ const PROOF: &str = "difficulty > 1, so result never overflows 256 bits; qed";
+ U256::try_from((U512::one() << 256) / difficulty).expect(PROOF)
}
}
@@ -210,12 +212,12 @@ fn test_lru() {
#[test]
fn test_difficulty_to_boundary() {
- use ethereum_types::H256;
+ use ethereum_types::{BigEndianHash, H256};
use std::str::FromStr;
assert_eq!(
difficulty_to_boundary(&U256::from(1)),
- H256::from(U256::max_value())
+ BigEndianHash::from_uint(&U256::max_value())
);
assert_eq!(
difficulty_to_boundary(&U256::from(2)),
@@ -243,16 +245,18 @@ fn test_difficulty_to_boundary_regression() {
boundary_to_difficulty(&difficulty_to_boundary(&difficulty.into()))
);
assert_eq!(
- H256::from(difficulty),
- difficulty_to_boundary(&boundary_to_difficulty(&difficulty.into()))
+ H256::from_low_u64_be(difficulty),
+ difficulty_to_boundary(&boundary_to_difficulty(&H256::from_low_u64_be(difficulty)))
);
assert_eq!(
U256::from(difficulty),
- boundary_to_difficulty(&boundary_to_difficulty(&difficulty.into()).into())
+ boundary_to_difficulty(&BigEndianHash::from_uint(&boundary_to_difficulty(
+ &H256::from_low_u64_be(difficulty)
+ ))),
);
assert_eq!(
- H256::from(difficulty),
- difficulty_to_boundary(&difficulty_to_boundary(&difficulty.into()).into())
+ H256::from_low_u64_be(difficulty),
+ difficulty_to_boundary(&difficulty_to_boundary(&difficulty.into()).into_uint())
);
}
}
@@ -266,5 +270,5 @@ fn test_difficulty_to_boundary_panics_on_zero() {
#[test]
#[should_panic]
fn test_boundary_to_difficulty_panics_on_zero() {
- boundary_to_difficulty(ðereum_types::H256::from(0));
+ boundary_to_difficulty(ðereum_types::H256::zero());
}
diff --git a/ethash/src/progpow.rs b/crates/concensus/ethash/src/progpow.rs
similarity index 100%
rename from ethash/src/progpow.rs
rename to crates/concensus/ethash/src/progpow.rs
diff --git a/ethash/src/seed_compute.rs b/crates/concensus/ethash/src/seed_compute.rs
similarity index 100%
rename from ethash/src/seed_compute.rs
rename to crates/concensus/ethash/src/seed_compute.rs
diff --git a/ethash/src/shared.rs b/crates/concensus/ethash/src/shared.rs
similarity index 100%
rename from ethash/src/shared.rs
rename to crates/concensus/ethash/src/shared.rs
diff --git a/miner/Cargo.toml b/crates/concensus/miner/Cargo.toml
similarity index 52%
rename from miner/Cargo.toml
rename to crates/concensus/miner/Cargo.toml
index 22e2e7dd84..f155005644 100644
--- a/miner/Cargo.toml
+++ b/crates/concensus/miner/Cargo.toml
@@ -8,35 +8,39 @@ authors = ["Parity Technologies "]
[dependencies]
# Only work_notify, consider a separate crate
-ethash = { path = "../ethash", optional = true }
-fetch = { path = "../util/fetch", optional = true }
+ethash = { path = "../../concensus/ethash", optional = true }
+fetch = { path = "../../net/fetch", optional = true }
hyper = { version = "0.12", optional = true }
url = { version = "2", optional = true }
# Miner
ansi_term = "0.10"
-common-types = { path = "../ethcore/types" }
+common-types = { path = "../../ethcore/types" }
error-chain = "0.12"
-ethabi = "6.0"
-ethabi-derive = "6.0"
-ethabi-contract = "6.0"
-ethcore-call-contract = { path = "../ethcore/call-contract" }
-ethereum-types = "0.4"
+ethabi = "12.0.0"
+ethabi-derive = "12.0.0"
+ethabi-contract = "11.0.0"
+ethcore-call-contract = { path = "../../vm/call-contract" }
+ethereum-types = "0.9.2"
futures = "0.1"
-heapsize = "0.4"
-keccak-hash = "0.1"
+keccak-hash = "0.5.0"
linked-hash-map = "0.5"
log = "0.4"
-parity-runtime = { path = "../util/runtime" }
+parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
+parity-runtime = { path = "../../runtime/runtime" }
+parity-util-mem = "0.7"
parking_lot = "0.7"
price-info = { path = "./price-info", optional = true }
-rlp = { version = "0.3.0", features = ["ethereum"] }
+rlp = { version = "0.4.6" }
+serde = { version = "1.0", features = ["derive"] }
+serde_derive = "1.0"
+serde_json = "1.0"
trace-time = "0.1"
transaction-pool = "2.0.1"
[dev-dependencies]
env_logger = "0.5"
-ethkey = { path = "../accounts/ethkey" }
+ethkey = { path = "../../accounts/ethkey" }
rustc-hex = "1.0"
[features]
diff --git a/miner/local-store/Cargo.toml b/crates/concensus/miner/local-store/Cargo.toml
similarity index 51%
rename from miner/local-store/Cargo.toml
rename to crates/concensus/miner/local-store/Cargo.toml
index d16c644071..554ea93015 100644
--- a/miner/local-store/Cargo.toml
+++ b/crates/concensus/miner/local-store/Cargo.toml
@@ -5,15 +5,17 @@ version = "0.1.0"
authors = ["Parity Technologies "]
[dependencies]
-common-types = { path = "../../ethcore/types" }
-ethcore-io = { path = "../../util/io" }
+common-types = { path = "../../../ethcore/types" }
+ethcore-io = { path = "../../../runtime/io" }
+ethcore-db = { path = "../../../db/db"}
kvdb = "0.1"
log = "0.4"
-rlp = { version = "0.3.0", features = ["ethereum"] }
+parity-crypto = { version = "0.6.2", features = [ "publickey" ] }
+rlp = { version = "0.4.6" }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
[dev-dependencies]
-ethkey = { path = "../../accounts/ethkey" }
+ethkey = { path = "../../../accounts/ethkey" }
kvdb-memorydb = "0.1"
diff --git a/miner/local-store/src/lib.rs b/crates/concensus/miner/local-store/src/lib.rs
similarity index 90%
rename from miner/local-store/src/lib.rs
rename to crates/concensus/miner/local-store/src/lib.rs
index b05efe2e00..d1aee10651 100644
--- a/miner/local-store/src/lib.rs
+++ b/crates/concensus/miner/local-store/src/lib.rs
@@ -18,16 +18,18 @@
use std::{fmt, sync::Arc, time::Duration};
+use ethcore_db::KeyValueDB;
use io::IoHandler;
-use kvdb::KeyValueDB;
-use rlp::Rlp;
use types::transaction::{
- Condition as TransactionCondition, PendingTransaction, SignedTransaction, UnverifiedTransaction,
+ Condition as TransactionCondition, PendingTransaction, SignedTransaction, TypedTransaction,
+ UnverifiedTransaction,
};
extern crate common_types as types;
+extern crate ethcore_db;
extern crate ethcore_io as io;
extern crate kvdb;
+extern crate parity_crypto as crypto;
extern crate rlp;
extern crate serde;
extern crate serde_json;
@@ -98,7 +100,7 @@ struct TransactionEntry {
impl TransactionEntry {
fn into_pending(self) -> Option {
- let tx: UnverifiedTransaction = match Rlp::new(&self.rlp_bytes).as_val() {
+ let tx: UnverifiedTransaction = match TypedTransaction::decode(&self.rlp_bytes) {
Err(e) => {
warn!(target: "local_store", "Invalid persistent transaction stored: {}", e);
return None;
@@ -120,7 +122,7 @@ impl TransactionEntry {
impl From for TransactionEntry {
fn from(pending: PendingTransaction) -> Self {
TransactionEntry {
- rlp_bytes: ::rlp::encode(&pending.transaction),
+ rlp_bytes: pending.transaction.encode(),
condition: pending.condition.map(Into::into),
}
}
@@ -237,9 +239,9 @@ impl Drop for LocalDataStore {
mod tests {
use super::NodeInfo;
- use ethkey::{Brain, Generator};
+ use ethkey::Brain;
use std::sync::Arc;
- use types::transaction::{Condition, PendingTransaction, Transaction};
+ use types::transaction::{Condition, PendingTransaction, Transaction, TypedTransaction};
// we want to test: round-trip of good transactions.
// failure to roundtrip bad transactions (but that it doesn't panic)
@@ -253,7 +255,7 @@ mod tests {
#[test]
fn twice_empty() {
- let db = Arc::new(::kvdb_memorydb::create(0));
+ let db = Arc::new(ethcore_db::InMemoryWithMetrics::create(0));
{
let store = super::create(db.clone(), None, Dummy(vec![]));
@@ -268,11 +270,11 @@ mod tests {
#[test]
fn with_condition() {
- let keypair = Brain::new("abcd".into()).generate().unwrap();
+ let keypair = Brain::new("abcd".into()).generate();
let transactions: Vec<_> = (0..10u64)
.map(|nonce| {
- let mut tx = Transaction::default();
- tx.nonce = nonce.into();
+ let mut tx = TypedTransaction::Legacy(Transaction::default());
+ tx.tx_mut().nonce = nonce.into();
let signed = tx.sign(keypair.secret(), None);
let condition = match nonce {
@@ -284,7 +286,7 @@ mod tests {
})
.collect();
- let db = Arc::new(::kvdb_memorydb::create(0));
+ let db = Arc::new(ethcore_db::InMemoryWithMetrics::create(0));
{
// nothing written yet, will write pending.
@@ -305,11 +307,11 @@ mod tests {
#[test]
fn skips_bad_transactions() {
- let keypair = Brain::new("abcd".into()).generate().unwrap();
+ let keypair = Brain::new("abcd".into()).generate();
let mut transactions: Vec<_> = (0..10u64)
.map(|nonce| {
- let mut tx = Transaction::default();
- tx.nonce = nonce.into();
+ let mut tx = TypedTransaction::Legacy(Transaction::default());
+ tx.tx_mut().nonce = nonce.into();
let signed = tx.sign(keypair.secret(), None);
@@ -318,14 +320,14 @@ mod tests {
.collect();
transactions.push({
- let mut tx = Transaction::default();
- tx.nonce = 10.into();
+ let mut tx = TypedTransaction::Legacy(Transaction::default());
+ tx.tx_mut().nonce = 10.into();
let signed = tx.fake_sign(Default::default());
PendingTransaction::new(signed, None)
});
- let db = Arc::new(::kvdb_memorydb::create(0));
+ let db = Arc::new(ethcore_db::InMemoryWithMetrics::create(0));
{
// nothing written, will write bad.
let store = super::create(db.clone(), None, Dummy(transactions.clone()));
diff --git a/miner/price-info/Cargo.toml b/crates/concensus/miner/price-info/Cargo.toml
similarity index 68%
rename from miner/price-info/Cargo.toml
rename to crates/concensus/miner/price-info/Cargo.toml
index 0426b01b4b..3a884b24db 100644
--- a/miner/price-info/Cargo.toml
+++ b/crates/concensus/miner/price-info/Cargo.toml
@@ -7,12 +7,12 @@ version = "1.12.0"
authors = ["Parity Technologies "]
[dependencies]
-fetch = { path = "../../util/fetch" }
+fetch = { path = "../../../net/fetch" }
futures = "0.1"
-parity-runtime = { path = "../../util/runtime" }
+parity-runtime = { path = "../../../runtime/runtime" }
log = "0.4"
serde_json = "1.0"
[dev-dependencies]
parking_lot = "0.7"
-fake-fetch = { path = "../../util/fake-fetch" }
+fake-fetch = { path = "../../../net/fake-fetch" }
diff --git a/miner/price-info/src/lib.rs b/crates/concensus/miner/price-info/src/lib.rs
similarity index 96%
rename from miner/price-info/src/lib.rs
rename to crates/concensus/miner/price-info/src/lib.rs
index 51ad6a0bc4..7cb422724b 100644
--- a/miner/price-info/src/lib.rs
+++ b/crates/concensus/miner/price-info/src/lib.rs
@@ -207,11 +207,11 @@ mod test {
// when
let bb = b.clone();
price_info.get(move |_| {
- bb.store(true, Ordering::Relaxed);
+ bb.store(true, Ordering::SeqCst);
});
// then
- assert_eq!(b.load(Ordering::Relaxed), false);
+ assert_eq!(b.load(Ordering::SeqCst), false);
}
#[test]
@@ -225,10 +225,10 @@ mod test {
// when
let bb = b.clone();
price_info.get(move |_| {
- bb.store(true, Ordering::Relaxed);
+ bb.store(true, Ordering::SeqCst);
});
// then
- assert_eq!(b.load(Ordering::Relaxed), false);
+ assert_eq!(b.load(Ordering::SeqCst), false);
}
}
diff --git a/miner/res/contracts/service_transaction.json b/crates/concensus/miner/res/contracts/service_transaction.json
similarity index 100%
rename from miner/res/contracts/service_transaction.json
rename to crates/concensus/miner/res/contracts/service_transaction.json
diff --git a/miner/src/external.rs b/crates/concensus/miner/src/external.rs
similarity index 91%
rename from miner/src/external.rs
rename to crates/concensus/miner/src/external.rs
index 403f6949d8..2a68b4e35c 100644
--- a/miner/src/external.rs
+++ b/crates/concensus/miner/src/external.rs
@@ -92,7 +92,7 @@ mod tests {
// given
let m = miner();
assert_eq!(m.hashrate(), U256::from(0));
- m.submit_hashrate(U256::from(10), H256::from(1));
+ m.submit_hashrate(U256::from(10), H256::from_low_u64_be(1));
assert_eq!(m.hashrate(), U256::from(10));
// when
@@ -107,12 +107,12 @@ mod tests {
// given
let m = miner();
assert_eq!(m.hashrate(), U256::from(0));
- m.submit_hashrate(U256::from(10), H256::from(1));
+ m.submit_hashrate(U256::from(10), H256::from_low_u64_be(1));
assert_eq!(m.hashrate(), U256::from(10));
// when
- m.submit_hashrate(U256::from(15), H256::from(1));
- m.submit_hashrate(U256::from(20), H256::from(2));
+ m.submit_hashrate(U256::from(15), H256::from_low_u64_be(1));
+ m.submit_hashrate(U256::from(20), H256::from_low_u64_be(2));
// then
assert_eq!(m.hashrate(), U256::from(35));
diff --git a/miner/src/gas_price_calibrator.rs b/crates/concensus/miner/src/gas_price_calibrator.rs
similarity index 100%
rename from miner/src/gas_price_calibrator.rs
rename to crates/concensus/miner/src/gas_price_calibrator.rs
diff --git a/miner/src/gas_pricer.rs b/crates/concensus/miner/src/gas_pricer.rs
similarity index 100%
rename from miner/src/gas_pricer.rs
rename to crates/concensus/miner/src/gas_pricer.rs
diff --git a/miner/src/lib.rs b/crates/concensus/miner/src/lib.rs
similarity index 94%
rename from miner/src/lib.rs
rename to crates/concensus/miner/src/lib.rs
index 89bd18c4f3..4df0b185ae 100644
--- a/miner/src/lib.rs
+++ b/crates/concensus/miner/src/lib.rs
@@ -22,13 +22,15 @@
extern crate ansi_term;
extern crate common_types as types;
extern crate ethabi;
+extern crate ethabi_derive;
extern crate ethcore_call_contract as call_contract;
extern crate ethereum_types;
extern crate futures;
-extern crate heapsize;
extern crate keccak_hash as hash;
extern crate linked_hash_map;
+extern crate parity_crypto as crypto;
extern crate parity_runtime;
+extern crate parity_util_mem;
extern crate parking_lot;
#[cfg(feature = "price-info")]
extern crate price_info;
@@ -38,12 +40,12 @@ extern crate transaction_pool as txpool;
#[macro_use]
extern crate ethabi_contract;
#[macro_use]
-extern crate ethabi_derive;
-#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate log;
#[macro_use]
+extern crate serde_derive;
+#[macro_use]
extern crate trace_time;
#[cfg(test)]
diff --git a/miner/src/local_accounts.rs b/crates/concensus/miner/src/local_accounts.rs
similarity index 100%
rename from miner/src/local_accounts.rs
rename to crates/concensus/miner/src/local_accounts.rs
diff --git a/miner/src/pool/client.rs b/crates/concensus/miner/src/pool/client.rs
similarity index 100%
rename from miner/src/pool/client.rs
rename to crates/concensus/miner/src/pool/client.rs
diff --git a/miner/src/pool/listener.rs b/crates/concensus/miner/src/pool/listener.rs
similarity index 90%
rename from miner/src/pool/listener.rs
rename to crates/concensus/miner/src/pool/listener.rs
index 35f94d6007..5d1b936b99 100644
--- a/miner/src/pool/listener.rs
+++ b/crates/concensus/miner/src/pool/listener.rs
@@ -79,11 +79,11 @@ impl txpool::Listener for Logger {
"[{hash:?}] Sender: {sender}, nonce: {nonce}, gasPrice: {gas_price}, gas: {gas}, value: {value}, dataLen: {data}))",
hash = tx.hash(),
sender = tx.sender(),
- nonce = tx.signed().nonce,
- gas_price = tx.signed().gas_price,
- gas = tx.signed().gas,
- value = tx.signed().value,
- data = tx.signed().data.len(),
+ nonce = tx.signed().tx().nonce,
+ gas_price = tx.signed().tx().gas_price,
+ gas = tx.signed().tx().gas,
+ value = tx.signed().tx().value,
+ data = tx.signed().tx().data.len(),
);
if let Some(old) = old {
@@ -124,6 +124,7 @@ impl txpool::Listener for Logger {
#[cfg(test)]
mod tests {
use super::*;
+ use ethereum_types::H160;
use parking_lot::Mutex;
use txpool::Listener;
use types::transaction;
@@ -150,7 +151,7 @@ mod tests {
assert_eq!(
*received.lock(),
vec![
- "13aff4201ac1dc49daf6a7cf07b558ed956511acbaabf9502bdacc353953766d"
+ "de96bdcdf864c95eb7f81eff1e3290be24a0f327732e0c4251c1896a565a80db"
.parse()
.unwrap()
]
@@ -158,15 +159,15 @@ mod tests {
}
fn new_tx() -> Arc {
- let signed = transaction::Transaction {
+ let signed = transaction::TypedTransaction::Legacy(transaction::Transaction {
action: transaction::Action::Create,
data: vec![1, 2, 3],
nonce: 5.into(),
gas: 21_000.into(),
gas_price: 5.into(),
value: 0.into(),
- }
- .fake_sign(5.into());
+ })
+ .fake_sign(H160::from_low_u64_be(5));
Arc::new(Transaction::from_pending_block_transaction(signed))
}
diff --git a/miner/src/pool/local_transactions.rs b/crates/concensus/miner/src/pool/local_transactions.rs
similarity index 98%
rename from miner/src/pool/local_transactions.rs
rename to crates/concensus/miner/src/pool/local_transactions.rs
index 89f1476248..bb86f76f93 100644
--- a/miner/src/pool/local_transactions.rs
+++ b/crates/concensus/miner/src/pool/local_transactions.rs
@@ -254,8 +254,8 @@ impl txpool::Listener for LocalTransactionsList {
#[cfg(test)]
mod tests {
use super::*;
+ use crypto::publickey::{Generator, Random};
use ethereum_types::U256;
- use ethkey::{Generator, Random};
use txpool::Listener;
use types::transaction;
@@ -339,15 +339,15 @@ mod tests {
}
fn new_tx>(nonce: T) -> Arc {
- let keypair = Random.generate().unwrap();
- let signed = transaction::Transaction {
+ let keypair = Random.generate();
+ let signed = transaction::TypedTransaction::Legacy(transaction::Transaction {
action: transaction::Action::Create,
value: U256::from(100),
data: Default::default(),
gas: U256::from(10),
gas_price: U256::from(1245),
nonce: nonce.into(),
- }
+ })
.sign(keypair.secret(), None);
let mut tx = Transaction::from_pending_block_transaction(signed);
diff --git a/miner/src/pool/mod.rs b/crates/concensus/miner/src/pool/mod.rs
similarity index 96%
rename from miner/src/pool/mod.rs
rename to crates/concensus/miner/src/pool/mod.rs
index 306189d13c..ee7b691a8e 100644
--- a/miner/src/pool/mod.rs
+++ b/crates/concensus/miner/src/pool/mod.rs
@@ -17,7 +17,7 @@
//! Transaction Pool
use ethereum_types::{Address, H256, U256};
-use heapsize::HeapSizeOf;
+use parity_util_mem::MallocSizeOfExt;
use txpool;
use types::transaction;
@@ -29,6 +29,7 @@ pub mod client;
pub mod local_transactions;
pub mod replace;
pub mod scoring;
+pub mod transaction_filter;
pub mod verifier;
#[cfg(test)]
@@ -177,7 +178,7 @@ impl txpool::VerifiedTransaction for VerifiedTransaction {
}
fn mem_usage(&self) -> usize {
- self.transaction.heap_size_of_children()
+ self.transaction.malloc_size_of()
}
fn sender(&self) -> &Address {
@@ -192,11 +193,11 @@ impl ScoredTransaction for VerifiedTransaction {
/// Gets transaction gas price.
fn gas_price(&self) -> &U256 {
- &self.transaction.gas_price
+ &self.transaction.tx().gas_price
}
/// Gets transaction nonce.
fn nonce(&self) -> U256 {
- self.transaction.nonce
+ self.transaction.tx().nonce
}
}
diff --git a/miner/src/pool/queue.rs b/crates/concensus/miner/src/pool/queue.rs
similarity index 92%
rename from miner/src/pool/queue.rs
rename to crates/concensus/miner/src/pool/queue.rs
index cf8a1f3802..64c543c53a 100644
--- a/miner/src/pool/queue.rs
+++ b/crates/concensus/miner/src/pool/queue.rs
@@ -32,7 +32,10 @@ use txpool::{self, Verifier};
use types::transaction;
use pool::{
- self, client, listener, local_transactions::LocalTransactionsList, ready, replace, scoring,
+ self, client, listener,
+ local_transactions::LocalTransactionsList,
+ ready, replace, scoring,
+ transaction_filter::{match_filter, TransactionFilter},
verifier, PendingOrdering, PendingSettings, PrioritizationStrategy,
};
@@ -120,6 +123,17 @@ impl CachedPending {
current_timestamp: u64,
nonce_cap: Option<&U256>,
max_len: usize,
+ ) -> Option>> {
+ self.pending_filtered(block_number, current_timestamp, nonce_cap, max_len, None)
+ }
+
+ pub fn pending_filtered(
+ &self,
+ block_number: u64,
+ current_timestamp: u64,
+ nonce_cap: Option<&U256>,
+ max_len: usize,
+ filter: Option,
) -> Option>> {
// First check if we have anything in cache.
let pending = self.pending.as_ref()?;
@@ -149,7 +163,14 @@ impl CachedPending {
return None;
}
- Some(pending.iter().take(max_len).cloned().collect())
+ Some(
+ pending
+ .iter()
+ .filter(|tx| match_filter(&filter, tx))
+ .take(max_len)
+ .cloned()
+ .collect(),
+ )
}
}
@@ -251,6 +272,7 @@ impl TransactionQueue {
self.pool.write().listener_mut().0.set_in_chain_checker(f)
}
+ // t_nb 10.2
/// Import a set of transactions to the pool.
///
/// Given blockchain and state access (Client)
@@ -425,6 +447,31 @@ impl TransactionQueue {
pending
}
+ /// Returns current pending transactions filtered.
+ ///
+ /// Different to the pending() method, this one does not cache.
+ pub fn pending_filtered(
+ &self,
+ client: C,
+ settings: PendingSettings,
+ filter: &TransactionFilter,
+ ) -> Vec>
+ where
+ C: client::NonceClient,
+ {
+ self.collect_pending(
+ client,
+ settings.block_number,
+ settings.current_timestamp,
+ settings.nonce_cap,
+ |i| {
+ i.filter(|tx| filter.matches(tx))
+ .take(settings.max_len)
+ .collect()
+ },
+ )
+ }
+
/// Collect pending transactions.
///
/// NOTE This is re-computing the pending set and it might be expensive to do so.
@@ -471,7 +518,7 @@ impl TransactionQueue {
(pending_readiness, state_readiness)
}
- /// Culls all stalled transactions from the pool.
+ /// t_nb 10.5.1 Culls all stalled transactions from the pool.
pub fn cull(&self, client: C) {
trace_time!("pool::cull");
// We don't care about future transactions, so nonce_cap is not important.
@@ -479,7 +526,7 @@ impl TransactionQueue {
// We want to clear stale transactions from the queue as well.
// (Transactions that are occuping the queue for a long time without being included)
let stale_id = {
- let current_id = self.insertion_id.load(atomic::Ordering::Relaxed);
+ let current_id = self.insertion_id.load(atomic::Ordering::SeqCst);
// wait at least for half of the queue to be replaced
let gap = self.pool.read().options().max_count / 2;
// but never less than 100 transactions
@@ -518,7 +565,7 @@ impl TransactionQueue {
.read()
.pending_from_sender(state_readiness, address)
.last()
- .map(|tx| tx.signed().nonce.saturating_add(U256::from(1)))
+ .map(|tx| tx.signed().tx().nonce.saturating_add(U256::from(1)))
}
/// Retrieve a transaction from the pool.
@@ -572,7 +619,7 @@ impl TransactionQueue {
/// Returns gas price of currently the worst transaction in the pool.
pub fn current_worst_gas_price(&self) -> U256 {
match self.pool.read().worst_transaction() {
- Some(tx) => tx.signed().gas_price,
+ Some(tx) => tx.signed().tx().gas_price,
None => self.options.read().minimal_gas_price,
}
}
@@ -659,7 +706,7 @@ mod tests {
);
for tx in pending {
- assert!(tx.signed().nonce > 0.into());
+ assert!(tx.signed().tx().nonce > 0.into());
}
}
}
diff --git a/miner/src/pool/ready.rs b/crates/concensus/miner/src/pool/ready.rs
similarity index 97%
rename from miner/src/pool/ready.rs
rename to crates/concensus/miner/src/pool/ready.rs
index 75d54bf8ff..d8914be5c9 100644
--- a/miner/src/pool/ready.rs
+++ b/crates/concensus/miner/src/pool/ready.rs
@@ -71,7 +71,7 @@ impl txpool::Ready for State {
fn is_ready(&mut self, tx: &VerifiedTransaction) -> txpool::Readiness {
// Check max nonce
match self.max_nonce {
- Some(nonce) if tx.transaction.nonce > nonce => {
+ Some(nonce) if tx.transaction.tx().nonce > nonce => {
return txpool::Readiness::Future;
}
_ => {}
@@ -81,7 +81,7 @@ impl txpool::Ready for State {
let state = &self.state;
let state_nonce = || state.account_nonce(sender);
let nonce = self.nonces.entry(*sender).or_insert_with(state_nonce);
- match tx.transaction.nonce.cmp(nonce) {
+ match tx.transaction.tx().nonce.cmp(nonce) {
// Before marking as future check for stale ids
cmp::Ordering::Greater => match self.stale_id {
Some(id) if tx.insertion_id() < id => txpool::Readiness::Stale,
@@ -150,8 +150,8 @@ impl Option> txpool::Ready for Opt
let nonce = self
.nonces
.entry(*sender)
- .or_insert_with(|| state(sender).unwrap_or_else(|| tx.transaction.nonce));
- match tx.transaction.nonce.cmp(nonce) {
+ .or_insert_with(|| state(sender).unwrap_or_else(|| tx.transaction.tx().nonce));
+ match tx.transaction.tx().nonce.cmp(nonce) {
cmp::Ordering::Greater => txpool::Readiness::Future,
cmp::Ordering::Less => txpool::Readiness::Stale,
cmp::Ordering::Equal => {
diff --git a/miner/src/pool/replace.rs b/crates/concensus/miner/src/pool/replace.rs
similarity index 97%
rename from miner/src/pool/replace.rs
rename to crates/concensus/miner/src/pool/replace.rs
index 0e2b7cc95e..d7d9ac1d96 100644
--- a/miner/src/pool/replace.rs
+++ b/crates/concensus/miner/src/pool/replace.rs
@@ -117,7 +117,7 @@ where
mod tests {
use super::*;
- use ethkey::{Generator, KeyPair, Random};
+ use crypto::publickey::{Generator, KeyPair, Random};
use pool::{
scoring::*,
tests::{
@@ -160,7 +160,7 @@ mod tests {
let replace = ReplaceByScoreAndReadiness::new(scoring, client);
// same sender txs
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let same_sender_tx1 = local_tx_verified(
Tx {
@@ -190,7 +190,7 @@ mod tests {
);
// different sender txs
- let sender1 = Random.generate().unwrap();
+ let sender1 = Random.generate();
let different_sender_tx1 = local_tx_verified(
Tx {
nonce: 2,
@@ -200,7 +200,7 @@ mod tests {
&sender1,
);
- let sender2 = Random.generate().unwrap();
+ let sender2 = Random.generate();
let different_sender_tx2 = local_tx_verified(
Tx {
nonce: 1,
@@ -274,7 +274,7 @@ mod tests {
..Default::default()
};
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let txs = vec![tx1, tx2, tx3, tx4]
.into_iter()
.map(|tx| tx.unsigned().sign(keypair.secret(), None).verified())
@@ -440,7 +440,7 @@ mod tests {
let client = TestClient::new().with_nonce(1);
let replace = ReplaceByScoreAndReadiness::new(scoring, client);
- let old_sender = Random.generate().unwrap();
+ let old_sender = Random.generate();
let tx_old_ready_1 = {
let tx = Tx {
nonce: 1,
@@ -518,7 +518,7 @@ mod tests {
tx.signed().verified()
};
- let new_sender = Random.generate().unwrap();
+ let new_sender = Random.generate();
let tx_new_ready_1 = {
let tx = Tx {
nonce: 1,
@@ -586,7 +586,7 @@ mod tests {
tx.signed().verified()
};
- let new_sender = Random.generate().unwrap();
+ let new_sender = Random.generate();
let tx_new_ready_1 = local_tx_verified(
Tx {
nonce: 1,
@@ -641,7 +641,7 @@ mod tests {
tx.signed().verified()
};
- let new_sender = Random.generate().unwrap();
+ let new_sender = Random.generate();
let tx_new_ready_1 = local_tx_verified(
Tx {
nonce: 1,
diff --git a/miner/src/pool/res/big_transaction.data b/crates/concensus/miner/src/pool/res/big_transaction.data
similarity index 100%
rename from miner/src/pool/res/big_transaction.data
rename to crates/concensus/miner/src/pool/res/big_transaction.data
diff --git a/miner/src/pool/scoring.rs b/crates/concensus/miner/src/pool/scoring.rs
similarity index 99%
rename from miner/src/pool/scoring.rs
rename to crates/concensus/miner/src/pool/scoring.rs
index 1b5e164179..d27ada1241 100644
--- a/miner/src/pool/scoring.rs
+++ b/crates/concensus/miner/src/pool/scoring.rs
@@ -67,7 +67,7 @@ impl NonceAndGasPrice {
return true;
}
- &old.transaction.gas_price > new.gas_price()
+ &old.transaction.tx().gas_price > new.gas_price()
}
}
diff --git a/miner/src/pool/tests/client.rs b/crates/concensus/miner/src/pool/tests/client.rs
similarity index 96%
rename from miner/src/pool/tests/client.rs
rename to crates/concensus/miner/src/pool/tests/client.rs
index fc0413690f..05d99f3ed4 100644
--- a/miner/src/pool/tests/client.rs
+++ b/crates/concensus/miner/src/pool/tests/client.rs
@@ -18,7 +18,9 @@ use std::sync::{atomic, Arc};
use ethereum_types::{Address, H256, U256};
use rlp::Rlp;
-use types::transaction::{self, SignedTransaction, Transaction, UnverifiedTransaction};
+use types::transaction::{
+ self, SignedTransaction, Transaction, TypedTransaction, UnverifiedTransaction,
+};
use pool::{self, client::AccountDetails};
@@ -150,7 +152,7 @@ impl pool::client::Client for TestClient {
if rlp.as_raw().len() > self.max_transaction_size {
return Err(transaction::Error::TooBig);
}
- rlp.as_val()
+ TypedTransaction::decode(transaction)
.map_err(|e| transaction::Error::InvalidRlp(e.to_string()))
}
}
diff --git a/miner/src/pool/tests/mod.rs b/crates/concensus/miner/src/pool/tests/mod.rs
similarity index 99%
rename from miner/src/pool/tests/mod.rs
rename to crates/concensus/miner/src/pool/tests/mod.rs
index fb25d66ac9..8d0fc94820 100644
--- a/miner/src/pool/tests/mod.rs
+++ b/crates/concensus/miner/src/pool/tests/mod.rs
@@ -69,7 +69,7 @@ fn should_return_correct_nonces_when_dropped_because_of_limit() {
);
let (tx1, tx2) = Tx::gas_price(2).signed_pair();
let sender = tx1.sender();
- let nonce = tx1.nonce;
+ let nonce = tx1.tx().nonce;
// when
let r1 = txq.import(TestClient::new(), vec![tx1].retracted());
@@ -129,7 +129,7 @@ fn should_never_drop_local_transactions_from_different_senders() {
);
let (tx1, tx2) = Tx::gas_price(2).signed_pair();
let sender = tx1.sender();
- let nonce = tx1.nonce;
+ let nonce = tx1.tx().nonce;
// when
let r1 = txq.import(TestClient::new(), vec![tx1].local());
@@ -662,12 +662,14 @@ fn should_not_replace_same_transaction_if_the_fee_is_less_than_minimal_bump() {
assert_eq!(
txq.pending(client.clone(), PendingSettings::all_prioritized(0, 0))[0]
.signed()
+ .tx()
.gas_price,
U256::from(20)
);
assert_eq!(
txq.pending(client.clone(), PendingSettings::all_prioritized(0, 0))[1]
.signed()
+ .tx()
.gas_price,
U256::from(2)
);
@@ -688,7 +690,7 @@ fn should_return_correct_nonce_when_transactions_from_given_address_exist() {
let txq = new_queue();
let tx = Tx::default().signed();
let from = tx.sender();
- let nonce = tx.nonce;
+ let nonce = tx.tx().nonce;
// when
txq.import(TestClient::new(), vec![tx.local()]);
diff --git a/miner/src/pool/tests/tx.rs b/crates/concensus/miner/src/pool/tests/tx.rs
similarity index 91%
rename from miner/src/pool/tests/tx.rs
rename to crates/concensus/miner/src/pool/tests/tx.rs
index 2e46fe28ef..84187cbd1d 100644
--- a/miner/src/pool/tests/tx.rs
+++ b/crates/concensus/miner/src/pool/tests/tx.rs
@@ -14,10 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with OpenEthereum. If not, see .
+use crypto::publickey::{Generator, Random};
use ethereum_types::{H256, U256};
-use ethkey::{Generator, Random};
use rustc_hex::FromHex;
-use types::transaction::{self, SignedTransaction, Transaction, UnverifiedTransaction};
+use types::transaction::{
+ self, SignedTransaction, Transaction, TypedTransaction, UnverifiedTransaction,
+};
use pool::{verifier, VerifiedTransaction};
@@ -47,7 +49,7 @@ impl Tx {
}
pub fn signed(self) -> SignedTransaction {
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
self.unsigned().sign(keypair.secret(), None)
}
@@ -57,7 +59,7 @@ impl Tx {
}
pub fn signed_triple(mut self) -> (SignedTransaction, SignedTransaction, SignedTransaction) {
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let tx1 = self.clone().unsigned().sign(keypair.secret(), None);
self.nonce += 1;
let tx2 = self.clone().unsigned().sign(keypair.secret(), None);
@@ -68,7 +70,7 @@ impl Tx {
}
pub fn signed_replacement(mut self) -> (SignedTransaction, SignedTransaction) {
- let keypair = Random.generate().unwrap();
+ let keypair = Random.generate();
let tx1 = self.clone().unsigned().sign(keypair.secret(), None);
self.gas_price += 1;
let tx2 = self.unsigned().sign(keypair.secret(), None);
@@ -76,20 +78,20 @@ impl Tx {
(tx1, tx2)
}
- pub fn unsigned(self) -> Transaction {
- Transaction {
+ pub fn unsigned(self) -> TypedTransaction {
+ TypedTransaction::Legacy(Transaction {
action: transaction::Action::Create,
value: U256::from(100),
data: "3331600055".from_hex().unwrap(),
gas: self.gas.into(),
gas_price: self.gas_price.into(),
nonce: self.nonce.into(),
- }
+ })
}
pub fn big_one(self) -> SignedTransaction {
- let keypair = Random.generate().unwrap();
- let tx = Transaction {
+ let keypair = Random.generate();
+ let tx = TypedTransaction::Legacy(Transaction {
action: transaction::Action::Create,
value: U256::from(100),
data: include_str!("../res/big_transaction.data")
@@ -98,7 +100,7 @@ impl Tx {
gas: self.gas.into(),
gas_price: self.gas_price.into(),
nonce: self.nonce.into(),
- };
+ });
tx.sign(keypair.secret(), None)
}
}
diff --git a/crates/concensus/miner/src/pool/transaction_filter.rs b/crates/concensus/miner/src/pool/transaction_filter.rs
new file mode 100644
index 0000000000..b261fd08a8
--- /dev/null
+++ b/crates/concensus/miner/src/pool/transaction_filter.rs
@@ -0,0 +1,129 @@
+// Copyright 2015-2021 Parity Technologies (UK) Ltd.
+// This file is part of OpenEthereum.
+
+// OpenEthereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// OpenEthereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with OpenEthereum. If not, see .
+
+//! Filter options available in the parity_pendingTransaction endpoint of the JSONRPC API.
+
+#![allow(missing_docs)]
+
+use ethereum_types::{Address, U256};
+
+use pool::VerifiedTransaction;
+use types::transaction::Action;
+
+#[allow(non_camel_case_types)]
+#[derive(Debug, Deserialize, Serialize)]
+#[serde()]
+pub enum SenderArgument {
+ eq(Address),
+ None,
+}
+
+impl Default for SenderArgument {
+ fn default() -> Self {
+ Self::None
+ }
+}
+
+impl SenderArgument {
+ fn matches(&self, value: &Address) -> bool {
+ match self {
+ Self::eq(expected) => value == expected,
+ Self::None => true,
+ }
+ }
+}
+
+#[allow(non_camel_case_types)]
+#[derive(Debug, Deserialize, Serialize)]
+#[serde()]
+pub enum ActionArgument {
+ eq(Address),
+ action(String),
+ None,
+}
+
+impl Default for ActionArgument {
+ fn default() -> Self {
+ Self::None
+ }
+}
+
+impl ActionArgument {
+ fn matches(&self, value: &Action) -> bool {
+ match self {
+ Self::eq(expected) => *value == Action::Call(*expected),
+ Self::action(name) => *value == Action::Create && name == "contract_creation",
+ Self::None => true,
+ }
+ }
+}
+
+#[allow(non_camel_case_types)]
+#[derive(Debug, Deserialize, Serialize)]
+#[serde()]
+pub enum ValueFilterArgument {
+ eq(U256),
+ lt(U256),
+ gt(U256),
+ None,
+}
+
+impl Default for ValueFilterArgument {
+ fn default() -> Self {
+ Self::None
+ }
+}
+
+impl ValueFilterArgument {
+ fn matches(&self, value: &U256) -> bool {
+ match self {
+ ValueFilterArgument::eq(expected) => value == expected,
+ ValueFilterArgument::lt(threshold) => value < threshold,
+ ValueFilterArgument::gt(threshold) => value > threshold,
+ ValueFilterArgument::None => true,
+ }
+ }
+}
+
+#[derive(Debug, Default, Deserialize, Serialize)]
+#[serde(default, rename_all = "camelCase")]
+pub struct TransactionFilter {
+ from: SenderArgument,
+ to: ActionArgument,
+ gas: ValueFilterArgument,
+ gas_price: ValueFilterArgument,
+ value: ValueFilterArgument,
+ nonce: ValueFilterArgument,
+}
+
+impl TransactionFilter {
+ pub fn matches(&self, transaction: &VerifiedTransaction) -> bool {
+ let tx = transaction.signed().tx();
+ self.from.matches(&transaction.sender)
+ && self.to.matches(&tx.action)
+ && self.gas.matches(&tx.gas)
+ && self.gas_price.matches(&tx.gas_price)
+ && self.nonce.matches(&tx.nonce)
+ && self.value.matches(&tx.value)
+ }
+}
+
+pub fn match_filter(filter: &Option, transaction: &VerifiedTransaction) -> bool {
+ match filter {
+ Some(f) => f.matches(transaction),
+ None => true,
+ }
+}
diff --git a/miner/src/pool/verifier.rs b/crates/concensus/miner/src/pool/verifier.rs
similarity index 90%
rename from miner/src/pool/verifier.rs
rename to crates/concensus/miner/src/pool/verifier.rs
index cf4e116de8..aa19991214 100644
--- a/miner/src/pool/verifier.rs
+++ b/crates/concensus/miner/src/pool/verifier.rs
@@ -31,7 +31,6 @@ use std::{
};
use ethereum_types::{H256, U256};
-use rlp::Encodable;
use txpool;
use types::transaction;
@@ -97,21 +96,21 @@ impl Transaction {
/// Return transaction gas price
pub fn gas_price(&self) -> &U256 {
match *self {
- Transaction::Unverified(ref tx) => &tx.gas_price,
- Transaction::Retracted(ref tx) => &tx.gas_price,
- Transaction::Local(ref tx) => &tx.gas_price,
+ Transaction::Unverified(ref tx) => &tx.tx().gas_price,
+ Transaction::Retracted(ref tx) => &tx.tx().gas_price,
+ Transaction::Local(ref tx) => &tx.tx().gas_price,
}
}
fn gas(&self) -> &U256 {
match *self {
- Transaction::Unverified(ref tx) => &tx.gas,
- Transaction::Retracted(ref tx) => &tx.gas,
- Transaction::Local(ref tx) => &tx.gas,
+ Transaction::Unverified(ref tx) => &tx.tx().gas,
+ Transaction::Retracted(ref tx) => &tx.tx().gas,
+ Transaction::Local(ref tx) => &tx.tx().gas,
}
}
- fn transaction(&self) -> &transaction::Transaction {
+ fn transaction(&self) -> &transaction::TypedTransaction {
match *self {
Transaction::Unverified(ref tx) => &*tx,
Transaction::Retracted(ref tx) => &*tx,
@@ -198,7 +197,7 @@ impl txpool::Verifier
});
}
- let minimal_gas = self.client.required_gas(tx.transaction());
+ let minimal_gas = self.client.required_gas(tx.transaction().tx());
if tx.gas() < &minimal_gas {
trace!(target: "txqueue",
"[{:?}] Rejected transaction with insufficient gas: {} < {}",
@@ -240,10 +239,10 @@ impl txpool::Verifier
"[{:?}] Rejected tx early, cause it doesn't have any chance to get to the pool: (gas price: {} < {})",
hash,
tx.gas_price(),
- vtx.transaction.gas_price,
+ vtx.transaction.tx().gas_price,
);
return Err(transaction::Error::TooCheapToReplace {
- prev: Some(vtx.transaction.gas_price),
+ prev: Some(vtx.transaction.tx().gas_price),
new: Some(*tx.gas_price()),
});
}
@@ -273,7 +272,7 @@ impl txpool::Verifier
};
// Verify RLP payload
- if let Err(err) = self.client.decode_transaction(&transaction.rlp_bytes()) {
+ if let Err(err) = self.client.decode_transaction(&transaction.encode()) {
debug!(target: "txqueue", "[{:?}] Rejected transaction's rlp payload", err);
bail!(err)
}
@@ -281,7 +280,7 @@ impl txpool::Verifier
let sender = transaction.sender();
let account_details = self.client.account_details(&sender);
- if transaction.gas_price < self.options.minimal_gas_price {
+ if transaction.tx().gas_price < self.options.minimal_gas_price {
let transaction_type = self.client.transaction_type(&transaction);
if let TransactionType::Service = transaction_type {
debug!(target: "txqueue", "Service tx {:?} below minimal gas price accepted", hash);
@@ -292,18 +291,21 @@ impl txpool::Verifier
target: "txqueue",
"[{:?}] Rejected tx below minimal gas price threshold: {} < {}",
hash,
- transaction.gas_price,
+ transaction.tx().gas_price,
self.options.minimal_gas_price,
);
bail!(transaction::Error::InsufficientGasPrice {
minimal: self.options.minimal_gas_price,
- got: transaction.gas_price,
+ got: transaction.tx().gas_price,
});
}
}
- let (full_gas_price, overflow_1) = transaction.gas_price.overflowing_mul(transaction.gas);
- let (cost, overflow_2) = transaction.value.overflowing_add(full_gas_price);
+ let (full_gas_price, overflow_1) = transaction
+ .tx()
+ .gas_price
+ .overflowing_mul(transaction.tx().gas);
+ let (cost, overflow_2) = transaction.tx().value.overflowing_add(full_gas_price);
if overflow_1 || overflow_2 {
trace!(
target: "txqueue",
@@ -329,12 +331,12 @@ impl txpool::Verifier
});
}
- if transaction.nonce < account_details.nonce {
+ if transaction.tx().nonce < account_details.nonce {
debug!(
target: "txqueue",
"[{:?}] Rejected tx with old nonce ({} < {})",
hash,
- transaction.nonce,
+ transaction.tx().nonce,
account_details.nonce,
);
bail!(transaction::Error::Old);
diff --git a/miner/src/service_transaction_checker.rs b/crates/concensus/miner/src/service_transaction_checker.rs
similarity index 99%
rename from miner/src/service_transaction_checker.rs
rename to crates/concensus/miner/src/service_transaction_checker.rs
index e6917568c4..f426571fa6 100644
--- a/miner/src/service_transaction_checker.rs
+++ b/crates/concensus/miner/src/service_transaction_checker.rs
@@ -45,7 +45,7 @@ impl ServiceTransactionChecker {
) -> Result {
let sender = tx.sender();
// Skip checking the contract if the transaction does not have zero gas price
- if !tx.gas_price.is_zero() {
+ if !tx.tx().gas_price.is_zero() {
return Ok(false);
}
diff --git a/miner/src/work_notify.rs b/crates/concensus/miner/src/work_notify.rs
similarity index 100%
rename from miner/src/work_notify.rs
rename to crates/concensus/miner/src/work_notify.rs
diff --git a/miner/stratum/Cargo.toml b/crates/concensus/miner/stratum/Cargo.toml
similarity index 87%
rename from miner/stratum/Cargo.toml
rename to crates/concensus/miner/stratum/Cargo.toml
index a4977555e5..2b1248576b 100644
--- a/miner/stratum/Cargo.toml
+++ b/crates/concensus/miner/stratum/Cargo.toml
@@ -6,8 +6,8 @@ license = "GPL-3.0"
authors = ["Parity Technologies "]
[dependencies]
-ethereum-types = "0.4"
-keccak-hash = "0.1"
+ethereum-types = "0.9.2"
+keccak-hash = "0.5.0"
jsonrpc-core = "15.0.0"
jsonrpc-tcp-server = "15.0.0"
log = "0.4"
diff --git a/miner/stratum/src/lib.rs b/crates/concensus/miner/stratum/src/lib.rs
similarity index 100%
rename from miner/stratum/src/lib.rs
rename to crates/concensus/miner/stratum/src/lib.rs
diff --git a/miner/stratum/src/traits.rs b/crates/concensus/miner/stratum/src/traits.rs
similarity index 100%
rename from miner/stratum/src/traits.rs
rename to crates/concensus/miner/stratum/src/traits.rs
diff --git a/miner/using-queue/Cargo.toml b/crates/concensus/miner/using-queue/Cargo.toml
similarity index 100%
rename from miner/using-queue/Cargo.toml
rename to crates/concensus/miner/using-queue/Cargo.toml
diff --git a/miner/using-queue/src/lib.rs b/crates/concensus/miner/using-queue/src/lib.rs
similarity index 100%
rename from miner/using-queue/src/lib.rs
rename to crates/concensus/miner/using-queue/src/lib.rs
diff --git a/util/bloom/Cargo.toml b/crates/db/bloom/Cargo.toml
similarity index 100%
rename from util/bloom/Cargo.toml
rename to crates/db/bloom/Cargo.toml
diff --git a/util/bloom/src/lib.rs b/crates/db/bloom/src/lib.rs
similarity index 100%
rename from util/bloom/src/lib.rs
rename to crates/db/bloom/src/lib.rs
diff --git a/util/blooms-db/Cargo.toml b/crates/db/blooms-db/Cargo.toml
similarity index 92%
rename from util/blooms-db/Cargo.toml
rename to crates/db/blooms-db/Cargo.toml
index 543a798772..a531ca5d60 100644
--- a/util/blooms-db/Cargo.toml
+++ b/crates/db/blooms-db/Cargo.toml
@@ -6,7 +6,7 @@ authors = ["Parity Technologies "]
[dependencies]
byteorder = "1.2"
-ethbloom = "=0.5.0"
+ethbloom = "0.9.1"
parking_lot = "0.7"
tiny-keccak = "1.4"
diff --git a/util/blooms-db/benches/blooms.rs b/crates/db/blooms-db/benches/blooms.rs
similarity index 93%
rename from util/blooms-db/benches/blooms.rs
rename to crates/db/blooms-db/benches/blooms.rs
index 42f59c37b4..9713a676ae 100644
--- a/util/blooms-db/benches/blooms.rs
+++ b/crates/db/blooms-db/benches/blooms.rs
@@ -40,7 +40,7 @@ fn bench_blooms_filter_1_million_ok(c: &mut Criterion) {
database
.insert_blooms(999_999, iter::once(&Bloom::zero()))
.unwrap();
- let bloom = Bloom::from(0x001);
+ let bloom = Bloom::from_low_u64_be(0x001);
database.insert_blooms(200_000, iter::once(&bloom)).unwrap();
database.insert_blooms(400_000, iter::once(&bloom)).unwrap();
database.insert_blooms(600_000, iter::once(&bloom)).unwrap();
@@ -60,8 +60,8 @@ fn bench_blooms_filter_1_million_miss(c: &mut Criterion) {
database
.insert_blooms(999_999, iter::once(&Bloom::zero()))
.unwrap();
- let bloom = Bloom::from(0x001);
- let bad_bloom = Bloom::from(0x0001);
+ let bloom = Bloom::from_low_u64_be(0x001);
+ let bad_bloom = Bloom::from_low_u64_be(0x0001);
database.insert_blooms(200_000, iter::once(&bloom)).unwrap();
database.insert_blooms(400_000, iter::once(&bloom)).unwrap();
database.insert_blooms(600_000, iter::once(&bloom)).unwrap();
@@ -81,8 +81,8 @@ fn bench_blooms_filter_1_million_miss_and_ok(c: &mut Criterion) {
database
.insert_blooms(999_999, iter::once(&Bloom::zero()))
.unwrap();
- let bloom = Bloom::from(0x001);
- let bad_bloom = Bloom::from(0x0001);
+ let bloom = Bloom::from_low_u64_be(0x001);
+ let bad_bloom = Bloom::from_low_u64_be(0x0001);
database.insert_blooms(200_000, iter::once(&bloom)).unwrap();
database.insert_blooms(400_000, iter::once(&bloom)).unwrap();
database.insert_blooms(600_000, iter::once(&bloom)).unwrap();
diff --git a/util/blooms-db/src/db.rs b/crates/db/blooms-db/src/db.rs
similarity index 90%
rename from util/blooms-db/src/db.rs
rename to crates/db/blooms-db/src/db.rs
index 752120b269..f174ffeb13 100644
--- a/util/blooms-db/src/db.rs
+++ b/crates/db/blooms-db/src/db.rs
@@ -346,59 +346,59 @@ mod tests {
.insert_blooms(
0,
vec![
- Bloom::from(0),
- Bloom::from(0x01),
- Bloom::from(0x10),
- Bloom::from(0x11),
+ Bloom::zero(),
+ Bloom::from_low_u64_be(0x01),
+ Bloom::from_low_u64_be(0x10),
+ Bloom::from_low_u64_be(0x11),
]
.iter(),
)
.unwrap();
let matches = database
- .iterate_matching(0, 3, Some(&Bloom::from(0)))
+ .iterate_matching(0, 3, Some(&Bloom::zero()))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![0, 1, 2, 3]);
let matches = database
- .iterate_matching(0, 4, Some(&Bloom::from(0)))
+ .iterate_matching(0, 4, Some(&Bloom::zero()))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![0, 1, 2, 3]);
let matches = database
- .iterate_matching(1, 3, Some(&Bloom::from(0)))
+ .iterate_matching(1, 3, Some(&Bloom::zero()))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![1, 2, 3]);
let matches = database
- .iterate_matching(1, 2, Some(&Bloom::from(0)))
+ .iterate_matching(1, 2, Some(&Bloom::zero()))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![1, 2]);
let matches = database
- .iterate_matching(0, 3, Some(&Bloom::from(0x01)))
+ .iterate_matching(0, 3, Some(&Bloom::from_low_u64_be(0x01)))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![1, 3]);
let matches = database
- .iterate_matching(0, 3, Some(&Bloom::from(0x10)))
+ .iterate_matching(0, 3, Some(&Bloom::from_low_u64_be(0x10)))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![2, 3]);
let matches = database
- .iterate_matching(2, 2, Some(&Bloom::from(0x10)))
+ .iterate_matching(2, 2, Some(&Bloom::from_low_u64_be(0x10)))
.unwrap()
.collect::, _>>()
.unwrap();
@@ -413,52 +413,52 @@ mod tests {
.insert_blooms(
254,
vec![
- Bloom::from(0x100),
- Bloom::from(0x01),
- Bloom::from(0x10),
- Bloom::from(0x11),
+ Bloom::from_low_u64_be(0x100),
+ Bloom::from_low_u64_be(0x01),
+ Bloom::from_low_u64_be(0x10),
+ Bloom::from_low_u64_be(0x11),
]
.iter(),
)
.unwrap();
let matches = database
- .iterate_matching(0, 257, Some(&Bloom::from(0x01)))
+ .iterate_matching(0, 257, Some(&Bloom::from_low_u64_be(0x01)))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![255, 257]);
let matches = database
- .iterate_matching(0, 258, Some(&Bloom::from(0x100)))
+ .iterate_matching(0, 258, Some(&Bloom::from_low_u64_be(0x100)))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![254]);
let matches = database
- .iterate_matching(0, 256, Some(&Bloom::from(0x01)))
+ .iterate_matching(0, 256, Some(&Bloom::from_low_u64_be(0x01)))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![255]);
let matches = database
- .iterate_matching(255, 255, Some(&Bloom::from(0x01)))
+ .iterate_matching(255, 255, Some(&Bloom::from_low_u64_be(0x01)))
.unwrap()
.collect::, _>>()
.unwrap();
assert_eq!(matches, vec![255]);
let matches = database
- .iterate_matching(256, 256, Some(&Bloom::from(0x10)))
+ .iterate_matching(256, 256, Some(&Bloom::from_low_u64_be(0x10)))
.unwrap()
.collect::