Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f04fc452dc | |||
| be90d03129 | |||
| 0a3e42700c | |||
| 55d554701c | |||
| 19c4769260 | |||
| 71aadc8e1b | |||
| 95340b5817 | |||
| 12751665bb | |||
| 01b86bcc0d | |||
| c6ce8caaf7 | |||
| 265713b9d2 | |||
| c9af4721f3 | |||
| 8c0ab7c697 | |||
| 92b220ca4b | |||
| c218cba96c | |||
| c958975fff |
@@ -1,113 +0,0 @@
|
||||
name: Build and upload binaries to CI
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- 'clients/**'
|
||||
- 'common/**'
|
||||
- 'contracts/**'
|
||||
- 'explorer-api/**'
|
||||
- 'gateway/**'
|
||||
- 'integrations/**'
|
||||
- 'mixnode/**'
|
||||
- 'sdk/rust/nym-sdk/**'
|
||||
- 'service-providers/**'
|
||||
- 'nym-api/**'
|
||||
- 'nym-outfox/**'
|
||||
- 'tools/nym-cli/**'
|
||||
- 'tools/ts-rs-cli/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'clients/**'
|
||||
- 'common/**'
|
||||
- 'contracts/**'
|
||||
- 'explorer-api/**'
|
||||
- 'gateway/**'
|
||||
- 'integrations/**'
|
||||
- 'mixnode/**'
|
||||
- 'sdk/rust/nym-sdk/**'
|
||||
- 'service-providers/**'
|
||||
- 'nym-api/**'
|
||||
- 'nym-outfox/**'
|
||||
- 'tools/nym-cli/**'
|
||||
- 'tools/ts-rs-cli/**'
|
||||
|
||||
env:
|
||||
NETWORK: mainnet
|
||||
|
||||
jobs:
|
||||
publish-nym:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [ubuntu-20.04]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare build output directory
|
||||
shell: bash
|
||||
env:
|
||||
OUTPUT_DIR: ci-builds/${{ github.ref_name }}
|
||||
run: |
|
||||
rm -rf ci-builds || true
|
||||
mkdir -p $OUTPUT_DIR
|
||||
echo $OUTPUT_DIR
|
||||
|
||||
- name: Install Dependencies (Linux)
|
||||
run: sudo apt-get update && sudo apt-get -y install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools
|
||||
continue-on-error: true
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Build all binaries
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --workspace --release
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: wasm32-unknown-unknown
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Build release contracts
|
||||
run: make wasm
|
||||
|
||||
- name: Prepare build output
|
||||
shell: bash
|
||||
env:
|
||||
OUTPUT_DIR: ci-builds/${{ github.ref_name }}
|
||||
run: |
|
||||
cp target/release/nym-client $OUTPUT_DIR
|
||||
cp target/release/nym-gateway $OUTPUT_DIR
|
||||
cp target/release/nym-mixnode $OUTPUT_DIR
|
||||
cp target/release/nym-socks5-client $OUTPUT_DIR
|
||||
cp target/release/nym-api $OUTPUT_DIR
|
||||
cp target/release/nym-network-requester $OUTPUT_DIR
|
||||
cp target/release/nym-network-statistics $OUTPUT_DIR
|
||||
cp target/release/nym-cli $OUTPUT_DIR
|
||||
|
||||
cp contracts/target/wasm32-unknown-unknown/release/mixnet_contract.wasm $OUTPUT_DIR
|
||||
cp contracts/target/wasm32-unknown-unknown/release/vesting_contract.wasm $OUTPUT_DIR
|
||||
|
||||
- name: Deploy branch to CI www
|
||||
continue-on-error: true
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.CI_WWW_SSH_PRIVATE_KEY }}
|
||||
ARGS: "-avzr"
|
||||
SOURCE: "ci-builds/"
|
||||
REMOTE_HOST: ${{ secrets.CI_WWW_REMOTE_HOST }}
|
||||
REMOTE_USER: ${{ secrets.CI_WWW_REMOTE_USER }}
|
||||
TARGET: ${{ secrets.CI_WWW_REMOTE_TARGET }}/builds/
|
||||
EXCLUDE: "/dist/, /node_modules/"
|
||||
|
||||
+28
-30
@@ -2,33 +2,11 @@ name: Continuous integration
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'clients/**'
|
||||
- 'common/**'
|
||||
- 'explorer-api/**'
|
||||
- 'gateway/**'
|
||||
- 'integrations/**'
|
||||
- 'mixnode/**'
|
||||
- 'sdk/rust/nym-sdk/**'
|
||||
- 'service-providers/**'
|
||||
- 'nym-api/**'
|
||||
- 'nym-outfox/**'
|
||||
- 'tools/nym-cli/**'
|
||||
- 'tools/ts-rs-cli/**'
|
||||
paths-ignore:
|
||||
- 'explorer/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'clients/**'
|
||||
- 'common/**'
|
||||
- 'explorer-api/**'
|
||||
- 'gateway/**'
|
||||
- 'integrations/**'
|
||||
- 'mixnode/**'
|
||||
- 'sdk/rust/nym-sdk/**'
|
||||
- 'service-providers/**'
|
||||
- 'nym-api/**'
|
||||
- 'nym-outfox/**'
|
||||
- 'tools/nym-cli/**'
|
||||
- 'tools/ts-rs-cli/**'
|
||||
paths-ignore:
|
||||
- 'explorer/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -74,24 +52,44 @@ jobs:
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --workspace
|
||||
args: --workspace --all-features
|
||||
|
||||
- name: Run expensive tests
|
||||
if: github.ref == 'refs/heads/develop' || github.event.pull_request.base.ref == 'develop' || github.event.pull_request.base.ref == 'master'
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --workspace -- --ignored
|
||||
args: --workspace --all-features -- --ignored
|
||||
|
||||
- uses: actions-rs/clippy-check@v1
|
||||
name: Clippy checks
|
||||
continue-on-error: true
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --workspace
|
||||
args: --workspace --all-features
|
||||
|
||||
- name: Run clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: --workspace --all-targets -- -D warnings
|
||||
args: --workspace --all-targets --all-features -- -D warnings
|
||||
|
||||
# COCONUT stuff
|
||||
|
||||
- name: Build all binaries with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --workspace --features=coconut
|
||||
|
||||
- name: Run all tests with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --workspace --features=coconut
|
||||
|
||||
- name: Run clippy with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: --all-targets --features=coconut -- -D warnings
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
name: Nym Connect for Android (rust)
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "nym-connect-android/src-tauri/**"
|
||||
- "clients/client-core/**"
|
||||
- "clients/socks5/**"
|
||||
- "common/**"
|
||||
- "gateway/gateway-requests/**"
|
||||
- "contracts/vesting/**"
|
||||
- "nym-api/nym-api-requests/**"
|
||||
pull_request:
|
||||
paths:
|
||||
- "nym-connect-android/src-tauri/**"
|
||||
- "clients/client-core/**"
|
||||
- "clients/socks5/**"
|
||||
- "common/**"
|
||||
- "gateway/gateway-requests/**"
|
||||
- "contracts/vesting/**"
|
||||
- "nym-api/nym-api-requests/**"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
#runs-on: [self-hosted, custom-linux]
|
||||
runs-on: ubuntu-22.04
|
||||
#env:
|
||||
#RUSTC_WRAPPER: /home/ubuntu/.cargo/bin/sccache
|
||||
#defaults:
|
||||
#run:
|
||||
#working-directory: nym-connect-android/src-tauri/
|
||||
steps:
|
||||
- name: Install Dependencies (Linux)
|
||||
if: ${{ !env.ACT }}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install \
|
||||
libwebkit2gtk-4.1-dev \
|
||||
build-essential \
|
||||
curl \
|
||||
wget \
|
||||
libssl-dev \
|
||||
libgtk-3-dev \
|
||||
squashfs-tools \
|
||||
libayatana-appindicator3-dev \
|
||||
librsvg2-dev \
|
||||
libsoup-3.0-dev \
|
||||
libjavascriptcoregtk-4.1-dev
|
||||
#continue-on-error: true
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable
|
||||
components: clippy, rustfmt
|
||||
|
||||
- name: Check formatting
|
||||
run: cargo fmt --manifest-path nym-connect-android/src-tauri/Cargo.toml -- --check
|
||||
|
||||
- name: Build all binaries
|
||||
run: cargo build --manifest-path nym-connect-android/src-tauri/Cargo.toml
|
||||
|
||||
- name: Run all tests
|
||||
run: cargo test --manifest-path nym-connect-android/src-tauri/Cargo.toml
|
||||
|
||||
- name: Clippy
|
||||
run: cargo clippy --manifest-path nym-connect-android/src-tauri/Cargo.toml --all-targets -- -D warnings
|
||||
@@ -2,23 +2,8 @@ name: Nym Connect (rust)
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'nym-connect/**'
|
||||
- 'clients/client-core/**'
|
||||
- 'clients/socks5/**'
|
||||
- 'common/**'
|
||||
- 'gateway/gateway-requests/**'
|
||||
- 'contracts/vesting/**'
|
||||
- 'nym-api/nym-api-requests/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'nym-connect/**'
|
||||
- 'clients/client-core/**'
|
||||
- 'clients/socks5/**'
|
||||
- 'common/**'
|
||||
- 'gateway/gateway-requests/**'
|
||||
- 'contracts/vesting/**'
|
||||
- 'nym-api/nym-api-requests/**'
|
||||
paths-ignore:
|
||||
- 'explorer/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -6,11 +6,17 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-contracts-') && github.event_name == 'release' }}
|
||||
runs-on: [self-hosted, custom-runner-linux]
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Check the release tag starts with `nym-contracts-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-contracts-') == false && github.event_name != 'workflow_dispatch'
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release tag did not start with nym-contracts-...')
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
|
||||
@@ -2,13 +2,11 @@ name: Contracts
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'contracts/**'
|
||||
- 'common/**'
|
||||
paths-ignore:
|
||||
- 'explorer/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'contracts/**'
|
||||
- 'common/**'
|
||||
- 'explorer/**'
|
||||
|
||||
jobs:
|
||||
matrix_prep:
|
||||
|
||||
@@ -10,7 +10,6 @@ env:
|
||||
|
||||
jobs:
|
||||
publish-nym:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-explorer-api-') && (github.event_name == 'release' || github.event_name == 'workflow_dispatch') }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -25,6 +24,7 @@ jobs:
|
||||
continue-on-error: true
|
||||
|
||||
- name: Check the release tag starts with `nym-explorer-api-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-explorer-api-') == false && github.event_name != 'workflow_dispatch'
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
|
||||
- name: Reclaim some disk space (because Windows is being annoying)
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-20.04' }}
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
with:
|
||||
command: clean
|
||||
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --workspace -- --ignored
|
||||
args: --workspace --all-features -- --ignored
|
||||
|
||||
- name: Reclaim some disk space (because Windows is being annoying)
|
||||
uses: actions-rs/cargo@v1
|
||||
@@ -99,14 +99,14 @@ jobs:
|
||||
continue-on-error: true
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: --workspace
|
||||
args: --all-features
|
||||
|
||||
- name: Run clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.rust != 'nightly' }}
|
||||
with:
|
||||
command: clippy
|
||||
args: --workspace --all-targets -- -D warnings
|
||||
args: --workspace --all-targets --all-features -- -D warnings
|
||||
|
||||
- name: Reclaim some disk space
|
||||
uses: actions-rs/cargo@v1
|
||||
@@ -114,6 +114,38 @@ jobs:
|
||||
with:
|
||||
command: clean
|
||||
|
||||
# COCONUT stuff
|
||||
- name: Build all binaries with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --workspace --features=coconut
|
||||
|
||||
- name: Reclaim some disk space (because Windows is being annoying)
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
with:
|
||||
command: clean
|
||||
|
||||
- name: Run all tests with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --workspace --features=coconut
|
||||
|
||||
- name: Reclaim some disk space (because Windows is being annoying)
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
with:
|
||||
command: clean
|
||||
|
||||
- name: Run clippy with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.rust != 'nightly' }}
|
||||
with:
|
||||
command: clippy
|
||||
args: --workspace --all-targets --features=coconut -- -D warnings
|
||||
|
||||
# nym-wallet (the rust part)
|
||||
- name: Build nym-wallet rust code
|
||||
uses: actions-rs/cargo@v1
|
||||
|
||||
@@ -117,6 +117,38 @@ jobs:
|
||||
with:
|
||||
command: clean
|
||||
|
||||
# COCONUT stuff
|
||||
- name: Build all binaries with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --workspace --features=coconut
|
||||
|
||||
- name: Reclaim some disk space (because Windows is being annoying)
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
with:
|
||||
command: clean
|
||||
|
||||
- name: Run all tests with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --workspace --features=coconut
|
||||
|
||||
- name: Reclaim some disk space (because Windows is being annoying)
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
with:
|
||||
command: clean
|
||||
|
||||
- name: Run clippy with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.rust != 'nightly' }}
|
||||
with:
|
||||
command: clippy
|
||||
args: --workspace --all-targets --features=coconut -- -D warnings
|
||||
|
||||
# nym-wallet (the rust part)
|
||||
- name: Build nym-wallet rust code
|
||||
uses: actions-rs/cargo@v1
|
||||
|
||||
@@ -117,6 +117,38 @@ jobs:
|
||||
with:
|
||||
command: clean
|
||||
|
||||
# COCONUT stuff
|
||||
- name: Build all binaries with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --workspace --features=coconut
|
||||
|
||||
- name: Reclaim some disk space (because Windows is being annoying)
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
with:
|
||||
command: clean
|
||||
|
||||
- name: Run all tests with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --workspace --features=coconut
|
||||
|
||||
- name: Reclaim some disk space (because Windows is being annoying)
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
with:
|
||||
command: clean
|
||||
|
||||
- name: Run clippy with coconut enabled
|
||||
uses: actions-rs/cargo@v1
|
||||
if: ${{ matrix.rust != 'nightly' }}
|
||||
with:
|
||||
command: clippy
|
||||
args: --workspace --all-targets --features=coconut -- -D warnings
|
||||
|
||||
# nym-wallet (the rust part)
|
||||
- name: Build nym-wallet rust code
|
||||
uses: actions-rs/cargo@v1
|
||||
|
||||
@@ -10,7 +10,6 @@ env:
|
||||
|
||||
jobs:
|
||||
publish-nym-cli:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-cli-') && (github.event_name == 'release' || github.event_name = 'workflow_dispatch') }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -21,6 +20,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Check the release tag starts with `nym-cli-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-cli-') == false && github.event_name != 'workflow_dispatch'
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
|
||||
@@ -10,7 +10,6 @@ defaults:
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-connect-') && github.event_name == 'release' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -20,6 +19,13 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Check the release tag starts with `nym-connect-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-connect-') == false && github.event_name != 'workflow_dispatch'
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release tag did not start with nym-connect-...')
|
||||
|
||||
- name: Node v16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
|
||||
@@ -10,11 +10,10 @@ defaults:
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-connect-') && github.event_name == 'release' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [custom-runner-linux]
|
||||
platform: [ubuntu-20.04]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
@@ -25,12 +24,17 @@ jobs:
|
||||
sudo apt-get update &&
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
|
||||
continue-on-error: true
|
||||
- name: Check the release tag starts with `nym-connect-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-connect-') == false && github.event_name != 'workflow_dispatch'
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release tag did not start with nym-connect-...')
|
||||
|
||||
- name: Node v16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
|
||||
@@ -10,7 +10,6 @@ defaults:
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-connect-') && github.event_name == 'release' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -28,6 +27,13 @@ jobs:
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Check the release tag starts with `nym-connect-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-connect-') == false && github.event_name != 'workflow_dispatch'
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release tag did not start with nym-connect-...')
|
||||
|
||||
- name: Import signing certificate
|
||||
env:
|
||||
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
||||
|
||||
@@ -16,11 +16,10 @@ env:
|
||||
|
||||
jobs:
|
||||
publish-nym:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-binaries-') && github.event_name == 'release' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [custom-runner-linux]
|
||||
platform: [ubuntu-20.04]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
@@ -29,6 +28,13 @@ jobs:
|
||||
- name: Install Dependencies (Linux)
|
||||
run: sudo apt-get update && sudo apt-get -y install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools
|
||||
continue-on-error: true
|
||||
|
||||
- name: Check the release tag starts with `nym-binaries-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-binaries-') == false && github.event_name != 'workflow_dispatch'
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release tag did not start with nym-binaries-...')
|
||||
|
||||
- name: Sets env vars for tokio if set in manual dispatch inputs
|
||||
run: |
|
||||
@@ -51,7 +57,6 @@ jobs:
|
||||
with:
|
||||
name: my-artifact
|
||||
path: |
|
||||
target/release/explorer-api
|
||||
target/release/nym-client
|
||||
target/release/nym-gateway
|
||||
target/release/nym-mixnode
|
||||
@@ -67,7 +72,6 @@ jobs:
|
||||
if: github.event_name == 'release'
|
||||
with:
|
||||
files: |
|
||||
target/release/explorer-api
|
||||
target/release/nym-client
|
||||
target/release/nym-gateway
|
||||
target/release/nym-mixnode
|
||||
|
||||
@@ -10,7 +10,6 @@ defaults:
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-wallet-') && github.event_name == 'release' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -20,6 +19,13 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Check the release tag starts with `nym-wallet-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-wallet-') == false && github.event_name != 'workflow_dispatch'
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release tag did not start with nym-wallet-...')
|
||||
|
||||
- name: Node v16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
|
||||
@@ -9,11 +9,10 @@ defaults:
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-wallet-') && github.event_name == 'release' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [custom-runner-linux]
|
||||
platform: [ubuntu-20.04]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
@@ -24,12 +23,17 @@ jobs:
|
||||
sudo apt-get update &&
|
||||
sudo apt-get install -y webkit2gtk-4.0
|
||||
continue-on-error: true
|
||||
- name: Check the release tag starts with `nym-wallet-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-wallet-') == false
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release tag did not start with nym-wallet-...')
|
||||
|
||||
- name: Node v16
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
|
||||
@@ -9,7 +9,6 @@ defaults:
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-wallet-') && github.event_name == 'release' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -27,6 +26,13 @@ jobs:
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Check the release tag starts with `nym-wallet-`
|
||||
if: startsWith(github.ref, 'refs/tags/nym-wallet-') == false
|
||||
uses: actions/github-script@v3
|
||||
with:
|
||||
script: |
|
||||
core.setFailed('Release tag did not start with nym-wallet-...')
|
||||
|
||||
- name: Import signing certificate
|
||||
env:
|
||||
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
||||
|
||||
@@ -6,7 +6,6 @@ on:
|
||||
- 'ts-packages/**'
|
||||
- 'sdk/typescript/**'
|
||||
- nym-connect
|
||||
- nym-connect-android
|
||||
- nym-wallet
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -2,17 +2,11 @@ name: Nym Wallet (rust)
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'nym-wallet/**'
|
||||
- 'common/**'
|
||||
- 'contracts/vesting/**'
|
||||
- 'nym-api/nym-api-requests/**'
|
||||
paths-ignore:
|
||||
- 'explorer/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'nym-wallet/**'
|
||||
- 'common/**'
|
||||
- 'contracts/vesting/**'
|
||||
- 'nym-api/nym-api-requests/**'
|
||||
paths-ignore:
|
||||
- 'explorer/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -22,7 +16,6 @@ jobs:
|
||||
steps:
|
||||
- name: Install Dependencies (Linux)
|
||||
run: sudo apt-get update && sudo apt-get -y install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev squashfs-tools
|
||||
continue-on-error: true
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
@@ -2,13 +2,8 @@ name: Wasm Client
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'clients/webassembly/**'
|
||||
- 'clients/client-core/**'
|
||||
- 'common/**'
|
||||
- 'contracts/**'
|
||||
- 'gateway/gateway-requests/**'
|
||||
- 'nym-api/nym-api-requests/**'
|
||||
paths-ignore:
|
||||
- 'explorer/**'
|
||||
|
||||
jobs:
|
||||
wasm:
|
||||
@@ -29,6 +24,11 @@ jobs:
|
||||
command: build
|
||||
args: --manifest-path clients/webassembly/Cargo.toml --target wasm32-unknown-unknown
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --manifest-path clients/webassembly/Cargo.toml --target wasm32-unknown-unknown --features=coconut
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
|
||||
@@ -42,4 +42,3 @@ envs/qwerty.env
|
||||
Cargo.lock
|
||||
nym-connect/Cargo.lock
|
||||
.parcel-cache
|
||||
.DS_Store
|
||||
|
||||
+1
-9
@@ -4,14 +4,6 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
|
||||
|
||||
# [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- remove coconut feature and unify builds ([#2890])
|
||||
- native-client: is now capable of listening for requests on sockets different than `127.0.0.1` ([#2939]). This can be specified via `--host` flag during `init` or `run`. Alternatively a custom `host` can be set in `config.toml` file under `socket` section.
|
||||
|
||||
[#2890]: https://github.com/nymtech/nym/pull/2890
|
||||
[#2939]: https://github.com/nymtech/nym/pull/2939
|
||||
|
||||
# [v1.1.8] (2023-01-31)
|
||||
|
||||
### Added
|
||||
@@ -26,7 +18,7 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
|
||||
- nym-api: an `--id` flag is now always explicitly required ([#2873])
|
||||
|
||||
[#2754]: https://github.com/nymtech/nym/issues/2754
|
||||
[#2810]: https://github.com/nymtech/nym/issues/2810
|
||||
[#2839]: https://github.com/nymtech/nym/issues/2810
|
||||
[#2931]: https://github.com/nymtech/nym/issues/2931
|
||||
[#1902]: https://github.com/nymtech/nym/issues/1902
|
||||
[#2873]: https://github.com/nymtech/nym/issues/2873
|
||||
|
||||
Generated
+57
-61
@@ -30,7 +30,7 @@ version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"cipher 0.3.0",
|
||||
"cpufeatures",
|
||||
"ctr 0.8.0",
|
||||
@@ -43,7 +43,7 @@ version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"cipher 0.4.3",
|
||||
"cpufeatures",
|
||||
]
|
||||
@@ -375,7 +375,7 @@ dependencies = [
|
||||
"arrayref",
|
||||
"arrayvec",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"constant_time_eq",
|
||||
"digest 0.10.6",
|
||||
]
|
||||
@@ -500,6 +500,12 @@ dependencies = [
|
||||
"jobserver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
@@ -522,7 +528,7 @@ version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7fc89c7c5b9e7a02dfe45cd2367bae382f9ed31c61ca8debe5f827c420a2f08"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"cipher 0.4.3",
|
||||
"cpufeatures",
|
||||
]
|
||||
@@ -701,7 +707,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "client-core"
|
||||
version = "1.1.8"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"client-connections",
|
||||
@@ -826,7 +832,7 @@ dependencies = [
|
||||
name = "config"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"handlebars",
|
||||
"log",
|
||||
"network-defaults",
|
||||
@@ -1046,7 +1052,7 @@ version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1054,6 +1060,7 @@ name = "credential"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bip39",
|
||||
"cfg-if 0.1.10",
|
||||
"clap 4.1.3",
|
||||
"coconut-interface",
|
||||
"completions",
|
||||
@@ -1174,7 +1181,7 @@ version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
@@ -1184,7 +1191,7 @@ version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
@@ -1196,7 +1203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a"
|
||||
dependencies = [
|
||||
"autocfg 1.1.0",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
"memoffset",
|
||||
"scopeguard",
|
||||
@@ -1208,7 +1215,7 @@ version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
@@ -1218,7 +1225,7 @@ version = "0.8.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1553,7 +1560,7 @@ version = "4.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
@@ -1563,7 +1570,7 @@ version = "5.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"hashbrown 0.12.3",
|
||||
"lock_api",
|
||||
"once_cell",
|
||||
@@ -1789,7 +1796,7 @@ version = "0.8.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1891,7 +1898,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "explorer-api"
|
||||
version = "1.1.8"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap 4.1.3",
|
||||
@@ -2169,7 +2176,6 @@ dependencies = [
|
||||
"gateway-requests",
|
||||
"getrandom 0.2.8",
|
||||
"log",
|
||||
"mobile-storage",
|
||||
"network-defaults",
|
||||
"nymsphinx",
|
||||
"pemstore",
|
||||
@@ -2252,7 +2258,7 @@ version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||
@@ -2265,7 +2271,7 @@ version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
@@ -2830,7 +2836,7 @@ version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
@@ -2937,7 +2943,7 @@ version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"ecdsa",
|
||||
"elliptic-curve",
|
||||
"sec1",
|
||||
@@ -3005,7 +3011,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45ba81a1f5f24396b37211478aff7fbcd605dd4544df8dbed07b9da3c2057aee"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"hex",
|
||||
"hidapi",
|
||||
"ledger-transport",
|
||||
@@ -3104,7 +3110,7 @@ version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3121,7 +3127,7 @@ version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"generator",
|
||||
"scoped-tls",
|
||||
"serde",
|
||||
@@ -3275,14 +3281,6 @@ dependencies = [
|
||||
"version-checker",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mobile-storage"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multer"
|
||||
version = "2.0.4"
|
||||
@@ -3339,7 +3337,7 @@ dependencies = [
|
||||
name = "network-defaults"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"dotenv",
|
||||
"hex-literal",
|
||||
"once_cell",
|
||||
@@ -3438,14 +3436,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-api"
|
||||
version = "1.1.8"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"bip39",
|
||||
"bs58",
|
||||
"build-information",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"clap 4.1.3",
|
||||
"coconut-bandwidth-contract-common",
|
||||
"coconut-dkg-common",
|
||||
@@ -3536,7 +3534,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-cli"
|
||||
version = "1.1.8"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.13.1",
|
||||
@@ -3565,7 +3563,7 @@ dependencies = [
|
||||
"base64 0.13.1",
|
||||
"bip39",
|
||||
"bs58",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"clap 4.1.3",
|
||||
"coconut-bandwidth-contract-common",
|
||||
"coconut-dkg-common",
|
||||
@@ -3594,7 +3592,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-client"
|
||||
version = "1.1.8"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"build-information",
|
||||
"clap 4.1.3",
|
||||
@@ -3634,7 +3632,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-gateway"
|
||||
version = "1.1.8"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -3686,7 +3684,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-mixnode"
|
||||
version = "1.1.9"
|
||||
version = "1.1.8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"atty",
|
||||
@@ -3731,7 +3729,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-network-requester"
|
||||
version = "1.1.8"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"clap 4.1.3",
|
||||
@@ -3743,7 +3741,6 @@ dependencies = [
|
||||
"log",
|
||||
"logging",
|
||||
"network-defaults",
|
||||
"nym-sdk",
|
||||
"nymsphinx",
|
||||
"ordered-buffer",
|
||||
"pretty_env_logger",
|
||||
@@ -3764,7 +3761,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-network-statistics"
|
||||
version = "1.1.8"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"log",
|
||||
@@ -3821,7 +3818,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-socks5-client"
|
||||
version = "1.1.8"
|
||||
version = "1.1.7"
|
||||
dependencies = [
|
||||
"build-information",
|
||||
"clap 4.1.3",
|
||||
@@ -3840,7 +3837,6 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"logging",
|
||||
"mobile-storage",
|
||||
"network-defaults",
|
||||
"nymsphinx",
|
||||
"ordered-buffer",
|
||||
@@ -4102,7 +4098,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"once_cell",
|
||||
@@ -4205,7 +4201,7 @@ version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"instant",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
@@ -4219,7 +4215,7 @@ version = "0.9.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec 1.10.0",
|
||||
@@ -4453,7 +4449,7 @@ version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"opaque-debug 0.3.0",
|
||||
"universal-hash",
|
||||
@@ -5501,7 +5497,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug 0.3.0",
|
||||
@@ -5513,7 +5509,7 @@ version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"digest 0.10.6",
|
||||
]
|
||||
@@ -5524,7 +5520,7 @@ version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"digest 0.10.6",
|
||||
]
|
||||
@@ -5536,7 +5532,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug 0.3.0",
|
||||
@@ -5548,7 +5544,7 @@ version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"digest 0.10.6",
|
||||
]
|
||||
@@ -6072,7 +6068,7 @@ version = "0.24.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54cb4ebf3d49308b99e6e9dc95e989e2fdbdc210e4f67c39db0bb89ba927001c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"ntapi",
|
||||
@@ -6105,7 +6101,7 @@ version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"fastrand",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
@@ -6563,7 +6559,7 @@ version = "0.1.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"log",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
@@ -6919,7 +6915,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6cf88d94e969e7956d924ba70741316796177fa0c79a2c9f4ab04998d96e966e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"chrono",
|
||||
"enum-iterator 0.8.1",
|
||||
"getset",
|
||||
@@ -6936,7 +6932,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "571b69f690c855821462709b6f41d42ceccc316fbd17b60bd06d06928cfe6a99"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"enum-iterator 1.2.0",
|
||||
"getset",
|
||||
"git2 0.15.0",
|
||||
@@ -7031,7 +7027,7 @@ version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
@@ -7056,7 +7052,7 @@ version = "0.4.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
|
||||
+1
-2
@@ -38,7 +38,6 @@ members = [
|
||||
"common/cosmwasm-smart-contracts/mixnet-contract",
|
||||
"common/cosmwasm-smart-contracts/multisig-contract",
|
||||
"common/cosmwasm-smart-contracts/vesting-contract",
|
||||
"common/mobile-storage",
|
||||
"common/credential-storage",
|
||||
"common/credentials",
|
||||
"common/crypto",
|
||||
@@ -96,7 +95,7 @@ default-members = [
|
||||
"explorer-api",
|
||||
]
|
||||
|
||||
exclude = ["explorer", "contracts", "clients/webassembly", "nym-wallet", "nym-connect", "nym-connect-android"]
|
||||
exclude = ["explorer", "contracts", "clients/webassembly", "nym-wallet", "nym-connect"]
|
||||
|
||||
[workspace.package]
|
||||
authors = ["Nym Technologies SA"]
|
||||
|
||||
@@ -2,10 +2,10 @@ test: clippy-all cargo-test wasm fmt
|
||||
test-all: test cargo-test-expensive
|
||||
no-clippy: build cargo-test wasm fmt
|
||||
happy: fmt clippy-happy test
|
||||
clippy-all: clippy-main clippy-all-contracts clippy-all-wallet clippy-all-connect clippy-all-wasm-client
|
||||
clippy-all: clippy-main clippy-coconut clippy-all-contracts clippy-all-wallet clippy-all-connect clippy-all-wasm-client
|
||||
clippy-happy: clippy-happy-main clippy-happy-contracts clippy-happy-wallet clippy-happy-connect
|
||||
cargo-test: test-main test-contracts test-wallet test-connect
|
||||
cargo-test-expensive: test-main-expensive test-contracts-expensive test-wallet-expensive test-connect-expensive
|
||||
cargo-test: test-main test-contracts test-wallet test-connect test-coconut
|
||||
cargo-test-expensive: test-main-expensive test-contracts-expensive test-wallet-expensive test-connect-expensive test-coconut-expensive
|
||||
build: build-contracts build-wallet build-main build-connect build-wasm-client
|
||||
fmt: fmt-main fmt-contracts fmt-wallet fmt-connect fmt-wasm-client
|
||||
|
||||
@@ -24,6 +24,9 @@ clippy-happy-connect:
|
||||
clippy-main:
|
||||
cargo clippy --workspace -- -D warnings
|
||||
|
||||
clippy-coconut:
|
||||
cargo clippy --workspace --features coconut -- -D warnings
|
||||
|
||||
clippy-wasm:
|
||||
cargo clippy --manifest-path clients/webassembly/Cargo.toml --target wasm32-unknown-unknown --workspace -- -D warnings
|
||||
|
||||
@@ -43,9 +46,16 @@ clippy-all-wasm-client:
|
||||
test-main:
|
||||
cargo test --workspace
|
||||
|
||||
test-coconut:
|
||||
cargo test --workspace --features coconut
|
||||
|
||||
|
||||
test-main-expensive:
|
||||
cargo test --workspace -- --ignored
|
||||
|
||||
test-coconut-expensive:
|
||||
cargo test --workspace --features coconut -- --ignored
|
||||
|
||||
test-contracts:
|
||||
cargo test --manifest-path contracts/Cargo.toml --all-features
|
||||
|
||||
@@ -109,6 +119,3 @@ mixnet-opt: wasm
|
||||
generate-typescript:
|
||||
cd tools/ts-rs-cli && cargo run && cd ../..
|
||||
yarn types:lint:fix
|
||||
|
||||
run-validator-tests:
|
||||
cd nym-api/tests/functional_test && yarn test:qa
|
||||
@@ -82,4 +82,5 @@ sqlx = { version = "0.6.2", features = ["runtime-tokio-rustls", "sqlite", "macro
|
||||
default = []
|
||||
fs-surb-storage = ["sqlx"]
|
||||
wasm = ["gateway-client/wasm"]
|
||||
coconut = ["gateway-client/coconut", "gateway-requests/coconut"]
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
use crate::{client::replies::reply_storage, config::DebugConfig};
|
||||
|
||||
pub fn setup_empty_reply_surb_backend(debug_config: &DebugConfig) -> reply_storage::Empty {
|
||||
reply_storage::Empty {
|
||||
min_surb_threshold: debug_config.minimum_reply_surb_storage_threshold,
|
||||
max_surb_threshold: debug_config.maximum_reply_surb_storage_threshold,
|
||||
}
|
||||
}
|
||||
@@ -49,24 +49,11 @@ use super::received_buffer::ReceivedBufferMessage;
|
||||
#[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))]
|
||||
pub mod non_wasm_helpers;
|
||||
|
||||
pub mod helpers;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ClientInput {
|
||||
pub connection_command_sender: ConnectionCommandSender,
|
||||
pub input_sender: InputMessageSender,
|
||||
}
|
||||
|
||||
impl ClientInput {
|
||||
pub async fn send(
|
||||
&self,
|
||||
message: InputMessage,
|
||||
) -> Result<(), tokio::sync::mpsc::error::SendError<InputMessage>> {
|
||||
self.input_sender.send(message).await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ClientOutput {
|
||||
pub received_buffer_request_sender: ReceivedBufferRequestSender,
|
||||
}
|
||||
@@ -302,6 +289,10 @@ where
|
||||
if gateway_id.is_empty() {
|
||||
return Err(ClientCoreError::GatewayIdUnknown);
|
||||
}
|
||||
let gateway_owner = self.gateway_config.gateway_owner.clone();
|
||||
if gateway_owner.is_empty() {
|
||||
return Err(ClientCoreError::GatewayOwnerUnknown);
|
||||
}
|
||||
let gateway_address = self.gateway_config.gateway_listener.clone();
|
||||
if gateway_address.is_empty() {
|
||||
return Err(ClientCoreError::GatwayAddressUnknown);
|
||||
@@ -321,6 +312,7 @@ where
|
||||
gateway_address,
|
||||
self.key_manager.identity_keypair(),
|
||||
gateway_identity,
|
||||
gateway_owner,
|
||||
shared_key,
|
||||
mixnet_message_sender,
|
||||
ack_sender,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::client::replies::reply_storage::{
|
||||
fs_backend, CombinedReplyStorage, ReplyStorageBackend,
|
||||
self, fs_backend, CombinedReplyStorage, ReplyStorageBackend,
|
||||
};
|
||||
use crate::config::DebugConfig;
|
||||
use crate::error::ClientCoreError;
|
||||
@@ -98,3 +98,10 @@ pub async fn setup_fs_reply_surb_backend<P: AsRef<Path>>(
|
||||
Ok(setup_inactive_backend(debug_config))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup_empty_reply_surb_backend(debug_config: &DebugConfig) -> reply_storage::Empty {
|
||||
reply_storage::Empty {
|
||||
min_surb_threshold: debug_config.minimum_reply_surb_storage_threshold,
|
||||
max_surb_threshold: debug_config.maximum_reply_surb_storage_threshold,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,11 +81,7 @@ pub struct Config {
|
||||
|
||||
/// Defines maximum amount of time the client is going to wait for reply surbs before explicitly asking
|
||||
/// for more even though in theory they wouldn't need to.
|
||||
maximum_reply_surb_rerequest_waiting_period: Duration,
|
||||
|
||||
/// Defines maximum amount of time the client is going to wait for reply surbs before
|
||||
/// deciding it's never going to get them and would drop all pending messages
|
||||
maximum_reply_surb_drop_waiting_period: Duration,
|
||||
maximum_reply_surb_waiting_period: Duration,
|
||||
|
||||
/// Defines maximum amount of time given reply surb is going to be valid for.
|
||||
/// This is going to be superseded by key rotation once implemented.
|
||||
@@ -123,8 +119,7 @@ impl<'a> From<&'a Config> for reply_controller::Config {
|
||||
cfg.minimum_reply_surb_request_size,
|
||||
cfg.maximum_reply_surb_request_size,
|
||||
cfg.maximum_allowed_reply_surb_request_size,
|
||||
cfg.maximum_reply_surb_rerequest_waiting_period,
|
||||
cfg.maximum_reply_surb_drop_waiting_period,
|
||||
cfg.maximum_reply_surb_waiting_period,
|
||||
cfg.maximum_reply_surb_age,
|
||||
cfg.maximum_reply_key_age,
|
||||
)
|
||||
@@ -166,10 +161,8 @@ impl Config {
|
||||
.maximum_reply_surb_request_size,
|
||||
maximum_allowed_reply_surb_request_size: base_client_debug_config
|
||||
.maximum_allowed_reply_surb_request_size,
|
||||
maximum_reply_surb_rerequest_waiting_period: base_client_debug_config
|
||||
.maximum_reply_surb_rerequest_waiting_period,
|
||||
maximum_reply_surb_drop_waiting_period: base_client_debug_config
|
||||
.maximum_reply_surb_drop_waiting_period,
|
||||
maximum_reply_surb_waiting_period: base_client_debug_config
|
||||
.maximum_reply_surb_waiting_period,
|
||||
maximum_reply_surb_age: base_client_debug_config.maximum_reply_surb_age,
|
||||
maximum_reply_key_age: base_client_debug_config.maximum_reply_key_age,
|
||||
}
|
||||
|
||||
@@ -342,6 +342,7 @@ where
|
||||
if let Poll::Ready(Some(id)) = Pin::new(&mut self.client_connection_rx).poll_next(cx) {
|
||||
match id {
|
||||
ConnectionCommand::Close(id) => self.on_close_connection(id),
|
||||
ConnectionCommand::ActiveConnections(_) => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,6 +421,7 @@ where
|
||||
if let Poll::Ready(Some(id)) = Pin::new(&mut self.client_connection_rx).poll_next(cx) {
|
||||
match id {
|
||||
ConnectionCommand::Close(id) => self.on_close_connection(id),
|
||||
ConnectionCommand::ActiveConnections(_) => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@ pub struct Config {
|
||||
min_surb_request_size: u32,
|
||||
max_surb_request_size: u32,
|
||||
maximum_allowed_reply_surb_request_size: u32,
|
||||
max_surb_rerequest_waiting_period: Duration,
|
||||
max_surb_drop_waiting_period: Duration,
|
||||
max_surb_waiting_period: Duration,
|
||||
max_reply_surb_age: Duration,
|
||||
max_reply_key_age: Duration,
|
||||
}
|
||||
@@ -41,8 +40,7 @@ impl Config {
|
||||
min_surb_request_size: u32,
|
||||
max_surb_request_size: u32,
|
||||
maximum_allowed_reply_surb_request_size: u32,
|
||||
max_surb_rerequest_waiting_period: Duration,
|
||||
max_surb_drop_waiting_period: Duration,
|
||||
max_surb_waiting_period: Duration,
|
||||
max_reply_surb_age: Duration,
|
||||
max_reply_key_age: Duration,
|
||||
) -> Self {
|
||||
@@ -50,8 +48,7 @@ impl Config {
|
||||
min_surb_request_size,
|
||||
max_surb_request_size,
|
||||
maximum_allowed_reply_surb_request_size,
|
||||
max_surb_rerequest_waiting_period,
|
||||
max_surb_drop_waiting_period,
|
||||
max_surb_waiting_period,
|
||||
max_reply_surb_age,
|
||||
max_reply_key_age,
|
||||
}
|
||||
@@ -745,13 +742,9 @@ where
|
||||
|
||||
let diff = now - last_received_time;
|
||||
|
||||
if diff > self.config.max_surb_rerequest_waiting_period {
|
||||
if diff > self.config.max_surb_drop_waiting_period {
|
||||
to_remove.push(*pending_reply_target)
|
||||
} else {
|
||||
debug!("We haven't received any surbs in {:?} from {pending_reply_target}. Going to explicitly ask for more", diff);
|
||||
to_request.push(*pending_reply_target);
|
||||
}
|
||||
if diff > self.config.max_surb_waiting_period {
|
||||
warn!("We haven't received any surbs in {:?} from {pending_reply_target}. Going to explicitly ask for more", diff);
|
||||
to_request.push(*pending_reply_target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,7 @@ const DEFAULT_MAXIMUM_REPLY_SURB_REQUEST_SIZE: u32 = 100;
|
||||
|
||||
const DEFAULT_MAXIMUM_ALLOWED_SURB_REQUEST_SIZE: u32 = 500;
|
||||
|
||||
const DEFAULT_MAXIMUM_REPLY_SURB_REREQUEST_WAITING_PERIOD: Duration = Duration::from_secs(10);
|
||||
const DEFAULT_MAXIMUM_REPLY_SURB_DROP_WAITING_PERIOD: Duration = Duration::from_secs(5 * 60);
|
||||
const DEFAULT_MAXIMUM_REPLY_SURB_WAITING_PERIOD: Duration = Duration::from_secs(10);
|
||||
|
||||
// 12 hours
|
||||
const DEFAULT_MAXIMUM_REPLY_SURB_AGE: Duration = Duration::from_secs(12 * 60 * 60);
|
||||
@@ -373,12 +372,8 @@ impl<T> Config<T> {
|
||||
self.debug.maximum_allowed_reply_surb_request_size
|
||||
}
|
||||
|
||||
pub fn get_maximum_reply_surb_rerequest_waiting_period(&self) -> Duration {
|
||||
self.debug.maximum_reply_surb_rerequest_waiting_period
|
||||
}
|
||||
|
||||
pub fn get_maximum_reply_surb_drop_waiting_period(&self) -> Duration {
|
||||
self.debug.maximum_reply_surb_drop_waiting_period
|
||||
pub fn get_maximum_reply_surb_waiting_period(&self) -> Duration {
|
||||
self.debug.maximum_reply_surb_waiting_period
|
||||
}
|
||||
|
||||
pub fn get_maximum_reply_surb_age(&self) -> Duration {
|
||||
@@ -668,12 +663,7 @@ pub struct DebugConfig {
|
||||
/// Defines maximum amount of time the client is going to wait for reply surbs before explicitly asking
|
||||
/// for more even though in theory they wouldn't need to.
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub maximum_reply_surb_rerequest_waiting_period: Duration,
|
||||
|
||||
/// Defines maximum amount of time the client is going to wait for reply surbs before
|
||||
/// deciding it's never going to get them and would drop all pending messages
|
||||
#[serde(with = "humantime_serde")]
|
||||
pub maximum_reply_surb_drop_waiting_period: Duration,
|
||||
pub maximum_reply_surb_waiting_period: Duration,
|
||||
|
||||
/// Defines maximum amount of time given reply surb is going to be valid for.
|
||||
/// This is going to be superseded by key rotation once implemented.
|
||||
@@ -714,9 +704,7 @@ impl Default for DebugConfig {
|
||||
minimum_reply_surb_request_size: DEFAULT_MINIMUM_REPLY_SURB_REQUEST_SIZE,
|
||||
maximum_reply_surb_request_size: DEFAULT_MAXIMUM_REPLY_SURB_REQUEST_SIZE,
|
||||
maximum_allowed_reply_surb_request_size: DEFAULT_MAXIMUM_ALLOWED_SURB_REQUEST_SIZE,
|
||||
maximum_reply_surb_rerequest_waiting_period:
|
||||
DEFAULT_MAXIMUM_REPLY_SURB_REREQUEST_WAITING_PERIOD,
|
||||
maximum_reply_surb_drop_waiting_period: DEFAULT_MAXIMUM_REPLY_SURB_DROP_WAITING_PERIOD,
|
||||
maximum_reply_surb_waiting_period: DEFAULT_MAXIMUM_REPLY_SURB_WAITING_PERIOD,
|
||||
maximum_reply_surb_age: DEFAULT_MAXIMUM_REPLY_SURB_AGE,
|
||||
maximum_reply_key_age: DEFAULT_MAXIMUM_REPLY_KEY_AGE,
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ pub(super) async fn register_with_gateway(
|
||||
let mut gateway_client: GatewayClient<SigningNyxdClient> = GatewayClient::new_init(
|
||||
gateway.clients_address(),
|
||||
gateway.identity_key,
|
||||
gateway.owner.clone(),
|
||||
our_identity.clone(),
|
||||
timeout,
|
||||
);
|
||||
|
||||
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bip39 = "1.0.1"
|
||||
cfg-if = "0.1"
|
||||
clap = { version = "4.0", features = ["cargo", "derive"] }
|
||||
rand = "0.7.3"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
@@ -24,3 +25,5 @@ network-defaults = { path = "../../common/network-defaults" }
|
||||
pemstore = { path = "../../common/pemstore" }
|
||||
validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] }
|
||||
|
||||
[features]
|
||||
coconut = ["credentials/coconut"]
|
||||
|
||||
@@ -1,47 +1,56 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
mod client;
|
||||
mod commands;
|
||||
mod error;
|
||||
mod state;
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "coconut")] {
|
||||
|
||||
use commands::*;
|
||||
use completions::fig_generate;
|
||||
use config::{DATA_DIR, DB_FILE_NAME};
|
||||
use error::Result;
|
||||
use network_defaults::setup_env;
|
||||
mod client;
|
||||
mod commands;
|
||||
mod error;
|
||||
mod state;
|
||||
|
||||
use clap::{CommandFactory, Parser};
|
||||
use error::Result;
|
||||
use network_defaults::setup_env;
|
||||
use completions::fig_generate;
|
||||
use commands::*;
|
||||
use config::{DATA_DIR, DB_FILE_NAME};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[clap(author = "Nymtech", version, about)]
|
||||
struct Cli {
|
||||
/// Path pointing to an env file that configures the client.
|
||||
#[clap(short, long)]
|
||||
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
||||
use clap::{CommandFactory, Parser};
|
||||
|
||||
#[clap(subcommand)]
|
||||
pub(crate) command: Command,
|
||||
}
|
||||
#[derive(Parser)]
|
||||
#[clap(author = "Nymtech", version, about)]
|
||||
struct Cli {
|
||||
/// Path pointing to an env file that configures the client.
|
||||
#[clap(short, long)]
|
||||
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let args = Cli::parse();
|
||||
setup_env(args.config_env_file.as_ref());
|
||||
let bin_name = "nym-credential-client";
|
||||
|
||||
match args.command {
|
||||
Command::Run(r) => {
|
||||
let db_path = r.client_home_directory.join(DATA_DIR).join(DB_FILE_NAME);
|
||||
let shared_storage = credential_storage::initialise_storage(db_path).await;
|
||||
|
||||
let state = deposit(&r.nyxd_url, &r.mnemonic, r.amount).await?;
|
||||
get_credential(&state, shared_storage).await?;
|
||||
#[clap(subcommand)]
|
||||
pub(crate) command: Command,
|
||||
}
|
||||
Command::Completions(c) => c.generate(&mut crate::Cli::command(), bin_name),
|
||||
Command::GenerateFigSpec => fig_generate(&mut crate::Cli::command(), bin_name),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let args = Cli::parse();
|
||||
setup_env(args.config_env_file.as_ref());
|
||||
let bin_name = "nym-credential-client";
|
||||
|
||||
match args.command {
|
||||
Command::Run(r) => {
|
||||
let db_path = r.client_home_directory.join(DATA_DIR).join(DB_FILE_NAME);
|
||||
let shared_storage = credential_storage::initialise_storage(db_path).await;
|
||||
|
||||
let state = deposit(&r.nyxd_url, &r.mnemonic, r.amount).await?;
|
||||
get_credential(&state, shared_storage).await?;
|
||||
}
|
||||
Command::Completions(c) => c.generate(&mut crate::Cli::command(), bin_name),
|
||||
Command::GenerateFigSpec => fig_generate(&mut crate::Cli::command(), bin_name)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
} else {
|
||||
fn main() {
|
||||
println!("Crate only designed for coconut feature");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ tokio-tungstenite = "0.14" # websocket
|
||||
build-information = { path = "../../common/build-information" }
|
||||
client-core = { path = "../client-core", features = ["fs-surb-storage"] }
|
||||
client-connections = { path = "../../common/client-connections" }
|
||||
coconut-interface = { path = "../../common/coconut-interface" }
|
||||
coconut-interface = { path = "../../common/coconut-interface", optional = true }
|
||||
config = { path = "../../common/config" }
|
||||
completions = { path = "../../common/completions" }
|
||||
credential-storage = { path = "../../common/credential-storage" }
|
||||
credentials = { path = "../../common/credentials" }
|
||||
credentials = { path = "../../common/credentials", optional = true }
|
||||
crypto = { path = "../../common/crypto" }
|
||||
logging = { path = "../../common/logging"}
|
||||
gateway-client = { path = "../../common/client-libs/gateway-client" }
|
||||
@@ -55,5 +55,8 @@ validator-client = { path = "../../common/client-libs/validator-client", feature
|
||||
version-checker = { path = "../../common/version-checker" }
|
||||
websocket-requests = { path = "websocket-requests" }
|
||||
|
||||
[features]
|
||||
coconut = ["coconut-interface", "credentials", "credentials/coconut", "gateway-requests/coconut", "gateway-client/coconut", "client-core/coconut"]
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0" # for the "textsend" example
|
||||
|
||||
@@ -9,7 +9,6 @@ use config::defaults::DEFAULT_WEBSOCKET_LISTENING_PORT;
|
||||
use config::{NymConfig, OptionalSet};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Debug;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
|
||||
@@ -105,11 +104,6 @@ impl Config {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_host(mut self, host: IpAddr) -> Self {
|
||||
self.socket.host = host;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_port(mut self, port: u16) -> Self {
|
||||
self.socket.listening_port = port;
|
||||
self
|
||||
@@ -136,10 +130,6 @@ impl Config {
|
||||
self.socket.socket_type
|
||||
}
|
||||
|
||||
pub fn get_listening_ip(&self) -> IpAddr {
|
||||
self.socket.host
|
||||
}
|
||||
|
||||
pub fn get_listening_port(&self) -> u16 {
|
||||
self.socket.listening_port
|
||||
}
|
||||
@@ -190,10 +180,9 @@ impl Config {
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Socket {
|
||||
socket_type: SocketType,
|
||||
host: IpAddr,
|
||||
listening_port: u16,
|
||||
}
|
||||
|
||||
@@ -201,7 +190,6 @@ impl Default for Socket {
|
||||
fn default() -> Self {
|
||||
Socket {
|
||||
socket_type: SocketType::WebSocket,
|
||||
host: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
|
||||
listening_port: DEFAULT_WEBSOCKET_LISTENING_PORT,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +93,6 @@ socket_type = '{{ socket.socket_type }}'
|
||||
# will be listening for incoming requests
|
||||
listening_port = {{ socket.listening_port }}
|
||||
|
||||
# if applicable (for the case of 'WebSocket'), the ip address on which the client
|
||||
# will be listening for incoming requests
|
||||
host = '{{ socket.host }}'
|
||||
|
||||
##### logging configuration options #####
|
||||
|
||||
|
||||
@@ -102,8 +102,7 @@ impl SocketClient {
|
||||
reply_controller_sender,
|
||||
);
|
||||
|
||||
websocket::Listener::new(config.get_listening_ip(), config.get_listening_port())
|
||||
.start(websocket_handler, shutdown);
|
||||
websocket::Listener::new(config.get_listening_port()).start(websocket_handler, shutdown);
|
||||
}
|
||||
|
||||
/// blocking version of `start_socket` method. Will run forever (or until SIGINT is sent)
|
||||
|
||||
@@ -12,7 +12,6 @@ use crypto::asymmetric::identity;
|
||||
use nymsphinx::addressing::clients::Recipient;
|
||||
use serde::Serialize;
|
||||
use std::fmt::Display;
|
||||
use std::net::IpAddr;
|
||||
use tap::TapFallible;
|
||||
|
||||
#[derive(Args, Clone)]
|
||||
@@ -31,6 +30,7 @@ pub(crate) struct Init {
|
||||
force_register_gateway: bool,
|
||||
|
||||
/// Comma separated list of rest endpoints of the nyxd validators
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long, alias = "nymd_validators", value_delimiter = ',')]
|
||||
nyxd_urls: Option<Vec<url::Url>>,
|
||||
|
||||
@@ -47,10 +47,6 @@ pub(crate) struct Init {
|
||||
#[clap(short, long)]
|
||||
port: Option<u16>,
|
||||
|
||||
/// Ip for the socket (if applicable) to listen for requests.
|
||||
#[clap(long)]
|
||||
host: Option<IpAddr>,
|
||||
|
||||
/// Mostly debug-related option to increase default traffic rate so that you would not need to
|
||||
/// modify config post init
|
||||
#[clap(long, hide = true)]
|
||||
@@ -62,6 +58,7 @@ pub(crate) struct Init {
|
||||
|
||||
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||
/// with bandwidth credential requirement.
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long)]
|
||||
enabled_credentials_mode: Option<bool>,
|
||||
|
||||
@@ -76,11 +73,12 @@ impl From<Init> for OverrideConfig {
|
||||
nym_apis: init_config.nym_apis,
|
||||
disable_socket: init_config.disable_socket,
|
||||
port: init_config.port,
|
||||
host: init_config.host,
|
||||
fastmode: init_config.fastmode,
|
||||
no_cover: init_config.no_cover,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: init_config.nyxd_urls,
|
||||
#[cfg(feature = "coconut")]
|
||||
enabled_credentials_mode: init_config.enabled_credentials_mode,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ use completions::{fig_generate, ArgShell};
|
||||
use config::OptionalSet;
|
||||
use lazy_static::lazy_static;
|
||||
use std::error::Error;
|
||||
use std::net::IpAddr;
|
||||
|
||||
pub(crate) mod init;
|
||||
pub(crate) mod run;
|
||||
@@ -57,10 +56,12 @@ pub(crate) struct OverrideConfig {
|
||||
nym_apis: Option<Vec<url::Url>>,
|
||||
disable_socket: Option<bool>,
|
||||
port: Option<u16>,
|
||||
host: Option<IpAddr>,
|
||||
fastmode: bool,
|
||||
no_cover: bool,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: Option<Vec<url::Url>>,
|
||||
#[cfg(feature = "coconut")]
|
||||
enabled_credentials_mode: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -77,29 +78,35 @@ pub(crate) async fn execute(args: &Cli) -> Result<(), Box<dyn Error + Send + Syn
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config {
|
||||
config
|
||||
pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Config {
|
||||
config = config
|
||||
.with_optional(Config::with_disabled_socket, args.disable_socket)
|
||||
.with_base(BaseConfig::with_high_default_traffic_volume, args.fastmode)
|
||||
.with_base(BaseConfig::with_disabled_cover_traffic, args.no_cover)
|
||||
.with_optional(Config::with_port, args.port)
|
||||
.with_optional(Config::with_host, args.host)
|
||||
.with_optional_custom_env_ext(
|
||||
BaseConfig::with_custom_nym_apis,
|
||||
args.nym_apis,
|
||||
network_defaults::var_names::NYM_API,
|
||||
config::parse_urls,
|
||||
)
|
||||
.with_optional_custom_env_ext(
|
||||
BaseConfig::with_custom_nyxd,
|
||||
args.nyxd_urls,
|
||||
network_defaults::var_names::NYXD,
|
||||
config::parse_urls,
|
||||
)
|
||||
.with_optional_ext(
|
||||
BaseConfig::with_disabled_credentials,
|
||||
args.enabled_credentials_mode.map(|b| !b),
|
||||
)
|
||||
);
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
{
|
||||
config = config
|
||||
.with_optional_custom_env_ext(
|
||||
BaseConfig::with_custom_nyxd,
|
||||
args.nyxd_urls,
|
||||
network_defaults::var_names::NYXD,
|
||||
config::parse_urls,
|
||||
)
|
||||
.with_optional_ext(
|
||||
BaseConfig::with_disabled_credentials,
|
||||
args.enabled_credentials_mode.map(|b| !b),
|
||||
);
|
||||
}
|
||||
|
||||
config
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use std::error::Error;
|
||||
use std::net::IpAddr;
|
||||
|
||||
use crate::{
|
||||
client::{config::Config, SocketClient},
|
||||
@@ -23,6 +22,7 @@ pub(crate) struct Run {
|
||||
id: String,
|
||||
|
||||
/// Comma separated list of rest endpoints of the nyxd validators
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long, alias = "nymd_validators", value_delimiter = ',')]
|
||||
nyxd_urls: Option<Vec<url::Url>>,
|
||||
|
||||
@@ -44,10 +44,6 @@ pub(crate) struct Run {
|
||||
#[clap(short, long)]
|
||||
port: Option<u16>,
|
||||
|
||||
/// Ip for the socket (if applicable) to listen for requests.
|
||||
#[clap(long)]
|
||||
host: Option<IpAddr>,
|
||||
|
||||
/// Mostly debug-related option to increase default traffic rate so that you would not need to
|
||||
/// modify config post init
|
||||
#[clap(long, hide = true)]
|
||||
@@ -59,6 +55,7 @@ pub(crate) struct Run {
|
||||
|
||||
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||
/// with bandwidth credential requirement.
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long)]
|
||||
enabled_credentials_mode: Option<bool>,
|
||||
}
|
||||
@@ -69,10 +66,12 @@ impl From<Run> for OverrideConfig {
|
||||
nym_apis: run_config.nym_apis,
|
||||
disable_socket: run_config.disable_socket,
|
||||
port: run_config.port,
|
||||
host: run_config.host,
|
||||
fastmode: run_config.fastmode,
|
||||
no_cover: run_config.no_cover,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: run_config.nyxd_urls,
|
||||
#[cfg(feature = "coconut")]
|
||||
enabled_credentials_mode: run_config.enabled_credentials_mode,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
use super::handler::HandlerBuilder;
|
||||
use log::*;
|
||||
use std::net::IpAddr;
|
||||
use std::{net::SocketAddr, process, sync::Arc};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::{sync::Notify, task::JoinHandle};
|
||||
@@ -25,9 +24,10 @@ pub(crate) struct Listener {
|
||||
}
|
||||
|
||||
impl Listener {
|
||||
pub(crate) fn new(host: IpAddr, port: u16) -> Self {
|
||||
pub(crate) fn new(port: u16) -> Self {
|
||||
Listener {
|
||||
address: SocketAddr::new(host, port),
|
||||
// unless we find compelling reason not to, just listen on local only
|
||||
address: SocketAddr::new("127.0.0.1".parse().unwrap(), port),
|
||||
state: State::AwaitingConnection,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,11 @@ url = "2.2"
|
||||
build-information = { path = "../../common/build-information" }
|
||||
client-core = { path = "../client-core", features = ["fs-surb-storage"] }
|
||||
client-connections = { path = "../../common/client-connections" }
|
||||
coconut-interface = { path = "../../common/coconut-interface" }
|
||||
coconut-interface = { path = "../../common/coconut-interface", optional = true }
|
||||
config = { path = "../../common/config" }
|
||||
completions = { path = "../../common/completions" }
|
||||
credential-storage = { path = "../../common/credential-storage", optional = true }
|
||||
mobile-storage = { path = "../../common/mobile-storage", optional = true }
|
||||
credentials = { path = "../../common/credentials" }
|
||||
credential-storage = { path = "../../common/credential-storage" }
|
||||
credentials = { path = "../../common/credentials", optional = true }
|
||||
crypto = { path = "../../common/crypto" }
|
||||
logging = { path = "../../common/logging"}
|
||||
gateway-client = { path = "../../common/client-libs/gateway-client" }
|
||||
@@ -52,6 +51,5 @@ validator-client = { path = "../../common/client-libs/validator-client", feature
|
||||
version-checker = { path = "../../common/version-checker" }
|
||||
|
||||
[features]
|
||||
default = ["credential-storage"]
|
||||
coconut = ["coconut-interface", "credentials", "gateway-requests/coconut", "gateway-client/coconut", "credentials/coconut", "client-core/coconut"]
|
||||
eth = []
|
||||
mobile = ["mobile-storage", "gateway-client/mobile"]
|
||||
|
||||
@@ -18,7 +18,7 @@ mod template;
|
||||
const DEFAULT_CONNECTION_START_SURBS: u32 = 20;
|
||||
const DEFAULT_PER_REQUEST_SURBS: u32 = 3;
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Config {
|
||||
#[serde(flatten)]
|
||||
@@ -36,12 +36,10 @@ impl NymConfig for Config {
|
||||
}
|
||||
|
||||
fn default_root_directory() -> PathBuf {
|
||||
#[cfg(not(feature = "mobile"))]
|
||||
let base_dir = dirs::home_dir().expect("Failed to evaluate $HOME value");
|
||||
#[cfg(feature = "mobile")]
|
||||
let base_dir = PathBuf::from("/tmp");
|
||||
|
||||
base_dir.join(".nym").join("socks5-clients")
|
||||
dirs::home_dir()
|
||||
.expect("Failed to evaluate $HOME value")
|
||||
.join(".nym")
|
||||
.join("socks5-clients")
|
||||
}
|
||||
|
||||
fn try_default_root_directory() -> Option<PathBuf> {
|
||||
@@ -178,7 +176,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Socks5 {
|
||||
/// The port on which the client will be listening for incoming requests
|
||||
@@ -216,7 +214,7 @@ impl Default for Socks5 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Socks5Debug {
|
||||
/// Number of reply SURBs attached to each `Request::Connect` message.
|
||||
|
||||
@@ -8,12 +8,9 @@ use crate::socks::{
|
||||
authentication::{AuthenticationMethods, Authenticator, User},
|
||||
server::SphinxSocksServer,
|
||||
};
|
||||
|
||||
#[cfg(feature = "mobile")]
|
||||
use client_core::client::base_client::helpers::setup_empty_reply_surb_backend;
|
||||
#[cfg(not(feature = "mobile"))]
|
||||
use client_core::client::base_client::non_wasm_helpers;
|
||||
use client_core::client::base_client::{BaseClientBuilder, ClientInput, ClientOutput, ClientState};
|
||||
use client_core::client::base_client::{
|
||||
non_wasm_helpers, BaseClientBuilder, ClientInput, ClientOutput, ClientState,
|
||||
};
|
||||
use client_core::client::key_manager::KeyManager;
|
||||
use client_core::config::persistence::key_pathfinder::ClientKeyPathfinder;
|
||||
use futures::channel::mpsc;
|
||||
@@ -57,18 +54,6 @@ impl NymClient {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_keys(config: Config, key_manager: Option<KeyManager>) -> Self {
|
||||
let key_manager = key_manager.unwrap_or_else(|| {
|
||||
let pathfinder = ClientKeyPathfinder::new_from_config(config.get_base());
|
||||
KeyManager::load_keys(&pathfinder).expect("failed to load stored keys")
|
||||
});
|
||||
|
||||
NymClient {
|
||||
config,
|
||||
key_manager,
|
||||
}
|
||||
}
|
||||
|
||||
async fn create_bandwidth_controller(config: &Config) -> BandwidthController<QueryNyxdClient> {
|
||||
let details = network_defaults::NymNetworkDetails::new_from_env();
|
||||
let mut client_config = validator_client::Config::try_from_nym_network_details(&details)
|
||||
@@ -87,15 +72,10 @@ impl NymClient {
|
||||
client_config = client_config.with_urls(nyxd_url, api_url);
|
||||
let client = validator_client::Client::new_query(client_config)
|
||||
.expect("Could not construct query client");
|
||||
|
||||
#[cfg(not(feature = "mobile"))]
|
||||
let storage =
|
||||
credential_storage::initialise_storage(config.get_base().get_database_path()).await;
|
||||
|
||||
#[cfg(feature = "mobile")]
|
||||
let storage = mobile_storage::PersistentStorage {};
|
||||
|
||||
BandwidthController::new(storage, client)
|
||||
BandwidthController::new(
|
||||
credential_storage::initialise_storage(config.get_base().get_database_path()).await,
|
||||
client,
|
||||
)
|
||||
}
|
||||
|
||||
fn start_socks5_listener(
|
||||
@@ -208,7 +188,6 @@ impl NymClient {
|
||||
}
|
||||
|
||||
pub async fn start(self) -> Result<TaskManager, Socks5ClientError> {
|
||||
#[cfg(not(feature = "mobile"))]
|
||||
let base_builder = BaseClientBuilder::new_from_base_config(
|
||||
self.config.get_base(),
|
||||
self.key_manager,
|
||||
@@ -220,14 +199,6 @@ impl NymClient {
|
||||
.await?,
|
||||
);
|
||||
|
||||
#[cfg(feature = "mobile")]
|
||||
let base_builder = BaseClientBuilder::<_, QueryNyxdClient>::new_from_base_config(
|
||||
self.config.get_base(),
|
||||
self.key_manager,
|
||||
None,
|
||||
setup_empty_reply_surb_backend(self.config.get_debug_settings()),
|
||||
);
|
||||
|
||||
let self_address = base_builder.as_mix_recipient();
|
||||
let mut started_client = base_builder.start_base().await?;
|
||||
let client_input = started_client.client_input.register_producer();
|
||||
|
||||
@@ -43,6 +43,7 @@ pub(crate) struct Init {
|
||||
force_register_gateway: bool,
|
||||
|
||||
/// Comma separated list of rest endpoints of the nyxd validators
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long, alias = "nymd_validators", value_delimiter = ',')]
|
||||
nyxd_urls: Option<Vec<url::Url>>,
|
||||
|
||||
@@ -66,6 +67,7 @@ pub(crate) struct Init {
|
||||
|
||||
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||
/// with bandwidth credential requirement.
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long)]
|
||||
enabled_credentials_mode: Option<bool>,
|
||||
|
||||
@@ -82,7 +84,10 @@ impl From<Init> for OverrideConfig {
|
||||
use_anonymous_replies: init_config.use_reply_surbs,
|
||||
fastmode: init_config.fastmode,
|
||||
no_cover: init_config.no_cover,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: init_config.nyxd_urls,
|
||||
#[cfg(feature = "coconut")]
|
||||
enabled_credentials_mode: init_config.enabled_credentials_mode,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,10 @@ pub(crate) struct OverrideConfig {
|
||||
use_anonymous_replies: Option<bool>,
|
||||
fastmode: bool,
|
||||
no_cover: bool,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: Option<Vec<url::Url>>,
|
||||
#[cfg(feature = "coconut")]
|
||||
enabled_credentials_mode: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -77,8 +80,8 @@ pub(crate) async fn execute(args: &Cli) -> Result<(), Box<dyn Error + Send + Syn
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config {
|
||||
config
|
||||
pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Config {
|
||||
config = config
|
||||
.with_base(BaseConfig::with_high_default_traffic_volume, args.fastmode)
|
||||
.with_base(BaseConfig::with_disabled_cover_traffic, args.no_cover)
|
||||
.with_optional(Config::with_anonymous_replies, args.use_anonymous_replies)
|
||||
@@ -88,17 +91,24 @@ pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config {
|
||||
args.nym_apis,
|
||||
network_defaults::var_names::NYM_API,
|
||||
config::parse_urls,
|
||||
)
|
||||
.with_optional_custom_env_ext(
|
||||
BaseConfig::with_custom_nyxd,
|
||||
args.nyxd_urls,
|
||||
network_defaults::var_names::NYXD,
|
||||
config::parse_urls,
|
||||
)
|
||||
.with_optional_ext(
|
||||
BaseConfig::with_disabled_credentials,
|
||||
args.enabled_credentials_mode.map(|b| !b),
|
||||
)
|
||||
);
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
{
|
||||
config = config
|
||||
.with_optional_custom_env_ext(
|
||||
BaseConfig::with_custom_nyxd,
|
||||
args.nyxd_urls,
|
||||
network_defaults::var_names::NYXD,
|
||||
config::parse_urls,
|
||||
)
|
||||
.with_optional_ext(
|
||||
BaseConfig::with_disabled_credentials,
|
||||
args.enabled_credentials_mode.map(|b| !b),
|
||||
);
|
||||
}
|
||||
|
||||
config
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -43,6 +43,7 @@ pub(crate) struct Run {
|
||||
gateway: Option<identity::PublicKey>,
|
||||
|
||||
/// Comma separated list of rest endpoints of the nyxd validators
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long, alias = "nymd_validators", value_delimiter = ',')]
|
||||
nyxd_urls: Option<Vec<url::Url>>,
|
||||
|
||||
@@ -65,6 +66,7 @@ pub(crate) struct Run {
|
||||
|
||||
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||
/// with bandwidth credential requirement.
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long)]
|
||||
enabled_credentials_mode: Option<bool>,
|
||||
}
|
||||
@@ -77,7 +79,10 @@ impl From<Run> for OverrideConfig {
|
||||
use_anonymous_replies: run_config.use_anonymous_replies,
|
||||
fastmode: run_config.fastmode,
|
||||
no_cover: run_config.no_cover,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: run_config.nyxd_urls,
|
||||
#[cfg(feature = "coconut")]
|
||||
enabled_credentials_mode: run_config.enabled_credentials_mode,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use client_core::client::{
|
||||
};
|
||||
use log::*;
|
||||
use nymsphinx::addressing::clients::Recipient;
|
||||
use proxy_helpers::connection_controller::Controller;
|
||||
use proxy_helpers::connection_controller::{BroadcastActiveConnections, Controller};
|
||||
use std::net::SocketAddr;
|
||||
use tap::TapFallible;
|
||||
use task::TaskClient;
|
||||
@@ -69,7 +69,7 @@ impl SphinxSocksServer {
|
||||
// controller for managing all active connections
|
||||
let (mut active_streams_controller, controller_sender) = Controller::new(
|
||||
client_connection_tx,
|
||||
//BroadcastActiveConnections::Off,
|
||||
BroadcastActiveConnections::Off,
|
||||
self.shutdown.clone(),
|
||||
);
|
||||
tokio::spawn(async move {
|
||||
|
||||
@@ -15,6 +15,7 @@ crate-type = ["cdylib", "rlib"]
|
||||
[features]
|
||||
default = ["console_error_panic_hook"]
|
||||
offline-test = []
|
||||
coconut = ["coconut-interface", "credentials", "gateway-client/coconut"]
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3"
|
||||
@@ -32,12 +33,12 @@ wasm-bindgen-futures = "0.4"
|
||||
# internal
|
||||
client-core = { path = "../client-core", default-features = false, features = ["wasm"] }
|
||||
client-connections = { path = "../../common/client-connections" }
|
||||
coconut-interface = { path = "../../common/coconut-interface" }
|
||||
credentials = { path = "../../common/credentials" }
|
||||
coconut-interface = { path = "../../common/coconut-interface", optional = true }
|
||||
credentials = { path = "../../common/credentials", optional = true }
|
||||
crypto = { path = "../../common/crypto" }
|
||||
nymsphinx = { path = "../../common/nymsphinx" }
|
||||
topology = { path = "../../common/topology" }
|
||||
gateway-client = { path = "../../common/client-libs/gateway-client", default-features = false, features = ["wasm"] }
|
||||
gateway-client = { path = "../../common/client-libs/gateway-client", default-features = false, features = ["wasm", "coconut"] }
|
||||
validator-client = { path = "../../common/client-libs/validator-client", default-features = false }
|
||||
wasm-utils = { path = "../../common/wasm-utils" }
|
||||
task = { path = "../../common/task" }
|
||||
|
||||
@@ -125,11 +125,7 @@ pub struct Debug {
|
||||
|
||||
/// Defines maximum amount of time the client is going to wait for reply surbs before explicitly asking
|
||||
/// for more even though in theory they wouldn't need to.
|
||||
pub maximum_reply_surb_rerequest_waiting_period_ms: u64,
|
||||
|
||||
/// Defines maximum amount of time the client is going to wait for reply surbs before
|
||||
/// deciding it's never going to get them and would drop all pending messages
|
||||
pub maximum_reply_surb_drop_waiting_period_ms: u64,
|
||||
pub maximum_reply_surb_waiting_period_ms: u64,
|
||||
|
||||
/// Defines maximum amount of time given reply surb is going to be valid for.
|
||||
/// This is going to be superseded by key rotation once implemented.
|
||||
@@ -172,11 +168,8 @@ impl From<Debug> for ConfigDebug {
|
||||
minimum_reply_surb_request_size: debug.minimum_reply_surb_request_size,
|
||||
maximum_reply_surb_request_size: debug.maximum_reply_surb_request_size,
|
||||
maximum_allowed_reply_surb_request_size: debug.maximum_allowed_reply_surb_request_size,
|
||||
maximum_reply_surb_rerequest_waiting_period: Duration::from_millis(
|
||||
debug.maximum_reply_surb_rerequest_waiting_period_ms,
|
||||
),
|
||||
maximum_reply_surb_drop_waiting_period: Duration::from_millis(
|
||||
debug.maximum_reply_surb_drop_waiting_period_ms,
|
||||
maximum_reply_surb_waiting_period: Duration::from_millis(
|
||||
debug.maximum_reply_surb_waiting_period_ms,
|
||||
),
|
||||
maximum_reply_surb_age: Duration::from_millis(debug.maximum_reply_surb_age_ms),
|
||||
maximum_reply_key_age: Duration::from_millis(debug.maximum_reply_key_age_ms),
|
||||
@@ -207,11 +200,8 @@ impl From<ConfigDebug> for Debug {
|
||||
minimum_reply_surb_request_size: debug.minimum_reply_surb_request_size,
|
||||
maximum_reply_surb_request_size: debug.maximum_reply_surb_request_size,
|
||||
maximum_allowed_reply_surb_request_size: debug.maximum_allowed_reply_surb_request_size,
|
||||
maximum_reply_surb_rerequest_waiting_period_ms: debug
|
||||
.maximum_reply_surb_rerequest_waiting_period
|
||||
.as_millis() as u64,
|
||||
maximum_reply_surb_drop_waiting_period_ms: debug
|
||||
.maximum_reply_surb_drop_waiting_period
|
||||
maximum_reply_surb_waiting_period_ms: debug
|
||||
.maximum_reply_surb_waiting_period
|
||||
.as_millis() as u64,
|
||||
maximum_reply_surb_age_ms: debug.maximum_reply_surb_age.as_millis() as u64,
|
||||
maximum_reply_key_age_ms: debug.maximum_reply_key_age.as_millis() as u64,
|
||||
|
||||
@@ -25,6 +25,12 @@ pub enum ConnectionCommand {
|
||||
// Announce that at a connection was closed. E.g the `OutQueueControl` uses this to discard
|
||||
// transmission lanes.
|
||||
Close(ConnectionId),
|
||||
|
||||
// In the network requester for example, we usually want to broadcast active connections
|
||||
// regularly, so we know what connections we need to request lane queue lengths for from the
|
||||
// client.
|
||||
// In the socks5-client, this is not needed since have direct access to the lane queue lengths.
|
||||
ActiveConnections(Vec<ConnectionId>),
|
||||
}
|
||||
|
||||
// The `OutQueueControl` publishes the backlog per lane, primarily so that upstream can slow down
|
||||
|
||||
@@ -18,7 +18,7 @@ async-trait = { version = "0.1.51" }
|
||||
tokio = { version = "1.24.1", features = ["macros"] }
|
||||
|
||||
# internal
|
||||
coconut-interface = { path = "../../coconut-interface" }
|
||||
coconut-interface = { path = "../../coconut-interface", optional = true }
|
||||
credentials = { path = "../../credentials" }
|
||||
crypto = { path = "../../crypto" }
|
||||
gateway-requests = { path = "../../../gateway/gateway-requests" }
|
||||
@@ -28,7 +28,6 @@ pemstore = { path = "../../pemstore" }
|
||||
validator-client = { path = "../validator-client" }
|
||||
task = { path = "../../task" }
|
||||
serde = { version = "1.0", features = ["derive"]}
|
||||
mobile-storage = { path = "../../mobile-storage" }
|
||||
|
||||
|
||||
[dependencies.tungstenite]
|
||||
@@ -80,5 +79,5 @@ features = ["js"]
|
||||
#url = "2.1"
|
||||
|
||||
[features]
|
||||
coconut = ["gateway-requests/coconut", "coconut-interface", "credentials/coconut"]
|
||||
wasm = []
|
||||
mobile = []
|
||||
|
||||
@@ -1,34 +1,27 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
use crate::error::GatewayClientError;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use crate::wasm_mockups::Storage;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(feature = "mobile"))]
|
||||
use credential_storage::storage::Storage;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(feature = "mobile")]
|
||||
use mobile_storage::Storage;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(feature = "mobile")]
|
||||
use mobile_storage::StorageError;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[cfg(all(target_arch = "wasm32", feature = "coconut"))]
|
||||
use crate::wasm_mockups::StorageError;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(feature = "mobile"))]
|
||||
#[cfg(all(not(target_arch = "wasm32"), feature = "coconut"))]
|
||||
use credential_storage::error::StorageError;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use crate::wasm_mockups::{Client, CosmWasmClient};
|
||||
#[cfg(feature = "coconut")]
|
||||
use std::str::FromStr;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use validator_client::{nyxd::CosmWasmClient, Client};
|
||||
#[cfg(feature = "coconut")]
|
||||
use {
|
||||
coconut_interface::Base58,
|
||||
credentials::coconut::{
|
||||
@@ -41,13 +34,8 @@ use {
|
||||
use crate::wasm_mockups::PersistentStorage;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(feature = "mobile"))]
|
||||
use credential_storage::PersistentStorage;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(feature = "mobile")]
|
||||
use mobile_storage::PersistentStorage;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct BandwidthController<C: Clone, St: Storage = PersistentStorage> {
|
||||
@@ -67,6 +55,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub async fn prepare_coconut_credential(
|
||||
&self,
|
||||
) -> Result<(coconut_interface::Credential, i64), GatewayClientError> {
|
||||
@@ -109,6 +98,7 @@ where
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub async fn consume_credential(&self, id: i64) -> Result<(), GatewayClientError> {
|
||||
Ok(self.storage.consume_coconut_credential(id).await?)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ pub use crate::packet_router::{
|
||||
};
|
||||
use crate::socket_state::{PartiallyDelegated, SocketState};
|
||||
use crate::{cleanup_socket_message, try_decrypt_binary_message};
|
||||
use coconut_interface::Credential;
|
||||
use crypto::asymmetric::identity;
|
||||
use futures::{SinkExt, StreamExt};
|
||||
use gateway_requests::authentication::encrypted_address::EncryptedAddressBytes;
|
||||
@@ -26,19 +25,16 @@ use std::time::Duration;
|
||||
use task::TaskClient;
|
||||
use tungstenite::protocol::Message;
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
use coconut_interface::Credential;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use credential_storage::PersistentStorage;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use tokio_tungstenite::connect_async;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use validator_client::nyxd::CosmWasmClient;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(feature = "mobile"))]
|
||||
use credential_storage::PersistentStorage;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(feature = "mobile")]
|
||||
use mobile_storage::PersistentStorage;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use crate::wasm_mockups::CosmWasmClient;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
@@ -57,6 +53,7 @@ pub struct GatewayClient<C: Clone> {
|
||||
bandwidth_remaining: i64,
|
||||
gateway_address: String,
|
||||
gateway_identity: identity::PublicKey,
|
||||
gateway_owner: String,
|
||||
local_identity: Arc<identity::KeyPair>,
|
||||
shared_key: Option<Arc<SharedKeys>>,
|
||||
connection: SocketState,
|
||||
@@ -87,6 +84,7 @@ where
|
||||
gateway_address: String,
|
||||
local_identity: Arc<identity::KeyPair>,
|
||||
gateway_identity: identity::PublicKey,
|
||||
gateway_owner: String,
|
||||
shared_key: Option<Arc<SharedKeys>>,
|
||||
mixnet_message_sender: MixnetMessageSender,
|
||||
ack_sender: AcknowledgementSender,
|
||||
@@ -100,6 +98,7 @@ where
|
||||
bandwidth_remaining: 0,
|
||||
gateway_address,
|
||||
gateway_identity,
|
||||
gateway_owner,
|
||||
local_identity,
|
||||
shared_key,
|
||||
connection: SocketState::NotConnected,
|
||||
@@ -133,6 +132,7 @@ where
|
||||
pub fn new_init(
|
||||
gateway_address: String,
|
||||
gateway_identity: identity::PublicKey,
|
||||
gateway_owner: String,
|
||||
local_identity: Arc<identity::KeyPair>,
|
||||
response_timeout_duration: Duration,
|
||||
) -> Self {
|
||||
@@ -151,6 +151,7 @@ where
|
||||
bandwidth_remaining: 0,
|
||||
gateway_address,
|
||||
gateway_identity,
|
||||
gateway_owner,
|
||||
local_identity,
|
||||
shared_key: None,
|
||||
connection: SocketState::NotConnected,
|
||||
@@ -540,6 +541,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
async fn claim_coconut_bandwidth(
|
||||
&mut self,
|
||||
credential: Credential,
|
||||
@@ -589,21 +591,28 @@ where
|
||||
return self.try_claim_testnet_bandwidth().await;
|
||||
}
|
||||
|
||||
let _gateway_owner = self.gateway_owner.clone();
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
let (credential, credential_id) = self
|
||||
.bandwidth_controller
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.prepare_coconut_credential()
|
||||
.await?;
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
return self.try_claim_testnet_bandwidth().await;
|
||||
|
||||
self.claim_coconut_bandwidth(credential).await?;
|
||||
self.bandwidth_controller
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.consume_credential(credential_id)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
#[cfg(feature = "coconut")]
|
||||
{
|
||||
self.claim_coconut_bandwidth(credential).await?;
|
||||
self.bandwidth_controller
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.consume_credential(credential_id)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn estimate_required_bandwidth(&self, packets: &[MixPacket]) -> i64 {
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use crate::wasm_mockups::StorageError;
|
||||
#[cfg(not(feature = "mobile"))]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use credential_storage::error::StorageError;
|
||||
use gateway_requests::registration::handshake::error::HandshakeError;
|
||||
#[cfg(feature = "mobile")]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use mobile_storage::StorageError;
|
||||
use std::io;
|
||||
use thiserror::Error;
|
||||
use tungstenite::Error as WsError;
|
||||
@@ -30,6 +26,7 @@ pub enum GatewayClientError {
|
||||
#[error("There was a credential storage error - {0}")]
|
||||
CredentialStorageError(#[from] StorageError),
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
#[error("Coconut error - {0}")]
|
||||
CoconutError(#[from] coconut_interface::CoconutError),
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ futures = "0.3"
|
||||
|
||||
coconut-interface = { path = "../../coconut-interface" }
|
||||
network-defaults = { path = "../../network-defaults" }
|
||||
nym-api-requests = { path = "../../../nym-api/nym-api-requests" }
|
||||
nym-api-requests = { path = "../../../nym-api/nym-api-requests", features = ["coconut"] }
|
||||
|
||||
# required for nyxd-client
|
||||
# at some point it might be possible to make it wasm-compatible
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use clap::Parser;
|
||||
use log::{debug, info};
|
||||
|
||||
use coconut_bandwidth_contract_common::msg::InstantiateMsg;
|
||||
use validator_client::nyxd::AccountId;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
@@ -15,7 +12,7 @@ pub struct Args {
|
||||
pub pool_addr: String,
|
||||
|
||||
#[clap(long)]
|
||||
pub multisig_addr: Option<AccountId>,
|
||||
pub multisig_addr: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
pub mix_denom: Option<String>,
|
||||
@@ -27,10 +24,8 @@ pub async fn generate(args: Args) {
|
||||
debug!("Received arguments: {:?}", args);
|
||||
|
||||
let multisig_addr = args.multisig_addr.unwrap_or_else(|| {
|
||||
let address = std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
||||
.expect("Multisig address has to be set");
|
||||
AccountId::from_str(address.as_str())
|
||||
.expect("Failed converting multisig address to AccountId")
|
||||
std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
||||
.expect("Multisig address has to be set")
|
||||
});
|
||||
|
||||
let mix_denom = args.mix_denom.unwrap_or_else(|| {
|
||||
@@ -39,7 +34,7 @@ pub async fn generate(args: Args) {
|
||||
|
||||
let instantiate_msg = InstantiateMsg {
|
||||
pool_addr: args.pool_addr,
|
||||
multisig_addr: multisig_addr.to_string(),
|
||||
multisig_addr,
|
||||
mix_denom,
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ use std::str::FromStr;
|
||||
|
||||
use coconut_dkg_common::msg::InstantiateMsg;
|
||||
use coconut_dkg_common::types::TimeConfiguration;
|
||||
use validator_client::nyxd::AccountId;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
@@ -15,7 +14,7 @@ pub struct Args {
|
||||
pub group_addr: String,
|
||||
|
||||
#[clap(long)]
|
||||
pub multisig_addr: Option<AccountId>,
|
||||
pub multisig_addr: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
pub public_key_submission_time_secs: Option<u64>,
|
||||
@@ -45,10 +44,8 @@ pub async fn generate(args: Args) {
|
||||
debug!("Received arguments: {:?}", args);
|
||||
|
||||
let multisig_addr = args.multisig_addr.unwrap_or_else(|| {
|
||||
let address = std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
||||
.expect("Multisig address has to be set");
|
||||
AccountId::from_str(address.as_str())
|
||||
.expect("Failed converting multisig address to AccountId")
|
||||
std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
||||
.expect("Multisig address has to be set")
|
||||
});
|
||||
|
||||
let mix_denom = args.mix_denom.unwrap_or_else(|| {
|
||||
@@ -89,7 +86,7 @@ pub async fn generate(args: Args) {
|
||||
|
||||
let instantiate_msg = InstantiateMsg {
|
||||
group_addr: args.group_addr,
|
||||
multisig_addr: multisig_addr.to_string(),
|
||||
multisig_addr,
|
||||
time_configuration: Some(time_configuration),
|
||||
mix_denom,
|
||||
};
|
||||
|
||||
@@ -6,17 +6,15 @@ use log::{debug, info};
|
||||
|
||||
use cosmwasm_std::Decimal;
|
||||
use mixnet_contract_common::{InitialRewardingParams, InstantiateMsg, Percent};
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use validator_client::nyxd::AccountId;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[clap(long)]
|
||||
pub rewarding_validator_address: Option<AccountId>,
|
||||
pub rewarding_validator_address: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
pub vesting_contract_address: Option<AccountId>,
|
||||
pub vesting_contract_address: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
pub rewarding_denom: Option<String>,
|
||||
@@ -79,17 +77,13 @@ pub async fn generate(args: Args) {
|
||||
debug!("initial_rewarding_params: {:?}", initial_rewarding_params);
|
||||
|
||||
let rewarding_validator_address = args.rewarding_validator_address.unwrap_or_else(|| {
|
||||
let address = std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
||||
.expect("Rewarding validator address has to be set");
|
||||
AccountId::from_str(address.as_str())
|
||||
.expect("Failed converting rewarding validator address to AccountId")
|
||||
std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
||||
.expect("Rewarding validator address has to be set")
|
||||
});
|
||||
|
||||
let vesting_contract_address = args.vesting_contract_address.unwrap_or_else(|| {
|
||||
let address = std::env::var(network_defaults::var_names::VESTING_CONTRACT_ADDRESS)
|
||||
.expect("Vesting contract address has to be set");
|
||||
AccountId::from_str(address.as_str())
|
||||
.expect("Failed converting vesting contract address to AccountId")
|
||||
std::env::var(network_defaults::var_names::VESTING_CONTRACT_ADDRESS)
|
||||
.expect("Vesting contract address has to be set")
|
||||
});
|
||||
|
||||
let rewarding_denom = args.rewarding_denom.unwrap_or_else(|| {
|
||||
@@ -98,8 +92,8 @@ pub async fn generate(args: Args) {
|
||||
});
|
||||
|
||||
let instantiate_msg = InstantiateMsg {
|
||||
rewarding_validator_address: rewarding_validator_address.to_string(),
|
||||
vesting_contract_address: vesting_contract_address.to_string(),
|
||||
rewarding_validator_address,
|
||||
vesting_contract_address,
|
||||
rewarding_denom,
|
||||
epochs_in_interval: args.epochs_in_interval,
|
||||
epoch_duration: Duration::from_secs(args.epoch_duration),
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use clap::Parser;
|
||||
use log::{debug, info};
|
||||
|
||||
use cosmwasm_std::Decimal;
|
||||
use cw_utils::{Duration, Threshold};
|
||||
use log::{debug, info};
|
||||
use multisig_contract_common::msg::InstantiateMsg;
|
||||
use validator_client::nyxd::AccountId;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
@@ -22,10 +20,10 @@ pub struct Args {
|
||||
pub max_voting_period: u64,
|
||||
|
||||
#[clap(long)]
|
||||
pub coconut_bandwidth_contract_address: Option<AccountId>,
|
||||
pub coconut_bandwidth_contract_address: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
pub coconut_dkg_contract_address: Option<AccountId>,
|
||||
pub coconut_dkg_contract_address: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn generate(args: Args) {
|
||||
@@ -35,18 +33,13 @@ pub async fn generate(args: Args) {
|
||||
|
||||
let coconut_bandwidth_contract_address =
|
||||
args.coconut_bandwidth_contract_address.unwrap_or_else(|| {
|
||||
let address =
|
||||
std::env::var(network_defaults::var_names::COCONUT_BANDWIDTH_CONTRACT_ADDRESS)
|
||||
.expect("Coconut bandwidth contract address has to be set");
|
||||
AccountId::from_str(address.as_str())
|
||||
.expect("Failed converting bandwidth contract address to AccountId")
|
||||
std::env::var(network_defaults::var_names::COCONUT_BANDWIDTH_CONTRACT_ADDRESS)
|
||||
.expect("Coconut bandwidth contract address has to be set")
|
||||
});
|
||||
|
||||
let coconut_dkg_contract_address = args.coconut_dkg_contract_address.unwrap_or_else(|| {
|
||||
let address = std::env::var(network_defaults::var_names::COCONUT_DKG_CONTRACT_ADDRESS)
|
||||
.expect("Coconut DKG contract address has to be set");
|
||||
AccountId::from_str(address.as_str())
|
||||
.expect("Failed converting DKG contract address to AccountId")
|
||||
std::env::var(network_defaults::var_names::COCONUT_DKG_CONTRACT_ADDRESS)
|
||||
.expect("Coconut DKG contract address has to be set")
|
||||
});
|
||||
|
||||
let instantiate_msg = InstantiateMsg {
|
||||
@@ -56,8 +49,8 @@ pub async fn generate(args: Args) {
|
||||
.expect("threshold can't be converted to Decimal"),
|
||||
},
|
||||
max_voting_period: Duration::Time(args.max_voting_period),
|
||||
coconut_bandwidth_contract_address: coconut_bandwidth_contract_address.to_string(),
|
||||
coconut_dkg_contract_address: coconut_dkg_contract_address.to_string(),
|
||||
coconut_bandwidth_contract_address,
|
||||
coconut_dkg_contract_address,
|
||||
};
|
||||
|
||||
debug!("instantiate_msg: {:?}", instantiate_msg);
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use clap::Parser;
|
||||
use log::{debug, info};
|
||||
|
||||
use validator_client::nyxd::AccountId;
|
||||
use vesting_contract_common::InitMsg;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct Args {
|
||||
#[clap(long)]
|
||||
pub mixnet_contract_address: Option<AccountId>,
|
||||
pub mixnet_contract_address: Option<String>,
|
||||
|
||||
#[clap(long)]
|
||||
pub mix_denom: Option<String>,
|
||||
@@ -24,10 +21,8 @@ pub async fn generate(args: Args) {
|
||||
debug!("Received arguments: {:?}", args);
|
||||
|
||||
let mixnet_contract_address = args.mixnet_contract_address.unwrap_or_else(|| {
|
||||
let address = std::env::var(network_defaults::var_names::MIXNET_CONTRACT_ADDRESS)
|
||||
.expect("Mixnet contract address has to be set");
|
||||
AccountId::from_str(address.as_str())
|
||||
.expect("Failed converting mixnet address to AccountId")
|
||||
std::env::var(network_defaults::var_names::MIXNET_CONTRACT_ADDRESS)
|
||||
.expect("Mixnet contract address has to be set")
|
||||
});
|
||||
|
||||
let mix_denom = args.mix_denom.unwrap_or_else(|| {
|
||||
@@ -35,7 +30,7 @@ pub async fn generate(args: Args) {
|
||||
});
|
||||
|
||||
let instantiate_msg = InitMsg {
|
||||
mixnet_contract_address: mixnet_contract_address.to_string(),
|
||||
mixnet_contract_address,
|
||||
mix_denom,
|
||||
};
|
||||
|
||||
|
||||
@@ -15,4 +15,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
thiserror = "1"
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0.0"
|
||||
serde_json = "1.0.0"
|
||||
|
||||
[features]
|
||||
coconut = ["dkg"]
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#[cfg(feature = "dkg")]
|
||||
#[cfg(feature = "coconut")]
|
||||
use dkg::{error::DkgError, Dealing};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
@@ -70,14 +70,14 @@ impl<'de> Deserialize<'de> for ContractSafeBytes {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "dkg")]
|
||||
#[cfg(feature = "coconut")]
|
||||
impl<'a> From<&'a Dealing> for ContractSafeBytes {
|
||||
fn from(dealing: &'a Dealing) -> Self {
|
||||
ContractSafeBytes(dealing.to_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "dkg")]
|
||||
#[cfg(feature = "coconut")]
|
||||
impl<'a> TryFrom<&'a ContractSafeBytes> for Dealing {
|
||||
type Error = DkgError;
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@ pub struct InitMsg {
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MigrateMsg {}
|
||||
pub struct MigrateMsg {
|
||||
// I'm making it explicit so that we wouldn't accidentally forget about it
|
||||
pub manually_verified_no_staking_addresses: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default)]
|
||||
pub struct VestingSpecification {
|
||||
|
||||
@@ -7,7 +7,7 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bls12_381 = { version = "0.5", default-features = false, features = ["pairings", "alloc", "experimental"] }
|
||||
cosmrs = { git = "https://github.com/neacsu/cosmos-rust", branch = "neacsu/feegrant_support" }
|
||||
cosmrs = { git = "https://github.com/neacsu/cosmos-rust", branch = "neacsu/feegrant_support", optional = true }
|
||||
thiserror = "1.0"
|
||||
|
||||
# I guess temporarily until we get serde support in coconut up and running
|
||||
@@ -19,3 +19,5 @@ validator-client = { path = "../client-libs/validator-client" }
|
||||
[dev-dependencies]
|
||||
rand = "0.7.3"
|
||||
|
||||
[features]
|
||||
coconut = ["cosmrs"]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
use coconut_interface::CoconutError;
|
||||
use crypto::asymmetric::encryption::KeyRecoveryError;
|
||||
use validator_client::ValidatorClientError;
|
||||
@@ -15,6 +16,7 @@ pub enum Error {
|
||||
#[error("Could not contact any validator")]
|
||||
NoValidatorsAvailable,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
#[error("Ran into a coconut error - {0}")]
|
||||
CoconutError(#[from] CoconutError),
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub mod coconut;
|
||||
pub mod error;
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
pub mod token;
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub use coconut::utils::{obtain_aggregate_signature, obtain_aggregate_verification_key};
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crypto::asymmetric::identity::{PublicKey, Signature, PUBLIC_KEY_LENGTH, SIGNATURE_LENGTH};
|
||||
|
||||
use crate::error::Error;
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub struct TokenCredential {
|
||||
verification_key: PublicKey,
|
||||
gateway_identity: PublicKey,
|
||||
bandwidth: u64,
|
||||
signature: Signature,
|
||||
}
|
||||
|
||||
impl TokenCredential {
|
||||
pub fn new(
|
||||
verification_key: PublicKey,
|
||||
gateway_identity: PublicKey,
|
||||
bandwidth: u64,
|
||||
signature: Signature,
|
||||
) -> Self {
|
||||
TokenCredential {
|
||||
verification_key,
|
||||
gateway_identity,
|
||||
bandwidth,
|
||||
signature,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn verification_key(&self) -> PublicKey {
|
||||
self.verification_key
|
||||
}
|
||||
|
||||
pub fn gateway_identity(&self) -> PublicKey {
|
||||
self.gateway_identity
|
||||
}
|
||||
|
||||
pub fn bandwidth(&self) -> u64 {
|
||||
self.bandwidth
|
||||
}
|
||||
|
||||
pub fn signature_bytes(&self) -> [u8; 64] {
|
||||
self.signature.to_bytes()
|
||||
}
|
||||
|
||||
pub fn verify_signature(&self) -> bool {
|
||||
let message: Vec<u8> = self
|
||||
.verification_key
|
||||
.to_bytes()
|
||||
.iter()
|
||||
.chain(self.gateway_identity.to_bytes().iter())
|
||||
.copied()
|
||||
.collect();
|
||||
self.verification_key
|
||||
.verify(&message, &self.signature)
|
||||
.is_ok()
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self) -> Vec<u8> {
|
||||
self.verification_key
|
||||
.to_bytes()
|
||||
.iter()
|
||||
.chain(self.gateway_identity.to_bytes().iter())
|
||||
.chain(self.bandwidth.to_be_bytes().iter())
|
||||
.chain(self.signature.to_bytes().iter())
|
||||
.copied()
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn from_bytes(b: &[u8]) -> Result<Self, Error> {
|
||||
if b.len() != 2 * PUBLIC_KEY_LENGTH + 8 + SIGNATURE_LENGTH {
|
||||
return Err(Error::BandwidthCredentialError);
|
||||
}
|
||||
let verification_key = PublicKey::from_bytes(&b[..PUBLIC_KEY_LENGTH])
|
||||
.map_err(|_| Error::BandwidthCredentialError)?;
|
||||
let gateway_identity = PublicKey::from_bytes(&b[PUBLIC_KEY_LENGTH..2 * PUBLIC_KEY_LENGTH])
|
||||
.map_err(|_| Error::BandwidthCredentialError)?;
|
||||
let bandwidth = u64::from_be_bytes(
|
||||
b[2 * PUBLIC_KEY_LENGTH..2 * PUBLIC_KEY_LENGTH + 8]
|
||||
.try_into()
|
||||
// unwrapping is safe because we know we have 8 bytes
|
||||
.unwrap(),
|
||||
);
|
||||
let signature = Signature::from_bytes(&b[2 * PUBLIC_KEY_LENGTH + 8..])
|
||||
.map_err(|_| Error::BandwidthCredentialError)?;
|
||||
Ok(TokenCredential {
|
||||
verification_key,
|
||||
gateway_identity,
|
||||
bandwidth,
|
||||
signature,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn token_serde() {
|
||||
// pre-generated, valid values
|
||||
let verification_key = PublicKey::from_bytes(&[
|
||||
103, 105, 71, 177, 149, 245, 26, 32, 73, 121, 76, 50, 94, 88, 119, 231, 91, 229, 167,
|
||||
56, 39, 62, 185, 39, 83, 246, 153, 27, 17, 155, 109, 73,
|
||||
])
|
||||
.unwrap();
|
||||
let gateway_identity = PublicKey::from_bytes(&[
|
||||
37, 113, 137, 189, 157, 82, 35, 2, 187, 136, 61, 119, 98, 5, 245, 82, 46, 124, 67, 45,
|
||||
165, 255, 53, 222, 185, 252, 6, 148, 128, 15, 206, 19,
|
||||
])
|
||||
.unwrap();
|
||||
let signature = Signature::from_bytes(&[
|
||||
117, 251, 162, 217, 57, 2, 50, 210, 206, 81, 236, 90, 74, 201, 69, 237, 240, 247, 214,
|
||||
158, 220, 89, 235, 222, 85, 134, 73, 73, 8, 60, 25, 39, 183, 28, 83, 193, 31, 174, 25,
|
||||
24, 38, 215, 205, 228, 159, 135, 35, 4, 171, 59, 100, 157, 12, 249, 77, 52, 143, 4, 32,
|
||||
28, 147, 70, 182, 14,
|
||||
])
|
||||
.unwrap();
|
||||
let credential = TokenCredential::new(verification_key, gateway_identity, 1024, signature);
|
||||
let serialized_credential = credential.to_bytes();
|
||||
let deserialized_credential = TokenCredential::from_bytes(&serialized_credential).unwrap();
|
||||
assert_eq!(
|
||||
credential.verification_key,
|
||||
deserialized_credential.verification_key
|
||||
);
|
||||
assert_eq!(
|
||||
credential.gateway_identity,
|
||||
deserialized_credential.gateway_identity
|
||||
);
|
||||
assert_eq!(credential.bandwidth, deserialized_credential.bandwidth);
|
||||
assert_eq!(
|
||||
credential.signature.to_bytes(),
|
||||
deserialized_credential.signature.to_bytes()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub mod bandwidth;
|
||||
@@ -1,11 +0,0 @@
|
||||
[package]
|
||||
name = "mobile-storage"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
async-trait = { version = "0.1.51" }
|
||||
thiserror = "1.0"
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use async_trait::async_trait;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum StorageError {
|
||||
#[error("Android is not yet supported")]
|
||||
AndroidNotSupported,
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[error("Code shouldn't reach this point")]
|
||||
InconsistentData,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct PersistentStorage {}
|
||||
|
||||
pub struct CoconutCredential {
|
||||
pub id: i64,
|
||||
pub voucher_value: String,
|
||||
pub voucher_info: String,
|
||||
pub serial_number: String,
|
||||
pub binding_number: String,
|
||||
pub signature: String,
|
||||
pub epoch_id: String,
|
||||
pub consumed: bool,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait Storage: Send + Sync {
|
||||
async fn insert_coconut_credential(
|
||||
&self,
|
||||
voucher_value: String,
|
||||
voucher_info: String,
|
||||
serial_number: String,
|
||||
binding_number: String,
|
||||
signature: String,
|
||||
) -> Result<(), StorageError>;
|
||||
|
||||
async fn get_next_coconut_credential(&self) -> Result<CoconutCredential, StorageError>;
|
||||
|
||||
async fn consume_coconut_credential(&self, id: i64) -> Result<(), StorageError>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Storage for PersistentStorage {
|
||||
async fn insert_coconut_credential(
|
||||
&self,
|
||||
_voucher_value: String,
|
||||
_voucher_info: String,
|
||||
_serial_number: String,
|
||||
_binding_number: String,
|
||||
_signature: String,
|
||||
) -> Result<(), StorageError> {
|
||||
Err(StorageError::AndroidNotSupported)
|
||||
}
|
||||
|
||||
async fn get_next_coconut_credential(&self) -> Result<CoconutCredential, StorageError> {
|
||||
Err(StorageError::AndroidNotSupported)
|
||||
}
|
||||
|
||||
async fn consume_coconut_credential(&self, _id: i64) -> Result<(), StorageError> {
|
||||
Err(StorageError::AndroidNotSupported)
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,12 @@ use futures::StreamExt;
|
||||
use log::*;
|
||||
use ordered_buffer::{OrderedMessage, OrderedMessageBuffer, ReadContiguousData};
|
||||
use socks5_requests::ConnectionId;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
time::Duration,
|
||||
};
|
||||
use task::TaskClient;
|
||||
use tokio::time;
|
||||
|
||||
/// A generic message produced after reading from a socket/connection. It includes data that was
|
||||
/// actually read alongside boolean indicating whether the connection got closed so that
|
||||
@@ -83,6 +87,10 @@ pub struct Controller {
|
||||
// Broadcast closed connections
|
||||
client_connection_tx: ConnectionCommandSender,
|
||||
|
||||
// The controller can broadcast active connections. This is useful in the network-requester
|
||||
// where its used to query the client for lane queue lengths
|
||||
broadcast_connections: BroadcastActiveConnections,
|
||||
|
||||
// TODO: this can potentially be abused to ddos and kill provider. Not sure at this point
|
||||
// how to handle it more gracefully
|
||||
|
||||
@@ -96,6 +104,7 @@ pub struct Controller {
|
||||
impl Controller {
|
||||
pub fn new(
|
||||
client_connection_tx: ConnectionCommandSender,
|
||||
broadcast_connections: BroadcastActiveConnections,
|
||||
shutdown: TaskClient,
|
||||
) -> (Self, ControllerSender) {
|
||||
let (sender, receiver) = mpsc::unbounded();
|
||||
@@ -105,6 +114,7 @@ impl Controller {
|
||||
receiver,
|
||||
recently_closed: HashSet::new(),
|
||||
client_connection_tx,
|
||||
broadcast_connections,
|
||||
pending_messages: HashMap::new(),
|
||||
shutdown,
|
||||
},
|
||||
@@ -155,6 +165,15 @@ impl Controller {
|
||||
}
|
||||
}
|
||||
|
||||
fn broadcast_active_connections(&mut self) {
|
||||
// What about the recently closed ones? Hopefully we can ignore them ...
|
||||
let conn_ids = self.active_connections.keys().copied().collect();
|
||||
|
||||
self.client_connection_tx
|
||||
.unbounded_send(ConnectionCommand::ActiveConnections(conn_ids))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn send_to_connection(&mut self, conn_id: ConnectionId, payload: Vec<u8>, is_closed: bool) {
|
||||
if let Some(active_connection) = self.active_connections.get_mut(&conn_id) {
|
||||
if !payload.is_empty() {
|
||||
@@ -211,6 +230,8 @@ impl Controller {
|
||||
}
|
||||
|
||||
pub async fn run(&mut self) {
|
||||
let mut interval = time::interval(Duration::from_millis(500));
|
||||
|
||||
loop {
|
||||
tokio::select! {
|
||||
command = self.receiver.next() => match command {
|
||||
@@ -226,6 +247,11 @@ impl Controller {
|
||||
break;
|
||||
}
|
||||
},
|
||||
_ = interval.tick() => {
|
||||
if self.broadcast_connections == BroadcastActiveConnections::On {
|
||||
self.broadcast_active_connections();
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
self.shutdown.recv_timeout().await;
|
||||
|
||||
@@ -51,7 +51,16 @@ pub fn instantiate(
|
||||
}
|
||||
|
||||
#[entry_point]
|
||||
pub fn migrate(_deps: DepsMut<'_>, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
|
||||
pub fn migrate(_deps: DepsMut<'_>, _env: Env, msg: MigrateMsg) -> Result<Response, ContractError> {
|
||||
// we can't perform this check inside the migrate function since there are 12k addresses to check
|
||||
// and this invariant MUST hold, otherwise we're gonna have bad time
|
||||
if !msg.manually_verified_no_staking_addresses {
|
||||
return Err(ContractError::Other {
|
||||
message:
|
||||
"the assumption that nobody has set a staking address hasn't been manually verified"
|
||||
.to_string(),
|
||||
});
|
||||
}
|
||||
Ok(Response::new())
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ pub trait VestingAccount {
|
||||
) -> Result<Uint128, ContractError>;
|
||||
|
||||
/// Returns the set of coins that are not spendable (can still be delegated tough) (i.e. locked),
|
||||
/// defined as vesting coins that are not delegated or pledged.
|
||||
/// defined as the vesting coins that are not delegated or pledged.
|
||||
///
|
||||
/// To get spendable coins of a vesting account, first the total balance must
|
||||
/// be retrieved and the locked tokens can be subtracted from the total balance.
|
||||
|
||||
@@ -48,7 +48,7 @@ mod tests {
|
||||
use crate::traits::{GatewayBondingAccount, MixnodeBondingAccount};
|
||||
use crate::vesting::{populate_vesting_periods, Account};
|
||||
use cosmwasm_std::testing::{mock_env, mock_info};
|
||||
use cosmwasm_std::{coin, coins, Addr, Coin, MessageInfo, Timestamp, Uint128};
|
||||
use cosmwasm_std::{coin, coins, Addr, Coin, Timestamp, Uint128};
|
||||
use mixnet_contract_common::mixnode::MixNodeCostParams;
|
||||
use mixnet_contract_common::{Gateway, MixNode, Percent};
|
||||
use vesting_contract_common::messages::{ExecuteMsg, VestingSpecification};
|
||||
@@ -1156,270 +1156,4 @@ mod tests {
|
||||
// the 50M delegation wasn't a thing here for VESTING tokens either
|
||||
assert_eq!(delegated_vesting.amount, Uint128::zero());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vesting_cap_escape() {
|
||||
let mut deps = init_contract();
|
||||
let mut env = mock_env();
|
||||
|
||||
let vesting_period_length_secs = 3600;
|
||||
let blocks_per_period = 100;
|
||||
|
||||
let account_creation_timestamp = 1650000000;
|
||||
let vesting_start_timestamp = 1650000000;
|
||||
|
||||
let account_creation_blockheight = 12345;
|
||||
|
||||
env.block.height = account_creation_blockheight;
|
||||
env.block.time = Timestamp::from_seconds(account_creation_timestamp);
|
||||
|
||||
let periods = populate_vesting_periods(
|
||||
vesting_start_timestamp,
|
||||
VestingSpecification::new(None, Some(vesting_period_length_secs), None),
|
||||
);
|
||||
|
||||
let vesting_account = Account::new(
|
||||
Addr::unchecked("owner"),
|
||||
None,
|
||||
Coin {
|
||||
amount: Uint128::new(40_000_000_000_000),
|
||||
denom: TEST_COIN_DENOM.to_string(),
|
||||
},
|
||||
Timestamp::from_seconds(account_creation_timestamp),
|
||||
periods,
|
||||
Some(PledgeCap::Percent(
|
||||
Percent::from_percentage_value(10).unwrap(),
|
||||
)),
|
||||
deps.as_mut().storage,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mix_id = 42;
|
||||
|
||||
let delegation = Coin {
|
||||
amount: Uint128::new(5_000_000_000_000),
|
||||
denom: TEST_COIN_DENOM.to_string(),
|
||||
};
|
||||
|
||||
// delegate explicitly at the time the account was created
|
||||
// (i.e. after 2 vesting periods already elapsed)
|
||||
env.block.height = account_creation_blockheight;
|
||||
env.block.time = Timestamp::from_seconds(account_creation_timestamp);
|
||||
let err = vesting_account.try_delegate_to_mixnode(
|
||||
mix_id,
|
||||
delegation.clone(),
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
);
|
||||
// Can't delegate due to cap
|
||||
assert!(err.is_err());
|
||||
|
||||
let delegated_free = vesting_account
|
||||
.get_delegated_free(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
let delegated_vesting = vesting_account
|
||||
.get_delegated_vesting(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(delegated_free.amount, Uint128::new(0));
|
||||
assert_eq!(delegated_vesting.amount, Uint128::new(0));
|
||||
|
||||
let delegation = Coin {
|
||||
amount: Uint128::new(4_000_000_000_000),
|
||||
denom: TEST_COIN_DENOM.to_string(),
|
||||
};
|
||||
|
||||
// delegate explicitly at the time the account was created
|
||||
// (i.e. after 2 vesting periods already elapsed)
|
||||
env.block.height = account_creation_blockheight;
|
||||
env.block.time = Timestamp::from_seconds(account_creation_timestamp);
|
||||
let ok = vesting_account.try_delegate_to_mixnode(
|
||||
mix_id,
|
||||
delegation.clone(),
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
);
|
||||
|
||||
// Max delegation allowed by cap
|
||||
assert!(ok.is_ok());
|
||||
|
||||
let delegated_free = vesting_account
|
||||
.get_delegated_free(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
let delegated_vesting = vesting_account
|
||||
.get_delegated_vesting(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(delegated_free.amount, Uint128::new(0));
|
||||
assert_eq!(delegated_vesting.amount, Uint128::new(4_000_000_000_000));
|
||||
|
||||
// Advance vesting period
|
||||
env.block.height += blocks_per_period * 2;
|
||||
env.block.time =
|
||||
Timestamp::from_seconds(env.block.time.seconds() + vesting_period_length_secs * 2);
|
||||
|
||||
let delegated_free = vesting_account
|
||||
.get_delegated_free(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
let delegated_vesting = vesting_account
|
||||
.get_delegated_vesting(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
|
||||
let spendable_coins = vesting_account
|
||||
.spendable_coins(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
|
||||
// let balance = vesting_account.load_balance(&deps.storage).unwrap();
|
||||
// assert_eq!(balance, Uint128::new(6_000_000_000_000));
|
||||
|
||||
// Entire delegation amount is no free, and more can be delegated from the locked tokens
|
||||
assert_eq!(delegated_free.amount, Uint128::new(4_000_000_000_000));
|
||||
assert_eq!(delegated_vesting.amount, Uint128::new(0));
|
||||
assert_eq!(spendable_coins.amount, Uint128::new(6_000_000_000_000));
|
||||
|
||||
let total_pledged_locked = vesting_account
|
||||
.total_pledged_locked(&deps.storage, &env)
|
||||
.unwrap();
|
||||
assert_eq!(total_pledged_locked, Uint128::new(0));
|
||||
|
||||
let delegation = Coin {
|
||||
amount: Uint128::new(5_000_000_000_000),
|
||||
denom: TEST_COIN_DENOM.to_string(),
|
||||
};
|
||||
|
||||
let err = vesting_account.try_delegate_to_mixnode(
|
||||
mix_id,
|
||||
delegation.clone(),
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
);
|
||||
|
||||
// Can't delegate due to cap
|
||||
assert!(err.is_err());
|
||||
|
||||
let delegation = Coin {
|
||||
amount: Uint128::new(4_000_000_000_000),
|
||||
denom: TEST_COIN_DENOM.to_string(),
|
||||
};
|
||||
|
||||
let ok = vesting_account.try_delegate_to_mixnode(
|
||||
mix_id,
|
||||
delegation.clone(),
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
);
|
||||
// Delegate max allowed amount
|
||||
assert!(ok.is_ok());
|
||||
|
||||
let delegated_free = vesting_account
|
||||
.get_delegated_free(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
let delegated_vesting = vesting_account
|
||||
.get_delegated_vesting(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
let total_pledged_locked = vesting_account
|
||||
.total_pledged_locked(&deps.storage, &env)
|
||||
.unwrap();
|
||||
let spendable_coins = vesting_account
|
||||
.spendable_coins(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
// There is an additional problem here since the cap calculation does not take vesting periods into account
|
||||
assert_eq!(total_pledged_locked, Uint128::new(0));
|
||||
|
||||
// Entire delegation amount is now free, and more can be delegated from the locked tokens
|
||||
assert_eq!(delegated_free.amount, Uint128::new(8_000_000_000_000));
|
||||
assert_eq!(delegated_vesting.amount, Uint128::new(0));
|
||||
assert_eq!(spendable_coins.amount, Uint128::new(2_000_000_000_000));
|
||||
|
||||
// Delegate some more to saturate the cap
|
||||
env.block.height += 1;
|
||||
env.block.time = Timestamp::from_seconds(env.block.time.seconds() + 36);
|
||||
|
||||
let delegation = Coin {
|
||||
amount: Uint128::new(4_000_000_000_000),
|
||||
denom: TEST_COIN_DENOM.to_string(),
|
||||
};
|
||||
|
||||
vesting_account
|
||||
.try_delegate_to_mixnode(mix_id, delegation.clone(), &env, &mut deps.storage)
|
||||
.unwrap();
|
||||
|
||||
let delegated_free = vesting_account
|
||||
.get_delegated_free(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
let delegated_vesting = vesting_account
|
||||
.get_delegated_vesting(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
let total_pledged_locked = vesting_account
|
||||
.total_pledged_locked(&deps.storage, &env)
|
||||
.unwrap();
|
||||
|
||||
// There is an additional problem here since the cap calculation does not take vesting periods into account
|
||||
assert_eq!(total_pledged_locked, Uint128::new(4_000_000_000_000));
|
||||
|
||||
assert_eq!(delegated_free.amount, Uint128::new(8_000_000_000_000));
|
||||
assert_eq!(delegated_vesting.amount, Uint128::new(4_000_000_000_000));
|
||||
|
||||
let spendable_coins = vesting_account
|
||||
.spendable_coins(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
|
||||
let locked_coins = vesting_account
|
||||
.locked_coins(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(spendable_coins.amount, Uint128::new(2_000_000_000_000));
|
||||
assert_eq!(locked_coins.amount, Uint128::new(26_000_000_000_000));
|
||||
|
||||
// Check that user can't withdraw free coins if they're delegated
|
||||
|
||||
let info = MessageInfo {
|
||||
sender: Addr::unchecked("owner"),
|
||||
funds: vec![],
|
||||
};
|
||||
|
||||
let ok = try_withdraw_vested_coins(
|
||||
Coin::new(1_000_000_000_000, TEST_COIN_DENOM),
|
||||
env.clone(),
|
||||
info,
|
||||
deps.as_mut(),
|
||||
);
|
||||
|
||||
assert!(ok.is_ok());
|
||||
|
||||
let spendable_coins = vesting_account
|
||||
.spendable_coins(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(spendable_coins.amount, Uint128::new(1_000_000_000_000));
|
||||
|
||||
let delegated_free = vesting_account
|
||||
.get_delegated_free(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
let delegated_vesting = vesting_account
|
||||
.get_delegated_vesting(None, &env, &deps.storage)
|
||||
.unwrap();
|
||||
let total_pledged_locked = vesting_account
|
||||
.total_pledged_locked(&deps.storage, &env)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(total_pledged_locked, Uint128::new(4_000_000_000_000));
|
||||
|
||||
assert_eq!(delegated_free.amount, Uint128::new(8_000_000_000_000));
|
||||
assert_eq!(delegated_vesting.amount, Uint128::new(4_000_000_000_000));
|
||||
|
||||
let delegation = Coin {
|
||||
amount: Uint128::new(1_000_000_000_000),
|
||||
denom: TEST_COIN_DENOM.to_string(),
|
||||
};
|
||||
|
||||
let err = vesting_account.try_delegate_to_mixnode(
|
||||
mix_id,
|
||||
delegation.clone(),
|
||||
&env,
|
||||
&mut deps.storage,
|
||||
);
|
||||
|
||||
assert!(err.is_err());
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -53,7 +53,7 @@ url = { version = "2.2", features = ["serde"] }
|
||||
|
||||
# internal
|
||||
build-information = { path = "../common/build-information" }
|
||||
coconut-interface = { path = "../common/coconut-interface" }
|
||||
coconut-interface = { path = "../common/coconut-interface", optional = true }
|
||||
credentials = { path = "../common/credentials" }
|
||||
config = { path = "../common/config" }
|
||||
crypto = { path = "../common/crypto" }
|
||||
@@ -76,6 +76,13 @@ nym-types = { path = "../common/types" }
|
||||
serde_json = "1"
|
||||
atty = "0.2"
|
||||
|
||||
[features]
|
||||
coconut = [
|
||||
"coconut-interface",
|
||||
"gateway-requests/coconut",
|
||||
"credentials/coconut",
|
||||
"nym-api-requests/coconut",
|
||||
]
|
||||
|
||||
[build-dependencies]
|
||||
tokio = { version = "1.24.1", features = ["rt-multi-thread", "macros"] }
|
||||
|
||||
@@ -22,9 +22,12 @@ thiserror = "1.0"
|
||||
crypto = { path = "../../common/crypto" }
|
||||
pemstore = { path = "../../common/pemstore" }
|
||||
|
||||
coconut-interface = { path = "../../common/coconut-interface" }
|
||||
coconut-interface = { path = "../../common/coconut-interface", optional = true }
|
||||
credentials = { path = "../../common/credentials" }
|
||||
|
||||
[features]
|
||||
coconut = ["coconut-interface", "credentials/coconut"]
|
||||
|
||||
[dependencies.tungstenite]
|
||||
version = "0.13.0"
|
||||
default-features = false
|
||||
|
||||
@@ -5,7 +5,6 @@ use crate::authentication::encrypted_address::EncryptedAddressBytes;
|
||||
use crate::iv::IV;
|
||||
use crate::registration::handshake::SharedKeys;
|
||||
use crate::{GatewayMacSize, PROTOCOL_VERSION};
|
||||
use coconut_interface::Credential;
|
||||
use crypto::generic_array::typenum::Unsigned;
|
||||
use crypto::hmac::recompute_keyed_hmac_and_verify_tag;
|
||||
use crypto::symmetric::stream_cipher;
|
||||
@@ -21,6 +20,11 @@ use std::{
|
||||
};
|
||||
use tungstenite::protocol::Message;
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
use coconut_interface::Credential;
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
use credentials::token::bandwidth::TokenCredential;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
pub enum RegistrationHandshake {
|
||||
@@ -153,6 +157,7 @@ impl ClientControlRequest {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub fn new_enc_coconut_bandwidth_credential(
|
||||
credential: &Credential,
|
||||
shared_key: &SharedKeys,
|
||||
@@ -167,6 +172,7 @@ impl ClientControlRequest {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub fn try_from_enc_coconut_bandwidth_credential(
|
||||
enc_credential: Vec<u8>,
|
||||
shared_key: &SharedKeys,
|
||||
@@ -176,6 +182,30 @@ impl ClientControlRequest {
|
||||
Credential::from_bytes(&credential_bytes)
|
||||
.map_err(|_| GatewayRequestsError::MalformedEncryption)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
pub fn new_enc_token_bandwidth_credential(
|
||||
credential: &TokenCredential,
|
||||
shared_key: &SharedKeys,
|
||||
iv: IV,
|
||||
) -> Self {
|
||||
let enc_credential = shared_key.encrypt_and_tag(&credential.to_bytes(), Some(iv.inner()));
|
||||
ClientControlRequest::BandwidthCredential {
|
||||
enc_credential,
|
||||
iv: iv.to_bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
pub fn try_from_enc_token_bandwidth_credential(
|
||||
enc_credential: Vec<u8>,
|
||||
shared_key: &SharedKeys,
|
||||
iv: IV,
|
||||
) -> Result<TokenCredential, GatewayRequestsError> {
|
||||
let credential = shared_key.decrypt_tagged(&enc_credential, Some(iv.inner()))?;
|
||||
TokenCredential::from_bytes(&credential)
|
||||
.map_err(|_| GatewayRequestsError::MalformedEncryption)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ClientControlRequest> for Message {
|
||||
|
||||
@@ -51,6 +51,7 @@ pub struct Init {
|
||||
nym_apis: Option<Vec<url::Url>>,
|
||||
|
||||
/// Comma separated list of endpoints of the validator
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(
|
||||
long,
|
||||
alias = "validators",
|
||||
@@ -66,6 +67,7 @@ pub struct Init {
|
||||
|
||||
/// Set this gateway to work only with coconut credentials; that would disallow clients to
|
||||
/// bypass bandwidth credential requirement
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long)]
|
||||
only_coconut_credentials: Option<bool>,
|
||||
|
||||
@@ -93,7 +95,9 @@ impl From<Init> for OverrideConfig {
|
||||
enabled_statistics: init_config.enabled_statistics,
|
||||
statistics_service_url: init_config.statistics_service_url,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: init_config.nyxd_urls,
|
||||
#[cfg(feature = "coconut")]
|
||||
only_coconut_credentials: init_config.only_coconut_credentials,
|
||||
}
|
||||
}
|
||||
@@ -180,7 +184,9 @@ mod tests {
|
||||
mnemonic: None,
|
||||
statistics_service_url: None,
|
||||
enabled_statistics: None,
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: None,
|
||||
#[cfg(feature = "coconut")]
|
||||
only_coconut_credentials: None,
|
||||
};
|
||||
std::env::set_var(BECH32_PREFIX, "n");
|
||||
|
||||
+21
-12
@@ -7,7 +7,6 @@ use clap::CommandFactory;
|
||||
use clap::Subcommand;
|
||||
use completions::{fig_generate, ArgShell};
|
||||
use config::OptionalSet;
|
||||
use network_defaults::var_names::NYXD;
|
||||
use network_defaults::var_names::{BECH32_PREFIX, NYM_API, STATISTICS_SERVICE_DOMAIN_ADDRESS};
|
||||
use std::error::Error;
|
||||
use std::net::IpAddr;
|
||||
@@ -57,7 +56,10 @@ pub(crate) struct OverrideConfig {
|
||||
statistics_service_url: Option<url::Url>,
|
||||
nym_apis: Option<Vec<url::Url>>,
|
||||
mnemonic: Option<bip39::Mnemonic>,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: Option<Vec<url::Url>>,
|
||||
#[cfg(feature = "coconut")]
|
||||
only_coconut_credentials: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -117,17 +119,24 @@ pub(crate) fn override_config(
|
||||
ensure_correct_bech32_prefix,
|
||||
)?
|
||||
.with_optional(Config::with_custom_persistent_store, args.datastore)
|
||||
.with_optional(Config::with_cosmos_mnemonic, args.mnemonic)
|
||||
.with_optional_custom_env(
|
||||
Config::with_custom_validator_nyxd,
|
||||
args.nyxd_urls,
|
||||
NYXD,
|
||||
config::parse_urls,
|
||||
)
|
||||
.with_optional(
|
||||
Config::with_only_coconut_credentials,
|
||||
args.only_coconut_credentials,
|
||||
);
|
||||
.with_optional(Config::with_cosmos_mnemonic, args.mnemonic);
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
{
|
||||
use network_defaults::var_names::NYXD;
|
||||
|
||||
config = config
|
||||
.with_optional_custom_env(
|
||||
Config::with_custom_validator_nyxd,
|
||||
args.nyxd_urls,
|
||||
NYXD,
|
||||
config::parse_urls,
|
||||
)
|
||||
.with_optional(
|
||||
Config::with_only_coconut_credentials,
|
||||
args.only_coconut_credentials,
|
||||
);
|
||||
}
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ pub struct Run {
|
||||
nym_apis: Option<Vec<url::Url>>,
|
||||
|
||||
/// Comma separated list of endpoints of the validator
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(
|
||||
long,
|
||||
alias = "validators",
|
||||
@@ -64,6 +65,7 @@ pub struct Run {
|
||||
|
||||
/// Set this gateway to work only with coconut credentials; that would disallow clients to
|
||||
/// bypass bandwidth credential requirement
|
||||
#[cfg(feature = "coconut")]
|
||||
#[clap(long)]
|
||||
only_coconut_credentials: Option<bool>,
|
||||
|
||||
@@ -90,7 +92,10 @@ impl From<Run> for OverrideConfig {
|
||||
|
||||
enabled_statistics: run_config.enabled_statistics,
|
||||
statistics_service_url: run_config.statistics_service_url,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
nyxd_urls: run_config.nyxd_urls,
|
||||
#[cfg(feature = "coconut")]
|
||||
only_coconut_credentials: run_config.only_coconut_credentials,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,6 +128,7 @@ impl Config {
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub fn with_only_coconut_credentials(mut self, only_coconut_credentials: bool) -> Self {
|
||||
self.gateway.only_coconut_credentials = only_coconut_credentials;
|
||||
self
|
||||
@@ -148,6 +149,7 @@ impl Config {
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub fn with_custom_validator_nyxd(mut self, validator_nyxd_urls: Vec<Url>) -> Self {
|
||||
self.gateway.nyxd_urls = validator_nyxd_urls;
|
||||
self
|
||||
@@ -235,10 +237,12 @@ impl Config {
|
||||
self.gateway.nym_api_urls.clone()
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub fn get_nyxd_urls(&self) -> Vec<Url> {
|
||||
self.gateway.nyxd_urls.clone()
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub fn get_cosmos_mnemonic(&self) -> bip39::Mnemonic {
|
||||
self.gateway.cosmos_mnemonic.clone()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
use coconut_interface::Credential;
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
use credentials::token::bandwidth::TokenCredential;
|
||||
|
||||
pub struct Bandwidth {
|
||||
value: u64,
|
||||
@@ -13,6 +16,7 @@ impl Bandwidth {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
impl From<Credential> for Bandwidth {
|
||||
fn from(credential: Credential) -> Self {
|
||||
let token_value = credential.voucher_value();
|
||||
@@ -22,3 +26,12 @@ impl From<Credential> for Bandwidth {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
impl From<TokenCredential> for Bandwidth {
|
||||
fn from(credential: TokenCredential) -> Self {
|
||||
Bandwidth {
|
||||
value: credential.bandwidth(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,18 +52,23 @@ pub(crate) enum RequestHandlingError {
|
||||
#[error("Nyxd Error - {0}")]
|
||||
NyxdError(#[from] validator_client::nyxd::error::NyxdError),
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
#[error("Validator API error - {0}")]
|
||||
APIError(#[from] validator_client::ValidatorClientError),
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
#[error("Not enough nym API endpoints provided. Needed {needed}, received {received}")]
|
||||
NotEnoughNymAPIs { received: usize, needed: usize },
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
#[error("There was a problem with the proposal id: {reason}")]
|
||||
ProposalIdError { reason: String },
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
#[error("Coconut interface error - {0}")]
|
||||
CoconutInterfaceError(#[from] coconut_interface::error::CoconutInterfaceError),
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
#[error("Credential error - {0}")]
|
||||
CredentialError(#[from] credentials::error::Error),
|
||||
}
|
||||
@@ -187,6 +192,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
/// Tries to handle the received bandwidth request by checking correctness of the received data
|
||||
/// and if successful, increases client's bandwidth by an appropriate amount.
|
||||
///
|
||||
@@ -194,7 +200,7 @@ where
|
||||
///
|
||||
/// * `enc_credential`: raw encrypted bandwidth credential to verify.
|
||||
/// * `iv`: fresh iv used for the credential.
|
||||
async fn handle_bandwidth(
|
||||
async fn handle_coconut_bandwidth(
|
||||
&mut self,
|
||||
enc_credential: Vec<u8>,
|
||||
iv: Vec<u8>,
|
||||
@@ -257,6 +263,70 @@ where
|
||||
Ok(ServerResponse::Bandwidth { available_total })
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
/// Tries to handle the received bandwidth request by checking correctness of the received data
|
||||
/// and if successful, increases client's bandwidth by an appropriate amount.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `enc_credential`: raw encrypted bandwidth credential to verify.
|
||||
/// * `iv`: fresh iv used for the credential.
|
||||
async fn handle_token_bandwidth(
|
||||
&mut self,
|
||||
enc_credential: Vec<u8>,
|
||||
iv: Vec<u8>,
|
||||
) -> Result<ServerResponse, RequestHandlingError> {
|
||||
let iv = IV::try_from_bytes(&iv)?;
|
||||
let credential = ClientControlRequest::try_from_enc_token_bandwidth_credential(
|
||||
enc_credential,
|
||||
&self.client.shared_keys,
|
||||
iv,
|
||||
)?;
|
||||
if !self
|
||||
.inner
|
||||
.check_local_identity(&credential.gateway_identity())
|
||||
{
|
||||
return Err(RequestHandlingError::InvalidBandwidthCredential(
|
||||
String::from("gateway"),
|
||||
));
|
||||
}
|
||||
|
||||
if !credential.verify_signature() {
|
||||
return Err(RequestHandlingError::InvalidBandwidthCredential(
|
||||
String::from("gateway"),
|
||||
));
|
||||
}
|
||||
|
||||
let bandwidth = Bandwidth::from(credential);
|
||||
let bandwidth_value = bandwidth.value();
|
||||
|
||||
if bandwidth_value > i64::MAX as u64 {
|
||||
// note that this would have represented more than 1 exabyte,
|
||||
// which is like 125,000 worth of hard drives so I don't think we have
|
||||
// to worry about it for now...
|
||||
warn!("Somehow we received bandwidth value higher than 9223372036854775807. We don't really want to deal with this now");
|
||||
return Err(RequestHandlingError::UnsupportedBandwidthValue(
|
||||
bandwidth_value,
|
||||
));
|
||||
}
|
||||
|
||||
self.increase_bandwidth(bandwidth_value as i64).await?;
|
||||
let available_total = self.get_available_bandwidth().await?;
|
||||
|
||||
Ok(ServerResponse::Bandwidth { available_total })
|
||||
}
|
||||
|
||||
async fn handle_bandwidth(
|
||||
&mut self,
|
||||
enc_credential: Vec<u8>,
|
||||
iv: Vec<u8>,
|
||||
) -> Result<ServerResponse, RequestHandlingError> {
|
||||
#[cfg(feature = "coconut")]
|
||||
return self.handle_coconut_bandwidth(enc_credential, iv).await;
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
return self.handle_token_bandwidth(enc_credential, iv).await;
|
||||
}
|
||||
|
||||
async fn handle_claim_testnet_bandwidth(
|
||||
&mut self,
|
||||
) -> Result<ServerResponse, RequestHandlingError> {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::node::client_handling::active_clients::ActiveClientsStore;
|
||||
#[cfg(feature = "coconut")]
|
||||
use crate::node::client_handling::websocket::connection_handler::coconut::CoconutVerifier;
|
||||
use crate::node::client_handling::websocket::connection_handler::{
|
||||
AuthenticatedHandler, ClientDetails, InitialAuthResult, SocketStream,
|
||||
@@ -74,6 +75,8 @@ pub(crate) struct FreshHandler<R, S, St> {
|
||||
pub(crate) outbound_mix_sender: MixForwardingSender,
|
||||
pub(crate) socket_connection: SocketStream<S>,
|
||||
pub(crate) storage: St,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub(crate) coconut_verifier: Arc<CoconutVerifier>,
|
||||
}
|
||||
|
||||
@@ -95,7 +98,7 @@ where
|
||||
local_identity: Arc<identity::KeyPair>,
|
||||
storage: St,
|
||||
active_clients_store: ActiveClientsStore,
|
||||
coconut_verifier: Arc<CoconutVerifier>,
|
||||
#[cfg(feature = "coconut")] coconut_verifier: Arc<CoconutVerifier>,
|
||||
) -> Self {
|
||||
FreshHandler {
|
||||
rng,
|
||||
@@ -105,10 +108,20 @@ where
|
||||
socket_connection: SocketStream::RawTcp(conn),
|
||||
local_identity,
|
||||
storage,
|
||||
#[cfg(feature = "coconut")]
|
||||
coconut_verifier,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "coconut"))]
|
||||
/// Check that the local identity matches a given identity.
|
||||
pub(crate) fn check_local_identity(
|
||||
&self,
|
||||
identity: &crypto::asymmetric::identity::PublicKey,
|
||||
) -> bool {
|
||||
self.local_identity.public_key().eq(identity)
|
||||
}
|
||||
|
||||
/// Attempts to perform websocket handshake with the remote and upgrades the raw TCP socket
|
||||
/// to the framed WebSocket.
|
||||
pub(crate) async fn perform_websocket_handshake(&mut self) -> Result<(), WsError>
|
||||
|
||||
@@ -15,6 +15,7 @@ pub(crate) use self::authenticated::AuthenticatedHandler;
|
||||
pub(crate) use self::fresh::FreshHandler;
|
||||
|
||||
mod authenticated;
|
||||
#[cfg(feature = "coconut")]
|
||||
pub(crate) mod coconut;
|
||||
mod fresh;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::node::client_handling::active_clients::ActiveClientsStore;
|
||||
use crate::node::client_handling::websocket::connection_handler::coconut::CoconutVerifier;
|
||||
use crate::node::client_handling::websocket::connection_handler::FreshHandler;
|
||||
use crate::node::storage::Storage;
|
||||
use crypto::asymmetric::identity;
|
||||
@@ -14,10 +13,15 @@ use std::process;
|
||||
use std::sync::Arc;
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
use crate::node::client_handling::websocket::connection_handler::coconut::CoconutVerifier;
|
||||
|
||||
pub(crate) struct Listener {
|
||||
address: SocketAddr,
|
||||
local_identity: Arc<identity::KeyPair>,
|
||||
only_coconut_credentials: bool,
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub(crate) coconut_verifier: Arc<CoconutVerifier>,
|
||||
}
|
||||
|
||||
@@ -26,12 +30,13 @@ impl Listener {
|
||||
address: SocketAddr,
|
||||
local_identity: Arc<identity::KeyPair>,
|
||||
only_coconut_credentials: bool,
|
||||
coconut_verifier: Arc<CoconutVerifier>,
|
||||
#[cfg(feature = "coconut")] coconut_verifier: Arc<CoconutVerifier>,
|
||||
) -> Self {
|
||||
Listener {
|
||||
address,
|
||||
local_identity,
|
||||
only_coconut_credentials,
|
||||
#[cfg(feature = "coconut")]
|
||||
coconut_verifier,
|
||||
}
|
||||
}
|
||||
@@ -76,6 +81,7 @@ impl Listener {
|
||||
Arc::clone(&self.local_identity),
|
||||
storage.clone(),
|
||||
active_clients_store.clone(),
|
||||
#[cfg(feature = "coconut")]
|
||||
Arc::clone(&self.coconut_verifier),
|
||||
);
|
||||
let shutdown = shutdown.clone();
|
||||
|
||||
+11
-3
@@ -8,7 +8,6 @@ use crate::config::Config;
|
||||
use crate::error::GatewayError;
|
||||
use crate::node::client_handling::active_clients::ActiveClientsStore;
|
||||
use crate::node::client_handling::websocket;
|
||||
use crate::node::client_handling::websocket::connection_handler::coconut::CoconutVerifier;
|
||||
use crate::node::mixnet_handling::receiver::connection_handler::ConnectionHandler;
|
||||
use crate::node::statistics::collector::GatewayStatisticsCollector;
|
||||
use crate::node::storage::Storage;
|
||||
@@ -17,7 +16,6 @@ use colored::Colorize;
|
||||
use crypto::asymmetric::{encryption, identity};
|
||||
use log::*;
|
||||
use mixnet_client::forwarder::{MixForwardingSender, PacketForwarder};
|
||||
use network_defaults::NymNetworkDetails;
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
use statistics_common::collector::StatisticsSender;
|
||||
@@ -26,6 +24,12 @@ use std::net::SocketAddr;
|
||||
use std::process;
|
||||
use std::sync::Arc;
|
||||
use task::{TaskClient, TaskManager};
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
use crate::node::client_handling::websocket::connection_handler::coconut::CoconutVerifier;
|
||||
#[cfg(feature = "coconut")]
|
||||
use network_defaults::NymNetworkDetails;
|
||||
#[cfg(feature = "coconut")]
|
||||
use validator_client::Client;
|
||||
|
||||
pub(crate) mod client_handling;
|
||||
@@ -186,7 +190,7 @@ where
|
||||
forwarding_channel: MixForwardingSender,
|
||||
active_clients_store: ActiveClientsStore,
|
||||
shutdown: TaskClient,
|
||||
coconut_verifier: Arc<CoconutVerifier>,
|
||||
#[cfg(feature = "coconut")] coconut_verifier: Arc<CoconutVerifier>,
|
||||
) {
|
||||
info!("Starting client [web]socket listener...");
|
||||
|
||||
@@ -199,6 +203,7 @@ where
|
||||
listening_address,
|
||||
Arc::clone(&self.identity_keypair),
|
||||
self.config.get_only_coconut_credentials(),
|
||||
#[cfg(feature = "coconut")]
|
||||
coconut_verifier,
|
||||
)
|
||||
.start(
|
||||
@@ -243,6 +248,7 @@ where
|
||||
validator_client::NymApiClient::new(nym_api.clone())
|
||||
}
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
fn random_nyxd_client(
|
||||
&self,
|
||||
) -> validator_client::Client<validator_client::nyxd::SigningNyxdClient> {
|
||||
@@ -310,6 +316,7 @@ where
|
||||
|
||||
let shutdown = TaskManager::new(10);
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
let coconut_verifier = {
|
||||
let nyxd_client = self.random_nyxd_client();
|
||||
CoconutVerifier::new(nyxd_client)
|
||||
@@ -341,6 +348,7 @@ where
|
||||
mix_forwarding_channel,
|
||||
active_clients_store,
|
||||
shutdown.subscribe(),
|
||||
#[cfg(feature = "coconut")]
|
||||
Arc::new(coconut_verifier),
|
||||
);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
"ts-packages/*",
|
||||
"nym-wallet",
|
||||
"nym-connect",
|
||||
"nym-connect-android",
|
||||
"sdk/typescript/**"
|
||||
],
|
||||
"version": "0.0.0"
|
||||
|
||||
+24
-10
@@ -16,7 +16,7 @@ rust-version = "1.56"
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.52"
|
||||
bs58 = {version = "0.4.0" }
|
||||
bs58 = {version = "0.4.0", optional = true }
|
||||
bip39 = "1"
|
||||
cfg-if = "1.0"
|
||||
clap = { version = "4.0", features = ["cargo", "derive"] }
|
||||
@@ -67,26 +67,26 @@ schemars = { version = "0.8", features = ["preserve_order"] }
|
||||
## internal
|
||||
build-information = { path = "../common/build-information" }
|
||||
coconut-bandwidth-contract-common = { path = "../common/cosmwasm-smart-contracts/coconut-bandwidth-contract" }
|
||||
coconut-dkg-common = { path = "../common/cosmwasm-smart-contracts/coconut-dkg" }
|
||||
coconut-interface = { path = "../common/coconut-interface" }
|
||||
coconut-dkg-common = { path = "../common/cosmwasm-smart-contracts/coconut-dkg", optional = true }
|
||||
coconut-interface = { path = "../common/coconut-interface", optional = true }
|
||||
config = { path = "../common/config" }
|
||||
cosmwasm-std = "1.0.0"
|
||||
credential-storage = { path = "../common/credential-storage" }
|
||||
credentials = { path = "../common/credentials" }
|
||||
credentials = { path = "../common/credentials", optional = true }
|
||||
crypto = { path = "../common/crypto" }
|
||||
logging = { path = "../common/logging"}
|
||||
cw3 = { version = "0.13.4" }
|
||||
cw4 = { version = "0.13.4" }
|
||||
dkg = { path = "../common/crypto/dkg" }
|
||||
cw3 = { version = "0.13.4", optional = true }
|
||||
cw4 = { version = "0.13.4", optional = true }
|
||||
dkg = { path = "../common/crypto/dkg", optional = true }
|
||||
gateway-client = { path = "../common/client-libs/gateway-client" }
|
||||
inclusion-probability = { path = "../common/inclusion-probability" }
|
||||
mixnet-contract-common = { path = "../common/cosmwasm-smart-contracts/mixnet-contract" }
|
||||
vesting-contract-common = { path = "../common/cosmwasm-smart-contracts/vesting-contract" }
|
||||
contracts-common = { path = "../common/cosmwasm-smart-contracts/contracts-common", features = ["dkg"] }
|
||||
contracts-common = { path = "../common/cosmwasm-smart-contracts/contracts-common", features = ["coconut"] }
|
||||
multisig-contract-common = { path = "../common/cosmwasm-smart-contracts/multisig-contract" }
|
||||
nymcoconut = { path = "../common/nymcoconut" }
|
||||
nymcoconut = { path = "../common/nymcoconut", optional = true }
|
||||
nymsphinx = { path = "../common/nymsphinx" }
|
||||
pemstore = { path = "../common/pemstore" }
|
||||
pemstore = { path = "../common/pemstore", optional = true }
|
||||
task = { path = "../common/task" }
|
||||
topology = { path = "../common/topology" }
|
||||
nym-api-requests = { path = "nym-api-requests" }
|
||||
@@ -96,6 +96,20 @@ validator-client = { path = "../common/client-libs/validator-client", features =
|
||||
version-checker = { path = "../common/version-checker" }
|
||||
|
||||
[features]
|
||||
coconut = [
|
||||
"coconut-interface",
|
||||
"credentials",
|
||||
"cw3",
|
||||
"cw4",
|
||||
"gateway-client/coconut",
|
||||
"credentials/coconut",
|
||||
"nym-api-requests/coconut",
|
||||
"nymcoconut",
|
||||
"coconut-dkg-common",
|
||||
"dkg",
|
||||
"bs58",
|
||||
"pemstore",
|
||||
]
|
||||
no-reward = []
|
||||
generate-ts = ["ts-rs"]
|
||||
|
||||
|
||||
@@ -14,9 +14,10 @@ schemars = { version = "0.8", features = ["preserve_order"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
ts-rs = { version = "6.1.2", optional = true }
|
||||
|
||||
coconut-interface = { path = "../../common/coconut-interface" }
|
||||
coconut-interface = { path = "../../common/coconut-interface", optional = true }
|
||||
mixnet-contract-common = { path= "../../common/cosmwasm-smart-contracts/mixnet-contract" }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
coconut = ["coconut-interface"]
|
||||
generate-ts = ["ts-rs"]
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
pub mod coconut;
|
||||
pub mod models;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ pub(crate) mod tests {
|
||||
use coconut_dkg_common::dealer::DealerDetails;
|
||||
use cosmwasm_std::Addr;
|
||||
use dkg::bte::keys::KeyPair as DkgKeyPair;
|
||||
use dkg::bte::{Params, PublicKeyWithProof};
|
||||
use dkg::bte::Params;
|
||||
use rand::rngs::OsRng;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
@@ -186,18 +186,8 @@ pub(crate) mod tests {
|
||||
let mut bytes = bs58::decode(details.bte_public_key_with_proof.clone())
|
||||
.into_vec()
|
||||
.unwrap();
|
||||
// Find another value for last byte that still deserializes to a public key with proof
|
||||
let initial_byte = *bytes.last_mut().unwrap();
|
||||
loop {
|
||||
let last_byte = bytes.last_mut().unwrap();
|
||||
let (ret, _) = last_byte.overflowing_add(1);
|
||||
*last_byte = ret;
|
||||
// stop when we find that value, or if we do a full round trip of u8 values
|
||||
// and can't find one, in which case this test is invalid
|
||||
if PublicKeyWithProof::try_from_bytes(&bytes).is_ok() || ret == initial_byte {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let last_byte = bytes.last_mut().unwrap();
|
||||
*last_byte += 1;
|
||||
details.bte_public_key_with_proof = bs58::encode(&bytes).into_string();
|
||||
});
|
||||
|
||||
|
||||
+22
-13
@@ -15,25 +15,31 @@ use ::config::defaults::setup_env;
|
||||
use anyhow::Result;
|
||||
use circulating_supply_api::cache::CirculatingSupplyCache;
|
||||
use clap::Parser;
|
||||
use coconut::dkg::controller::DkgController;
|
||||
use config::NymConfig;
|
||||
use log::info;
|
||||
use logging::setup_logging;
|
||||
use node_status_api::NodeStatusCache;
|
||||
use nym_contract_cache::cache::NymContractCache;
|
||||
use rand::rngs::OsRng;
|
||||
use std::error::Error;
|
||||
use support::{http, nyxd};
|
||||
use task::TaskManager;
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
use coconut::dkg::controller::DkgController;
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
mod circulating_supply_api;
|
||||
mod coconut;
|
||||
mod epoch_operations;
|
||||
mod network_monitor;
|
||||
pub(crate) mod node_status_api;
|
||||
pub(crate) mod nym_contract_cache;
|
||||
pub(crate) mod support;
|
||||
|
||||
#[cfg(feature = "coconut")]
|
||||
mod coconut;
|
||||
|
||||
struct ShutdownHandles {
|
||||
task_manager_handle: TaskManager,
|
||||
rocket_handle: rocket::Shutdown,
|
||||
@@ -62,6 +68,9 @@ async fn start_nym_api_tasks(
|
||||
let nyxd_client = nyxd::Client::new(&config);
|
||||
let mix_denom = nyxd_client.chain_details().await.mix_denom.base;
|
||||
|
||||
// TODO: question to @BN: why are we creating a fresh coconut keypair here every time as opposed
|
||||
// to using some persistent keys?
|
||||
#[cfg(feature = "coconut")]
|
||||
let coconut_keypair = coconut::keypair::KeyPair::new();
|
||||
|
||||
// let's build our rocket!
|
||||
@@ -69,6 +78,7 @@ async fn start_nym_api_tasks(
|
||||
&config,
|
||||
mix_denom,
|
||||
nyxd_client.clone(),
|
||||
#[cfg(feature = "coconut")]
|
||||
coconut_keypair.clone(),
|
||||
)
|
||||
.await?;
|
||||
@@ -110,16 +120,15 @@ async fn start_nym_api_tasks(
|
||||
);
|
||||
|
||||
// start dkg task
|
||||
if config.get_coconut_signer_enabled() {
|
||||
DkgController::start(
|
||||
&config,
|
||||
nyxd_client.clone(),
|
||||
coconut_keypair,
|
||||
OsRng,
|
||||
&shutdown,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
#[cfg(feature = "coconut")]
|
||||
DkgController::start(
|
||||
&config,
|
||||
nyxd_client.clone(),
|
||||
coconut_keypair,
|
||||
OsRng,
|
||||
&shutdown,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// and then only start the uptime updater (and the monitor itself, duh)
|
||||
// if the monitoring if it's enabled
|
||||
|
||||
@@ -380,6 +380,7 @@ impl PacketPreparer {
|
||||
GatewayPackets::new(
|
||||
route.gateway_clients_address(),
|
||||
route.gateway_identity(),
|
||||
route.gateway_owner(),
|
||||
mix_packets,
|
||||
)
|
||||
}
|
||||
@@ -452,6 +453,7 @@ impl PacketPreparer {
|
||||
let recipient = self.create_packet_sender(test_route.gateway());
|
||||
let gateway_identity = test_route.gateway_identity();
|
||||
let gateway_address = test_route.gateway_clients_address();
|
||||
let gateway_owner = test_route.gateway_owner();
|
||||
|
||||
// it's actually going to be a tiny bit more due to gateway testing, but it's a good enough approximation
|
||||
let mut mix_packets = Vec::with_capacity(mixnodes.len() * self.per_node_test_packets);
|
||||
@@ -469,7 +471,9 @@ impl PacketPreparer {
|
||||
|
||||
let gateway_packets = all_gateway_packets
|
||||
.entry(gateway_identity.to_bytes())
|
||||
.or_insert_with(|| GatewayPackets::empty(gateway_address, gateway_identity));
|
||||
.or_insert_with(|| {
|
||||
GatewayPackets::empty(gateway_address, gateway_identity, gateway_owner)
|
||||
});
|
||||
gateway_packets.push_packets(mix_packets);
|
||||
|
||||
// and for each gateway...
|
||||
@@ -478,6 +482,7 @@ impl PacketPreparer {
|
||||
let test_packet = TestPacket::from_gateway(gateway, test_route.id(), test_nonce);
|
||||
let gateway_identity = gateway.identity_key;
|
||||
let gateway_address = gateway.clients_address();
|
||||
let gateway_owner = gateway.owner.clone();
|
||||
let recipient = self.create_packet_sender(gateway);
|
||||
let topology = test_route.substitute_gateway(gateway);
|
||||
// produce n mix packets
|
||||
@@ -490,7 +495,9 @@ impl PacketPreparer {
|
||||
// or create a new one
|
||||
let gateway_packets = all_gateway_packets
|
||||
.entry(gateway_identity.to_bytes())
|
||||
.or_insert_with(|| GatewayPackets::empty(gateway_address, gateway_identity));
|
||||
.or_insert_with(|| {
|
||||
GatewayPackets::empty(gateway_address, gateway_identity, gateway_owner)
|
||||
});
|
||||
gateway_packets.push_packets(gateway_mix_packets);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user