Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fb86ce9eea |
@@ -1,112 +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/"
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
name: Build and upload binaries to artifact storage
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
add_tokio_unstable:
|
|
||||||
description: 'True to add RUSTFLAGS="--cfg tokio_unstable"'
|
|
||||||
required: true
|
|
||||||
default: false
|
|
||||||
type: boolean
|
|
||||||
|
|
||||||
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: 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: Sets env vars for tokio if set in manual dispatch inputs
|
|
||||||
run: |
|
|
||||||
echo 'RUSTFLAGS="--cfg tokio_unstable"' >> $GITHUB_ENV
|
|
||||||
if: github.event_name == 'workflow_dispatch' && inputs.add_tokio_unstable == 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: Upload Artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: nym-binaries-artifacts
|
|
||||||
path: |
|
|
||||||
target/release/nym-client
|
|
||||||
target/release/nym-gateway
|
|
||||||
target/release/nym-mixnode
|
|
||||||
target/release/nym-socks5-client
|
|
||||||
target/release/nym-api
|
|
||||||
target/release/nym-network-requester
|
|
||||||
target/release/nym-network-statistics
|
|
||||||
target/release/nym-cli
|
|
||||||
retention-days: 30
|
|
||||||
@@ -12,7 +12,6 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install rsync
|
- name: Install rsync
|
||||||
run: sudo apt-get install rsync
|
run: sudo apt-get install rsync
|
||||||
continue-on-error: true
|
|
||||||
- uses: rlespinasse/github-slug-action@v3.x
|
- uses: rlespinasse/github-slug-action@v3.x
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
+28
-30
@@ -2,33 +2,11 @@ name: Continuous integration
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths-ignore:
|
||||||
- 'clients/**'
|
- 'explorer/**'
|
||||||
- 'common/**'
|
|
||||||
- 'explorer-api/**'
|
|
||||||
- 'gateway/**'
|
|
||||||
- 'integrations/**'
|
|
||||||
- 'mixnode/**'
|
|
||||||
- 'sdk/rust/nym-sdk/**'
|
|
||||||
- 'service-providers/**'
|
|
||||||
- 'nym-api/**'
|
|
||||||
- 'nym-outfox/**'
|
|
||||||
- 'tools/nym-cli/**'
|
|
||||||
- 'tools/ts-rs-cli/**'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths-ignore:
|
||||||
- 'clients/**'
|
- 'explorer/**'
|
||||||
- 'common/**'
|
|
||||||
- 'explorer-api/**'
|
|
||||||
- 'gateway/**'
|
|
||||||
- 'integrations/**'
|
|
||||||
- 'mixnode/**'
|
|
||||||
- 'sdk/rust/nym-sdk/**'
|
|
||||||
- 'service-providers/**'
|
|
||||||
- 'nym-api/**'
|
|
||||||
- 'nym-outfox/**'
|
|
||||||
- 'tools/nym-cli/**'
|
|
||||||
- 'tools/ts-rs-cli/**'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -74,24 +52,44 @@ jobs:
|
|||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --workspace
|
args: --workspace --all-features
|
||||||
|
|
||||||
- name: Run expensive tests
|
- name: Run expensive tests
|
||||||
if: github.ref == 'refs/heads/develop' || github.event.pull_request.base.ref == 'develop' || github.event.pull_request.base.ref == 'master'
|
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
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --workspace -- --ignored
|
args: --workspace --all-features -- --ignored
|
||||||
|
|
||||||
- uses: actions-rs/clippy-check@v1
|
- uses: actions-rs/clippy-check@v1
|
||||||
name: Clippy checks
|
name: Clippy checks
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
args: --workspace
|
args: --workspace --all-features
|
||||||
|
|
||||||
- name: Run clippy
|
- name: Run clippy
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: clippy
|
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:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths-ignore:
|
||||||
- 'nym-connect/**'
|
- 'explorer/**'
|
||||||
- '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/**'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -6,11 +6,17 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-contracts-') && github.event_name == 'release' }}
|
runs-on: ubuntu-20.04
|
||||||
runs-on: [self-hosted, custom-runner-linux]
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- 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
|
- name: Install Rust stable
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -2,13 +2,11 @@ name: Contracts
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths-ignore:
|
||||||
- 'contracts/**'
|
- 'explorer/**'
|
||||||
- 'common/**'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'contracts/**'
|
- 'explorer/**'
|
||||||
- 'common/**'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
matrix_prep:
|
matrix_prep:
|
||||||
|
|||||||
@@ -1,134 +0,0 @@
|
|||||||
name: NC Android APK Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- "release/nc-android-v[0-9].[0-9].[0-9]*"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build APK
|
|
||||||
runs-on: custom-runner-linux
|
|
||||||
env:
|
|
||||||
ANDROID_HOME: ${{ github.workspace }}/android-sdk
|
|
||||||
NDK_VERSION: 25.1.8937393
|
|
||||||
NDK_HOME: ${{ github.workspace }}/android-sdk/ndk/25.1.8937393
|
|
||||||
SDK_PLATFORM_VERSION: android-33
|
|
||||||
SDK_BUILDTOOLS_VERSION: 33.0.1
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Install Dependencies (Linux)
|
|
||||||
# https://next--tauri.netlify.app/next/guides/getting-started/prerequisites/linux/#1-system-dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get -y install \
|
|
||||||
libwebkit2gtk-4.0-dev \
|
|
||||||
build-essential \
|
|
||||||
unzip \
|
|
||||||
curl \
|
|
||||||
wget \
|
|
||||||
libssl-dev \
|
|
||||||
libgtk-3-dev \
|
|
||||||
squashfs-tools \
|
|
||||||
libayatana-appindicator3-dev \
|
|
||||||
librsvg2-dev
|
|
||||||
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Install Java
|
|
||||||
uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: "temurin"
|
|
||||||
java-version: "17"
|
|
||||||
|
|
||||||
- name: Install Android SDK manager
|
|
||||||
# https://developer.android.com/studio/command-line/sdkmanager
|
|
||||||
run: |
|
|
||||||
curl -sS https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -o cmdline-tools.zip
|
|
||||||
unzip cmdline-tools.zip
|
|
||||||
mkdir -p $ANDROID_HOME/cmdline-tools/latest
|
|
||||||
mv cmdline-tools/* $ANDROID_HOME/cmdline-tools/latest
|
|
||||||
rm -rf cmdline-tools
|
|
||||||
|
|
||||||
- name: Install Android S/NDK
|
|
||||||
run: |
|
|
||||||
echo y | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses
|
|
||||||
echo y | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager \
|
|
||||||
"platforms;$SDK_PLATFORM_VERSION" \
|
|
||||||
"platform-tools" \
|
|
||||||
"ndk;$NDK_VERSION" \
|
|
||||||
"build-tools;$SDK_BUILDTOOLS_VERSION"
|
|
||||||
|
|
||||||
- name: Install Rust toolchain
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Install tauri cli
|
|
||||||
run: cargo install tauri-cli --version "^2.0.0-alpha.2"
|
|
||||||
|
|
||||||
- name: Install rust android targets
|
|
||||||
run: |
|
|
||||||
rustup target add aarch64-linux-android \
|
|
||||||
armv7-linux-androideabi \
|
|
||||||
i686-linux-android \
|
|
||||||
x86_64-linux-android
|
|
||||||
|
|
||||||
- name: Setup Nodejs
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
|
|
||||||
- name: Install yarn
|
|
||||||
run: |
|
|
||||||
npm i -g yarn
|
|
||||||
yarn --version
|
|
||||||
|
|
||||||
- name: Build frontend code
|
|
||||||
run: |
|
|
||||||
yarn install --frozen-lockfile
|
|
||||||
yarn build
|
|
||||||
yarn workspace @nym/nym-connect-android webpack:prod
|
|
||||||
|
|
||||||
- name: Build APK
|
|
||||||
working-directory: nym-connect-android
|
|
||||||
env:
|
|
||||||
ANDROID_SDK_ROOT: ${{ env.ANDROID_HOME }}
|
|
||||||
WRY_ANDROID_PACKAGE: net.nymtech.nym_connect_android
|
|
||||||
WRY_ANDROID_LIBRARY: nym_connect_android
|
|
||||||
# TODO build with release profile (--release), it will requires
|
|
||||||
# to sign the APK. For now build with debug profile to avoid that
|
|
||||||
run: cargo tauri android build --debug --apk --split-per-abi -t aarch64
|
|
||||||
|
|
||||||
# TODO add the version number to APK name
|
|
||||||
- name: Rename APK artifact
|
|
||||||
run: |
|
|
||||||
mkdir apk/
|
|
||||||
mv nym-connect-android/src-tauri/gen/android/nym_connect_android/app/build/outputs/apk/arm64/debug/app-arm64-debug.apk \
|
|
||||||
apk/nym-connect-arm64-debug.apk
|
|
||||||
mv nym-connect-android/src-tauri/gen/android/nym_connect_android/app/build/outputs/apk/x86_64/debug/app-x86_64-debug.apk \
|
|
||||||
apk/nym-connect-x86_64-debug.apk
|
|
||||||
|
|
||||||
- name: Upload APK artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: nc-apk-debug
|
|
||||||
path: |
|
|
||||||
apk/nym-connect-arm64-debug.apk
|
|
||||||
apk/nym-connect-x86_64-debug.apk
|
|
||||||
|
|
||||||
# publish:
|
|
||||||
# name: Publish APK
|
|
||||||
# needs: build
|
|
||||||
# runs-on: ubuntu-latest
|
|
||||||
# steps:
|
|
||||||
# - name: Checkout
|
|
||||||
# uses: actions/checkout@v3
|
|
||||||
# - name: Download binary artifact
|
|
||||||
# uses: actions/download-artifact@v3
|
|
||||||
# with:
|
|
||||||
# name: nc-apk-debug
|
|
||||||
# path: apk
|
|
||||||
# # TODO add a step to upload the APK somewhere
|
|
||||||
# - name: Publish
|
|
||||||
# uses: ???
|
|
||||||
@@ -10,7 +10,6 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-nym:
|
publish-nym:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-explorer-api-') && (github.event_name == 'release' || github.event_name == 'workflow_dispatch') }}
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -22,9 +21,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Dependencies (Linux)
|
- 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
|
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-explorer-api-`
|
- 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
|
uses: actions/github-script@v3
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ jobs:
|
|||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
# creates the matrix strategy from nightly_build_matrix_includes.json
|
# creates the matrix strategy from nightly_build_matrix_includes.json
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v2
|
||||||
- id: set-matrix
|
- id: set-matrix
|
||||||
uses: JoshuaTheMiller/conditional-build-matrix@main
|
uses: JoshuaTheMiller/conditional-build-matrix@main
|
||||||
with:
|
with:
|
||||||
@@ -25,11 +25,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Install Dependencies (Linux)
|
- name: Install Dependencies (Linux)
|
||||||
run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools
|
run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools
|
||||||
continue-on-error: true
|
|
||||||
if: matrix.os == 'ubuntu-20.04'
|
if: matrix.os == 'ubuntu-20.04'
|
||||||
|
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install rust toolchain
|
- name: Install rust toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
@@ -77,7 +76,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Reclaim some disk space (because Windows is being annoying)
|
- name: Reclaim some disk space (because Windows is being annoying)
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-20.04' }}
|
if: ${{ matrix.os == 'windows-latest' }}
|
||||||
with:
|
with:
|
||||||
command: clean
|
command: clean
|
||||||
|
|
||||||
@@ -86,7 +85,7 @@ jobs:
|
|||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --workspace -- --ignored
|
args: --workspace --all-features -- --ignored
|
||||||
|
|
||||||
- name: Reclaim some disk space (because Windows is being annoying)
|
- name: Reclaim some disk space (because Windows is being annoying)
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
@@ -99,14 +98,14 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
args: --workspace
|
args: --all-features
|
||||||
|
|
||||||
- name: Run clippy
|
- name: Run clippy
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
if: ${{ matrix.rust != 'nightly' }}
|
if: ${{ matrix.rust != 'nightly' }}
|
||||||
with:
|
with:
|
||||||
command: clippy
|
command: clippy
|
||||||
args: --workspace --all-targets -- -D warnings
|
args: --workspace --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
- name: Reclaim some disk space
|
- name: Reclaim some disk space
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
@@ -114,6 +113,38 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
command: clean
|
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)
|
# nym-wallet (the rust part)
|
||||||
- name: Build nym-wallet rust code
|
- name: Build nym-wallet rust code
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
@@ -147,7 +178,7 @@ jobs:
|
|||||||
- name: Collect jobs status
|
- name: Collect jobs status
|
||||||
uses: technote-space/workflow-conclusion-action@v2
|
uses: technote-space/workflow-conclusion-action@v2
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
- name: install npm
|
- name: install npm
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
if: env.WORKFLOW_CONCLUSION == 'failure'
|
if: env.WORKFLOW_CONCLUSION == 'failure'
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Install Dependencies (Linux)
|
- name: Install Dependencies (Linux)
|
||||||
run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools
|
run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools
|
||||||
continue-on-error: true
|
|
||||||
if: matrix.os == 'ubuntu-20.04'
|
if: matrix.os == 'ubuntu-20.04'
|
||||||
|
|
||||||
- name: Check out latest release branch
|
- name: Check out latest release branch
|
||||||
@@ -54,12 +53,6 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
|
|
||||||
- name: Check formatting
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: fmt
|
|
||||||
args: --all -- --check
|
|
||||||
|
|
||||||
- name: Build all binaries
|
- name: Build all binaries
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
@@ -72,18 +65,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
command: clean
|
command: clean
|
||||||
|
|
||||||
- name: Build all examples
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: build
|
|
||||||
args: --workspace --examples
|
|
||||||
|
|
||||||
- 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
|
- name: Run all tests
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
@@ -92,7 +73,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Reclaim some disk space (because Windows is being annoying)
|
- name: Reclaim some disk space (because Windows is being annoying)
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-20.04' }}
|
if: ${{ matrix.os == 'windows-latest' }}
|
||||||
with:
|
with:
|
||||||
command: clean
|
command: clean
|
||||||
|
|
||||||
@@ -101,7 +82,13 @@ jobs:
|
|||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --workspace -- --ignored
|
args: --workspace --all-features -- --ignored
|
||||||
|
|
||||||
|
- name: Check formatting
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
- name: Reclaim some disk space (because Windows is being annoying)
|
- name: Reclaim some disk space (because Windows is being annoying)
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
@@ -114,7 +101,7 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
args: --workspace
|
args: --all-features
|
||||||
|
|
||||||
- name: Run clippy
|
- name: Run clippy
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
@@ -129,6 +116,38 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
command: clean
|
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)
|
# nym-wallet (the rust part)
|
||||||
- name: Build nym-wallet rust code
|
- name: Build nym-wallet rust code
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Install Dependencies (Linux)
|
- name: Install Dependencies (Linux)
|
||||||
run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools
|
run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libudev-dev squashfs-tools
|
||||||
continue-on-error: true
|
|
||||||
if: matrix.os == 'ubuntu-20.04'
|
if: matrix.os == 'ubuntu-20.04'
|
||||||
|
|
||||||
- name: Check out latest release branch
|
- name: Check out latest release branch
|
||||||
@@ -54,12 +53,6 @@ jobs:
|
|||||||
override: true
|
override: true
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
|
|
||||||
- name: Check formatting
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: fmt
|
|
||||||
args: --all -- --check
|
|
||||||
|
|
||||||
- name: Build all binaries
|
- name: Build all binaries
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
@@ -72,18 +65,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
command: clean
|
command: clean
|
||||||
|
|
||||||
- name: Build all examples
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: build
|
|
||||||
args: --workspace --examples
|
|
||||||
|
|
||||||
- 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
|
- name: Run all tests
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
@@ -92,7 +73,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Reclaim some disk space (because Windows is being annoying)
|
- name: Reclaim some disk space (because Windows is being annoying)
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-20.04' }}
|
if: ${{ matrix.os == 'windows-latest' }}
|
||||||
with:
|
with:
|
||||||
command: clean
|
command: clean
|
||||||
|
|
||||||
@@ -101,7 +82,13 @@ jobs:
|
|||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --workspace -- --ignored
|
args: --workspace --all-features -- --ignored
|
||||||
|
|
||||||
|
- name: Check formatting
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
- name: Reclaim some disk space (because Windows is being annoying)
|
- name: Reclaim some disk space (because Windows is being annoying)
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
@@ -114,7 +101,7 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
args: --workspace
|
args: --all-features
|
||||||
|
|
||||||
- name: Run clippy
|
- name: Run clippy
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
@@ -129,6 +116,38 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
command: clean
|
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)
|
# nym-wallet (the rust part)
|
||||||
- name: Build nym-wallet rust code
|
- name: Build nym-wallet rust code
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-nym-cli:
|
publish-nym-cli:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-cli-') && (github.event_name == 'release' || github.event_name = 'workflow_dispatch') }}
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -21,6 +20,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Check the release tag starts with `nym-cli-`
|
- 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
|
uses: actions/github-script@v3
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-tauri:
|
publish-tauri:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-connect-') && github.event_name == 'release' }}
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -20,6 +19,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- 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
|
- name: Node v16
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -10,11 +10,10 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-tauri:
|
publish-tauri:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-connect-') && github.event_name == 'release' }}
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform: [custom-runner-linux]
|
platform: [ubuntu-20.04]
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
@@ -24,13 +23,17 @@ jobs:
|
|||||||
run: >
|
run: >
|
||||||
sudo apt-get update &&
|
sudo apt-get update &&
|
||||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
|
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
|
- name: Node v16
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 16
|
||||||
|
|
||||||
- name: Install Rust stable
|
- name: Install Rust stable
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-tauri:
|
publish-tauri:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-connect-') && github.event_name == 'release' }}
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -28,6 +27,13 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/checkout@v3
|
- 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
|
- name: Import signing certificate
|
||||||
env:
|
env:
|
||||||
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-nym:
|
publish-nym:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-binaries-') && github.event_name == 'release' }}
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform: [custom-runner-linux]
|
platform: [ubuntu-20.04]
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
@@ -28,7 +27,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Dependencies (Linux)
|
- 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
|
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
|
- name: Sets env vars for tokio if set in manual dispatch inputs
|
||||||
run: |
|
run: |
|
||||||
@@ -51,7 +56,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: my-artifact
|
name: my-artifact
|
||||||
path: |
|
path: |
|
||||||
target/release/explorer-api
|
|
||||||
target/release/nym-client
|
target/release/nym-client
|
||||||
target/release/nym-gateway
|
target/release/nym-gateway
|
||||||
target/release/nym-mixnode
|
target/release/nym-mixnode
|
||||||
@@ -67,7 +71,6 @@ jobs:
|
|||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
target/release/explorer-api
|
|
||||||
target/release/nym-client
|
target/release/nym-client
|
||||||
target/release/nym-gateway
|
target/release/nym-gateway
|
||||||
target/release/nym-mixnode
|
target/release/nym-mixnode
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-tauri:
|
publish-tauri:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-wallet-') && github.event_name == 'release' }}
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -20,6 +19,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- 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
|
- name: Node v16
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-tauri:
|
publish-tauri:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-wallet-') && github.event_name == 'release' }}
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform: [custom-runner-linux]
|
platform: [ubuntu-20.04]
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
@@ -23,13 +22,17 @@ jobs:
|
|||||||
run: >
|
run: >
|
||||||
sudo apt-get update &&
|
sudo apt-get update &&
|
||||||
sudo apt-get install -y webkit2gtk-4.0
|
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
|
- name: Node v16
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 16
|
||||||
|
|
||||||
- name: Install Rust stable
|
- name: Install Rust stable
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-tauri:
|
publish-tauri:
|
||||||
if: ${{ startsWith(github.ref, 'refs/tags/nym-wallet-') && github.event_name == 'release' }}
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -27,6 +26,13 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/checkout@v3
|
- 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
|
- name: Import signing certificate
|
||||||
env:
|
env:
|
||||||
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ jobs:
|
|||||||
libappindicator3-dev
|
libappindicator3-dev
|
||||||
webkit2gtk-driver
|
webkit2gtk-driver
|
||||||
xvfb
|
xvfb
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Install minimal stable
|
- name: Install minimal stable
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ on:
|
|||||||
- 'ts-packages/**'
|
- 'ts-packages/**'
|
||||||
- 'sdk/typescript/**'
|
- 'sdk/typescript/**'
|
||||||
- nym-connect
|
- nym-connect
|
||||||
- nym-connect-android
|
|
||||||
- nym-wallet
|
- nym-wallet
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -16,7 +15,6 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install rsync
|
- name: Install rsync
|
||||||
run: sudo apt-get install rsync
|
run: sudo apt-get install rsync
|
||||||
continue-on-error: true
|
|
||||||
- uses: rlespinasse/github-slug-action@v3.x
|
- uses: rlespinasse/github-slug-action@v3.x
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
@@ -24,7 +22,7 @@ jobs:
|
|||||||
- name: Setup yarn
|
- name: Setup yarn
|
||||||
run: npm install -g yarn
|
run: npm install -g yarn
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: yarn && yarn lint && yarn tsc
|
run: yarn && yarn lint
|
||||||
- name: Keybase - Node Install
|
- name: Keybase - Node Install
|
||||||
run: npm install
|
run: npm install
|
||||||
working-directory: .github/workflows/support-files
|
working-directory: .github/workflows/support-files
|
||||||
|
|||||||
@@ -2,17 +2,11 @@ name: Nym Wallet (rust)
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths-ignore:
|
||||||
- 'nym-wallet/**'
|
- 'explorer/**'
|
||||||
- 'common/**'
|
|
||||||
- 'contracts/vesting/**'
|
|
||||||
- 'nym-api/nym-api-requests/**'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths-ignore:
|
||||||
- 'nym-wallet/**'
|
- 'explorer/**'
|
||||||
- 'common/**'
|
|
||||||
- 'contracts/vesting/**'
|
|
||||||
- 'nym-api/nym-api-requests/**'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -2,13 +2,8 @@ name: Wasm Client
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths-ignore:
|
||||||
- 'clients/webassembly/**'
|
- 'explorer/**'
|
||||||
- 'clients/client-core/**'
|
|
||||||
- 'common/**'
|
|
||||||
- 'contracts/**'
|
|
||||||
- 'gateway/gateway-requests/**'
|
|
||||||
- 'nym-api/nym-api-requests/**'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
wasm:
|
wasm:
|
||||||
@@ -29,6 +24,11 @@ jobs:
|
|||||||
command: build
|
command: build
|
||||||
args: --manifest-path clients/webassembly/Cargo.toml --target wasm32-unknown-unknown
|
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
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: fmt
|
command: fmt
|
||||||
|
|||||||
@@ -42,4 +42,3 @@ envs/qwerty.env
|
|||||||
Cargo.lock
|
Cargo.lock
|
||||||
nym-connect/Cargo.lock
|
nym-connect/Cargo.lock
|
||||||
.parcel-cache
|
.parcel-cache
|
||||||
**/.DS_Store
|
|
||||||
|
|||||||
+7
-71
@@ -2,77 +2,19 @@
|
|||||||
|
|
||||||
Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
# [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- dkg resharing mode ([#2936])
|
- dkg rerun from scratch and dkg-specific epochs ([#2839])
|
||||||
|
- nym-sdk: add support for surb storage ([#2870])
|
||||||
|
- nym-sdk: enable reply-SURBs by default ([#2874])
|
||||||
|
|
||||||
[#2936]: https://github.com/nymtech/nym/pull/2936
|
[#2839]: https://github.com/nymtech/nym/pull/2839
|
||||||
|
[#2870]: https://github.com/nymtech/nym/pull/2870
|
||||||
|
[#2874]: https://github.com/nymtech/nym/pull/2874
|
||||||
|
|
||||||
|
|
||||||
# [v1.1.9] (2023-02-07)
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Separate `nym-api` endpoints with values of "total-supply" and "circulating-supply" in `nym` ([#2964])
|
|
||||||
- Add `host` option to client init ([#2912])
|
|
||||||
- Remove Coconut feature flag ([#2793])
|
|
||||||
- Don't drop in mixnet connection handler ([#2963])
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- 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.
|
|
||||||
- mixnode, gateway: fix unexpected shutdown on corrupted connection ([#2963])
|
|
||||||
|
|
||||||
[#2939]: https://github.com/nymtech/nym/pull/2939
|
|
||||||
[#2963]: https://github.com/nymtech/nym/pull/2963
|
|
||||||
|
|
||||||
|
|
||||||
# [v1.1.8] (2023-01-31)
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Rust SDK - Support SURBS (anonymous send + storage) ([#2754])
|
|
||||||
- dkg rerun from scratch and dkg-specific epochs ([#2810])
|
|
||||||
- Rename `'initial_supply'` field to `'total_supply'` in the circulating supply endpoint ([#2931])
|
|
||||||
- Circulating supply api endpoint (read the note inside before testing/deploying) ([#1902])
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- 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
|
|
||||||
[#2931]: https://github.com/nymtech/nym/issues/2931
|
|
||||||
[#1902]: https://github.com/nymtech/nym/issues/1902
|
|
||||||
[#2873]: https://github.com/nymtech/nym/issues/2873
|
|
||||||
|
|
||||||
|
|
||||||
# [v1.1.7] (2023-01-24)
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Gateways now shut down gracefully ([#2019]).
|
|
||||||
- Rust SDK - Initial version for nym-client ([#2669]).
|
|
||||||
- Introduce vesting contract query for addresses of all vesting accounts (required for the circulating supply calculation) ([#2778]).
|
|
||||||
- Add threshold value to the contract storage ([#1893])
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- Refactor vesting account storage (and in particular, ACCOUNTS saving) ([#2795]).
|
|
||||||
- Move from manual advancing DKG state to an automatic process ([#2670]).
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Gateways now shut down gracefully ([#2019]).
|
|
||||||
|
|
||||||
[#2019]: https://github.com/nymtech/nym/issues/2019
|
|
||||||
[#2669]: https://github.com/nymtech/nym/issues/2669
|
|
||||||
[#2795]: https://github.com/nymtech/nym/issues/2795
|
|
||||||
[#2778]: https://github.com/nymtech/nym/issues/2778
|
|
||||||
[#2670]: https://github.com/nymtech/nym/issues/2670
|
|
||||||
[#1893]: https://github.com/nymtech/nym/issues/1893
|
|
||||||
|
|
||||||
## [v1.1.6] (2023-01-17)
|
## [v1.1.6] (2023-01-17)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -104,12 +46,6 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
## [v1.1.5] (2023-01-10)
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- socks5: send status message for service ready, and network-requester error response in https://github.com/nymtech/nym/pull/2715
|
- socks5: send status message for service ready, and network-requester error response in https://github.com/nymtech/nym/pull/2715
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
Generated
+226
-263
File diff suppressed because it is too large
Load Diff
+1
-11
@@ -38,7 +38,6 @@ members = [
|
|||||||
"common/cosmwasm-smart-contracts/mixnet-contract",
|
"common/cosmwasm-smart-contracts/mixnet-contract",
|
||||||
"common/cosmwasm-smart-contracts/multisig-contract",
|
"common/cosmwasm-smart-contracts/multisig-contract",
|
||||||
"common/cosmwasm-smart-contracts/vesting-contract",
|
"common/cosmwasm-smart-contracts/vesting-contract",
|
||||||
"common/mobile-storage",
|
|
||||||
"common/credential-storage",
|
"common/credential-storage",
|
||||||
"common/credentials",
|
"common/credentials",
|
||||||
"common/crypto",
|
"common/crypto",
|
||||||
@@ -76,7 +75,6 @@ members = [
|
|||||||
"integrations/bity",
|
"integrations/bity",
|
||||||
"mixnode",
|
"mixnode",
|
||||||
"sdk/rust/nym-sdk",
|
"sdk/rust/nym-sdk",
|
||||||
"service-providers/common",
|
|
||||||
"service-providers/network-requester",
|
"service-providers/network-requester",
|
||||||
"service-providers/network-statistics",
|
"service-providers/network-statistics",
|
||||||
"nym-api",
|
"nym-api",
|
||||||
@@ -97,7 +95,7 @@ default-members = [
|
|||||||
"explorer-api",
|
"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]
|
[workspace.package]
|
||||||
authors = ["Nym Technologies SA"]
|
authors = ["Nym Technologies SA"]
|
||||||
@@ -106,12 +104,4 @@ homepage = "https://nymtech.net"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
async-trait = "0.1.63"
|
|
||||||
lazy_static = "1.4.0"
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
serde = "1.0.152"
|
|
||||||
serde_json = "1.0.91"
|
|
||||||
tap = "1.0.1"
|
|
||||||
thiserror = "1.0.38"
|
|
||||||
tokio = "1.24.1"
|
|
||||||
url = "2.2"
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ test: clippy-all cargo-test wasm fmt
|
|||||||
test-all: test cargo-test-expensive
|
test-all: test cargo-test-expensive
|
||||||
no-clippy: build cargo-test wasm fmt
|
no-clippy: build cargo-test wasm fmt
|
||||||
happy: fmt clippy-happy test
|
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
|
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: 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
|
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
|
build: build-contracts build-wallet build-main build-connect build-wasm-client
|
||||||
fmt: fmt-main fmt-contracts fmt-wallet fmt-connect fmt-wasm-client
|
fmt: fmt-main fmt-contracts fmt-wallet fmt-connect fmt-wasm-client
|
||||||
|
|
||||||
@@ -24,6 +24,9 @@ clippy-happy-connect:
|
|||||||
clippy-main:
|
clippy-main:
|
||||||
cargo clippy --workspace -- -D warnings
|
cargo clippy --workspace -- -D warnings
|
||||||
|
|
||||||
|
clippy-coconut:
|
||||||
|
cargo clippy --workspace --features coconut -- -D warnings
|
||||||
|
|
||||||
clippy-wasm:
|
clippy-wasm:
|
||||||
cargo clippy --manifest-path clients/webassembly/Cargo.toml --target wasm32-unknown-unknown --workspace -- -D warnings
|
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:
|
test-main:
|
||||||
cargo test --workspace
|
cargo test --workspace
|
||||||
|
|
||||||
|
test-coconut:
|
||||||
|
cargo test --workspace --features coconut
|
||||||
|
|
||||||
|
|
||||||
test-main-expensive:
|
test-main-expensive:
|
||||||
cargo test --workspace -- --ignored
|
cargo test --workspace -- --ignored
|
||||||
|
|
||||||
|
test-coconut-expensive:
|
||||||
|
cargo test --workspace --features coconut -- --ignored
|
||||||
|
|
||||||
test-contracts:
|
test-contracts:
|
||||||
cargo test --manifest-path contracts/Cargo.toml --all-features
|
cargo test --manifest-path contracts/Cargo.toml --all-features
|
||||||
|
|
||||||
@@ -109,6 +119,3 @@ mixnet-opt: wasm
|
|||||||
generate-typescript:
|
generate-typescript:
|
||||||
cd tools/ts-rs-cli && cargo run && cd ../..
|
cd tools/ts-rs-cli && cargo run && cd ../..
|
||||||
yarn types:lint:fix
|
yarn types:lint:fix
|
||||||
|
|
||||||
run-validator-tests:
|
|
||||||
cd nym-api/tests/functional_test && yarn test:qa
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "client-core"
|
name = "client-core"
|
||||||
version = "1.1.8"
|
version = "1.1.6"
|
||||||
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>"]
|
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.66"
|
rust-version = "1.66"
|
||||||
@@ -82,4 +82,5 @@ sqlx = { version = "0.6.2", features = ["runtime-tokio-rustls", "sqlite", "macro
|
|||||||
default = []
|
default = []
|
||||||
fs-surb-storage = ["sqlx"]
|
fs-surb-storage = ["sqlx"]
|
||||||
wasm = ["gateway-client/wasm"]
|
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"))]
|
#[cfg(all(not(target_arch = "wasm32"), feature = "fs-surb-storage"))]
|
||||||
pub mod non_wasm_helpers;
|
pub mod non_wasm_helpers;
|
||||||
|
|
||||||
pub mod helpers;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct ClientInput {
|
pub struct ClientInput {
|
||||||
pub connection_command_sender: ConnectionCommandSender,
|
pub connection_command_sender: ConnectionCommandSender,
|
||||||
pub input_sender: InputMessageSender,
|
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 struct ClientOutput {
|
||||||
pub received_buffer_request_sender: ReceivedBufferRequestSender,
|
pub received_buffer_request_sender: ReceivedBufferRequestSender,
|
||||||
}
|
}
|
||||||
@@ -302,6 +289,10 @@ where
|
|||||||
if gateway_id.is_empty() {
|
if gateway_id.is_empty() {
|
||||||
return Err(ClientCoreError::GatewayIdUnknown);
|
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();
|
let gateway_address = self.gateway_config.gateway_listener.clone();
|
||||||
if gateway_address.is_empty() {
|
if gateway_address.is_empty() {
|
||||||
return Err(ClientCoreError::GatwayAddressUnknown);
|
return Err(ClientCoreError::GatwayAddressUnknown);
|
||||||
@@ -314,7 +305,6 @@ where
|
|||||||
let shared_key = if self.key_manager.is_gateway_key_set() {
|
let shared_key = if self.key_manager.is_gateway_key_set() {
|
||||||
Some(self.key_manager.gateway_shared_key())
|
Some(self.key_manager.gateway_shared_key())
|
||||||
} else {
|
} else {
|
||||||
log::info!("Gateway key not set! Will proceed anyway.");
|
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -322,6 +312,7 @@ where
|
|||||||
gateway_address,
|
gateway_address,
|
||||||
self.key_manager.identity_keypair(),
|
self.key_manager.identity_keypair(),
|
||||||
gateway_identity,
|
gateway_identity,
|
||||||
|
gateway_owner,
|
||||||
shared_key,
|
shared_key,
|
||||||
mixnet_message_sender,
|
mixnet_message_sender,
|
||||||
ack_sender,
|
ack_sender,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::replies::reply_storage::{
|
use crate::client::replies::reply_storage::{
|
||||||
fs_backend, CombinedReplyStorage, ReplyStorageBackend,
|
self, fs_backend, CombinedReplyStorage, ReplyStorageBackend,
|
||||||
};
|
};
|
||||||
use crate::config::DebugConfig;
|
use crate::config::DebugConfig;
|
||||||
use crate::error::ClientCoreError;
|
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))
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -77,12 +77,4 @@ impl InputMessage {
|
|||||||
lane,
|
lane,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lane(&self) -> &TransmissionLane {
|
|
||||||
match self {
|
|
||||||
InputMessage::Regular { lane, .. }
|
|
||||||
| InputMessage::Anonymous { lane, .. }
|
|
||||||
| InputMessage::Reply { lane, .. } => lane,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,11 +81,7 @@ pub struct Config {
|
|||||||
|
|
||||||
/// Defines maximum amount of time the client is going to wait for reply surbs before explicitly asking
|
/// 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.
|
/// for more even though in theory they wouldn't need to.
|
||||||
maximum_reply_surb_rerequest_waiting_period: Duration,
|
maximum_reply_surb_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,
|
|
||||||
|
|
||||||
/// Defines maximum amount of time given reply surb is going to be valid for.
|
/// 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.
|
/// 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.minimum_reply_surb_request_size,
|
||||||
cfg.maximum_reply_surb_request_size,
|
cfg.maximum_reply_surb_request_size,
|
||||||
cfg.maximum_allowed_reply_surb_request_size,
|
cfg.maximum_allowed_reply_surb_request_size,
|
||||||
cfg.maximum_reply_surb_rerequest_waiting_period,
|
cfg.maximum_reply_surb_waiting_period,
|
||||||
cfg.maximum_reply_surb_drop_waiting_period,
|
|
||||||
cfg.maximum_reply_surb_age,
|
cfg.maximum_reply_surb_age,
|
||||||
cfg.maximum_reply_key_age,
|
cfg.maximum_reply_key_age,
|
||||||
)
|
)
|
||||||
@@ -166,10 +161,8 @@ impl Config {
|
|||||||
.maximum_reply_surb_request_size,
|
.maximum_reply_surb_request_size,
|
||||||
maximum_allowed_reply_surb_request_size: base_client_debug_config
|
maximum_allowed_reply_surb_request_size: base_client_debug_config
|
||||||
.maximum_allowed_reply_surb_request_size,
|
.maximum_allowed_reply_surb_request_size,
|
||||||
maximum_reply_surb_rerequest_waiting_period: base_client_debug_config
|
maximum_reply_surb_waiting_period: base_client_debug_config
|
||||||
.maximum_reply_surb_rerequest_waiting_period,
|
.maximum_reply_surb_waiting_period,
|
||||||
maximum_reply_surb_drop_waiting_period: base_client_debug_config
|
|
||||||
.maximum_reply_surb_drop_waiting_period,
|
|
||||||
maximum_reply_surb_age: base_client_debug_config.maximum_reply_surb_age,
|
maximum_reply_surb_age: base_client_debug_config.maximum_reply_surb_age,
|
||||||
maximum_reply_key_age: base_client_debug_config.maximum_reply_key_age,
|
maximum_reply_key_age: base_client_debug_config.maximum_reply_key_age,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ pub struct Config {
|
|||||||
min_surb_request_size: u32,
|
min_surb_request_size: u32,
|
||||||
max_surb_request_size: u32,
|
max_surb_request_size: u32,
|
||||||
maximum_allowed_reply_surb_request_size: u32,
|
maximum_allowed_reply_surb_request_size: u32,
|
||||||
max_surb_rerequest_waiting_period: Duration,
|
max_surb_waiting_period: Duration,
|
||||||
max_surb_drop_waiting_period: Duration,
|
|
||||||
max_reply_surb_age: Duration,
|
max_reply_surb_age: Duration,
|
||||||
max_reply_key_age: Duration,
|
max_reply_key_age: Duration,
|
||||||
}
|
}
|
||||||
@@ -41,8 +40,7 @@ impl Config {
|
|||||||
min_surb_request_size: u32,
|
min_surb_request_size: u32,
|
||||||
max_surb_request_size: u32,
|
max_surb_request_size: u32,
|
||||||
maximum_allowed_reply_surb_request_size: u32,
|
maximum_allowed_reply_surb_request_size: u32,
|
||||||
max_surb_rerequest_waiting_period: Duration,
|
max_surb_waiting_period: Duration,
|
||||||
max_surb_drop_waiting_period: Duration,
|
|
||||||
max_reply_surb_age: Duration,
|
max_reply_surb_age: Duration,
|
||||||
max_reply_key_age: Duration,
|
max_reply_key_age: Duration,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -50,8 +48,7 @@ impl Config {
|
|||||||
min_surb_request_size,
|
min_surb_request_size,
|
||||||
max_surb_request_size,
|
max_surb_request_size,
|
||||||
maximum_allowed_reply_surb_request_size,
|
maximum_allowed_reply_surb_request_size,
|
||||||
max_surb_rerequest_waiting_period,
|
max_surb_waiting_period,
|
||||||
max_surb_drop_waiting_period,
|
|
||||||
max_reply_surb_age,
|
max_reply_surb_age,
|
||||||
max_reply_key_age,
|
max_reply_key_age,
|
||||||
}
|
}
|
||||||
@@ -745,13 +742,9 @@ where
|
|||||||
|
|
||||||
let diff = now - last_received_time;
|
let diff = now - last_received_time;
|
||||||
|
|
||||||
if diff > self.config.max_surb_rerequest_waiting_period {
|
if diff > self.config.max_surb_waiting_period {
|
||||||
if diff > self.config.max_surb_drop_waiting_period {
|
warn!("We haven't received any surbs in {:?} from {pending_reply_target}. Going to explicitly ask for more", diff);
|
||||||
to_remove.push(*pending_reply_target)
|
to_request.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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ use crate::client::replies::reply_storage::backend::Empty;
|
|||||||
use crate::client::replies::reply_storage::{CombinedReplyStorage, ReplyStorageBackend};
|
use crate::client::replies::reply_storage::{CombinedReplyStorage, ReplyStorageBackend};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
// well, right now we don't have the browser storage : (
|
// well, right now we don't have the browser storage : (
|
||||||
// so we keep everything in memory
|
// so we keep everything in memory
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -29,18 +27,6 @@ impl Backend {
|
|||||||
impl ReplyStorageBackend for Backend {
|
impl ReplyStorageBackend for Backend {
|
||||||
type StorageError = <Empty as ReplyStorageBackend>::StorageError;
|
type StorageError = <Empty as ReplyStorageBackend>::StorageError;
|
||||||
|
|
||||||
async fn new(
|
|
||||||
debug_config: &crate::config::DebugConfig,
|
|
||||||
_db_path: Option<PathBuf>,
|
|
||||||
) -> Result<Self, Self::StorageError> {
|
|
||||||
Ok(Backend {
|
|
||||||
empty: Empty {
|
|
||||||
min_surb_threshold: debug_config.minimum_reply_surb_storage_threshold,
|
|
||||||
max_surb_threshold: debug_config.maximum_reply_surb_storage_threshold,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn flush_surb_storage(
|
async fn flush_surb_storage(
|
||||||
&mut self,
|
&mut self,
|
||||||
storage: &CombinedReplyStorage,
|
storage: &CombinedReplyStorage,
|
||||||
|
|||||||
@@ -56,9 +56,4 @@ pub enum StorageError {
|
|||||||
details: String,
|
details: String,
|
||||||
// err: Option<Box<dyn std::error::Error>>
|
// err: Option<Box<dyn std::error::Error>>
|
||||||
},
|
},
|
||||||
|
|
||||||
#[error("failed to create storage")]
|
|
||||||
FailedToCreateStorage {
|
|
||||||
source: Box<dyn std::error::Error + Send + Sync>,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::base_client::non_wasm_helpers;
|
|
||||||
use crate::client::replies::reply_storage::backend::fs_backend::manager::StorageManager;
|
use crate::client::replies::reply_storage::backend::fs_backend::manager::StorageManager;
|
||||||
use crate::client::replies::reply_storage::backend::fs_backend::models::{
|
use crate::client::replies::reply_storage::backend::fs_backend::models::{
|
||||||
ReplySurbStorageMetadata, StoredReplyKey, StoredReplySurb, StoredSenderTag, StoredSurbSender,
|
ReplySurbStorageMetadata, StoredReplyKey, StoredReplySurb, StoredSenderTag, StoredSurbSender,
|
||||||
@@ -368,20 +367,6 @@ impl Backend {
|
|||||||
impl ReplyStorageBackend for Backend {
|
impl ReplyStorageBackend for Backend {
|
||||||
type StorageError = error::StorageError;
|
type StorageError = error::StorageError;
|
||||||
|
|
||||||
async fn new(
|
|
||||||
debug_config: &crate::config::DebugConfig,
|
|
||||||
db_path: Option<PathBuf>,
|
|
||||||
) -> Result<Self, Self::StorageError> {
|
|
||||||
non_wasm_helpers::setup_fs_reply_surb_backend(db_path, debug_config)
|
|
||||||
.await
|
|
||||||
.map_err(|err| {
|
|
||||||
log::error!("Failed to create storage: {err}");
|
|
||||||
Self::StorageError::FailedToCreateStorage {
|
|
||||||
source: Box::new(err),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_active(&self) -> bool {
|
fn is_active(&self) -> bool {
|
||||||
self.manager.is_active()
|
self.manager.is_active()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
use crate::client::replies::reply_storage::CombinedReplyStorage;
|
use crate::client::replies::reply_storage::CombinedReplyStorage;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use std::{error::Error, path::PathBuf};
|
use std::error::Error;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
@@ -30,16 +30,6 @@ pub struct Empty {
|
|||||||
impl ReplyStorageBackend for Empty {
|
impl ReplyStorageBackend for Empty {
|
||||||
type StorageError = UndefinedError;
|
type StorageError = UndefinedError;
|
||||||
|
|
||||||
async fn new(
|
|
||||||
debug_config: &crate::config::DebugConfig,
|
|
||||||
_db_path: Option<PathBuf>,
|
|
||||||
) -> Result<Self, Self::StorageError> {
|
|
||||||
Ok(Self {
|
|
||||||
min_surb_threshold: debug_config.minimum_reply_surb_storage_threshold,
|
|
||||||
max_surb_threshold: debug_config.maximum_reply_surb_storage_threshold,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn flush_surb_storage(
|
async fn flush_surb_storage(
|
||||||
&mut self,
|
&mut self,
|
||||||
_storage: &CombinedReplyStorage,
|
_storage: &CombinedReplyStorage,
|
||||||
@@ -73,11 +63,6 @@ impl ReplyStorageBackend for Empty {
|
|||||||
pub trait ReplyStorageBackend: Sized {
|
pub trait ReplyStorageBackend: Sized {
|
||||||
type StorageError: Error + 'static;
|
type StorageError: Error + 'static;
|
||||||
|
|
||||||
async fn new(
|
|
||||||
debug_config: &crate::config::DebugConfig,
|
|
||||||
db_path: Option<PathBuf>,
|
|
||||||
) -> Result<Self, Self::StorageError>;
|
|
||||||
|
|
||||||
fn is_active(&self) -> bool {
|
fn is_active(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_ALLOWED_SURB_REQUEST_SIZE: u32 = 500;
|
||||||
|
|
||||||
const DEFAULT_MAXIMUM_REPLY_SURB_REREQUEST_WAITING_PERIOD: Duration = Duration::from_secs(10);
|
const DEFAULT_MAXIMUM_REPLY_SURB_WAITING_PERIOD: Duration = Duration::from_secs(10);
|
||||||
const DEFAULT_MAXIMUM_REPLY_SURB_DROP_WAITING_PERIOD: Duration = Duration::from_secs(5 * 60);
|
|
||||||
|
|
||||||
// 12 hours
|
// 12 hours
|
||||||
const DEFAULT_MAXIMUM_REPLY_SURB_AGE: Duration = Duration::from_secs(12 * 60 * 60);
|
const DEFAULT_MAXIMUM_REPLY_SURB_AGE: Duration = Duration::from_secs(12 * 60 * 60);
|
||||||
@@ -171,15 +170,10 @@ impl<T> Config<T> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_gateway_endpoint(&mut self, gateway_endpoint: GatewayEndpointConfig) {
|
pub fn with_gateway_endpoint(&mut self, gateway_endpoint: GatewayEndpointConfig) {
|
||||||
self.client.gateway_endpoint = gateway_endpoint;
|
self.client.gateway_endpoint = gateway_endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_gateway_endpoint(mut self, gateway_endpoint: GatewayEndpointConfig) -> Self {
|
|
||||||
self.client.gateway_endpoint = gateway_endpoint;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_gateway_id<S: Into<String>>(&mut self, id: S) {
|
pub fn with_gateway_id<S: Into<String>>(&mut self, id: S) {
|
||||||
self.client.gateway_endpoint.gateway_id = id.into();
|
self.client.gateway_endpoint.gateway_id = id.into();
|
||||||
}
|
}
|
||||||
@@ -378,12 +372,8 @@ impl<T> Config<T> {
|
|||||||
self.debug.maximum_allowed_reply_surb_request_size
|
self.debug.maximum_allowed_reply_surb_request_size
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_maximum_reply_surb_rerequest_waiting_period(&self) -> Duration {
|
pub fn get_maximum_reply_surb_waiting_period(&self) -> Duration {
|
||||||
self.debug.maximum_reply_surb_rerequest_waiting_period
|
self.debug.maximum_reply_surb_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_age(&self) -> Duration {
|
pub fn get_maximum_reply_surb_age(&self) -> Duration {
|
||||||
@@ -551,35 +541,35 @@ impl<T: NymConfig> Default for Client<T> {
|
|||||||
|
|
||||||
impl<T: NymConfig> Client<T> {
|
impl<T: NymConfig> Client<T> {
|
||||||
fn default_private_identity_key_file(id: &str) -> PathBuf {
|
fn default_private_identity_key_file(id: &str) -> PathBuf {
|
||||||
T::default_data_directory(id).join("private_identity.pem")
|
T::default_data_directory(Some(id)).join("private_identity.pem")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_public_identity_key_file(id: &str) -> PathBuf {
|
fn default_public_identity_key_file(id: &str) -> PathBuf {
|
||||||
T::default_data_directory(id).join("public_identity.pem")
|
T::default_data_directory(Some(id)).join("public_identity.pem")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_private_encryption_key_file(id: &str) -> PathBuf {
|
fn default_private_encryption_key_file(id: &str) -> PathBuf {
|
||||||
T::default_data_directory(id).join("private_encryption.pem")
|
T::default_data_directory(Some(id)).join("private_encryption.pem")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_public_encryption_key_file(id: &str) -> PathBuf {
|
fn default_public_encryption_key_file(id: &str) -> PathBuf {
|
||||||
T::default_data_directory(id).join("public_encryption.pem")
|
T::default_data_directory(Some(id)).join("public_encryption.pem")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_gateway_shared_key_file(id: &str) -> PathBuf {
|
fn default_gateway_shared_key_file(id: &str) -> PathBuf {
|
||||||
T::default_data_directory(id).join("gateway_shared.pem")
|
T::default_data_directory(Some(id)).join("gateway_shared.pem")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_ack_key_file(id: &str) -> PathBuf {
|
fn default_ack_key_file(id: &str) -> PathBuf {
|
||||||
T::default_data_directory(id).join("ack_key.pem")
|
T::default_data_directory(Some(id)).join("ack_key.pem")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_reply_surb_database_path(id: &str) -> PathBuf {
|
fn default_reply_surb_database_path(id: &str) -> PathBuf {
|
||||||
T::default_data_directory(id).join("persistent_reply_store.sqlite")
|
T::default_data_directory(Some(id)).join("persistent_reply_store.sqlite")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_database_path(id: &str) -> PathBuf {
|
fn default_database_path(id: &str) -> PathBuf {
|
||||||
T::default_data_directory(id).join(DB_FILE_NAME)
|
T::default_data_directory(Some(id)).join(DB_FILE_NAME)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,12 +663,7 @@ pub struct DebugConfig {
|
|||||||
/// Defines maximum amount of time the client is going to wait for reply surbs before explicitly asking
|
/// 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.
|
/// for more even though in theory they wouldn't need to.
|
||||||
#[serde(with = "humantime_serde")]
|
#[serde(with = "humantime_serde")]
|
||||||
pub maximum_reply_surb_rerequest_waiting_period: Duration,
|
pub maximum_reply_surb_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,
|
|
||||||
|
|
||||||
/// Defines maximum amount of time given reply surb is going to be valid for.
|
/// 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.
|
/// This is going to be superseded by key rotation once implemented.
|
||||||
@@ -719,9 +704,7 @@ impl Default for DebugConfig {
|
|||||||
minimum_reply_surb_request_size: DEFAULT_MINIMUM_REPLY_SURB_REQUEST_SIZE,
|
minimum_reply_surb_request_size: DEFAULT_MINIMUM_REPLY_SURB_REQUEST_SIZE,
|
||||||
maximum_reply_surb_request_size: DEFAULT_MAXIMUM_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_allowed_reply_surb_request_size: DEFAULT_MAXIMUM_ALLOWED_SURB_REQUEST_SIZE,
|
||||||
maximum_reply_surb_rerequest_waiting_period:
|
maximum_reply_surb_waiting_period: DEFAULT_MAXIMUM_REPLY_SURB_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_age: DEFAULT_MAXIMUM_REPLY_SURB_AGE,
|
maximum_reply_surb_age: DEFAULT_MAXIMUM_REPLY_SURB_AGE,
|
||||||
maximum_reply_key_age: DEFAULT_MAXIMUM_REPLY_KEY_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(
|
let mut gateway_client: GatewayClient<SigningNyxdClient> = GatewayClient::new_init(
|
||||||
gateway.clients_address(),
|
gateway.clients_address(),
|
||||||
gateway.identity_key,
|
gateway.identity_key,
|
||||||
|
gateway.owner.clone(),
|
||||||
our_identity.clone(),
|
our_identity.clone(),
|
||||||
timeout,
|
timeout,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ pub fn load_existing_gateway_config<T>(id: &str) -> Result<GatewayEndpointConfig
|
|||||||
where
|
where
|
||||||
T: NymConfig + ClientCoreConfigTrait,
|
T: NymConfig + ClientCoreConfigTrait,
|
||||||
{
|
{
|
||||||
T::load_from_file(id)
|
T::load_from_file(Some(id))
|
||||||
.map(|existing_config| existing_config.get_gateway_endpoint().clone())
|
.map(|existing_config| existing_config.get_gateway_endpoint().clone())
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
log::error!(
|
log::error!(
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bip39 = "1.0.1"
|
bip39 = "1.0.1"
|
||||||
|
cfg-if = "0.1"
|
||||||
clap = { version = "4.0", features = ["cargo", "derive"] }
|
clap = { version = "4.0", features = ["cargo", "derive"] }
|
||||||
log = "0.4"
|
|
||||||
rand = "0.7.3"
|
rand = "0.7.3"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
@@ -21,8 +21,9 @@ completions = { path = "../../common/completions" }
|
|||||||
credentials = { path = "../../common/credentials" }
|
credentials = { path = "../../common/credentials" }
|
||||||
credential-storage = { path = "../../common/credential-storage" }
|
credential-storage = { path = "../../common/credential-storage" }
|
||||||
crypto = { path = "../../common/crypto", features = ["rand", "asymmetric", "symmetric", "aes", "hashing"] }
|
crypto = { path = "../../common/crypto", features = ["rand", "asymmetric", "symmetric", "aes", "hashing"] }
|
||||||
logging = { path = "../../common/logging"}
|
|
||||||
network-defaults = { path = "../../common/network-defaults" }
|
network-defaults = { path = "../../common/network-defaults" }
|
||||||
pemstore = { path = "../../common/pemstore" }
|
pemstore = { path = "../../common/pemstore" }
|
||||||
validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] }
|
validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
coconut = ["credentials/coconut"]
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use clap::{ArgGroup, Args, Subcommand};
|
use clap::{Args, Subcommand};
|
||||||
use completions::ArgShell;
|
use completions::ArgShell;
|
||||||
use log::*;
|
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
@@ -13,20 +12,18 @@ use credential_storage::PersistentStorage;
|
|||||||
use credentials::coconut::bandwidth::{BandwidthVoucher, TOTAL_ATTRIBUTES};
|
use credentials::coconut::bandwidth::{BandwidthVoucher, TOTAL_ATTRIBUTES};
|
||||||
use credentials::coconut::utils::obtain_aggregate_signature;
|
use credentials::coconut::utils::obtain_aggregate_signature;
|
||||||
use crypto::asymmetric::{encryption, identity};
|
use crypto::asymmetric::{encryption, identity};
|
||||||
use network_defaults::VOUCHER_INFO;
|
use network_defaults::{NymNetworkDetails, VOUCHER_INFO};
|
||||||
use validator_client::nyxd::traits::DkgQueryClient;
|
use validator_client::nyxd::traits::DkgQueryClient;
|
||||||
use validator_client::nyxd::tx::Hash;
|
use validator_client::nyxd::tx::Hash;
|
||||||
use validator_client::nyxd::CosmWasmClient;
|
use validator_client::{CoconutApiClient, Config};
|
||||||
use validator_client::CoconutApiClient;
|
|
||||||
|
|
||||||
use crate::client::Client;
|
use crate::client::Client;
|
||||||
use crate::error::{CredentialClientError, Result};
|
use crate::error::{CredentialClientError, Result};
|
||||||
use crate::recovery_storage::RecoveryStorage;
|
|
||||||
use crate::state::{KeyPair, State};
|
use crate::state::{KeyPair, State};
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
pub(crate) enum Command {
|
pub(crate) enum Command {
|
||||||
/// Run the binary to obtain a credential
|
/// Run the binary
|
||||||
Run(Run),
|
Run(Run),
|
||||||
|
|
||||||
/// Generate shell completions
|
/// Generate shell completions
|
||||||
@@ -37,11 +34,6 @@ pub(crate) enum Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
#[clap(group(
|
|
||||||
ArgGroup::new("recov")
|
|
||||||
.required(true)
|
|
||||||
.args(&["amount", "recovery_mode"]),
|
|
||||||
))]
|
|
||||||
pub(crate) struct Run {
|
pub(crate) struct Run {
|
||||||
/// Home directory of the client that is supposed to use the credential.
|
/// Home directory of the client that is supposed to use the credential.
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
@@ -55,25 +47,15 @@ pub(crate) struct Run {
|
|||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub(crate) mnemonic: String,
|
pub(crate) mnemonic: String,
|
||||||
|
|
||||||
/// The amount of utokens the credential will hold. If recovery mode is enabled, this value
|
/// The amount of utokens the credential will hold
|
||||||
/// is not needed
|
#[clap(long)]
|
||||||
#[clap(long, default_value = "0")]
|
|
||||||
pub(crate) amount: u64,
|
pub(crate) amount: u64,
|
||||||
|
|
||||||
/// Path to a directory used to store recovery files for unconsumed deposits
|
|
||||||
#[clap(long)]
|
|
||||||
pub(crate) recovery_dir: std::path::PathBuf,
|
|
||||||
|
|
||||||
/// Recovery mode, when enabled, tries to recover any deposit data dumped in recovery_dir
|
|
||||||
#[clap(long)]
|
|
||||||
pub(crate) recovery_mode: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn deposit(nyxd_url: &str, mnemonic: &str, amount: u64) -> Result<State> {
|
pub(crate) async fn deposit(nyxd_url: &str, mnemonic: &str, amount: u64) -> Result<State> {
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
let signing_keypair = KeyPair::from(identity::KeyPair::new(&mut rng));
|
let signing_keypair = KeyPair::from(identity::KeyPair::new(&mut rng));
|
||||||
let encryption_keypair = KeyPair::from(encryption::KeyPair::new(&mut rng));
|
let encryption_keypair = KeyPair::from(encryption::KeyPair::new(&mut rng));
|
||||||
let params = Parameters::new(TOTAL_ATTRIBUTES).unwrap();
|
|
||||||
|
|
||||||
let client = Client::new(nyxd_url, mnemonic);
|
let client = Client::new(nyxd_url, mnemonic);
|
||||||
let tx_hash = client
|
let tx_hash = client
|
||||||
@@ -85,47 +67,46 @@ pub(crate) async fn deposit(nyxd_url: &str, mnemonic: &str, amount: u64) -> Resu
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let voucher = BandwidthVoucher::new(
|
let state = State {
|
||||||
¶ms,
|
amount,
|
||||||
amount.to_string(),
|
tx_hash,
|
||||||
VOUCHER_INFO.to_string(),
|
signing_keypair,
|
||||||
Hash::from_str(&tx_hash).map_err(|_| CredentialClientError::InvalidTxHash)?,
|
encryption_keypair,
|
||||||
identity::PrivateKey::from_base58_string(&signing_keypair.private_key)?,
|
};
|
||||||
encryption::PrivateKey::from_base58_string(&encryption_keypair.private_key)?,
|
|
||||||
);
|
|
||||||
|
|
||||||
let state = State { voucher, params };
|
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn get_credential<C: Clone + CosmWasmClient + Send + Sync>(
|
pub(crate) async fn get_credential(state: &State, shared_storage: PersistentStorage) -> Result<()> {
|
||||||
state: &State,
|
let network_details = NymNetworkDetails::new_from_env();
|
||||||
client: validator_client::Client<C>,
|
let config = Config::try_from_nym_network_details(&network_details)?;
|
||||||
shared_storage: PersistentStorage,
|
let client = validator_client::Client::new_query(config)?;
|
||||||
) -> Result<()> {
|
|
||||||
let epoch_id = client.nyxd.get_current_epoch().await?.epoch_id;
|
let epoch_id = client.nyxd.get_current_epoch().await?.epoch_id;
|
||||||
let threshold = client
|
|
||||||
.nyxd
|
|
||||||
.get_current_epoch_threshold()
|
|
||||||
.await?
|
|
||||||
.ok_or(CredentialClientError::NoThreshold)?;
|
|
||||||
let coconut_api_clients = CoconutApiClient::all_coconut_api_clients(&client, epoch_id).await?;
|
let coconut_api_clients = CoconutApiClient::all_coconut_api_clients(&client, epoch_id).await?;
|
||||||
|
|
||||||
|
let params = Parameters::new(TOTAL_ATTRIBUTES).unwrap();
|
||||||
|
let bandwidth_credential_attributes = BandwidthVoucher::new(
|
||||||
|
¶ms,
|
||||||
|
state.amount.to_string(),
|
||||||
|
VOUCHER_INFO.to_string(),
|
||||||
|
Hash::from_str(&state.tx_hash).map_err(|_| CredentialClientError::InvalidTxHash)?,
|
||||||
|
identity::PrivateKey::from_base58_string(&state.signing_keypair.private_key)?,
|
||||||
|
encryption::PrivateKey::from_base58_string(&state.encryption_keypair.private_key)?,
|
||||||
|
);
|
||||||
|
|
||||||
let signature = obtain_aggregate_signature(
|
let signature = obtain_aggregate_signature(
|
||||||
&state.params,
|
¶ms,
|
||||||
&state.voucher,
|
&bandwidth_credential_attributes,
|
||||||
&coconut_api_clients,
|
&coconut_api_clients,
|
||||||
threshold,
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
info!("Signature: {:?}", signature.to_bs58());
|
println!("Signature: {:?}", signature.to_bs58());
|
||||||
shared_storage
|
shared_storage
|
||||||
.insert_coconut_credential(
|
.insert_coconut_credential(
|
||||||
state.voucher.get_voucher_value(),
|
state.amount.to_string(),
|
||||||
VOUCHER_INFO.to_string(),
|
VOUCHER_INFO.to_string(),
|
||||||
state.voucher.get_private_attributes()[0].to_bs58(),
|
bandwidth_credential_attributes.get_private_attributes()[0].to_bs58(),
|
||||||
state.voucher.get_private_attributes()[1].to_bs58(),
|
bandwidth_credential_attributes.get_private_attributes()[1].to_bs58(),
|
||||||
signature.to_bs58(),
|
signature.to_bs58(),
|
||||||
epoch_id.to_string(),
|
epoch_id.to_string(),
|
||||||
)
|
)
|
||||||
@@ -133,33 +114,3 @@ pub(crate) async fn get_credential<C: Clone + CosmWasmClient + Send + Sync>(
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn recover_credentials<C: Clone + CosmWasmClient + Send + Sync>(
|
|
||||||
client: validator_client::Client<C>,
|
|
||||||
recovery_storage: &RecoveryStorage,
|
|
||||||
shared_storage: PersistentStorage,
|
|
||||||
) -> Result<()> {
|
|
||||||
for voucher in recovery_storage.unconsumed_vouchers()? {
|
|
||||||
let state = State {
|
|
||||||
voucher,
|
|
||||||
params: Parameters::new(TOTAL_ATTRIBUTES).unwrap(),
|
|
||||||
};
|
|
||||||
if let Err(e) = get_credential(&state, client.clone(), shared_storage.clone()).await {
|
|
||||||
error!(
|
|
||||||
"Could not recover deposit {} due to {:?}, try again later",
|
|
||||||
state.voucher.tx_hash(),
|
|
||||||
e
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
info!(
|
|
||||||
"Converted deposit {} to a credential, removing recovery data for it",
|
|
||||||
state.voucher.tx_hash()
|
|
||||||
);
|
|
||||||
if let Err(e) = recovery_storage.remove_voucher(state.voucher.tx_hash().to_string()) {
|
|
||||||
warn!("Could not remove recovery data - {:?}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use std::time::SystemTimeError;
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use credential_storage::error::StorageError;
|
use credential_storage::error::StorageError;
|
||||||
@@ -15,9 +14,6 @@ pub type Result<T> = std::result::Result<T, CredentialClientError>;
|
|||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum CredentialClientError {
|
pub enum CredentialClientError {
|
||||||
#[error("IO error: {0}")]
|
|
||||||
IOError(#[from] std::io::Error),
|
|
||||||
|
|
||||||
#[error("Nyxd error: {0}")]
|
#[error("Nyxd error: {0}")]
|
||||||
Nyxd(#[from] NyxdError),
|
Nyxd(#[from] NyxdError),
|
||||||
|
|
||||||
@@ -38,10 +34,4 @@ pub enum CredentialClientError {
|
|||||||
|
|
||||||
#[error("Could not use shared storage")]
|
#[error("Could not use shared storage")]
|
||||||
SharedStorageError(#[from] StorageError),
|
SharedStorageError(#[from] StorageError),
|
||||||
|
|
||||||
#[error("Could not get system time")]
|
|
||||||
SysTimeError(#[from] SystemTimeError),
|
|
||||||
|
|
||||||
#[error("Threshold not set yet")]
|
|
||||||
NoThreshold,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,109 +1,56 @@
|
|||||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
mod client;
|
cfg_if::cfg_if! {
|
||||||
mod commands;
|
if #[cfg(feature = "coconut")] {
|
||||||
mod error;
|
|
||||||
mod recovery_storage;
|
|
||||||
mod state;
|
|
||||||
|
|
||||||
use commands::*;
|
mod client;
|
||||||
use completions::fig_generate;
|
mod commands;
|
||||||
use config::{DATA_DIR, DB_FILE_NAME};
|
mod error;
|
||||||
use error::Result;
|
mod state;
|
||||||
use log::*;
|
|
||||||
use network_defaults::{setup_env, NymNetworkDetails};
|
|
||||||
use std::process::exit;
|
|
||||||
use std::time::{Duration, SystemTime};
|
|
||||||
|
|
||||||
use clap::{CommandFactory, Parser};
|
use error::Result;
|
||||||
use logging::setup_logging;
|
use network_defaults::setup_env;
|
||||||
use validator_client::nyxd::traits::DkgQueryClient;
|
use completions::fig_generate;
|
||||||
use validator_client::nyxd::CosmWasmClient;
|
use commands::*;
|
||||||
use validator_client::Config;
|
use config::{DATA_DIR, DB_FILE_NAME};
|
||||||
|
|
||||||
const SAFETY_BUFFER_SECS: u64 = 60; // 1 minute
|
use clap::{CommandFactory, Parser};
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author = "Nymtech", version, about)]
|
#[clap(author = "Nymtech", version, about)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Path pointing to an env file that configures the client.
|
/// Path pointing to an env file that configures the client.
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
||||||
|
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
pub(crate) command: Command,
|
pub(crate) command: Command,
|
||||||
}
|
|
||||||
|
|
||||||
async fn block_until_coconut_is_available<C: Clone + CosmWasmClient + Send + Sync>(
|
|
||||||
client: &validator_client::Client<C>,
|
|
||||||
) -> Result<()> {
|
|
||||||
loop {
|
|
||||||
let epoch = client.nyxd.get_current_epoch().await?;
|
|
||||||
let current_timestamp_secs = SystemTime::now()
|
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)?
|
|
||||||
.as_secs();
|
|
||||||
if epoch.state.is_final() {
|
|
||||||
if current_timestamp_secs + SAFETY_BUFFER_SECS >= epoch.finish_timestamp.seconds() {
|
|
||||||
info!("In the next {} minute(s), a transition will take place in the coconut system. Deposits should be halted in this time for safety reasons.", SAFETY_BUFFER_SECS / 60);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// Use 20 additional seconds to avoid the exact moment of going into the final epoch state
|
|
||||||
let secs_until_final = epoch.final_timestamp_secs() + 20 - current_timestamp_secs;
|
|
||||||
info!("Approximately {} seconds until coconut is available. Sleeping until then. You can safely kill the process at any moment.", secs_until_final);
|
|
||||||
std::thread::sleep(Duration::from_secs(secs_until_final));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
#[tokio::main]
|
match args.command {
|
||||||
async fn main() -> Result<()> {
|
Command::Run(r) => {
|
||||||
let args = Cli::parse();
|
let db_path = r.client_home_directory.join(DATA_DIR).join(DB_FILE_NAME);
|
||||||
setup_logging();
|
let shared_storage = credential_storage::initialise_storage(db_path).await;
|
||||||
setup_env(args.config_env_file.as_ref());
|
|
||||||
let bin_name = "nym-credential-client";
|
|
||||||
|
|
||||||
match args.command {
|
let state = deposit(&r.nyxd_url, &r.mnemonic, r.amount).await?;
|
||||||
Command::Run(r) => {
|
get_credential(&state, shared_storage).await?;
|
||||||
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 recovery_storage = recovery_storage::RecoveryStorage::new(r.recovery_dir)?;
|
|
||||||
|
|
||||||
let network_details = NymNetworkDetails::new_from_env();
|
|
||||||
let config = Config::try_from_nym_network_details(&network_details)?;
|
|
||||||
let client = validator_client::Client::new_query(config)?;
|
|
||||||
|
|
||||||
block_until_coconut_is_available(&client).await?;
|
|
||||||
info!("Starting depositing funds, don't kill the process");
|
|
||||||
|
|
||||||
if !r.recovery_mode {
|
|
||||||
let state = deposit(&r.nyxd_url, &r.mnemonic, r.amount).await?;
|
|
||||||
if get_credential(&state, client, shared_storage)
|
|
||||||
.await
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
warn!("Failed to obtain credential. Dumping recovery data.",);
|
|
||||||
match recovery_storage.insert_voucher(&state.voucher) {
|
|
||||||
Ok(file_path) => {
|
|
||||||
warn!("Dumped recovery data to {:?}. Try using recovery mode to convert it to a credential", file_path);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
error!("Could not dump recovery data to file system due to {:?}, the deposit will be lost!", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
Command::Completions(c) => c.generate(&mut crate::Cli::command(), bin_name),
|
||||||
recover_credentials(client, &recovery_storage, shared_storage).await?;
|
Command::GenerateFigSpec => fig_generate(&mut crate::Cli::command(), bin_name)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Command::Completions(c) => c.generate(&mut crate::Cli::command(), bin_name),
|
|
||||||
Command::GenerateFigSpec => fig_generate(&mut crate::Cli::command(), bin_name),
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fn main() {
|
||||||
|
println!("Crate only designed for coconut feature");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
use credentials::coconut::bandwidth::BandwidthVoucher;
|
|
||||||
use std::fs::{create_dir_all, read_dir, File};
|
|
||||||
use std::io::{Read, Write};
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
pub struct RecoveryStorage {
|
|
||||||
recovery_dir: PathBuf,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RecoveryStorage {
|
|
||||||
pub fn new(recovery_dir: PathBuf) -> std::io::Result<Self> {
|
|
||||||
create_dir_all(&recovery_dir)?;
|
|
||||||
Ok(Self { recovery_dir })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unconsumed_vouchers(&self) -> std::io::Result<impl Iterator<Item = BandwidthVoucher>> {
|
|
||||||
Ok(read_dir(&self.recovery_dir)?
|
|
||||||
.filter_map(|entry| entry.ok())
|
|
||||||
.filter_map(|entry| {
|
|
||||||
let path = entry.path();
|
|
||||||
if path.is_file() {
|
|
||||||
Some(path)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.filter_map(|path| File::open(path).ok())
|
|
||||||
.filter_map(|mut f| {
|
|
||||||
let mut buff = Vec::new();
|
|
||||||
if f.read_to_end(&mut buff).is_ok() {
|
|
||||||
Some(buff)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.filter_map(|buff| BandwidthVoucher::try_from_bytes(&buff).ok()))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn insert_voucher(&self, voucher: &BandwidthVoucher) -> std::io::Result<PathBuf> {
|
|
||||||
let file_name = voucher.tx_hash().to_string();
|
|
||||||
let file_path = self.recovery_dir.join(file_name);
|
|
||||||
let mut file = File::create(&file_path)?;
|
|
||||||
let buff = voucher.to_bytes();
|
|
||||||
file.write_all(&buff)?;
|
|
||||||
|
|
||||||
Ok(file_path)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn remove_voucher(&self, file_name: String) -> std::io::Result<()> {
|
|
||||||
let file_path = self.recovery_dir.join(file_name);
|
|
||||||
std::fs::remove_file(file_path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use coconut_interface::Parameters;
|
use serde::{Deserialize, Serialize};
|
||||||
use credentials::coconut::bandwidth::BandwidthVoucher;
|
|
||||||
|
|
||||||
use crypto::asymmetric::{encryption, identity};
|
use crypto::asymmetric::{encryption, identity};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub(crate) struct KeyPair {
|
pub(crate) struct KeyPair {
|
||||||
pub public_key: String,
|
pub public_key: String,
|
||||||
pub private_key: String,
|
pub private_key: String,
|
||||||
@@ -29,7 +29,10 @@ impl From<encryption::KeyPair> for KeyPair {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub(crate) struct State {
|
pub(crate) struct State {
|
||||||
pub voucher: BandwidthVoucher,
|
pub amount: u64,
|
||||||
pub params: Parameters,
|
pub tx_hash: String,
|
||||||
|
pub signing_keypair: KeyPair,
|
||||||
|
pub encryption_keypair: KeyPair,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nym-client"
|
name = "nym-client"
|
||||||
version = "1.1.8"
|
version = "1.1.6"
|
||||||
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
|
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
|
||||||
description = "Implementation of the Nym Client"
|
description = "Implementation of the Nym Client"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -37,11 +37,11 @@ tokio-tungstenite = "0.14" # websocket
|
|||||||
build-information = { path = "../../common/build-information" }
|
build-information = { path = "../../common/build-information" }
|
||||||
client-core = { path = "../client-core", features = ["fs-surb-storage"] }
|
client-core = { path = "../client-core", features = ["fs-surb-storage"] }
|
||||||
client-connections = { path = "../../common/client-connections" }
|
client-connections = { path = "../../common/client-connections" }
|
||||||
coconut-interface = { path = "../../common/coconut-interface" }
|
coconut-interface = { path = "../../common/coconut-interface", optional = true }
|
||||||
config = { path = "../../common/config" }
|
config = { path = "../../common/config" }
|
||||||
completions = { path = "../../common/completions" }
|
completions = { path = "../../common/completions" }
|
||||||
credential-storage = { path = "../../common/credential-storage" }
|
credential-storage = { path = "../../common/credential-storage" }
|
||||||
credentials = { path = "../../common/credentials" }
|
credentials = { path = "../../common/credentials", optional = true }
|
||||||
crypto = { path = "../../common/crypto" }
|
crypto = { path = "../../common/crypto" }
|
||||||
logging = { path = "../../common/logging"}
|
logging = { path = "../../common/logging"}
|
||||||
gateway-client = { path = "../../common/client-libs/gateway-client" }
|
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" }
|
version-checker = { path = "../../common/version-checker" }
|
||||||
websocket-requests = { path = "websocket-requests" }
|
websocket-requests = { path = "websocket-requests" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
coconut = ["coconut-interface", "credentials", "credentials/coconut", "gateway-requests/coconut", "gateway-client/coconut", "client-core/coconut"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_json = "1.0" # for the "textsend" example
|
serde_json = "1.0" # for the "textsend" example
|
||||||
|
|||||||
@@ -2,19 +2,16 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::config::template::config_template;
|
use crate::client::config::template::config_template;
|
||||||
use client_core::config::ClientCoreConfigTrait;
|
pub use client_core::config::Config as BaseConfig;
|
||||||
|
pub use client_core::config::MISSING_VALUE;
|
||||||
|
use client_core::config::{ClientCoreConfigTrait, DebugConfig};
|
||||||
use config::defaults::DEFAULT_WEBSOCKET_LISTENING_PORT;
|
use config::defaults::DEFAULT_WEBSOCKET_LISTENING_PORT;
|
||||||
use config::{NymConfig, OptionalSet};
|
use config::{NymConfig, OptionalSet};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::net::{IpAddr, Ipv4Addr};
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
pub use client_core::config::Config as BaseConfig;
|
|
||||||
pub use client_core::config::MISSING_VALUE;
|
|
||||||
pub use client_core::config::{DebugConfig, GatewayEndpointConfig};
|
|
||||||
|
|
||||||
mod template;
|
mod template;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize, Clone, Copy)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize, Clone, Copy)]
|
||||||
@@ -107,11 +104,6 @@ impl Config {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_host(mut self, host: IpAddr) -> Self {
|
|
||||||
self.socket.host = host;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_port(mut self, port: u16) -> Self {
|
pub fn with_port(mut self, port: u16) -> Self {
|
||||||
self.socket.listening_port = port;
|
self.socket.listening_port = port;
|
||||||
self
|
self
|
||||||
@@ -138,10 +130,6 @@ impl Config {
|
|||||||
self.socket.socket_type
|
self.socket.socket_type
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_listening_ip(&self) -> IpAddr {
|
|
||||||
self.socket.host
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_listening_port(&self) -> u16 {
|
pub fn get_listening_port(&self) -> u16 {
|
||||||
self.socket.listening_port
|
self.socket.listening_port
|
||||||
}
|
}
|
||||||
@@ -192,10 +180,9 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
#[serde(default, deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Socket {
|
pub struct Socket {
|
||||||
socket_type: SocketType,
|
socket_type: SocketType,
|
||||||
host: IpAddr,
|
|
||||||
listening_port: u16,
|
listening_port: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +190,6 @@ impl Default for Socket {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Socket {
|
Socket {
|
||||||
socket_type: SocketType::WebSocket,
|
socket_type: SocketType::WebSocket,
|
||||||
host: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
|
|
||||||
listening_port: DEFAULT_WEBSOCKET_LISTENING_PORT,
|
listening_port: DEFAULT_WEBSOCKET_LISTENING_PORT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,9 +93,6 @@ socket_type = '{{ socket.socket_type }}'
|
|||||||
# will be listening for incoming requests
|
# will be listening for incoming requests
|
||||||
listening_port = {{ socket.listening_port }}
|
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 #####
|
##### logging configuration options #####
|
||||||
|
|
||||||
|
|||||||
@@ -11,22 +11,19 @@ use client_core::client::base_client::{
|
|||||||
non_wasm_helpers, BaseClientBuilder, ClientInput, ClientOutput, ClientState,
|
non_wasm_helpers, BaseClientBuilder, ClientInput, ClientOutput, ClientState,
|
||||||
};
|
};
|
||||||
use client_core::client::inbound_messages::InputMessage;
|
use client_core::client::inbound_messages::InputMessage;
|
||||||
use client_core::client::received_buffer::{
|
use client_core::client::key_manager::KeyManager;
|
||||||
ReceivedBufferMessage, ReceivedBufferRequestSender, ReconstructedMessagesReceiver,
|
use client_core::client::received_buffer::{ReceivedBufferMessage, ReconstructedMessagesReceiver};
|
||||||
};
|
|
||||||
use client_core::config::persistence::key_pathfinder::ClientKeyPathfinder;
|
use client_core::config::persistence::key_pathfinder::ClientKeyPathfinder;
|
||||||
use futures::channel::mpsc;
|
use futures::channel::mpsc;
|
||||||
use gateway_client::bandwidth::BandwidthController;
|
use gateway_client::bandwidth::BandwidthController;
|
||||||
use log::*;
|
use log::*;
|
||||||
|
use nymsphinx::addressing::clients::Recipient;
|
||||||
use nymsphinx::anonymous_replies::requests::AnonymousSenderTag;
|
use nymsphinx::anonymous_replies::requests::AnonymousSenderTag;
|
||||||
|
use nymsphinx::receiver::ReconstructedMessage;
|
||||||
use task::TaskManager;
|
use task::TaskManager;
|
||||||
use tokio::sync::watch::error::SendError;
|
|
||||||
use validator_client::nyxd::QueryNyxdClient;
|
use validator_client::nyxd::QueryNyxdClient;
|
||||||
|
|
||||||
pub use client_core::client::key_manager::KeyManager;
|
pub(crate) mod config;
|
||||||
pub use nymsphinx::addressing::clients::Recipient;
|
|
||||||
pub use nymsphinx::receiver::ReconstructedMessage;
|
|
||||||
pub mod config;
|
|
||||||
|
|
||||||
pub struct SocketClient {
|
pub struct SocketClient {
|
||||||
/// Client configuration options, including, among other things, packet sending rates,
|
/// Client configuration options, including, among other things, packet sending rates,
|
||||||
@@ -48,13 +45,6 @@ impl SocketClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_keys(config: Config, key_manager: KeyManager) -> Self {
|
|
||||||
SocketClient {
|
|
||||||
config,
|
|
||||||
key_manager,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn create_bandwidth_controller(config: &Config) -> BandwidthController<QueryNyxdClient> {
|
async fn create_bandwidth_controller(config: &Config) -> BandwidthController<QueryNyxdClient> {
|
||||||
let details = network_defaults::NymNetworkDetails::new_from_env();
|
let details = network_defaults::NymNetworkDetails::new_from_env();
|
||||||
let mut client_config = validator_client::Config::try_from_nym_network_details(&details)
|
let mut client_config = validator_client::Config::try_from_nym_network_details(&details)
|
||||||
@@ -112,8 +102,7 @@ impl SocketClient {
|
|||||||
reply_controller_sender,
|
reply_controller_sender,
|
||||||
);
|
);
|
||||||
|
|
||||||
websocket::Listener::new(config.get_listening_ip(), config.get_listening_port())
|
websocket::Listener::new(config.get_listening_port()).start(websocket_handler, shutdown);
|
||||||
.start(websocket_handler, shutdown);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// blocking version of `start_socket` method. Will run forever (or until SIGINT is sent)
|
/// blocking version of `start_socket` method. Will run forever (or until SIGINT is sent)
|
||||||
@@ -130,17 +119,10 @@ impl SocketClient {
|
|||||||
return Err(ClientError::InvalidSocketMode);
|
return Err(ClientError::InvalidSocketMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't create bandwidth controller if credentials are disabled
|
|
||||||
let bandwidth_controller = if self.config.get_base().get_disabled_credentials_mode() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(Self::create_bandwidth_controller(&self.config).await)
|
|
||||||
};
|
|
||||||
|
|
||||||
let base_builder = BaseClientBuilder::new_from_base_config(
|
let base_builder = BaseClientBuilder::new_from_base_config(
|
||||||
self.config.get_base(),
|
self.config.get_base(),
|
||||||
self.key_manager,
|
self.key_manager,
|
||||||
bandwidth_controller,
|
Some(Self::create_bandwidth_controller(&self.config).await),
|
||||||
non_wasm_helpers::setup_fs_reply_surb_backend(
|
non_wasm_helpers::setup_fs_reply_surb_backend(
|
||||||
Some(self.config.get_base().get_reply_surb_database_path()),
|
Some(self.config.get_base().get_reply_surb_database_path()),
|
||||||
self.config.get_debug_settings(),
|
self.config.get_debug_settings(),
|
||||||
@@ -174,17 +156,10 @@ impl SocketClient {
|
|||||||
return Err(ClientError::InvalidSocketMode);
|
return Err(ClientError::InvalidSocketMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't create bandwidth controller if credentials are disabled
|
|
||||||
let bandwidth_controller = if self.config.get_base().get_disabled_credentials_mode() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(Self::create_bandwidth_controller(&self.config).await)
|
|
||||||
};
|
|
||||||
|
|
||||||
let base_client = BaseClientBuilder::new_from_base_config(
|
let base_client = BaseClientBuilder::new_from_base_config(
|
||||||
self.config.get_base(),
|
self.config.get_base(),
|
||||||
self.key_manager,
|
self.key_manager,
|
||||||
bandwidth_controller,
|
Some(Self::create_bandwidth_controller(&self.config).await),
|
||||||
non_wasm_helpers::setup_fs_reply_surb_backend(
|
non_wasm_helpers::setup_fs_reply_surb_backend(
|
||||||
Some(self.config.get_base().get_reply_surb_database_path()),
|
Some(self.config.get_base().get_reply_surb_database_path()),
|
||||||
self.config.get_debug_settings(),
|
self.config.get_debug_settings(),
|
||||||
@@ -192,8 +167,6 @@ impl SocketClient {
|
|||||||
.await?,
|
.await?,
|
||||||
);
|
);
|
||||||
|
|
||||||
let address = base_client.as_mix_recipient();
|
|
||||||
|
|
||||||
let mut started_client = base_client.start_base().await?;
|
let mut started_client = base_client.start_base().await?;
|
||||||
let client_input = started_client.client_input.register_producer();
|
let client_input = started_client.client_input.register_producer();
|
||||||
let client_output = started_client.client_output.register_consumer();
|
let client_output = started_client.client_output.register_consumer();
|
||||||
@@ -211,38 +184,21 @@ impl SocketClient {
|
|||||||
|
|
||||||
Ok(DirectClient {
|
Ok(DirectClient {
|
||||||
client_input,
|
client_input,
|
||||||
_received_buffer_request_sender: client_output.received_buffer_request_sender,
|
|
||||||
reconstructed_receiver,
|
reconstructed_receiver,
|
||||||
address,
|
_shutdown_notifier: started_client.task_manager,
|
||||||
shutdown_notifier: started_client.task_manager,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DirectClient {
|
pub struct DirectClient {
|
||||||
client_input: ClientInput,
|
client_input: ClientInput,
|
||||||
// make sure to not drop the channel
|
|
||||||
_received_buffer_request_sender: ReceivedBufferRequestSender,
|
|
||||||
reconstructed_receiver: ReconstructedMessagesReceiver,
|
reconstructed_receiver: ReconstructedMessagesReceiver,
|
||||||
address: Recipient,
|
|
||||||
|
|
||||||
// we need to keep reference to this guy otherwise things will start dropping
|
// we need to keep reference to this guy otherwise things will start dropping
|
||||||
shutdown_notifier: TaskManager,
|
_shutdown_notifier: TaskManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DirectClient {
|
impl DirectClient {
|
||||||
pub fn address(&self) -> &Recipient {
|
|
||||||
&self.address
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn signal_shutdown(&self) -> Result<(), SendError<()>> {
|
|
||||||
self.shutdown_notifier.signal_shutdown()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn wait_for_shutdown(&mut self) {
|
|
||||||
self.shutdown_notifier.wait_for_shutdown().await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// EXPERIMENTAL DIRECT RUST API
|
/// EXPERIMENTAL DIRECT RUST API
|
||||||
/// It's untested and there are absolutely no guarantees about it (but seems to have worked
|
/// It's untested and there are absolutely no guarantees about it (but seems to have worked
|
||||||
/// well enough in local tests)
|
/// well enough in local tests)
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use crypto::asymmetric::identity;
|
|||||||
use nymsphinx::addressing::clients::Recipient;
|
use nymsphinx::addressing::clients::Recipient;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::net::IpAddr;
|
|
||||||
use tap::TapFallible;
|
use tap::TapFallible;
|
||||||
|
|
||||||
#[derive(Args, Clone)]
|
#[derive(Args, Clone)]
|
||||||
@@ -31,7 +30,8 @@ pub(crate) struct Init {
|
|||||||
force_register_gateway: bool,
|
force_register_gateway: bool,
|
||||||
|
|
||||||
/// Comma separated list of rest endpoints of the nyxd validators
|
/// Comma separated list of rest endpoints of the nyxd validators
|
||||||
#[clap(long, alias = "nymd_validators", value_delimiter = ',', hide = true)]
|
#[cfg(feature = "coconut")]
|
||||||
|
#[clap(long, alias = "nymd_validators", value_delimiter = ',')]
|
||||||
nyxd_urls: Option<Vec<url::Url>>,
|
nyxd_urls: Option<Vec<url::Url>>,
|
||||||
|
|
||||||
/// Comma separated list of rest endpoints of the API validators
|
/// Comma separated list of rest endpoints of the API validators
|
||||||
@@ -47,10 +47,6 @@ pub(crate) struct Init {
|
|||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
port: Option<u16>,
|
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
|
/// Mostly debug-related option to increase default traffic rate so that you would not need to
|
||||||
/// modify config post init
|
/// modify config post init
|
||||||
#[clap(long, hide = true)]
|
#[clap(long, hide = true)]
|
||||||
@@ -62,7 +58,8 @@ pub(crate) struct Init {
|
|||||||
|
|
||||||
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||||
/// with bandwidth credential requirement.
|
/// with bandwidth credential requirement.
|
||||||
#[clap(long, hide = true)]
|
#[cfg(feature = "coconut")]
|
||||||
|
#[clap(long)]
|
||||||
enabled_credentials_mode: Option<bool>,
|
enabled_credentials_mode: Option<bool>,
|
||||||
|
|
||||||
/// Save a summary of the initialization to a json file
|
/// Save a summary of the initialization to a json file
|
||||||
@@ -76,11 +73,12 @@ impl From<Init> for OverrideConfig {
|
|||||||
nym_apis: init_config.nym_apis,
|
nym_apis: init_config.nym_apis,
|
||||||
disable_socket: init_config.disable_socket,
|
disable_socket: init_config.disable_socket,
|
||||||
port: init_config.port,
|
port: init_config.port,
|
||||||
host: init_config.host,
|
|
||||||
fastmode: init_config.fastmode,
|
fastmode: init_config.fastmode,
|
||||||
no_cover: init_config.no_cover,
|
no_cover: init_config.no_cover,
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
nyxd_urls: init_config.nyxd_urls,
|
nyxd_urls: init_config.nyxd_urls,
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
enabled_credentials_mode: init_config.enabled_credentials_mode,
|
enabled_credentials_mode: init_config.enabled_credentials_mode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,7 +112,7 @@ pub(crate) async fn execute(args: &Init) -> Result<(), ClientError> {
|
|||||||
|
|
||||||
let id = &args.id;
|
let id = &args.id;
|
||||||
|
|
||||||
let already_init = Config::default_config_file_path(id).exists();
|
let already_init = Config::default_config_file_path(Some(id)).exists();
|
||||||
if already_init {
|
if already_init {
|
||||||
println!("Client \"{id}\" was already initialised before");
|
println!("Client \"{id}\" was already initialised before");
|
||||||
}
|
}
|
||||||
@@ -147,7 +145,7 @@ pub(crate) async fn execute(args: &Init) -> Result<(), ClientError> {
|
|||||||
.await
|
.await
|
||||||
.tap_err(|err| eprintln!("Failed to setup gateway\nError: {err}"))?;
|
.tap_err(|err| eprintln!("Failed to setup gateway\nError: {err}"))?;
|
||||||
|
|
||||||
config.get_base_mut().set_gateway_endpoint(gateway);
|
config.get_base_mut().with_gateway_endpoint(gateway);
|
||||||
|
|
||||||
config.save_to_file(None).tap_err(|_| {
|
config.save_to_file(None).tap_err(|_| {
|
||||||
log::error!("Failed to save the config file");
|
log::error!("Failed to save the config file");
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use completions::{fig_generate, ArgShell};
|
|||||||
use config::OptionalSet;
|
use config::OptionalSet;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::net::IpAddr;
|
|
||||||
|
|
||||||
pub(crate) mod init;
|
pub(crate) mod init;
|
||||||
pub(crate) mod run;
|
pub(crate) mod run;
|
||||||
@@ -57,10 +56,12 @@ pub(crate) struct OverrideConfig {
|
|||||||
nym_apis: Option<Vec<url::Url>>,
|
nym_apis: Option<Vec<url::Url>>,
|
||||||
disable_socket: Option<bool>,
|
disable_socket: Option<bool>,
|
||||||
port: Option<u16>,
|
port: Option<u16>,
|
||||||
host: Option<IpAddr>,
|
|
||||||
fastmode: bool,
|
fastmode: bool,
|
||||||
no_cover: bool,
|
no_cover: bool,
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
nyxd_urls: Option<Vec<url::Url>>,
|
nyxd_urls: Option<Vec<url::Url>>,
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
enabled_credentials_mode: Option<bool>,
|
enabled_credentials_mode: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,29 +78,35 @@ pub(crate) async fn execute(args: &Cli) -> Result<(), Box<dyn Error + Send + Syn
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config {
|
pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Config {
|
||||||
config
|
config = config
|
||||||
.with_optional(Config::with_disabled_socket, args.disable_socket)
|
.with_optional(Config::with_disabled_socket, args.disable_socket)
|
||||||
.with_base(BaseConfig::with_high_default_traffic_volume, args.fastmode)
|
.with_base(BaseConfig::with_high_default_traffic_volume, args.fastmode)
|
||||||
.with_base(BaseConfig::with_disabled_cover_traffic, args.no_cover)
|
.with_base(BaseConfig::with_disabled_cover_traffic, args.no_cover)
|
||||||
.with_optional(Config::with_port, args.port)
|
.with_optional(Config::with_port, args.port)
|
||||||
.with_optional(Config::with_host, args.host)
|
|
||||||
.with_optional_custom_env_ext(
|
.with_optional_custom_env_ext(
|
||||||
BaseConfig::with_custom_nym_apis,
|
BaseConfig::with_custom_nym_apis,
|
||||||
args.nym_apis,
|
args.nym_apis,
|
||||||
network_defaults::var_names::NYM_API,
|
network_defaults::var_names::NYM_API,
|
||||||
config::parse_urls,
|
config::parse_urls,
|
||||||
)
|
);
|
||||||
.with_optional_custom_env_ext(
|
|
||||||
BaseConfig::with_custom_nyxd,
|
#[cfg(feature = "coconut")]
|
||||||
args.nyxd_urls,
|
{
|
||||||
network_defaults::var_names::NYXD,
|
config = config
|
||||||
config::parse_urls,
|
.with_optional_custom_env_ext(
|
||||||
)
|
BaseConfig::with_custom_nyxd,
|
||||||
.with_optional_ext(
|
args.nyxd_urls,
|
||||||
BaseConfig::with_disabled_credentials,
|
network_defaults::var_names::NYXD,
|
||||||
args.enabled_credentials_mode.map(|b| !b),
|
config::parse_urls,
|
||||||
)
|
)
|
||||||
|
.with_optional_ext(
|
||||||
|
BaseConfig::with_disabled_credentials,
|
||||||
|
args.enabled_credentials_mode.map(|b| !b),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::net::IpAddr;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::{config::Config, SocketClient},
|
client::{config::Config, SocketClient},
|
||||||
@@ -23,7 +22,8 @@ pub(crate) struct Run {
|
|||||||
id: String,
|
id: String,
|
||||||
|
|
||||||
/// Comma separated list of rest endpoints of the nyxd validators
|
/// Comma separated list of rest endpoints of the nyxd validators
|
||||||
#[clap(long, alias = "nymd_validators", value_delimiter = ',', hide = true)]
|
#[cfg(feature = "coconut")]
|
||||||
|
#[clap(long, alias = "nymd_validators", value_delimiter = ',')]
|
||||||
nyxd_urls: Option<Vec<url::Url>>,
|
nyxd_urls: Option<Vec<url::Url>>,
|
||||||
|
|
||||||
/// Comma separated list of rest endpoints of the API validators
|
/// Comma separated list of rest endpoints of the API validators
|
||||||
@@ -44,10 +44,6 @@ pub(crate) struct Run {
|
|||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
port: Option<u16>,
|
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
|
/// Mostly debug-related option to increase default traffic rate so that you would not need to
|
||||||
/// modify config post init
|
/// modify config post init
|
||||||
#[clap(long, hide = true)]
|
#[clap(long, hide = true)]
|
||||||
@@ -59,7 +55,8 @@ pub(crate) struct Run {
|
|||||||
|
|
||||||
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||||
/// with bandwidth credential requirement.
|
/// with bandwidth credential requirement.
|
||||||
#[clap(long, hide = true)]
|
#[cfg(feature = "coconut")]
|
||||||
|
#[clap(long)]
|
||||||
enabled_credentials_mode: Option<bool>,
|
enabled_credentials_mode: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,10 +66,12 @@ impl From<Run> for OverrideConfig {
|
|||||||
nym_apis: run_config.nym_apis,
|
nym_apis: run_config.nym_apis,
|
||||||
disable_socket: run_config.disable_socket,
|
disable_socket: run_config.disable_socket,
|
||||||
port: run_config.port,
|
port: run_config.port,
|
||||||
host: run_config.host,
|
|
||||||
fastmode: run_config.fastmode,
|
fastmode: run_config.fastmode,
|
||||||
no_cover: run_config.no_cover,
|
no_cover: run_config.no_cover,
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
nyxd_urls: run_config.nyxd_urls,
|
nyxd_urls: run_config.nyxd_urls,
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
enabled_credentials_mode: run_config.enabled_credentials_mode,
|
enabled_credentials_mode: run_config.enabled_credentials_mode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +99,7 @@ fn version_check(cfg: &Config) -> bool {
|
|||||||
pub(crate) async fn execute(args: &Run) -> Result<(), Box<dyn Error + Send + Sync>> {
|
pub(crate) async fn execute(args: &Run) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||||
let id = &args.id;
|
let id = &args.id;
|
||||||
|
|
||||||
let mut config = match Config::load_from_file(id) {
|
let mut config = match Config::load_from_file(Some(id)) {
|
||||||
Ok(cfg) => cfg,
|
Ok(cfg) => cfg,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Failed to load config for {}. Are you sure you have run `init` before? (Error was: {err})", id);
|
error!("Failed to load config for {}. Are you sure you have run `init` before? (Error was: {err})", id);
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ pub(crate) fn execute(args: &Upgrade) {
|
|||||||
|
|
||||||
let id = &args.id;
|
let id = &args.id;
|
||||||
|
|
||||||
let existing_config = Config::load_from_file(id).unwrap_or_else(|err| {
|
let existing_config = Config::load_from_file(Some(id)).unwrap_or_else(|err| {
|
||||||
eprintln!("failed to load existing config file! - {err}");
|
eprintln!("failed to load existing config file! - {err}");
|
||||||
process::exit(1)
|
process::exit(1)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
use super::handler::HandlerBuilder;
|
use super::handler::HandlerBuilder;
|
||||||
use log::*;
|
use log::*;
|
||||||
use std::net::IpAddr;
|
|
||||||
use std::{net::SocketAddr, process, sync::Arc};
|
use std::{net::SocketAddr, process, sync::Arc};
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
use tokio::{sync::Notify, task::JoinHandle};
|
use tokio::{sync::Notify, task::JoinHandle};
|
||||||
@@ -25,9 +24,10 @@ pub(crate) struct Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Listener {
|
impl Listener {
|
||||||
pub(crate) fn new(host: IpAddr, port: u16) -> Self {
|
pub(crate) fn new(port: u16) -> Self {
|
||||||
Listener {
|
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,
|
state: State::AwaitingConnection,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nym-socks5-client"
|
name = "nym-socks5-client"
|
||||||
version = "1.1.8"
|
version = "1.1.5"
|
||||||
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>"]
|
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>"]
|
||||||
description = "A SOCKS5 localhost proxy that converts incoming messages to Sphinx and sends them to a Nym address"
|
description = "A SOCKS5 localhost proxy that converts incoming messages to Sphinx and sends them to a Nym address"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -19,8 +19,8 @@ log = { workspace = true }
|
|||||||
pin-project = "1.0"
|
pin-project = "1.0"
|
||||||
pretty_env_logger = "0.4"
|
pretty_env_logger = "0.4"
|
||||||
rand = { version = "0.7.3", features = ["wasm-bindgen"] }
|
rand = { version = "0.7.3", features = ["wasm-bindgen"] }
|
||||||
serde = { workspace = true, features = ["derive"] } # for config serialization/deserialization
|
serde = { version = "1.0", features = ["derive"] } # for config serialization/deserialization
|
||||||
serde_json = { workspace = true }
|
serde_json = "1.0.89"
|
||||||
tap = "1.0.1"
|
tap = "1.0.1"
|
||||||
thiserror = "1.0.34"
|
thiserror = "1.0.34"
|
||||||
tokio = { version = "1.24.1", features = ["rt-multi-thread", "net", "signal"] }
|
tokio = { version = "1.24.1", features = ["rt-multi-thread", "net", "signal"] }
|
||||||
@@ -30,12 +30,11 @@ url = "2.2"
|
|||||||
build-information = { path = "../../common/build-information" }
|
build-information = { path = "../../common/build-information" }
|
||||||
client-core = { path = "../client-core", features = ["fs-surb-storage"] }
|
client-core = { path = "../client-core", features = ["fs-surb-storage"] }
|
||||||
client-connections = { path = "../../common/client-connections" }
|
client-connections = { path = "../../common/client-connections" }
|
||||||
coconut-interface = { path = "../../common/coconut-interface" }
|
coconut-interface = { path = "../../common/coconut-interface", optional = true }
|
||||||
config = { path = "../../common/config" }
|
config = { path = "../../common/config" }
|
||||||
completions = { path = "../../common/completions" }
|
completions = { path = "../../common/completions" }
|
||||||
credential-storage = { path = "../../common/credential-storage", optional = true }
|
credential-storage = { path = "../../common/credential-storage" }
|
||||||
mobile-storage = { path = "../../common/mobile-storage", optional = true }
|
credentials = { path = "../../common/credentials", optional = true }
|
||||||
credentials = { path = "../../common/credentials" }
|
|
||||||
crypto = { path = "../../common/crypto" }
|
crypto = { path = "../../common/crypto" }
|
||||||
logging = { path = "../../common/logging"}
|
logging = { path = "../../common/logging"}
|
||||||
gateway-client = { path = "../../common/client-libs/gateway-client" }
|
gateway-client = { path = "../../common/client-libs/gateway-client" }
|
||||||
@@ -45,7 +44,6 @@ nymsphinx = { path = "../../common/nymsphinx" }
|
|||||||
ordered-buffer = { path = "../../common/socks5/ordered-buffer" }
|
ordered-buffer = { path = "../../common/socks5/ordered-buffer" }
|
||||||
pemstore = { path = "../../common/pemstore" }
|
pemstore = { path = "../../common/pemstore" }
|
||||||
proxy-helpers = { path = "../../common/socks5/proxy-helpers" }
|
proxy-helpers = { path = "../../common/socks5/proxy-helpers" }
|
||||||
service-providers-common = { path = "../../service-providers/common" }
|
|
||||||
socks5-requests = { path = "../../common/socks5/requests" }
|
socks5-requests = { path = "../../common/socks5/requests" }
|
||||||
task = { path = "../../common/task" }
|
task = { path = "../../common/task" }
|
||||||
topology = { path = "../../common/topology" }
|
topology = { path = "../../common/topology" }
|
||||||
@@ -53,6 +51,5 @@ validator-client = { path = "../../common/client-libs/validator-client", feature
|
|||||||
version-checker = { path = "../../common/version-checker" }
|
version-checker = { path = "../../common/version-checker" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["credential-storage"]
|
coconut = ["coconut-interface", "credentials", "gateway-requests/coconut", "gateway-client/coconut", "credentials/coconut", "client-core/coconut"]
|
||||||
eth = []
|
eth = []
|
||||||
mobile = ["mobile-storage", "gateway-client/mobile"]
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021-2023 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::config::template::config_template;
|
use crate::client::config::template::config_template;
|
||||||
@@ -9,8 +9,6 @@ use config::defaults::DEFAULT_SOCKS5_LISTENING_PORT;
|
|||||||
use config::{NymConfig, OptionalSet};
|
use config::{NymConfig, OptionalSet};
|
||||||
use nymsphinx::addressing::clients::Recipient;
|
use nymsphinx::addressing::clients::Recipient;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use service_providers_common::interface::ProviderInterfaceVersion;
|
|
||||||
use socks5_requests::Socks5ProtocolVersion;
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@@ -20,7 +18,7 @@ mod template;
|
|||||||
const DEFAULT_CONNECTION_START_SURBS: u32 = 20;
|
const DEFAULT_CONNECTION_START_SURBS: u32 = 20;
|
||||||
const DEFAULT_PER_REQUEST_SURBS: u32 = 3;
|
const DEFAULT_PER_REQUEST_SURBS: u32 = 3;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
|
#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
@@ -38,12 +36,10 @@ impl NymConfig for Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn default_root_directory() -> PathBuf {
|
fn default_root_directory() -> PathBuf {
|
||||||
#[cfg(not(feature = "mobile"))]
|
dirs::home_dir()
|
||||||
let base_dir = dirs::home_dir().expect("Failed to evaluate $HOME value");
|
.expect("Failed to evaluate $HOME value")
|
||||||
#[cfg(feature = "mobile")]
|
.join(".nym")
|
||||||
let base_dir = PathBuf::from("/tmp");
|
.join("socks5-clients")
|
||||||
|
|
||||||
base_dir.join(".nym").join("socks5-clients")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_default_root_directory() -> Option<PathBuf> {
|
fn try_default_root_directory() -> Option<PathBuf> {
|
||||||
@@ -92,16 +88,6 @@ impl Config {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_provider_interface_version(mut self, version: ProviderInterfaceVersion) -> Self {
|
|
||||||
self.socks5.provider_interface_version = version;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_socks5_protocol_version(mut self, version: Socks5ProtocolVersion) -> Self {
|
|
||||||
self.socks5.socks5_protocol_version = version;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_anonymous_replies(mut self, anonymous_replies: bool) -> Self {
|
pub fn with_anonymous_replies(mut self, anonymous_replies: bool) -> Self {
|
||||||
self.socks5.send_anonymously = anonymous_replies;
|
self.socks5.send_anonymously = anonymous_replies;
|
||||||
self
|
self
|
||||||
@@ -129,14 +115,6 @@ impl Config {
|
|||||||
.expect("malformed provider address")
|
.expect("malformed provider address")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_provider_interface_version(&self) -> ProviderInterfaceVersion {
|
|
||||||
self.socks5.provider_interface_version
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_socks5_protocol_version(&self) -> Socks5ProtocolVersion {
|
|
||||||
self.socks5.socks5_protocol_version
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_send_anonymously(&self) -> bool {
|
pub fn get_send_anonymously(&self) -> bool {
|
||||||
self.socks5.send_anonymously
|
self.socks5.send_anonymously
|
||||||
}
|
}
|
||||||
@@ -198,7 +176,7 @@ impl Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Socks5 {
|
pub struct Socks5 {
|
||||||
/// The port on which the client will be listening for incoming requests
|
/// The port on which the client will be listening for incoming requests
|
||||||
@@ -207,15 +185,6 @@ pub struct Socks5 {
|
|||||||
/// The mix address of the provider to which all requests are going to be sent.
|
/// The mix address of the provider to which all requests are going to be sent.
|
||||||
provider_mix_address: String,
|
provider_mix_address: String,
|
||||||
|
|
||||||
/// The version of the 'service provider' this client is going to use in its communication with the
|
|
||||||
/// specified socks5 provider.
|
|
||||||
// if in doubt, use the legacy version as initially nobody will be using the updated binaries
|
|
||||||
#[serde(default = "ProviderInterfaceVersion::new_legacy")]
|
|
||||||
provider_interface_version: ProviderInterfaceVersion,
|
|
||||||
|
|
||||||
#[serde(default = "Socks5ProtocolVersion::new_legacy")]
|
|
||||||
socks5_protocol_version: Socks5ProtocolVersion,
|
|
||||||
|
|
||||||
/// Specifies whether this client is going to use an anonymous sender tag for communication with the service provider.
|
/// Specifies whether this client is going to use an anonymous sender tag for communication with the service provider.
|
||||||
/// While this is going to hide its actual address information, it will make the actual communication
|
/// While this is going to hide its actual address information, it will make the actual communication
|
||||||
/// slower and consume nearly double the bandwidth as it will require sending reply SURBs.
|
/// slower and consume nearly double the bandwidth as it will require sending reply SURBs.
|
||||||
@@ -230,8 +199,6 @@ impl Socks5 {
|
|||||||
Socks5 {
|
Socks5 {
|
||||||
listening_port: DEFAULT_SOCKS5_LISTENING_PORT,
|
listening_port: DEFAULT_SOCKS5_LISTENING_PORT,
|
||||||
provider_mix_address: provider_mix_address.into(),
|
provider_mix_address: provider_mix_address.into(),
|
||||||
provider_interface_version: ProviderInterfaceVersion::Legacy,
|
|
||||||
socks5_protocol_version: Socks5ProtocolVersion::Legacy,
|
|
||||||
send_anonymously: false,
|
send_anonymously: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,14 +209,12 @@ impl Default for Socks5 {
|
|||||||
Socks5 {
|
Socks5 {
|
||||||
listening_port: DEFAULT_SOCKS5_LISTENING_PORT,
|
listening_port: DEFAULT_SOCKS5_LISTENING_PORT,
|
||||||
provider_mix_address: "".into(),
|
provider_mix_address: "".into(),
|
||||||
provider_interface_version: ProviderInterfaceVersion::Legacy,
|
|
||||||
socks5_protocol_version: Socks5ProtocolVersion::Legacy,
|
|
||||||
send_anonymously: false,
|
send_anonymously: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Socks5Debug {
|
pub struct Socks5Debug {
|
||||||
/// Number of reply SURBs attached to each `Request::Connect` message.
|
/// Number of reply SURBs attached to each `Request::Connect` message.
|
||||||
|
|||||||
@@ -8,17 +8,13 @@ use crate::socks::{
|
|||||||
authentication::{AuthenticationMethods, Authenticator, User},
|
authentication::{AuthenticationMethods, Authenticator, User},
|
||||||
server::SphinxSocksServer,
|
server::SphinxSocksServer,
|
||||||
};
|
};
|
||||||
|
use client_core::client::base_client::{
|
||||||
#[cfg(feature = "mobile")]
|
non_wasm_helpers, BaseClientBuilder, ClientInput, ClientOutput, ClientState,
|
||||||
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::key_manager::KeyManager;
|
use client_core::client::key_manager::KeyManager;
|
||||||
use client_core::config::persistence::key_pathfinder::ClientKeyPathfinder;
|
use client_core::config::persistence::key_pathfinder::ClientKeyPathfinder;
|
||||||
use futures::channel::mpsc;
|
use futures::channel::mpsc;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
#[cfg(not(feature = "mobile"))]
|
|
||||||
use gateway_client::bandwidth::BandwidthController;
|
use gateway_client::bandwidth::BandwidthController;
|
||||||
use log::*;
|
use log::*;
|
||||||
use nymsphinx::addressing::clients::Recipient;
|
use nymsphinx::addressing::clients::Recipient;
|
||||||
@@ -58,19 +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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "mobile"))]
|
|
||||||
async fn create_bandwidth_controller(config: &Config) -> BandwidthController<QueryNyxdClient> {
|
async fn create_bandwidth_controller(config: &Config) -> BandwidthController<QueryNyxdClient> {
|
||||||
let details = network_defaults::NymNetworkDetails::new_from_env();
|
let details = network_defaults::NymNetworkDetails::new_from_env();
|
||||||
let mut client_config = validator_client::Config::try_from_nym_network_details(&details)
|
let mut client_config = validator_client::Config::try_from_nym_network_details(&details)
|
||||||
@@ -89,15 +72,10 @@ impl NymClient {
|
|||||||
client_config = client_config.with_urls(nyxd_url, api_url);
|
client_config = client_config.with_urls(nyxd_url, api_url);
|
||||||
let client = validator_client::Client::new_query(client_config)
|
let client = validator_client::Client::new_query(client_config)
|
||||||
.expect("Could not construct query client");
|
.expect("Could not construct query client");
|
||||||
|
BandwidthController::new(
|
||||||
#[cfg(not(feature = "mobile"))]
|
credential_storage::initialise_storage(config.get_base().get_database_path()).await,
|
||||||
let storage =
|
client,
|
||||||
credential_storage::initialise_storage(config.get_base().get_database_path()).await;
|
)
|
||||||
|
|
||||||
#[cfg(feature = "mobile")]
|
|
||||||
let storage = mobile_storage::PersistentStorage {};
|
|
||||||
|
|
||||||
BandwidthController::new(storage, client)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_socks5_listener(
|
fn start_socks5_listener(
|
||||||
@@ -134,8 +112,6 @@ impl NymClient {
|
|||||||
self_address,
|
self_address,
|
||||||
shared_lane_queue_lengths,
|
shared_lane_queue_lengths,
|
||||||
socks::client::Config::new(
|
socks::client::Config::new(
|
||||||
config.get_provider_interface_version(),
|
|
||||||
config.get_socks5_protocol_version(),
|
|
||||||
config.get_send_anonymously(),
|
config.get_send_anonymously(),
|
||||||
config.get_connection_start_surbs(),
|
config.get_connection_start_surbs(),
|
||||||
config.get_per_request_surbs(),
|
config.get_per_request_surbs(),
|
||||||
@@ -212,7 +188,6 @@ impl NymClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn start(self) -> Result<TaskManager, Socks5ClientError> {
|
pub async fn start(self) -> Result<TaskManager, Socks5ClientError> {
|
||||||
#[cfg(not(feature = "mobile"))]
|
|
||||||
let base_builder = BaseClientBuilder::new_from_base_config(
|
let base_builder = BaseClientBuilder::new_from_base_config(
|
||||||
self.config.get_base(),
|
self.config.get_base(),
|
||||||
self.key_manager,
|
self.key_manager,
|
||||||
@@ -224,14 +199,6 @@ impl NymClient {
|
|||||||
.await?,
|
.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 self_address = base_builder.as_mix_recipient();
|
||||||
let mut started_client = base_builder.start_base().await?;
|
let mut started_client = base_builder.start_base().await?;
|
||||||
let client_input = started_client.client_input.register_producer();
|
let client_input = started_client.client_input.register_producer();
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ pub(crate) struct Init {
|
|||||||
force_register_gateway: bool,
|
force_register_gateway: bool,
|
||||||
|
|
||||||
/// Comma separated list of rest endpoints of the nyxd validators
|
/// Comma separated list of rest endpoints of the nyxd validators
|
||||||
#[clap(long, alias = "nymd_validators", value_delimiter = ',', hide = true)]
|
#[cfg(feature = "coconut")]
|
||||||
|
#[clap(long, alias = "nymd_validators", value_delimiter = ',')]
|
||||||
nyxd_urls: Option<Vec<url::Url>>,
|
nyxd_urls: Option<Vec<url::Url>>,
|
||||||
|
|
||||||
/// Comma separated list of rest endpoints of the API validators
|
/// Comma separated list of rest endpoints of the API validators
|
||||||
@@ -66,7 +67,8 @@ pub(crate) struct Init {
|
|||||||
|
|
||||||
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||||
/// with bandwidth credential requirement.
|
/// with bandwidth credential requirement.
|
||||||
#[clap(long, hide = true)]
|
#[cfg(feature = "coconut")]
|
||||||
|
#[clap(long)]
|
||||||
enabled_credentials_mode: Option<bool>,
|
enabled_credentials_mode: Option<bool>,
|
||||||
|
|
||||||
/// Save a summary of the initialization to a json file
|
/// Save a summary of the initialization to a json file
|
||||||
@@ -82,7 +84,10 @@ impl From<Init> for OverrideConfig {
|
|||||||
use_anonymous_replies: init_config.use_reply_surbs,
|
use_anonymous_replies: init_config.use_reply_surbs,
|
||||||
fastmode: init_config.fastmode,
|
fastmode: init_config.fastmode,
|
||||||
no_cover: init_config.no_cover,
|
no_cover: init_config.no_cover,
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
nyxd_urls: init_config.nyxd_urls,
|
nyxd_urls: init_config.nyxd_urls,
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
enabled_credentials_mode: init_config.enabled_credentials_mode,
|
enabled_credentials_mode: init_config.enabled_credentials_mode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +122,7 @@ pub(crate) async fn execute(args: &Init) -> Result<(), Socks5ClientError> {
|
|||||||
let id = &args.id;
|
let id = &args.id;
|
||||||
let provider_address = &args.provider;
|
let provider_address = &args.provider;
|
||||||
|
|
||||||
let already_init = Config::default_config_file_path(id).exists();
|
let already_init = Config::default_config_file_path(Some(id)).exists();
|
||||||
if already_init {
|
if already_init {
|
||||||
println!("SOCKS5 client \"{id}\" was already initialised before");
|
println!("SOCKS5 client \"{id}\" was already initialised before");
|
||||||
}
|
}
|
||||||
@@ -153,9 +158,7 @@ pub(crate) async fn execute(args: &Init) -> Result<(), Socks5ClientError> {
|
|||||||
.await
|
.await
|
||||||
.tap_err(|err| eprintln!("Failed to setup gateway\nError: {err}"))?;
|
.tap_err(|err| eprintln!("Failed to setup gateway\nError: {err}"))?;
|
||||||
|
|
||||||
config.get_base_mut().set_gateway_endpoint(gateway);
|
config.get_base_mut().with_gateway_endpoint(gateway);
|
||||||
|
|
||||||
// TODO: ask the service provider we specified for its interface version and set it in the config
|
|
||||||
|
|
||||||
config.save_to_file(None).tap_err(|_| {
|
config.save_to_file(None).tap_err(|_| {
|
||||||
log::error!("Failed to save the config file");
|
log::error!("Failed to save the config file");
|
||||||
|
|||||||
@@ -60,7 +60,10 @@ pub(crate) struct OverrideConfig {
|
|||||||
use_anonymous_replies: Option<bool>,
|
use_anonymous_replies: Option<bool>,
|
||||||
fastmode: bool,
|
fastmode: bool,
|
||||||
no_cover: bool,
|
no_cover: bool,
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
nyxd_urls: Option<Vec<url::Url>>,
|
nyxd_urls: Option<Vec<url::Url>>,
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
enabled_credentials_mode: Option<bool>,
|
enabled_credentials_mode: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +80,8 @@ pub(crate) async fn execute(args: &Cli) -> Result<(), Box<dyn Error + Send + Syn
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn override_config(config: Config, args: OverrideConfig) -> Config {
|
pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Config {
|
||||||
config
|
config = config
|
||||||
.with_base(BaseConfig::with_high_default_traffic_volume, args.fastmode)
|
.with_base(BaseConfig::with_high_default_traffic_volume, args.fastmode)
|
||||||
.with_base(BaseConfig::with_disabled_cover_traffic, args.no_cover)
|
.with_base(BaseConfig::with_disabled_cover_traffic, args.no_cover)
|
||||||
.with_optional(Config::with_anonymous_replies, args.use_anonymous_replies)
|
.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,
|
args.nym_apis,
|
||||||
network_defaults::var_names::NYM_API,
|
network_defaults::var_names::NYM_API,
|
||||||
config::parse_urls,
|
config::parse_urls,
|
||||||
)
|
);
|
||||||
.with_optional_custom_env_ext(
|
|
||||||
BaseConfig::with_custom_nyxd,
|
#[cfg(feature = "coconut")]
|
||||||
args.nyxd_urls,
|
{
|
||||||
network_defaults::var_names::NYXD,
|
config = config
|
||||||
config::parse_urls,
|
.with_optional_custom_env_ext(
|
||||||
)
|
BaseConfig::with_custom_nyxd,
|
||||||
.with_optional_ext(
|
args.nyxd_urls,
|
||||||
BaseConfig::with_disabled_credentials,
|
network_defaults::var_names::NYXD,
|
||||||
args.enabled_credentials_mode.map(|b| !b),
|
config::parse_urls,
|
||||||
)
|
)
|
||||||
|
.with_optional_ext(
|
||||||
|
BaseConfig::with_disabled_credentials,
|
||||||
|
args.enabled_credentials_mode.map(|b| !b),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ pub(crate) struct Run {
|
|||||||
gateway: Option<identity::PublicKey>,
|
gateway: Option<identity::PublicKey>,
|
||||||
|
|
||||||
/// Comma separated list of rest endpoints of the nyxd validators
|
/// Comma separated list of rest endpoints of the nyxd validators
|
||||||
#[clap(long, alias = "nymd_validators", value_delimiter = ',', hide = true)]
|
#[cfg(feature = "coconut")]
|
||||||
|
#[clap(long, alias = "nymd_validators", value_delimiter = ',')]
|
||||||
nyxd_urls: Option<Vec<url::Url>>,
|
nyxd_urls: Option<Vec<url::Url>>,
|
||||||
|
|
||||||
/// Comma separated list of rest endpoints of the Nym APIs
|
/// Comma separated list of rest endpoints of the Nym APIs
|
||||||
@@ -65,7 +66,8 @@ pub(crate) struct Run {
|
|||||||
|
|
||||||
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||||
/// with bandwidth credential requirement.
|
/// with bandwidth credential requirement.
|
||||||
#[clap(long, hide = true)]
|
#[cfg(feature = "coconut")]
|
||||||
|
#[clap(long)]
|
||||||
enabled_credentials_mode: Option<bool>,
|
enabled_credentials_mode: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +79,10 @@ impl From<Run> for OverrideConfig {
|
|||||||
use_anonymous_replies: run_config.use_anonymous_replies,
|
use_anonymous_replies: run_config.use_anonymous_replies,
|
||||||
fastmode: run_config.fastmode,
|
fastmode: run_config.fastmode,
|
||||||
no_cover: run_config.no_cover,
|
no_cover: run_config.no_cover,
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
nyxd_urls: run_config.nyxd_urls,
|
nyxd_urls: run_config.nyxd_urls,
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
enabled_credentials_mode: run_config.enabled_credentials_mode,
|
enabled_credentials_mode: run_config.enabled_credentials_mode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +113,7 @@ fn version_check(cfg: &Config) -> bool {
|
|||||||
pub(crate) async fn execute(args: &Run) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
pub(crate) async fn execute(args: &Run) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
let id = &args.id;
|
let id = &args.id;
|
||||||
|
|
||||||
let mut config = match Config::load_from_file(id) {
|
let mut config = match Config::load_from_file(Some(id)) {
|
||||||
Ok(cfg) => cfg,
|
Ok(cfg) => cfg,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Failed to load config for {}. Are you sure you have run `init` before? (Error was: {err})", id);
|
error!("Failed to load config for {}. Are you sure you have run `init` before? (Error was: {err})", id);
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ pub(crate) fn execute(args: &Upgrade) {
|
|||||||
|
|
||||||
let id = &args.id;
|
let id = &args.id;
|
||||||
|
|
||||||
let existing_config = Config::load_from_file(id).unwrap_or_else(|err| {
|
let existing_config = Config::load_from_file(Some(id)).unwrap_or_else(|err| {
|
||||||
eprintln!("failed to load existing config file! - {err}");
|
eprintln!("failed to load existing config file! - {err}");
|
||||||
process::exit(1)
|
process::exit(1)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::socks::types::SocksProxyError;
|
use crate::socks::types::SocksProxyError;
|
||||||
use client_core::error::ClientCoreError;
|
use client_core::error::ClientCoreError;
|
||||||
use socks5_requests::{ConnectionError, ConnectionId};
|
use socks5_requests::ConnectionId;
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum Socks5ClientError {
|
pub enum Socks5ClientError {
|
||||||
@@ -28,12 +28,3 @@ pub enum Socks5ClientError {
|
|||||||
error: String,
|
error: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ConnectionError> for Socks5ClientError {
|
|
||||||
fn from(value: ConnectionError) -> Self {
|
|
||||||
Socks5ClientError::NetworkRequesterError {
|
|
||||||
connection_id: value.connection_id,
|
|
||||||
error: value.network_requester_error,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ use proxy_helpers::connection_controller::{
|
|||||||
};
|
};
|
||||||
use proxy_helpers::proxy_runner::ProxyRunner;
|
use proxy_helpers::proxy_runner::ProxyRunner;
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use service_providers_common::interface::{ProviderInterfaceVersion, RequestVersion};
|
use socks5_requests::{ConnectionId, Message, RemoteAddress, Request};
|
||||||
use socks5_requests::{
|
|
||||||
ConnectionId, RemoteAddress, Socks5ProtocolVersion, Socks5ProviderRequest, Socks5Request,
|
|
||||||
};
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
@@ -131,8 +128,6 @@ impl AsyncWrite for StreamState {
|
|||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub(crate) struct Config {
|
pub(crate) struct Config {
|
||||||
provider_interface_version: ProviderInterfaceVersion,
|
|
||||||
socks5_protocol_version: Socks5ProtocolVersion,
|
|
||||||
use_surbs_for_responses: bool,
|
use_surbs_for_responses: bool,
|
||||||
connection_start_surbs: u32,
|
connection_start_surbs: u32,
|
||||||
per_request_surbs: u32,
|
per_request_surbs: u32,
|
||||||
@@ -140,27 +135,16 @@ pub(crate) struct Config {
|
|||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
provider_interface_version: ProviderInterfaceVersion,
|
|
||||||
socks5_protocol_version: Socks5ProtocolVersion,
|
|
||||||
use_surbs_for_responses: bool,
|
use_surbs_for_responses: bool,
|
||||||
connection_start_surbs: u32,
|
connection_start_surbs: u32,
|
||||||
per_request_surbs: u32,
|
per_request_surbs: u32,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
provider_interface_version,
|
|
||||||
socks5_protocol_version,
|
|
||||||
use_surbs_for_responses,
|
use_surbs_for_responses,
|
||||||
connection_start_surbs,
|
connection_start_surbs,
|
||||||
per_request_surbs,
|
per_request_surbs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_version(&self) -> RequestVersion<Socks5Request> {
|
|
||||||
RequestVersion {
|
|
||||||
provider_interface: self.provider_interface_version,
|
|
||||||
provider_protocol: self.socks5_protocol_version,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A client connecting to the Socks proxy server, because
|
/// A client connecting to the Socks proxy server, because
|
||||||
@@ -189,9 +173,7 @@ impl Drop for SocksClient {
|
|||||||
// if we never managed to start a proxy, the entry will not exist in the controller
|
// if we never managed to start a proxy, the entry will not exist in the controller
|
||||||
if self.started_proxy {
|
if self.started_proxy {
|
||||||
self.controller_sender
|
self.controller_sender
|
||||||
.unbounded_send(ControllerCommand::Remove {
|
.unbounded_send(ControllerCommand::Remove(self.connection_id))
|
||||||
connection_id: self.connection_id,
|
|
||||||
})
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,26 +248,19 @@ impl SocksClient {
|
|||||||
|
|
||||||
// Send an error back to the client
|
// Send an error back to the client
|
||||||
pub async fn send_error_v4(&mut self, r: ResponseCodeV4) -> Result<(), SocksProxyError> {
|
pub async fn send_error_v4(&mut self, r: ResponseCodeV4) -> Result<(), SocksProxyError> {
|
||||||
self.stream
|
self.stream.write_all(&[SOCKS4_VERSION, r as u8]).await?;
|
||||||
.write_all(&[SOCKS4_VERSION, r as u8])
|
Ok(())
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketWriteError { source })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_error_v5(&mut self, r: ResponseCodeV5) -> Result<(), SocksProxyError> {
|
pub async fn send_error_v5(&mut self, r: ResponseCodeV5) -> Result<(), SocksProxyError> {
|
||||||
self.stream
|
self.stream.write_all(&[SOCKS5_VERSION, r as u8]).await?;
|
||||||
.write_all(&[SOCKS5_VERSION, r as u8])
|
Ok(())
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketWriteError { source })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shutdown the `TcpStream` to the client and end the session
|
/// Shutdown the `TcpStream` to the client and end the session
|
||||||
pub async fn shutdown(&mut self) -> Result<(), SocksProxyError> {
|
pub async fn shutdown(&mut self) -> Result<(), SocksProxyError> {
|
||||||
info!("client is shutting down its TCP stream");
|
info!("client is shutting down its TCP stream");
|
||||||
self.stream
|
self.stream.shutdown().await?;
|
||||||
.shutdown()
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketShutdownFailure { source })?;
|
|
||||||
self.shutdown_listener.mark_as_success();
|
self.shutdown_listener.mark_as_success();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -293,20 +268,11 @@ impl SocksClient {
|
|||||||
/// Initializes the new client, checking that the correct Socks version (5)
|
/// Initializes the new client, checking that the correct Socks version (5)
|
||||||
/// is in use and that the client is authenticated, then runs the request.
|
/// is in use and that the client is authenticated, then runs the request.
|
||||||
pub async fn run(&mut self) -> Result<(), SocksProxyError> {
|
pub async fn run(&mut self) -> Result<(), SocksProxyError> {
|
||||||
debug!(
|
debug!("New connection from: {}", self.stream.peer_addr()?.ip());
|
||||||
"New connection from: {}",
|
|
||||||
self.stream
|
|
||||||
.peer_addr()
|
|
||||||
.map_err(|source| SocksProxyError::PeerAddrExtractionFailure { source })?
|
|
||||||
.ip()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Read a byte from the stream and determine the version being requested
|
// Read a byte from the stream and determine the version being requested
|
||||||
let mut header = [0u8];
|
let mut header = [0u8];
|
||||||
self.stream
|
self.stream.read_exact(&mut header).await?;
|
||||||
.read_exact(&mut header)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
|
|
||||||
self.socks_version = match SocksVersion::try_from(header[0]) {
|
self.socks_version = match SocksVersion::try_from(header[0]) {
|
||||||
Ok(version) => Some(version),
|
Ok(version) => Some(version),
|
||||||
@@ -318,10 +284,7 @@ impl SocksClient {
|
|||||||
|
|
||||||
if self.socks_version == Some(SocksVersion::V5) {
|
if self.socks_version == Some(SocksVersion::V5) {
|
||||||
let mut auth = [0u8];
|
let mut auth = [0u8];
|
||||||
self.stream
|
self.stream.read_exact(&mut auth).await?;
|
||||||
.read_exact(&mut auth)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
self.auth_nmethods = auth[0];
|
self.auth_nmethods = auth[0];
|
||||||
self.authenticate_socks5().await?;
|
self.authenticate_socks5().await?;
|
||||||
}
|
}
|
||||||
@@ -330,15 +293,8 @@ impl SocksClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn send_anonymous_connect_to_mixnet(&mut self, remote_address: RemoteAddress) {
|
async fn send_anonymous_connect_to_mixnet(&mut self, remote_address: RemoteAddress) {
|
||||||
// TODO: simplify by using `request_version`
|
let req = Request::new_connect(self.connection_id, remote_address, None);
|
||||||
let req = Socks5Request::new_connect(
|
let msg = Message::Request(req);
|
||||||
self.config.socks5_protocol_version,
|
|
||||||
self.connection_id,
|
|
||||||
remote_address,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
let msg =
|
|
||||||
Socks5ProviderRequest::new_provider_data(self.config.provider_interface_version, req);
|
|
||||||
|
|
||||||
let input_message = InputMessage::new_anonymous(
|
let input_message = InputMessage::new_anonymous(
|
||||||
self.service_provider,
|
self.service_provider,
|
||||||
@@ -353,15 +309,8 @@ impl SocksClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn send_connect_to_mixnet_with_return_address(&mut self, remote_address: RemoteAddress) {
|
async fn send_connect_to_mixnet_with_return_address(&mut self, remote_address: RemoteAddress) {
|
||||||
// TODO: simplify by using `request_version`
|
let req = Request::new_connect(self.connection_id, remote_address, Some(self.self_address));
|
||||||
let req = Socks5Request::new_connect(
|
let msg = Message::Request(req);
|
||||||
self.config.socks5_protocol_version,
|
|
||||||
self.connection_id,
|
|
||||||
remote_address,
|
|
||||||
Some(self.self_address),
|
|
||||||
);
|
|
||||||
let msg =
|
|
||||||
Socks5ProviderRequest::new_provider_data(self.config.provider_interface_version, req);
|
|
||||||
|
|
||||||
let input_message = InputMessage::new_regular(
|
let input_message = InputMessage::new_regular(
|
||||||
self.service_provider,
|
self.service_provider,
|
||||||
@@ -401,7 +350,6 @@ impl SocksClient {
|
|||||||
let input_sender = self.input_sender.clone();
|
let input_sender = self.input_sender.clone();
|
||||||
let anonymous = self.config.use_surbs_for_responses;
|
let anonymous = self.config.use_surbs_for_responses;
|
||||||
let per_request_surbs = self.config.per_request_surbs;
|
let per_request_surbs = self.config.per_request_surbs;
|
||||||
let request_version = self.config.request_version();
|
|
||||||
|
|
||||||
let recipient = self.service_provider;
|
let recipient = self.service_provider;
|
||||||
let (stream, _) = ProxyRunner::new(
|
let (stream, _) = ProxyRunner::new(
|
||||||
@@ -415,16 +363,8 @@ impl SocksClient {
|
|||||||
self.shutdown_listener.clone(),
|
self.shutdown_listener.clone(),
|
||||||
)
|
)
|
||||||
.run(move |conn_id, read_data, socket_closed| {
|
.run(move |conn_id, read_data, socket_closed| {
|
||||||
let provider_request = Socks5Request::new_send(
|
let provider_request = Request::new_send(conn_id, read_data, socket_closed);
|
||||||
request_version.provider_protocol,
|
let provider_message = Message::Request(provider_request);
|
||||||
conn_id,
|
|
||||||
read_data,
|
|
||||||
socket_closed,
|
|
||||||
);
|
|
||||||
let provider_message = Socks5ProviderRequest::new_provider_data(
|
|
||||||
request_version.provider_interface,
|
|
||||||
provider_request,
|
|
||||||
);
|
|
||||||
let lane = TransmissionLane::ConnectionId(conn_id);
|
let lane = TransmissionLane::ConnectionId(conn_id);
|
||||||
if anonymous {
|
if anonymous {
|
||||||
InputMessage::new_anonymous(
|
InputMessage::new_anonymous(
|
||||||
@@ -473,10 +413,7 @@ impl SocksClient {
|
|||||||
|
|
||||||
self.started_proxy = true;
|
self.started_proxy = true;
|
||||||
self.controller_sender
|
self.controller_sender
|
||||||
.unbounded_send(ControllerCommand::Insert {
|
.unbounded_send(ControllerCommand::Insert(self.connection_id, mix_sender))
|
||||||
connection_id: self.connection_id,
|
|
||||||
connection_sender: mix_sender,
|
|
||||||
})
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
@@ -554,13 +491,7 @@ impl SocksClient {
|
|||||||
/// into the Authenticator (where it'll be more easily testable)
|
/// into the Authenticator (where it'll be more easily testable)
|
||||||
/// would be a good next step.
|
/// would be a good next step.
|
||||||
async fn authenticate_socks5(&mut self) -> Result<(), SocksProxyError> {
|
async fn authenticate_socks5(&mut self) -> Result<(), SocksProxyError> {
|
||||||
debug!(
|
debug!("Authenticating w/ {}", self.stream.peer_addr()?.ip());
|
||||||
"Authenticating w/ {}",
|
|
||||||
self.stream
|
|
||||||
.peer_addr()
|
|
||||||
.map_err(|source| SocksProxyError::PeerAddrExtractionFailure { source })?
|
|
||||||
.ip()
|
|
||||||
);
|
|
||||||
// Get valid auth methods
|
// Get valid auth methods
|
||||||
let methods = self.get_available_methods().await?;
|
let methods = self.get_available_methods().await?;
|
||||||
trace!("methods: {:?}", methods);
|
trace!("methods: {:?}", methods);
|
||||||
@@ -574,45 +505,27 @@ impl SocksClient {
|
|||||||
response[1] = AuthenticationMethods::UserPass as u8;
|
response[1] = AuthenticationMethods::UserPass as u8;
|
||||||
|
|
||||||
debug!("Sending USER/PASS packet");
|
debug!("Sending USER/PASS packet");
|
||||||
self.stream
|
self.stream.write_all(&response).await?;
|
||||||
.write_all(&response)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketWriteError { source })?;
|
|
||||||
|
|
||||||
let mut header = [0u8; 2];
|
let mut header = [0u8; 2];
|
||||||
|
|
||||||
// Read a byte from the stream and determine the version being requested
|
// Read a byte from the stream and determine the version being requested
|
||||||
self.stream
|
self.stream.read_exact(&mut header).await?;
|
||||||
.read_exact(&mut header)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
|
|
||||||
// debug!("Auth Header: [{}, {}]", header[0], header[1]);
|
// debug!("Auth Header: [{}, {}]", header[0], header[1]);
|
||||||
|
|
||||||
// Username parsing
|
// Username parsing
|
||||||
let ulen = header[1];
|
let ulen = header[1];
|
||||||
let mut username = vec![0; ulen as usize];
|
let mut username = vec![0; ulen as usize];
|
||||||
self.stream
|
self.stream.read_exact(&mut username).await?;
|
||||||
.read_exact(&mut username)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
|
|
||||||
// Password Parsing
|
// Password Parsing
|
||||||
let plen = self
|
let plen = self.stream.read_u8().await?;
|
||||||
.stream
|
|
||||||
.read_u8()
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
let mut password = vec![0; plen as usize];
|
let mut password = vec![0; plen as usize];
|
||||||
self.stream
|
self.stream.read_exact(&mut password).await?;
|
||||||
.read_exact(&mut password)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
|
|
||||||
let username_str = String::from_utf8(username)
|
let username_str = String::from_utf8(username)?;
|
||||||
.map_err(|source| SocksProxyError::MalformedAuthUsername { source })?;
|
let password_str = String::from_utf8(password)?;
|
||||||
let password_str = String::from_utf8(password)
|
|
||||||
.map_err(|source| SocksProxyError::MalformedAuthPassword { source })?;
|
|
||||||
|
|
||||||
let user = User {
|
let user = User {
|
||||||
username: username_str,
|
username: username_str,
|
||||||
@@ -623,17 +536,11 @@ impl SocksClient {
|
|||||||
if self.authenticator.is_allowed(&user) {
|
if self.authenticator.is_allowed(&user) {
|
||||||
debug!("Access Granted. User: {}", user.username);
|
debug!("Access Granted. User: {}", user.username);
|
||||||
let response = [1, ResponseCodeV5::Success as u8];
|
let response = [1, ResponseCodeV5::Success as u8];
|
||||||
self.stream
|
self.stream.write_all(&response).await?;
|
||||||
.write_all(&response)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketWriteError { source })?;
|
|
||||||
} else {
|
} else {
|
||||||
debug!("Access Denied. User: {}", user.username);
|
debug!("Access Denied. User: {}", user.username);
|
||||||
let response = [1, ResponseCodeV5::Failure as u8];
|
let response = [1, ResponseCodeV5::Failure as u8];
|
||||||
self.stream
|
self.stream.write_all(&response).await?;
|
||||||
.write_all(&response)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketWriteError { source })?;
|
|
||||||
|
|
||||||
// Shutdown
|
// Shutdown
|
||||||
self.shutdown().await?;
|
self.shutdown().await?;
|
||||||
@@ -644,18 +551,12 @@ impl SocksClient {
|
|||||||
// set the default auth method (no auth)
|
// set the default auth method (no auth)
|
||||||
response[1] = AuthenticationMethods::NoAuth as u8;
|
response[1] = AuthenticationMethods::NoAuth as u8;
|
||||||
debug!("Sending NOAUTH packet");
|
debug!("Sending NOAUTH packet");
|
||||||
self.stream
|
self.stream.write_all(&response).await?;
|
||||||
.write_all(&response)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketWriteError { source })?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
warn!("Client has no suitable authentication methods!");
|
warn!("Client has no suitable authentication methods!");
|
||||||
response[1] = AuthenticationMethods::NoMethods as u8;
|
response[1] = AuthenticationMethods::NoMethods as u8;
|
||||||
self.stream
|
self.stream.write_all(&response).await?;
|
||||||
.write_all(&response)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketWriteError { source })?;
|
|
||||||
self.shutdown().await?;
|
self.shutdown().await?;
|
||||||
Err(ResponseCodeV5::Failure.into())
|
Err(ResponseCodeV5::Failure.into())
|
||||||
}
|
}
|
||||||
@@ -666,10 +567,7 @@ impl SocksClient {
|
|||||||
let mut methods: Vec<u8> = Vec::with_capacity(self.auth_nmethods as usize);
|
let mut methods: Vec<u8> = Vec::with_capacity(self.auth_nmethods as usize);
|
||||||
for _ in 0..self.auth_nmethods {
|
for _ in 0..self.auth_nmethods {
|
||||||
let mut method = [0u8; 1];
|
let mut method = [0u8; 1];
|
||||||
self.stream
|
self.stream.read_exact(&mut method).await?;
|
||||||
.read_exact(&mut method)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
if self.authenticator.auth_methods.contains(&method[0]) {
|
if self.authenticator.auth_methods.contains(&method[0]) {
|
||||||
methods.append(&mut method.to_vec());
|
methods.append(&mut method.to_vec());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ use log::*;
|
|||||||
use client_core::client::received_buffer::ReconstructedMessagesReceiver;
|
use client_core::client::received_buffer::ReconstructedMessagesReceiver;
|
||||||
use client_core::client::received_buffer::{ReceivedBufferMessage, ReceivedBufferRequestSender};
|
use client_core::client::received_buffer::{ReceivedBufferMessage, ReceivedBufferRequestSender};
|
||||||
use nymsphinx::receiver::ReconstructedMessage;
|
use nymsphinx::receiver::ReconstructedMessage;
|
||||||
use proxy_helpers::connection_controller::ControllerSender;
|
use proxy_helpers::connection_controller::{ControllerCommand, ControllerSender};
|
||||||
use service_providers_common::interface::{ControlResponse, ResponseContent};
|
use socks5_requests::Message;
|
||||||
use socks5_requests::{Socks5ProviderResponse, Socks5Response, Socks5ResponseContent};
|
|
||||||
use task::TaskClient;
|
use task::TaskClient;
|
||||||
|
|
||||||
use crate::error::Socks5ClientError;
|
use crate::error::Socks5ClientError;
|
||||||
@@ -53,39 +52,6 @@ impl MixnetResponseListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_control_response(
|
|
||||||
&self,
|
|
||||||
control_response: ControlResponse,
|
|
||||||
) -> Result<(), Socks5ClientError> {
|
|
||||||
error!("received a control response which we don't know how to handle yet!");
|
|
||||||
error!("got: {:?}", control_response);
|
|
||||||
|
|
||||||
// I guess we'd need another channel here to forward those to where they need to go
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_provider_data_response(
|
|
||||||
&self,
|
|
||||||
provider_response: Socks5Response,
|
|
||||||
) -> Result<(), Socks5ClientError> {
|
|
||||||
match provider_response.content {
|
|
||||||
Socks5ResponseContent::ConnectionError(err_response) => {
|
|
||||||
error!(
|
|
||||||
"Network requester failed on connection id {} with error: {}",
|
|
||||||
err_response.connection_id, err_response.network_requester_error
|
|
||||||
);
|
|
||||||
Err(err_response.into())
|
|
||||||
}
|
|
||||||
Socks5ResponseContent::NetworkData(response) => {
|
|
||||||
self.controller_sender
|
|
||||||
.unbounded_send(response.into())
|
|
||||||
.unwrap();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_message(
|
fn on_message(
|
||||||
&self,
|
&self,
|
||||||
reconstructed_message: ReconstructedMessage,
|
reconstructed_message: ReconstructedMessage,
|
||||||
@@ -94,28 +60,38 @@ impl MixnetResponseListener {
|
|||||||
if reconstructed_message.sender_tag.is_some() {
|
if reconstructed_message.sender_tag.is_some() {
|
||||||
warn!("this message was sent anonymously - it couldn't have come from the service provider");
|
warn!("this message was sent anonymously - it couldn't have come from the service provider");
|
||||||
}
|
}
|
||||||
match Socks5ProviderResponse::try_from_bytes(&raw_message) {
|
|
||||||
|
let response = match Message::try_from_bytes(&raw_message) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!("failed to parse received response: {err}");
|
warn!("failed to parse received response - {err}");
|
||||||
Ok(())
|
return Ok(());
|
||||||
}
|
}
|
||||||
Ok(response) => {
|
Ok(Message::Request(_)) => {
|
||||||
// as long as the client used the same (or older) interface than the service provider,
|
warn!("unexpected request");
|
||||||
// the response should have used exactly the same version
|
return Ok(());
|
||||||
trace!(
|
}
|
||||||
"the received response was sent with {:?} interface version",
|
Ok(Message::Response(data)) => data,
|
||||||
response.interface_version
|
Ok(Message::NetworkRequesterResponse(r)) => {
|
||||||
|
error!(
|
||||||
|
"Network requester failed on connection id {} with error: {}",
|
||||||
|
r.connection_id, r.network_requester_error
|
||||||
);
|
);
|
||||||
match response.content {
|
return Err(Socks5ClientError::NetworkRequesterError {
|
||||||
ResponseContent::Control(control_response) => {
|
connection_id: r.connection_id,
|
||||||
self.on_control_response(control_response)
|
error: r.network_requester_error,
|
||||||
}
|
});
|
||||||
ResponseContent::ProviderData(provider_response) => {
|
|
||||||
self.on_provider_data_response(provider_response)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
self.controller_sender
|
||||||
|
.unbounded_send(ControllerCommand::Send(
|
||||||
|
response.connection_id,
|
||||||
|
response.data,
|
||||||
|
response.is_closed,
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn run(&mut self) {
|
pub(crate) async fn run(&mut self) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ impl TryFrom<u8> for SocksVersion {
|
|||||||
match version {
|
match version {
|
||||||
SOCKS4_VERSION => Ok(Self::V4),
|
SOCKS4_VERSION => Ok(Self::V4),
|
||||||
SOCKS5_VERSION => Ok(Self::V5),
|
SOCKS5_VERSION => Ok(Self::V5),
|
||||||
_ => Err(SocksProxyError::UnsupportedProxyVersion { version }),
|
_ => Err(SocksProxyError::UnsupportedProxyVersion(version)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,7 @@ impl SocksRequest {
|
|||||||
log::trace!("read from stream socks4");
|
log::trace!("read from stream socks4");
|
||||||
|
|
||||||
let mut packet = [0u8; 3];
|
let mut packet = [0u8; 3];
|
||||||
stream
|
stream.read_exact(&mut packet).await?;
|
||||||
.read_exact(&mut packet)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
|
|
||||||
// CD (command)
|
// CD (command)
|
||||||
let Some(command) = SocksCommand::from(packet[0] as usize) else {
|
let Some(command) = SocksCommand::from(packet[0] as usize) else {
|
||||||
@@ -46,10 +43,7 @@ impl SocksRequest {
|
|||||||
|
|
||||||
// DSTIP
|
// DSTIP
|
||||||
let mut ip = [0u8; 4];
|
let mut ip = [0u8; 4];
|
||||||
stream
|
stream.read_exact(&mut ip).await?;
|
||||||
.read_exact(&mut ip)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
|
|
||||||
// USERID
|
// USERID
|
||||||
let _userid = read_until_zero(stream).await;
|
let _userid = read_until_zero(stream).await;
|
||||||
@@ -82,17 +76,12 @@ impl SocksRequest {
|
|||||||
|
|
||||||
let mut packet = [0u8; 4];
|
let mut packet = [0u8; 4];
|
||||||
// Read a byte from the stream and determine the version being requested
|
// Read a byte from the stream and determine the version being requested
|
||||||
stream
|
stream.read_exact(&mut packet).await?;
|
||||||
.read_exact(&mut packet)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
|
|
||||||
// VER
|
// VER
|
||||||
if packet[0] != SOCKS5_VERSION {
|
if packet[0] != SOCKS5_VERSION {
|
||||||
warn!("Unsupported version: SOCKS{}", packet[0]);
|
warn!("Unsupported version: SOCKS{}", packet[0]);
|
||||||
return Err(SocksProxyError::UnsupportedProxyVersion {
|
return Err(SocksProxyError::UnsupportedProxyVersion(packet[0]));
|
||||||
version: (packet[0]),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CMD
|
// CMD
|
||||||
@@ -114,41 +103,26 @@ impl SocksRequest {
|
|||||||
let addr = match addr_type {
|
let addr = match addr_type {
|
||||||
AddrType::Domain => {
|
AddrType::Domain => {
|
||||||
let mut domain_length = [0u8];
|
let mut domain_length = [0u8];
|
||||||
stream
|
stream.read_exact(&mut domain_length).await?;
|
||||||
.read_exact(&mut domain_length)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
let mut domain = vec![0u8; domain_length[0] as usize];
|
let mut domain = vec![0u8; domain_length[0] as usize];
|
||||||
stream
|
stream.read_exact(&mut domain).await?;
|
||||||
.read_exact(&mut domain)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
domain
|
domain
|
||||||
}
|
}
|
||||||
AddrType::V4 => {
|
AddrType::V4 => {
|
||||||
let mut addr = [0u8; 4];
|
let mut addr = [0u8; 4];
|
||||||
stream
|
stream.read_exact(&mut addr).await?;
|
||||||
.read_exact(&mut addr)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
addr.to_vec()
|
addr.to_vec()
|
||||||
}
|
}
|
||||||
AddrType::V6 => {
|
AddrType::V6 => {
|
||||||
let mut addr = [0u8; 16];
|
let mut addr = [0u8; 16];
|
||||||
stream
|
stream.read_exact(&mut addr).await?;
|
||||||
.read_exact(&mut addr)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
addr.to_vec()
|
addr.to_vec()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// DST.PORT
|
// DST.PORT
|
||||||
let mut port = [0u8; 2];
|
let mut port = [0u8; 2];
|
||||||
stream
|
stream.read_exact(&mut port).await?;
|
||||||
.read_exact(&mut port)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
let port = merge_u8_into_u16(port[0], port[1]);
|
let port = merge_u8_into_u16(port[0], port[1]);
|
||||||
|
|
||||||
Ok(SocksRequest {
|
Ok(SocksRequest {
|
||||||
@@ -205,10 +179,7 @@ where
|
|||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
let mut char = [0u8];
|
let mut char = [0u8];
|
||||||
loop {
|
loop {
|
||||||
stream
|
stream.read_exact(&mut char).await?;
|
||||||
.read_exact(&mut char)
|
|
||||||
.await
|
|
||||||
.map_err(|source| SocksProxyError::SocketReadError { source })?;
|
|
||||||
if char[0] == 0 {
|
if char[0] == 0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,11 +86,6 @@ impl SphinxSocksServer {
|
|||||||
mixnet_response_listener.run().await;
|
mixnet_response_listener.run().await;
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO:, if required, there should be another task here responsible for control requests.
|
|
||||||
// it should get `input_sender` to send actual requests into the mixnet
|
|
||||||
// and some channel that connects it from `MixnetResponseListener` to receive
|
|
||||||
// any control responses
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
Ok((stream, _remote)) = listener.accept() => {
|
Ok((stream, _remote)) = listener.accept() => {
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
use socks5_requests::Socks5RequestError;
|
|
||||||
use std::string::FromUtf8Error;
|
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
/// SOCKS4 Response codes
|
/// SOCKS4 Response codes
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) enum ResponseCodeV4 {
|
pub(crate) enum ResponseCodeV4 {
|
||||||
@@ -12,8 +8,9 @@ pub(crate) enum ResponseCodeV4 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Possible SOCKS5 Response Codes
|
/// Possible SOCKS5 Response Codes
|
||||||
#[derive(Debug, Error)]
|
#[allow(dead_code)]
|
||||||
pub enum ResponseCodeV5 {
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
pub(crate) enum ResponseCodeV5 {
|
||||||
#[error("SOCKS5 Server Success")]
|
#[error("SOCKS5 Server Success")]
|
||||||
Success = 0x00,
|
Success = 0x00,
|
||||||
#[error("SOCKS5 Server Failure")]
|
#[error("SOCKS5 Server Failure")]
|
||||||
@@ -34,55 +31,30 @@ pub enum ResponseCodeV5 {
|
|||||||
AddrTypeNotSupported = 0x08,
|
AddrTypeNotSupported = 0x08,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Debug)]
|
||||||
pub enum SocksProxyError {
|
pub enum SocksProxyError {
|
||||||
#[error("{version} of the socks protocol is not supported by this client")]
|
GenericError(Box<dyn std::error::Error + Send + Sync>),
|
||||||
UnsupportedProxyVersion { version: u8 },
|
UnsupportedProxyVersion(u8),
|
||||||
|
}
|
||||||
|
|
||||||
#[error("failed to write to the socket: {source}")]
|
impl std::fmt::Display for SocksProxyError {
|
||||||
SocketWriteError {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
#[source]
|
match self {
|
||||||
source: std::io::Error,
|
SocksProxyError::GenericError(err) => write!(f, "GenericError - {err}"),
|
||||||
},
|
SocksProxyError::UnsupportedProxyVersion(version) => {
|
||||||
|
write!(f, "Unsupported proxy version {}", version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[error("failed to read from the socket: {source}")]
|
impl<E> From<E> for SocksProxyError
|
||||||
SocketReadError {
|
where
|
||||||
#[source]
|
E: std::error::Error + Send + Sync + 'static,
|
||||||
source: std::io::Error,
|
{
|
||||||
},
|
fn from(err: E) -> Self {
|
||||||
|
SocksProxyError::GenericError(Box::new(err))
|
||||||
#[error("failed to shutdown underlying socket stream: {source}")]
|
}
|
||||||
SocketShutdownFailure {
|
|
||||||
#[source]
|
|
||||||
source: std::io::Error,
|
|
||||||
},
|
|
||||||
|
|
||||||
#[error("failed to extract ip address of the connected peer: {source}")]
|
|
||||||
PeerAddrExtractionFailure {
|
|
||||||
#[source]
|
|
||||||
source: std::io::Error,
|
|
||||||
},
|
|
||||||
|
|
||||||
#[error("failed to authenticate user due to malformed username: {source}")]
|
|
||||||
MalformedAuthUsername {
|
|
||||||
#[source]
|
|
||||||
source: FromUtf8Error,
|
|
||||||
},
|
|
||||||
|
|
||||||
#[error("failed to authenticate user due to malformed password: {source}")]
|
|
||||||
MalformedAuthPassword {
|
|
||||||
#[source]
|
|
||||||
source: FromUtf8Error,
|
|
||||||
},
|
|
||||||
|
|
||||||
#[error(transparent)]
|
|
||||||
Socks5ResponseFailure(#[from] ResponseCodeV5),
|
|
||||||
|
|
||||||
#[error("could not complete the provider request: {source}")]
|
|
||||||
ProviderRequestFailure {
|
|
||||||
#[from]
|
|
||||||
source: Socks5RequestError,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DST.addr variant types
|
/// DST.addr variant types
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ crate-type = ["cdylib", "rlib"]
|
|||||||
[features]
|
[features]
|
||||||
default = ["console_error_panic_hook"]
|
default = ["console_error_panic_hook"]
|
||||||
offline-test = []
|
offline-test = []
|
||||||
|
coconut = ["coconut-interface", "credentials", "gateway-client/coconut"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
@@ -32,12 +33,12 @@ wasm-bindgen-futures = "0.4"
|
|||||||
# internal
|
# internal
|
||||||
client-core = { path = "../client-core", default-features = false, features = ["wasm"] }
|
client-core = { path = "../client-core", default-features = false, features = ["wasm"] }
|
||||||
client-connections = { path = "../../common/client-connections" }
|
client-connections = { path = "../../common/client-connections" }
|
||||||
coconut-interface = { path = "../../common/coconut-interface" }
|
coconut-interface = { path = "../../common/coconut-interface", optional = true }
|
||||||
credentials = { path = "../../common/credentials" }
|
credentials = { path = "../../common/credentials", optional = true }
|
||||||
crypto = { path = "../../common/crypto" }
|
crypto = { path = "../../common/crypto" }
|
||||||
nymsphinx = { path = "../../common/nymsphinx" }
|
nymsphinx = { path = "../../common/nymsphinx" }
|
||||||
topology = { path = "../../common/topology" }
|
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 }
|
validator-client = { path = "../../common/client-libs/validator-client", default-features = false }
|
||||||
wasm-utils = { path = "../../common/wasm-utils" }
|
wasm-utils = { path = "../../common/wasm-utils" }
|
||||||
task = { path = "../../common/task" }
|
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
|
/// 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.
|
/// for more even though in theory they wouldn't need to.
|
||||||
pub maximum_reply_surb_rerequest_waiting_period_ms: u64,
|
pub maximum_reply_surb_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,
|
|
||||||
|
|
||||||
/// Defines maximum amount of time given reply surb is going to be valid for.
|
/// 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.
|
/// 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,
|
minimum_reply_surb_request_size: debug.minimum_reply_surb_request_size,
|
||||||
maximum_reply_surb_request_size: debug.maximum_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_allowed_reply_surb_request_size: debug.maximum_allowed_reply_surb_request_size,
|
||||||
maximum_reply_surb_rerequest_waiting_period: Duration::from_millis(
|
maximum_reply_surb_waiting_period: Duration::from_millis(
|
||||||
debug.maximum_reply_surb_rerequest_waiting_period_ms,
|
debug.maximum_reply_surb_waiting_period_ms,
|
||||||
),
|
|
||||||
maximum_reply_surb_drop_waiting_period: Duration::from_millis(
|
|
||||||
debug.maximum_reply_surb_drop_waiting_period_ms,
|
|
||||||
),
|
),
|
||||||
maximum_reply_surb_age: Duration::from_millis(debug.maximum_reply_surb_age_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),
|
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,
|
minimum_reply_surb_request_size: debug.minimum_reply_surb_request_size,
|
||||||
maximum_reply_surb_request_size: debug.maximum_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_allowed_reply_surb_request_size: debug.maximum_allowed_reply_surb_request_size,
|
||||||
maximum_reply_surb_rerequest_waiting_period_ms: debug
|
maximum_reply_surb_waiting_period_ms: debug
|
||||||
.maximum_reply_surb_rerequest_waiting_period
|
.maximum_reply_surb_waiting_period
|
||||||
.as_millis() as u64,
|
|
||||||
maximum_reply_surb_drop_waiting_period_ms: debug
|
|
||||||
.maximum_reply_surb_drop_waiting_period
|
|
||||||
.as_millis() as u64,
|
.as_millis() as u64,
|
||||||
maximum_reply_surb_age_ms: debug.maximum_reply_surb_age.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,
|
maximum_reply_key_age_ms: debug.maximum_reply_key_age.as_millis() as u64,
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { workspace = true, features = ["derive"], optional = true }
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
vergen = { version = "7", default-features = false, features = ["build", "git", "rustc", "cargo"] }
|
vergen = { version = "7", default-features = false, features = ["build", "git", "rustc", "cargo"] }
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
// TODO: at a later date this crate should probably also expose `ContractBuildInformation`
|
// TODO: at a later date this crate should probably also expose `ContractBuildInformation`
|
||||||
// and be used by our smart contracts
|
// and be used by our smart contracts
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct BinaryBuildInformation {
|
pub struct BinaryBuildInformation {
|
||||||
// VERGEN_BUILD_TIMESTAMP
|
// VERGEN_BUILD_TIMESTAMP
|
||||||
/// Provides the build timestamp, for example `2021-02-23T20:14:46.558472672+00:00`.
|
/// Provides the build timestamp, for example `2021-02-23T20:14:46.558472672+00:00`.
|
||||||
@@ -54,19 +53,6 @@ impl BinaryBuildInformation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_owned(&self) -> BinaryBuildInformationOwned {
|
|
||||||
BinaryBuildInformationOwned {
|
|
||||||
build_timestamp: self.build_timestamp.to_owned(),
|
|
||||||
build_version: self.build_version.to_owned(),
|
|
||||||
commit_sha: self.commit_sha.to_owned(),
|
|
||||||
commit_timestamp: self.commit_timestamp.to_owned(),
|
|
||||||
commit_branch: self.commit_branch.to_owned(),
|
|
||||||
rustc_version: self.rustc_version.to_owned(),
|
|
||||||
rustc_channel: self.rustc_channel.to_owned(),
|
|
||||||
cargo_profile: self.cargo_profile.to_owned(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn pretty_print(&self) -> String {
|
pub fn pretty_print(&self) -> String {
|
||||||
format!(
|
format!(
|
||||||
r#"
|
r#"
|
||||||
@@ -98,39 +84,3 @@ impl BinaryBuildInformation {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
||||||
pub struct BinaryBuildInformationOwned {
|
|
||||||
// VERGEN_BUILD_TIMESTAMP
|
|
||||||
/// Provides the build timestamp, for example `2021-02-23T20:14:46.558472672+00:00`.
|
|
||||||
pub build_timestamp: String,
|
|
||||||
|
|
||||||
// VERGEN_BUILD_SEMVER
|
|
||||||
/// Provides the build version, for example `0.1.0-9-g46f83e1`.
|
|
||||||
pub build_version: String,
|
|
||||||
|
|
||||||
// VERGEN_GIT_SHA
|
|
||||||
/// Provides the hash of the commit that was used for the build, for example `46f83e112520533338245862d366f6a02cef07d4`.
|
|
||||||
pub commit_sha: String,
|
|
||||||
|
|
||||||
// VERGEN_GIT_COMMIT_TIMESTAMP
|
|
||||||
/// Provides the timestamp of the commit that was used for the build, for example `2021-02-23T08:08:02-05:00`.
|
|
||||||
pub commit_timestamp: String,
|
|
||||||
|
|
||||||
// VERGEN_GIT_BRANCH
|
|
||||||
/// Provides the name of the git branch that was used for the build, for example `master`.
|
|
||||||
pub commit_branch: String,
|
|
||||||
|
|
||||||
// VERGEN_RUSTC_SEMVER
|
|
||||||
/// Provides the rustc version that was used for the build, for example `1.52.0-nightly`.
|
|
||||||
pub rustc_version: String,
|
|
||||||
|
|
||||||
// VERGEN_RUSTC_CHANNEL
|
|
||||||
/// Provides the rustc channel that was used for the build, for example `nightly`.
|
|
||||||
pub rustc_channel: String,
|
|
||||||
|
|
||||||
// VERGEN_CARGO_PROFILE
|
|
||||||
/// Provides the cargo profile that was used for the build, for example `debug`.
|
|
||||||
pub cargo_profile: String,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ async-trait = { version = "0.1.51" }
|
|||||||
tokio = { version = "1.24.1", features = ["macros"] }
|
tokio = { version = "1.24.1", features = ["macros"] }
|
||||||
|
|
||||||
# internal
|
# internal
|
||||||
coconut-interface = { path = "../../coconut-interface" }
|
coconut-interface = { path = "../../coconut-interface", optional = true }
|
||||||
credentials = { path = "../../credentials" }
|
credentials = { path = "../../credentials" }
|
||||||
crypto = { path = "../../crypto" }
|
crypto = { path = "../../crypto" }
|
||||||
gateway-requests = { path = "../../../gateway/gateway-requests" }
|
gateway-requests = { path = "../../../gateway/gateway-requests" }
|
||||||
@@ -28,7 +28,6 @@ pemstore = { path = "../../pemstore" }
|
|||||||
validator-client = { path = "../validator-client" }
|
validator-client = { path = "../validator-client" }
|
||||||
task = { path = "../../task" }
|
task = { path = "../../task" }
|
||||||
serde = { version = "1.0", features = ["derive"]}
|
serde = { version = "1.0", features = ["derive"]}
|
||||||
mobile-storage = { path = "../../mobile-storage" }
|
|
||||||
|
|
||||||
|
|
||||||
[dependencies.tungstenite]
|
[dependencies.tungstenite]
|
||||||
@@ -80,5 +79,5 @@ features = ["js"]
|
|||||||
#url = "2.1"
|
#url = "2.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
coconut = ["gateway-requests/coconut", "coconut-interface", "credentials/coconut"]
|
||||||
wasm = []
|
wasm = []
|
||||||
mobile = []
|
|
||||||
|
|||||||
@@ -1,34 +1,27 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
use crate::error::GatewayClientError;
|
use crate::error::GatewayClientError;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use crate::wasm_mockups::Storage;
|
use crate::wasm_mockups::Storage;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[cfg(not(feature = "mobile"))]
|
|
||||||
use credential_storage::storage::Storage;
|
use credential_storage::storage::Storage;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(all(target_arch = "wasm32", feature = "coconut"))]
|
||||||
#[cfg(feature = "mobile")]
|
|
||||||
use mobile_storage::Storage;
|
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
#[cfg(feature = "mobile")]
|
|
||||||
use mobile_storage::StorageError;
|
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
use crate::wasm_mockups::StorageError;
|
use crate::wasm_mockups::StorageError;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(all(not(target_arch = "wasm32"), feature = "coconut"))]
|
||||||
#[cfg(not(feature = "mobile"))]
|
|
||||||
use credential_storage::error::StorageError;
|
use credential_storage::error::StorageError;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use crate::wasm_mockups::{Client, CosmWasmClient};
|
use crate::wasm_mockups::{Client, CosmWasmClient};
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use validator_client::{nyxd::CosmWasmClient, Client};
|
use validator_client::{nyxd::CosmWasmClient, Client};
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
use {
|
use {
|
||||||
coconut_interface::Base58,
|
coconut_interface::Base58,
|
||||||
credentials::coconut::{
|
credentials::coconut::{
|
||||||
@@ -41,13 +34,8 @@ use {
|
|||||||
use crate::wasm_mockups::PersistentStorage;
|
use crate::wasm_mockups::PersistentStorage;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[cfg(not(feature = "mobile"))]
|
|
||||||
use credential_storage::PersistentStorage;
|
use credential_storage::PersistentStorage;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
#[cfg(feature = "mobile")]
|
|
||||||
use mobile_storage::PersistentStorage;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct BandwidthController<C: Clone, St: Storage = PersistentStorage> {
|
pub struct BandwidthController<C: Clone, St: Storage = PersistentStorage> {
|
||||||
@@ -67,6 +55,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
pub async fn prepare_coconut_credential(
|
pub async fn prepare_coconut_credential(
|
||||||
&self,
|
&self,
|
||||||
) -> Result<(coconut_interface::Credential, i64), GatewayClientError> {
|
) -> Result<(coconut_interface::Credential, i64), GatewayClientError> {
|
||||||
@@ -109,6 +98,7 @@ where
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
pub async fn consume_credential(&self, id: i64) -> Result<(), GatewayClientError> {
|
pub async fn consume_credential(&self, id: i64) -> Result<(), GatewayClientError> {
|
||||||
Ok(self.storage.consume_coconut_credential(id).await?)
|
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::socket_state::{PartiallyDelegated, SocketState};
|
||||||
use crate::{cleanup_socket_message, try_decrypt_binary_message};
|
use crate::{cleanup_socket_message, try_decrypt_binary_message};
|
||||||
use coconut_interface::Credential;
|
|
||||||
use crypto::asymmetric::identity;
|
use crypto::asymmetric::identity;
|
||||||
use futures::{SinkExt, StreamExt};
|
use futures::{SinkExt, StreamExt};
|
||||||
use gateway_requests::authentication::encrypted_address::EncryptedAddressBytes;
|
use gateway_requests::authentication::encrypted_address::EncryptedAddressBytes;
|
||||||
@@ -26,19 +25,16 @@ use std::time::Duration;
|
|||||||
use task::TaskClient;
|
use task::TaskClient;
|
||||||
use tungstenite::protocol::Message;
|
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"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use tokio_tungstenite::connect_async;
|
use tokio_tungstenite::connect_async;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use validator_client::nyxd::CosmWasmClient;
|
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")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use crate::wasm_mockups::CosmWasmClient;
|
use crate::wasm_mockups::CosmWasmClient;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
@@ -57,6 +53,7 @@ pub struct GatewayClient<C: Clone> {
|
|||||||
bandwidth_remaining: i64,
|
bandwidth_remaining: i64,
|
||||||
gateway_address: String,
|
gateway_address: String,
|
||||||
gateway_identity: identity::PublicKey,
|
gateway_identity: identity::PublicKey,
|
||||||
|
gateway_owner: String,
|
||||||
local_identity: Arc<identity::KeyPair>,
|
local_identity: Arc<identity::KeyPair>,
|
||||||
shared_key: Option<Arc<SharedKeys>>,
|
shared_key: Option<Arc<SharedKeys>>,
|
||||||
connection: SocketState,
|
connection: SocketState,
|
||||||
@@ -87,6 +84,7 @@ where
|
|||||||
gateway_address: String,
|
gateway_address: String,
|
||||||
local_identity: Arc<identity::KeyPair>,
|
local_identity: Arc<identity::KeyPair>,
|
||||||
gateway_identity: identity::PublicKey,
|
gateway_identity: identity::PublicKey,
|
||||||
|
gateway_owner: String,
|
||||||
shared_key: Option<Arc<SharedKeys>>,
|
shared_key: Option<Arc<SharedKeys>>,
|
||||||
mixnet_message_sender: MixnetMessageSender,
|
mixnet_message_sender: MixnetMessageSender,
|
||||||
ack_sender: AcknowledgementSender,
|
ack_sender: AcknowledgementSender,
|
||||||
@@ -100,6 +98,7 @@ where
|
|||||||
bandwidth_remaining: 0,
|
bandwidth_remaining: 0,
|
||||||
gateway_address,
|
gateway_address,
|
||||||
gateway_identity,
|
gateway_identity,
|
||||||
|
gateway_owner,
|
||||||
local_identity,
|
local_identity,
|
||||||
shared_key,
|
shared_key,
|
||||||
connection: SocketState::NotConnected,
|
connection: SocketState::NotConnected,
|
||||||
@@ -133,6 +132,7 @@ where
|
|||||||
pub fn new_init(
|
pub fn new_init(
|
||||||
gateway_address: String,
|
gateway_address: String,
|
||||||
gateway_identity: identity::PublicKey,
|
gateway_identity: identity::PublicKey,
|
||||||
|
gateway_owner: String,
|
||||||
local_identity: Arc<identity::KeyPair>,
|
local_identity: Arc<identity::KeyPair>,
|
||||||
response_timeout_duration: Duration,
|
response_timeout_duration: Duration,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@@ -151,6 +151,7 @@ where
|
|||||||
bandwidth_remaining: 0,
|
bandwidth_remaining: 0,
|
||||||
gateway_address,
|
gateway_address,
|
||||||
gateway_identity,
|
gateway_identity,
|
||||||
|
gateway_owner,
|
||||||
local_identity,
|
local_identity,
|
||||||
shared_key: None,
|
shared_key: None,
|
||||||
connection: SocketState::NotConnected,
|
connection: SocketState::NotConnected,
|
||||||
@@ -441,7 +442,6 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
debug_assert!(self.connection.is_available());
|
debug_assert!(self.connection.is_available());
|
||||||
log::trace!("Registering gateway");
|
|
||||||
|
|
||||||
// it's fine to instantiate it here as it's only used once (during authentication or registration)
|
// it's fine to instantiate it here as it's only used once (during authentication or registration)
|
||||||
// and putting it into the GatewayClient struct would be a hassle
|
// and putting it into the GatewayClient struct would be a hassle
|
||||||
@@ -541,6 +541,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
async fn claim_coconut_bandwidth(
|
async fn claim_coconut_bandwidth(
|
||||||
&mut self,
|
&mut self,
|
||||||
credential: Credential,
|
credential: Credential,
|
||||||
@@ -590,21 +591,28 @@ where
|
|||||||
return self.try_claim_testnet_bandwidth().await;
|
return self.try_claim_testnet_bandwidth().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _gateway_owner = self.gateway_owner.clone();
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
let (credential, credential_id) = self
|
let (credential, credential_id) = self
|
||||||
.bandwidth_controller
|
.bandwidth_controller
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.prepare_coconut_credential()
|
.prepare_coconut_credential()
|
||||||
.await?;
|
.await?;
|
||||||
|
#[cfg(not(feature = "coconut"))]
|
||||||
|
return self.try_claim_testnet_bandwidth().await;
|
||||||
|
|
||||||
self.claim_coconut_bandwidth(credential).await?;
|
#[cfg(feature = "coconut")]
|
||||||
self.bandwidth_controller
|
{
|
||||||
.as_ref()
|
self.claim_coconut_bandwidth(credential).await?;
|
||||||
.unwrap()
|
self.bandwidth_controller
|
||||||
.consume_credential(credential_id)
|
.as_ref()
|
||||||
.await?;
|
.unwrap()
|
||||||
|
.consume_credential(credential_id)
|
||||||
Ok(())
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn estimate_required_bandwidth(&self, packets: &[MixPacket]) -> i64 {
|
fn estimate_required_bandwidth(&self, packets: &[MixPacket]) -> i64 {
|
||||||
|
|||||||
@@ -3,13 +3,9 @@
|
|||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use crate::wasm_mockups::StorageError;
|
use crate::wasm_mockups::StorageError;
|
||||||
#[cfg(not(feature = "mobile"))]
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use credential_storage::error::StorageError;
|
use credential_storage::error::StorageError;
|
||||||
use gateway_requests::registration::handshake::error::HandshakeError;
|
use gateway_requests::registration::handshake::error::HandshakeError;
|
||||||
#[cfg(feature = "mobile")]
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
use mobile_storage::StorageError;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tungstenite::Error as WsError;
|
use tungstenite::Error as WsError;
|
||||||
@@ -30,6 +26,7 @@ pub enum GatewayClientError {
|
|||||||
#[error("There was a credential storage error - {0}")]
|
#[error("There was a credential storage error - {0}")]
|
||||||
CredentialStorageError(#[from] StorageError),
|
CredentialStorageError(#[from] StorageError),
|
||||||
|
|
||||||
|
#[cfg(feature = "coconut")]
|
||||||
#[error("Coconut error - {0}")]
|
#[error("Coconut error - {0}")]
|
||||||
CoconutError(#[from] coconut_interface::CoconutError),
|
CoconutError(#[from] coconut_interface::CoconutError),
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ futures = "0.3"
|
|||||||
|
|
||||||
coconut-interface = { path = "../../coconut-interface" }
|
coconut-interface = { path = "../../coconut-interface" }
|
||||||
network-defaults = { path = "../../network-defaults" }
|
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
|
# required for nyxd-client
|
||||||
# at some point it might be possible to make it wasm-compatible
|
# at some point it might be possible to make it wasm-compatible
|
||||||
|
|||||||
@@ -934,6 +934,16 @@ impl NymApiClient {
|
|||||||
Ok(self.nym_api_client.blind_sign(request_body).await?)
|
Ok(self.nym_api_client.blind_sign(request_body).await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn partial_bandwidth_credential(
|
||||||
|
&self,
|
||||||
|
request_body: &str,
|
||||||
|
) -> Result<BlindedSignatureResponse, ValidatorClientError> {
|
||||||
|
Ok(self
|
||||||
|
.nym_api_client
|
||||||
|
.partial_bandwidth_credential(request_body)
|
||||||
|
.await?)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn verify_bandwidth_credential(
|
pub async fn verify_bandwidth_credential(
|
||||||
&self,
|
&self,
|
||||||
request_body: &VerifyCredentialBody,
|
request_body: &VerifyCredentialBody,
|
||||||
|
|||||||
@@ -449,6 +449,23 @@ impl Client {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn partial_bandwidth_credential(
|
||||||
|
&self,
|
||||||
|
request_body: &str,
|
||||||
|
) -> Result<BlindedSignatureResponse, NymAPIError> {
|
||||||
|
self.post_nym_api(
|
||||||
|
&[
|
||||||
|
routes::API_VERSION,
|
||||||
|
routes::COCONUT_ROUTES,
|
||||||
|
routes::BANDWIDTH,
|
||||||
|
routes::COCONUT_PARTIAL_BANDWIDTH_CREDENTIAL,
|
||||||
|
],
|
||||||
|
NO_PARAMS,
|
||||||
|
request_body,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn verify_bandwidth_credential(
|
pub async fn verify_bandwidth_credential(
|
||||||
&self,
|
&self,
|
||||||
request_body: &VerifyCredentialBody,
|
request_body: &VerifyCredentialBody,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ pub const COCONUT_ROUTES: &str = "coconut";
|
|||||||
pub const BANDWIDTH: &str = "bandwidth";
|
pub const BANDWIDTH: &str = "bandwidth";
|
||||||
|
|
||||||
pub const COCONUT_BLIND_SIGN: &str = "blind-sign";
|
pub const COCONUT_BLIND_SIGN: &str = "blind-sign";
|
||||||
|
pub const COCONUT_PARTIAL_BANDWIDTH_CREDENTIAL: &str = "partial-bandwidth-credential";
|
||||||
pub const COCONUT_VERIFY_BANDWIDTH_CREDENTIAL: &str = "verify-bandwidth-credential";
|
pub const COCONUT_VERIFY_BANDWIDTH_CREDENTIAL: &str = "verify-bandwidth-credential";
|
||||||
|
|
||||||
pub const STATUS_ROUTES: &str = "status";
|
pub const STATUS_ROUTES: &str = "status";
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use coconut_dkg_common::dealer::{
|
|||||||
DealerDetailsResponse, PagedDealerResponse, PagedDealingsResponse,
|
DealerDetailsResponse, PagedDealerResponse, PagedDealingsResponse,
|
||||||
};
|
};
|
||||||
use coconut_dkg_common::msg::QueryMsg as DkgQueryMsg;
|
use coconut_dkg_common::msg::QueryMsg as DkgQueryMsg;
|
||||||
use coconut_dkg_common::types::{Epoch, EpochId, InitialReplacementData};
|
use coconut_dkg_common::types::{Epoch, EpochId};
|
||||||
use coconut_dkg_common::verification_key::PagedVKSharesResponse;
|
use coconut_dkg_common::verification_key::PagedVKSharesResponse;
|
||||||
use cosmrs::AccountId;
|
use cosmrs::AccountId;
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@ use cosmrs::AccountId;
|
|||||||
pub trait DkgQueryClient {
|
pub trait DkgQueryClient {
|
||||||
async fn get_current_epoch(&self) -> Result<Epoch, NyxdError>;
|
async fn get_current_epoch(&self) -> Result<Epoch, NyxdError>;
|
||||||
async fn get_current_epoch_threshold(&self) -> Result<Option<u64>, NyxdError>;
|
async fn get_current_epoch_threshold(&self) -> Result<Option<u64>, NyxdError>;
|
||||||
async fn get_initial_dealers(&self) -> Result<Option<InitialReplacementData>, NyxdError>;
|
|
||||||
async fn get_dealer_details(
|
async fn get_dealer_details(
|
||||||
&self,
|
&self,
|
||||||
address: &AccountId,
|
address: &AccountId,
|
||||||
@@ -63,14 +62,6 @@ where
|
|||||||
.query_contract_smart(self.coconut_dkg_contract_address(), &request)
|
.query_contract_smart(self.coconut_dkg_contract_address(), &request)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_initial_dealers(&self) -> Result<Option<InitialReplacementData>, NyxdError> {
|
|
||||||
let request = DkgQueryMsg::GetInitialDealers {};
|
|
||||||
self.client
|
|
||||||
.query_contract_smart(self.coconut_dkg_contract_address(), &request)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_dealer_details(
|
async fn get_dealer_details(
|
||||||
&self,
|
&self,
|
||||||
address: &AccountId,
|
address: &AccountId,
|
||||||
|
|||||||
@@ -17,21 +17,18 @@ pub trait DkgSigningClient {
|
|||||||
&self,
|
&self,
|
||||||
bte_key: EncodedBTEPublicKeyWithProof,
|
bte_key: EncodedBTEPublicKeyWithProof,
|
||||||
announce_address: String,
|
announce_address: String,
|
||||||
resharing: bool,
|
|
||||||
fee: Option<Fee>,
|
fee: Option<Fee>,
|
||||||
) -> Result<ExecuteResult, NyxdError>;
|
) -> Result<ExecuteResult, NyxdError>;
|
||||||
|
|
||||||
async fn submit_dealing_bytes(
|
async fn submit_dealing_bytes(
|
||||||
&self,
|
&self,
|
||||||
commitment: ContractSafeBytes,
|
commitment: ContractSafeBytes,
|
||||||
resharing: bool,
|
|
||||||
fee: Option<Fee>,
|
fee: Option<Fee>,
|
||||||
) -> Result<ExecuteResult, NyxdError>;
|
) -> Result<ExecuteResult, NyxdError>;
|
||||||
|
|
||||||
async fn submit_verification_key_share(
|
async fn submit_verification_key_share(
|
||||||
&self,
|
&self,
|
||||||
share: VerificationKeyShare,
|
share: VerificationKeyShare,
|
||||||
resharing: bool,
|
|
||||||
fee: Option<Fee>,
|
fee: Option<Fee>,
|
||||||
) -> Result<ExecuteResult, NyxdError>;
|
) -> Result<ExecuteResult, NyxdError>;
|
||||||
}
|
}
|
||||||
@@ -60,13 +57,11 @@ where
|
|||||||
&self,
|
&self,
|
||||||
bte_key: EncodedBTEPublicKeyWithProof,
|
bte_key: EncodedBTEPublicKeyWithProof,
|
||||||
announce_address: String,
|
announce_address: String,
|
||||||
resharing: bool,
|
|
||||||
fee: Option<Fee>,
|
fee: Option<Fee>,
|
||||||
) -> Result<ExecuteResult, NyxdError> {
|
) -> Result<ExecuteResult, NyxdError> {
|
||||||
let req = DkgExecuteMsg::RegisterDealer {
|
let req = DkgExecuteMsg::RegisterDealer {
|
||||||
bte_key_with_proof: bte_key,
|
bte_key_with_proof: bte_key,
|
||||||
announce_address,
|
announce_address,
|
||||||
resharing,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.client
|
self.client
|
||||||
@@ -84,13 +79,9 @@ where
|
|||||||
async fn submit_dealing_bytes(
|
async fn submit_dealing_bytes(
|
||||||
&self,
|
&self,
|
||||||
dealing_bytes: ContractSafeBytes,
|
dealing_bytes: ContractSafeBytes,
|
||||||
resharing: bool,
|
|
||||||
fee: Option<Fee>,
|
fee: Option<Fee>,
|
||||||
) -> Result<ExecuteResult, NyxdError> {
|
) -> Result<ExecuteResult, NyxdError> {
|
||||||
let req = DkgExecuteMsg::CommitDealing {
|
let req = DkgExecuteMsg::CommitDealing { dealing_bytes };
|
||||||
dealing_bytes,
|
|
||||||
resharing,
|
|
||||||
};
|
|
||||||
|
|
||||||
self.client
|
self.client
|
||||||
.execute(
|
.execute(
|
||||||
@@ -107,10 +98,9 @@ where
|
|||||||
async fn submit_verification_key_share(
|
async fn submit_verification_key_share(
|
||||||
&self,
|
&self,
|
||||||
share: VerificationKeyShare,
|
share: VerificationKeyShare,
|
||||||
resharing: bool,
|
|
||||||
fee: Option<Fee>,
|
fee: Option<Fee>,
|
||||||
) -> Result<ExecuteResult, NyxdError> {
|
) -> Result<ExecuteResult, NyxdError> {
|
||||||
let req = DkgExecuteMsg::CommitVerificationKeyShare { share, resharing };
|
let req = DkgExecuteMsg::CommitVerificationKeyShare { share };
|
||||||
|
|
||||||
self.client
|
self.client
|
||||||
.execute(
|
.execute(
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
|
|
||||||
use coconut_bandwidth_contract_common::msg::InstantiateMsg;
|
use coconut_bandwidth_contract_common::msg::InstantiateMsg;
|
||||||
use validator_client::nyxd::AccountId;
|
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
@@ -15,7 +12,7 @@ pub struct Args {
|
|||||||
pub pool_addr: String,
|
pub pool_addr: String,
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub multisig_addr: Option<AccountId>,
|
pub multisig_addr: Option<String>,
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub mix_denom: Option<String>,
|
pub mix_denom: Option<String>,
|
||||||
@@ -27,10 +24,8 @@ pub async fn generate(args: Args) {
|
|||||||
debug!("Received arguments: {:?}", args);
|
debug!("Received arguments: {:?}", args);
|
||||||
|
|
||||||
let multisig_addr = args.multisig_addr.unwrap_or_else(|| {
|
let multisig_addr = args.multisig_addr.unwrap_or_else(|| {
|
||||||
let address = std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
||||||
.expect("Multisig address has to be set");
|
.expect("Multisig address has to be set")
|
||||||
AccountId::from_str(address.as_str())
|
|
||||||
.expect("Failed converting multisig address to AccountId")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let mix_denom = args.mix_denom.unwrap_or_else(|| {
|
let mix_denom = args.mix_denom.unwrap_or_else(|| {
|
||||||
@@ -39,7 +34,7 @@ pub async fn generate(args: Args) {
|
|||||||
|
|
||||||
let instantiate_msg = InstantiateMsg {
|
let instantiate_msg = InstantiateMsg {
|
||||||
pool_addr: args.pool_addr,
|
pool_addr: args.pool_addr,
|
||||||
multisig_addr: multisig_addr.to_string(),
|
multisig_addr,
|
||||||
mix_denom,
|
mix_denom,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use std::str::FromStr;
|
|||||||
|
|
||||||
use coconut_dkg_common::msg::InstantiateMsg;
|
use coconut_dkg_common::msg::InstantiateMsg;
|
||||||
use coconut_dkg_common::types::TimeConfiguration;
|
use coconut_dkg_common::types::TimeConfiguration;
|
||||||
use validator_client::nyxd::AccountId;
|
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
@@ -15,7 +14,7 @@ pub struct Args {
|
|||||||
pub group_addr: String,
|
pub group_addr: String,
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub multisig_addr: Option<AccountId>,
|
pub multisig_addr: Option<String>,
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub public_key_submission_time_secs: Option<u64>,
|
pub public_key_submission_time_secs: Option<u64>,
|
||||||
@@ -45,10 +44,8 @@ pub async fn generate(args: Args) {
|
|||||||
debug!("Received arguments: {:?}", args);
|
debug!("Received arguments: {:?}", args);
|
||||||
|
|
||||||
let multisig_addr = args.multisig_addr.unwrap_or_else(|| {
|
let multisig_addr = args.multisig_addr.unwrap_or_else(|| {
|
||||||
let address = std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
||||||
.expect("Multisig address has to be set");
|
.expect("Multisig address has to be set")
|
||||||
AccountId::from_str(address.as_str())
|
|
||||||
.expect("Failed converting multisig address to AccountId")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let mix_denom = args.mix_denom.unwrap_or_else(|| {
|
let mix_denom = args.mix_denom.unwrap_or_else(|| {
|
||||||
@@ -89,7 +86,7 @@ pub async fn generate(args: Args) {
|
|||||||
|
|
||||||
let instantiate_msg = InstantiateMsg {
|
let instantiate_msg = InstantiateMsg {
|
||||||
group_addr: args.group_addr,
|
group_addr: args.group_addr,
|
||||||
multisig_addr: multisig_addr.to_string(),
|
multisig_addr,
|
||||||
time_configuration: Some(time_configuration),
|
time_configuration: Some(time_configuration),
|
||||||
mix_denom,
|
mix_denom,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,17 +6,15 @@ use log::{debug, info};
|
|||||||
|
|
||||||
use cosmwasm_std::Decimal;
|
use cosmwasm_std::Decimal;
|
||||||
use mixnet_contract_common::{InitialRewardingParams, InstantiateMsg, Percent};
|
use mixnet_contract_common::{InitialRewardingParams, InstantiateMsg, Percent};
|
||||||
use std::str::FromStr;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use validator_client::nyxd::AccountId;
|
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub rewarding_validator_address: Option<AccountId>,
|
pub rewarding_validator_address: Option<String>,
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub vesting_contract_address: Option<AccountId>,
|
pub vesting_contract_address: Option<String>,
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub rewarding_denom: Option<String>,
|
pub rewarding_denom: Option<String>,
|
||||||
@@ -79,17 +77,13 @@ pub async fn generate(args: Args) {
|
|||||||
debug!("initial_rewarding_params: {:?}", initial_rewarding_params);
|
debug!("initial_rewarding_params: {:?}", initial_rewarding_params);
|
||||||
|
|
||||||
let rewarding_validator_address = args.rewarding_validator_address.unwrap_or_else(|| {
|
let rewarding_validator_address = args.rewarding_validator_address.unwrap_or_else(|| {
|
||||||
let address = std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
std::env::var(network_defaults::var_names::REWARDING_VALIDATOR_ADDRESS)
|
||||||
.expect("Rewarding validator address has to be set");
|
.expect("Rewarding validator address has to be set")
|
||||||
AccountId::from_str(address.as_str())
|
|
||||||
.expect("Failed converting rewarding validator address to AccountId")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let vesting_contract_address = args.vesting_contract_address.unwrap_or_else(|| {
|
let vesting_contract_address = args.vesting_contract_address.unwrap_or_else(|| {
|
||||||
let address = std::env::var(network_defaults::var_names::VESTING_CONTRACT_ADDRESS)
|
std::env::var(network_defaults::var_names::VESTING_CONTRACT_ADDRESS)
|
||||||
.expect("Vesting contract address has to be set");
|
.expect("Vesting contract address has to be set")
|
||||||
AccountId::from_str(address.as_str())
|
|
||||||
.expect("Failed converting vesting contract address to AccountId")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let rewarding_denom = args.rewarding_denom.unwrap_or_else(|| {
|
let rewarding_denom = args.rewarding_denom.unwrap_or_else(|| {
|
||||||
@@ -98,8 +92,8 @@ pub async fn generate(args: Args) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let instantiate_msg = InstantiateMsg {
|
let instantiate_msg = InstantiateMsg {
|
||||||
rewarding_validator_address: rewarding_validator_address.to_string(),
|
rewarding_validator_address,
|
||||||
vesting_contract_address: vesting_contract_address.to_string(),
|
vesting_contract_address,
|
||||||
rewarding_denom,
|
rewarding_denom,
|
||||||
epochs_in_interval: args.epochs_in_interval,
|
epochs_in_interval: args.epochs_in_interval,
|
||||||
epoch_duration: Duration::from_secs(args.epoch_duration),
|
epoch_duration: Duration::from_secs(args.epoch_duration),
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use log::{debug, info};
|
||||||
|
|
||||||
use cosmwasm_std::Decimal;
|
use cosmwasm_std::Decimal;
|
||||||
use cw_utils::{Duration, Threshold};
|
use cw_utils::{Duration, Threshold};
|
||||||
use log::{debug, info};
|
|
||||||
use multisig_contract_common::msg::InstantiateMsg;
|
use multisig_contract_common::msg::InstantiateMsg;
|
||||||
use validator_client::nyxd::AccountId;
|
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
@@ -22,10 +20,10 @@ pub struct Args {
|
|||||||
pub max_voting_period: u64,
|
pub max_voting_period: u64,
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub coconut_bandwidth_contract_address: Option<AccountId>,
|
pub coconut_bandwidth_contract_address: Option<String>,
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub coconut_dkg_contract_address: Option<AccountId>,
|
pub coconut_dkg_contract_address: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn generate(args: Args) {
|
pub async fn generate(args: Args) {
|
||||||
@@ -35,18 +33,13 @@ pub async fn generate(args: Args) {
|
|||||||
|
|
||||||
let coconut_bandwidth_contract_address =
|
let coconut_bandwidth_contract_address =
|
||||||
args.coconut_bandwidth_contract_address.unwrap_or_else(|| {
|
args.coconut_bandwidth_contract_address.unwrap_or_else(|| {
|
||||||
let address =
|
std::env::var(network_defaults::var_names::COCONUT_BANDWIDTH_CONTRACT_ADDRESS)
|
||||||
std::env::var(network_defaults::var_names::COCONUT_BANDWIDTH_CONTRACT_ADDRESS)
|
.expect("Coconut bandwidth contract address has to be set")
|
||||||
.expect("Coconut bandwidth contract address has to be set");
|
|
||||||
AccountId::from_str(address.as_str())
|
|
||||||
.expect("Failed converting bandwidth contract address to AccountId")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let coconut_dkg_contract_address = args.coconut_dkg_contract_address.unwrap_or_else(|| {
|
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)
|
std::env::var(network_defaults::var_names::COCONUT_DKG_CONTRACT_ADDRESS)
|
||||||
.expect("Coconut DKG contract address has to be set");
|
.expect("Coconut DKG contract address has to be set")
|
||||||
AccountId::from_str(address.as_str())
|
|
||||||
.expect("Failed converting DKG contract address to AccountId")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let instantiate_msg = InstantiateMsg {
|
let instantiate_msg = InstantiateMsg {
|
||||||
@@ -56,8 +49,8 @@ pub async fn generate(args: Args) {
|
|||||||
.expect("threshold can't be converted to Decimal"),
|
.expect("threshold can't be converted to Decimal"),
|
||||||
},
|
},
|
||||||
max_voting_period: Duration::Time(args.max_voting_period),
|
max_voting_period: Duration::Time(args.max_voting_period),
|
||||||
coconut_bandwidth_contract_address: coconut_bandwidth_contract_address.to_string(),
|
coconut_bandwidth_contract_address,
|
||||||
coconut_dkg_contract_address: coconut_dkg_contract_address.to_string(),
|
coconut_dkg_contract_address,
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("instantiate_msg: {:?}", instantiate_msg);
|
debug!("instantiate_msg: {:?}", instantiate_msg);
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
|
|
||||||
use validator_client::nyxd::AccountId;
|
|
||||||
use vesting_contract_common::InitMsg;
|
use vesting_contract_common::InitMsg;
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub mixnet_contract_address: Option<AccountId>,
|
pub mixnet_contract_address: Option<String>,
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub mix_denom: Option<String>,
|
pub mix_denom: Option<String>,
|
||||||
@@ -24,10 +21,8 @@ pub async fn generate(args: Args) {
|
|||||||
debug!("Received arguments: {:?}", args);
|
debug!("Received arguments: {:?}", args);
|
||||||
|
|
||||||
let mixnet_contract_address = args.mixnet_contract_address.unwrap_or_else(|| {
|
let mixnet_contract_address = args.mixnet_contract_address.unwrap_or_else(|| {
|
||||||
let address = std::env::var(network_defaults::var_names::MIXNET_CONTRACT_ADDRESS)
|
std::env::var(network_defaults::var_names::MIXNET_CONTRACT_ADDRESS)
|
||||||
.expect("Mixnet contract address has to be set");
|
.expect("Mixnet contract address has to be set")
|
||||||
AccountId::from_str(address.as_str())
|
|
||||||
.expect("Failed converting mixnet address to AccountId")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let mix_denom = args.mix_denom.unwrap_or_else(|| {
|
let mix_denom = args.mix_denom.unwrap_or_else(|| {
|
||||||
@@ -35,7 +30,7 @@ pub async fn generate(args: Args) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let instantiate_msg = InitMsg {
|
let instantiate_msg = InitMsg {
|
||||||
mixnet_contract_address: mixnet_contract_address.to_string(),
|
mixnet_contract_address,
|
||||||
mix_denom,
|
mix_denom,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+27
-11
@@ -30,15 +30,23 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
|
|||||||
fn default_root_directory() -> PathBuf;
|
fn default_root_directory() -> PathBuf;
|
||||||
|
|
||||||
// default, most probable, implementations; can be easily overridden where required
|
// default, most probable, implementations; can be easily overridden where required
|
||||||
fn default_config_directory(id: &str) -> PathBuf {
|
fn default_config_directory(id: Option<&str>) -> PathBuf {
|
||||||
Self::default_root_directory().join(id).join(CONFIG_DIR)
|
if let Some(id) = id {
|
||||||
|
Self::default_root_directory().join(id).join(CONFIG_DIR)
|
||||||
|
} else {
|
||||||
|
Self::default_root_directory().join(CONFIG_DIR)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_data_directory(id: &str) -> PathBuf {
|
fn default_data_directory(id: Option<&str>) -> PathBuf {
|
||||||
Self::default_root_directory().join(id).join(DATA_DIR)
|
if let Some(id) = id {
|
||||||
|
Self::default_root_directory().join(id).join(DATA_DIR)
|
||||||
|
} else {
|
||||||
|
Self::default_root_directory().join(DATA_DIR)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_config_file_path(id: &str) -> PathBuf {
|
fn default_config_file_path(id: Option<&str>) -> PathBuf {
|
||||||
Self::default_config_directory(id).join(Self::config_file_name())
|
Self::default_config_directory(id).join(Self::config_file_name())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,15 +54,23 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
|
|||||||
|
|
||||||
fn try_default_root_directory() -> Option<PathBuf>;
|
fn try_default_root_directory() -> Option<PathBuf>;
|
||||||
|
|
||||||
fn try_default_config_directory(id: &str) -> Option<PathBuf> {
|
fn try_default_config_directory(id: Option<&str>) -> Option<PathBuf> {
|
||||||
Self::try_default_root_directory().map(|d| d.join(id).join(CONFIG_DIR))
|
if let Some(id) = id {
|
||||||
|
Self::try_default_root_directory().map(|d| d.join(id).join(CONFIG_DIR))
|
||||||
|
} else {
|
||||||
|
Self::try_default_root_directory().map(|d| d.join(CONFIG_DIR))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_default_data_directory(id: &str) -> Option<PathBuf> {
|
fn try_default_data_directory(id: Option<&str>) -> Option<PathBuf> {
|
||||||
Self::try_default_root_directory().map(|d| d.join(id).join(DATA_DIR))
|
if let Some(id) = id {
|
||||||
|
Self::try_default_root_directory().map(|d| d.join(id).join(DATA_DIR))
|
||||||
|
} else {
|
||||||
|
Self::try_default_root_directory().map(|d| d.join(DATA_DIR))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_default_config_file_path(id: &str) -> Option<PathBuf> {
|
fn try_default_config_file_path(id: Option<&str>) -> Option<PathBuf> {
|
||||||
Self::try_default_config_directory(id).map(|d| d.join(Self::config_file_name()))
|
Self::try_default_config_directory(id).map(|d| d.join(Self::config_file_name()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +113,7 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_from_file(id: &str) -> io::Result<Self> {
|
fn load_from_file(id: Option<&str>) -> io::Result<Self> {
|
||||||
let file = Self::default_config_file_path(id);
|
let file = Self::default_config_file_path(id);
|
||||||
log::trace!("Loading from file: {:#?}", file);
|
log::trace!("Loading from file: {:#?}", file);
|
||||||
let config_contents = fs::read_to_string(file)?;
|
let config_contents = fs::read_to_string(file)?;
|
||||||
|
|||||||
@@ -21,22 +21,18 @@ pub enum ExecuteMsg {
|
|||||||
RegisterDealer {
|
RegisterDealer {
|
||||||
bte_key_with_proof: EncodedBTEPublicKeyWithProof,
|
bte_key_with_proof: EncodedBTEPublicKeyWithProof,
|
||||||
announce_address: String,
|
announce_address: String,
|
||||||
resharing: bool,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
CommitDealing {
|
CommitDealing {
|
||||||
dealing_bytes: ContractSafeBytes,
|
dealing_bytes: ContractSafeBytes,
|
||||||
resharing: bool,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
CommitVerificationKeyShare {
|
CommitVerificationKeyShare {
|
||||||
share: VerificationKeyShare,
|
share: VerificationKeyShare,
|
||||||
resharing: bool,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
VerifyVerificationKeyShare {
|
VerifyVerificationKeyShare {
|
||||||
owner: Addr,
|
owner: Addr,
|
||||||
resharing: bool,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
SurpassedThreshold {},
|
SurpassedThreshold {},
|
||||||
@@ -49,7 +45,6 @@ pub enum ExecuteMsg {
|
|||||||
pub enum QueryMsg {
|
pub enum QueryMsg {
|
||||||
GetCurrentEpochState {},
|
GetCurrentEpochState {},
|
||||||
GetCurrentEpochThreshold {},
|
GetCurrentEpochThreshold {},
|
||||||
GetInitialDealers {},
|
|
||||||
GetDealerDetails {
|
GetDealerDetails {
|
||||||
dealer_address: String,
|
dealer_address: String,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,12 +18,6 @@ pub type EpochId = u64;
|
|||||||
// 2 public attributes, 2 private attributes, 1 fixed for coconut credential
|
// 2 public attributes, 2 private attributes, 1 fixed for coconut credential
|
||||||
pub const TOTAL_DEALINGS: usize = 2 + 2 + 1;
|
pub const TOTAL_DEALINGS: usize = 2 + 2 + 1;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq, Ord, PartialOrd)]
|
|
||||||
pub struct InitialReplacementData {
|
|
||||||
pub initial_dealers: Vec<Addr>,
|
|
||||||
pub initial_height: Option<u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, JsonSchema,
|
Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, JsonSchema,
|
||||||
)]
|
)]
|
||||||
@@ -92,17 +86,15 @@ impl Epoch {
|
|||||||
current_timestamp: Timestamp,
|
current_timestamp: Timestamp,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let duration = match state {
|
let duration = match state {
|
||||||
EpochState::PublicKeySubmission { .. } => {
|
EpochState::PublicKeySubmission => time_configuration.public_key_submission_time_secs,
|
||||||
time_configuration.public_key_submission_time_secs
|
EpochState::DealingExchange => time_configuration.dealing_exchange_time_secs,
|
||||||
}
|
EpochState::VerificationKeySubmission => {
|
||||||
EpochState::DealingExchange { .. } => time_configuration.dealing_exchange_time_secs,
|
|
||||||
EpochState::VerificationKeySubmission { .. } => {
|
|
||||||
time_configuration.verification_key_submission_time_secs
|
time_configuration.verification_key_submission_time_secs
|
||||||
}
|
}
|
||||||
EpochState::VerificationKeyValidation { .. } => {
|
EpochState::VerificationKeyValidation => {
|
||||||
time_configuration.verification_key_validation_time_secs
|
time_configuration.verification_key_validation_time_secs
|
||||||
}
|
}
|
||||||
EpochState::VerificationKeyFinalization { .. } => {
|
EpochState::VerificationKeyFinalization => {
|
||||||
time_configuration.verification_key_finalization_time_secs
|
time_configuration.verification_key_finalization_time_secs
|
||||||
}
|
}
|
||||||
EpochState::InProgress => time_configuration.in_progress_time_secs,
|
EpochState::InProgress => time_configuration.in_progress_time_secs,
|
||||||
@@ -114,33 +106,6 @@ impl Epoch {
|
|||||||
finish_timestamp: current_timestamp.plus_seconds(duration),
|
finish_timestamp: current_timestamp.plus_seconds(duration),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn final_timestamp_secs(&self) -> u64 {
|
|
||||||
let mut finish = self.finish_timestamp.seconds();
|
|
||||||
let time_configuration = self.time_configuration;
|
|
||||||
let mut curr_epoch_state = self.state;
|
|
||||||
while let Some(state) = curr_epoch_state.next() {
|
|
||||||
curr_epoch_state = state;
|
|
||||||
let adding = match curr_epoch_state {
|
|
||||||
EpochState::PublicKeySubmission { .. } => {
|
|
||||||
time_configuration.public_key_submission_time_secs
|
|
||||||
}
|
|
||||||
EpochState::DealingExchange { .. } => time_configuration.dealing_exchange_time_secs,
|
|
||||||
EpochState::VerificationKeySubmission { .. } => {
|
|
||||||
time_configuration.verification_key_submission_time_secs
|
|
||||||
}
|
|
||||||
EpochState::VerificationKeyValidation { .. } => {
|
|
||||||
time_configuration.verification_key_validation_time_secs
|
|
||||||
}
|
|
||||||
EpochState::VerificationKeyFinalization { .. } => {
|
|
||||||
time_configuration.verification_key_finalization_time_secs
|
|
||||||
}
|
|
||||||
EpochState::InProgress { .. } => 0,
|
|
||||||
};
|
|
||||||
finish += adding;
|
|
||||||
}
|
|
||||||
finish
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// currently (it is still extremely likely to change, we might be able to get rid of verification key-related complaints),
|
// currently (it is still extremely likely to change, we might be able to get rid of verification key-related complaints),
|
||||||
@@ -158,36 +123,28 @@ impl Epoch {
|
|||||||
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)]
|
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum EpochState {
|
pub enum EpochState {
|
||||||
PublicKeySubmission { resharing: bool },
|
PublicKeySubmission,
|
||||||
DealingExchange { resharing: bool },
|
DealingExchange,
|
||||||
VerificationKeySubmission { resharing: bool },
|
VerificationKeySubmission,
|
||||||
VerificationKeyValidation { resharing: bool },
|
VerificationKeyValidation,
|
||||||
VerificationKeyFinalization { resharing: bool },
|
VerificationKeyFinalization,
|
||||||
InProgress,
|
InProgress,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for EpochState {
|
impl Default for EpochState {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::PublicKeySubmission { resharing: false }
|
Self::PublicKeySubmission
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for EpochState {
|
impl Display for EpochState {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
EpochState::PublicKeySubmission { resharing } => {
|
EpochState::PublicKeySubmission => write!(f, "PublicKeySubmission"),
|
||||||
write!(f, "PublicKeySubmission with resharing {resharing}")
|
EpochState::DealingExchange => write!(f, "DealingExchange"),
|
||||||
}
|
EpochState::VerificationKeySubmission => write!(f, "VerificationKeySubmission"),
|
||||||
EpochState::DealingExchange { resharing } => write!(f, "DealingExchange {resharing}"),
|
EpochState::VerificationKeyValidation => write!(f, "VerificationKeyValidation"),
|
||||||
EpochState::VerificationKeySubmission { resharing } => {
|
EpochState::VerificationKeyFinalization => write!(f, "VerificationKeyFinalization"),
|
||||||
write!(f, "VerificationKeySubmission with resharing {resharing}")
|
|
||||||
}
|
|
||||||
EpochState::VerificationKeyValidation { resharing } => {
|
|
||||||
write!(f, "VerificationKeyValidation with resharing {resharing}")
|
|
||||||
}
|
|
||||||
EpochState::VerificationKeyFinalization { resharing } => {
|
|
||||||
write!(f, "VerificationKeyFinalization with resharing {resharing}")
|
|
||||||
}
|
|
||||||
EpochState::InProgress => write!(f, "InProgress"),
|
EpochState::InProgress => write!(f, "InProgress"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,19 +153,11 @@ impl Display for EpochState {
|
|||||||
impl EpochState {
|
impl EpochState {
|
||||||
pub fn next(self) -> Option<Self> {
|
pub fn next(self) -> Option<Self> {
|
||||||
match self {
|
match self {
|
||||||
EpochState::PublicKeySubmission { resharing } => {
|
EpochState::PublicKeySubmission => Some(EpochState::DealingExchange),
|
||||||
Some(EpochState::DealingExchange { resharing })
|
EpochState::DealingExchange => Some(EpochState::VerificationKeySubmission),
|
||||||
}
|
EpochState::VerificationKeySubmission => Some(EpochState::VerificationKeyValidation),
|
||||||
EpochState::DealingExchange { resharing } => {
|
EpochState::VerificationKeyValidation => Some(EpochState::VerificationKeyFinalization),
|
||||||
Some(EpochState::VerificationKeySubmission { resharing })
|
EpochState::VerificationKeyFinalization => Some(EpochState::InProgress),
|
||||||
}
|
|
||||||
EpochState::VerificationKeySubmission { resharing } => {
|
|
||||||
Some(EpochState::VerificationKeyValidation { resharing })
|
|
||||||
}
|
|
||||||
EpochState::VerificationKeyValidation { resharing } => {
|
|
||||||
Some(EpochState::VerificationKeyFinalization { resharing })
|
|
||||||
}
|
|
||||||
EpochState::VerificationKeyFinalization { .. } => Some(EpochState::InProgress),
|
|
||||||
EpochState::InProgress => None,
|
EpochState::InProgress => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,8 +171,4 @@ impl EpochState {
|
|||||||
|
|
||||||
states
|
states
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_final(&self) -> bool {
|
|
||||||
*self == EpochState::InProgress
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,11 @@ pub struct PagedVKSharesResponse {
|
|||||||
|
|
||||||
pub fn to_cosmos_msg(
|
pub fn to_cosmos_msg(
|
||||||
owner: Addr,
|
owner: Addr,
|
||||||
resharing: bool,
|
|
||||||
coconut_dkg_addr: String,
|
coconut_dkg_addr: String,
|
||||||
multisig_addr: String,
|
multisig_addr: String,
|
||||||
expiration_time: Timestamp,
|
expiration_time: Timestamp,
|
||||||
) -> StdResult<CosmosMsg> {
|
) -> StdResult<CosmosMsg> {
|
||||||
let verify_vk_share_req = ExecuteMsg::VerifyVerificationKeyShare { owner, resharing };
|
let verify_vk_share_req = ExecuteMsg::VerifyVerificationKeyShare { owner };
|
||||||
let verify_vk_share_msg = CosmosMsg::Wasm(WasmMsg::Execute {
|
let verify_vk_share_msg = CosmosMsg::Wasm(WasmMsg::Execute {
|
||||||
contract_addr: coconut_dkg_addr,
|
contract_addr: coconut_dkg_addr,
|
||||||
msg: to_binary(&verify_vk_share_req)?,
|
msg: to_binary(&verify_vk_share_req)?,
|
||||||
@@ -63,8 +62,7 @@ pub fn owner_from_cosmos_msgs(msgs: &[CosmosMsg]) -> Option<Addr> {
|
|||||||
funds: _,
|
funds: _,
|
||||||
})) = msgs.get(0)
|
})) = msgs.get(0)
|
||||||
{
|
{
|
||||||
if let Ok(ExecuteMsg::VerifyVerificationKeyShare { owner, .. }) =
|
if let Ok(ExecuteMsg::VerifyVerificationKeyShare { owner }) = from_binary::<ExecuteMsg>(msg)
|
||||||
from_binary::<ExecuteMsg>(msg)
|
|
||||||
{
|
{
|
||||||
return Some(owner);
|
return Some(owner);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[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>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
#[cfg(feature = "dkg")]
|
#[cfg(feature = "coconut")]
|
||||||
use dkg::{error::DkgError, Dealing};
|
use dkg::{error::DkgError, Dealing};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
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 {
|
impl<'a> From<&'a Dealing> for ContractSafeBytes {
|
||||||
fn from(dealing: &'a Dealing) -> Self {
|
fn from(dealing: &'a Dealing) -> Self {
|
||||||
ContractSafeBytes(dealing.to_bytes())
|
ContractSafeBytes(dealing.to_bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "dkg")]
|
#[cfg(feature = "coconut")]
|
||||||
impl<'a> TryFrom<&'a ContractSafeBytes> for Dealing {
|
impl<'a> TryFrom<&'a ContractSafeBytes> for Dealing {
|
||||||
type Error = DkgError;
|
type Error = DkgError;
|
||||||
|
|
||||||
|
|||||||
@@ -13,4 +13,3 @@ cw4 = { version = "0.13.4" }
|
|||||||
cosmwasm-std = "1.0.0"
|
cosmwasm-std = "1.0.0"
|
||||||
schemars = "0.8"
|
schemars = "0.8"
|
||||||
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
|
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
|
||||||
thiserror = { version = "1.0.23" }
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
pub mod error;
|
|
||||||
pub mod msg;
|
pub mod msg;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user