mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Compare commits
341 Commits
ff-0.14
...
c45c973ca1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c45c973ca1 | ||
|
|
6e37ac030d | ||
|
|
e7c759c468 | ||
|
|
8ec0582237 | ||
|
|
8d8e8a7a77 | ||
|
|
028ec3cce0 | ||
|
|
c49215805f | ||
|
|
2ffdd2a01d | ||
|
|
e1e6e67d4a | ||
|
|
6b19780c7b | ||
|
|
6100c3ca90 | ||
|
|
fa0ed4b180 | ||
|
|
0ea16f9e01 | ||
|
|
7a314baa9f | ||
|
|
9891ccade8 | ||
|
|
f1f166c168 | ||
|
|
df4aee2d59 | ||
|
|
302a43653f | ||
|
|
d219b77bd0 | ||
|
|
fce26eaee1 | ||
|
|
3cfbd9add7 | ||
|
|
609cf06393 | ||
|
|
46b1f1b7ec | ||
|
|
09113201e7 | ||
|
|
556d294157 | ||
|
|
82ca889ed3 | ||
|
|
cde0f753c2 | ||
|
|
6ff0ef7aa6 | ||
|
|
f9e3d1b142 | ||
|
|
a793aa18ef | ||
|
|
5662beeb8a | ||
|
|
509bd58f4e | ||
|
|
367a5769e8 | ||
|
|
cb6eb6430a | ||
|
|
4f82e5912c | ||
|
|
ac7af40f2e | ||
|
|
264bdd46ca | ||
|
|
c52f7634de | ||
|
|
21eaa5793d | ||
|
|
c744a80d80 | ||
|
|
a34f9f6164 | ||
|
|
353683cfd2 | ||
|
|
d4f77159c4 | ||
|
|
191bf4bdea | ||
|
|
06a4824aba | ||
|
|
e65a37e639 | ||
|
|
4653ef4a61 | ||
|
|
ce08fad931 | ||
|
|
1866bb7ae3 | ||
|
|
aff2065c31 | ||
|
|
7300700108 | ||
|
|
31874ceeae | ||
|
|
012b8fddae | ||
|
|
d2f58232c8 | ||
|
|
49794b6a75 | ||
|
|
973287d0a1 | ||
|
|
1b499edfe1 | ||
|
|
642848bd24 | ||
|
|
f7fb78bdd6 | ||
|
|
9c47ef2658 | ||
|
|
e1b6b638c6 | ||
|
|
c24768f922 | ||
|
|
65613750e1 | ||
|
|
87ee879dea | ||
|
|
b5603560e8 | ||
|
|
5818f1a41c | ||
|
|
1b781b4b57 | ||
|
|
94faf098b6 | ||
|
|
03e45f73cd | ||
|
|
63f7e220c0 | ||
|
|
7d49366373 | ||
|
|
56f6ba2dac | ||
|
|
55ed33d2d1 | ||
|
|
138a0e9b40 | ||
|
|
4fc7263ac3 | ||
|
|
f27fd59fa6 | ||
|
|
08f6af8bb9 | ||
|
|
3512b3832d | ||
|
|
1164f92ea1 | ||
|
|
0a3ead0e19 | ||
|
|
437f0e9a93 | ||
|
|
cc5d38f1ce | ||
|
|
0ce025e0c2 | ||
|
|
ea66cd0d1a | ||
|
|
8b32fba458 | ||
|
|
e63acf3f67 | ||
|
|
d373d2a4c9 | ||
|
|
cbf998ff30 | ||
|
|
ef07253a27 | ||
|
|
ffae6753ec | ||
|
|
a04215bc13 | ||
|
|
28aea8a442 | ||
|
|
7b46477ca0 | ||
|
|
e62b62ddfb | ||
|
|
a2d8d0fd13 | ||
|
|
b2b36b17c4 | ||
|
|
9de8394efa | ||
|
|
3cb9432daa | ||
|
|
3f5150b3fa | ||
|
|
d74b00b9e4 | ||
|
|
224cf4ea21 | ||
|
|
3955f92cc2 | ||
|
|
a9b1e5293c | ||
|
|
80009ab67f | ||
|
|
df9fda2971 | ||
|
|
ca8afb83a1 | ||
|
|
18a9cf2535 | ||
|
|
10c126ad92 | ||
|
|
19305aebc9 | ||
|
|
be68e27551 | ||
|
|
d6d96fe8ff | ||
|
|
95909d83a4 | ||
|
|
3bd48974f3 | ||
|
|
29093715e3 | ||
|
|
87b4dfc8f3 | ||
|
|
4db78b1787 | ||
|
|
02a5f15535 | ||
|
|
a1ef18a039 | ||
|
|
bec806230a | ||
|
|
8bafeab5b3 | ||
|
|
3722df7326 | ||
|
|
ddb8e1398e | ||
|
|
2be69b23b1 | ||
|
|
a82ccadbb0 | ||
|
|
1ff2934927 | ||
|
|
cd4ffa862f | ||
|
|
c0a4d85ae6 | ||
|
|
55e845fe12 | ||
|
|
5ea087d177 | ||
|
|
dd7dc0c1dc | ||
|
|
c83fbb3e44 | ||
|
|
befbbbfb84 | ||
|
|
d0f497dc68 | ||
|
|
1b755a5d48 | ||
|
|
e5efcd56ba | ||
|
|
5d60b3c2ae | ||
|
|
ae923b24ff | ||
|
|
d304cd97e1 | ||
|
|
2b56dcdf3f | ||
|
|
865e351f96 | ||
|
|
ea275df26c | ||
|
|
90804c4c30 | ||
|
|
46caca2f51 | ||
|
|
2077e485bb | ||
|
|
28dbef8a1c | ||
|
|
2216ade8c4 | ||
|
|
3541197aa5 | ||
|
|
5265cc69de | ||
|
|
a141deaf36 | ||
|
|
215e41fdb6 | ||
|
|
41c34d7f11 | ||
|
|
974bc82387 | ||
|
|
47ef24a7cc | ||
|
|
a2209dd6ff | ||
|
|
2032cf355f | ||
|
|
fe41b09fd4 | ||
|
|
74bad049a7 | ||
|
|
72fefb3d85 | ||
|
|
200c1530a4 | ||
|
|
5736b87b57 | ||
|
|
ada94e8c5d | ||
|
|
75240ed327 | ||
|
|
6177cf5c07 | ||
|
|
0d38dc96b6 | ||
|
|
e8094523ff | ||
|
|
53a64bc7e2 | ||
|
|
c0e48867e1 | ||
|
|
0066b94d38 | ||
|
|
7d54c02ec6 | ||
|
|
568324f631 | ||
|
|
2a02a8dc59 | ||
|
|
eaa9a0e5a6 | ||
|
|
251996c1b0 | ||
|
|
98b9cc82a7 | ||
|
|
3c6e889732 | ||
|
|
354efc0192 | ||
|
|
e20058feae | ||
|
|
09f0714894 | ||
|
|
d3d539553c | ||
|
|
b08ae8e6a7 | ||
|
|
35db2924b4 | ||
|
|
bfff823bf7 | ||
|
|
352af85498 | ||
|
|
ecad89b269 | ||
|
|
48f5ed71d7 | ||
|
|
ed9cbdd8e0 | ||
|
|
0ac11defcc | ||
|
|
24e89316d5 | ||
|
|
3f03dac050 | ||
|
|
820b710928 | ||
|
|
88c7ae3e7d | ||
|
|
dd5e43760d | ||
|
|
776e417fd2 | ||
|
|
2f8ce15a92 | ||
|
|
af56304676 | ||
|
|
62a2c4f20e | ||
|
|
c69841710a | ||
|
|
3158590675 | ||
|
|
263d75d380 | ||
|
|
030185c7fc | ||
|
|
e2dc5db7aa | ||
|
|
90bc364f9f | ||
|
|
a4811c9a41 | ||
|
|
12cfa6b2a5 | ||
|
|
0c71b6fc4d | ||
|
|
ffe1b60a11 | ||
|
|
5526b8d439 | ||
|
|
beac35c119 | ||
|
|
62bb75e09a | ||
|
|
45bd376c08 | ||
|
|
da190759a9 | ||
|
|
f2d399ba1e | ||
|
|
220bcbc592 | ||
|
|
85949f4b04 | ||
|
|
f8adfb56ad | ||
|
|
2f833dec77 | ||
|
|
e3e41324c9 | ||
|
|
6ed7c5d65e | ||
|
|
9dddfd91c8 | ||
|
|
c24b694fb2 | ||
|
|
738babf7e9 | ||
|
|
33faa53b56 | ||
|
|
8c366107ae | ||
|
|
7a790f3a20 | ||
|
|
a7c77f8b5f | ||
|
|
da3095ed15 | ||
|
|
758d422595 | ||
|
|
9841061b49 | ||
|
|
4122a0135f | ||
|
|
b63ef32864 | ||
|
|
8be03a8fc2 | ||
|
|
677a2e5749 | ||
|
|
38bda1d586 | ||
|
|
2bc2ca6906 | ||
|
|
900a6612d7 | ||
|
|
17c1d5cd6b | ||
|
|
8a1b56a928 | ||
|
|
75964cf6da | ||
|
|
d407e35cee | ||
|
|
c8ef044acb | ||
|
|
ddbc32de4d | ||
|
|
e5ccfac19e | ||
|
|
432daae1d1 | ||
|
|
da3a85efe5 | ||
|
|
1e0240123d | ||
|
|
f6d4d1b084 | ||
|
|
1b37dd2951 | ||
|
|
f32e0609f1 | ||
|
|
ca85f9ba0c | ||
|
|
cfd1cb3a37 | ||
|
|
f2c13a0040 | ||
|
|
961f46bc04 | ||
|
|
2c4de3bab4 | ||
|
|
95c30720d2 | ||
|
|
ceede14f5c | ||
|
|
5e60ea9718 | ||
|
|
153f6f2f2f | ||
|
|
104c0d4492 | ||
|
|
7c8f13ab28 | ||
|
|
cb0deadf9a | ||
|
|
cb489f9cef | ||
|
|
cc662cb591 | ||
|
|
a8b8844e3f | ||
|
|
82b543ef75 | ||
|
|
72e80c1a3d | ||
|
|
b6edc94bcd | ||
|
|
cfce2b26e2 | ||
|
|
e87bbcda64 | ||
|
|
9f84adf8b3 | ||
|
|
3919cf55ae | ||
|
|
38dd8cb191 | ||
|
|
f2563d39cb | ||
|
|
15a9cbef40 | ||
|
|
078d6e51e5 | ||
|
|
6c33e18745 | ||
|
|
b743c9a43e | ||
|
|
0c2f2979a9 | ||
|
|
971951a1a6 | ||
|
|
92d9e908cb | ||
|
|
a32b97be88 | ||
|
|
e3809b2ff1 | ||
|
|
fd2d8b4f0a | ||
|
|
bc81614894 | ||
|
|
8df5aa2e2d | ||
|
|
b000740470 | ||
|
|
b9f554111d | ||
|
|
354c408e3e | ||
|
|
df3b60376a | ||
|
|
8d209c652e | ||
|
|
9ddad794b4 | ||
|
|
b934e484cc | ||
|
|
f8aee9b3c8 | ||
|
|
f51d77d26a | ||
|
|
0780deb643 | ||
|
|
75c38560f4 | ||
|
|
9f1c5268a5 | ||
|
|
35b113768b | ||
|
|
f2595c4939 | ||
|
|
8fcfa6d3d5 | ||
|
|
54c9d19726 | ||
|
|
25324c3cd5 | ||
|
|
ecb7df85b0 | ||
|
|
68c7acdbef | ||
|
|
8b60feed92 | ||
|
|
5c895efcd0 | ||
|
|
60e55656aa | ||
|
|
9536282418 | ||
|
|
8297d0679d | ||
|
|
d9f854b08a | ||
|
|
8aaf7f7dc6 | ||
|
|
ce447558ac | ||
|
|
fc850da30e | ||
|
|
d6f6cf1965 | ||
|
|
4438b51881 | ||
|
|
6ae0d9fad7 | ||
|
|
ad08b410a8 | ||
|
|
ec3cfd3ab7 | ||
|
|
01eb2daa0b | ||
|
|
885000f970 | ||
|
|
4be506414b | ||
|
|
1143d84e1d | ||
|
|
336922101f | ||
|
|
ffa033d978 | ||
|
|
23f986f57a | ||
|
|
bb726b58af | ||
|
|
387615705c | ||
|
|
c7f825a192 | ||
|
|
d363b1c173 | ||
|
|
d5077ae966 | ||
|
|
188fcc3cb4 | ||
|
|
cbab9486c6 | ||
|
|
a5f4c450c6 | ||
|
|
4f65a0b147 | ||
|
|
feb18d64a7 | ||
|
|
cb1e6535cb | ||
|
|
6b8cf6653a | ||
|
|
b426bfcfe8 | ||
|
|
21ce50ecf7 | ||
|
|
a4ceb2e756 | ||
|
|
b59b1f59dd | ||
|
|
eab5d9e64f |
2
.github/LICENSE
vendored
2
.github/LICENSE
vendored
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2022-2023 Luke Parker
|
Copyright (c) 2022-2025 Luke Parker
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
4
.github/actions/bitcoin/action.yml
vendored
4
.github/actions/bitcoin/action.yml
vendored
@@ -5,14 +5,14 @@ inputs:
|
|||||||
version:
|
version:
|
||||||
description: "Version to download and run"
|
description: "Version to download and run"
|
||||||
required: false
|
required: false
|
||||||
default: "27.0"
|
default: "30.0"
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Bitcoin Daemon Cache
|
- name: Bitcoin Daemon Cache
|
||||||
id: cache-bitcoind
|
id: cache-bitcoind
|
||||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
|
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
|
||||||
with:
|
with:
|
||||||
path: bitcoin.tar.gz
|
path: bitcoin.tar.gz
|
||||||
key: bitcoind-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
|
key: bitcoind-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
|
||||||
|
|||||||
54
.github/actions/build-dependencies/action.yml
vendored
54
.github/actions/build-dependencies/action.yml
vendored
@@ -7,13 +7,20 @@ runs:
|
|||||||
- name: Remove unused packages
|
- name: Remove unused packages
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
sudo apt remove -y "*msbuild*" "*powershell*" "*nuget*" "*bazel*" "*ansible*" "*terraform*" "*heroku*" "*aws*" azure-cli
|
# Ensure the repositories are synced
|
||||||
|
sudo apt update -y
|
||||||
|
|
||||||
|
# Actually perform the removals
|
||||||
|
sudo apt remove -y "*powershell*" "*nuget*" "*bazel*" "*ansible*" "*terraform*" "*heroku*" "*aws*" azure-cli
|
||||||
sudo apt remove -y "*nodejs*" "*npm*" "*yarn*" "*java*" "*kotlin*" "*golang*" "*swift*" "*julia*" "*fortran*" "*android*"
|
sudo apt remove -y "*nodejs*" "*npm*" "*yarn*" "*java*" "*kotlin*" "*golang*" "*swift*" "*julia*" "*fortran*" "*android*"
|
||||||
sudo apt remove -y "*apache2*" "*nginx*" "*firefox*" "*chromium*" "*chrome*" "*edge*"
|
sudo apt remove -y "*apache2*" "*nginx*" "*firefox*" "*chromium*" "*chrome*" "*edge*"
|
||||||
|
|
||||||
|
sudo apt remove -y --allow-remove-essential -f shim-signed *python3*
|
||||||
|
# This removal command requires the prior removals due to unmet dependencies otherwise
|
||||||
sudo apt remove -y "*qemu*" "*sql*" "*texinfo*" "*imagemagick*"
|
sudo apt remove -y "*qemu*" "*sql*" "*texinfo*" "*imagemagick*"
|
||||||
sudo apt autoremove -y
|
|
||||||
sudo apt clean
|
# Reinstall python3 as a general dependency of a functional operating system
|
||||||
docker system prune -a --volumes
|
sudo apt install -y python3 --fix-missing
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
|
|
||||||
- name: Remove unused packages
|
- name: Remove unused packages
|
||||||
@@ -31,19 +38,48 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ "$RUNNER_OS" == "Linux" ]; then
|
if [ "$RUNNER_OS" == "Linux" ]; then
|
||||||
sudo apt install -y ca-certificates protobuf-compiler
|
sudo apt install -y ca-certificates protobuf-compiler libclang-dev
|
||||||
elif [ "$RUNNER_OS" == "Windows" ]; then
|
elif [ "$RUNNER_OS" == "Windows" ]; then
|
||||||
choco install protoc
|
choco install protoc
|
||||||
elif [ "$RUNNER_OS" == "macOS" ]; then
|
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||||
brew install protobuf
|
brew install protobuf llvm
|
||||||
|
HOMEBREW_ROOT_PATH=/opt/homebrew # Apple Silicon
|
||||||
|
if [ $(uname -m) = "x86_64" ]; then HOMEBREW_ROOT_PATH=/usr/local; fi # Intel
|
||||||
|
ls $HOMEBREW_ROOT_PATH/opt/llvm/lib | grep "libclang.dylib" # Make sure this installed `libclang`
|
||||||
|
echo "DYLD_LIBRARY_PATH=$HOMEBREW_ROOT_PATH/opt/llvm/lib:$DYLD_LIBRARY_PATH" >> "$GITHUB_ENV"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Install solc
|
- name: Install solc
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cargo install svm-rs
|
cargo +1.91 install svm-rs --version =0.5.19
|
||||||
svm install 0.8.26
|
svm install 0.8.29
|
||||||
svm use 0.8.26
|
svm use 0.8.29
|
||||||
|
|
||||||
|
- name: Remove preinstalled Docker
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker system prune -a --volumes
|
||||||
|
sudo apt remove -y *docker*
|
||||||
|
# Install uidmap which will be required for the explicitly installed Docker
|
||||||
|
sudo apt install uidmap
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
|
||||||
|
- name: Update system dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
sudo apt update -y
|
||||||
|
sudo apt upgrade -y
|
||||||
|
sudo apt autoremove -y
|
||||||
|
sudo apt clean
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
|
||||||
|
- name: Install rootless Docker
|
||||||
|
uses: docker/setup-docker-action@b60f85385d03ac8acfca6d9996982511d8620a19
|
||||||
|
with:
|
||||||
|
rootless: true
|
||||||
|
set-host: true
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
|
||||||
# - name: Cache Rust
|
# - name: Cache Rust
|
||||||
# uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
|
# uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
|
||||||
|
|||||||
4
.github/actions/monero-wallet-rpc/action.yml
vendored
4
.github/actions/monero-wallet-rpc/action.yml
vendored
@@ -5,14 +5,14 @@ inputs:
|
|||||||
version:
|
version:
|
||||||
description: "Version to download and run"
|
description: "Version to download and run"
|
||||||
required: false
|
required: false
|
||||||
default: v0.18.3.4
|
default: v0.18.4.3
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Monero Wallet RPC Cache
|
- name: Monero Wallet RPC Cache
|
||||||
id: cache-monero-wallet-rpc
|
id: cache-monero-wallet-rpc
|
||||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
|
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
|
||||||
with:
|
with:
|
||||||
path: monero-wallet-rpc
|
path: monero-wallet-rpc
|
||||||
key: monero-wallet-rpc-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
|
key: monero-wallet-rpc-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
|
||||||
|
|||||||
4
.github/actions/monero/action.yml
vendored
4
.github/actions/monero/action.yml
vendored
@@ -5,14 +5,14 @@ inputs:
|
|||||||
version:
|
version:
|
||||||
description: "Version to download and run"
|
description: "Version to download and run"
|
||||||
required: false
|
required: false
|
||||||
default: v0.18.3.4
|
default: v0.18.4.3
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Monero Daemon Cache
|
- name: Monero Daemon Cache
|
||||||
id: cache-monerod
|
id: cache-monerod
|
||||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
|
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
|
||||||
with:
|
with:
|
||||||
path: /usr/bin/monerod
|
path: /usr/bin/monerod
|
||||||
key: monerod-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
|
key: monerod-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
|
||||||
|
|||||||
4
.github/actions/test-dependencies/action.yml
vendored
4
.github/actions/test-dependencies/action.yml
vendored
@@ -5,12 +5,12 @@ inputs:
|
|||||||
monero-version:
|
monero-version:
|
||||||
description: "Monero version to download and run as a regtest node"
|
description: "Monero version to download and run as a regtest node"
|
||||||
required: false
|
required: false
|
||||||
default: v0.18.3.4
|
default: v0.18.4.3
|
||||||
|
|
||||||
bitcoin-version:
|
bitcoin-version:
|
||||||
description: "Bitcoin version to download and run as a regtest node"
|
description: "Bitcoin version to download and run as a regtest node"
|
||||||
required: false
|
required: false
|
||||||
default: "27.1"
|
default: "30.0"
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
|
|||||||
2
.github/nightly-version
vendored
2
.github/nightly-version
vendored
@@ -1 +1 @@
|
|||||||
nightly-2025-02-01
|
nightly-2025-11-11
|
||||||
|
|||||||
14
.github/workflows/crypto-tests.yml
vendored
14
.github/workflows/crypto-tests.yml
vendored
@@ -32,13 +32,17 @@ jobs:
|
|||||||
-p dalek-ff-group \
|
-p dalek-ff-group \
|
||||||
-p minimal-ed448 \
|
-p minimal-ed448 \
|
||||||
-p ciphersuite \
|
-p ciphersuite \
|
||||||
|
-p ciphersuite-kp256 \
|
||||||
-p multiexp \
|
-p multiexp \
|
||||||
-p schnorr-signatures \
|
-p schnorr-signatures \
|
||||||
-p dleq \
|
-p prime-field \
|
||||||
-p generalized-bulletproofs \
|
-p short-weierstrass \
|
||||||
-p generalized-bulletproofs-circuit-abstraction \
|
-p secq256k1 \
|
||||||
-p ec-divisors \
|
-p embedwards25519 \
|
||||||
-p generalized-bulletproofs-ec-gadgets \
|
|
||||||
-p dkg \
|
-p dkg \
|
||||||
|
-p dkg-recovery \
|
||||||
|
-p dkg-dealer \
|
||||||
|
-p dkg-musig \
|
||||||
|
-p dkg-evrf \
|
||||||
-p modular-frost \
|
-p modular-frost \
|
||||||
-p frost-schnorrkel
|
-p frost-schnorrkel
|
||||||
|
|||||||
6
.github/workflows/daily-deny.yml
vendored
6
.github/workflows/daily-deny.yml
vendored
@@ -12,13 +12,13 @@ jobs:
|
|||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
||||||
|
|
||||||
- name: Advisory Cache
|
- name: Advisory Cache
|
||||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
|
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
|
||||||
with:
|
with:
|
||||||
path: ~/.cargo/advisory-db
|
path: ~/.cargo/advisory-db
|
||||||
key: rust-advisory-db
|
key: rust-advisory-db
|
||||||
|
|
||||||
- name: Install cargo deny
|
- name: Install cargo deny
|
||||||
run: cargo install --locked cargo-deny
|
run: cargo +1.91 install cargo-deny --version =0.18.5
|
||||||
|
|
||||||
- name: Run cargo deny
|
- name: Run cargo deny
|
||||||
run: cargo deny -L error --all-features check
|
run: cargo deny -L error --all-features check --hide-inclusion-graph
|
||||||
|
|||||||
117
.github/workflows/lint.yml
vendored
117
.github/workflows/lint.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
clippy:
|
clippy:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-13, macos-14, windows-latest]
|
os: [ubuntu-latest, macos-15-intel, macos-latest, windows-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
uses: ./.github/actions/build-dependencies
|
uses: ./.github/actions/build-dependencies
|
||||||
|
|
||||||
- name: Install nightly rust
|
- name: Install nightly rust
|
||||||
run: rustup toolchain install ${{ steps.nightly.outputs.version }} --profile minimal -t wasm32-unknown-unknown -c clippy
|
run: rustup toolchain install ${{ steps.nightly.outputs.version }} --profile minimal -t wasm32v1-none -c clippy
|
||||||
|
|
||||||
- name: Run Clippy
|
- name: Run Clippy
|
||||||
run: cargo +${{ steps.nightly.outputs.version }} clippy --all-features --all-targets -- -D warnings -A clippy::items_after_test_module
|
run: cargo +${{ steps.nightly.outputs.version }} clippy --all-features --all-targets -- -D warnings -A clippy::items_after_test_module
|
||||||
@@ -46,16 +46,16 @@ jobs:
|
|||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
||||||
|
|
||||||
- name: Advisory Cache
|
- name: Advisory Cache
|
||||||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
|
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
|
||||||
with:
|
with:
|
||||||
path: ~/.cargo/advisory-db
|
path: ~/.cargo/advisory-db
|
||||||
key: rust-advisory-db
|
key: rust-advisory-db
|
||||||
|
|
||||||
- name: Install cargo deny
|
- name: Install cargo deny
|
||||||
run: cargo install --locked cargo-deny
|
run: cargo +1.91 install cargo-deny --version =0.18.5
|
||||||
|
|
||||||
- name: Run cargo deny
|
- name: Run cargo deny
|
||||||
run: cargo deny -L error --all-features check
|
run: cargo deny -L error --all-features check --hide-inclusion-graph
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -88,19 +88,114 @@ jobs:
|
|||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
||||||
- name: Verify all dependencies are in use
|
- name: Verify all dependencies are in use
|
||||||
run: |
|
run: |
|
||||||
cargo install cargo-machete
|
cargo +1.91 install cargo-machete --version =0.9.1
|
||||||
cargo machete
|
cargo +1.91 machete
|
||||||
|
|
||||||
|
msrv:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
||||||
|
- name: Verify claimed `rust-version`
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cargo +1.91 install cargo-msrv --version =0.18.4
|
||||||
|
|
||||||
|
function check_msrv {
|
||||||
|
# We `cd` into the directory passed as the first argument, but will return to the
|
||||||
|
# directory called from.
|
||||||
|
return_to=$(pwd)
|
||||||
|
echo "Checking $1"
|
||||||
|
cd $1
|
||||||
|
|
||||||
|
# We then find the existing `rust-version` using `grep` (for the right line) and then a
|
||||||
|
# regex (to strip to just the major and minor version).
|
||||||
|
existing=$(cat ./Cargo.toml | grep "rust-version" | grep -Eo "[0-9]+\.[0-9]+")
|
||||||
|
|
||||||
|
# We then backup the `Cargo.toml`, allowing us to restore it after, saving time on future
|
||||||
|
# MSRV checks (as they'll benefit from immediately exiting if the queried version is less
|
||||||
|
# than the declared MSRV).
|
||||||
|
mv ./Cargo.toml ./Cargo.toml.bak
|
||||||
|
|
||||||
|
# We then use an inverted (`-v`) grep to remove the existing `rust-version` from the
|
||||||
|
# `Cargo.toml`, as required because else earlier versions of Rust won't even attempt to
|
||||||
|
# compile this crate.
|
||||||
|
cat ./Cargo.toml.bak | grep -v "rust-version" > Cargo.toml
|
||||||
|
|
||||||
|
# We then find the actual `rust-version` using `cargo-msrv` (again stripping to just the
|
||||||
|
# major and minor version).
|
||||||
|
actual=$(cargo msrv find --output-format minimal | grep -Eo "^[0-9]+\.[0-9]+")
|
||||||
|
|
||||||
|
# Finally, we compare the two.
|
||||||
|
echo "Declared rust-version: $existing"
|
||||||
|
echo "Actual rust-version: $actual"
|
||||||
|
[ $existing == $actual ]
|
||||||
|
result=$?
|
||||||
|
|
||||||
|
# Restore the original `Cargo.toml`.
|
||||||
|
rm Cargo.toml
|
||||||
|
mv ./Cargo.toml.bak ./Cargo.toml
|
||||||
|
|
||||||
|
# Return to the directory called from and return the result.
|
||||||
|
cd $return_to
|
||||||
|
return $result
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check each member of the workspace
|
||||||
|
function check_workspace {
|
||||||
|
# Get the members array from the workspace's `Cargo.toml`
|
||||||
|
cargo_toml_lines=$(cat ./Cargo.toml | wc -l)
|
||||||
|
# Keep all lines after the start of the array, then keep all lines before the next "]"
|
||||||
|
members=$(cat Cargo.toml | grep "members\ \=\ \[" -m1 -A$cargo_toml_lines | grep "]" -m1 -B$cargo_toml_lines)
|
||||||
|
|
||||||
|
# Parse out any comments, whitespace, including comments post-fixed on the same line as an entry
|
||||||
|
# We accomplish the latter by pruning all characters after the entry's ","
|
||||||
|
members=$(echo "$members" | grep -Ev "^[[:space:]]*(#|$)" | awk -F',' '{print $1","}')
|
||||||
|
# Replace the first line, which was "members = [" and is now "members = [,", with "["
|
||||||
|
members=$(echo "$members" | sed "1s/.*/\[/")
|
||||||
|
# Correct the last line, which was malleated to "],"
|
||||||
|
members=$(echo "$members" | sed "$(echo "$members" | wc -l)s/\]\,/\]/")
|
||||||
|
|
||||||
|
# Don't check the following
|
||||||
|
# Most of these are binaries, with the exception of the Substrate runtime which has a
|
||||||
|
# bespoke build pipeline
|
||||||
|
members=$(echo "$members" | grep -v "networks/ethereum/relayer\"")
|
||||||
|
members=$(echo "$members" | grep -v "message-queue\"")
|
||||||
|
members=$(echo "$members" | grep -v "processor/bin\"")
|
||||||
|
members=$(echo "$members" | grep -v "processor/bitcoin\"")
|
||||||
|
members=$(echo "$members" | grep -v "processor/ethereum\"")
|
||||||
|
members=$(echo "$members" | grep -v "processor/monero\"")
|
||||||
|
members=$(echo "$members" | grep -v "coordinator\"")
|
||||||
|
members=$(echo "$members" | grep -v "substrate/runtime\"")
|
||||||
|
members=$(echo "$members" | grep -v "substrate/node\"")
|
||||||
|
members=$(echo "$members" | grep -v "orchestration\"")
|
||||||
|
|
||||||
|
# Don't check the tests
|
||||||
|
members=$(echo "$members" | grep -v "mini\"")
|
||||||
|
members=$(echo "$members" | grep -v "tests/")
|
||||||
|
|
||||||
|
# Remove the trailing comma by replacing the last line's "," with ""
|
||||||
|
members=$(echo "$members" | sed "$(($(echo "$members" | wc -l) - 1))s/\,//")
|
||||||
|
|
||||||
|
echo $members | jq -r ".[]" | while read -r member; do
|
||||||
|
check_msrv $member
|
||||||
|
correct=$?
|
||||||
|
if [ $correct -ne 0 ]; then
|
||||||
|
return $correct
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
check_workspace
|
||||||
|
|
||||||
slither:
|
slither:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
||||||
|
|
||||||
|
- name: Build Dependencies
|
||||||
|
uses: ./.github/actions/build-dependencies
|
||||||
|
|
||||||
- name: Slither
|
- name: Slither
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install solc-select
|
|
||||||
solc-select install 0.8.26
|
|
||||||
solc-select use 0.8.26
|
|
||||||
|
|
||||||
python3 -m pip install slither-analyzer
|
python3 -m pip install slither-analyzer
|
||||||
|
|
||||||
slither --include-paths ./networks/ethereum/schnorr/contracts/Schnorr.sol
|
slither --include-paths ./networks/ethereum/schnorr/contracts/Schnorr.sol
|
||||||
|
|||||||
72
.github/workflows/monero-tests.yaml
vendored
72
.github/workflows/monero-tests.yaml
vendored
@@ -1,72 +0,0 @@
|
|||||||
name: Monero Tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- develop
|
|
||||||
paths:
|
|
||||||
- "networks/monero/**"
|
|
||||||
- "processor/**"
|
|
||||||
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- "networks/monero/**"
|
|
||||||
- "processor/**"
|
|
||||||
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# Only run these once since they will be consistent regardless of any node
|
|
||||||
unit-tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Test Dependencies
|
|
||||||
uses: ./.github/actions/test-dependencies
|
|
||||||
|
|
||||||
- name: Run Unit Tests Without Features
|
|
||||||
run: |
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-io --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-generators --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-primitives --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-mlsag --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-clsag --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-borromean --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-bulletproofs --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-serai --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-rpc --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-simple-request-rpc --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-address --lib
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-wallet --lib
|
|
||||||
|
|
||||||
# Doesn't run unit tests with features as the tests workflow will
|
|
||||||
|
|
||||||
integration-tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
# Test against all supported protocol versions
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
version: [v0.17.3.2, v0.18.3.4]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Test Dependencies
|
|
||||||
uses: ./.github/actions/test-dependencies
|
|
||||||
with:
|
|
||||||
monero-version: ${{ matrix.version }}
|
|
||||||
|
|
||||||
- name: Run Integration Tests Without Features
|
|
||||||
run: |
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-serai --test '*'
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-simple-request-rpc --test '*'
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-wallet --test '*'
|
|
||||||
|
|
||||||
- name: Run Integration Tests
|
|
||||||
# Don't run if the the tests workflow also will
|
|
||||||
if: ${{ matrix.version != 'v0.18.3.4' }}
|
|
||||||
run: |
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-serai --all-features --test '*'
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-simple-request-rpc --test '*'
|
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-wallet --all-features --test '*'
|
|
||||||
259
.github/workflows/msrv.yml
vendored
259
.github/workflows/msrv.yml
vendored
@@ -1,259 +0,0 @@
|
|||||||
name: Weekly MSRV Check
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: "0 0 * * 0"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
msrv-common:
|
|
||||||
name: Run cargo msrv on common
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Install Build Dependencies
|
|
||||||
uses: ./.github/actions/build-dependencies
|
|
||||||
|
|
||||||
- name: Install cargo msrv
|
|
||||||
run: cargo install --locked cargo-msrv
|
|
||||||
|
|
||||||
- name: Run cargo msrv on common
|
|
||||||
run: |
|
|
||||||
cargo msrv verify --manifest-path common/zalloc/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path common/std-shims/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path common/env/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path common/db/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path common/task/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path common/request/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path common/patchable-async-sleep/Cargo.toml
|
|
||||||
|
|
||||||
msrv-crypto:
|
|
||||||
name: Run cargo msrv on crypto
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Install Build Dependencies
|
|
||||||
uses: ./.github/actions/build-dependencies
|
|
||||||
|
|
||||||
- name: Install cargo msrv
|
|
||||||
run: cargo install --locked cargo-msrv
|
|
||||||
|
|
||||||
- name: Run cargo msrv on crypto
|
|
||||||
run: |
|
|
||||||
cargo msrv verify --manifest-path crypto/transcript/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path crypto/ff-group-tests/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/dalek-ff-group/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/ed448/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path crypto/multiexp/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path crypto/dleq/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/ciphersuite/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/schnorr/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path crypto/evrf/generalized-bulletproofs/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/evrf/circuit-abstraction/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/evrf/divisors/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/evrf/ec-gadgets/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/evrf/embedwards25519/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/evrf/secq256k1/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path crypto/dkg/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/frost/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path crypto/schnorrkel/Cargo.toml
|
|
||||||
|
|
||||||
msrv-networks:
|
|
||||||
name: Run cargo msrv on networks
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Install Build Dependencies
|
|
||||||
uses: ./.github/actions/build-dependencies
|
|
||||||
|
|
||||||
- name: Install cargo msrv
|
|
||||||
run: cargo install --locked cargo-msrv
|
|
||||||
|
|
||||||
- name: Run cargo msrv on networks
|
|
||||||
run: |
|
|
||||||
cargo msrv verify --manifest-path networks/bitcoin/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path networks/ethereum/build-contracts/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/ethereum/schnorr/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/ethereum/alloy-simple-request-transport/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/ethereum/relayer/Cargo.toml --features parity-db
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path networks/monero/io/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/generators/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/ringct/mlsag/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/ringct/clsag/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/ringct/borromean/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/ringct/bulletproofs/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/rpc/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/rpc/simple-request/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/wallet/address/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/wallet/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path networks/monero/verify-chain/Cargo.toml
|
|
||||||
|
|
||||||
msrv-message-queue:
|
|
||||||
name: Run cargo msrv on message-queue
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Install Build Dependencies
|
|
||||||
uses: ./.github/actions/build-dependencies
|
|
||||||
|
|
||||||
- name: Install cargo msrv
|
|
||||||
run: cargo install --locked cargo-msrv
|
|
||||||
|
|
||||||
- name: Run cargo msrv on message-queue
|
|
||||||
run: |
|
|
||||||
cargo msrv verify --manifest-path message-queue/Cargo.toml --features parity-db
|
|
||||||
|
|
||||||
msrv-processor:
|
|
||||||
name: Run cargo msrv on processor
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Install Build Dependencies
|
|
||||||
uses: ./.github/actions/build-dependencies
|
|
||||||
|
|
||||||
- name: Install cargo msrv
|
|
||||||
run: cargo install --locked cargo-msrv
|
|
||||||
|
|
||||||
- name: Run cargo msrv on processor
|
|
||||||
run: |
|
|
||||||
cargo msrv verify --manifest-path processor/view-keys/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path processor/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/messages/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path processor/scanner/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path processor/scheduler/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/scheduler/smart-contract/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/scheduler/utxo/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/scheduler/utxo/standard/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/scheduler/utxo/transaction-chaining/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path processor/key-gen/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/frost-attempt-manager/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/signers/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/bin/Cargo.toml --features parity-db
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path processor/bitcoin/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path processor/ethereum/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/ethereum/test-primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/ethereum/erc20/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/ethereum/deployer/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/ethereum/router/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path processor/ethereum/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path processor/monero/Cargo.toml
|
|
||||||
|
|
||||||
msrv-coordinator:
|
|
||||||
name: Run cargo msrv on coordinator
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Install Build Dependencies
|
|
||||||
uses: ./.github/actions/build-dependencies
|
|
||||||
|
|
||||||
- name: Install cargo msrv
|
|
||||||
run: cargo install --locked cargo-msrv
|
|
||||||
|
|
||||||
- name: Run cargo msrv on coordinator
|
|
||||||
run: |
|
|
||||||
cargo msrv verify --manifest-path coordinator/tributary-sdk/tendermint/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path coordinator/tributary-sdk/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path coordinator/cosign/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path coordinator/substrate/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path coordinator/tributary/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path coordinator/p2p/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path coordinator/p2p/libp2p/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path coordinator/Cargo.toml
|
|
||||||
|
|
||||||
msrv-substrate:
|
|
||||||
name: Run cargo msrv on substrate
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Install Build Dependencies
|
|
||||||
uses: ./.github/actions/build-dependencies
|
|
||||||
|
|
||||||
- name: Install cargo msrv
|
|
||||||
run: cargo install --locked cargo-msrv
|
|
||||||
|
|
||||||
- name: Run cargo msrv on substrate
|
|
||||||
run: |
|
|
||||||
cargo msrv verify --manifest-path substrate/primitives/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/coins/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path substrate/coins/pallet/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/dex/pallet/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/economic-security/pallet/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/genesis-liquidity/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path substrate/genesis-liquidity/pallet/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/in-instructions/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path substrate/in-instructions/pallet/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/validator-sets/pallet/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path substrate/validator-sets/primitives/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/emissions/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path substrate/emissions/pallet/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/signals/primitives/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path substrate/signals/pallet/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/abi/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path substrate/client/Cargo.toml
|
|
||||||
|
|
||||||
cargo msrv verify --manifest-path substrate/runtime/Cargo.toml
|
|
||||||
cargo msrv verify --manifest-path substrate/node/Cargo.toml
|
|
||||||
|
|
||||||
msrv-orchestration:
|
|
||||||
name: Run cargo msrv on orchestration
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Install Build Dependencies
|
|
||||||
uses: ./.github/actions/build-dependencies
|
|
||||||
|
|
||||||
- name: Install cargo msrv
|
|
||||||
run: cargo install --locked cargo-msrv
|
|
||||||
|
|
||||||
- name: Run cargo msrv on message-queue
|
|
||||||
run: |
|
|
||||||
cargo msrv verify --manifest-path orchestration/Cargo.toml
|
|
||||||
|
|
||||||
msrv-mini:
|
|
||||||
name: Run cargo msrv on mini
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
|
||||||
|
|
||||||
- name: Install Build Dependencies
|
|
||||||
uses: ./.github/actions/build-dependencies
|
|
||||||
|
|
||||||
- name: Install cargo msrv
|
|
||||||
run: cargo install --locked cargo-msrv
|
|
||||||
|
|
||||||
- name: Run cargo msrv on mini
|
|
||||||
run: |
|
|
||||||
cargo msrv verify --manifest-path mini/Cargo.toml
|
|
||||||
13
.github/workflows/networks-tests.yml
vendored
13
.github/workflows/networks-tests.yml
vendored
@@ -34,16 +34,3 @@ jobs:
|
|||||||
-p ethereum-schnorr-contract \
|
-p ethereum-schnorr-contract \
|
||||||
-p alloy-simple-request-transport \
|
-p alloy-simple-request-transport \
|
||||||
-p serai-ethereum-relayer \
|
-p serai-ethereum-relayer \
|
||||||
-p monero-io \
|
|
||||||
-p monero-generators \
|
|
||||||
-p monero-primitives \
|
|
||||||
-p monero-mlsag \
|
|
||||||
-p monero-clsag \
|
|
||||||
-p monero-borromean \
|
|
||||||
-p monero-bulletproofs \
|
|
||||||
-p monero-serai \
|
|
||||||
-p monero-rpc \
|
|
||||||
-p monero-simple-request-rpc \
|
|
||||||
-p monero-address \
|
|
||||||
-p monero-wallet \
|
|
||||||
-p monero-serai-verify-chain
|
|
||||||
|
|||||||
14
.github/workflows/no-std.yml
vendored
14
.github/workflows/no-std.yml
vendored
@@ -28,8 +28,18 @@ jobs:
|
|||||||
- name: Install Build Dependencies
|
- name: Install Build Dependencies
|
||||||
uses: ./.github/actions/build-dependencies
|
uses: ./.github/actions/build-dependencies
|
||||||
|
|
||||||
|
- name: Get nightly version to use
|
||||||
|
id: nightly
|
||||||
|
shell: bash
|
||||||
|
run: echo "version=$(cat .github/nightly-version)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Install RISC-V Toolchain
|
- name: Install RISC-V Toolchain
|
||||||
run: sudo apt update && sudo apt install -y gcc-riscv64-unknown-elf gcc-multilib && rustup target add riscv32imac-unknown-none-elf
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y gcc-riscv64-unknown-elf gcc-multilib
|
||||||
|
rustup toolchain install ${{ steps.nightly.outputs.version }} --profile minimal --component rust-src --target riscv32imac-unknown-none-elf
|
||||||
|
|
||||||
- name: Verify no-std builds
|
- name: Verify no-std builds
|
||||||
run: CFLAGS=-I/usr/include cargo build --target riscv32imac-unknown-none-elf -p serai-no-std-tests
|
run: |
|
||||||
|
CFLAGS=-I/usr/include cargo +${{ steps.nightly.outputs.version }} build --target riscv32imac-unknown-none-elf -Z build-std=core -p serai-no-std-tests
|
||||||
|
CFLAGS=-I/usr/include cargo +${{ steps.nightly.outputs.version }} build --target riscv32imac-unknown-none-elf -Z build-std=core,alloc -p serai-no-std-tests --features "alloc"
|
||||||
|
|||||||
14
.github/workflows/pages.yml
vendored
14
.github/workflows/pages.yml
vendored
@@ -46,16 +46,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
|
||||||
- name: Setup Ruby
|
- name: Setup Ruby
|
||||||
uses: ruby/setup-ruby@v1
|
uses: ruby/setup-ruby@44511735964dcb71245e7e55f72539531f7bc0eb
|
||||||
with:
|
with:
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
cache-version: 0
|
cache-version: 0
|
||||||
working-directory: "${{ github.workspace }}/docs"
|
working-directory: "${{ github.workspace }}/docs"
|
||||||
- name: Setup Pages
|
- name: Setup Pages
|
||||||
id: pages
|
id: pages
|
||||||
uses: actions/configure-pages@v3
|
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b
|
||||||
- name: Build with Jekyll
|
- name: Build with Jekyll
|
||||||
run: cd ${{ github.workspace }}/docs && bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
|
run: cd ${{ github.workspace }}/docs && bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
|
||||||
env:
|
env:
|
||||||
@@ -69,12 +69,12 @@ jobs:
|
|||||||
uses: ./.github/actions/build-dependencies
|
uses: ./.github/actions/build-dependencies
|
||||||
- name: Buld Rust docs
|
- name: Buld Rust docs
|
||||||
run: |
|
run: |
|
||||||
rustup toolchain install ${{ steps.nightly.outputs.version }} --profile minimal -t wasm32-unknown-unknown -c rust-docs
|
rustup toolchain install ${{ steps.nightly.outputs.version }} --profile minimal -t wasm32v1-none -c rust-docs
|
||||||
RUSTDOCFLAGS="--cfg docsrs" cargo +${{ steps.nightly.outputs.version }} doc --workspace --all-features
|
RUSTDOCFLAGS="--cfg docsrs" cargo +${{ steps.nightly.outputs.version }} doc --workspace --no-deps --all-features
|
||||||
mv target/doc docs/_site/rust
|
mv target/doc docs/_site/rust
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-pages-artifact@v3
|
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b
|
||||||
with:
|
with:
|
||||||
path: "docs/_site/"
|
path: "docs/_site/"
|
||||||
|
|
||||||
@@ -88,4 +88,4 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v4
|
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e
|
||||||
|
|||||||
33
.github/workflows/tests.yml
vendored
33
.github/workflows/tests.yml
vendored
@@ -61,6 +61,7 @@ jobs:
|
|||||||
-p serai-monero-processor \
|
-p serai-monero-processor \
|
||||||
-p tendermint-machine \
|
-p tendermint-machine \
|
||||||
-p tributary-sdk \
|
-p tributary-sdk \
|
||||||
|
-p serai-cosign-types \
|
||||||
-p serai-cosign \
|
-p serai-cosign \
|
||||||
-p serai-coordinator-substrate \
|
-p serai-coordinator-substrate \
|
||||||
-p serai-coordinator-tributary \
|
-p serai-coordinator-tributary \
|
||||||
@@ -82,23 +83,20 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features \
|
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features \
|
||||||
-p serai-primitives \
|
-p serai-primitives \
|
||||||
-p serai-coins-primitives \
|
|
||||||
-p serai-coins-pallet \
|
|
||||||
-p serai-dex-pallet \
|
|
||||||
-p serai-validator-sets-primitives \
|
|
||||||
-p serai-validator-sets-pallet \
|
|
||||||
-p serai-genesis-liquidity-primitives \
|
|
||||||
-p serai-genesis-liquidity-pallet \
|
|
||||||
-p serai-emissions-primitives \
|
|
||||||
-p serai-emissions-pallet \
|
|
||||||
-p serai-economic-security-pallet \
|
|
||||||
-p serai-in-instructions-primitives \
|
|
||||||
-p serai-in-instructions-pallet \
|
|
||||||
-p serai-signals-primitives \
|
|
||||||
-p serai-signals-pallet \
|
|
||||||
-p serai-abi \
|
-p serai-abi \
|
||||||
|
-p substrate-median \
|
||||||
|
-p serai-core-pallet \
|
||||||
|
-p serai-coins-pallet \
|
||||||
|
-p serai-validator-sets-pallet \
|
||||||
|
-p serai-signals-pallet \
|
||||||
|
-p serai-dex-pallet \
|
||||||
|
-p serai-genesis-liquidity-pallet \
|
||||||
|
-p serai-economic-security-pallet \
|
||||||
|
-p serai-emissions-pallet \
|
||||||
|
-p serai-in-instructions-pallet \
|
||||||
-p serai-runtime \
|
-p serai-runtime \
|
||||||
-p serai-node
|
-p serai-node
|
||||||
|
-p serai-substrate-tests
|
||||||
|
|
||||||
test-serai-client:
|
test-serai-client:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -109,4 +107,9 @@ jobs:
|
|||||||
uses: ./.github/actions/build-dependencies
|
uses: ./.github/actions/build-dependencies
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client
|
run: |
|
||||||
|
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-serai
|
||||||
|
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-bitcoin
|
||||||
|
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-ethereum
|
||||||
|
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-monero
|
||||||
|
GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client
|
||||||
|
|||||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,7 +1,13 @@
|
|||||||
target
|
target
|
||||||
|
|
||||||
|
# Don't commit any `Cargo.lock` which aren't the workspace's
|
||||||
|
Cargo.lock
|
||||||
|
!/Cargo.lock
|
||||||
|
|
||||||
|
# Don't commit any `Dockerfile`, as they're auto-generated, except the only one which isn't
|
||||||
Dockerfile
|
Dockerfile
|
||||||
Dockerfile.fast-epoch
|
|
||||||
!orchestration/runtime/Dockerfile
|
!orchestration/runtime/Dockerfile
|
||||||
|
|
||||||
.test-logs
|
.test-logs
|
||||||
|
|
||||||
.vscode
|
.vscode
|
||||||
|
|||||||
7955
Cargo.lock
generated
7955
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
183
Cargo.toml
183
Cargo.toml
@@ -1,20 +1,6 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = [
|
members = [
|
||||||
# Version patches
|
|
||||||
"patches/parking_lot_core",
|
|
||||||
"patches/parking_lot",
|
|
||||||
"patches/zstd",
|
|
||||||
"patches/rocksdb",
|
|
||||||
|
|
||||||
# std patches
|
|
||||||
"patches/matches",
|
|
||||||
"patches/is-terminal",
|
|
||||||
|
|
||||||
# Rewrites/redirects
|
|
||||||
"patches/option-ext",
|
|
||||||
"patches/directories-next",
|
|
||||||
|
|
||||||
"common/std-shims",
|
"common/std-shims",
|
||||||
"common/zalloc",
|
"common/zalloc",
|
||||||
"common/patchable-async-sleep",
|
"common/patchable-async-sleep",
|
||||||
@@ -29,19 +15,21 @@ members = [
|
|||||||
"crypto/dalek-ff-group",
|
"crypto/dalek-ff-group",
|
||||||
"crypto/ed448",
|
"crypto/ed448",
|
||||||
"crypto/ciphersuite",
|
"crypto/ciphersuite",
|
||||||
|
"crypto/ciphersuite/kp256",
|
||||||
|
|
||||||
"crypto/multiexp",
|
"crypto/multiexp",
|
||||||
"crypto/schnorr",
|
"crypto/schnorr",
|
||||||
"crypto/dleq",
|
|
||||||
|
|
||||||
"crypto/evrf/secq256k1",
|
"crypto/prime-field",
|
||||||
"crypto/evrf/embedwards25519",
|
"crypto/short-weierstrass",
|
||||||
"crypto/evrf/generalized-bulletproofs",
|
"crypto/secq256k1",
|
||||||
"crypto/evrf/circuit-abstraction",
|
"crypto/embedwards25519",
|
||||||
"crypto/evrf/divisors",
|
|
||||||
"crypto/evrf/ec-gadgets",
|
|
||||||
|
|
||||||
"crypto/dkg",
|
"crypto/dkg",
|
||||||
|
"crypto/dkg/recovery",
|
||||||
|
"crypto/dkg/dealer",
|
||||||
|
"crypto/dkg/musig",
|
||||||
|
"crypto/dkg/evrf",
|
||||||
"crypto/frost",
|
"crypto/frost",
|
||||||
"crypto/schnorrkel",
|
"crypto/schnorrkel",
|
||||||
|
|
||||||
@@ -52,20 +40,6 @@ members = [
|
|||||||
"networks/ethereum/alloy-simple-request-transport",
|
"networks/ethereum/alloy-simple-request-transport",
|
||||||
"networks/ethereum/relayer",
|
"networks/ethereum/relayer",
|
||||||
|
|
||||||
"networks/monero/io",
|
|
||||||
"networks/monero/generators",
|
|
||||||
"networks/monero/primitives",
|
|
||||||
"networks/monero/ringct/mlsag",
|
|
||||||
"networks/monero/ringct/clsag",
|
|
||||||
"networks/monero/ringct/borromean",
|
|
||||||
"networks/monero/ringct/bulletproofs",
|
|
||||||
"networks/monero",
|
|
||||||
"networks/monero/rpc",
|
|
||||||
"networks/monero/rpc/simple-request",
|
|
||||||
"networks/monero/wallet/address",
|
|
||||||
"networks/monero/wallet",
|
|
||||||
"networks/monero/verify-chain",
|
|
||||||
|
|
||||||
"message-queue",
|
"message-queue",
|
||||||
|
|
||||||
"processor/messages",
|
"processor/messages",
|
||||||
@@ -88,13 +62,14 @@ members = [
|
|||||||
"processor/ethereum/primitives",
|
"processor/ethereum/primitives",
|
||||||
"processor/ethereum/test-primitives",
|
"processor/ethereum/test-primitives",
|
||||||
"processor/ethereum/deployer",
|
"processor/ethereum/deployer",
|
||||||
"processor/ethereum/router",
|
|
||||||
"processor/ethereum/erc20",
|
"processor/ethereum/erc20",
|
||||||
|
"processor/ethereum/router",
|
||||||
"processor/ethereum",
|
"processor/ethereum",
|
||||||
"processor/monero",
|
"processor/monero",
|
||||||
|
|
||||||
"coordinator/tributary-sdk/tendermint",
|
"coordinator/tributary-sdk/tendermint",
|
||||||
"coordinator/tributary-sdk",
|
"coordinator/tributary-sdk",
|
||||||
|
"coordinator/cosign/types",
|
||||||
"coordinator/cosign",
|
"coordinator/cosign",
|
||||||
"coordinator/substrate",
|
"coordinator/substrate",
|
||||||
"coordinator/tributary",
|
"coordinator/tributary",
|
||||||
@@ -103,34 +78,27 @@ members = [
|
|||||||
"coordinator",
|
"coordinator",
|
||||||
|
|
||||||
"substrate/primitives",
|
"substrate/primitives",
|
||||||
|
|
||||||
"substrate/coins/primitives",
|
|
||||||
"substrate/coins/pallet",
|
|
||||||
|
|
||||||
"substrate/dex/pallet",
|
|
||||||
|
|
||||||
"substrate/validator-sets/primitives",
|
|
||||||
"substrate/validator-sets/pallet",
|
|
||||||
|
|
||||||
"substrate/genesis-liquidity/primitives",
|
|
||||||
"substrate/genesis-liquidity/pallet",
|
|
||||||
|
|
||||||
"substrate/emissions/primitives",
|
|
||||||
"substrate/emissions/pallet",
|
|
||||||
|
|
||||||
"substrate/economic-security/pallet",
|
|
||||||
|
|
||||||
"substrate/in-instructions/primitives",
|
|
||||||
"substrate/in-instructions/pallet",
|
|
||||||
|
|
||||||
"substrate/signals/primitives",
|
|
||||||
"substrate/signals/pallet",
|
|
||||||
|
|
||||||
"substrate/abi",
|
"substrate/abi",
|
||||||
|
|
||||||
|
"substrate/median",
|
||||||
|
|
||||||
|
"substrate/core",
|
||||||
|
"substrate/coins",
|
||||||
|
"substrate/validator-sets",
|
||||||
|
"substrate/signals",
|
||||||
|
"substrate/dex",
|
||||||
|
"substrate/genesis-liquidity",
|
||||||
|
"substrate/economic-security",
|
||||||
|
"substrate/emissions",
|
||||||
|
"substrate/in-instructions",
|
||||||
|
|
||||||
"substrate/runtime",
|
"substrate/runtime",
|
||||||
"substrate/node",
|
"substrate/node",
|
||||||
|
|
||||||
|
"substrate/client/serai",
|
||||||
|
"substrate/client/bitcoin",
|
||||||
|
"substrate/client/ethereum",
|
||||||
|
"substrate/client/monero",
|
||||||
"substrate/client",
|
"substrate/client",
|
||||||
|
|
||||||
"orchestration",
|
"orchestration",
|
||||||
@@ -143,60 +111,94 @@ members = [
|
|||||||
"tests/message-queue",
|
"tests/message-queue",
|
||||||
# TODO "tests/processor",
|
# TODO "tests/processor",
|
||||||
# TODO "tests/coordinator",
|
# TODO "tests/coordinator",
|
||||||
|
"tests/substrate",
|
||||||
# TODO "tests/full-stack",
|
# TODO "tests/full-stack",
|
||||||
"tests/reproducible-runtime",
|
"tests/reproducible-runtime",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[profile.dev.package]
|
||||||
# Always compile Monero (and a variety of dependencies) with optimizations due
|
# Always compile Monero (and a variety of dependencies) with optimizations due
|
||||||
# to the extensive operations required for Bulletproofs
|
# to the extensive operations required for Bulletproofs
|
||||||
[profile.dev.package]
|
|
||||||
subtle = { opt-level = 3 }
|
subtle = { opt-level = 3 }
|
||||||
|
|
||||||
|
sha3 = { opt-level = 3 }
|
||||||
|
blake2 = { opt-level = 3 }
|
||||||
|
|
||||||
ff = { opt-level = 3 }
|
ff = { opt-level = 3 }
|
||||||
group = { opt-level = 3 }
|
group = { opt-level = 3 }
|
||||||
|
|
||||||
crypto-bigint = { opt-level = 3 }
|
crypto-bigint = { opt-level = 3 }
|
||||||
secp256k1 = { opt-level = 3 }
|
|
||||||
curve25519-dalek = { opt-level = 3 }
|
curve25519-dalek = { opt-level = 3 }
|
||||||
dalek-ff-group = { opt-level = 3 }
|
dalek-ff-group = { opt-level = 3 }
|
||||||
minimal-ed448 = { opt-level = 3 }
|
|
||||||
|
|
||||||
multiexp = { opt-level = 3 }
|
multiexp = { opt-level = 3 }
|
||||||
|
|
||||||
|
monero-io = { opt-level = 3 }
|
||||||
|
monero-primitives = { opt-level = 3 }
|
||||||
|
monero-ed25519 = { opt-level = 3 }
|
||||||
|
monero-mlsag = { opt-level = 3 }
|
||||||
|
monero-clsag = { opt-level = 3 }
|
||||||
|
monero-borromean = { opt-level = 3 }
|
||||||
|
monero-bulletproofs-generators = { opt-level = 3 }
|
||||||
|
monero-bulletproofs = {opt-level = 3 }
|
||||||
|
monero-oxide = { opt-level = 3 }
|
||||||
|
|
||||||
|
# Always compile the eVRF DKG tree with optimizations as well
|
||||||
|
secp256k1 = { opt-level = 3 }
|
||||||
secq256k1 = { opt-level = 3 }
|
secq256k1 = { opt-level = 3 }
|
||||||
embedwards25519 = { opt-level = 3 }
|
embedwards25519 = { opt-level = 3 }
|
||||||
generalized-bulletproofs = { opt-level = 3 }
|
generalized-bulletproofs = { opt-level = 3 }
|
||||||
generalized-bulletproofs-circuit-abstraction = { opt-level = 3 }
|
generalized-bulletproofs-circuit-abstraction = { opt-level = 3 }
|
||||||
ec-divisors = { opt-level = 3 }
|
|
||||||
generalized-bulletproofs-ec-gadgets = { opt-level = 3 }
|
generalized-bulletproofs-ec-gadgets = { opt-level = 3 }
|
||||||
|
|
||||||
dkg = { opt-level = 3 }
|
# revm also effectively requires being built with optimizations
|
||||||
|
revm = { opt-level = 3 }
|
||||||
monero-generators = { opt-level = 3 }
|
revm-bytecode = { opt-level = 3 }
|
||||||
monero-borromean = { opt-level = 3 }
|
revm-context = { opt-level = 3 }
|
||||||
monero-bulletproofs = { opt-level = 3 }
|
revm-context-interface = { opt-level = 3 }
|
||||||
monero-mlsag = { opt-level = 3 }
|
revm-database = { opt-level = 3 }
|
||||||
monero-clsag = { opt-level = 3 }
|
revm-database-interface = { opt-level = 3 }
|
||||||
|
revm-handler = { opt-level = 3 }
|
||||||
|
revm-inspector = { opt-level = 3 }
|
||||||
|
revm-interpreter = { opt-level = 3 }
|
||||||
|
revm-precompile = { opt-level = 3 }
|
||||||
|
revm-primitives = { opt-level = 3 }
|
||||||
|
revm-state = { opt-level = 3 }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = "unwind"
|
panic = "unwind"
|
||||||
|
overflow-checks = true
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
# Point to empty crates for crates unused within in our tree
|
||||||
|
alloy-eip2124 = { path = "patches/ethereum/alloy-eip2124" }
|
||||||
|
ark-ff-3 = { package = "ark-ff", path = "patches/ethereum/ark-ff-0.3" }
|
||||||
|
ark-ff-4 = { package = "ark-ff", path = "patches/ethereum/ark-ff-0.4" }
|
||||||
|
c-kzg = { path = "patches/ethereum/c-kzg" }
|
||||||
|
secp256k1-30 = { package = "secp256k1", path = "patches/ethereum/secp256k1-30" }
|
||||||
|
|
||||||
|
# Dependencies from monero-oxide which originate from within our own tree, potentially shimmed to account for deviations since publishing
|
||||||
|
std-shims = { path = "patches/std-shims" }
|
||||||
|
simple-request = { path = "patches/simple-request" }
|
||||||
|
multiexp = { path = "crypto/multiexp" }
|
||||||
|
flexible-transcript = { path = "crypto/transcript" }
|
||||||
|
ciphersuite = { path = "patches/ciphersuite" }
|
||||||
|
dalek-ff-group = { path = "patches/dalek-ff-group" }
|
||||||
|
minimal-ed448 = { path = "crypto/ed448" }
|
||||||
|
modular-frost = { path = "crypto/frost" }
|
||||||
|
|
||||||
|
# Patch due to `std` now including the required functionality
|
||||||
|
is_terminal_polyfill = { path = "./patches/is_terminal_polyfill" }
|
||||||
|
# This has a non-deprecated `std` alternative since Rust's 2024 edition
|
||||||
|
home = { path = "patches/home" }
|
||||||
|
|
||||||
|
# Updates to the latest version
|
||||||
|
darling = { path = "patches/darling" }
|
||||||
|
thiserror = { path = "patches/thiserror" }
|
||||||
|
|
||||||
# https://github.com/rust-lang-nursery/lazy-static.rs/issues/201
|
# https://github.com/rust-lang-nursery/lazy-static.rs/issues/201
|
||||||
lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev = "5735630d46572f1e5377c8f2ba0f79d18f53b10c" }
|
lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev = "5735630d46572f1e5377c8f2ba0f79d18f53b10c" }
|
||||||
|
|
||||||
parking_lot_core = { path = "patches/parking_lot_core" }
|
|
||||||
parking_lot = { path = "patches/parking_lot" }
|
|
||||||
# wasmtime pulls in an old version for this
|
|
||||||
zstd = { path = "patches/zstd" }
|
|
||||||
# Needed for WAL compression
|
|
||||||
rocksdb = { path = "patches/rocksdb" }
|
|
||||||
|
|
||||||
# is-terminal now has an std-based solution with an equivalent API
|
|
||||||
is-terminal = { path = "patches/is-terminal" }
|
|
||||||
# So does matches
|
|
||||||
matches = { path = "patches/matches" }
|
|
||||||
|
|
||||||
# directories-next was created because directories was unmaintained
|
# directories-next was created because directories was unmaintained
|
||||||
# directories-next is now unmaintained while directories is maintained
|
# directories-next is now unmaintained while directories is maintained
|
||||||
# The directories author pulls in ridiculously pointless crates and prefers
|
# The directories author pulls in ridiculously pointless crates and prefers
|
||||||
@@ -205,7 +207,19 @@ matches = { path = "patches/matches" }
|
|||||||
option-ext = { path = "patches/option-ext" }
|
option-ext = { path = "patches/option-ext" }
|
||||||
directories-next = { path = "patches/directories-next" }
|
directories-next = { path = "patches/directories-next" }
|
||||||
|
|
||||||
|
# Patch from a fork back to upstream
|
||||||
|
parity-bip39 = { path = "patches/parity-bip39" }
|
||||||
|
|
||||||
|
# Patch to include `FromUniformBytes<64>` over `Scalar`
|
||||||
|
k256 = { git = "https://github.com/kayabaNerve/elliptic-curves", rev = "4994c9ab163781a88cd4a49beae812a89a44e8c3" }
|
||||||
|
p256 = { git = "https://github.com/kayabaNerve/elliptic-curves", rev = "4994c9ab163781a88cd4a49beae812a89a44e8c3" }
|
||||||
|
|
||||||
|
# `jemalloc` conflicts with `mimalloc`, so patch to a `rocksdb` which never uses `jemalloc`
|
||||||
|
librocksdb-sys = { path = "patches/librocksdb-sys" }
|
||||||
|
|
||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
|
incompatible_msrv = "allow" # Manually verified with a GitHub workflow
|
||||||
|
manual_is_multiple_of = "allow"
|
||||||
unwrap_or_default = "allow"
|
unwrap_or_default = "allow"
|
||||||
map_unwrap_or = "allow"
|
map_unwrap_or = "allow"
|
||||||
needless_continue = "allow"
|
needless_continue = "allow"
|
||||||
@@ -247,7 +261,7 @@ redundant_closure_for_method_calls = "deny"
|
|||||||
redundant_else = "deny"
|
redundant_else = "deny"
|
||||||
string_add_assign = "deny"
|
string_add_assign = "deny"
|
||||||
string_slice = "deny"
|
string_slice = "deny"
|
||||||
unchecked_duration_subtraction = "deny"
|
unchecked_time_subtraction = "deny"
|
||||||
uninlined_format_args = "deny"
|
uninlined_format_args = "deny"
|
||||||
unnecessary_box_returns = "deny"
|
unnecessary_box_returns = "deny"
|
||||||
unnecessary_join = "deny"
|
unnecessary_join = "deny"
|
||||||
@@ -256,3 +270,6 @@ unnested_or_patterns = "deny"
|
|||||||
unused_async = "deny"
|
unused_async = "deny"
|
||||||
unused_self = "deny"
|
unused_self = "deny"
|
||||||
zero_sized_map_values = "deny"
|
zero_sized_map_values = "deny"
|
||||||
|
|
||||||
|
[workspace.lints.rust]
|
||||||
|
unused = "allow" # TODO: https://github.com/rust-lang/rust/issues/147648
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ issued at the discretion of the Immunefi program managers.
|
|||||||
- [Website](https://serai.exchange/): https://serai.exchange/
|
- [Website](https://serai.exchange/): https://serai.exchange/
|
||||||
- [Immunefi](https://immunefi.com/bounty/serai/): https://immunefi.com/bounty/serai/
|
- [Immunefi](https://immunefi.com/bounty/serai/): https://immunefi.com/bounty/serai/
|
||||||
- [Twitter](https://twitter.com/SeraiDEX): https://twitter.com/SeraiDEX
|
- [Twitter](https://twitter.com/SeraiDEX): https://twitter.com/SeraiDEX
|
||||||
- [Mastodon](https://cryptodon.lol/@serai): https://cryptodon.lol/@serai
|
|
||||||
- [Discord](https://discord.gg/mpEUtJR3vz): https://discord.gg/mpEUtJR3vz
|
- [Discord](https://discord.gg/mpEUtJR3vz): https://discord.gg/mpEUtJR3vz
|
||||||
- [Matrix](https://matrix.to/#/#serai:matrix.org): https://matrix.to/#/#serai:matrix.org
|
- [Matrix](https://matrix.to/#/#serai:matrix.org): https://matrix.to/#/#serai:matrix.org
|
||||||
- [Reddit](https://www.reddit.com/r/SeraiDEX/): https://www.reddit.com/r/SeraiDEX/
|
- [Reddit](https://www.reddit.com/r/SeraiDEX/): https://www.reddit.com/r/SeraiDEX/
|
||||||
|
|||||||
Binary file not shown.
@@ -1,427 +0,0 @@
|
|||||||
Attribution-ShareAlike 4.0 International
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
|
||||||
does not provide legal services or legal advice. Distribution of
|
|
||||||
Creative Commons public licenses does not create a lawyer-client or
|
|
||||||
other relationship. Creative Commons makes its licenses and related
|
|
||||||
information available on an "as-is" basis. Creative Commons gives no
|
|
||||||
warranties regarding its licenses, any material licensed under their
|
|
||||||
terms and conditions, or any related information. Creative Commons
|
|
||||||
disclaims all liability for damages resulting from their use to the
|
|
||||||
fullest extent possible.
|
|
||||||
|
|
||||||
Using Creative Commons Public Licenses
|
|
||||||
|
|
||||||
Creative Commons public licenses provide a standard set of terms and
|
|
||||||
conditions that creators and other rights holders may use to share
|
|
||||||
original works of authorship and other material subject to copyright
|
|
||||||
and certain other rights specified in the public license below. The
|
|
||||||
following considerations are for informational purposes only, are not
|
|
||||||
exhaustive, and do not form part of our licenses.
|
|
||||||
|
|
||||||
Considerations for licensors: Our public licenses are
|
|
||||||
intended for use by those authorized to give the public
|
|
||||||
permission to use material in ways otherwise restricted by
|
|
||||||
copyright and certain other rights. Our licenses are
|
|
||||||
irrevocable. Licensors should read and understand the terms
|
|
||||||
and conditions of the license they choose before applying it.
|
|
||||||
Licensors should also secure all rights necessary before
|
|
||||||
applying our licenses so that the public can reuse the
|
|
||||||
material as expected. Licensors should clearly mark any
|
|
||||||
material not subject to the license. This includes other CC-
|
|
||||||
licensed material, or material used under an exception or
|
|
||||||
limitation to copyright. More considerations for licensors:
|
|
||||||
wiki.creativecommons.org/Considerations_for_licensors
|
|
||||||
|
|
||||||
Considerations for the public: By using one of our public
|
|
||||||
licenses, a licensor grants the public permission to use the
|
|
||||||
licensed material under specified terms and conditions. If
|
|
||||||
the licensor's permission is not necessary for any reason--for
|
|
||||||
example, because of any applicable exception or limitation to
|
|
||||||
copyright--then that use is not regulated by the license. Our
|
|
||||||
licenses grant only permissions under copyright and certain
|
|
||||||
other rights that a licensor has authority to grant. Use of
|
|
||||||
the licensed material may still be restricted for other
|
|
||||||
reasons, including because others have copyright or other
|
|
||||||
rights in the material. A licensor may make special requests,
|
|
||||||
such as asking that all changes be marked or described.
|
|
||||||
Although not required by our licenses, you are encouraged to
|
|
||||||
respect those requests where reasonable. More considerations
|
|
||||||
for the public:
|
|
||||||
wiki.creativecommons.org/Considerations_for_licensees
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Creative Commons Attribution-ShareAlike 4.0 International Public
|
|
||||||
License
|
|
||||||
|
|
||||||
By exercising the Licensed Rights (defined below), You accept and agree
|
|
||||||
to be bound by the terms and conditions of this Creative Commons
|
|
||||||
Attribution-ShareAlike 4.0 International Public License ("Public
|
|
||||||
License"). To the extent this Public License may be interpreted as a
|
|
||||||
contract, You are granted the Licensed Rights in consideration of Your
|
|
||||||
acceptance of these terms and conditions, and the Licensor grants You
|
|
||||||
such rights in consideration of benefits the Licensor receives from
|
|
||||||
making the Licensed Material available under these terms and
|
|
||||||
conditions.
|
|
||||||
|
|
||||||
|
|
||||||
Section 1 -- Definitions.
|
|
||||||
|
|
||||||
a. Adapted Material means material subject to Copyright and Similar
|
|
||||||
Rights that is derived from or based upon the Licensed Material
|
|
||||||
and in which the Licensed Material is translated, altered,
|
|
||||||
arranged, transformed, or otherwise modified in a manner requiring
|
|
||||||
permission under the Copyright and Similar Rights held by the
|
|
||||||
Licensor. For purposes of this Public License, where the Licensed
|
|
||||||
Material is a musical work, performance, or sound recording,
|
|
||||||
Adapted Material is always produced where the Licensed Material is
|
|
||||||
synched in timed relation with a moving image.
|
|
||||||
|
|
||||||
b. Adapter's License means the license You apply to Your Copyright
|
|
||||||
and Similar Rights in Your contributions to Adapted Material in
|
|
||||||
accordance with the terms and conditions of this Public License.
|
|
||||||
|
|
||||||
c. BY-SA Compatible License means a license listed at
|
|
||||||
creativecommons.org/compatiblelicenses, approved by Creative
|
|
||||||
Commons as essentially the equivalent of this Public License.
|
|
||||||
|
|
||||||
d. Copyright and Similar Rights means copyright and/or similar rights
|
|
||||||
closely related to copyright including, without limitation,
|
|
||||||
performance, broadcast, sound recording, and Sui Generis Database
|
|
||||||
Rights, without regard to how the rights are labeled or
|
|
||||||
categorized. For purposes of this Public License, the rights
|
|
||||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
|
||||||
Rights.
|
|
||||||
|
|
||||||
e. Effective Technological Measures means those measures that, in the
|
|
||||||
absence of proper authority, may not be circumvented under laws
|
|
||||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
|
||||||
Treaty adopted on December 20, 1996, and/or similar international
|
|
||||||
agreements.
|
|
||||||
|
|
||||||
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
|
||||||
any other exception or limitation to Copyright and Similar Rights
|
|
||||||
that applies to Your use of the Licensed Material.
|
|
||||||
|
|
||||||
g. License Elements means the license attributes listed in the name
|
|
||||||
of a Creative Commons Public License. The License Elements of this
|
|
||||||
Public License are Attribution and ShareAlike.
|
|
||||||
|
|
||||||
h. Licensed Material means the artistic or literary work, database,
|
|
||||||
or other material to which the Licensor applied this Public
|
|
||||||
License.
|
|
||||||
|
|
||||||
i. Licensed Rights means the rights granted to You subject to the
|
|
||||||
terms and conditions of this Public License, which are limited to
|
|
||||||
all Copyright and Similar Rights that apply to Your use of the
|
|
||||||
Licensed Material and that the Licensor has authority to license.
|
|
||||||
|
|
||||||
j. Licensor means the individual(s) or entity(ies) granting rights
|
|
||||||
under this Public License.
|
|
||||||
|
|
||||||
k. Share means to provide material to the public by any means or
|
|
||||||
process that requires permission under the Licensed Rights, such
|
|
||||||
as reproduction, public display, public performance, distribution,
|
|
||||||
dissemination, communication, or importation, and to make material
|
|
||||||
available to the public including in ways that members of the
|
|
||||||
public may access the material from a place and at a time
|
|
||||||
individually chosen by them.
|
|
||||||
|
|
||||||
l. Sui Generis Database Rights means rights other than copyright
|
|
||||||
resulting from Directive 96/9/EC of the European Parliament and of
|
|
||||||
the Council of 11 March 1996 on the legal protection of databases,
|
|
||||||
as amended and/or succeeded, as well as other essentially
|
|
||||||
equivalent rights anywhere in the world.
|
|
||||||
|
|
||||||
m. You means the individual or entity exercising the Licensed Rights
|
|
||||||
under this Public License. Your has a corresponding meaning.
|
|
||||||
|
|
||||||
|
|
||||||
Section 2 -- Scope.
|
|
||||||
|
|
||||||
a. License grant.
|
|
||||||
|
|
||||||
1. Subject to the terms and conditions of this Public License,
|
|
||||||
the Licensor hereby grants You a worldwide, royalty-free,
|
|
||||||
non-sublicensable, non-exclusive, irrevocable license to
|
|
||||||
exercise the Licensed Rights in the Licensed Material to:
|
|
||||||
|
|
||||||
a. reproduce and Share the Licensed Material, in whole or
|
|
||||||
in part; and
|
|
||||||
|
|
||||||
b. produce, reproduce, and Share Adapted Material.
|
|
||||||
|
|
||||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
|
||||||
Exceptions and Limitations apply to Your use, this Public
|
|
||||||
License does not apply, and You do not need to comply with
|
|
||||||
its terms and conditions.
|
|
||||||
|
|
||||||
3. Term. The term of this Public License is specified in Section
|
|
||||||
6(a).
|
|
||||||
|
|
||||||
4. Media and formats; technical modifications allowed. The
|
|
||||||
Licensor authorizes You to exercise the Licensed Rights in
|
|
||||||
all media and formats whether now known or hereafter created,
|
|
||||||
and to make technical modifications necessary to do so. The
|
|
||||||
Licensor waives and/or agrees not to assert any right or
|
|
||||||
authority to forbid You from making technical modifications
|
|
||||||
necessary to exercise the Licensed Rights, including
|
|
||||||
technical modifications necessary to circumvent Effective
|
|
||||||
Technological Measures. For purposes of this Public License,
|
|
||||||
simply making modifications authorized by this Section 2(a)
|
|
||||||
(4) never produces Adapted Material.
|
|
||||||
|
|
||||||
5. Downstream recipients.
|
|
||||||
|
|
||||||
a. Offer from the Licensor -- Licensed Material. Every
|
|
||||||
recipient of the Licensed Material automatically
|
|
||||||
receives an offer from the Licensor to exercise the
|
|
||||||
Licensed Rights under the terms and conditions of this
|
|
||||||
Public License.
|
|
||||||
|
|
||||||
b. Additional offer from the Licensor -- Adapted Material.
|
|
||||||
Every recipient of Adapted Material from You
|
|
||||||
automatically receives an offer from the Licensor to
|
|
||||||
exercise the Licensed Rights in the Adapted Material
|
|
||||||
under the conditions of the Adapter's License You apply.
|
|
||||||
|
|
||||||
c. No downstream restrictions. You may not offer or impose
|
|
||||||
any additional or different terms or conditions on, or
|
|
||||||
apply any Effective Technological Measures to, the
|
|
||||||
Licensed Material if doing so restricts exercise of the
|
|
||||||
Licensed Rights by any recipient of the Licensed
|
|
||||||
Material.
|
|
||||||
|
|
||||||
6. No endorsement. Nothing in this Public License constitutes or
|
|
||||||
may be construed as permission to assert or imply that You
|
|
||||||
are, or that Your use of the Licensed Material is, connected
|
|
||||||
with, or sponsored, endorsed, or granted official status by,
|
|
||||||
the Licensor or others designated to receive attribution as
|
|
||||||
provided in Section 3(a)(1)(A)(i).
|
|
||||||
|
|
||||||
b. Other rights.
|
|
||||||
|
|
||||||
1. Moral rights, such as the right of integrity, are not
|
|
||||||
licensed under this Public License, nor are publicity,
|
|
||||||
privacy, and/or other similar personality rights; however, to
|
|
||||||
the extent possible, the Licensor waives and/or agrees not to
|
|
||||||
assert any such rights held by the Licensor to the limited
|
|
||||||
extent necessary to allow You to exercise the Licensed
|
|
||||||
Rights, but not otherwise.
|
|
||||||
|
|
||||||
2. Patent and trademark rights are not licensed under this
|
|
||||||
Public License.
|
|
||||||
|
|
||||||
3. To the extent possible, the Licensor waives any right to
|
|
||||||
collect royalties from You for the exercise of the Licensed
|
|
||||||
Rights, whether directly or through a collecting society
|
|
||||||
under any voluntary or waivable statutory or compulsory
|
|
||||||
licensing scheme. In all other cases the Licensor expressly
|
|
||||||
reserves any right to collect such royalties.
|
|
||||||
|
|
||||||
|
|
||||||
Section 3 -- License Conditions.
|
|
||||||
|
|
||||||
Your exercise of the Licensed Rights is expressly made subject to the
|
|
||||||
following conditions.
|
|
||||||
|
|
||||||
a. Attribution.
|
|
||||||
|
|
||||||
1. If You Share the Licensed Material (including in modified
|
|
||||||
form), You must:
|
|
||||||
|
|
||||||
a. retain the following if it is supplied by the Licensor
|
|
||||||
with the Licensed Material:
|
|
||||||
|
|
||||||
i. identification of the creator(s) of the Licensed
|
|
||||||
Material and any others designated to receive
|
|
||||||
attribution, in any reasonable manner requested by
|
|
||||||
the Licensor (including by pseudonym if
|
|
||||||
designated);
|
|
||||||
|
|
||||||
ii. a copyright notice;
|
|
||||||
|
|
||||||
iii. a notice that refers to this Public License;
|
|
||||||
|
|
||||||
iv. a notice that refers to the disclaimer of
|
|
||||||
warranties;
|
|
||||||
|
|
||||||
v. a URI or hyperlink to the Licensed Material to the
|
|
||||||
extent reasonably practicable;
|
|
||||||
|
|
||||||
b. indicate if You modified the Licensed Material and
|
|
||||||
retain an indication of any previous modifications; and
|
|
||||||
|
|
||||||
c. indicate the Licensed Material is licensed under this
|
|
||||||
Public License, and include the text of, or the URI or
|
|
||||||
hyperlink to, this Public License.
|
|
||||||
|
|
||||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
|
||||||
reasonable manner based on the medium, means, and context in
|
|
||||||
which You Share the Licensed Material. For example, it may be
|
|
||||||
reasonable to satisfy the conditions by providing a URI or
|
|
||||||
hyperlink to a resource that includes the required
|
|
||||||
information.
|
|
||||||
|
|
||||||
3. If requested by the Licensor, You must remove any of the
|
|
||||||
information required by Section 3(a)(1)(A) to the extent
|
|
||||||
reasonably practicable.
|
|
||||||
|
|
||||||
b. ShareAlike.
|
|
||||||
|
|
||||||
In addition to the conditions in Section 3(a), if You Share
|
|
||||||
Adapted Material You produce, the following conditions also apply.
|
|
||||||
|
|
||||||
1. The Adapter's License You apply must be a Creative Commons
|
|
||||||
license with the same License Elements, this version or
|
|
||||||
later, or a BY-SA Compatible License.
|
|
||||||
|
|
||||||
2. You must include the text of, or the URI or hyperlink to, the
|
|
||||||
Adapter's License You apply. You may satisfy this condition
|
|
||||||
in any reasonable manner based on the medium, means, and
|
|
||||||
context in which You Share Adapted Material.
|
|
||||||
|
|
||||||
3. You may not offer or impose any additional or different terms
|
|
||||||
or conditions on, or apply any Effective Technological
|
|
||||||
Measures to, Adapted Material that restrict exercise of the
|
|
||||||
rights granted under the Adapter's License You apply.
|
|
||||||
|
|
||||||
|
|
||||||
Section 4 -- Sui Generis Database Rights.
|
|
||||||
|
|
||||||
Where the Licensed Rights include Sui Generis Database Rights that
|
|
||||||
apply to Your use of the Licensed Material:
|
|
||||||
|
|
||||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
|
||||||
to extract, reuse, reproduce, and Share all or a substantial
|
|
||||||
portion of the contents of the database;
|
|
||||||
|
|
||||||
b. if You include all or a substantial portion of the database
|
|
||||||
contents in a database in which You have Sui Generis Database
|
|
||||||
Rights, then the database in which You have Sui Generis Database
|
|
||||||
Rights (but not its individual contents) is Adapted Material,
|
|
||||||
|
|
||||||
including for purposes of Section 3(b); and
|
|
||||||
c. You must comply with the conditions in Section 3(a) if You Share
|
|
||||||
all or a substantial portion of the contents of the database.
|
|
||||||
|
|
||||||
For the avoidance of doubt, this Section 4 supplements and does not
|
|
||||||
replace Your obligations under this Public License where the Licensed
|
|
||||||
Rights include other Copyright and Similar Rights.
|
|
||||||
|
|
||||||
|
|
||||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
|
||||||
|
|
||||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
|
||||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
|
||||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
|
||||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
|
||||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
|
||||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
|
||||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
|
||||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
|
||||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
|
||||||
|
|
||||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
|
||||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
|
||||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
|
||||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
|
||||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
|
||||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
|
||||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
|
||||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
|
||||||
|
|
||||||
c. The disclaimer of warranties and limitation of liability provided
|
|
||||||
above shall be interpreted in a manner that, to the extent
|
|
||||||
possible, most closely approximates an absolute disclaimer and
|
|
||||||
waiver of all liability.
|
|
||||||
|
|
||||||
|
|
||||||
Section 6 -- Term and Termination.
|
|
||||||
|
|
||||||
a. This Public License applies for the term of the Copyright and
|
|
||||||
Similar Rights licensed here. However, if You fail to comply with
|
|
||||||
this Public License, then Your rights under this Public License
|
|
||||||
terminate automatically.
|
|
||||||
|
|
||||||
b. Where Your right to use the Licensed Material has terminated under
|
|
||||||
Section 6(a), it reinstates:
|
|
||||||
|
|
||||||
1. automatically as of the date the violation is cured, provided
|
|
||||||
it is cured within 30 days of Your discovery of the
|
|
||||||
violation; or
|
|
||||||
|
|
||||||
2. upon express reinstatement by the Licensor.
|
|
||||||
|
|
||||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
|
||||||
right the Licensor may have to seek remedies for Your violations
|
|
||||||
of this Public License.
|
|
||||||
|
|
||||||
c. For the avoidance of doubt, the Licensor may also offer the
|
|
||||||
Licensed Material under separate terms or conditions or stop
|
|
||||||
distributing the Licensed Material at any time; however, doing so
|
|
||||||
will not terminate this Public License.
|
|
||||||
|
|
||||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
|
||||||
License.
|
|
||||||
|
|
||||||
|
|
||||||
Section 7 -- Other Terms and Conditions.
|
|
||||||
|
|
||||||
a. The Licensor shall not be bound by any additional or different
|
|
||||||
terms or conditions communicated by You unless expressly agreed.
|
|
||||||
|
|
||||||
b. Any arrangements, understandings, or agreements regarding the
|
|
||||||
Licensed Material not stated herein are separate from and
|
|
||||||
independent of the terms and conditions of this Public License.
|
|
||||||
|
|
||||||
|
|
||||||
Section 8 -- Interpretation.
|
|
||||||
|
|
||||||
a. For the avoidance of doubt, this Public License does not, and
|
|
||||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
|
||||||
conditions on any use of the Licensed Material that could lawfully
|
|
||||||
be made without permission under this Public License.
|
|
||||||
|
|
||||||
b. To the extent possible, if any provision of this Public License is
|
|
||||||
deemed unenforceable, it shall be automatically reformed to the
|
|
||||||
minimum extent necessary to make it enforceable. If the provision
|
|
||||||
cannot be reformed, it shall be severed from this Public License
|
|
||||||
without affecting the enforceability of the remaining terms and
|
|
||||||
conditions.
|
|
||||||
|
|
||||||
c. No term or condition of this Public License will be waived and no
|
|
||||||
failure to comply consented to unless expressly agreed to by the
|
|
||||||
Licensor.
|
|
||||||
|
|
||||||
d. Nothing in this Public License constitutes or may be interpreted
|
|
||||||
as a limitation upon, or waiver of, any privileges and immunities
|
|
||||||
that apply to the Licensor or You, including from the legal
|
|
||||||
processes of any jurisdiction or authority.
|
|
||||||
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Creative Commons is not a party to its public
|
|
||||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
|
||||||
its public licenses to material it publishes and in those instances
|
|
||||||
will be considered the “Licensor.” The text of the Creative Commons
|
|
||||||
public licenses is dedicated to the public domain under the CC0 Public
|
|
||||||
Domain Dedication. Except for the limited purpose of indicating that
|
|
||||||
material is shared under a Creative Commons public license or as
|
|
||||||
otherwise permitted by the Creative Commons policies published at
|
|
||||||
creativecommons.org/policies, Creative Commons does not authorize the
|
|
||||||
use of the trademark "Creative Commons" or any other trademark or logo
|
|
||||||
of Creative Commons without its prior written consent including,
|
|
||||||
without limitation, in connection with any unauthorized modifications
|
|
||||||
to any of its public licenses or any other arrangements,
|
|
||||||
understandings, or agreements concerning use of licensed material. For
|
|
||||||
the avoidance of doubt, this paragraph does not form part of the
|
|
||||||
public licenses.
|
|
||||||
|
|
||||||
Creative Commons may be contacted at creativecommons.org.
|
|
||||||
@@ -11,4 +11,4 @@ It is encompassing up to commit 4e0c58464fc4673623938335f06e2e9ea96ca8dd.
|
|||||||
|
|
||||||
Please see
|
Please see
|
||||||
https://github.com/trailofbits/publications/blob/30c4fa3ebf39ff8e4d23ba9567344ec9691697b5/reviews/2025-04-serai-dex-security-review.pdf
|
https://github.com/trailofbits/publications/blob/30c4fa3ebf39ff8e4d23ba9567344ec9691697b5/reviews/2025-04-serai-dex-security-review.pdf
|
||||||
for provenance.
|
for the actual report.
|
||||||
|
|||||||
50
audits/crypto/dkg/evrf/README.md
Normal file
50
audits/crypto/dkg/evrf/README.md
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# eVRF DKG
|
||||||
|
|
||||||
|
In 2024, the [eVRF paper](https://eprint.iacr.org/2024/397) was published to
|
||||||
|
the IACR preprint server. Within it was a one-round unbiased DKG and a
|
||||||
|
one-round unbiased threshold DKG. Unfortunately, both simply describe
|
||||||
|
communication of the secret shares as 'Alice sends $s_b$ to Bob'. This causes,
|
||||||
|
in practice, the need for an additional round of communication to occur where
|
||||||
|
all participants confirm they received their secret shares.
|
||||||
|
|
||||||
|
Within Serai, it was posited to use the same premises as the DDH eVRF itself to
|
||||||
|
achieve a verifiable encryption scheme. This allows the secret shares to be
|
||||||
|
posted to any 'bulletin board' (such as a blockchain) and for all observers to
|
||||||
|
confirm:
|
||||||
|
|
||||||
|
- A participant participated
|
||||||
|
- The secret shares sent can be received by the intended recipient so long as
|
||||||
|
they can access the bulletin board
|
||||||
|
|
||||||
|
Additionally, Serai desired a robust scheme (albeit with an biased key as the
|
||||||
|
output, which is fine for our purposes). Accordingly, our implementation
|
||||||
|
instantiates the threshold eVRF DKG from the eVRF paper, with our own proposal
|
||||||
|
for verifiable encryption, with the caller allowed to decide the set of
|
||||||
|
participants. They may:
|
||||||
|
|
||||||
|
- Select everyone, collapsing to the non-threshold unbiased DKG from the eVRF
|
||||||
|
paper
|
||||||
|
- Select a pre-determined set, collapsing to the threshold unbaised DKG from
|
||||||
|
the eVRF paper
|
||||||
|
- Select a post-determined set (with any solution for the Common Subset
|
||||||
|
problem), allowing achieving a robust threshold biased DKG
|
||||||
|
|
||||||
|
Note that the eVRF paper proposes using the eVRF to sample coefficients yet
|
||||||
|
this is unnecessary when the resulting key will be biased. Any proof of
|
||||||
|
knowledge for the coefficients, as necessary for their extraction within the
|
||||||
|
security proofs, would be sufficient.
|
||||||
|
|
||||||
|
MAGIC Grants contracted HashCloak to formalize Serai's proposal for a DKG and
|
||||||
|
provide proofs for its security. This resulted in
|
||||||
|
[this paper](<./Security Proofs.pdf>).
|
||||||
|
|
||||||
|
Our implementation itself is then built on top of the audited
|
||||||
|
[`generalized-bulletproofs`](https://github.com/kayabaNerve/monero-oxide/tree/generalized-bulletproofs/audits/crypto/generalized-bulletproofs)
|
||||||
|
and
|
||||||
|
[`generalized-bulletproofs-ec-gadgets`](https://github.com/monero-oxide/monero-oxide/tree/fcmp%2B%2B/audits/fcmps).
|
||||||
|
|
||||||
|
Note we do not use the originally premised DDH eVRF yet the one premised on
|
||||||
|
elliptic curve divisors, the methodology of which is commented on
|
||||||
|
[here](https://github.com/monero-oxide/monero-oxide/tree/fcmp%2B%2B/audits/divisors).
|
||||||
|
|
||||||
|
Our implementation itself is unaudited at this time however.
|
||||||
BIN
audits/crypto/dkg/evrf/Security Proofs.pdf
Normal file
BIN
audits/crypto/dkg/evrf/Security Proofs.pdf
Normal file
Binary file not shown.
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/common/db"
|
|||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = []
|
keywords = []
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.71"
|
rust-version = "1.77"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -17,8 +17,8 @@ rustdoc-args = ["--cfg", "docsrs"]
|
|||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parity-db = { version = "0.4", default-features = false, optional = true }
|
parity-db = { version = "0.5", default-features = false, features = ["arc"], optional = true }
|
||||||
rocksdb = { version = "0.23", default-features = false, features = ["zstd"], optional = true }
|
rocksdb = { version = "0.24", default-features = false, features = ["zstd"], optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
parity-db = ["dep:parity-db"]
|
parity-db = ["dep:parity-db"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2022-2023 Luke Parker
|
Copyright (c) 2022-2025 Luke Parker
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub fn serai_db_key(
|
|||||||
///
|
///
|
||||||
/// Creates a unit struct and a default implementation for the `key`, `get`, and `set`. The macro
|
/// Creates a unit struct and a default implementation for the `key`, `get`, and `set`. The macro
|
||||||
/// uses a syntax similar to defining a function. Parameters are concatenated to produce a key,
|
/// uses a syntax similar to defining a function. Parameters are concatenated to produce a key,
|
||||||
/// they must be `scale` encodable. The return type is used to auto encode and decode the database
|
/// they must be `borsh` serializable. The return type is used to auto (de)serialize the database
|
||||||
/// value bytes using `borsh`.
|
/// value bytes using `borsh`.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -54,11 +54,10 @@ macro_rules! create_db {
|
|||||||
)?;
|
)?;
|
||||||
impl$(<$($generic_name: $generic_type),+>)? $field_name$(<$($generic_name),+>)? {
|
impl$(<$($generic_name: $generic_type),+>)? $field_name$(<$($generic_name),+>)? {
|
||||||
pub(crate) fn key($($arg: $arg_type),*) -> Vec<u8> {
|
pub(crate) fn key($($arg: $arg_type),*) -> Vec<u8> {
|
||||||
use scale::Encode;
|
|
||||||
$crate::serai_db_key(
|
$crate::serai_db_key(
|
||||||
stringify!($db_name).as_bytes(),
|
stringify!($db_name).as_bytes(),
|
||||||
stringify!($field_name).as_bytes(),
|
stringify!($field_name).as_bytes(),
|
||||||
($($arg),*).encode()
|
&borsh::to_vec(&($($arg),*)).unwrap(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub(crate) fn set(
|
pub(crate) fn set(
|
||||||
|
|||||||
2
common/env/Cargo.toml
vendored
2
common/env/Cargo.toml
vendored
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/common/env"
|
|||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = []
|
keywords = []
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.71"
|
rust-version = "1.64"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|||||||
2
common/env/LICENSE
vendored
2
common/env/LICENSE
vendored
@@ -1,6 +1,6 @@
|
|||||||
AGPL-3.0-only license
|
AGPL-3.0-only license
|
||||||
|
|
||||||
Copyright (c) 2023 Luke Parker
|
Copyright (c) 2023-2025 Luke Parker
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License Version 3 as
|
it under the terms of the GNU Affero General Public License Version 3 as
|
||||||
|
|||||||
2
common/env/src/lib.rs
vendored
2
common/env/src/lib.rs
vendored
@@ -1,5 +1,5 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
|
||||||
// Obtain a variable from the Serai environment/secret store.
|
// Obtain a variable from the Serai environment/secret store.
|
||||||
pub fn var(variable: &str) -> Option<String> {
|
pub fn var(variable: &str) -> Option<String> {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/common/patchable-a
|
|||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = ["async", "sleep", "tokio", "smol", "async-std"]
|
keywords = ["async", "sleep", "tokio", "smol", "async-std"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.71"
|
rust-version = "1.70"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2024 Luke Parker
|
Copyright (c) 2024-2025 Luke Parker
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "simple-request"
|
name = "simple-request"
|
||||||
version = "0.1.0"
|
version = "0.3.0"
|
||||||
description = "A simple HTTP(S) request library"
|
description = "A simple HTTP(S) request library"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/serai-dex/serai/tree/develop/common/simple-request"
|
repository = "https://github.com/serai-dex/serai/tree/develop/common/request"
|
||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = ["http", "https", "async", "request", "ssl"]
|
keywords = ["http", "https", "async", "request", "ssl"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -19,9 +19,10 @@ workspace = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
tower-service = { version = "0.3", default-features = false }
|
tower-service = { version = "0.3", default-features = false }
|
||||||
hyper = { version = "1", default-features = false, features = ["http1", "client"] }
|
hyper = { version = "1", default-features = false, features = ["http1", "client"] }
|
||||||
hyper-util = { version = "0.1", default-features = false, features = ["http1", "client-legacy", "tokio"] }
|
hyper-util = { version = "0.1", default-features = false, features = ["http1", "client-legacy"] }
|
||||||
http-body-util = { version = "0.1", default-features = false }
|
http-body-util = { version = "0.1", default-features = false }
|
||||||
tokio = { version = "1", default-features = false }
|
futures-util = { version = "0.3", default-features = false, features = ["std"] }
|
||||||
|
tokio = { version = "1", default-features = false, features = ["sync"] }
|
||||||
|
|
||||||
hyper-rustls = { version = "0.27", default-features = false, features = ["http1", "ring", "rustls-native-certs", "native-tokio"], optional = true }
|
hyper-rustls = { version = "0.27", default-features = false, features = ["http1", "ring", "rustls-native-certs", "native-tokio"], optional = true }
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ zeroize = { version = "1", optional = true }
|
|||||||
base64ct = { version = "1", features = ["alloc"], optional = true }
|
base64ct = { version = "1", features = ["alloc"], optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
tls = ["hyper-rustls"]
|
tokio = ["hyper-util/tokio"]
|
||||||
|
tls = ["tokio", "hyper-rustls"]
|
||||||
|
webpki-roots = ["tls", "hyper-rustls/webpki-roots"]
|
||||||
basic-auth = ["zeroize", "base64ct"]
|
basic-auth = ["zeroize", "base64ct"]
|
||||||
default = ["tls"]
|
default = ["tls"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023 Luke Parker
|
Copyright (c) 2023-2025 Luke Parker
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
|
|
||||||
|
use core::{pin::Pin, future::Future};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use tokio::sync::Mutex;
|
use futures_util::FutureExt;
|
||||||
|
use ::tokio::sync::Mutex;
|
||||||
|
|
||||||
use tower_service::Service as TowerService;
|
use tower_service::Service as TowerService;
|
||||||
|
use hyper::{Uri, header::HeaderValue, body::Bytes, client::conn::http1::SendRequest, rt::Executor};
|
||||||
|
pub use hyper;
|
||||||
|
|
||||||
|
use hyper_util::client::legacy::{Client as HyperClient, connect::HttpConnector};
|
||||||
|
|
||||||
#[cfg(feature = "tls")]
|
#[cfg(feature = "tls")]
|
||||||
use hyper_rustls::{HttpsConnectorBuilder, HttpsConnector};
|
use hyper_rustls::{HttpsConnectorBuilder, HttpsConnector};
|
||||||
use hyper::{Uri, header::HeaderValue, body::Bytes, client::conn::http1::SendRequest};
|
|
||||||
use hyper_util::{
|
|
||||||
rt::tokio::TokioExecutor,
|
|
||||||
client::legacy::{Client as HyperClient, connect::HttpConnector},
|
|
||||||
};
|
|
||||||
pub use hyper;
|
|
||||||
|
|
||||||
mod request;
|
mod request;
|
||||||
pub use request::*;
|
pub use request::*;
|
||||||
@@ -37,52 +38,86 @@ type Connector = HttpConnector;
|
|||||||
type Connector = HttpsConnector<HttpConnector>;
|
type Connector = HttpsConnector<HttpConnector>;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
enum Connection {
|
enum Connection<
|
||||||
|
E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>,
|
||||||
|
> {
|
||||||
ConnectionPool(HyperClient<Connector, Full<Bytes>>),
|
ConnectionPool(HyperClient<Connector, Full<Bytes>>),
|
||||||
Connection {
|
Connection {
|
||||||
|
executor: E,
|
||||||
connector: Connector,
|
connector: Connector,
|
||||||
host: Uri,
|
host: Uri,
|
||||||
connection: Arc<Mutex<Option<SendRequest<Full<Bytes>>>>>,
|
connection: Arc<Mutex<Option<SendRequest<Full<Bytes>>>>>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An HTTP client.
|
||||||
|
///
|
||||||
|
/// `tls` is only guaranteed to work when using the `tokio` executor. Instantiating a client when
|
||||||
|
/// the `tls` feature is active without using the `tokio` executor will cause errors.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Client {
|
pub struct Client<
|
||||||
connection: Connection,
|
E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>,
|
||||||
|
> {
|
||||||
|
connection: Connection<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Client {
|
impl<E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>>
|
||||||
fn connector() -> Connector {
|
Client<E>
|
||||||
|
{
|
||||||
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
|
fn connector() -> Result<Connector, Error> {
|
||||||
let mut res = HttpConnector::new();
|
let mut res = HttpConnector::new();
|
||||||
res.set_keepalive(Some(core::time::Duration::from_secs(60)));
|
res.set_keepalive(Some(core::time::Duration::from_secs(60)));
|
||||||
res.set_nodelay(true);
|
res.set_nodelay(true);
|
||||||
res.set_reuse_address(true);
|
res.set_reuse_address(true);
|
||||||
|
|
||||||
|
#[cfg(feature = "tls")]
|
||||||
|
if core::any::TypeId::of::<E>() !=
|
||||||
|
core::any::TypeId::of::<hyper_util::rt::tokio::TokioExecutor>()
|
||||||
|
{
|
||||||
|
Err(Error::ConnectionError(
|
||||||
|
"`tls` feature enabled but not using the `tokio` executor".into(),
|
||||||
|
))?;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "tls")]
|
#[cfg(feature = "tls")]
|
||||||
res.enforce_http(false);
|
res.enforce_http(false);
|
||||||
#[cfg(feature = "tls")]
|
#[cfg(feature = "tls")]
|
||||||
let res = HttpsConnectorBuilder::new()
|
let https = HttpsConnectorBuilder::new().with_native_roots();
|
||||||
.with_native_roots()
|
#[cfg(all(feature = "tls", not(feature = "webpki-roots")))]
|
||||||
.expect("couldn't fetch system's SSL roots")
|
let https = https.map_err(|e| {
|
||||||
.https_or_http()
|
Error::ConnectionError(
|
||||||
.enable_http1()
|
format!("couldn't load system's SSL root certificates and webpki-roots unavilable: {e:?}")
|
||||||
.wrap_connector(res);
|
.into(),
|
||||||
res
|
)
|
||||||
|
})?;
|
||||||
|
// Fallback to `webpki-roots` if present
|
||||||
|
#[cfg(all(feature = "tls", feature = "webpki-roots"))]
|
||||||
|
let https = https.unwrap_or(HttpsConnectorBuilder::new().with_webpki_roots());
|
||||||
|
#[cfg(feature = "tls")]
|
||||||
|
let res = https.https_or_http().enable_http1().wrap_connector(res);
|
||||||
|
|
||||||
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_connection_pool() -> Client {
|
pub fn with_executor_and_connection_pool(executor: E) -> Result<Client<E>, Error> {
|
||||||
Client {
|
Ok(Client {
|
||||||
connection: Connection::ConnectionPool(
|
connection: Connection::ConnectionPool(
|
||||||
HyperClient::builder(TokioExecutor::new())
|
HyperClient::builder(executor)
|
||||||
.pool_idle_timeout(core::time::Duration::from_secs(60))
|
.pool_idle_timeout(core::time::Duration::from_secs(60))
|
||||||
.build(Self::connector()),
|
.build(Self::connector()?),
|
||||||
),
|
),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn without_connection_pool(host: &str) -> Result<Client, Error> {
|
pub fn with_executor_and_without_connection_pool(
|
||||||
|
executor: E,
|
||||||
|
host: &str,
|
||||||
|
) -> Result<Client<E>, Error> {
|
||||||
Ok(Client {
|
Ok(Client {
|
||||||
connection: Connection::Connection {
|
connection: Connection::Connection {
|
||||||
connector: Self::connector(),
|
executor,
|
||||||
|
connector: Self::connector()?,
|
||||||
host: {
|
host: {
|
||||||
let uri: Uri = host.parse().map_err(|_| Error::InvalidUri)?;
|
let uri: Uri = host.parse().map_err(|_| Error::InvalidUri)?;
|
||||||
if uri.host().is_none() {
|
if uri.host().is_none() {
|
||||||
@@ -95,9 +130,9 @@ impl Client {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn request<R: Into<Request>>(&self, request: R) -> Result<Response<'_>, Error> {
|
pub async fn request<R: Into<Request>>(&self, request: R) -> Result<Response<'_, E>, Error> {
|
||||||
let request: Request = request.into();
|
let request: Request = request.into();
|
||||||
let mut request = request.0;
|
let Request { mut request, response_size_limit } = request;
|
||||||
if let Some(header_host) = request.headers().get(hyper::header::HOST) {
|
if let Some(header_host) = request.headers().get(hyper::header::HOST) {
|
||||||
match &self.connection {
|
match &self.connection {
|
||||||
Connection::ConnectionPool(_) => {}
|
Connection::ConnectionPool(_) => {}
|
||||||
@@ -131,7 +166,7 @@ impl Client {
|
|||||||
Connection::ConnectionPool(client) => {
|
Connection::ConnectionPool(client) => {
|
||||||
client.request(request).await.map_err(Error::HyperUtil)?
|
client.request(request).await.map_err(Error::HyperUtil)?
|
||||||
}
|
}
|
||||||
Connection::Connection { connector, host, connection } => {
|
Connection::Connection { executor, connector, host, connection } => {
|
||||||
let mut connection_lock = connection.lock().await;
|
let mut connection_lock = connection.lock().await;
|
||||||
|
|
||||||
// If there's not a connection...
|
// If there's not a connection...
|
||||||
@@ -143,28 +178,46 @@ impl Client {
|
|||||||
let call_res = call_res.map_err(Error::ConnectionError);
|
let call_res = call_res.map_err(Error::ConnectionError);
|
||||||
let (requester, connection) =
|
let (requester, connection) =
|
||||||
hyper::client::conn::http1::handshake(call_res?).await.map_err(Error::Hyper)?;
|
hyper::client::conn::http1::handshake(call_res?).await.map_err(Error::Hyper)?;
|
||||||
// This will die when we drop the requester, so we don't need to track an AbortHandle
|
// This task will die when we drop the requester
|
||||||
// for it
|
executor.execute(Box::pin(connection.map(|_| ())));
|
||||||
tokio::spawn(connection);
|
|
||||||
*connection_lock = Some(requester);
|
*connection_lock = Some(requester);
|
||||||
}
|
}
|
||||||
|
|
||||||
let connection = connection_lock.as_mut().unwrap();
|
let connection = connection_lock.as_mut().expect("lock over the connection was poisoned");
|
||||||
let mut err = connection.ready().await.err();
|
let mut err = connection.ready().await.err();
|
||||||
if err.is_none() {
|
if err.is_none() {
|
||||||
// Send the request
|
// Send the request
|
||||||
let res = connection.send_request(request).await;
|
let response = connection.send_request(request).await;
|
||||||
if let Ok(res) = res {
|
if let Ok(response) = response {
|
||||||
return Ok(Response(res, self));
|
return Ok(Response { response, size_limit: response_size_limit, client: self });
|
||||||
}
|
}
|
||||||
err = res.err();
|
err = response.err();
|
||||||
}
|
}
|
||||||
// Since this connection has been put into an error state, drop it
|
// Since this connection has been put into an error state, drop it
|
||||||
*connection_lock = None;
|
*connection_lock = None;
|
||||||
Err(Error::Hyper(err.unwrap()))?
|
Err(Error::Hyper(err.expect("only here if `err` is some yet no error")))?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Response(response, self))
|
Ok(Response { response, size_limit: response_size_limit, client: self })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "tokio")]
|
||||||
|
mod tokio {
|
||||||
|
use hyper_util::rt::tokio::TokioExecutor;
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub type TokioClient = Client<TokioExecutor>;
|
||||||
|
impl Client<TokioExecutor> {
|
||||||
|
pub fn with_connection_pool() -> Result<Self, Error> {
|
||||||
|
Self::with_executor_and_connection_pool(TokioExecutor::new())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn without_connection_pool(host: &str) -> Result<Self, Error> {
|
||||||
|
Self::with_executor_and_without_connection_pool(TokioExecutor::new(), host)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(feature = "tokio")]
|
||||||
|
pub use tokio::TokioClient;
|
||||||
|
|||||||
@@ -7,11 +7,15 @@ pub use http_body_util::Full;
|
|||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Request(pub(crate) hyper::Request<Full<Bytes>>);
|
pub struct Request {
|
||||||
|
pub(crate) request: hyper::Request<Full<Bytes>>,
|
||||||
|
pub(crate) response_size_limit: Option<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
#[cfg(feature = "basic-auth")]
|
#[cfg(feature = "basic-auth")]
|
||||||
fn username_password_from_uri(&self) -> Result<(String, String), Error> {
|
fn username_password_from_uri(&self) -> Result<(String, String), Error> {
|
||||||
if let Some(authority) = self.0.uri().authority() {
|
if let Some(authority) = self.request.uri().authority() {
|
||||||
let authority = authority.as_str();
|
let authority = authority.as_str();
|
||||||
if authority.contains('@') {
|
if authority.contains('@') {
|
||||||
// Decode the username and password from the URI
|
// Decode the username and password from the URI
|
||||||
@@ -36,9 +40,10 @@ impl Request {
|
|||||||
let mut formatted = format!("{username}:{password}");
|
let mut formatted = format!("{username}:{password}");
|
||||||
let mut encoded = Base64::encode_string(formatted.as_bytes());
|
let mut encoded = Base64::encode_string(formatted.as_bytes());
|
||||||
formatted.zeroize();
|
formatted.zeroize();
|
||||||
self.0.headers_mut().insert(
|
self.request.headers_mut().insert(
|
||||||
hyper::header::AUTHORIZATION,
|
hyper::header::AUTHORIZATION,
|
||||||
HeaderValue::from_str(&format!("Basic {encoded}")).unwrap(),
|
HeaderValue::from_str(&format!("Basic {encoded}"))
|
||||||
|
.expect("couldn't form header from base64-encoded string"),
|
||||||
);
|
);
|
||||||
encoded.zeroize();
|
encoded.zeroize();
|
||||||
}
|
}
|
||||||
@@ -59,9 +64,17 @@ impl Request {
|
|||||||
pub fn with_basic_auth(&mut self) {
|
pub fn with_basic_auth(&mut self) {
|
||||||
let _ = self.basic_auth_from_uri();
|
let _ = self.basic_auth_from_uri();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
impl From<hyper::Request<Full<Bytes>>> for Request {
|
/// Set a size limit for the response.
|
||||||
fn from(request: hyper::Request<Full<Bytes>>) -> Request {
|
///
|
||||||
Request(request)
|
/// This may be exceeded by a single HTTP frame and accordingly isn't perfect.
|
||||||
|
pub fn set_response_size_limit(&mut self, response_size_limit: Option<usize>) {
|
||||||
|
self.response_size_limit = response_size_limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<hyper::Request<Full<Bytes>>> for Request {
|
||||||
|
fn from(request: hyper::Request<Full<Bytes>>) -> Request {
|
||||||
|
Request { request, response_size_limit: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,54 @@
|
|||||||
|
use core::{pin::Pin, future::Future};
|
||||||
|
use std::io;
|
||||||
|
|
||||||
use hyper::{
|
use hyper::{
|
||||||
StatusCode,
|
StatusCode,
|
||||||
header::{HeaderValue, HeaderMap},
|
header::{HeaderValue, HeaderMap},
|
||||||
body::{Buf, Incoming},
|
body::Incoming,
|
||||||
|
rt::Executor,
|
||||||
};
|
};
|
||||||
use http_body_util::BodyExt;
|
use http_body_util::BodyExt;
|
||||||
|
|
||||||
|
use futures_util::{Stream, StreamExt};
|
||||||
|
|
||||||
use crate::{Client, Error};
|
use crate::{Client, Error};
|
||||||
|
|
||||||
// Borrows the client so its async task lives as long as this response exists.
|
// Borrows the client so its async task lives as long as this response exists.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Response<'a>(pub(crate) hyper::Response<Incoming>, pub(crate) &'a Client);
|
pub struct Response<
|
||||||
impl Response<'_> {
|
'a,
|
||||||
|
E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>,
|
||||||
|
> {
|
||||||
|
pub(crate) response: hyper::Response<Incoming>,
|
||||||
|
pub(crate) size_limit: Option<usize>,
|
||||||
|
pub(crate) client: &'a Client<E>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>>
|
||||||
|
Response<'_, E>
|
||||||
|
{
|
||||||
pub fn status(&self) -> StatusCode {
|
pub fn status(&self) -> StatusCode {
|
||||||
self.0.status()
|
self.response.status()
|
||||||
}
|
}
|
||||||
pub fn headers(&self) -> &HeaderMap<HeaderValue> {
|
pub fn headers(&self) -> &HeaderMap<HeaderValue> {
|
||||||
self.0.headers()
|
self.response.headers()
|
||||||
}
|
}
|
||||||
pub async fn body(self) -> Result<impl std::io::Read, Error> {
|
pub async fn body(self) -> Result<impl std::io::Read, Error> {
|
||||||
Ok(self.0.into_body().collect().await.map_err(Error::Hyper)?.aggregate().reader())
|
let mut body = self.response.into_body().into_data_stream();
|
||||||
|
let mut res: Vec<u8> = vec![];
|
||||||
|
loop {
|
||||||
|
if let Some(size_limit) = self.size_limit {
|
||||||
|
let (lower, upper) = body.size_hint();
|
||||||
|
if res.len().wrapping_add(upper.unwrap_or(lower)) > size_limit.min(usize::MAX - 1) {
|
||||||
|
Err(Error::ConnectionError("response exceeded size limit".into()))?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let Some(part) = body.next().await else { break };
|
||||||
|
let part = part.map_err(Error::Hyper)?;
|
||||||
|
res.extend(part.as_ref());
|
||||||
|
}
|
||||||
|
Ok(io::Cursor::new(res))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "std-shims"
|
name = "std-shims"
|
||||||
version = "0.1.1"
|
version = "0.1.5"
|
||||||
description = "A series of std shims to make alloc more feasible"
|
description = "A series of std shims to make alloc more feasible"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/serai-dex/serai/tree/develop/common/std-shims"
|
repository = "https://github.com/serai-dex/serai/tree/develop/common/std-shims"
|
||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = ["nostd", "no_std", "alloc", "io"]
|
keywords = ["nostd", "no_std", "alloc", "io"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.80"
|
rust-version = "1.65"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -17,9 +17,11 @@ rustdoc-args = ["--cfg", "docsrs"]
|
|||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
spin = { version = "0.9", default-features = false, features = ["use_ticket_mutex", "lazy"] }
|
rustversion = { version = "1", default-features = false }
|
||||||
hashbrown = { version = "0.15", default-features = false, features = ["default-hasher", "inline-more"] }
|
spin = { version = "0.10", default-features = false, features = ["use_ticket_mutex", "fair_mutex", "once", "lazy"] }
|
||||||
|
hashbrown = { version = "0.16", default-features = false, features = ["default-hasher", "inline-more"], optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
std = []
|
alloc = ["hashbrown"]
|
||||||
|
std = ["alloc", "spin/std"]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023 Luke Parker
|
Copyright (c) 2023-2025 Luke Parker
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,6 +1,28 @@
|
|||||||
# std shims
|
# `std` shims
|
||||||
|
|
||||||
A crate which passes through to std when the default `std` feature is enabled,
|
`std-shims` is a Rust crate with two purposes:
|
||||||
yet provides a series of shims when it isn't.
|
- Expand the functionality of `core` and `alloc`
|
||||||
|
- Polyfill functionality only available on newer version of Rust
|
||||||
|
|
||||||
`HashSet` and `HashMap` are provided via `hashbrown`.
|
The goal is to make supporting no-`std` environments, and older versions of
|
||||||
|
Rust, as simple as possible. For most use cases, replacing `std::` with
|
||||||
|
`std_shims::` and adding `use std_shims::prelude::*` is sufficient to take full
|
||||||
|
advantage of `std-shims`.
|
||||||
|
|
||||||
|
# API Surface
|
||||||
|
|
||||||
|
`std-shims` only aims to have items _mutually available_ between `alloc` (with
|
||||||
|
extra dependencies) and `std` publicly exposed. Items exclusive to `std`, with
|
||||||
|
no shims available, will not be exported by `std-shims`.
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
|
||||||
|
`HashSet` and `HashMap` are provided via `hashbrown`. Synchronization
|
||||||
|
primitives are provided via `spin` (avoiding a requirement on
|
||||||
|
`critical-section`). Sections of `std::io` are independently matched as
|
||||||
|
possible. `rustversion` is used to detect when to provide polyfills.
|
||||||
|
|
||||||
|
# Disclaimer
|
||||||
|
|
||||||
|
No guarantee of one-to-one parity is provided. The shims provided aim to be
|
||||||
|
sufficient for the average case. Pull requests are _welcome_.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||||
|
pub use extern_alloc::collections::*;
|
||||||
|
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||||
|
pub use hashbrown::{HashSet, HashMap};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub use std::collections::*;
|
pub use std::collections::*;
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
pub use alloc::collections::*;
|
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
pub use hashbrown::{HashSet, HashMap};
|
|
||||||
|
|||||||
@@ -1,42 +1,74 @@
|
|||||||
#[cfg(feature = "std")]
|
|
||||||
pub use std::io::*;
|
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
mod shims {
|
mod shims {
|
||||||
use core::fmt::{Debug, Formatter};
|
use core::fmt::{self, Debug, Display, Formatter};
|
||||||
use alloc::{boxed::Box, vec::Vec};
|
#[cfg(feature = "alloc")]
|
||||||
|
use extern_alloc::{boxed::Box, vec::Vec};
|
||||||
|
use crate::error::Error as CoreError;
|
||||||
|
|
||||||
|
/// The kind of error.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub enum ErrorKind {
|
pub enum ErrorKind {
|
||||||
UnexpectedEof,
|
UnexpectedEof,
|
||||||
Other,
|
Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An error.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
kind: ErrorKind,
|
kind: ErrorKind,
|
||||||
error: Box<dyn Send + Sync>,
|
#[cfg(feature = "alloc")]
|
||||||
|
error: Box<dyn Send + Sync + CoreError>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, fmt: &mut Formatter<'_>) -> core::result::Result<(), core::fmt::Error> {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
fmt.debug_struct("Error").field("kind", &self.kind).finish_non_exhaustive()
|
<Self as Debug>::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl CoreError for Error {}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "alloc"))]
|
||||||
|
pub trait IntoBoxSendSyncError {}
|
||||||
|
#[cfg(not(feature = "alloc"))]
|
||||||
|
impl<I> IntoBoxSendSyncError for I {}
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
|
pub trait IntoBoxSendSyncError: Into<Box<dyn Send + Sync + CoreError>> {}
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
|
impl<I: Into<Box<dyn Send + Sync + CoreError>>> IntoBoxSendSyncError for I {}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
pub fn new<E: 'static + Send + Sync>(kind: ErrorKind, error: E) -> Error {
|
/// Create a new error.
|
||||||
Error { kind, error: Box::new(error) }
|
///
|
||||||
|
/// The error object itself is silently dropped when `alloc` is not enabled.
|
||||||
|
#[allow(unused)]
|
||||||
|
pub fn new<E: 'static + IntoBoxSendSyncError>(kind: ErrorKind, error: E) -> Error {
|
||||||
|
#[cfg(not(feature = "alloc"))]
|
||||||
|
let res = Error { kind };
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
|
let res = Error { kind, error: error.into() };
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn other<E: 'static + Send + Sync>(error: E) -> Error {
|
/// Create a new error with `io::ErrorKind::Other` as its kind.
|
||||||
Error { kind: ErrorKind::Other, error: Box::new(error) }
|
///
|
||||||
|
/// The error object itself is silently dropped when `alloc` is not enabled.
|
||||||
|
#[allow(unused)]
|
||||||
|
pub fn other<E: 'static + IntoBoxSendSyncError>(error: E) -> Error {
|
||||||
|
#[cfg(not(feature = "alloc"))]
|
||||||
|
let res = Error { kind: ErrorKind::Other };
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
|
let res = Error { kind: ErrorKind::Other, error: error.into() };
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The kind of error.
|
||||||
pub fn kind(&self) -> ErrorKind {
|
pub fn kind(&self) -> ErrorKind {
|
||||||
self.kind
|
self.kind
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_inner(self) -> Option<Box<dyn Send + Sync>> {
|
/// Retrieve the inner error.
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
|
pub fn into_inner(self) -> Option<Box<dyn Send + Sync + CoreError>> {
|
||||||
Some(self.error)
|
Some(self.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,6 +96,12 @@ mod shims {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<R: Read> Read for &mut R {
|
||||||
|
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
|
||||||
|
R::read(*self, buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait BufRead: Read {
|
pub trait BufRead: Read {
|
||||||
fn fill_buf(&mut self) -> Result<&[u8]>;
|
fn fill_buf(&mut self) -> Result<&[u8]>;
|
||||||
fn consume(&mut self, amt: usize);
|
fn consume(&mut self, amt: usize);
|
||||||
@@ -88,6 +126,7 @@ mod shims {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
impl Write for Vec<u8> {
|
impl Write for Vec<u8> {
|
||||||
fn write(&mut self, buf: &[u8]) -> Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> Result<usize> {
|
||||||
self.extend(buf);
|
self.extend(buf);
|
||||||
@@ -95,6 +134,8 @@ mod shims {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
pub use shims::*;
|
pub use shims::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub use std::io::{ErrorKind, Error, Result, Read, BufRead, Write};
|
||||||
|
|||||||
@@ -1,13 +1,102 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
pub extern crate alloc;
|
#[cfg(not(feature = "alloc"))]
|
||||||
|
pub use core::*;
|
||||||
|
#[cfg(not(feature = "alloc"))]
|
||||||
|
pub use core::{alloc, borrow, ffi, fmt, slice, str, task};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
#[rustversion::before(1.81)]
|
||||||
|
pub mod error {
|
||||||
|
use core::fmt::Debug::Display;
|
||||||
|
pub trait Error: Debug + Display {}
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "std"))]
|
||||||
|
#[rustversion::since(1.81)]
|
||||||
|
pub use core::error;
|
||||||
|
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
|
extern crate alloc as extern_alloc;
|
||||||
|
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||||
|
pub use extern_alloc::{alloc, borrow, boxed, ffi, fmt, rc, slice, str, string, task, vec, format};
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub use std::{alloc, borrow, boxed, error, ffi, fmt, rc, slice, str, string, task, vec, format};
|
||||||
|
|
||||||
pub mod sync;
|
|
||||||
pub mod collections;
|
pub mod collections;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
|
pub mod sync;
|
||||||
|
|
||||||
pub use alloc::vec;
|
pub mod prelude {
|
||||||
pub use alloc::str;
|
// Shim the `std` prelude
|
||||||
pub use alloc::string;
|
#[cfg(feature = "alloc")]
|
||||||
|
pub use extern_alloc::{
|
||||||
|
format, vec,
|
||||||
|
borrow::ToOwned,
|
||||||
|
boxed::Box,
|
||||||
|
vec::Vec,
|
||||||
|
string::{String, ToString},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Shim `div_ceil`
|
||||||
|
#[rustversion::before(1.73)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub trait StdShimsDivCeil {
|
||||||
|
fn div_ceil(self, rhs: Self) -> Self;
|
||||||
|
}
|
||||||
|
#[rustversion::before(1.73)]
|
||||||
|
mod impl_divceil {
|
||||||
|
use super::StdShimsDivCeil;
|
||||||
|
impl StdShimsDivCeil for u8 {
|
||||||
|
fn div_ceil(self, rhs: Self) -> Self {
|
||||||
|
(self + (rhs - 1)) / rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl StdShimsDivCeil for u16 {
|
||||||
|
fn div_ceil(self, rhs: Self) -> Self {
|
||||||
|
(self + (rhs - 1)) / rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl StdShimsDivCeil for u32 {
|
||||||
|
fn div_ceil(self, rhs: Self) -> Self {
|
||||||
|
(self + (rhs - 1)) / rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl StdShimsDivCeil for u64 {
|
||||||
|
fn div_ceil(self, rhs: Self) -> Self {
|
||||||
|
(self + (rhs - 1)) / rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl StdShimsDivCeil for u128 {
|
||||||
|
fn div_ceil(self, rhs: Self) -> Self {
|
||||||
|
(self + (rhs - 1)) / rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl StdShimsDivCeil for usize {
|
||||||
|
fn div_ceil(self, rhs: Self) -> Self {
|
||||||
|
(self + (rhs - 1)) / rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shim `io::Error::other`
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
#[rustversion::before(1.74)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub trait StdShimsIoErrorOther {
|
||||||
|
fn other<E>(error: E) -> Self
|
||||||
|
where
|
||||||
|
E: Into<Box<dyn std::error::Error + Send + Sync>>;
|
||||||
|
}
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
#[rustversion::before(1.74)]
|
||||||
|
impl StdShimsIoErrorOther for std::io::Error {
|
||||||
|
fn other<E>(error: E) -> Self
|
||||||
|
where
|
||||||
|
E: Into<Box<dyn std::error::Error + Send + Sync>>,
|
||||||
|
{
|
||||||
|
std::io::Error::new(std::io::ErrorKind::Other, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,19 +1,28 @@
|
|||||||
pub use core::sync::*;
|
pub use core::sync::atomic;
|
||||||
pub use alloc::sync::*;
|
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||||
|
pub use extern_alloc::sync::{Arc, Weak};
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub use std::sync::{Arc, Weak};
|
||||||
|
|
||||||
mod mutex_shim {
|
mod mutex_shim {
|
||||||
#[cfg(feature = "std")]
|
|
||||||
pub use std::sync::*;
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
pub use spin::*;
|
pub use spin::{Mutex, MutexGuard};
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub use std::sync::{Mutex, MutexGuard};
|
||||||
|
|
||||||
|
/// A shimmed `Mutex` with an API mutual to `spin` and `std`.
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct ShimMutex<T>(Mutex<T>);
|
pub struct ShimMutex<T>(Mutex<T>);
|
||||||
impl<T> ShimMutex<T> {
|
impl<T> ShimMutex<T> {
|
||||||
|
/// Construct a new `Mutex`.
|
||||||
pub const fn new(value: T) -> Self {
|
pub const fn new(value: T) -> Self {
|
||||||
Self(Mutex::new(value))
|
Self(Mutex::new(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Acquire a lock on the contents of the `Mutex`.
|
||||||
|
///
|
||||||
|
/// On no-`std` environments, this may spin until the lock is acquired. On `std` environments,
|
||||||
|
/// this may panic if the `Mutex` was poisoned.
|
||||||
pub fn lock(&self) -> MutexGuard<'_, T> {
|
pub fn lock(&self) -> MutexGuard<'_, T> {
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
let res = self.0.lock().unwrap();
|
let res = self.0.lock().unwrap();
|
||||||
@@ -25,7 +34,12 @@ mod mutex_shim {
|
|||||||
}
|
}
|
||||||
pub use mutex_shim::{ShimMutex as Mutex, MutexGuard};
|
pub use mutex_shim::{ShimMutex as Mutex, MutexGuard};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[rustversion::before(1.80)]
|
||||||
pub use std::sync::LazyLock;
|
pub use spin::Lazy as LazyLock;
|
||||||
|
|
||||||
|
#[rustversion::since(1.80)]
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
pub use spin::Lazy as LazyLock;
|
pub use spin::Lazy as LazyLock;
|
||||||
|
#[rustversion::since(1.80)]
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub use std::sync::LazyLock;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
AGPL-3.0-only license
|
AGPL-3.0-only license
|
||||||
|
|
||||||
Copyright (c) 2022-2024 Luke Parker
|
Copyright (c) 2022-2025 Luke Parker
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License Version 3 as
|
it under the terms of the GNU Affero General Public License Version 3 as
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ repository = "https://github.com/serai-dex/serai/tree/develop/common/zalloc"
|
|||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = []
|
keywords = []
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.77"
|
# This must be specified with the patch version, else Rust believes `1.77` < `1.77.0` and will
|
||||||
|
# refuse to compile due to relying on versions introduced with `1.77.0`
|
||||||
|
rust-version = "1.77.0"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2022-2023 Luke Parker
|
Copyright (c) 2022-2025 Luke Parker
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![cfg_attr(all(zalloc_rustc_nightly, feature = "allocator"), feature(allocator_api))]
|
#![cfg_attr(all(zalloc_rustc_nightly, feature = "allocator"), feature(allocator_api))]
|
||||||
|
|
||||||
//! Implementation of a Zeroizing Allocator, enabling zeroizing memory on deallocation.
|
//! Implementation of a Zeroizing Allocator, enabling zeroizing memory on deallocation.
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
|||||||
keywords = []
|
keywords = []
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
rust-version = "1.81"
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -22,15 +21,16 @@ zeroize = { version = "^1.5", default-features = false, features = ["std"] }
|
|||||||
bitvec = { version = "1", default-features = false, features = ["std"] }
|
bitvec = { version = "1", default-features = false, features = ["std"] }
|
||||||
rand_core = { version = "0.6", default-features = false, features = ["std"] }
|
rand_core = { version = "0.6", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
blake2 = { version = "0.10", default-features = false, features = ["std"] }
|
blake2 = { version = "0.11.0-rc.0", default-features = false, features = ["alloc"] }
|
||||||
schnorrkel = { version = "0.11", default-features = false, features = ["std"] }
|
schnorrkel = { version = "0.11", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
ciphersuite = { path = "../crypto/ciphersuite", default-features = false, features = ["std", "ristretto"] }
|
dalek-ff-group = { path = "../crypto/dalek-ff-group", default-features = false, features = ["std"] }
|
||||||
dkg = { path = "../crypto/dkg", default-features = false, features = ["std"] }
|
ciphersuite = { path = "../crypto/ciphersuite", default-features = false, features = ["std"] }
|
||||||
|
dkg = { package = "dkg-musig", path = "../crypto/dkg/musig", default-features = false, features = ["std"] }
|
||||||
|
frost = { package = "modular-frost", path = "../crypto/frost" }
|
||||||
frost-schnorrkel = { path = "../crypto/schnorrkel" }
|
frost-schnorrkel = { path = "../crypto/schnorrkel" }
|
||||||
|
|
||||||
hex = { version = "0.4", default-features = false, features = ["std"] }
|
hex = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive", "bit-vec"] }
|
|
||||||
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||||
|
|
||||||
zalloc = { path = "../common/zalloc" }
|
zalloc = { path = "../common/zalloc" }
|
||||||
@@ -42,7 +42,7 @@ messages = { package = "serai-processor-messages", path = "../processor/messages
|
|||||||
message-queue = { package = "serai-message-queue", path = "../message-queue" }
|
message-queue = { package = "serai-message-queue", path = "../message-queue" }
|
||||||
tributary-sdk = { path = "./tributary-sdk" }
|
tributary-sdk = { path = "./tributary-sdk" }
|
||||||
|
|
||||||
serai-client = { path = "../substrate/client", default-features = false, features = ["serai", "borsh"] }
|
serai-client-serai = { path = "../substrate/client/serai", default-features = false }
|
||||||
|
|
||||||
log = { version = "0.4", default-features = false, features = ["std"] }
|
log = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
env_logger = { version = "0.10", default-features = false, features = ["humantime"] }
|
env_logger = { version = "0.10", default-features = false, features = ["humantime"] }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
|||||||
keywords = []
|
keywords = []
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
rust-version = "1.81"
|
rust-version = "1.85"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -18,12 +18,10 @@ rustdoc-args = ["--cfg", "docsrs"]
|
|||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
blake2 = { version = "0.10", default-features = false, features = ["std"] }
|
blake2 = { version = "0.11.0-rc.0", default-features = false, features = ["alloc"] }
|
||||||
schnorrkel = { version = "0.11", default-features = false, features = ["std"] }
|
|
||||||
|
|
||||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive"] }
|
|
||||||
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||||
serai-client = { path = "../../substrate/client", default-features = false, features = ["serai", "borsh"] }
|
serai-client-serai = { path = "../../substrate/client/serai", default-features = false }
|
||||||
|
|
||||||
log = { version = "0.4", default-features = false, features = ["std"] }
|
log = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
@@ -31,3 +29,5 @@ tokio = { version = "1", default-features = false }
|
|||||||
|
|
||||||
serai-db = { path = "../../common/db", version = "0.1.1" }
|
serai-db = { path = "../../common/db", version = "0.1.1" }
|
||||||
serai-task = { path = "../../common/task", version = "0.1" }
|
serai-task = { path = "../../common/task", version = "0.1" }
|
||||||
|
|
||||||
|
serai-cosign-types = { path = "./types" }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
AGPL-3.0-only license
|
AGPL-3.0-only license
|
||||||
|
|
||||||
Copyright (c) 2023-2024 Luke Parker
|
Copyright (c) 2023-2025 Luke Parker
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License Version 3 as
|
it under the terms of the GNU Affero General Public License Version 3 as
|
||||||
|
|||||||
@@ -1,10 +1,21 @@
|
|||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use std::{sync::Arc, collections::HashMap};
|
use std::{sync::Arc, collections::HashMap};
|
||||||
|
|
||||||
use serai_client::{
|
use blake2::{Digest, Blake2b256};
|
||||||
primitives::{SeraiAddress, Amount},
|
|
||||||
validator_sets::primitives::ExternalValidatorSet,
|
use serai_client_serai::{
|
||||||
Serai,
|
abi::{
|
||||||
|
primitives::{
|
||||||
|
network_id::{ExternalNetworkId, NetworkId},
|
||||||
|
balance::Amount,
|
||||||
|
crypto::Public,
|
||||||
|
validator_sets::{Session, ExternalValidatorSet},
|
||||||
|
address::SeraiAddress,
|
||||||
|
merkle::IncrementalUnbalancedMerkleTree,
|
||||||
|
},
|
||||||
|
validator_sets::Event,
|
||||||
|
},
|
||||||
|
Serai, Events,
|
||||||
};
|
};
|
||||||
|
|
||||||
use serai_db::*;
|
use serai_db::*;
|
||||||
@@ -12,9 +23,20 @@ use serai_task::ContinuallyRan;
|
|||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
#[derive(BorshSerialize, BorshDeserialize)]
|
||||||
|
struct Set {
|
||||||
|
session: Session,
|
||||||
|
key: Public,
|
||||||
|
stake: Amount,
|
||||||
|
}
|
||||||
|
|
||||||
create_db!(
|
create_db!(
|
||||||
CosignIntend {
|
CosignIntend {
|
||||||
ScanCosignFrom: () -> u64,
|
ScanCosignFrom: () -> u64,
|
||||||
|
BuildsUpon: () -> IncrementalUnbalancedMerkleTree,
|
||||||
|
Stakes: (network: ExternalNetworkId, validator: SeraiAddress) -> Amount,
|
||||||
|
Validators: (set: ExternalValidatorSet) -> Vec<SeraiAddress>,
|
||||||
|
LatestSet: (network: ExternalNetworkId) -> Set,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -35,23 +57,38 @@ db_channel! {
|
|||||||
async fn block_has_events_justifying_a_cosign(
|
async fn block_has_events_justifying_a_cosign(
|
||||||
serai: &Serai,
|
serai: &Serai,
|
||||||
block_number: u64,
|
block_number: u64,
|
||||||
) -> Result<(Block, HasEvents), String> {
|
) -> Result<(Block, Events, HasEvents), String> {
|
||||||
let block = serai
|
let block = serai
|
||||||
.finalized_block_by_number(block_number)
|
.block_by_number(block_number)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("{e:?}"))?
|
.map_err(|e| format!("{e:?}"))?
|
||||||
.ok_or_else(|| "couldn't get block which should've been finalized".to_string())?;
|
.ok_or_else(|| "couldn't get block which should've been finalized".to_string())?;
|
||||||
let serai = serai.as_of(block.hash());
|
let events = serai.events(block.header.hash()).await.map_err(|e| format!("{e:?}"))?;
|
||||||
|
|
||||||
if !serai.validator_sets().key_gen_events().await.map_err(|e| format!("{e:?}"))?.is_empty() {
|
if events.validator_sets().set_keys_events().next().is_some() {
|
||||||
return Ok((block, HasEvents::Notable));
|
return Ok((block, events, HasEvents::Notable));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !serai.coins().burn_with_instruction_events().await.map_err(|e| format!("{e:?}"))?.is_empty() {
|
if events.coins().burn_with_instruction_events().next().is_some() {
|
||||||
return Ok((block, HasEvents::NonNotable));
|
return Ok((block, events, HasEvents::NonNotable));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((block, HasEvents::No))
|
Ok((block, events, HasEvents::No))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch the `ExternalValidatorSet`s, and their associated keys, used for cosigning as of this
|
||||||
|
// block.
|
||||||
|
fn cosigning_sets(getter: &impl Get) -> Vec<(ExternalValidatorSet, Public, Amount)> {
|
||||||
|
let mut sets = vec![];
|
||||||
|
for network in ExternalNetworkId::all() {
|
||||||
|
let Some(Set { session, key, stake }) = LatestSet::get(getter, network) else {
|
||||||
|
// If this network doesn't have usable keys, move on
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
sets.push((ExternalValidatorSet { network, session }, key, stake));
|
||||||
|
}
|
||||||
|
sets
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A task to determine which blocks we should intend to cosign.
|
/// A task to determine which blocks we should intend to cosign.
|
||||||
@@ -67,56 +104,108 @@ impl<D: Db> ContinuallyRan for CosignIntendTask<D> {
|
|||||||
async move {
|
async move {
|
||||||
let start_block_number = ScanCosignFrom::get(&self.db).unwrap_or(1);
|
let start_block_number = ScanCosignFrom::get(&self.db).unwrap_or(1);
|
||||||
let latest_block_number =
|
let latest_block_number =
|
||||||
self.serai.latest_finalized_block().await.map_err(|e| format!("{e:?}"))?.number();
|
self.serai.latest_finalized_block_number().await.map_err(|e| format!("{e:?}"))?;
|
||||||
|
|
||||||
for block_number in start_block_number ..= latest_block_number {
|
for block_number in start_block_number ..= latest_block_number {
|
||||||
let mut txn = self.db.txn();
|
let mut txn = self.db.txn();
|
||||||
|
|
||||||
let (block, mut has_events) =
|
let (block, events, mut has_events) =
|
||||||
block_has_events_justifying_a_cosign(&self.serai, block_number)
|
block_has_events_justifying_a_cosign(&self.serai, block_number)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("{e:?}"))?;
|
.map_err(|e| format!("{e:?}"))?;
|
||||||
|
|
||||||
|
let mut builds_upon =
|
||||||
|
BuildsUpon::get(&txn).unwrap_or(IncrementalUnbalancedMerkleTree::new());
|
||||||
|
|
||||||
// Check we are indexing a linear chain
|
// Check we are indexing a linear chain
|
||||||
if (block_number > 1) &&
|
if block.header.builds_upon() !=
|
||||||
(<[u8; 32]>::from(block.header.parent_hash) !=
|
builds_upon.clone().calculate(serai_client_serai::abi::BLOCK_HEADER_BRANCH_TAG)
|
||||||
SubstrateBlockHash::get(&txn, block_number - 1)
|
|
||||||
.expect("indexing a block but haven't indexed its parent"))
|
|
||||||
{
|
{
|
||||||
Err(format!(
|
Err(format!(
|
||||||
"node's block #{block_number} doesn't build upon the block #{} prior indexed",
|
"node's block #{block_number} doesn't build upon the block #{} prior indexed",
|
||||||
block_number - 1
|
block_number - 1
|
||||||
))?;
|
))?;
|
||||||
}
|
}
|
||||||
let block_hash = block.hash();
|
let block_hash = block.header.hash();
|
||||||
SubstrateBlockHash::set(&mut txn, block_number, &block_hash);
|
SubstrateBlockHash::set(&mut txn, block_number, &block_hash);
|
||||||
|
builds_upon.append(
|
||||||
|
serai_client_serai::abi::BLOCK_HEADER_BRANCH_TAG,
|
||||||
|
Blake2b256::new_with_prefix([serai_client_serai::abi::BLOCK_HEADER_LEAF_TAG])
|
||||||
|
.chain_update(block_hash.0)
|
||||||
|
.finalize()
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
BuildsUpon::set(&mut txn, &builds_upon);
|
||||||
|
|
||||||
|
// Update the stakes
|
||||||
|
for event in events.validator_sets().allocation_events() {
|
||||||
|
let Event::Allocation { validator, network, amount } = event else {
|
||||||
|
panic!("event from `allocation_events` wasn't `Event::Allocation`")
|
||||||
|
};
|
||||||
|
let Ok(network) = ExternalNetworkId::try_from(*network) else { continue };
|
||||||
|
let existing = Stakes::get(&txn, network, *validator).unwrap_or(Amount(0));
|
||||||
|
Stakes::set(&mut txn, network, *validator, &Amount(existing.0 + amount.0));
|
||||||
|
}
|
||||||
|
for event in events.validator_sets().deallocation_events() {
|
||||||
|
let Event::Deallocation { validator, network, amount, timeline: _ } = event else {
|
||||||
|
panic!("event from `deallocation_events` wasn't `Event::Deallocation`")
|
||||||
|
};
|
||||||
|
let Ok(network) = ExternalNetworkId::try_from(*network) else { continue };
|
||||||
|
let existing = Stakes::get(&txn, network, *validator).unwrap_or(Amount(0));
|
||||||
|
Stakes::set(&mut txn, network, *validator, &Amount(existing.0 - amount.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle decided sets
|
||||||
|
for event in events.validator_sets().set_decided_events() {
|
||||||
|
let Event::SetDecided { set, validators } = event else {
|
||||||
|
panic!("event from `set_decided_events` wasn't `Event::SetDecided`")
|
||||||
|
};
|
||||||
|
|
||||||
|
let Ok(set) = ExternalValidatorSet::try_from(*set) else { continue };
|
||||||
|
Validators::set(
|
||||||
|
&mut txn,
|
||||||
|
set,
|
||||||
|
&validators.iter().map(|(validator, _key_shares)| *validator).collect(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle declarations of the latest set
|
||||||
|
for event in events.validator_sets().set_keys_events() {
|
||||||
|
let Event::SetKeys { set, key_pair } = event else {
|
||||||
|
panic!("event from `set_keys_events` wasn't `Event::SetKeys`")
|
||||||
|
};
|
||||||
|
let mut stake = 0;
|
||||||
|
for validator in
|
||||||
|
Validators::take(&mut txn, *set).expect("set which wasn't decided set keys")
|
||||||
|
{
|
||||||
|
stake += Stakes::get(&txn, set.network, validator).unwrap_or(Amount(0)).0;
|
||||||
|
}
|
||||||
|
LatestSet::set(
|
||||||
|
&mut txn,
|
||||||
|
set.network,
|
||||||
|
&Set { session: set.session, key: key_pair.0, stake: Amount(stake) },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let global_session_for_this_block = LatestGlobalSessionIntended::get(&txn);
|
let global_session_for_this_block = LatestGlobalSessionIntended::get(&txn);
|
||||||
|
|
||||||
// If this is notable, it creates a new global session, which we index into the database
|
// If this is notable, it creates a new global session, which we index into the database
|
||||||
// now
|
// now
|
||||||
if has_events == HasEvents::Notable {
|
if has_events == HasEvents::Notable {
|
||||||
let serai = self.serai.as_of(block_hash);
|
let sets_and_keys_and_stakes = cosigning_sets(&txn);
|
||||||
let sets_and_keys = cosigning_sets(&serai).await?;
|
let global_session = GlobalSession::id(
|
||||||
let global_session =
|
sets_and_keys_and_stakes.iter().map(|(set, _key, _stake)| *set).collect(),
|
||||||
GlobalSession::id(sets_and_keys.iter().map(|(set, _key)| *set).collect());
|
);
|
||||||
|
|
||||||
let mut sets = Vec::with_capacity(sets_and_keys.len());
|
let mut sets = Vec::with_capacity(sets_and_keys_and_stakes.len());
|
||||||
let mut keys = HashMap::with_capacity(sets_and_keys.len());
|
let mut keys = HashMap::with_capacity(sets_and_keys_and_stakes.len());
|
||||||
let mut stakes = HashMap::with_capacity(sets_and_keys.len());
|
let mut stakes = HashMap::with_capacity(sets_and_keys_and_stakes.len());
|
||||||
let mut total_stake = 0;
|
let mut total_stake = 0;
|
||||||
for (set, key) in &sets_and_keys {
|
for (set, key, stake) in sets_and_keys_and_stakes {
|
||||||
sets.push(*set);
|
sets.push(set);
|
||||||
keys.insert(set.network, SeraiAddress::from(*key));
|
keys.insert(set.network, key);
|
||||||
let stake = serai
|
stakes.insert(set.network, stake.0);
|
||||||
.validator_sets()
|
total_stake += stake.0;
|
||||||
.total_allocated_stake(set.network.into())
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("{e:?}"))?
|
|
||||||
.unwrap_or(Amount(0))
|
|
||||||
.0;
|
|
||||||
stakes.insert(set.network, stake);
|
|
||||||
total_stake += stake;
|
|
||||||
}
|
}
|
||||||
if total_stake == 0 {
|
if total_stake == 0 {
|
||||||
Err(format!("cosigning sets for block #{block_number} had 0 stake in total"))?;
|
Err(format!("cosigning sets for block #{block_number} had 0 stake in total"))?;
|
||||||
@@ -155,7 +244,7 @@ impl<D: Db> ContinuallyRan for CosignIntendTask<D> {
|
|||||||
|
|
||||||
// Tell each set of their expectation to cosign this block
|
// Tell each set of their expectation to cosign this block
|
||||||
for set in global_session_info.sets {
|
for set in global_session_info.sets {
|
||||||
log::debug!("{:?} will be cosigning block #{block_number}", set);
|
log::debug!("{set:?} will be cosigning block #{block_number}");
|
||||||
IntendedCosigns::send(
|
IntendedCosigns::send(
|
||||||
&mut txn,
|
&mut txn,
|
||||||
set,
|
set,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
@@ -7,18 +7,27 @@ use std::{sync::Arc, collections::HashMap, time::Instant};
|
|||||||
|
|
||||||
use blake2::{Digest, Blake2s256};
|
use blake2::{Digest, Blake2s256};
|
||||||
|
|
||||||
use scale::{Encode, Decode};
|
|
||||||
use borsh::{BorshSerialize, BorshDeserialize};
|
use borsh::{BorshSerialize, BorshDeserialize};
|
||||||
|
|
||||||
use serai_client::{
|
use serai_client_serai::{
|
||||||
primitives::{ExternalNetworkId, SeraiAddress},
|
abi::{
|
||||||
validator_sets::primitives::{Session, ExternalValidatorSet, KeyPair},
|
primitives::{
|
||||||
Public, Block, Serai, TemporalSerai,
|
BlockHash,
|
||||||
|
crypto::{Public, KeyPair},
|
||||||
|
network_id::ExternalNetworkId,
|
||||||
|
validator_sets::{Session, ExternalValidatorSet},
|
||||||
|
address::SeraiAddress,
|
||||||
|
},
|
||||||
|
Block,
|
||||||
|
},
|
||||||
|
Serai, State,
|
||||||
};
|
};
|
||||||
|
|
||||||
use serai_db::*;
|
use serai_db::*;
|
||||||
use serai_task::*;
|
use serai_task::*;
|
||||||
|
|
||||||
|
pub use serai_cosign_types::*;
|
||||||
|
|
||||||
/// The cosigns which are intended to be performed.
|
/// The cosigns which are intended to be performed.
|
||||||
mod intend;
|
mod intend;
|
||||||
/// The evaluator of the cosigns.
|
/// The evaluator of the cosigns.
|
||||||
@@ -28,9 +37,6 @@ mod delay;
|
|||||||
pub use delay::BROADCAST_FREQUENCY;
|
pub use delay::BROADCAST_FREQUENCY;
|
||||||
use delay::LatestCosignedBlockNumber;
|
use delay::LatestCosignedBlockNumber;
|
||||||
|
|
||||||
/// The schnorrkel context to used when signing a cosign.
|
|
||||||
pub const COSIGN_CONTEXT: &[u8] = b"/serai/coordinator/cosign";
|
|
||||||
|
|
||||||
/// A 'global session', defined as all validator sets used for cosigning at a given moment.
|
/// A 'global session', defined as all validator sets used for cosigning at a given moment.
|
||||||
///
|
///
|
||||||
/// We evaluate cosign faults within a global session. This ensures even if cosigners cosign
|
/// We evaluate cosign faults within a global session. This ensures even if cosigners cosign
|
||||||
@@ -53,7 +59,7 @@ pub const COSIGN_CONTEXT: &[u8] = b"/serai/coordinator/cosign";
|
|||||||
pub(crate) struct GlobalSession {
|
pub(crate) struct GlobalSession {
|
||||||
pub(crate) start_block_number: u64,
|
pub(crate) start_block_number: u64,
|
||||||
pub(crate) sets: Vec<ExternalValidatorSet>,
|
pub(crate) sets: Vec<ExternalValidatorSet>,
|
||||||
pub(crate) keys: HashMap<ExternalNetworkId, SeraiAddress>,
|
pub(crate) keys: HashMap<ExternalNetworkId, Public>,
|
||||||
pub(crate) stakes: HashMap<ExternalNetworkId, u64>,
|
pub(crate) stakes: HashMap<ExternalNetworkId, u64>,
|
||||||
pub(crate) total_stake: u64,
|
pub(crate) total_stake: u64,
|
||||||
}
|
}
|
||||||
@@ -78,74 +84,12 @@ enum HasEvents {
|
|||||||
No,
|
No,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An intended cosign.
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
|
||||||
pub struct CosignIntent {
|
|
||||||
/// The global session this cosign is being performed under.
|
|
||||||
pub global_session: [u8; 32],
|
|
||||||
/// The number of the block to cosign.
|
|
||||||
pub block_number: u64,
|
|
||||||
/// The hash of the block to cosign.
|
|
||||||
pub block_hash: [u8; 32],
|
|
||||||
/// If this cosign must be handled before further cosigns are.
|
|
||||||
pub notable: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A cosign.
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode, BorshSerialize, BorshDeserialize)]
|
|
||||||
pub struct Cosign {
|
|
||||||
/// The global session this cosign is being performed under.
|
|
||||||
pub global_session: [u8; 32],
|
|
||||||
/// The number of the block to cosign.
|
|
||||||
pub block_number: u64,
|
|
||||||
/// The hash of the block to cosign.
|
|
||||||
pub block_hash: [u8; 32],
|
|
||||||
/// The actual cosigner.
|
|
||||||
pub cosigner: ExternalNetworkId,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CosignIntent {
|
|
||||||
/// Convert this into a `Cosign`.
|
|
||||||
pub fn into_cosign(self, cosigner: ExternalNetworkId) -> Cosign {
|
|
||||||
let CosignIntent { global_session, block_number, block_hash, notable: _ } = self;
|
|
||||||
Cosign { global_session, block_number, block_hash, cosigner }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Cosign {
|
|
||||||
/// The message to sign to sign this cosign.
|
|
||||||
///
|
|
||||||
/// This must be signed with schnorrkel, the context set to `COSIGN_CONTEXT`.
|
|
||||||
pub fn signature_message(&self) -> Vec<u8> {
|
|
||||||
// We use a schnorrkel context to domain-separate this
|
|
||||||
self.encode()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A signed cosign.
|
|
||||||
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
|
|
||||||
pub struct SignedCosign {
|
|
||||||
/// The cosign.
|
|
||||||
pub cosign: Cosign,
|
|
||||||
/// The signature for the cosign.
|
|
||||||
pub signature: [u8; 64],
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SignedCosign {
|
|
||||||
fn verify_signature(&self, signer: serai_client::Public) -> bool {
|
|
||||||
let Ok(signer) = schnorrkel::PublicKey::from_bytes(&signer.0) else { return false };
|
|
||||||
let Ok(signature) = schnorrkel::Signature::from_bytes(&self.signature) else { return false };
|
|
||||||
|
|
||||||
signer.verify_simple(COSIGN_CONTEXT, &self.cosign.signature_message(), &signature).is_ok()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
create_db! {
|
create_db! {
|
||||||
Cosign {
|
Cosign {
|
||||||
// The following are populated by the intend task and used throughout the library
|
// The following are populated by the intend task and used throughout the library
|
||||||
|
|
||||||
// An index of Substrate blocks
|
// An index of Substrate blocks
|
||||||
SubstrateBlockHash: (block_number: u64) -> [u8; 32],
|
SubstrateBlockHash: (block_number: u64) -> BlockHash,
|
||||||
// A mapping from a global session's ID to its relevant information.
|
// A mapping from a global session's ID to its relevant information.
|
||||||
GlobalSessions: (global_session: [u8; 32]) -> GlobalSession,
|
GlobalSessions: (global_session: [u8; 32]) -> GlobalSession,
|
||||||
// The last block to be cosigned by a global session.
|
// The last block to be cosigned by a global session.
|
||||||
@@ -177,60 +121,6 @@ create_db! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch the keys used for cosigning by a specific network.
|
|
||||||
async fn keys_for_network(
|
|
||||||
serai: &TemporalSerai<'_>,
|
|
||||||
network: ExternalNetworkId,
|
|
||||||
) -> Result<Option<(Session, KeyPair)>, String> {
|
|
||||||
let Some(latest_session) =
|
|
||||||
serai.validator_sets().session(network.into()).await.map_err(|e| format!("{e:?}"))?
|
|
||||||
else {
|
|
||||||
// If this network hasn't had a session declared, move on
|
|
||||||
return Ok(None);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get the keys for the latest session
|
|
||||||
if let Some(keys) = serai
|
|
||||||
.validator_sets()
|
|
||||||
.keys(ExternalValidatorSet { network, session: latest_session })
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("{e:?}"))?
|
|
||||||
{
|
|
||||||
return Ok(Some((latest_session, keys)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the latest session has yet to set keys, use the prior session
|
|
||||||
if let Some(prior_session) = latest_session.0.checked_sub(1).map(Session) {
|
|
||||||
if let Some(keys) = serai
|
|
||||||
.validator_sets()
|
|
||||||
.keys(ExternalValidatorSet { network, session: prior_session })
|
|
||||||
.await
|
|
||||||
.map_err(|e| format!("{e:?}"))?
|
|
||||||
{
|
|
||||||
return Ok(Some((prior_session, keys)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fetch the `ExternalValidatorSet`s, and their associated keys, used for cosigning as of this
|
|
||||||
/// block.
|
|
||||||
async fn cosigning_sets(
|
|
||||||
serai: &TemporalSerai<'_>,
|
|
||||||
) -> Result<Vec<(ExternalValidatorSet, Public)>, String> {
|
|
||||||
let mut sets = Vec::with_capacity(serai_client::primitives::EXTERNAL_NETWORKS.len());
|
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
|
||||||
let Some((session, keys)) = keys_for_network(serai, network).await? else {
|
|
||||||
// If this network doesn't have usable keys, move on
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
sets.push((ExternalValidatorSet { network, session }, keys.0));
|
|
||||||
}
|
|
||||||
Ok(sets)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An object usable to request notable cosigns for a block.
|
/// An object usable to request notable cosigns for a block.
|
||||||
pub trait RequestNotableCosigns: 'static + Send {
|
pub trait RequestNotableCosigns: 'static + Send {
|
||||||
/// The error type which may be encountered when requesting notable cosigns.
|
/// The error type which may be encountered when requesting notable cosigns.
|
||||||
@@ -331,7 +221,10 @@ impl<D: Db> Cosigning<D> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Fetch a cosigned Substrate block's hash by its block number.
|
/// Fetch a cosigned Substrate block's hash by its block number.
|
||||||
pub fn cosigned_block(getter: &impl Get, block_number: u64) -> Result<Option<[u8; 32]>, Faulted> {
|
pub fn cosigned_block(
|
||||||
|
getter: &impl Get,
|
||||||
|
block_number: u64,
|
||||||
|
) -> Result<Option<BlockHash>, Faulted> {
|
||||||
if block_number > Self::latest_cosigned_block_number(getter)? {
|
if block_number > Self::latest_cosigned_block_number(getter)? {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
@@ -346,8 +239,8 @@ impl<D: Db> Cosigning<D> {
|
|||||||
/// If this global session hasn't produced any notable cosigns, this will return the latest
|
/// If this global session hasn't produced any notable cosigns, this will return the latest
|
||||||
/// cosigns for this session.
|
/// cosigns for this session.
|
||||||
pub fn notable_cosigns(getter: &impl Get, global_session: [u8; 32]) -> Vec<SignedCosign> {
|
pub fn notable_cosigns(getter: &impl Get, global_session: [u8; 32]) -> Vec<SignedCosign> {
|
||||||
let mut cosigns = Vec::with_capacity(serai_client::primitives::EXTERNAL_NETWORKS.len());
|
let mut cosigns = vec![];
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
if let Some(cosign) = NetworksLatestCosignedBlock::get(getter, global_session, network) {
|
if let Some(cosign) = NetworksLatestCosignedBlock::get(getter, global_session, network) {
|
||||||
cosigns.push(cosign);
|
cosigns.push(cosign);
|
||||||
}
|
}
|
||||||
@@ -364,7 +257,7 @@ impl<D: Db> Cosigning<D> {
|
|||||||
let mut cosigns = Faults::get(&self.db, faulted).expect("faulted with no faults");
|
let mut cosigns = Faults::get(&self.db, faulted).expect("faulted with no faults");
|
||||||
// Also include all of our recognized-as-honest cosigns in an attempt to induce fault
|
// Also include all of our recognized-as-honest cosigns in an attempt to induce fault
|
||||||
// identification in those who see the faulty cosigns as honest
|
// identification in those who see the faulty cosigns as honest
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
if let Some(cosign) = NetworksLatestCosignedBlock::get(&self.db, faulted, network) {
|
if let Some(cosign) = NetworksLatestCosignedBlock::get(&self.db, faulted, network) {
|
||||||
if cosign.cosign.global_session == faulted {
|
if cosign.cosign.global_session == faulted {
|
||||||
cosigns.push(cosign);
|
cosigns.push(cosign);
|
||||||
@@ -376,8 +269,8 @@ impl<D: Db> Cosigning<D> {
|
|||||||
let Some(global_session) = evaluator::currently_evaluated_global_session(&self.db) else {
|
let Some(global_session) = evaluator::currently_evaluated_global_session(&self.db) else {
|
||||||
return vec![];
|
return vec![];
|
||||||
};
|
};
|
||||||
let mut cosigns = Vec::with_capacity(serai_client::primitives::EXTERNAL_NETWORKS.len());
|
let mut cosigns = vec![];
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
if let Some(cosign) = NetworksLatestCosignedBlock::get(&self.db, global_session, network) {
|
if let Some(cosign) = NetworksLatestCosignedBlock::get(&self.db, global_session, network) {
|
||||||
cosigns.push(cosign);
|
cosigns.push(cosign);
|
||||||
}
|
}
|
||||||
@@ -432,13 +325,8 @@ impl<D: Db> Cosigning<D> {
|
|||||||
|
|
||||||
// Check the cosign's signature
|
// Check the cosign's signature
|
||||||
{
|
{
|
||||||
let key = Public::from({
|
let key =
|
||||||
let Some(key) = global_session.keys.get(&network) else {
|
*global_session.keys.get(&network).ok_or(IntakeCosignError::NonParticipatingNetwork)?;
|
||||||
Err(IntakeCosignError::NonParticipatingNetwork)?
|
|
||||||
};
|
|
||||||
*key
|
|
||||||
});
|
|
||||||
|
|
||||||
if !signed_cosign.verify_signature(key) {
|
if !signed_cosign.verify_signature(key) {
|
||||||
Err(IntakeCosignError::InvalidSignature)?;
|
Err(IntakeCosignError::InvalidSignature)?;
|
||||||
}
|
}
|
||||||
|
|||||||
25
coordinator/cosign/types/Cargo.toml
Normal file
25
coordinator/cosign/types/Cargo.toml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
[package]
|
||||||
|
name = "serai-cosign-types"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Evaluator of cosigns for the Serai network"
|
||||||
|
license = "AGPL-3.0-only"
|
||||||
|
repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/cosign"
|
||||||
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
|
keywords = []
|
||||||
|
edition = "2021"
|
||||||
|
publish = false
|
||||||
|
rust-version = "1.85"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
schnorrkel = { version = "0.11", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
|
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||||
|
|
||||||
|
serai-primitives = { path = "../../../substrate/primitives", default-features = false, features = ["std"] }
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
AGPL-3.0-only license
|
AGPL-3.0-only license
|
||||||
|
|
||||||
Copyright (c) 2024 Luke Parker
|
Copyright (c) 2023-2025 Luke Parker
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License Version 3 as
|
it under the terms of the GNU Affero General Public License Version 3 as
|
||||||
72
coordinator/cosign/types/src/lib.rs
Normal file
72
coordinator/cosign/types/src/lib.rs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
//! Types used when cosigning Serai. For more info, please see `serai-cosign`.
|
||||||
|
use borsh::{BorshSerialize, BorshDeserialize};
|
||||||
|
|
||||||
|
use serai_primitives::{BlockHash, crypto::Public, network_id::ExternalNetworkId};
|
||||||
|
|
||||||
|
/// The schnorrkel context to used when signing a cosign.
|
||||||
|
pub const COSIGN_CONTEXT: &[u8] = b"/serai/coordinator/cosign";
|
||||||
|
|
||||||
|
/// An intended cosign.
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
||||||
|
pub struct CosignIntent {
|
||||||
|
/// The global session this cosign is being performed under.
|
||||||
|
pub global_session: [u8; 32],
|
||||||
|
/// The number of the block to cosign.
|
||||||
|
pub block_number: u64,
|
||||||
|
/// The hash of the block to cosign.
|
||||||
|
pub block_hash: BlockHash,
|
||||||
|
/// If this cosign must be handled before further cosigns are.
|
||||||
|
pub notable: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A cosign.
|
||||||
|
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
||||||
|
pub struct Cosign {
|
||||||
|
/// The global session this cosign is being performed under.
|
||||||
|
pub global_session: [u8; 32],
|
||||||
|
/// The number of the block to cosign.
|
||||||
|
pub block_number: u64,
|
||||||
|
/// The hash of the block to cosign.
|
||||||
|
pub block_hash: BlockHash,
|
||||||
|
/// The actual cosigner.
|
||||||
|
pub cosigner: ExternalNetworkId,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CosignIntent {
|
||||||
|
/// Convert this into a `Cosign`.
|
||||||
|
pub fn into_cosign(self, cosigner: ExternalNetworkId) -> Cosign {
|
||||||
|
let CosignIntent { global_session, block_number, block_hash, notable: _ } = self;
|
||||||
|
Cosign { global_session, block_number, block_hash, cosigner }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Cosign {
|
||||||
|
/// The message to sign to sign this cosign.
|
||||||
|
///
|
||||||
|
/// This must be signed with schnorrkel, the context set to `COSIGN_CONTEXT`.
|
||||||
|
pub fn signature_message(&self) -> Vec<u8> {
|
||||||
|
// We use a schnorrkel context to domain-separate this
|
||||||
|
borsh::to_vec(self).unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A signed cosign.
|
||||||
|
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
|
||||||
|
pub struct SignedCosign {
|
||||||
|
/// The cosign.
|
||||||
|
pub cosign: Cosign,
|
||||||
|
/// The signature for the cosign.
|
||||||
|
pub signature: [u8; 64],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SignedCosign {
|
||||||
|
/// Verify a cosign's signature.
|
||||||
|
pub fn verify_signature(&self, signer: Public) -> bool {
|
||||||
|
let Ok(signer) = schnorrkel::PublicKey::from_bytes(&signer.0) else { return false };
|
||||||
|
let Ok(signature) = schnorrkel::Signature::from_bytes(&self.signature) else { return false };
|
||||||
|
|
||||||
|
signer.verify_simple(COSIGN_CONTEXT, &self.cosign.signature_message(), &signature).is_ok()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
|||||||
keywords = []
|
keywords = []
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
rust-version = "1.81"
|
rust-version = "1.85"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -22,7 +22,7 @@ borsh = { version = "1", default-features = false, features = ["std", "derive",
|
|||||||
|
|
||||||
serai-db = { path = "../../common/db", version = "0.1" }
|
serai-db = { path = "../../common/db", version = "0.1" }
|
||||||
|
|
||||||
serai-client = { path = "../../substrate/client", default-features = false, features = ["serai", "borsh"] }
|
serai-primitives = { path = "../../substrate/primitives", default-features = false, features = ["std"] }
|
||||||
serai-cosign = { path = "../cosign" }
|
serai-cosign = { path = "../cosign" }
|
||||||
tributary-sdk = { path = "../tributary-sdk" }
|
tributary-sdk = { path = "../tributary-sdk" }
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
|||||||
keywords = []
|
keywords = []
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
rust-version = "1.81"
|
rust-version = "1.87"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -23,19 +23,19 @@ async-trait = { version = "0.1", default-features = false }
|
|||||||
rand_core = { version = "0.6", default-features = false, features = ["std"] }
|
rand_core = { version = "0.6", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
zeroize = { version = "^1.5", default-features = false, features = ["std"] }
|
zeroize = { version = "^1.5", default-features = false, features = ["std"] }
|
||||||
blake2 = { version = "0.10", default-features = false, features = ["std"] }
|
blake2 = { version = "0.11.0-rc.0", default-features = false, features = ["alloc"] }
|
||||||
schnorrkel = { version = "0.11", default-features = false, features = ["std"] }
|
schnorrkel = { version = "0.11", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
hex = { version = "0.4", default-features = false, features = ["std"] }
|
hex = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||||
|
|
||||||
serai-client = { path = "../../../substrate/client", default-features = false, features = ["serai", "borsh"] }
|
serai-client-serai = { path = "../../../substrate/client/serai", default-features = false }
|
||||||
serai-cosign = { path = "../../cosign" }
|
serai-cosign = { path = "../../cosign" }
|
||||||
tributary-sdk = { path = "../../tributary-sdk" }
|
tributary-sdk = { path = "../../tributary-sdk" }
|
||||||
|
|
||||||
futures-util = { version = "0.3", default-features = false, features = ["std"] }
|
futures-util = { version = "0.3", default-features = false, features = ["std"] }
|
||||||
tokio = { version = "1", default-features = false, features = ["sync"] }
|
tokio = { version = "1", default-features = false, features = ["sync"] }
|
||||||
libp2p = { version = "0.54", default-features = false, features = ["tokio", "tcp", "noise", "yamux", "ping", "request-response", "gossipsub", "macros"] }
|
libp2p = { version = "0.56", default-features = false, features = ["tokio", "tcp", "noise", "yamux", "ping", "request-response", "gossipsub", "macros"] }
|
||||||
|
|
||||||
log = { version = "0.4", default-features = false, features = ["std"] }
|
log = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
serai-task = { path = "../../../common/task", version = "0.1" }
|
serai-task = { path = "../../../common/task", version = "0.1" }
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use rand_core::{RngCore, OsRng};
|
|||||||
use blake2::{Digest, Blake2s256};
|
use blake2::{Digest, Blake2s256};
|
||||||
use schnorrkel::{Keypair, PublicKey, Signature};
|
use schnorrkel::{Keypair, PublicKey, Signature};
|
||||||
|
|
||||||
use serai_client::primitives::PublicKey as Public;
|
use serai_client_serai::abi::primitives::crypto::Public;
|
||||||
|
|
||||||
use futures_util::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
use futures_util::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
||||||
use libp2p::{
|
use libp2p::{
|
||||||
@@ -104,7 +104,7 @@ impl OnlyValidators {
|
|||||||
.verify_simple(PROTOCOL.as_bytes(), &msg, &sig)
|
.verify_simple(PROTOCOL.as_bytes(), &msg, &sig)
|
||||||
.map_err(|_| io::Error::other("invalid signature"))?;
|
.map_err(|_| io::Error::other("invalid signature"))?;
|
||||||
|
|
||||||
Ok(peer_id_from_public(Public::from_raw(public_key.to_bytes())))
|
Ok(peer_id_from_public(Public(public_key.to_bytes())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use core::future::Future;
|
use core::{future::Future, str::FromStr};
|
||||||
use std::{sync::Arc, collections::HashSet};
|
use std::{sync::Arc, collections::HashSet};
|
||||||
|
|
||||||
use rand_core::{RngCore, OsRng};
|
use rand_core::{RngCore, OsRng};
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use serai_client::{SeraiError, Serai};
|
use serai_client_serai::{RpcError, Serai};
|
||||||
|
|
||||||
use libp2p::{
|
use libp2p::{
|
||||||
core::multiaddr::{Protocol, Multiaddr},
|
core::multiaddr::{Protocol, Multiaddr},
|
||||||
@@ -50,7 +50,7 @@ impl ContinuallyRan for DialTask {
|
|||||||
const DELAY_BETWEEN_ITERATIONS: u64 = 5 * 60;
|
const DELAY_BETWEEN_ITERATIONS: u64 = 5 * 60;
|
||||||
const MAX_DELAY_BETWEEN_ITERATIONS: u64 = 10 * 60;
|
const MAX_DELAY_BETWEEN_ITERATIONS: u64 = 10 * 60;
|
||||||
|
|
||||||
type Error = SeraiError;
|
type Error = RpcError;
|
||||||
|
|
||||||
fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, Self::Error>> {
|
fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, Self::Error>> {
|
||||||
async move {
|
async move {
|
||||||
@@ -94,6 +94,13 @@ impl ContinuallyRan for DialTask {
|
|||||||
usize::try_from(OsRng.next_u64() % u64::try_from(potential_peers.len()).unwrap())
|
usize::try_from(OsRng.next_u64() % u64::try_from(potential_peers.len()).unwrap())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let randomly_selected_peer = potential_peers.swap_remove(index_to_dial);
|
let randomly_selected_peer = potential_peers.swap_remove(index_to_dial);
|
||||||
|
let Ok(randomly_selected_peer) = libp2p::Multiaddr::from_str(&randomly_selected_peer)
|
||||||
|
else {
|
||||||
|
log::error!(
|
||||||
|
"peer from substrate wasn't a valid `Multiaddr`: {randomly_selected_peer}"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
log::info!("found peer from substrate: {randomly_selected_peer}");
|
log::info!("found peer from substrate: {randomly_selected_peer}");
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
@@ -13,9 +13,10 @@ use rand_core::{RngCore, OsRng};
|
|||||||
use zeroize::Zeroizing;
|
use zeroize::Zeroizing;
|
||||||
use schnorrkel::Keypair;
|
use schnorrkel::Keypair;
|
||||||
|
|
||||||
use serai_client::{
|
use serai_client_serai::{
|
||||||
primitives::{ExternalNetworkId, PublicKey},
|
abi::primitives::{
|
||||||
validator_sets::primitives::ExternalValidatorSet,
|
crypto::Public, network_id::ExternalNetworkId, validator_sets::ExternalValidatorSet,
|
||||||
|
},
|
||||||
Serai,
|
Serai,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ use dial::DialTask;
|
|||||||
|
|
||||||
const PORT: u16 = 30563; // 5132 ^ (('c' << 8) | 'o')
|
const PORT: u16 = 30563; // 5132 ^ (('c' << 8) | 'o')
|
||||||
|
|
||||||
fn peer_id_from_public(public: PublicKey) -> PeerId {
|
fn peer_id_from_public(public: Public) -> PeerId {
|
||||||
// 0 represents the identity Multihash, that no hash was performed
|
// 0 represents the identity Multihash, that no hash was performed
|
||||||
// It's an internal constant so we can't refer to the constant inside libp2p
|
// It's an internal constant so we can't refer to the constant inside libp2p
|
||||||
PeerId::from_multihash(Multihash::wrap(0, &public.0).unwrap()).unwrap()
|
PeerId::from_multihash(Multihash::wrap(0, &public.0).unwrap()).unwrap()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::{
|
|||||||
|
|
||||||
use borsh::BorshDeserialize;
|
use borsh::BorshDeserialize;
|
||||||
|
|
||||||
use serai_client::validator_sets::primitives::ExternalValidatorSet;
|
use serai_client_serai::abi::primitives::validator_sets::ExternalValidatorSet;
|
||||||
|
|
||||||
use tokio::sync::{mpsc, oneshot, RwLock};
|
use tokio::sync::{mpsc, oneshot, RwLock};
|
||||||
|
|
||||||
@@ -92,7 +92,8 @@ impl SwarmTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
gossip::Event::Subscribed { .. } | gossip::Event::Unsubscribed { .. } => {}
|
gossip::Event::Subscribed { .. } | gossip::Event::Unsubscribed { .. } => {}
|
||||||
gossip::Event::GossipsubNotSupported { peer_id } => {
|
gossip::Event::GossipsubNotSupported { peer_id } |
|
||||||
|
gossip::Event::SlowPeer { peer_id, .. } => {
|
||||||
let _: Result<_, _> = self.swarm.disconnect_peer_id(peer_id);
|
let _: Result<_, _> = self.swarm.disconnect_peer_id(peer_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ use std::{
|
|||||||
collections::{HashSet, HashMap},
|
collections::{HashSet, HashMap},
|
||||||
};
|
};
|
||||||
|
|
||||||
use serai_client::{
|
use serai_client_serai::abi::primitives::{network_id::ExternalNetworkId, validator_sets::Session};
|
||||||
primitives::ExternalNetworkId, validator_sets::primitives::Session, SeraiError, Serai,
|
use serai_client_serai::{RpcError, Serai};
|
||||||
};
|
|
||||||
|
|
||||||
use serai_task::{Task, ContinuallyRan};
|
use serai_task::{Task, ContinuallyRan};
|
||||||
|
|
||||||
@@ -52,7 +51,7 @@ impl Validators {
|
|||||||
async fn session_changes(
|
async fn session_changes(
|
||||||
serai: impl Borrow<Serai>,
|
serai: impl Borrow<Serai>,
|
||||||
sessions: impl Borrow<HashMap<ExternalNetworkId, Session>>,
|
sessions: impl Borrow<HashMap<ExternalNetworkId, Session>>,
|
||||||
) -> Result<Vec<(ExternalNetworkId, Session, HashSet<PeerId>)>, SeraiError> {
|
) -> Result<Vec<(ExternalNetworkId, Session, HashSet<PeerId>)>, RpcError> {
|
||||||
/*
|
/*
|
||||||
This uses the latest finalized block, not the latest cosigned block, which should be fine as
|
This uses the latest finalized block, not the latest cosigned block, which should be fine as
|
||||||
in the worst case, we'd connect to unexpected validators. They still shouldn't be able to
|
in the worst case, we'd connect to unexpected validators. They still shouldn't be able to
|
||||||
@@ -61,18 +60,18 @@ impl Validators {
|
|||||||
|
|
||||||
Besides, we can't connect to historical validators, only the current validators.
|
Besides, we can't connect to historical validators, only the current validators.
|
||||||
*/
|
*/
|
||||||
let temporal_serai = serai.borrow().as_of_latest_finalized_block().await?;
|
let serai = serai.borrow().state().await?;
|
||||||
let temporal_serai = temporal_serai.validator_sets();
|
|
||||||
|
|
||||||
let mut session_changes = vec![];
|
let mut session_changes = vec![];
|
||||||
{
|
{
|
||||||
// FuturesUnordered can be bad practice as it'll cause timeouts if infrequently polled, but
|
// FuturesUnordered can be bad practice as it'll cause timeouts if infrequently polled, but
|
||||||
// we poll it till it yields all futures with the most minimal processing possible
|
// we poll it till it yields all futures with the most minimal processing possible
|
||||||
let mut futures = FuturesUnordered::new();
|
let mut futures = FuturesUnordered::new();
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
let sessions = sessions.borrow();
|
let sessions = sessions.borrow();
|
||||||
|
let serai = serai.borrow();
|
||||||
futures.push(async move {
|
futures.push(async move {
|
||||||
let session = match temporal_serai.session(network.into()).await {
|
let session = match serai.current_session(network.into()).await {
|
||||||
Ok(Some(session)) => session,
|
Ok(Some(session)) => session,
|
||||||
Ok(None) => return Ok(None),
|
Ok(None) => return Ok(None),
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
@@ -81,12 +80,16 @@ impl Validators {
|
|||||||
if sessions.get(&network) == Some(&session) {
|
if sessions.get(&network) == Some(&session) {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
} else {
|
} else {
|
||||||
match temporal_serai.active_network_validators(network.into()).await {
|
match serai.current_validators(network.into()).await {
|
||||||
Ok(validators) => Ok(Some((
|
Ok(Some(validators)) => Ok(Some((
|
||||||
network,
|
network,
|
||||||
session,
|
session,
|
||||||
validators.into_iter().map(peer_id_from_public).collect(),
|
validators
|
||||||
|
.into_iter()
|
||||||
|
.map(|validator| peer_id_from_public(validator.into()))
|
||||||
|
.collect(),
|
||||||
))),
|
))),
|
||||||
|
Ok(None) => panic!("network has session yet no validators"),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,7 +156,7 @@ impl Validators {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update the view of the validators.
|
/// Update the view of the validators.
|
||||||
pub(crate) async fn update(&mut self) -> Result<(), SeraiError> {
|
pub(crate) async fn update(&mut self) -> Result<(), RpcError> {
|
||||||
let session_changes = Self::session_changes(&*self.serai, &self.sessions).await?;
|
let session_changes = Self::session_changes(&*self.serai, &self.sessions).await?;
|
||||||
self.incorporate_session_changes(session_changes);
|
self.incorporate_session_changes(session_changes);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -206,7 +209,7 @@ impl ContinuallyRan for UpdateValidatorsTask {
|
|||||||
const DELAY_BETWEEN_ITERATIONS: u64 = 60;
|
const DELAY_BETWEEN_ITERATIONS: u64 = 60;
|
||||||
const MAX_DELAY_BETWEEN_ITERATIONS: u64 = 5 * 60;
|
const MAX_DELAY_BETWEEN_ITERATIONS: u64 = 5 * 60;
|
||||||
|
|
||||||
type Error = SeraiError;
|
type Error = RpcError;
|
||||||
|
|
||||||
fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, Self::Error>> {
|
fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, Self::Error>> {
|
||||||
async move {
|
async move {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
use serai_client::validator_sets::primitives::{MAX_KEY_SHARES_PER_SET, ExternalValidatorSet};
|
use serai_primitives::validator_sets::{ExternalValidatorSet, KeyShares};
|
||||||
|
|
||||||
use futures_lite::FutureExt;
|
use futures_lite::FutureExt;
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ pub const MIN_BLOCKS_PER_BATCH: usize = BLOCKS_PER_MINUTE + 1;
|
|||||||
/// commit is `8 + (validators * 32) + (32 + (validators * 32))` (for the time, list of validators,
|
/// commit is `8 + (validators * 32) + (32 + (validators * 32))` (for the time, list of validators,
|
||||||
/// and aggregate signature). Accordingly, this should be a safe over-estimate.
|
/// and aggregate signature). Accordingly, this should be a safe over-estimate.
|
||||||
pub const BATCH_SIZE_LIMIT: usize = MIN_BLOCKS_PER_BATCH *
|
pub const BATCH_SIZE_LIMIT: usize = MIN_BLOCKS_PER_BATCH *
|
||||||
(tributary_sdk::BLOCK_SIZE_LIMIT + 32 + ((MAX_KEY_SHARES_PER_SET as usize) * 128));
|
(tributary_sdk::BLOCK_SIZE_LIMIT + 32 + ((KeyShares::MAX_PER_SET as usize) * 128));
|
||||||
|
|
||||||
/// Sends a heartbeat to other validators on regular intervals informing them of our Tributary's
|
/// Sends a heartbeat to other validators on regular intervals informing them of our Tributary's
|
||||||
/// tip.
|
/// tip.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use borsh::{BorshSerialize, BorshDeserialize};
|
use borsh::{BorshSerialize, BorshDeserialize};
|
||||||
|
|
||||||
use serai_client::{primitives::ExternalNetworkId, validator_sets::primitives::ExternalValidatorSet};
|
use serai_primitives::{network_id::ExternalNetworkId, validator_sets::ExternalValidatorSet};
|
||||||
|
|
||||||
use serai_db::Db;
|
use serai_db::Db;
|
||||||
use tributary_sdk::{ReadWrite, TransactionTrait, Tributary, TributaryReader};
|
use tributary_sdk::{ReadWrite, TransactionTrait, Tributary, TributaryReader};
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ use serai_db::{create_db, db_channel};
|
|||||||
|
|
||||||
use dkg::Participant;
|
use dkg::Participant;
|
||||||
|
|
||||||
use serai_client::{
|
use serai_client_serai::abi::primitives::{
|
||||||
primitives::ExternalNetworkId,
|
crypto::KeyPair,
|
||||||
validator_sets::primitives::{Session, ExternalValidatorSet, KeyPair},
|
network_id::ExternalNetworkId,
|
||||||
|
validator_sets::{Session, ExternalValidatorSet},
|
||||||
};
|
};
|
||||||
|
|
||||||
use serai_cosign::SignedCosign;
|
use serai_cosign::SignedCosign;
|
||||||
@@ -103,7 +104,7 @@ mod _internal_db {
|
|||||||
// Tributary transactions to publish from the DKG confirmation task
|
// Tributary transactions to publish from the DKG confirmation task
|
||||||
TributaryTransactionsFromDkgConfirmation: (set: ExternalValidatorSet) -> Transaction,
|
TributaryTransactionsFromDkgConfirmation: (set: ExternalValidatorSet) -> Transaction,
|
||||||
// Participants to remove
|
// Participants to remove
|
||||||
RemoveParticipant: (set: ExternalValidatorSet) -> Participant,
|
RemoveParticipant: (set: ExternalValidatorSet) -> u16,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,10 +140,11 @@ impl RemoveParticipant {
|
|||||||
pub(crate) fn send(txn: &mut impl DbTxn, set: ExternalValidatorSet, participant: Participant) {
|
pub(crate) fn send(txn: &mut impl DbTxn, set: ExternalValidatorSet, participant: Participant) {
|
||||||
// If this set has yet to be retired, send this transaction
|
// If this set has yet to be retired, send this transaction
|
||||||
if RetiredTributary::get(txn, set.network).map(|session| session.0) < Some(set.session.0) {
|
if RetiredTributary::get(txn, set.network).map(|session| session.0) < Some(set.session.0) {
|
||||||
_internal_db::RemoveParticipant::send(txn, set, &participant);
|
_internal_db::RemoveParticipant::send(txn, set, &u16::from(participant));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub(crate) fn try_recv(txn: &mut impl DbTxn, set: ExternalValidatorSet) -> Option<Participant> {
|
pub(crate) fn try_recv(txn: &mut impl DbTxn, set: ExternalValidatorSet) -> Option<Participant> {
|
||||||
_internal_db::RemoveParticipant::try_recv(txn, set)
|
_internal_db::RemoveParticipant::try_recv(txn, set)
|
||||||
|
.map(|i| Participant::new(i).expect("sent invalid participant index for removal"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,22 +3,17 @@ use std::{boxed::Box, collections::HashMap};
|
|||||||
|
|
||||||
use zeroize::Zeroizing;
|
use zeroize::Zeroizing;
|
||||||
use rand_core::OsRng;
|
use rand_core::OsRng;
|
||||||
use ciphersuite::{group::GroupEncoding, Ciphersuite, Ristretto};
|
use ciphersuite::{group::GroupEncoding, *};
|
||||||
|
use dkg::{Participant, musig};
|
||||||
use frost_schnorrkel::{
|
use frost_schnorrkel::{
|
||||||
frost::{
|
frost::{curve::Ristretto, FrostError, sign::*},
|
||||||
dkg::{Participant, musig::musig},
|
|
||||||
FrostError,
|
|
||||||
sign::*,
|
|
||||||
},
|
|
||||||
Schnorrkel,
|
Schnorrkel,
|
||||||
};
|
};
|
||||||
|
|
||||||
use serai_db::{DbTxn, Db as DbTrait};
|
use serai_db::{DbTxn, Db as DbTrait};
|
||||||
|
|
||||||
use serai_client::{
|
#[rustfmt::skip]
|
||||||
primitives::SeraiAddress,
|
use serai_client_serai::abi::primitives::{validator_sets::ExternalValidatorSet, address::SeraiAddress};
|
||||||
validator_sets::primitives::{ExternalValidatorSet, musig_context, set_keys_message},
|
|
||||||
};
|
|
||||||
|
|
||||||
use serai_task::{DoesNotError, ContinuallyRan};
|
use serai_task::{DoesNotError, ContinuallyRan};
|
||||||
|
|
||||||
@@ -33,7 +28,7 @@ fn schnorrkel() -> Schnorrkel {
|
|||||||
|
|
||||||
fn our_i(
|
fn our_i(
|
||||||
set: &NewSetInformation,
|
set: &NewSetInformation,
|
||||||
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: &Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
data: &HashMap<Participant, Vec<u8>>,
|
data: &HashMap<Participant, Vec<u8>>,
|
||||||
) -> Participant {
|
) -> Participant {
|
||||||
let public = SeraiAddress((Ristretto::generator() * key.deref()).to_bytes());
|
let public = SeraiAddress((Ristretto::generator() * key.deref()).to_bytes());
|
||||||
@@ -127,7 +122,7 @@ pub(crate) struct ConfirmDkgTask<CD: DbTrait, TD: DbTrait> {
|
|||||||
set: NewSetInformation,
|
set: NewSetInformation,
|
||||||
tributary_db: TD,
|
tributary_db: TD,
|
||||||
|
|
||||||
key: Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
signer: Option<Signer>,
|
signer: Option<Signer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +131,7 @@ impl<CD: DbTrait, TD: DbTrait> ConfirmDkgTask<CD, TD> {
|
|||||||
db: CD,
|
db: CD,
|
||||||
set: NewSetInformation,
|
set: NewSetInformation,
|
||||||
tributary_db: TD,
|
tributary_db: TD,
|
||||||
key: Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { db, set, tributary_db, key, signer: None }
|
Self { db, set, tributary_db, key, signer: None }
|
||||||
}
|
}
|
||||||
@@ -155,16 +150,15 @@ impl<CD: DbTrait, TD: DbTrait> ConfirmDkgTask<CD, TD> {
|
|||||||
db: &mut CD,
|
db: &mut CD,
|
||||||
set: ExternalValidatorSet,
|
set: ExternalValidatorSet,
|
||||||
attempt: u32,
|
attempt: u32,
|
||||||
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
signer: &mut Option<Signer>,
|
signer: &mut Option<Signer>,
|
||||||
) {
|
) {
|
||||||
// Perform the preprocess
|
// Perform the preprocess
|
||||||
|
let public_key = Ristretto::generator() * key.deref();
|
||||||
let (machine, preprocess) = AlgorithmMachine::new(
|
let (machine, preprocess) = AlgorithmMachine::new(
|
||||||
schnorrkel(),
|
schnorrkel(),
|
||||||
// We use a 1-of-1 Musig here as we don't know who will actually be in this Musig yet
|
// We use a 1-of-1 Musig here as we don't know who will actually be in this Musig yet
|
||||||
musig(&musig_context(set.into()), key, &[Ristretto::generator() * key.deref()])
|
musig(ExternalValidatorSet::musig_context(&set), key, &[public_key]).unwrap(),
|
||||||
.unwrap()
|
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
.preprocess(&mut OsRng);
|
.preprocess(&mut OsRng);
|
||||||
// We take the preprocess so we can use it in a distinct machine with the actual Musig
|
// We take the preprocess so we can use it in a distinct machine with the actual Musig
|
||||||
@@ -199,7 +193,7 @@ impl<CD: DbTrait, TD: DbTrait> ContinuallyRan for ConfirmDkgTask<CD, TD> {
|
|||||||
// If we were sent a key to set, create the signer for it
|
// If we were sent a key to set, create the signer for it
|
||||||
if self.signer.is_none() && KeysToConfirm::get(&self.db, self.set.set).is_some() {
|
if self.signer.is_none() && KeysToConfirm::get(&self.db, self.set.set).is_some() {
|
||||||
// Create and publish the initial preprocess
|
// Create and publish the initial preprocess
|
||||||
Self::preprocess(&mut self.db, self.set.set, 0, &self.key, &mut self.signer);
|
Self::preprocess(&mut self.db, self.set.set, 0, self.key.clone(), &mut self.signer);
|
||||||
|
|
||||||
made_progress = true;
|
made_progress = true;
|
||||||
}
|
}
|
||||||
@@ -219,7 +213,13 @@ impl<CD: DbTrait, TD: DbTrait> ContinuallyRan for ConfirmDkgTask<CD, TD> {
|
|||||||
id: messages::sign::SignId { attempt, .. },
|
id: messages::sign::SignId { attempt, .. },
|
||||||
} => {
|
} => {
|
||||||
// Create and publish the preprocess for the specified attempt
|
// Create and publish the preprocess for the specified attempt
|
||||||
Self::preprocess(&mut self.db, self.set.set, attempt, &self.key, &mut self.signer);
|
Self::preprocess(
|
||||||
|
&mut self.db,
|
||||||
|
self.set.set,
|
||||||
|
attempt,
|
||||||
|
self.key.clone(),
|
||||||
|
&mut self.signer,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
messages::sign::CoordinatorMessage::Preprocesses {
|
messages::sign::CoordinatorMessage::Preprocesses {
|
||||||
id: messages::sign::SignId { attempt, .. },
|
id: messages::sign::SignId { attempt, .. },
|
||||||
@@ -258,9 +258,12 @@ impl<CD: DbTrait, TD: DbTrait> ContinuallyRan for ConfirmDkgTask<CD, TD> {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let keys = musig(&musig_context(self.set.set.into()), &self.key, &musig_public_keys)
|
let keys = musig(
|
||||||
.unwrap()
|
ExternalValidatorSet::musig_context(&self.set.set),
|
||||||
.into();
|
self.key.clone(),
|
||||||
|
&musig_public_keys,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// Rebuild the machine
|
// Rebuild the machine
|
||||||
let (machine, preprocess_from_cache) =
|
let (machine, preprocess_from_cache) =
|
||||||
@@ -294,9 +297,10 @@ impl<CD: DbTrait, TD: DbTrait> ContinuallyRan for ConfirmDkgTask<CD, TD> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Calculate our share
|
// Calculate our share
|
||||||
let (machine, share) = match handle_frost_error(
|
let (machine, share) = match handle_frost_error(machine.sign(
|
||||||
machine.sign(preprocesses, &set_keys_message(&self.set.set, &key_pair)),
|
preprocesses,
|
||||||
) {
|
&ExternalValidatorSet::set_keys_message(&self.set.set, &key_pair),
|
||||||
|
)) {
|
||||||
Ok((machine, share)) => (machine, share),
|
Ok((machine, share)) => (machine, share),
|
||||||
// This yields the *musig participant index*
|
// This yields the *musig participant index*
|
||||||
Err(participant) => {
|
Err(participant) => {
|
||||||
|
|||||||
@@ -4,18 +4,24 @@ use std::{sync::Arc, collections::HashMap, time::Instant};
|
|||||||
use zeroize::{Zeroize, Zeroizing};
|
use zeroize::{Zeroize, Zeroizing};
|
||||||
use rand_core::{RngCore, OsRng};
|
use rand_core::{RngCore, OsRng};
|
||||||
|
|
||||||
|
use dalek_ff_group::Ristretto;
|
||||||
use ciphersuite::{
|
use ciphersuite::{
|
||||||
group::{ff::PrimeField, GroupEncoding},
|
group::{ff::PrimeField, GroupEncoding},
|
||||||
Ciphersuite, Ristretto,
|
*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use borsh::BorshDeserialize;
|
use borsh::BorshDeserialize;
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use serai_client::{
|
use serai_client_serai::{
|
||||||
primitives::{ExternalNetworkId, PublicKey, SeraiAddress, Signature},
|
abi::primitives::{
|
||||||
validator_sets::primitives::{ExternalValidatorSet, KeyPair},
|
BlockHash,
|
||||||
|
crypto::{Public, Signature, ExternalKey, KeyPair},
|
||||||
|
network_id::ExternalNetworkId,
|
||||||
|
validator_sets::ExternalValidatorSet,
|
||||||
|
address::SeraiAddress,
|
||||||
|
},
|
||||||
Serai,
|
Serai,
|
||||||
};
|
};
|
||||||
use message_queue::{Service, client::MessageQueue};
|
use message_queue::{Service, client::MessageQueue};
|
||||||
@@ -60,9 +66,7 @@ async fn serai() -> Arc<Serai> {
|
|||||||
let Ok(serai) = Serai::new(format!(
|
let Ok(serai) = Serai::new(format!(
|
||||||
"http://{}:9944",
|
"http://{}:9944",
|
||||||
serai_env::var("SERAI_HOSTNAME").expect("Serai hostname wasn't provided")
|
serai_env::var("SERAI_HOSTNAME").expect("Serai hostname wasn't provided")
|
||||||
))
|
)) else {
|
||||||
.await
|
|
||||||
else {
|
|
||||||
log::error!("couldn't connect to the Serai node");
|
log::error!("couldn't connect to the Serai node");
|
||||||
tokio::time::sleep(delay).await;
|
tokio::time::sleep(delay).await;
|
||||||
delay = (delay + SERAI_CONNECTION_DELAY).min(MAX_SERAI_CONNECTION_DELAY);
|
delay = (delay + SERAI_CONNECTION_DELAY).min(MAX_SERAI_CONNECTION_DELAY);
|
||||||
@@ -212,10 +216,12 @@ async fn handle_network(
|
|||||||
&mut txn,
|
&mut txn,
|
||||||
ExternalValidatorSet { network, session },
|
ExternalValidatorSet { network, session },
|
||||||
&KeyPair(
|
&KeyPair(
|
||||||
PublicKey::from_raw(substrate_key),
|
Public(substrate_key),
|
||||||
network_key
|
ExternalKey(
|
||||||
.try_into()
|
network_key
|
||||||
.expect("generated a network key which exceeds the maximum key length"),
|
.try_into()
|
||||||
|
.expect("generated a network key which exceeds the maximum key length"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -289,6 +295,7 @@ async fn handle_network(
|
|||||||
},
|
},
|
||||||
messages::ProcessorMessage::Substrate(msg) => match msg {
|
messages::ProcessorMessage::Substrate(msg) => match msg {
|
||||||
messages::substrate::ProcessorMessage::SubstrateBlockAck { block, plans } => {
|
messages::substrate::ProcessorMessage::SubstrateBlockAck { block, plans } => {
|
||||||
|
let block = BlockHash(block);
|
||||||
let mut by_session = HashMap::new();
|
let mut by_session = HashMap::new();
|
||||||
for plan in plans {
|
for plan in plans {
|
||||||
by_session
|
by_session
|
||||||
@@ -351,7 +358,7 @@ async fn main() {
|
|||||||
let mut key_bytes = [0; 32];
|
let mut key_bytes = [0; 32];
|
||||||
key_bytes.copy_from_slice(&key_vec);
|
key_bytes.copy_from_slice(&key_vec);
|
||||||
key_vec.zeroize();
|
key_vec.zeroize();
|
||||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::from_repr(key_bytes).unwrap());
|
let key = Zeroizing::new(<Ristretto as WrappedGroup>::F::from_repr(key_bytes).unwrap());
|
||||||
key_bytes.zeroize();
|
key_bytes.zeroize();
|
||||||
key
|
key
|
||||||
};
|
};
|
||||||
@@ -438,7 +445,7 @@ async fn main() {
|
|||||||
EphemeralEventStream::new(
|
EphemeralEventStream::new(
|
||||||
db.clone(),
|
db.clone(),
|
||||||
serai.clone(),
|
serai.clone(),
|
||||||
SeraiAddress((<Ristretto as Ciphersuite>::generator() * serai_key.deref()).to_bytes()),
|
SeraiAddress((<Ristretto as WrappedGroup>::generator() * serai_key.deref()).to_bytes()),
|
||||||
)
|
)
|
||||||
.continually_run(substrate_ephemeral_task_def, vec![substrate_task]),
|
.continually_run(substrate_ephemeral_task_def, vec![substrate_task]),
|
||||||
);
|
);
|
||||||
@@ -480,7 +487,7 @@ async fn main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Handle each of the networks
|
// Handle each of the networks
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
tokio::spawn(handle_network(db.clone(), message_queue.clone(), serai.clone(), network));
|
tokio::spawn(handle_network(db.clone(), message_queue.clone(), serai.clone(), network));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,17 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use zeroize::Zeroizing;
|
use zeroize::Zeroizing;
|
||||||
|
|
||||||
use ciphersuite::{Ciphersuite, Ristretto};
|
use ciphersuite::*;
|
||||||
|
use dalek_ff_group::Ristretto;
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use serai_db::{DbTxn, Db as DbTrait};
|
use serai_db::{DbTxn, Db as DbTrait};
|
||||||
|
|
||||||
use serai_client::validator_sets::primitives::{Session, ExternalValidatorSet};
|
use serai_client_serai::abi::primitives::{
|
||||||
|
network_id::ExternalNetworkId,
|
||||||
|
validator_sets::{Session, ExternalValidatorSet},
|
||||||
|
};
|
||||||
use message_queue::{Service, Metadata, client::MessageQueue};
|
use message_queue::{Service, Metadata, client::MessageQueue};
|
||||||
|
|
||||||
use tributary_sdk::Tributary;
|
use tributary_sdk::Tributary;
|
||||||
@@ -22,7 +26,7 @@ use serai_coordinator_p2p::P2p;
|
|||||||
use crate::{Db, KeySet};
|
use crate::{Db, KeySet};
|
||||||
|
|
||||||
pub(crate) struct SubstrateTask<P: P2p> {
|
pub(crate) struct SubstrateTask<P: P2p> {
|
||||||
pub(crate) serai_key: Zeroizing<<Ristretto as Ciphersuite>::F>,
|
pub(crate) serai_key: Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
pub(crate) db: Db,
|
pub(crate) db: Db,
|
||||||
pub(crate) message_queue: Arc<MessageQueue>,
|
pub(crate) message_queue: Arc<MessageQueue>,
|
||||||
pub(crate) p2p: P,
|
pub(crate) p2p: P,
|
||||||
@@ -38,7 +42,7 @@ impl<P: P2p> ContinuallyRan for SubstrateTask<P> {
|
|||||||
let mut made_progress = false;
|
let mut made_progress = false;
|
||||||
|
|
||||||
// Handle the Canonical events
|
// Handle the Canonical events
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
loop {
|
loop {
|
||||||
let mut txn = self.db.txn();
|
let mut txn = self.db.txn();
|
||||||
let Some(msg) = serai_coordinator_substrate::Canonical::try_recv(&mut txn, network)
|
let Some(msg) = serai_coordinator_substrate::Canonical::try_recv(&mut txn, network)
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ use std::sync::Arc;
|
|||||||
use zeroize::Zeroizing;
|
use zeroize::Zeroizing;
|
||||||
use rand_core::OsRng;
|
use rand_core::OsRng;
|
||||||
use blake2::{digest::typenum::U32, Digest, Blake2s};
|
use blake2::{digest::typenum::U32, Digest, Blake2s};
|
||||||
use ciphersuite::{Ciphersuite, Ristretto};
|
use ciphersuite::*;
|
||||||
|
use dalek_ff_group::Ristretto;
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use serai_db::{Get, DbTxn, Db as DbTrait, create_db, db_channel};
|
use serai_db::{Get, DbTxn, Db as DbTrait, create_db, db_channel};
|
||||||
|
|
||||||
use scale::Encode;
|
use serai_client_serai::abi::primitives::validator_sets::ExternalValidatorSet;
|
||||||
use serai_client::validator_sets::primitives::ExternalValidatorSet;
|
|
||||||
|
|
||||||
use tributary_sdk::{TransactionKind, TransactionError, ProvidedError, TransactionTrait, Tributary};
|
use tributary_sdk::{TransactionKind, TransactionError, ProvidedError, TransactionTrait, Tributary};
|
||||||
|
|
||||||
@@ -67,9 +67,7 @@ async fn provide_transaction<TD: DbTrait, P: P2p>(
|
|||||||
// advancing
|
// advancing
|
||||||
Err(ProvidedError::LocalMismatchesOnChain) => loop {
|
Err(ProvidedError::LocalMismatchesOnChain) => loop {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Tributary {:?} was supposed to provide {:?} but peers disagree, halting Tributary",
|
"Tributary {set:?} was supposed to provide {tx:?} but peers disagree, halting Tributary",
|
||||||
set,
|
|
||||||
tx,
|
|
||||||
);
|
);
|
||||||
// Print this every five minutes as this does need to be handled
|
// Print this every five minutes as this does need to be handled
|
||||||
tokio::time::sleep(Duration::from_secs(5 * 60)).await;
|
tokio::time::sleep(Duration::from_secs(5 * 60)).await;
|
||||||
@@ -161,7 +159,7 @@ impl<CD: DbTrait, TD: DbTrait, P: P2p> ContinuallyRan
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
async fn add_signed_unsigned_transaction<TD: DbTrait, P: P2p>(
|
async fn add_signed_unsigned_transaction<TD: DbTrait, P: P2p>(
|
||||||
tributary: &Tributary<TD, Transaction, P>,
|
tributary: &Tributary<TD, Transaction, P>,
|
||||||
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: &Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
mut tx: Transaction,
|
mut tx: Transaction,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// If this is a signed transaction, sign it
|
// If this is a signed transaction, sign it
|
||||||
@@ -214,7 +212,7 @@ async fn add_with_recognition_check<TD: DbTrait, P: P2p>(
|
|||||||
set: ExternalValidatorSet,
|
set: ExternalValidatorSet,
|
||||||
tributary_db: &mut TD,
|
tributary_db: &mut TD,
|
||||||
tributary: &Tributary<TD, Transaction, P>,
|
tributary: &Tributary<TD, Transaction, P>,
|
||||||
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: &Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
tx: Transaction,
|
tx: Transaction,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let kind = tx.kind();
|
let kind = tx.kind();
|
||||||
@@ -253,7 +251,7 @@ pub(crate) struct AddTributaryTransactionsTask<CD: DbTrait, TD: DbTrait, P: P2p>
|
|||||||
tributary_db: TD,
|
tributary_db: TD,
|
||||||
tributary: Tributary<TD, Transaction, P>,
|
tributary: Tributary<TD, Transaction, P>,
|
||||||
set: NewSetInformation,
|
set: NewSetInformation,
|
||||||
key: Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
}
|
}
|
||||||
impl<CD: DbTrait, TD: DbTrait, P: P2p> ContinuallyRan for AddTributaryTransactionsTask<CD, TD, P> {
|
impl<CD: DbTrait, TD: DbTrait, P: P2p> ContinuallyRan for AddTributaryTransactionsTask<CD, TD, P> {
|
||||||
type Error = DoesNotError;
|
type Error = DoesNotError;
|
||||||
@@ -383,7 +381,7 @@ pub(crate) struct SignSlashReportTask<CD: DbTrait, TD: DbTrait, P: P2p> {
|
|||||||
tributary_db: TD,
|
tributary_db: TD,
|
||||||
tributary: Tributary<TD, Transaction, P>,
|
tributary: Tributary<TD, Transaction, P>,
|
||||||
set: NewSetInformation,
|
set: NewSetInformation,
|
||||||
key: Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
}
|
}
|
||||||
impl<CD: DbTrait, TD: DbTrait, P: P2p> ContinuallyRan for SignSlashReportTask<CD, TD, P> {
|
impl<CD: DbTrait, TD: DbTrait, P: P2p> ContinuallyRan for SignSlashReportTask<CD, TD, P> {
|
||||||
type Error = DoesNotError;
|
type Error = DoesNotError;
|
||||||
@@ -471,7 +469,7 @@ pub(crate) async fn spawn_tributary<P: P2p>(
|
|||||||
p2p: P,
|
p2p: P,
|
||||||
p2p_add_tributary: &mpsc::UnboundedSender<(ExternalValidatorSet, Tributary<Db, Transaction, P>)>,
|
p2p_add_tributary: &mpsc::UnboundedSender<(ExternalValidatorSet, Tributary<Db, Transaction, P>)>,
|
||||||
set: NewSetInformation,
|
set: NewSetInformation,
|
||||||
serai_key: Zeroizing<<Ristretto as Ciphersuite>::F>,
|
serai_key: Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
) {
|
) {
|
||||||
// Don't spawn retired Tributaries
|
// Don't spawn retired Tributaries
|
||||||
if crate::db::RetiredTributary::get(&db, set.set.network).map(|session| session.0) >=
|
if crate::db::RetiredTributary::get(&db, set.set.network).map(|session| session.0) >=
|
||||||
@@ -480,7 +478,8 @@ pub(crate) async fn spawn_tributary<P: P2p>(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let genesis = <[u8; 32]>::from(Blake2s::<U32>::digest((set.serai_block, set.set).encode()));
|
let genesis =
|
||||||
|
<[u8; 32]>::from(Blake2s::<U32>::digest(borsh::to_vec(&(set.serai_block, set.set)).unwrap()));
|
||||||
|
|
||||||
// Since the Serai block will be finalized, then cosigned, before we handle this, this time will
|
// Since the Serai block will be finalized, then cosigned, before we handle this, this time will
|
||||||
// be a couple of minutes stale. While the Tributary will still function with a start time in the
|
// be a couple of minutes stale. While the Tributary will still function with a start time in the
|
||||||
@@ -491,7 +490,7 @@ pub(crate) async fn spawn_tributary<P: P2p>(
|
|||||||
|
|
||||||
let mut tributary_validators = Vec::with_capacity(set.validators.len());
|
let mut tributary_validators = Vec::with_capacity(set.validators.len());
|
||||||
for (validator, weight) in set.validators.iter().copied() {
|
for (validator, weight) in set.validators.iter().copied() {
|
||||||
let validator_key = <Ristretto as Ciphersuite>::read_G(&mut validator.0.as_slice())
|
let validator_key = <Ristretto as GroupIo>::read_G(&mut validator.0.as_slice())
|
||||||
.expect("Serai validator had an invalid public key");
|
.expect("Serai validator had an invalid public key");
|
||||||
let weight = u64::from(weight);
|
let weight = u64::from(weight);
|
||||||
tributary_validators.push((validator_key, weight));
|
tributary_validators.push((validator_key, weight));
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
|||||||
keywords = []
|
keywords = []
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
rust-version = "1.81"
|
rust-version = "1.85"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -20,17 +20,15 @@ workspace = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
bitvec = { version = "1", default-features = false, features = ["std"] }
|
bitvec = { version = "1", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive", "bit-vec"] }
|
|
||||||
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||||
|
|
||||||
dkg = { path = "../../crypto/dkg", default-features = false, features = ["std"] }
|
dkg = { path = "../../crypto/dkg", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
serai-client = { path = "../../substrate/client", version = "0.1", default-features = false, features = ["serai", "borsh"] }
|
serai-client-serai = { path = "../../substrate/client/serai", default-features = false }
|
||||||
|
|
||||||
log = { version = "0.4", default-features = false, features = ["std"] }
|
log = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
futures = { version = "0.3", default-features = false, features = ["std"] }
|
futures = { version = "0.3", default-features = false, features = ["std"] }
|
||||||
tokio = { version = "1", default-features = false }
|
|
||||||
|
|
||||||
serai-db = { path = "../../common/db", version = "0.1.1" }
|
serai-db = { path = "../../common/db", version = "0.1.1" }
|
||||||
serai-task = { path = "../../common/task", version = "0.1" }
|
serai-task = { path = "../../common/task", version = "0.1" }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
AGPL-3.0-only license
|
AGPL-3.0-only license
|
||||||
|
|
||||||
Copyright (c) 2023-2024 Luke Parker
|
Copyright (c) 2023-2025 Luke Parker
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License Version 3 as
|
it under the terms of the GNU Affero General Public License Version 3 as
|
||||||
|
|||||||
@@ -3,7 +3,13 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use futures::stream::{StreamExt, FuturesOrdered};
|
use futures::stream::{StreamExt, FuturesOrdered};
|
||||||
|
|
||||||
use serai_client::{validator_sets::primitives::ExternalValidatorSet, Serai};
|
use serai_client_serai::{
|
||||||
|
abi::{
|
||||||
|
self,
|
||||||
|
primitives::{network_id::ExternalNetworkId, validator_sets::ExternalValidatorSet},
|
||||||
|
},
|
||||||
|
Serai,
|
||||||
|
};
|
||||||
|
|
||||||
use messages::substrate::{InInstructionResult, ExecutedBatch, CoordinatorMessage};
|
use messages::substrate::{InInstructionResult, ExecutedBatch, CoordinatorMessage};
|
||||||
|
|
||||||
@@ -15,6 +21,7 @@ use serai_cosign::Cosigning;
|
|||||||
create_db!(
|
create_db!(
|
||||||
CoordinatorSubstrateCanonical {
|
CoordinatorSubstrateCanonical {
|
||||||
NextBlock: () -> u64,
|
NextBlock: () -> u64,
|
||||||
|
LastIndexedBatchId: (network: ExternalNetworkId) -> u32,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -45,10 +52,10 @@ impl<D: Db> ContinuallyRan for CanonicalEventStream<D> {
|
|||||||
// These are all the events which generate canonical messages
|
// These are all the events which generate canonical messages
|
||||||
struct CanonicalEvents {
|
struct CanonicalEvents {
|
||||||
time: u64,
|
time: u64,
|
||||||
key_gen_events: Vec<serai_client::validator_sets::ValidatorSetsEvent>,
|
set_keys_events: Vec<abi::validator_sets::Event>,
|
||||||
set_retired_events: Vec<serai_client::validator_sets::ValidatorSetsEvent>,
|
slash_report_events: Vec<abi::validator_sets::Event>,
|
||||||
batch_events: Vec<serai_client::in_instructions::InInstructionsEvent>,
|
batch_events: Vec<abi::in_instructions::Event>,
|
||||||
burn_events: Vec<serai_client::coins::CoinsEvent>,
|
burn_events: Vec<abi::coins::Event>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// For a cosigned block, fetch all relevant events
|
// For a cosigned block, fetch all relevant events
|
||||||
@@ -66,40 +73,24 @@ impl<D: Db> ContinuallyRan for CanonicalEventStream<D> {
|
|||||||
}
|
}
|
||||||
Err(serai_cosign::Faulted) => return Err("cosigning process faulted".to_string()),
|
Err(serai_cosign::Faulted) => return Err("cosigning process faulted".to_string()),
|
||||||
};
|
};
|
||||||
let temporal_serai = serai.as_of(block_hash);
|
let events = serai.events(block_hash).await.map_err(|e| format!("{e}"))?;
|
||||||
let temporal_serai_validators = temporal_serai.validator_sets();
|
let set_keys_events = events.validator_sets().set_keys_events().cloned().collect();
|
||||||
let temporal_serai_instructions = temporal_serai.in_instructions();
|
let slash_report_events =
|
||||||
let temporal_serai_coins = temporal_serai.coins();
|
events.validator_sets().slash_report_events().cloned().collect();
|
||||||
|
let batch_events = events.in_instructions().batch_events().cloned().collect();
|
||||||
let (block, key_gen_events, set_retired_events, batch_events, burn_events) =
|
let burn_events = events.coins().burn_with_instruction_events().cloned().collect();
|
||||||
tokio::try_join!(
|
let Some(block) = serai.block(block_hash).await.map_err(|e| format!("{e:?}"))? else {
|
||||||
serai.block(block_hash),
|
|
||||||
temporal_serai_validators.key_gen_events(),
|
|
||||||
temporal_serai_validators.set_retired_events(),
|
|
||||||
temporal_serai_instructions.batch_events(),
|
|
||||||
temporal_serai_coins.burn_with_instruction_events(),
|
|
||||||
)
|
|
||||||
.map_err(|e| format!("{e:?}"))?;
|
|
||||||
let Some(block) = block else {
|
|
||||||
Err(format!("Serai node didn't have cosigned block #{block_number}"))?
|
Err(format!("Serai node didn't have cosigned block #{block_number}"))?
|
||||||
};
|
};
|
||||||
|
|
||||||
let time = if block_number == 0 {
|
// We use time in seconds, not milliseconds, here
|
||||||
block.time().unwrap_or(0)
|
let time = block.header.unix_time_in_millis() / 1000;
|
||||||
} else {
|
|
||||||
// Serai's block time is in milliseconds
|
|
||||||
block
|
|
||||||
.time()
|
|
||||||
.ok_or_else(|| "non-genesis Serai block didn't have a time".to_string())? /
|
|
||||||
1000
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
block_number,
|
block_number,
|
||||||
CanonicalEvents {
|
CanonicalEvents {
|
||||||
time,
|
time,
|
||||||
key_gen_events,
|
set_keys_events,
|
||||||
set_retired_events,
|
slash_report_events,
|
||||||
batch_events,
|
batch_events,
|
||||||
burn_events,
|
burn_events,
|
||||||
},
|
},
|
||||||
@@ -131,10 +122,9 @@ impl<D: Db> ContinuallyRan for CanonicalEventStream<D> {
|
|||||||
|
|
||||||
let mut txn = self.db.txn();
|
let mut txn = self.db.txn();
|
||||||
|
|
||||||
for key_gen in block.key_gen_events {
|
for set_keys in block.set_keys_events {
|
||||||
let serai_client::validator_sets::ValidatorSetsEvent::KeyGen { set, key_pair } = &key_gen
|
let abi::validator_sets::Event::SetKeys { set, key_pair } = &set_keys else {
|
||||||
else {
|
panic!("`SetKeys` event wasn't a `SetKeys` event: {set_keys:?}");
|
||||||
panic!("KeyGen event wasn't a KeyGen event: {key_gen:?}");
|
|
||||||
};
|
};
|
||||||
crate::Canonical::send(
|
crate::Canonical::send(
|
||||||
&mut txn,
|
&mut txn,
|
||||||
@@ -147,12 +137,10 @@ impl<D: Db> ContinuallyRan for CanonicalEventStream<D> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for set_retired in block.set_retired_events {
|
for slash_report in block.slash_report_events {
|
||||||
let serai_client::validator_sets::ValidatorSetsEvent::SetRetired { set } = &set_retired
|
let abi::validator_sets::Event::SlashReport { set } = &slash_report else {
|
||||||
else {
|
panic!("`SlashReport` event wasn't a `SlashReport` event: {slash_report:?}");
|
||||||
panic!("SetRetired event wasn't a SetRetired event: {set_retired:?}");
|
|
||||||
};
|
};
|
||||||
let Ok(set) = ExternalValidatorSet::try_from(*set) else { continue };
|
|
||||||
crate::Canonical::send(
|
crate::Canonical::send(
|
||||||
&mut txn,
|
&mut txn,
|
||||||
set.network,
|
set.network,
|
||||||
@@ -160,10 +148,12 @@ impl<D: Db> ContinuallyRan for CanonicalEventStream<D> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
let mut batch = None;
|
let mut batch = None;
|
||||||
for this_batch in &block.batch_events {
|
for this_batch in &block.batch_events {
|
||||||
let serai_client::in_instructions::InInstructionsEvent::Batch {
|
// Only irrefutable as this is the only member of the enum at this time
|
||||||
|
#[expect(irrefutable_let_patterns)]
|
||||||
|
let abi::in_instructions::Event::Batch {
|
||||||
network: batch_network,
|
network: batch_network,
|
||||||
publishing_session,
|
publishing_session,
|
||||||
id,
|
id,
|
||||||
@@ -194,14 +184,19 @@ impl<D: Db> ContinuallyRan for CanonicalEventStream<D> {
|
|||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if LastIndexedBatchId::get(&txn, network) != id.checked_sub(1) {
|
||||||
|
panic!(
|
||||||
|
"next batch from Serai's ID was not an increment of the last indexed batch's ID"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
LastIndexedBatchId::set(&mut txn, network, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut burns = vec![];
|
let mut burns = vec![];
|
||||||
for burn in &block.burn_events {
|
for burn in &block.burn_events {
|
||||||
let serai_client::coins::CoinsEvent::BurnWithInstruction { from: _, instruction } =
|
let abi::coins::Event::BurnWithInstruction { from: _, instruction } = &burn else {
|
||||||
&burn
|
|
||||||
else {
|
|
||||||
panic!("BurnWithInstruction event wasn't a BurnWithInstruction event: {burn:?}");
|
panic!("BurnWithInstruction event wasn't a BurnWithInstruction event: {burn:?}");
|
||||||
};
|
};
|
||||||
if instruction.balance.coin.network() == network {
|
if instruction.balance.coin.network() == network {
|
||||||
@@ -223,3 +218,7 @@ impl<D: Db> ContinuallyRan for CanonicalEventStream<D> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn last_indexed_batch_id(txn: &impl DbTxn, network: ExternalNetworkId) -> Option<u32> {
|
||||||
|
LastIndexedBatchId::get(txn, network)
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,9 +3,14 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use futures::stream::{StreamExt, FuturesOrdered};
|
use futures::stream::{StreamExt, FuturesOrdered};
|
||||||
|
|
||||||
use serai_client::{
|
use serai_client_serai::{
|
||||||
primitives::{SeraiAddress, EmbeddedEllipticCurve},
|
abi::primitives::{
|
||||||
validator_sets::primitives::{MAX_KEY_SHARES_PER_SET, ExternalValidatorSet},
|
BlockHash,
|
||||||
|
crypto::EmbeddedEllipticCurveKeys as EmbeddedEllipticCurveKeysStruct,
|
||||||
|
network_id::ExternalNetworkId,
|
||||||
|
validator_sets::{KeyShares, ExternalValidatorSet},
|
||||||
|
address::SeraiAddress,
|
||||||
|
},
|
||||||
Serai,
|
Serai,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -19,6 +24,10 @@ use crate::NewSetInformation;
|
|||||||
create_db!(
|
create_db!(
|
||||||
CoordinatorSubstrateEphemeral {
|
CoordinatorSubstrateEphemeral {
|
||||||
NextBlock: () -> u64,
|
NextBlock: () -> u64,
|
||||||
|
EmbeddedEllipticCurveKeys: (
|
||||||
|
network: ExternalNetworkId,
|
||||||
|
validator: SeraiAddress
|
||||||
|
) -> EmbeddedEllipticCurveKeysStruct,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -49,10 +58,11 @@ impl<D: Db> ContinuallyRan for EphemeralEventStream<D> {
|
|||||||
|
|
||||||
// These are all the events which generate canonical messages
|
// These are all the events which generate canonical messages
|
||||||
struct EphemeralEvents {
|
struct EphemeralEvents {
|
||||||
block_hash: [u8; 32],
|
block_hash: BlockHash,
|
||||||
time: u64,
|
time: u64,
|
||||||
new_set_events: Vec<serai_client::validator_sets::ValidatorSetsEvent>,
|
embedded_elliptic_curve_keys_events: Vec<serai_client_serai::abi::validator_sets::Event>,
|
||||||
accepted_handover_events: Vec<serai_client::validator_sets::ValidatorSetsEvent>,
|
set_decided_events: Vec<serai_client_serai::abi::validator_sets::Event>,
|
||||||
|
accepted_handover_events: Vec<serai_client_serai::abi::validator_sets::Event>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// For a cosigned block, fetch all relevant events
|
// For a cosigned block, fetch all relevant events
|
||||||
@@ -71,31 +81,31 @@ impl<D: Db> ContinuallyRan for EphemeralEventStream<D> {
|
|||||||
Err(serai_cosign::Faulted) => return Err("cosigning process faulted".to_string()),
|
Err(serai_cosign::Faulted) => return Err("cosigning process faulted".to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let temporal_serai = serai.as_of(block_hash);
|
let events = serai.events(block_hash).await.map_err(|e| format!("{e}"))?;
|
||||||
let temporal_serai_validators = temporal_serai.validator_sets();
|
let embedded_elliptic_curve_keys_events = events
|
||||||
let (block, new_set_events, accepted_handover_events) = tokio::try_join!(
|
.validator_sets()
|
||||||
serai.block(block_hash),
|
.set_embedded_elliptic_curve_keys_events()
|
||||||
temporal_serai_validators.new_set_events(),
|
.cloned()
|
||||||
temporal_serai_validators.accepted_handover_events(),
|
.collect::<Vec<_>>();
|
||||||
)
|
let set_decided_events =
|
||||||
.map_err(|e| format!("{e:?}"))?;
|
events.validator_sets().set_decided_events().cloned().collect::<Vec<_>>();
|
||||||
let Some(block) = block else {
|
let accepted_handover_events =
|
||||||
|
events.validator_sets().accepted_handover_events().cloned().collect::<Vec<_>>();
|
||||||
|
let Some(block) = serai.block(block_hash).await.map_err(|e| format!("{e:?}"))? else {
|
||||||
Err(format!("Serai node didn't have cosigned block #{block_number}"))?
|
Err(format!("Serai node didn't have cosigned block #{block_number}"))?
|
||||||
};
|
};
|
||||||
|
|
||||||
let time = if block_number == 0 {
|
// We use time in seconds, not milliseconds, here
|
||||||
block.time().unwrap_or(0)
|
let time = block.header.unix_time_in_millis() / 1000;
|
||||||
} else {
|
|
||||||
// Serai's block time is in milliseconds
|
|
||||||
block
|
|
||||||
.time()
|
|
||||||
.ok_or_else(|| "non-genesis Serai block didn't have a time".to_string())? /
|
|
||||||
1000
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
block_number,
|
block_number,
|
||||||
EphemeralEvents { block_hash, time, new_set_events, accepted_handover_events },
|
EphemeralEvents {
|
||||||
|
block_hash,
|
||||||
|
time,
|
||||||
|
embedded_elliptic_curve_keys_events,
|
||||||
|
set_decided_events,
|
||||||
|
accepted_handover_events,
|
||||||
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,105 +136,82 @@ impl<D: Db> ContinuallyRan for EphemeralEventStream<D> {
|
|||||||
|
|
||||||
let mut txn = self.db.txn();
|
let mut txn = self.db.txn();
|
||||||
|
|
||||||
for new_set in block.new_set_events {
|
for event in block.embedded_elliptic_curve_keys_events {
|
||||||
let serai_client::validator_sets::ValidatorSetsEvent::NewSet { set } = &new_set else {
|
let serai_client_serai::abi::validator_sets::Event::SetEmbeddedEllipticCurveKeys {
|
||||||
panic!("NewSet event wasn't a NewSet event: {new_set:?}");
|
validator,
|
||||||
|
keys,
|
||||||
|
} = &event
|
||||||
|
else {
|
||||||
|
panic!(
|
||||||
|
"{}: {event:?}",
|
||||||
|
"`SetEmbeddedEllipticCurveKeys` event wasn't a `SetEmbeddedEllipticCurveKeys` event"
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EmbeddedEllipticCurveKeys::set(&mut txn, keys.network(), *validator, keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
for set_decided in block.set_decided_events {
|
||||||
|
let serai_client_serai::abi::validator_sets::Event::SetDecided { set, validators } =
|
||||||
|
&set_decided
|
||||||
|
else {
|
||||||
|
panic!("`SetDecided` event wasn't a `SetDecided` event: {set_decided:?}");
|
||||||
|
};
|
||||||
|
|
||||||
// We only coordinate over external networks
|
// We only coordinate over external networks
|
||||||
let Ok(set) = ExternalValidatorSet::try_from(*set) else { continue };
|
let Ok(set) = ExternalValidatorSet::try_from(*set) else { continue };
|
||||||
|
let validators =
|
||||||
|
validators.iter().map(|(validator, weight)| (*validator, weight.0)).collect::<Vec<_>>();
|
||||||
|
|
||||||
let serai = self.serai.as_of(block.block_hash);
|
|
||||||
let serai = serai.validator_sets();
|
|
||||||
let Some(validators) =
|
|
||||||
serai.participants(set.network.into()).await.map_err(|e| format!("{e:?}"))?
|
|
||||||
else {
|
|
||||||
Err(format!(
|
|
||||||
"block #{block_number} declared a new set but didn't have the participants"
|
|
||||||
))?
|
|
||||||
};
|
|
||||||
let validators = validators
|
|
||||||
.into_iter()
|
|
||||||
.map(|(validator, weight)| (SeraiAddress::from(validator), weight))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let in_set = validators.iter().any(|(validator, _)| *validator == self.validator);
|
let in_set = validators.iter().any(|(validator, _)| *validator == self.validator);
|
||||||
if in_set {
|
if in_set {
|
||||||
if u16::try_from(validators.len()).is_err() {
|
if u16::try_from(validators.len()).is_err() {
|
||||||
Err("more than u16::MAX validators sent")?;
|
Err("more than u16::MAX validators sent")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Ok(validators) = validators
|
|
||||||
.into_iter()
|
|
||||||
.map(|(validator, weight)| u16::try_from(weight).map(|weight| (validator, weight)))
|
|
||||||
.collect::<Result<Vec<_>, _>>()
|
|
||||||
else {
|
|
||||||
Err("validator's weight exceeded u16::MAX".to_string())?
|
|
||||||
};
|
|
||||||
|
|
||||||
// Do the summation in u32 so we don't risk a u16 overflow
|
// Do the summation in u32 so we don't risk a u16 overflow
|
||||||
let total_weight = validators.iter().map(|(_, weight)| u32::from(*weight)).sum::<u32>();
|
let total_weight = validators.iter().map(|(_, weight)| u32::from(*weight)).sum::<u32>();
|
||||||
if total_weight > u32::from(MAX_KEY_SHARES_PER_SET) {
|
if total_weight > u32::from(KeyShares::MAX_PER_SET) {
|
||||||
Err(format!(
|
Err(format!(
|
||||||
"{set:?} has {total_weight} key shares when the max is {MAX_KEY_SHARES_PER_SET}"
|
"{set:?} has {total_weight} key shares when the max is {}",
|
||||||
|
KeyShares::MAX_PER_SET
|
||||||
))?;
|
))?;
|
||||||
}
|
}
|
||||||
let total_weight = u16::try_from(total_weight).unwrap();
|
let total_weight = u16::try_from(total_weight)
|
||||||
|
.expect("value smaller than `u16` constant but doesn't fit in `u16`");
|
||||||
|
|
||||||
// Fetch all of the validators' embedded elliptic curve keys
|
// Fetch all of the validators' embedded elliptic curve keys
|
||||||
let mut embedded_elliptic_curve_keys = FuturesOrdered::new();
|
|
||||||
for (validator, _) in &validators {
|
|
||||||
let validator = *validator;
|
|
||||||
// try_join doesn't return a future so we need to wrap it in this additional async
|
|
||||||
// block
|
|
||||||
embedded_elliptic_curve_keys.push_back(async move {
|
|
||||||
tokio::try_join!(
|
|
||||||
// One future to fetch the substrate embedded key
|
|
||||||
serai.embedded_elliptic_curve_key(
|
|
||||||
validator.into(),
|
|
||||||
EmbeddedEllipticCurve::Embedwards25519
|
|
||||||
),
|
|
||||||
// One future to fetch the external embedded key, if there is a distinct curve
|
|
||||||
async {
|
|
||||||
// `embedded_elliptic_curves` is documented to have the second entry be the
|
|
||||||
// network-specific curve (if it exists and is distinct from Embedwards25519)
|
|
||||||
if let Some(curve) = set.network.embedded_elliptic_curves().get(1) {
|
|
||||||
serai.embedded_elliptic_curve_key(validator.into(), *curve).await.map(Some)
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.map(|(substrate_embedded_key, external_embedded_key)| {
|
|
||||||
(validator, substrate_embedded_key, external_embedded_key)
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut evrf_public_keys = Vec::with_capacity(usize::from(total_weight));
|
let mut evrf_public_keys = Vec::with_capacity(usize::from(total_weight));
|
||||||
for (validator, weight) in &validators {
|
for (validator, weight) in &validators {
|
||||||
let (future_validator, substrate_embedded_key, external_embedded_key) =
|
let keys = match EmbeddedEllipticCurveKeys::get(&txn, set.network, *validator)
|
||||||
embedded_elliptic_curve_keys.next().await.unwrap().map_err(|e| format!("{e:?}"))?;
|
.expect("selected validator lacked embedded elliptic curve keys")
|
||||||
assert_eq!(*validator, future_validator);
|
{
|
||||||
let external_embedded_key =
|
EmbeddedEllipticCurveKeysStruct::Bitcoin(substrate, external) => {
|
||||||
external_embedded_key.unwrap_or(substrate_embedded_key.clone());
|
assert_eq!(set.network, ExternalNetworkId::Bitcoin);
|
||||||
match (substrate_embedded_key, external_embedded_key) {
|
(substrate, external.to_vec())
|
||||||
(Some(substrate_embedded_key), Some(external_embedded_key)) => {
|
|
||||||
let substrate_embedded_key = <[u8; 32]>::try_from(substrate_embedded_key)
|
|
||||||
.map_err(|_| "Embedwards25519 key wasn't 32 bytes".to_string())?;
|
|
||||||
for _ in 0 .. *weight {
|
|
||||||
evrf_public_keys.push((substrate_embedded_key, external_embedded_key.clone()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => Err("NewSet with validator missing an embedded key".to_string())?,
|
EmbeddedEllipticCurveKeysStruct::Ethereum(substrate, external) => {
|
||||||
|
assert_eq!(set.network, ExternalNetworkId::Ethereum);
|
||||||
|
(substrate, external.to_vec())
|
||||||
|
}
|
||||||
|
EmbeddedEllipticCurveKeysStruct::Monero(substrate) => {
|
||||||
|
assert_eq!(set.network, ExternalNetworkId::Monero);
|
||||||
|
(substrate, substrate.to_vec())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for _ in 0 .. *weight {
|
||||||
|
evrf_public_keys.push(keys.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut new_set = NewSetInformation {
|
let mut new_set = NewSetInformation {
|
||||||
set,
|
set,
|
||||||
serai_block: block.block_hash,
|
serai_block: block.block_hash.0,
|
||||||
declaration_time: block.time,
|
declaration_time: block.time,
|
||||||
// TODO: This should be inlined into the Processor's key gen code
|
// TODO: This should be inlined into the Processor's key gen code
|
||||||
// It's legacy from when we removed participants from the key gen
|
// It's legacy from when we removed participants from the key gen
|
||||||
threshold: ((total_weight * 2) / 3) + 1,
|
threshold: ((total_weight * 2) / 3) + 1,
|
||||||
|
// TODO: Why are `validators` and `evrf_public_keys` two separate fields?
|
||||||
validators,
|
validators,
|
||||||
evrf_public_keys,
|
evrf_public_keys,
|
||||||
participant_indexes: Default::default(),
|
participant_indexes: Default::default(),
|
||||||
@@ -238,7 +225,7 @@ impl<D: Db> ContinuallyRan for EphemeralEventStream<D> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for accepted_handover in block.accepted_handover_events {
|
for accepted_handover in block.accepted_handover_events {
|
||||||
let serai_client::validator_sets::ValidatorSetsEvent::AcceptedHandover { set } =
|
let serai_client_serai::abi::validator_sets::Event::AcceptedHandover { set } =
|
||||||
&accepted_handover
|
&accepted_handover
|
||||||
else {
|
else {
|
||||||
panic!("AcceptedHandover event wasn't a AcceptedHandover event: {accepted_handover:?}");
|
panic!("AcceptedHandover event wasn't a AcceptedHandover event: {accepted_handover:?}");
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use scale::{Encode, Decode};
|
|
||||||
use borsh::{BorshSerialize, BorshDeserialize};
|
use borsh::{BorshSerialize, BorshDeserialize};
|
||||||
|
|
||||||
use dkg::Participant;
|
use dkg::Participant;
|
||||||
|
|
||||||
use serai_client::{
|
use serai_client_serai::abi::{
|
||||||
primitives::{ExternalNetworkId, SeraiAddress, Signature},
|
primitives::{
|
||||||
validator_sets::primitives::{Session, ExternalValidatorSet, KeyPair, SlashReport},
|
network_id::ExternalNetworkId,
|
||||||
in_instructions::primitives::SignedBatch,
|
validator_sets::{Session, ExternalValidatorSet, SlashReport},
|
||||||
|
crypto::{Signature, KeyPair},
|
||||||
|
address::SeraiAddress,
|
||||||
|
instructions::SignedBatch,
|
||||||
|
},
|
||||||
Transaction,
|
Transaction,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -20,6 +23,7 @@ use serai_db::*;
|
|||||||
|
|
||||||
mod canonical;
|
mod canonical;
|
||||||
pub use canonical::CanonicalEventStream;
|
pub use canonical::CanonicalEventStream;
|
||||||
|
use canonical::last_indexed_batch_id;
|
||||||
mod ephemeral;
|
mod ephemeral;
|
||||||
pub use ephemeral::EphemeralEventStream;
|
pub use ephemeral::EphemeralEventStream;
|
||||||
|
|
||||||
@@ -38,7 +42,7 @@ pub struct NewSetInformation {
|
|||||||
pub set: ExternalValidatorSet,
|
pub set: ExternalValidatorSet,
|
||||||
/// The Serai block which declared it.
|
/// The Serai block which declared it.
|
||||||
pub serai_block: [u8; 32],
|
pub serai_block: [u8; 32],
|
||||||
/// The time of the block which declared it, in seconds.
|
/// The time of the block which declared it, in seconds since the epoch.
|
||||||
pub declaration_time: u64,
|
pub declaration_time: u64,
|
||||||
/// The threshold to use.
|
/// The threshold to use.
|
||||||
pub threshold: u16,
|
pub threshold: u16,
|
||||||
@@ -97,9 +101,9 @@ mod _public_db {
|
|||||||
create_db!(
|
create_db!(
|
||||||
CoordinatorSubstrate {
|
CoordinatorSubstrate {
|
||||||
// Keys to set on the Serai network
|
// Keys to set on the Serai network
|
||||||
Keys: (network: ExternalNetworkId) -> (Session, Vec<u8>),
|
Keys: (network: ExternalNetworkId) -> (Session, Transaction),
|
||||||
// Slash reports to publish onto the Serai network
|
// Slash reports to publish onto the Serai network
|
||||||
SlashReports: (network: ExternalNetworkId) -> (Session, Vec<u8>),
|
SlashReports: (network: ExternalNetworkId) -> (Session, Transaction),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -172,20 +176,19 @@ impl Keys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tx = serai_client::validator_sets::SeraiValidatorSets::set_keys(
|
let tx = serai_client_serai::ValidatorSets::set_keys(
|
||||||
set.network,
|
set.network,
|
||||||
key_pair,
|
key_pair,
|
||||||
signature_participants,
|
signature_participants,
|
||||||
signature,
|
signature,
|
||||||
);
|
);
|
||||||
_public_db::Keys::set(txn, set.network, &(set.session, tx.encode()));
|
_public_db::Keys::set(txn, set.network, &(set.session, tx));
|
||||||
}
|
}
|
||||||
pub(crate) fn take(
|
pub(crate) fn take(
|
||||||
txn: &mut impl DbTxn,
|
txn: &mut impl DbTxn,
|
||||||
network: ExternalNetworkId,
|
network: ExternalNetworkId,
|
||||||
) -> Option<(Session, Transaction)> {
|
) -> Option<(Session, Transaction)> {
|
||||||
let (session, tx) = _public_db::Keys::take(txn, network)?;
|
_public_db::Keys::take(txn, network)
|
||||||
Some((session, <_>::decode(&mut tx.as_slice()).unwrap()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +197,7 @@ pub struct SignedBatches;
|
|||||||
impl SignedBatches {
|
impl SignedBatches {
|
||||||
/// Send a `SignedBatch` to publish onto Serai.
|
/// Send a `SignedBatch` to publish onto Serai.
|
||||||
pub fn send(txn: &mut impl DbTxn, batch: &SignedBatch) {
|
pub fn send(txn: &mut impl DbTxn, batch: &SignedBatch) {
|
||||||
_public_db::SignedBatches::send(txn, batch.batch.network, batch);
|
_public_db::SignedBatches::send(txn, batch.batch.network(), batch);
|
||||||
}
|
}
|
||||||
pub(crate) fn try_recv(txn: &mut impl DbTxn, network: ExternalNetworkId) -> Option<SignedBatch> {
|
pub(crate) fn try_recv(txn: &mut impl DbTxn, network: ExternalNetworkId) -> Option<SignedBatch> {
|
||||||
_public_db::SignedBatches::try_recv(txn, network)
|
_public_db::SignedBatches::try_recv(txn, network)
|
||||||
@@ -221,18 +224,14 @@ impl SlashReports {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tx = serai_client::validator_sets::SeraiValidatorSets::report_slashes(
|
let tx =
|
||||||
set.network,
|
serai_client_serai::ValidatorSets::report_slashes(set.network, slash_report, signature);
|
||||||
slash_report,
|
_public_db::SlashReports::set(txn, set.network, &(set.session, tx));
|
||||||
signature,
|
|
||||||
);
|
|
||||||
_public_db::SlashReports::set(txn, set.network, &(set.session, tx.encode()));
|
|
||||||
}
|
}
|
||||||
pub(crate) fn take(
|
pub(crate) fn take(
|
||||||
txn: &mut impl DbTxn,
|
txn: &mut impl DbTxn,
|
||||||
network: ExternalNetworkId,
|
network: ExternalNetworkId,
|
||||||
) -> Option<(Session, Transaction)> {
|
) -> Option<(Session, Transaction)> {
|
||||||
let (session, tx) = _public_db::SlashReports::take(txn, network)?;
|
_public_db::SlashReports::take(txn, network)
|
||||||
Some((session, <_>::decode(&mut tx.as_slice()).unwrap()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
use serai_client_serai::{
|
||||||
use serai_client::{primitives::ExternalNetworkId, in_instructions::primitives::SignedBatch, SeraiError, Serai};
|
abi::primitives::{network_id::ExternalNetworkId, instructions::SignedBatch},
|
||||||
|
RpcError, Serai,
|
||||||
|
};
|
||||||
|
|
||||||
use serai_db::{Get, DbTxn, Db, create_db};
|
use serai_db::{Get, DbTxn, Db, create_db};
|
||||||
use serai_task::ContinuallyRan;
|
use serai_task::ContinuallyRan;
|
||||||
@@ -31,7 +33,7 @@ impl<D: Db> PublishBatchTask<D> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Db> ContinuallyRan for PublishBatchTask<D> {
|
impl<D: Db> ContinuallyRan for PublishBatchTask<D> {
|
||||||
type Error = SeraiError;
|
type Error = RpcError;
|
||||||
|
|
||||||
fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, Self::Error>> {
|
fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, Self::Error>> {
|
||||||
async move {
|
async move {
|
||||||
@@ -43,8 +45,8 @@ impl<D: Db> ContinuallyRan for PublishBatchTask<D> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// If this is a Batch not yet published, save it into our unordered mapping
|
// If this is a Batch not yet published, save it into our unordered mapping
|
||||||
if LastPublishedBatch::get(&txn, self.network) < Some(batch.batch.id) {
|
if LastPublishedBatch::get(&txn, self.network) < Some(batch.batch.id()) {
|
||||||
BatchesToPublish::set(&mut txn, self.network, batch.batch.id, &batch);
|
BatchesToPublish::set(&mut txn, self.network, batch.batch.id(), &batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
@@ -52,12 +54,8 @@ impl<D: Db> ContinuallyRan for PublishBatchTask<D> {
|
|||||||
|
|
||||||
// Synchronize our last published batch with the Serai network's
|
// Synchronize our last published batch with the Serai network's
|
||||||
let next_to_publish = {
|
let next_to_publish = {
|
||||||
// This uses the latest finalized block, not the latest cosigned block, which should be
|
|
||||||
// fine as in the worst case, the only impact is no longer attempting TX publication
|
|
||||||
let serai = self.serai.as_of_latest_finalized_block().await?;
|
|
||||||
let last_batch = serai.in_instructions().last_batch_for_network(self.network).await?;
|
|
||||||
|
|
||||||
let mut txn = self.db.txn();
|
let mut txn = self.db.txn();
|
||||||
|
let last_batch = crate::last_indexed_batch_id(&txn, self.network);
|
||||||
let mut our_last_batch = LastPublishedBatch::get(&txn, self.network);
|
let mut our_last_batch = LastPublishedBatch::get(&txn, self.network);
|
||||||
while our_last_batch < last_batch {
|
while our_last_batch < last_batch {
|
||||||
let next_batch = our_last_batch.map(|batch| batch + 1).unwrap_or(0);
|
let next_batch = our_last_batch.map(|batch| batch + 1).unwrap_or(0);
|
||||||
@@ -68,6 +66,7 @@ impl<D: Db> ContinuallyRan for PublishBatchTask<D> {
|
|||||||
if let Some(last_batch) = our_last_batch {
|
if let Some(last_batch) = our_last_batch {
|
||||||
LastPublishedBatch::set(&mut txn, self.network, &last_batch);
|
LastPublishedBatch::set(&mut txn, self.network, &last_batch);
|
||||||
}
|
}
|
||||||
|
txn.commit();
|
||||||
last_batch.map(|batch| batch + 1).unwrap_or(0)
|
last_batch.map(|batch| batch + 1).unwrap_or(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,7 +74,7 @@ impl<D: Db> ContinuallyRan for PublishBatchTask<D> {
|
|||||||
if let Some(batch) = BatchesToPublish::get(&self.db, self.network, next_to_publish) {
|
if let Some(batch) = BatchesToPublish::get(&self.db, self.network, next_to_publish) {
|
||||||
self
|
self
|
||||||
.serai
|
.serai
|
||||||
.publish(&serai_client::in_instructions::SeraiInInstructions::execute_batch(batch))
|
.publish_transaction(&serai_client_serai::InInstructions::execute_batch(batch))
|
||||||
.await?;
|
.await?;
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use serai_db::{DbTxn, Db};
|
use serai_db::{DbTxn, Db};
|
||||||
|
|
||||||
use serai_client::{primitives::ExternalNetworkId, validator_sets::primitives::Session, Serai};
|
use serai_client_serai::{
|
||||||
|
abi::primitives::{network_id::ExternalNetworkId, validator_sets::Session},
|
||||||
|
Serai,
|
||||||
|
};
|
||||||
|
|
||||||
use serai_task::ContinuallyRan;
|
use serai_task::ContinuallyRan;
|
||||||
|
|
||||||
@@ -33,10 +36,10 @@ impl<D: Db> PublishSlashReportTask<D> {
|
|||||||
|
|
||||||
// This uses the latest finalized block, not the latest cosigned block, which should be
|
// This uses the latest finalized block, not the latest cosigned block, which should be
|
||||||
// fine as in the worst case, the only impact is no longer attempting TX publication
|
// fine as in the worst case, the only impact is no longer attempting TX publication
|
||||||
let serai = self.serai.as_of_latest_finalized_block().await.map_err(|e| format!("{e:?}"))?;
|
let serai = self.serai.state().await.map_err(|e| format!("{e:?}"))?;
|
||||||
let serai = serai.validator_sets();
|
|
||||||
let session_after_slash_report = Session(session.0 + 1);
|
let session_after_slash_report = Session(session.0 + 1);
|
||||||
let current_session = serai.session(network.into()).await.map_err(|e| format!("{e:?}"))?;
|
let current_session =
|
||||||
|
serai.current_session(network.into()).await.map_err(|e| format!("{e:?}"))?;
|
||||||
let current_session = current_session.map(|session| session.0);
|
let current_session = current_session.map(|session| session.0);
|
||||||
// Only attempt to publish the slash report for session #n while session #n+1 is still
|
// Only attempt to publish the slash report for session #n while session #n+1 is still
|
||||||
// active
|
// active
|
||||||
@@ -55,14 +58,13 @@ impl<D: Db> PublishSlashReportTask<D> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If this session which should publish a slash report already has, move on
|
// If this session which should publish a slash report already has, move on
|
||||||
let key_pending_slash_report =
|
if !serai.pending_slash_report(network).await.map_err(|e| format!("{e:?}"))? {
|
||||||
serai.key_pending_slash_report(network).await.map_err(|e| format!("{e:?}"))?;
|
|
||||||
if key_pending_slash_report.is_none() {
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
match self.serai.publish(&slash_report).await {
|
// Since this slash report is still pending, publish it
|
||||||
|
match self.serai.publish_transaction(&slash_report).await {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
txn.commit();
|
txn.commit();
|
||||||
Ok(true)
|
Ok(true)
|
||||||
@@ -84,7 +86,7 @@ impl<D: Db> ContinuallyRan for PublishSlashReportTask<D> {
|
|||||||
async move {
|
async move {
|
||||||
let mut made_progress = false;
|
let mut made_progress = false;
|
||||||
let mut error = None;
|
let mut error = None;
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
let network_res = self.publish(network).await;
|
let network_res = self.publish(network).await;
|
||||||
// We made progress if any network successfully published their slash report
|
// We made progress if any network successfully published their slash report
|
||||||
made_progress |= network_res == Ok(true);
|
made_progress |= network_res == Ok(true);
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use serai_db::{DbTxn, Db};
|
use serai_db::{DbTxn, Db};
|
||||||
|
|
||||||
use serai_client::{validator_sets::primitives::ExternalValidatorSet, Serai};
|
use serai_client_serai::{
|
||||||
|
abi::primitives::{network_id::ExternalNetworkId, validator_sets::ExternalValidatorSet},
|
||||||
|
Serai,
|
||||||
|
};
|
||||||
|
|
||||||
use serai_task::ContinuallyRan;
|
use serai_task::ContinuallyRan;
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ impl<D: Db> ContinuallyRan for SetKeysTask<D> {
|
|||||||
fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, Self::Error>> {
|
fn run_iteration(&mut self) -> impl Send + Future<Output = Result<bool, Self::Error>> {
|
||||||
async move {
|
async move {
|
||||||
let mut made_progress = false;
|
let mut made_progress = false;
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
let mut txn = self.db.txn();
|
let mut txn = self.db.txn();
|
||||||
let Some((session, keys)) = Keys::take(&mut txn, network) else {
|
let Some((session, keys)) = Keys::take(&mut txn, network) else {
|
||||||
// No keys to set
|
// No keys to set
|
||||||
@@ -37,10 +40,9 @@ impl<D: Db> ContinuallyRan for SetKeysTask<D> {
|
|||||||
|
|
||||||
// This uses the latest finalized block, not the latest cosigned block, which should be
|
// This uses the latest finalized block, not the latest cosigned block, which should be
|
||||||
// fine as in the worst case, the only impact is no longer attempting TX publication
|
// fine as in the worst case, the only impact is no longer attempting TX publication
|
||||||
let serai =
|
let serai = self.serai.state().await.map_err(|e| format!("{e:?}"))?;
|
||||||
self.serai.as_of_latest_finalized_block().await.map_err(|e| format!("{e:?}"))?;
|
let current_session =
|
||||||
let serai = serai.validator_sets();
|
serai.current_session(network.into()).await.map_err(|e| format!("{e:?}"))?;
|
||||||
let current_session = serai.session(network.into()).await.map_err(|e| format!("{e:?}"))?;
|
|
||||||
let current_session = current_session.map(|session| session.0);
|
let current_session = current_session.map(|session| session.0);
|
||||||
// Only attempt to set these keys if this isn't a retired session
|
// Only attempt to set these keys if this isn't a retired session
|
||||||
if Some(session.0) < current_session {
|
if Some(session.0) < current_session {
|
||||||
@@ -67,7 +69,7 @@ impl<D: Db> ContinuallyRan for SetKeysTask<D> {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
match self.serai.publish(&keys).await {
|
match self.serai.publish_transaction(&keys).await {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
txn.commit();
|
txn.commit();
|
||||||
made_progress = true;
|
made_progress = true;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ license = "AGPL-3.0-only"
|
|||||||
repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tributary-sdk"
|
repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tributary-sdk"
|
||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.81"
|
rust-version = "1.85"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -24,18 +24,19 @@ zeroize = { version = "^1.5", default-features = false, features = ["std"] }
|
|||||||
rand = { version = "0.8", default-features = false, features = ["std"] }
|
rand = { version = "0.8", default-features = false, features = ["std"] }
|
||||||
rand_chacha = { version = "0.3", default-features = false, features = ["std"] }
|
rand_chacha = { version = "0.3", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
blake2 = { version = "0.10", default-features = false, features = ["std"] }
|
blake2 = { version = "0.11.0-rc.0", default-features = false, features = ["alloc"] }
|
||||||
transcript = { package = "flexible-transcript", path = "../../crypto/transcript", version = "0.3", default-features = false, features = ["std", "recommended"] }
|
transcript = { package = "flexible-transcript", path = "../../crypto/transcript", version = "0.3", default-features = false, features = ["std", "recommended"] }
|
||||||
|
|
||||||
ciphersuite = { package = "ciphersuite", path = "../../crypto/ciphersuite", version = "0.4", default-features = false, features = ["std", "ristretto"] }
|
ciphersuite = { path = "../../crypto/ciphersuite", version = "0.4", default-features = false, features = ["std"] }
|
||||||
schnorr = { package = "schnorr-signatures", path = "../../crypto/schnorr", version = "0.5", default-features = false, features = ["std"] }
|
dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = false, features = ["std"] }
|
||||||
|
schnorr = { package = "schnorr-signatures", path = "../../crypto/schnorr", version = "0.5", default-features = false, features = ["std", "aggregate"] }
|
||||||
|
|
||||||
hex = { version = "0.4", default-features = false, features = ["std"] }
|
hex = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
log = { version = "0.4", default-features = false, features = ["std"] }
|
log = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
serai-db = { path = "../../common/db", version = "0.1" }
|
serai-db = { path = "../../common/db", version = "0.1" }
|
||||||
|
|
||||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive"] }
|
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||||
futures-util = { version = "0.3", default-features = false, features = ["std", "sink", "channel"] }
|
futures-util = { version = "0.3", default-features = false, features = ["std", "sink", "channel"] }
|
||||||
futures-channel = { version = "0.3", default-features = false, features = ["std", "sink"] }
|
futures-channel = { version = "0.3", default-features = false, features = ["std", "sink"] }
|
||||||
tendermint = { package = "tendermint-machine", path = "./tendermint", version = "0.2" }
|
tendermint = { package = "tendermint-machine", path = "./tendermint", version = "0.2" }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
AGPL-3.0-only license
|
AGPL-3.0-only license
|
||||||
|
|
||||||
Copyright (c) 2023 Luke Parker
|
Copyright (c) 2023-2025 Luke Parker
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License Version 3 as
|
it under the terms of the GNU Affero General Public License Version 3 as
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
use std::collections::{VecDeque, HashSet};
|
use std::collections::{VecDeque, HashSet};
|
||||||
|
|
||||||
use ciphersuite::{group::GroupEncoding, Ciphersuite, Ristretto};
|
use dalek_ff_group::Ristretto;
|
||||||
|
use ciphersuite::{group::GroupEncoding, *};
|
||||||
|
|
||||||
use serai_db::{Get, DbTxn, Db};
|
use serai_db::{Get, DbTxn, Db};
|
||||||
|
|
||||||
use scale::Decode;
|
use borsh::BorshDeserialize;
|
||||||
|
|
||||||
use tendermint::ext::{Network, Commit};
|
use tendermint::ext::{Network, Commit};
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ pub(crate) struct Blockchain<D: Db, T: TransactionTrait> {
|
|||||||
|
|
||||||
block_number: u64,
|
block_number: u64,
|
||||||
tip: [u8; 32],
|
tip: [u8; 32],
|
||||||
participants: HashSet<<Ristretto as Ciphersuite>::G>,
|
participants: HashSet<[u8; 32]>,
|
||||||
|
|
||||||
provided: ProvidedTransactions<D, T>,
|
provided: ProvidedTransactions<D, T>,
|
||||||
mempool: Mempool<D, T>,
|
mempool: Mempool<D, T>,
|
||||||
@@ -55,25 +56,28 @@ impl<D: Db, T: TransactionTrait> Blockchain<D, T> {
|
|||||||
}
|
}
|
||||||
fn next_nonce_key(
|
fn next_nonce_key(
|
||||||
genesis: &[u8; 32],
|
genesis: &[u8; 32],
|
||||||
signer: &<Ristretto as Ciphersuite>::G,
|
signer: &<Ristretto as WrappedGroup>::G,
|
||||||
order: &[u8],
|
order: &[u8],
|
||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
D::key(
|
D::key(
|
||||||
b"tributary_blockchain",
|
b"tributary_blockchain",
|
||||||
b"next_nonce",
|
b"next_nonce",
|
||||||
[genesis.as_ref(), signer.to_bytes().as_ref(), order].concat(),
|
[genesis.as_slice(), signer.to_bytes().as_slice(), order].concat(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
db: D,
|
db: D,
|
||||||
genesis: [u8; 32],
|
genesis: [u8; 32],
|
||||||
participants: &[<Ristretto as Ciphersuite>::G],
|
participants: &[<Ristretto as WrappedGroup>::G],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut res = Self {
|
let mut res = Self {
|
||||||
db: Some(db.clone()),
|
db: Some(db.clone()),
|
||||||
genesis,
|
genesis,
|
||||||
participants: participants.iter().copied().collect(),
|
participants: participants
|
||||||
|
.iter()
|
||||||
|
.map(<<Ristretto as WrappedGroup>::G as GroupEncoding>::to_bytes)
|
||||||
|
.collect(),
|
||||||
|
|
||||||
block_number: 0,
|
block_number: 0,
|
||||||
tip: genesis,
|
tip: genesis,
|
||||||
@@ -105,7 +109,7 @@ impl<D: Db, T: TransactionTrait> Blockchain<D, T> {
|
|||||||
|
|
||||||
pub(crate) fn block_from_db(db: &D, genesis: [u8; 32], block: &[u8; 32]) -> Option<Block<T>> {
|
pub(crate) fn block_from_db(db: &D, genesis: [u8; 32], block: &[u8; 32]) -> Option<Block<T>> {
|
||||||
db.get(Self::block_key(&genesis, block))
|
db.get(Self::block_key(&genesis, block))
|
||||||
.map(|bytes| Block::<T>::read::<&[u8]>(&mut bytes.as_ref()).unwrap())
|
.map(|bytes| Block::<T>::read::<&[u8]>(&mut bytes.as_slice()).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn commit_from_db(db: &D, genesis: [u8; 32], block: &[u8; 32]) -> Option<Vec<u8>> {
|
pub(crate) fn commit_from_db(db: &D, genesis: [u8; 32], block: &[u8; 32]) -> Option<Vec<u8>> {
|
||||||
@@ -165,14 +169,14 @@ impl<D: Db, T: TransactionTrait> Blockchain<D, T> {
|
|||||||
// we must have a commit per valid hash
|
// we must have a commit per valid hash
|
||||||
let commit = Self::commit_from_db(db, genesis, &hash).unwrap();
|
let commit = Self::commit_from_db(db, genesis, &hash).unwrap();
|
||||||
// commit has to be valid if it is coming from our db
|
// commit has to be valid if it is coming from our db
|
||||||
Some(Commit::<N::SignatureScheme>::decode(&mut commit.as_ref()).unwrap())
|
Some(Commit::<N::SignatureScheme>::deserialize_reader(&mut commit.as_slice()).unwrap())
|
||||||
};
|
};
|
||||||
let unsigned_in_chain =
|
let unsigned_in_chain =
|
||||||
|hash: [u8; 32]| db.get(Self::unsigned_included_key(&self.genesis, &hash)).is_some();
|
|hash: [u8; 32]| db.get(Self::unsigned_included_key(&self.genesis, &hash)).is_some();
|
||||||
|
|
||||||
self.mempool.add::<N, _>(
|
self.mempool.add::<N, _>(
|
||||||
|signer, order| {
|
|signer, order| {
|
||||||
if self.participants.contains(&signer) {
|
if self.participants.contains(&signer.to_bytes()) {
|
||||||
Some(
|
Some(
|
||||||
db.get(Self::next_nonce_key(&self.genesis, &signer, &order))
|
db.get(Self::next_nonce_key(&self.genesis, &signer, &order))
|
||||||
.map_or(0, |bytes| u32::from_le_bytes(bytes.try_into().unwrap())),
|
.map_or(0, |bytes| u32::from_le_bytes(bytes.try_into().unwrap())),
|
||||||
@@ -195,13 +199,13 @@ impl<D: Db, T: TransactionTrait> Blockchain<D, T> {
|
|||||||
|
|
||||||
pub(crate) fn next_nonce(
|
pub(crate) fn next_nonce(
|
||||||
&self,
|
&self,
|
||||||
signer: &<Ristretto as Ciphersuite>::G,
|
signer: &<Ristretto as WrappedGroup>::G,
|
||||||
order: &[u8],
|
order: &[u8],
|
||||||
) -> Option<u32> {
|
) -> Option<u32> {
|
||||||
if let Some(next_nonce) = self.mempool.next_nonce_in_mempool(signer, order.to_vec()) {
|
if let Some(next_nonce) = self.mempool.next_nonce_in_mempool(signer, order.to_vec()) {
|
||||||
return Some(next_nonce);
|
return Some(next_nonce);
|
||||||
}
|
}
|
||||||
if self.participants.contains(signer) {
|
if self.participants.contains(&signer.to_bytes()) {
|
||||||
Some(
|
Some(
|
||||||
self
|
self
|
||||||
.db
|
.db
|
||||||
@@ -240,7 +244,7 @@ impl<D: Db, T: TransactionTrait> Blockchain<D, T> {
|
|||||||
let commit = |block: u64| -> Option<Commit<N::SignatureScheme>> {
|
let commit = |block: u64| -> Option<Commit<N::SignatureScheme>> {
|
||||||
let commit = self.commit_by_block_number(block)?;
|
let commit = self.commit_by_block_number(block)?;
|
||||||
// commit has to be valid if it is coming from our db
|
// commit has to be valid if it is coming from our db
|
||||||
Some(Commit::<N::SignatureScheme>::decode(&mut commit.as_ref()).unwrap())
|
Some(Commit::<N::SignatureScheme>::deserialize_reader(&mut commit.as_slice()).unwrap())
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut txn_db = db.clone();
|
let mut txn_db = db.clone();
|
||||||
@@ -250,7 +254,7 @@ impl<D: Db, T: TransactionTrait> Blockchain<D, T> {
|
|||||||
self.tip,
|
self.tip,
|
||||||
self.provided.transactions.clone(),
|
self.provided.transactions.clone(),
|
||||||
&mut |signer, order| {
|
&mut |signer, order| {
|
||||||
if self.participants.contains(signer) {
|
if self.participants.contains(&signer.to_bytes()) {
|
||||||
let key = Self::next_nonce_key(&self.genesis, signer, order);
|
let key = Self::next_nonce_key(&self.genesis, signer, order);
|
||||||
let next = txn
|
let next = txn
|
||||||
.get(&key)
|
.get(&key)
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ use std::{sync::Arc, io};
|
|||||||
|
|
||||||
use zeroize::Zeroizing;
|
use zeroize::Zeroizing;
|
||||||
|
|
||||||
use ciphersuite::{Ciphersuite, Ristretto};
|
use borsh::BorshDeserialize;
|
||||||
|
|
||||||
|
use ciphersuite::*;
|
||||||
|
use dalek_ff_group::Ristretto;
|
||||||
|
|
||||||
use scale::Decode;
|
|
||||||
use futures_channel::mpsc::UnboundedReceiver;
|
use futures_channel::mpsc::UnboundedReceiver;
|
||||||
use futures_util::{StreamExt, SinkExt};
|
use futures_util::{StreamExt, SinkExt};
|
||||||
use ::tendermint::{
|
use ::tendermint::{
|
||||||
@@ -161,8 +163,8 @@ impl<D: Db, T: TransactionTrait, P: P2p> Tributary<D, T, P> {
|
|||||||
db: D,
|
db: D,
|
||||||
genesis: [u8; 32],
|
genesis: [u8; 32],
|
||||||
start_time: u64,
|
start_time: u64,
|
||||||
key: Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
validators: Vec<(<Ristretto as Ciphersuite>::G, u64)>,
|
validators: Vec<(<Ristretto as WrappedGroup>::G, u64)>,
|
||||||
p2p: P,
|
p2p: P,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
log::info!("new Tributary with genesis {}", hex::encode(genesis));
|
log::info!("new Tributary with genesis {}", hex::encode(genesis));
|
||||||
@@ -176,7 +178,7 @@ impl<D: Db, T: TransactionTrait, P: P2p> Tributary<D, T, P> {
|
|||||||
let block_number = BlockNumber(blockchain.block_number());
|
let block_number = BlockNumber(blockchain.block_number());
|
||||||
|
|
||||||
let start_time = if let Some(commit) = blockchain.commit(&blockchain.tip()) {
|
let start_time = if let Some(commit) = blockchain.commit(&blockchain.tip()) {
|
||||||
Commit::<Validators>::decode(&mut commit.as_ref()).unwrap().end_time
|
Commit::<Validators>::deserialize_reader(&mut commit.as_slice()).unwrap().end_time
|
||||||
} else {
|
} else {
|
||||||
start_time
|
start_time
|
||||||
};
|
};
|
||||||
@@ -234,7 +236,7 @@ impl<D: Db, T: TransactionTrait, P: P2p> Tributary<D, T, P> {
|
|||||||
|
|
||||||
pub async fn next_nonce(
|
pub async fn next_nonce(
|
||||||
&self,
|
&self,
|
||||||
signer: &<Ristretto as Ciphersuite>::G,
|
signer: &<Ristretto as WrappedGroup>::G,
|
||||||
order: &[u8],
|
order: &[u8],
|
||||||
) -> Option<u32> {
|
) -> Option<u32> {
|
||||||
self.network.blockchain.read().await.next_nonce(signer, order)
|
self.network.blockchain.read().await.next_nonce(signer, order)
|
||||||
@@ -275,8 +277,8 @@ impl<D: Db, T: TransactionTrait, P: P2p> Tributary<D, T, P> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let block = TendermintBlock(block.serialize());
|
let block = TendermintBlock(block.serialize());
|
||||||
let mut commit_ref = commit.as_ref();
|
let mut commit_ref = commit.as_slice();
|
||||||
let Ok(commit) = Commit::<Arc<Validators>>::decode(&mut commit_ref) else {
|
let Ok(commit) = Commit::<Arc<Validators>>::deserialize_reader(&mut commit_ref) else {
|
||||||
log::error!("sent an invalidly serialized commit");
|
log::error!("sent an invalidly serialized commit");
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -326,7 +328,7 @@ impl<D: Db, T: TransactionTrait, P: P2p> Tributary<D, T, P> {
|
|||||||
|
|
||||||
Some(&TENDERMINT_MESSAGE) => {
|
Some(&TENDERMINT_MESSAGE) => {
|
||||||
let Ok(msg) =
|
let Ok(msg) =
|
||||||
SignedMessageFor::<TendermintNetwork<D, T, P>>::decode::<&[u8]>(&mut &msg[1 ..])
|
SignedMessageFor::<TendermintNetwork<D, T, P>>::deserialize_reader(&mut &msg[1 ..])
|
||||||
else {
|
else {
|
||||||
log::error!("received invalid tendermint message");
|
log::error!("received invalid tendermint message");
|
||||||
return false;
|
return false;
|
||||||
@@ -366,15 +368,17 @@ impl<D: Db, T: TransactionTrait> TributaryReader<D, T> {
|
|||||||
Blockchain::<D, T>::commit_from_db(&self.0, self.1, hash)
|
Blockchain::<D, T>::commit_from_db(&self.0, self.1, hash)
|
||||||
}
|
}
|
||||||
pub fn parsed_commit(&self, hash: &[u8; 32]) -> Option<Commit<Validators>> {
|
pub fn parsed_commit(&self, hash: &[u8; 32]) -> Option<Commit<Validators>> {
|
||||||
self.commit(hash).map(|commit| Commit::<Validators>::decode(&mut commit.as_ref()).unwrap())
|
self
|
||||||
|
.commit(hash)
|
||||||
|
.map(|commit| Commit::<Validators>::deserialize_reader(&mut commit.as_slice()).unwrap())
|
||||||
}
|
}
|
||||||
pub fn block_after(&self, hash: &[u8; 32]) -> Option<[u8; 32]> {
|
pub fn block_after(&self, hash: &[u8; 32]) -> Option<[u8; 32]> {
|
||||||
Blockchain::<D, T>::block_after(&self.0, self.1, hash)
|
Blockchain::<D, T>::block_after(&self.0, self.1, hash)
|
||||||
}
|
}
|
||||||
pub fn time_of_block(&self, hash: &[u8; 32]) -> Option<u64> {
|
pub fn time_of_block(&self, hash: &[u8; 32]) -> Option<u64> {
|
||||||
self
|
self.commit(hash).map(|commit| {
|
||||||
.commit(hash)
|
Commit::<Validators>::deserialize_reader(&mut commit.as_slice()).unwrap().end_time
|
||||||
.map(|commit| Commit::<Validators>::decode(&mut commit.as_ref()).unwrap().end_time)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn locally_provided_txs_in_block(&self, hash: &[u8; 32], order: &str) -> bool {
|
pub fn locally_provided_txs_in_block(&self, hash: &[u8; 32], order: &str) -> bool {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use ciphersuite::{Ciphersuite, Ristretto};
|
use dalek_ff_group::Ristretto;
|
||||||
|
use ciphersuite::{group::GroupEncoding, *};
|
||||||
|
|
||||||
use serai_db::{DbTxn, Db};
|
use serai_db::{DbTxn, Db};
|
||||||
|
|
||||||
@@ -20,9 +21,9 @@ pub(crate) struct Mempool<D: Db, T: TransactionTrait> {
|
|||||||
db: D,
|
db: D,
|
||||||
genesis: [u8; 32],
|
genesis: [u8; 32],
|
||||||
|
|
||||||
last_nonce_in_mempool: HashMap<(<Ristretto as Ciphersuite>::G, Vec<u8>), u32>,
|
last_nonce_in_mempool: HashMap<([u8; 32], Vec<u8>), u32>,
|
||||||
txs: HashMap<[u8; 32], Transaction<T>>,
|
txs: HashMap<[u8; 32], Transaction<T>>,
|
||||||
txs_per_signer: HashMap<<Ristretto as Ciphersuite>::G, u32>,
|
txs_per_signer: HashMap<[u8; 32], u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
||||||
@@ -81,6 +82,7 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
|||||||
}
|
}
|
||||||
Transaction::Application(tx) => match tx.kind() {
|
Transaction::Application(tx) => match tx.kind() {
|
||||||
TransactionKind::Signed(order, Signed { signer, nonce, .. }) => {
|
TransactionKind::Signed(order, Signed { signer, nonce, .. }) => {
|
||||||
|
let signer = signer.to_bytes();
|
||||||
let amount = *res.txs_per_signer.get(&signer).unwrap_or(&0) + 1;
|
let amount = *res.txs_per_signer.get(&signer).unwrap_or(&0) + 1;
|
||||||
res.txs_per_signer.insert(signer, amount);
|
res.txs_per_signer.insert(signer, amount);
|
||||||
|
|
||||||
@@ -106,7 +108,7 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
|||||||
// Returns Ok(true) if new, Ok(false) if an already present unsigned, or the error.
|
// Returns Ok(true) if new, Ok(false) if an already present unsigned, or the error.
|
||||||
pub(crate) fn add<
|
pub(crate) fn add<
|
||||||
N: Network,
|
N: Network,
|
||||||
F: FnOnce(<Ristretto as Ciphersuite>::G, Vec<u8>) -> Option<u32>,
|
F: FnOnce(<Ristretto as WrappedGroup>::G, Vec<u8>) -> Option<u32>,
|
||||||
>(
|
>(
|
||||||
&mut self,
|
&mut self,
|
||||||
blockchain_next_nonce: F,
|
blockchain_next_nonce: F,
|
||||||
@@ -139,6 +141,8 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
|||||||
};
|
};
|
||||||
let mut next_nonce = blockchain_next_nonce;
|
let mut next_nonce = blockchain_next_nonce;
|
||||||
|
|
||||||
|
let signer = signer.to_bytes();
|
||||||
|
|
||||||
if let Some(mempool_last_nonce) =
|
if let Some(mempool_last_nonce) =
|
||||||
self.last_nonce_in_mempool.get(&(signer, order.clone()))
|
self.last_nonce_in_mempool.get(&(signer, order.clone()))
|
||||||
{
|
{
|
||||||
@@ -178,10 +182,10 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
|||||||
// Returns None if the mempool doesn't have a nonce tracked.
|
// Returns None if the mempool doesn't have a nonce tracked.
|
||||||
pub(crate) fn next_nonce_in_mempool(
|
pub(crate) fn next_nonce_in_mempool(
|
||||||
&self,
|
&self,
|
||||||
signer: &<Ristretto as Ciphersuite>::G,
|
signer: &<Ristretto as WrappedGroup>::G,
|
||||||
order: Vec<u8>,
|
order: Vec<u8>,
|
||||||
) -> Option<u32> {
|
) -> Option<u32> {
|
||||||
self.last_nonce_in_mempool.get(&(*signer, order)).copied().map(|nonce| nonce + 1)
|
self.last_nonce_in_mempool.get(&(signer.to_bytes(), order)).copied().map(|nonce| nonce + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get transactions to include in a block.
|
/// Get transactions to include in a block.
|
||||||
@@ -242,6 +246,8 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
|||||||
|
|
||||||
if let Some(tx) = self.txs.remove(tx) {
|
if let Some(tx) = self.txs.remove(tx) {
|
||||||
if let TransactionKind::Signed(order, Signed { signer, nonce, .. }) = tx.kind() {
|
if let TransactionKind::Signed(order, Signed { signer, nonce, .. }) = tx.kind() {
|
||||||
|
let signer = signer.to_bytes();
|
||||||
|
|
||||||
let amount = *self.txs_per_signer.get(&signer).unwrap() - 1;
|
let amount = *self.txs_per_signer.get(&signer).unwrap() - 1;
|
||||||
self.txs_per_signer.insert(signer, amount);
|
self.txs_per_signer.insert(signer, amount);
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,10 @@ use rand_chacha::ChaCha12Rng;
|
|||||||
use transcript::{Transcript, RecommendedTranscript};
|
use transcript::{Transcript, RecommendedTranscript};
|
||||||
|
|
||||||
use ciphersuite::{
|
use ciphersuite::{
|
||||||
group::{
|
group::{ff::PrimeField, GroupEncoding},
|
||||||
GroupEncoding,
|
*,
|
||||||
ff::{Field, PrimeField},
|
|
||||||
},
|
|
||||||
Ciphersuite, Ristretto,
|
|
||||||
};
|
};
|
||||||
|
use dalek_ff_group::Ristretto;
|
||||||
use schnorr::{
|
use schnorr::{
|
||||||
SchnorrSignature,
|
SchnorrSignature,
|
||||||
aggregate::{SchnorrAggregator, SchnorrAggregate},
|
aggregate::{SchnorrAggregator, SchnorrAggregate},
|
||||||
@@ -23,7 +21,7 @@ use schnorr::{
|
|||||||
|
|
||||||
use serai_db::Db;
|
use serai_db::Db;
|
||||||
|
|
||||||
use scale::{Encode, Decode};
|
use borsh::{BorshSerialize, BorshDeserialize};
|
||||||
use tendermint::{
|
use tendermint::{
|
||||||
SignedMessageFor,
|
SignedMessageFor,
|
||||||
ext::{
|
ext::{
|
||||||
@@ -50,24 +48,26 @@ fn challenge(
|
|||||||
key: [u8; 32],
|
key: [u8; 32],
|
||||||
nonce: &[u8],
|
nonce: &[u8],
|
||||||
msg: &[u8],
|
msg: &[u8],
|
||||||
) -> <Ristretto as Ciphersuite>::F {
|
) -> <Ristretto as WrappedGroup>::F {
|
||||||
let mut transcript = RecommendedTranscript::new(b"Tributary Chain Tendermint Message");
|
let mut transcript = RecommendedTranscript::new(b"Tributary Chain Tendermint Message");
|
||||||
transcript.append_message(b"genesis", genesis);
|
transcript.append_message(b"genesis", genesis);
|
||||||
transcript.append_message(b"key", key);
|
transcript.append_message(b"key", key);
|
||||||
transcript.append_message(b"nonce", nonce);
|
transcript.append_message(b"nonce", nonce);
|
||||||
transcript.append_message(b"message", msg);
|
transcript.append_message(b"message", msg);
|
||||||
|
|
||||||
<Ristretto as Ciphersuite>::F::from_bytes_mod_order_wide(&transcript.challenge(b"schnorr").into())
|
<Ristretto as WrappedGroup>::F::from_bytes_mod_order_wide(
|
||||||
|
&transcript.challenge(b"schnorr").into(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct Signer {
|
pub struct Signer {
|
||||||
genesis: [u8; 32],
|
genesis: [u8; 32],
|
||||||
key: Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Signer {
|
impl Signer {
|
||||||
pub(crate) fn new(genesis: [u8; 32], key: Zeroizing<<Ristretto as Ciphersuite>::F>) -> Signer {
|
pub(crate) fn new(genesis: [u8; 32], key: Zeroizing<<Ristretto as WrappedGroup>::F>) -> Signer {
|
||||||
Signer { genesis, key }
|
Signer { genesis, key }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,10 +100,10 @@ impl SignerTrait for Signer {
|
|||||||
assert_eq!(nonce_ref, [0; 64].as_ref());
|
assert_eq!(nonce_ref, [0; 64].as_ref());
|
||||||
|
|
||||||
let nonce =
|
let nonce =
|
||||||
Zeroizing::new(<Ristretto as Ciphersuite>::F::from_bytes_mod_order_wide(&nonce_arr));
|
Zeroizing::new(<Ristretto as WrappedGroup>::F::from_bytes_mod_order_wide(&nonce_arr));
|
||||||
nonce_arr.zeroize();
|
nonce_arr.zeroize();
|
||||||
|
|
||||||
assert!(!bool::from(nonce.ct_eq(&<Ristretto as Ciphersuite>::F::ZERO)));
|
assert!(!bool::from(nonce.ct_eq(&<Ristretto as WrappedGroup>::F::ZERO)));
|
||||||
|
|
||||||
let challenge = challenge(
|
let challenge = challenge(
|
||||||
self.genesis,
|
self.genesis,
|
||||||
@@ -132,7 +132,7 @@ pub struct Validators {
|
|||||||
impl Validators {
|
impl Validators {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
genesis: [u8; 32],
|
genesis: [u8; 32],
|
||||||
validators: Vec<(<Ristretto as Ciphersuite>::G, u64)>,
|
validators: Vec<(<Ristretto as WrappedGroup>::G, u64)>,
|
||||||
) -> Option<Validators> {
|
) -> Option<Validators> {
|
||||||
let mut total_weight = 0;
|
let mut total_weight = 0;
|
||||||
let mut weights = HashMap::new();
|
let mut weights = HashMap::new();
|
||||||
@@ -163,7 +163,6 @@ impl SignatureScheme for Validators {
|
|||||||
type AggregateSignature = Vec<u8>;
|
type AggregateSignature = Vec<u8>;
|
||||||
type Signer = Arc<Signer>;
|
type Signer = Arc<Signer>;
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
fn verify(&self, validator: Self::ValidatorId, msg: &[u8], sig: &Self::Signature) -> bool {
|
fn verify(&self, validator: Self::ValidatorId, msg: &[u8], sig: &Self::Signature) -> bool {
|
||||||
if !self.weights.contains_key(&validator) {
|
if !self.weights.contains_key(&validator) {
|
||||||
return false;
|
return false;
|
||||||
@@ -196,7 +195,6 @@ impl SignatureScheme for Validators {
|
|||||||
aggregate.serialize()
|
aggregate.serialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
fn verify_aggregate(
|
fn verify_aggregate(
|
||||||
&self,
|
&self,
|
||||||
signers: &[Self::ValidatorId],
|
signers: &[Self::ValidatorId],
|
||||||
@@ -221,7 +219,7 @@ impl SignatureScheme for Validators {
|
|||||||
signers
|
signers
|
||||||
.iter()
|
.iter()
|
||||||
.zip(challenges)
|
.zip(challenges)
|
||||||
.map(|(s, c)| (<Ristretto as Ciphersuite>::read_G(&mut s.as_slice()).unwrap(), c))
|
.map(|(s, c)| (<Ristretto as GroupIo>::read_G(&mut s.as_slice()).unwrap(), c))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.as_slice(),
|
.as_slice(),
|
||||||
)
|
)
|
||||||
@@ -250,7 +248,7 @@ impl Weights for Validators {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)]
|
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
||||||
pub struct TendermintBlock(pub Vec<u8>);
|
pub struct TendermintBlock(pub Vec<u8>);
|
||||||
impl BlockTrait for TendermintBlock {
|
impl BlockTrait for TendermintBlock {
|
||||||
type Id = [u8; 32];
|
type Id = [u8; 32];
|
||||||
@@ -302,7 +300,7 @@ impl<D: Db, T: TransactionTrait, P: P2p> Network for TendermintNetwork<D, T, P>
|
|||||||
fn broadcast(&mut self, msg: SignedMessageFor<Self>) -> impl Send + Future<Output = ()> {
|
fn broadcast(&mut self, msg: SignedMessageFor<Self>) -> impl Send + Future<Output = ()> {
|
||||||
async move {
|
async move {
|
||||||
let mut to_broadcast = vec![TENDERMINT_MESSAGE];
|
let mut to_broadcast = vec![TENDERMINT_MESSAGE];
|
||||||
to_broadcast.extend(msg.encode());
|
msg.serialize(&mut to_broadcast).unwrap();
|
||||||
self.p2p.broadcast(self.genesis, to_broadcast).await
|
self.p2p.broadcast(self.genesis, to_broadcast).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -392,7 +390,7 @@ impl<D: Db, T: TransactionTrait, P: P2p> Network for TendermintNetwork<D, T, P>
|
|||||||
return invalid_block();
|
return invalid_block();
|
||||||
};
|
};
|
||||||
|
|
||||||
let encoded_commit = commit.encode();
|
let encoded_commit = borsh::to_vec(&commit).unwrap();
|
||||||
loop {
|
loop {
|
||||||
let block_res = self.blockchain.write().await.add_block::<Self>(
|
let block_res = self.blockchain.write().await.add_block::<Self>(
|
||||||
&block,
|
&block,
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use scale::{Encode, Decode, IoReader};
|
use borsh::BorshDeserialize;
|
||||||
|
|
||||||
use blake2::{Digest, Blake2s256};
|
use blake2::{Digest, Blake2s256};
|
||||||
|
|
||||||
use ciphersuite::{Ciphersuite, Ristretto};
|
use dalek_ff_group::Ristretto;
|
||||||
|
use ciphersuite::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
transaction::{Transaction, TransactionKind, TransactionError},
|
transaction::{Transaction, TransactionKind, TransactionError},
|
||||||
@@ -26,14 +27,14 @@ pub enum TendermintTx {
|
|||||||
|
|
||||||
impl ReadWrite for TendermintTx {
|
impl ReadWrite for TendermintTx {
|
||||||
fn read<R: io::Read>(reader: &mut R) -> io::Result<Self> {
|
fn read<R: io::Read>(reader: &mut R) -> io::Result<Self> {
|
||||||
Evidence::decode(&mut IoReader(reader))
|
Evidence::deserialize_reader(reader)
|
||||||
.map(TendermintTx::SlashEvidence)
|
.map(TendermintTx::SlashEvidence)
|
||||||
.map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "invalid evidence format"))
|
.map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "invalid evidence format"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write<W: io::Write>(&self, writer: &mut W) -> io::Result<()> {
|
fn write<W: io::Write>(&self, writer: &mut W) -> io::Result<()> {
|
||||||
match self {
|
match self {
|
||||||
TendermintTx::SlashEvidence(ev) => writer.write_all(&ev.encode()),
|
TendermintTx::SlashEvidence(ev) => writer.write_all(&borsh::to_vec(&ev).unwrap()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +50,7 @@ impl Transaction for TendermintTx {
|
|||||||
Blake2s256::digest(self.serialize()).into()
|
Blake2s256::digest(self.serialize()).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sig_hash(&self, _genesis: [u8; 32]) -> <Ristretto as Ciphersuite>::F {
|
fn sig_hash(&self, _genesis: [u8; 32]) -> <Ristretto as WrappedGroup>::F {
|
||||||
match self {
|
match self {
|
||||||
TendermintTx::SlashEvidence(_) => panic!("sig_hash called on slash evidence transaction"),
|
TendermintTx::SlashEvidence(_) => panic!("sig_hash called on slash evidence transaction"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
use std::{sync::Arc, io, collections::HashMap, fmt::Debug};
|
use std::{sync::Arc, io, collections::HashMap, fmt::Debug};
|
||||||
|
|
||||||
use blake2::{Digest, Blake2s256};
|
use blake2::{Digest, Blake2s256};
|
||||||
use ciphersuite::{
|
|
||||||
group::{ff::Field, Group},
|
use dalek_ff_group::Ristretto;
|
||||||
Ciphersuite, Ristretto,
|
use ciphersuite::{group::Group, *};
|
||||||
};
|
|
||||||
use schnorr::SchnorrSignature;
|
use schnorr::SchnorrSignature;
|
||||||
|
|
||||||
use serai_db::MemDb;
|
use serai_db::MemDb;
|
||||||
@@ -30,11 +29,11 @@ impl NonceTransaction {
|
|||||||
nonce,
|
nonce,
|
||||||
distinguisher,
|
distinguisher,
|
||||||
Signed {
|
Signed {
|
||||||
signer: <Ristretto as Ciphersuite>::G::identity(),
|
signer: <Ristretto as WrappedGroup>::G::identity(),
|
||||||
nonce,
|
nonce,
|
||||||
signature: SchnorrSignature::<Ristretto> {
|
signature: SchnorrSignature::<Ristretto> {
|
||||||
R: <Ristretto as Ciphersuite>::G::identity(),
|
R: <Ristretto as WrappedGroup>::G::identity(),
|
||||||
s: <Ristretto as Ciphersuite>::F::ZERO,
|
s: <Ristretto as WrappedGroup>::F::ZERO,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ use rand::rngs::OsRng;
|
|||||||
|
|
||||||
use blake2::{Digest, Blake2s256};
|
use blake2::{Digest, Blake2s256};
|
||||||
|
|
||||||
use ciphersuite::{group::ff::Field, Ciphersuite, Ristretto};
|
use dalek_ff_group::Ristretto;
|
||||||
|
use ciphersuite::*;
|
||||||
|
|
||||||
use serai_db::{DbTxn, Db, MemDb};
|
use serai_db::{DbTxn, Db, MemDb};
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ type N = TendermintNetwork<MemDb, SignedTransaction, DummyP2p>;
|
|||||||
|
|
||||||
fn new_blockchain<T: TransactionTrait>(
|
fn new_blockchain<T: TransactionTrait>(
|
||||||
genesis: [u8; 32],
|
genesis: [u8; 32],
|
||||||
participants: &[<Ristretto as Ciphersuite>::G],
|
participants: &[<Ristretto as WrappedGroup>::G],
|
||||||
) -> (MemDb, Blockchain<MemDb, T>) {
|
) -> (MemDb, Blockchain<MemDb, T>) {
|
||||||
let db = MemDb::new();
|
let db = MemDb::new();
|
||||||
let blockchain = Blockchain::new(db.clone(), genesis, participants);
|
let blockchain = Blockchain::new(db.clone(), genesis, participants);
|
||||||
@@ -81,7 +82,7 @@ fn invalid_block() {
|
|||||||
assert!(blockchain.verify_block::<N>(&block, &validators, false).is_err());
|
assert!(blockchain.verify_block::<N>(&block, &validators, false).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng));
|
let key = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng));
|
||||||
let tx = crate::tests::signed_transaction(&mut OsRng, genesis, &key, 0);
|
let tx = crate::tests::signed_transaction(&mut OsRng, genesis, &key, 0);
|
||||||
|
|
||||||
// Not a participant
|
// Not a participant
|
||||||
@@ -133,7 +134,7 @@ fn invalid_block() {
|
|||||||
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
blockchain.verify_block::<N>(&block, &validators, false).unwrap();
|
||||||
match &mut block.transactions[0] {
|
match &mut block.transactions[0] {
|
||||||
Transaction::Application(tx) => {
|
Transaction::Application(tx) => {
|
||||||
tx.1.signature.s += <Ristretto as Ciphersuite>::F::ONE;
|
tx.1.signature.s += <Ristretto as WrappedGroup>::F::ONE;
|
||||||
}
|
}
|
||||||
_ => panic!("non-signed tx found"),
|
_ => panic!("non-signed tx found"),
|
||||||
}
|
}
|
||||||
@@ -149,7 +150,7 @@ fn invalid_block() {
|
|||||||
fn signed_transaction() {
|
fn signed_transaction() {
|
||||||
let genesis = new_genesis();
|
let genesis = new_genesis();
|
||||||
let validators = Arc::new(Validators::new(genesis, vec![]).unwrap());
|
let validators = Arc::new(Validators::new(genesis, vec![]).unwrap());
|
||||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng));
|
let key = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng));
|
||||||
let tx = crate::tests::signed_transaction(&mut OsRng, genesis, &key, 0);
|
let tx = crate::tests::signed_transaction(&mut OsRng, genesis, &key, 0);
|
||||||
let signer = tx.1.signer;
|
let signer = tx.1.signer;
|
||||||
|
|
||||||
@@ -338,7 +339,7 @@ fn provided_transaction() {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn tendermint_evidence_tx() {
|
async fn tendermint_evidence_tx() {
|
||||||
let genesis = new_genesis();
|
let genesis = new_genesis();
|
||||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng));
|
let key = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng));
|
||||||
let signer = Signer::new(genesis, key.clone());
|
let signer = Signer::new(genesis, key.clone());
|
||||||
let signer_id = Ristretto::generator() * key.deref();
|
let signer_id = Ristretto::generator() * key.deref();
|
||||||
let validators = Arc::new(Validators::new(genesis, vec![(signer_id, 1)]).unwrap());
|
let validators = Arc::new(Validators::new(genesis, vec![(signer_id, 1)]).unwrap());
|
||||||
@@ -378,7 +379,7 @@ async fn tendermint_evidence_tx() {
|
|||||||
let mut mempool: Vec<Transaction<SignedTransaction>> = vec![];
|
let mut mempool: Vec<Transaction<SignedTransaction>> = vec![];
|
||||||
let mut signers = vec![];
|
let mut signers = vec![];
|
||||||
for _ in 0 .. 5 {
|
for _ in 0 .. 5 {
|
||||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng));
|
let key = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng));
|
||||||
let signer = Signer::new(genesis, key.clone());
|
let signer = Signer::new(genesis, key.clone());
|
||||||
let signer_id = Ristretto::generator() * key.deref();
|
let signer_id = Ristretto::generator() * key.deref();
|
||||||
signers.push((signer_id, 1));
|
signers.push((signer_id, 1));
|
||||||
@@ -445,7 +446,7 @@ async fn block_tx_ordering() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let genesis = new_genesis();
|
let genesis = new_genesis();
|
||||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng));
|
let key = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng));
|
||||||
|
|
||||||
// signer
|
// signer
|
||||||
let signer = crate::tests::signed_transaction(&mut OsRng, genesis, &key, 0).1.signer;
|
let signer = crate::tests::signed_transaction(&mut OsRng, genesis, &key, 0).1.signer;
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ use std::{sync::Arc, collections::HashMap};
|
|||||||
use zeroize::Zeroizing;
|
use zeroize::Zeroizing;
|
||||||
use rand::{RngCore, rngs::OsRng};
|
use rand::{RngCore, rngs::OsRng};
|
||||||
|
|
||||||
use ciphersuite::{group::ff::Field, Ciphersuite, Ristretto};
|
use dalek_ff_group::Ristretto;
|
||||||
|
use ciphersuite::*;
|
||||||
|
|
||||||
use tendermint::ext::Commit;
|
use tendermint::ext::Commit;
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ async fn mempool_addition() {
|
|||||||
Some(Commit::<Arc<Validators>> { end_time: 0, validators: vec![], signature: vec![] })
|
Some(Commit::<Arc<Validators>> { end_time: 0, validators: vec![], signature: vec![] })
|
||||||
};
|
};
|
||||||
let unsigned_in_chain = |_: [u8; 32]| false;
|
let unsigned_in_chain = |_: [u8; 32]| false;
|
||||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng));
|
let key = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng));
|
||||||
|
|
||||||
let first_tx = signed_transaction(&mut OsRng, genesis, &key, 0);
|
let first_tx = signed_transaction(&mut OsRng, genesis, &key, 0);
|
||||||
let signer = first_tx.1.signer;
|
let signer = first_tx.1.signer;
|
||||||
@@ -124,7 +125,7 @@ async fn mempool_addition() {
|
|||||||
|
|
||||||
// If the mempool doesn't have a nonce for an account, it should successfully use the
|
// If the mempool doesn't have a nonce for an account, it should successfully use the
|
||||||
// blockchain's
|
// blockchain's
|
||||||
let second_key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng));
|
let second_key = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng));
|
||||||
let tx = signed_transaction(&mut OsRng, genesis, &second_key, 2);
|
let tx = signed_transaction(&mut OsRng, genesis, &second_key, 2);
|
||||||
let second_signer = tx.1.signer;
|
let second_signer = tx.1.signer;
|
||||||
assert_eq!(mempool.next_nonce_in_mempool(&second_signer, vec![]), None);
|
assert_eq!(mempool.next_nonce_in_mempool(&second_signer, vec![]), None);
|
||||||
@@ -164,7 +165,7 @@ fn too_many_mempool() {
|
|||||||
Some(Commit::<Arc<Validators>> { end_time: 0, validators: vec![], signature: vec![] })
|
Some(Commit::<Arc<Validators>> { end_time: 0, validators: vec![], signature: vec![] })
|
||||||
};
|
};
|
||||||
let unsigned_in_chain = |_: [u8; 32]| false;
|
let unsigned_in_chain = |_: [u8; 32]| false;
|
||||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng));
|
let key = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng));
|
||||||
|
|
||||||
// We should be able to add transactions up to the limit
|
// We should be able to add transactions up to the limit
|
||||||
for i in 0 .. ACCOUNT_MEMPOOL_LIMIT {
|
for i in 0 .. ACCOUNT_MEMPOOL_LIMIT {
|
||||||
|
|||||||
@@ -6,14 +6,10 @@ use rand::{RngCore, CryptoRng, rngs::OsRng};
|
|||||||
|
|
||||||
use blake2::{Digest, Blake2s256};
|
use blake2::{Digest, Blake2s256};
|
||||||
|
|
||||||
use ciphersuite::{
|
use dalek_ff_group::Ristretto;
|
||||||
group::{ff::Field, Group},
|
use ciphersuite::*;
|
||||||
Ciphersuite, Ristretto,
|
|
||||||
};
|
|
||||||
use schnorr::SchnorrSignature;
|
use schnorr::SchnorrSignature;
|
||||||
|
|
||||||
use scale::Encode;
|
|
||||||
|
|
||||||
use ::tendermint::{
|
use ::tendermint::{
|
||||||
ext::{Network, Signer as SignerTrait, SignatureScheme, BlockNumber, RoundNumber},
|
ext::{Network, Signer as SignerTrait, SignatureScheme, BlockNumber, RoundNumber},
|
||||||
SignedMessageFor, DataFor, Message, SignedMessage, Data, Evidence,
|
SignedMessageFor, DataFor, Message, SignedMessage, Data, Evidence,
|
||||||
@@ -33,11 +29,11 @@ mod tendermint;
|
|||||||
|
|
||||||
pub fn random_signed<R: RngCore + CryptoRng>(rng: &mut R) -> Signed {
|
pub fn random_signed<R: RngCore + CryptoRng>(rng: &mut R) -> Signed {
|
||||||
Signed {
|
Signed {
|
||||||
signer: <Ristretto as Ciphersuite>::G::random(&mut *rng),
|
signer: <Ristretto as WrappedGroup>::G::random(&mut *rng),
|
||||||
nonce: u32::try_from(rng.next_u64() >> 32 >> 1).unwrap(),
|
nonce: u32::try_from(rng.next_u64() >> 32 >> 1).unwrap(),
|
||||||
signature: SchnorrSignature::<Ristretto> {
|
signature: SchnorrSignature::<Ristretto> {
|
||||||
R: <Ristretto as Ciphersuite>::G::random(&mut *rng),
|
R: <Ristretto as WrappedGroup>::G::random(&mut *rng),
|
||||||
s: <Ristretto as Ciphersuite>::F::random(rng),
|
s: <Ristretto as WrappedGroup>::F::random(rng),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,18 +132,18 @@ impl Transaction for SignedTransaction {
|
|||||||
pub fn signed_transaction<R: RngCore + CryptoRng>(
|
pub fn signed_transaction<R: RngCore + CryptoRng>(
|
||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
genesis: [u8; 32],
|
genesis: [u8; 32],
|
||||||
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
|
key: &Zeroizing<<Ristretto as WrappedGroup>::F>,
|
||||||
nonce: u32,
|
nonce: u32,
|
||||||
) -> SignedTransaction {
|
) -> SignedTransaction {
|
||||||
let mut data = vec![0; 512];
|
let mut data = vec![0; 512];
|
||||||
rng.fill_bytes(&mut data);
|
rng.fill_bytes(&mut data);
|
||||||
|
|
||||||
let signer = <Ristretto as Ciphersuite>::generator() * **key;
|
let signer = <Ristretto as WrappedGroup>::generator() * **key;
|
||||||
|
|
||||||
let mut tx =
|
let mut tx =
|
||||||
SignedTransaction(data, Signed { signer, nonce, signature: random_signed(rng).signature });
|
SignedTransaction(data, Signed { signer, nonce, signature: random_signed(rng).signature });
|
||||||
|
|
||||||
let sig_nonce = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(rng));
|
let sig_nonce = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(rng));
|
||||||
tx.1.signature.R = Ristretto::generator() * sig_nonce.deref();
|
tx.1.signature.R = Ristretto::generator() * sig_nonce.deref();
|
||||||
tx.1.signature = SchnorrSignature::sign(key, sig_nonce, tx.sig_hash(genesis));
|
tx.1.signature = SchnorrSignature::sign(key, sig_nonce, tx.sig_hash(genesis));
|
||||||
|
|
||||||
@@ -162,7 +158,7 @@ pub fn random_signed_transaction<R: RngCore + CryptoRng>(
|
|||||||
let mut genesis = [0; 32];
|
let mut genesis = [0; 32];
|
||||||
rng.fill_bytes(&mut genesis);
|
rng.fill_bytes(&mut genesis);
|
||||||
|
|
||||||
let key = Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut *rng));
|
let key = Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut *rng));
|
||||||
// Shift over an additional bit to ensure it won't overflow when incremented
|
// Shift over an additional bit to ensure it won't overflow when incremented
|
||||||
let nonce = u32::try_from(rng.next_u64() >> 32 >> 1).unwrap();
|
let nonce = u32::try_from(rng.next_u64() >> 32 >> 1).unwrap();
|
||||||
|
|
||||||
@@ -179,12 +175,11 @@ pub async fn tendermint_meta() -> ([u8; 32], Signer, [u8; 32], Arc<Validators>)
|
|||||||
// signer
|
// signer
|
||||||
let genesis = new_genesis();
|
let genesis = new_genesis();
|
||||||
let signer =
|
let signer =
|
||||||
Signer::new(genesis, Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng)));
|
Signer::new(genesis, Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng)));
|
||||||
let validator_id = signer.validator_id().await.unwrap();
|
let validator_id = signer.validator_id().await.unwrap();
|
||||||
|
|
||||||
// schema
|
// schema
|
||||||
let signer_pub =
|
let signer_pub = <Ristretto as GroupIo>::read_G::<&[u8]>(&mut validator_id.as_slice()).unwrap();
|
||||||
<Ristretto as Ciphersuite>::read_G::<&[u8]>(&mut validator_id.as_slice()).unwrap();
|
|
||||||
let validators = Arc::new(Validators::new(genesis, vec![(signer_pub, 1)]).unwrap());
|
let validators = Arc::new(Validators::new(genesis, vec![(signer_pub, 1)]).unwrap());
|
||||||
|
|
||||||
(genesis, signer, validator_id, validators)
|
(genesis, signer, validator_id, validators)
|
||||||
@@ -203,7 +198,7 @@ pub async fn signed_from_data<N: Network>(
|
|||||||
round: RoundNumber(round_number),
|
round: RoundNumber(round_number),
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
let sig = signer.sign(&msg.encode()).await;
|
let sig = signer.sign(&borsh::to_vec(&msg).unwrap()).await;
|
||||||
SignedMessage { msg, sig }
|
SignedMessage { msg, sig }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,5 +211,5 @@ pub async fn random_evidence_tx<N: Network>(
|
|||||||
let data = Data::Proposal(Some(RoundNumber(0)), b);
|
let data = Data::Proposal(Some(RoundNumber(0)), b);
|
||||||
let signer_id = signer.validator_id().await.unwrap();
|
let signer_id = signer.validator_id().await.unwrap();
|
||||||
let signed = signed_from_data::<N>(signer, signer_id, 0, 0, data).await;
|
let signed = signed_from_data::<N>(signer, signer_id, 0, 0, data).await;
|
||||||
TendermintTx::SlashEvidence(Evidence::InvalidValidRound(signed.encode()))
|
TendermintTx::SlashEvidence(Evidence::InvalidValidRound(borsh::to_vec(&signed).unwrap()))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ use rand::rngs::OsRng;
|
|||||||
|
|
||||||
use blake2::{Digest, Blake2s256};
|
use blake2::{Digest, Blake2s256};
|
||||||
|
|
||||||
use ciphersuite::{group::ff::Field, Ciphersuite, Ristretto};
|
use dalek_ff_group::Ristretto;
|
||||||
|
use ciphersuite::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ReadWrite,
|
ReadWrite,
|
||||||
@@ -68,7 +69,7 @@ fn signed_transaction() {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
let mut tx = tx.clone();
|
let mut tx = tx.clone();
|
||||||
tx.1.signature.s += <Ristretto as Ciphersuite>::F::ONE;
|
tx.1.signature.s += <Ristretto as WrappedGroup>::F::ONE;
|
||||||
assert!(verify_transaction(&tx, genesis, &mut |_, _| Some(tx.1.nonce)).is_err());
|
assert!(verify_transaction(&tx, genesis, &mut |_, _| Some(tx.1.nonce)).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ use std::sync::Arc;
|
|||||||
use zeroize::Zeroizing;
|
use zeroize::Zeroizing;
|
||||||
use rand::{RngCore, rngs::OsRng};
|
use rand::{RngCore, rngs::OsRng};
|
||||||
|
|
||||||
use ciphersuite::{Ristretto, Ciphersuite, group::ff::Field};
|
use dalek_ff_group::Ristretto;
|
||||||
|
use ciphersuite::*;
|
||||||
use scale::Encode;
|
|
||||||
|
|
||||||
use tendermint::{
|
use tendermint::{
|
||||||
time::CanonicalInstant,
|
time::CanonicalInstant,
|
||||||
@@ -51,7 +50,10 @@ async fn invalid_valid_round() {
|
|||||||
async move {
|
async move {
|
||||||
let data = Data::Proposal(valid_round, TendermintBlock(vec![]));
|
let data = Data::Proposal(valid_round, TendermintBlock(vec![]));
|
||||||
let signed = signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, data).await;
|
let signed = signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, data).await;
|
||||||
(signed.clone(), TendermintTx::SlashEvidence(Evidence::InvalidValidRound(signed.encode())))
|
(
|
||||||
|
signed.clone(),
|
||||||
|
TendermintTx::SlashEvidence(Evidence::InvalidValidRound(borsh::to_vec(&signed).unwrap())),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,7 +71,8 @@ async fn invalid_valid_round() {
|
|||||||
let mut random_sig = [0u8; 64];
|
let mut random_sig = [0u8; 64];
|
||||||
OsRng.fill_bytes(&mut random_sig);
|
OsRng.fill_bytes(&mut random_sig);
|
||||||
signed.sig = random_sig;
|
signed.sig = random_sig;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::InvalidValidRound(signed.encode()));
|
let tx =
|
||||||
|
TendermintTx::SlashEvidence(Evidence::InvalidValidRound(borsh::to_vec(&signed).unwrap()));
|
||||||
|
|
||||||
// should fail
|
// should fail
|
||||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||||
@@ -89,7 +92,10 @@ async fn invalid_precommit_signature() {
|
|||||||
let signed =
|
let signed =
|
||||||
signed_from_data::<N>(signer.clone().into(), signer_id, 1, 0, Data::Precommit(precommit))
|
signed_from_data::<N>(signer.clone().into(), signer_id, 1, 0, Data::Precommit(precommit))
|
||||||
.await;
|
.await;
|
||||||
(signed.clone(), TendermintTx::SlashEvidence(Evidence::InvalidPrecommit(signed.encode())))
|
(
|
||||||
|
signed.clone(),
|
||||||
|
TendermintTx::SlashEvidence(Evidence::InvalidPrecommit(borsh::to_vec(&signed).unwrap())),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -119,7 +125,8 @@ async fn invalid_precommit_signature() {
|
|||||||
let mut random_sig = [0u8; 64];
|
let mut random_sig = [0u8; 64];
|
||||||
OsRng.fill_bytes(&mut random_sig);
|
OsRng.fill_bytes(&mut random_sig);
|
||||||
signed.sig = random_sig;
|
signed.sig = random_sig;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::InvalidPrecommit(signed.encode()));
|
let tx =
|
||||||
|
TendermintTx::SlashEvidence(Evidence::InvalidPrecommit(borsh::to_vec(&signed).unwrap()));
|
||||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,24 +144,32 @@ async fn evidence_with_prevote() {
|
|||||||
// it should fail for all reasons.
|
// it should fail for all reasons.
|
||||||
let mut txs = vec![];
|
let mut txs = vec![];
|
||||||
txs.push(TendermintTx::SlashEvidence(Evidence::InvalidPrecommit(
|
txs.push(TendermintTx::SlashEvidence(Evidence::InvalidPrecommit(
|
||||||
signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, Data::Prevote(block_id))
|
borsh::to_vec(
|
||||||
.await
|
&&signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, Data::Prevote(block_id))
|
||||||
.encode(),
|
.await,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
)));
|
)));
|
||||||
txs.push(TendermintTx::SlashEvidence(Evidence::InvalidValidRound(
|
txs.push(TendermintTx::SlashEvidence(Evidence::InvalidValidRound(
|
||||||
signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, Data::Prevote(block_id))
|
borsh::to_vec(
|
||||||
.await
|
&signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, Data::Prevote(block_id))
|
||||||
.encode(),
|
.await,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
)));
|
)));
|
||||||
// Since these require a second message, provide this one again
|
// Since these require a second message, provide this one again
|
||||||
// ConflictingMessages can be fired for actually conflicting Prevotes however
|
// ConflictingMessages can be fired for actually conflicting Prevotes however
|
||||||
txs.push(TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
txs.push(TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, Data::Prevote(block_id))
|
borsh::to_vec(
|
||||||
.await
|
&signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, Data::Prevote(block_id))
|
||||||
.encode(),
|
.await,
|
||||||
signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, Data::Prevote(block_id))
|
)
|
||||||
.await
|
.unwrap(),
|
||||||
.encode(),
|
borsh::to_vec(
|
||||||
|
&signed_from_data::<N>(signer.clone().into(), signer_id, 0, 0, Data::Prevote(block_id))
|
||||||
|
.await,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
)));
|
)));
|
||||||
txs
|
txs
|
||||||
}
|
}
|
||||||
@@ -188,16 +203,16 @@ async fn conflicting_msgs_evidence_tx() {
|
|||||||
// non-conflicting data should fail
|
// non-conflicting data should fail
|
||||||
let signed_1 = signed_for_b_r(0, 0, Data::Proposal(None, TendermintBlock(vec![0x11]))).await;
|
let signed_1 = signed_for_b_r(0, 0, Data::Proposal(None, TendermintBlock(vec![0x11]))).await;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
));
|
));
|
||||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||||
|
|
||||||
// conflicting data should pass
|
// conflicting data should pass
|
||||||
let signed_2 = signed_for_b_r(0, 0, Data::Proposal(None, TendermintBlock(vec![0x22]))).await;
|
let signed_2 = signed_for_b_r(0, 0, Data::Proposal(None, TendermintBlock(vec![0x22]))).await;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_2.encode(),
|
borsh::to_vec(&signed_2).unwrap(),
|
||||||
));
|
));
|
||||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap();
|
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap();
|
||||||
|
|
||||||
@@ -205,16 +220,16 @@ async fn conflicting_msgs_evidence_tx() {
|
|||||||
// (except for Precommit)
|
// (except for Precommit)
|
||||||
let signed_2 = signed_for_b_r(0, 1, Data::Proposal(None, TendermintBlock(vec![0x22]))).await;
|
let signed_2 = signed_for_b_r(0, 1, Data::Proposal(None, TendermintBlock(vec![0x22]))).await;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_2.encode(),
|
borsh::to_vec(&signed_2).unwrap(),
|
||||||
));
|
));
|
||||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
||||||
|
|
||||||
// Proposals for different block numbers should also fail as evidence
|
// Proposals for different block numbers should also fail as evidence
|
||||||
let signed_2 = signed_for_b_r(1, 0, Data::Proposal(None, TendermintBlock(vec![0x22]))).await;
|
let signed_2 = signed_for_b_r(1, 0, Data::Proposal(None, TendermintBlock(vec![0x22]))).await;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_2.encode(),
|
borsh::to_vec(&signed_2).unwrap(),
|
||||||
));
|
));
|
||||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
||||||
}
|
}
|
||||||
@@ -224,16 +239,16 @@ async fn conflicting_msgs_evidence_tx() {
|
|||||||
// non-conflicting data should fail
|
// non-conflicting data should fail
|
||||||
let signed_1 = signed_for_b_r(0, 0, Data::Prevote(Some([0x11; 32]))).await;
|
let signed_1 = signed_for_b_r(0, 0, Data::Prevote(Some([0x11; 32]))).await;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
));
|
));
|
||||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||||
|
|
||||||
// conflicting data should pass
|
// conflicting data should pass
|
||||||
let signed_2 = signed_for_b_r(0, 0, Data::Prevote(Some([0x22; 32]))).await;
|
let signed_2 = signed_for_b_r(0, 0, Data::Prevote(Some([0x22; 32]))).await;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_2.encode(),
|
borsh::to_vec(&signed_2).unwrap(),
|
||||||
));
|
));
|
||||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap();
|
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap();
|
||||||
|
|
||||||
@@ -241,16 +256,16 @@ async fn conflicting_msgs_evidence_tx() {
|
|||||||
// (except for Precommit)
|
// (except for Precommit)
|
||||||
let signed_2 = signed_for_b_r(0, 1, Data::Prevote(Some([0x22; 32]))).await;
|
let signed_2 = signed_for_b_r(0, 1, Data::Prevote(Some([0x22; 32]))).await;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_2.encode(),
|
borsh::to_vec(&signed_2).unwrap(),
|
||||||
));
|
));
|
||||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
||||||
|
|
||||||
// Proposals for different block numbers should also fail as evidence
|
// Proposals for different block numbers should also fail as evidence
|
||||||
let signed_2 = signed_for_b_r(1, 0, Data::Prevote(Some([0x22; 32]))).await;
|
let signed_2 = signed_for_b_r(1, 0, Data::Prevote(Some([0x22; 32]))).await;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_2.encode(),
|
borsh::to_vec(&signed_2).unwrap(),
|
||||||
));
|
));
|
||||||
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
verify_tendermint_tx::<N>(&tx, &validators, commit).unwrap_err();
|
||||||
}
|
}
|
||||||
@@ -260,7 +275,7 @@ async fn conflicting_msgs_evidence_tx() {
|
|||||||
let signed_1 = signed_for_b_r(0, 0, Data::Proposal(None, TendermintBlock(vec![0x11]))).await;
|
let signed_1 = signed_for_b_r(0, 0, Data::Proposal(None, TendermintBlock(vec![0x11]))).await;
|
||||||
|
|
||||||
let signer_2 =
|
let signer_2 =
|
||||||
Signer::new(genesis, Zeroizing::new(<Ristretto as Ciphersuite>::F::random(&mut OsRng)));
|
Signer::new(genesis, Zeroizing::new(<Ristretto as WrappedGroup>::F::random(&mut OsRng)));
|
||||||
let signed_id_2 = signer_2.validator_id().await.unwrap();
|
let signed_id_2 = signer_2.validator_id().await.unwrap();
|
||||||
let signed_2 = signed_from_data::<N>(
|
let signed_2 = signed_from_data::<N>(
|
||||||
signer_2.into(),
|
signer_2.into(),
|
||||||
@@ -272,15 +287,14 @@ async fn conflicting_msgs_evidence_tx() {
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_2.encode(),
|
borsh::to_vec(&signed_2).unwrap(),
|
||||||
));
|
));
|
||||||
|
|
||||||
// update schema so that we don't fail due to invalid signature
|
// update schema so that we don't fail due to invalid signature
|
||||||
let signer_pub =
|
let signer_pub = <Ristretto as GroupIo>::read_G::<&[u8]>(&mut signer_id.as_slice()).unwrap();
|
||||||
<Ristretto as Ciphersuite>::read_G::<&[u8]>(&mut signer_id.as_slice()).unwrap();
|
|
||||||
let signer_pub_2 =
|
let signer_pub_2 =
|
||||||
<Ristretto as Ciphersuite>::read_G::<&[u8]>(&mut signed_id_2.as_slice()).unwrap();
|
<Ristretto as GroupIo>::read_G::<&[u8]>(&mut signed_id_2.as_slice()).unwrap();
|
||||||
let validators =
|
let validators =
|
||||||
Arc::new(Validators::new(genesis, vec![(signer_pub, 1), (signer_pub_2, 1)]).unwrap());
|
Arc::new(Validators::new(genesis, vec![(signer_pub, 1), (signer_pub_2, 1)]).unwrap());
|
||||||
|
|
||||||
@@ -292,8 +306,8 @@ async fn conflicting_msgs_evidence_tx() {
|
|||||||
let signed_1 = signed_for_b_r(0, 0, Data::Proposal(None, TendermintBlock(vec![]))).await;
|
let signed_1 = signed_for_b_r(0, 0, Data::Proposal(None, TendermintBlock(vec![]))).await;
|
||||||
let signed_2 = signed_for_b_r(0, 0, Data::Prevote(None)).await;
|
let signed_2 = signed_for_b_r(0, 0, Data::Prevote(None)).await;
|
||||||
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
let tx = TendermintTx::SlashEvidence(Evidence::ConflictingMessages(
|
||||||
signed_1.encode(),
|
borsh::to_vec(&signed_1).unwrap(),
|
||||||
signed_2.encode(),
|
borsh::to_vec(&signed_2).unwrap(),
|
||||||
));
|
));
|
||||||
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
assert!(verify_tendermint_tx::<N>(&tx, &validators, commit).is_err());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ use blake2::{Digest, Blake2b512};
|
|||||||
|
|
||||||
use ciphersuite::{
|
use ciphersuite::{
|
||||||
group::{Group, GroupEncoding},
|
group::{Group, GroupEncoding},
|
||||||
Ciphersuite, Ristretto,
|
*,
|
||||||
};
|
};
|
||||||
|
use dalek_ff_group::Ristretto;
|
||||||
use schnorr::SchnorrSignature;
|
use schnorr::SchnorrSignature;
|
||||||
|
|
||||||
use crate::{TRANSACTION_SIZE_LIMIT, ReadWrite};
|
use crate::{TRANSACTION_SIZE_LIMIT, ReadWrite};
|
||||||
@@ -42,7 +43,7 @@ pub enum TransactionError {
|
|||||||
/// Data for a signed transaction.
|
/// Data for a signed transaction.
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct Signed {
|
pub struct Signed {
|
||||||
pub signer: <Ristretto as Ciphersuite>::G,
|
pub signer: <Ristretto as WrappedGroup>::G,
|
||||||
pub nonce: u32,
|
pub nonce: u32,
|
||||||
pub signature: SchnorrSignature<Ristretto>,
|
pub signature: SchnorrSignature<Ristretto>,
|
||||||
}
|
}
|
||||||
@@ -159,10 +160,10 @@ pub trait Transaction: 'static + Send + Sync + Clone + Eq + Debug + ReadWrite {
|
|||||||
/// Do not override this unless you know what you're doing.
|
/// Do not override this unless you know what you're doing.
|
||||||
///
|
///
|
||||||
/// Panics if called on non-signed transactions.
|
/// Panics if called on non-signed transactions.
|
||||||
fn sig_hash(&self, genesis: [u8; 32]) -> <Ristretto as Ciphersuite>::F {
|
fn sig_hash(&self, genesis: [u8; 32]) -> <Ristretto as WrappedGroup>::F {
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
TransactionKind::Signed(order, Signed { signature, .. }) => {
|
TransactionKind::Signed(order, Signed { signature, .. }) => {
|
||||||
<Ristretto as Ciphersuite>::F::from_bytes_mod_order_wide(
|
<Ristretto as WrappedGroup>::F::from_bytes_mod_order_wide(
|
||||||
&Blake2b512::digest(
|
&Blake2b512::digest(
|
||||||
[
|
[
|
||||||
b"Tributary Signed Transaction",
|
b"Tributary Signed Transaction",
|
||||||
@@ -181,8 +182,8 @@ pub trait Transaction: 'static + Send + Sync + Clone + Eq + Debug + ReadWrite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait GAIN: FnMut(&<Ristretto as Ciphersuite>::G, &[u8]) -> Option<u32> {}
|
pub trait GAIN: FnMut(&<Ristretto as WrappedGroup>::G, &[u8]) -> Option<u32> {}
|
||||||
impl<F: FnMut(&<Ristretto as Ciphersuite>::G, &[u8]) -> Option<u32>> GAIN for F {}
|
impl<F: FnMut(&<Ristretto as WrappedGroup>::G, &[u8]) -> Option<u32>> GAIN for F {}
|
||||||
|
|
||||||
pub(crate) fn verify_transaction<F: GAIN, T: Transaction>(
|
pub(crate) fn verify_transaction<F: GAIN, T: Transaction>(
|
||||||
tx: &T,
|
tx: &T,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ license = "MIT"
|
|||||||
repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tendermint"
|
repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tendermint"
|
||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.81"
|
rust-version = "1.77"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -21,7 +21,7 @@ thiserror = { version = "2", default-features = false, features = ["std"] }
|
|||||||
hex = { version = "0.4", default-features = false, features = ["std"] }
|
hex = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
log = { version = "0.4", default-features = false, features = ["std"] }
|
log = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
parity-scale-codec = { version = "3", default-features = false, features = ["std", "derive"] }
|
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||||
|
|
||||||
futures-util = { version = "0.3", default-features = false, features = ["std", "async-await-macro", "sink", "channel"] }
|
futures-util = { version = "0.3", default-features = false, features = ["std", "async-await-macro", "sink", "channel"] }
|
||||||
futures-channel = { version = "0.3", default-features = false, features = ["std", "sink"] }
|
futures-channel = { version = "0.3", default-features = false, features = ["std", "sink"] }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2022-2023 Luke Parker
|
Copyright (c) 2022-2025 Luke Parker
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user