Skip to content

Commit

Permalink
Merge commit '29fcf6be4d47d259acc77b433c44b0cd0c994593' into macrod-db
Browse files Browse the repository at this point in the history
  • Loading branch information
econsta committed Oct 12, 2023
2 parents e92f8ab + 29fcf6b commit 811fa5c
Show file tree
Hide file tree
Showing 80 changed files with 1,958 additions and 967 deletions.
15 changes: 14 additions & 1 deletion .github/actions/build-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
rust-toolchain:
description: "Rust toolchain to install"
required: false
default: 1.72.1
default: 1.73.0

rust-components:
description: "Rust components to install"
Expand All @@ -20,6 +20,19 @@ inputs:
runs:
using: "composite"
steps:
- name: Remove unused packages
shell: bash
run: |
sudo apt remove -y "*msbuild*" "*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 "*apache2*" "*nginx*" "*firefox*" "*chromium*" "*chrome*" "*edge*"
sudo apt remove -y "*qemu*" "*sql*" "*texinfo*" "*imagemagick*"
sudo apt autoremove -y
sudo apt update
sudo apt install python3 python3-pip -y
sudo apt clean
docker system prune -a --volumes
- name: Install Protobuf
uses: arduino/setup-protoc@a8b67ba40b37d35169e222f3bb352603327985b6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/nightly-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2023-09-01
nightly-2023-10-01
2 changes: 1 addition & 1 deletion .github/workflows/daily-deny.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install cargo
uses: dtolnay/rust-toolchain@5cb429dd810e16ff67df78472fa81cf760f4d1c0
with:
toolchain: 1.72.1
toolchain: 1.73.0

- name: Install cargo deny
run: cargo install --locked cargo-deny
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install cargo
uses: dtolnay/rust-toolchain@5cb429dd810e16ff67df78472fa81cf760f4d1c0
with:
toolchain: 1.72.1
toolchain: 1.73.0

- name: Install cargo deny
run: cargo install --locked cargo-deny
Expand Down
24 changes: 23 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ members = [
"substrate/validator-sets/primitives",
"substrate/validator-sets/pallet",

"substrate/staking/pallet",

"substrate/runtime",
"substrate/node",

Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ issued at the discretion of the Immunefi program managers.

### Links

- [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
- [Matrix](https://matrix.to/#/#serai:matrix.org):
https://matrix.to/#/#serai:matrix.org
- [Immunefi](https://immunefi.com/bounty/serai/):
https://immunefi.com/bounty/serai/
- [Website](https://serai.exchange/): https://serai.exchange/
- [Immunefi](https://immunefi.com/bounty/serai/): https://immunefi.com/bounty/serai/
- [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
- [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/
- [Telegram](https://t.me/SeraiDEX): https://t.me/SeraiDEX
2 changes: 1 addition & 1 deletion coins/bitcoin/src/wallet/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl SignableTransaction {
// multiplied by DEFAULT_BYTES_PER_SIGOP (20)
// We only use 1 signature per input, and our inputs have a weight exceeding 20
// Accordingly, our inputs' weight will always be greater than the cost of the signature ops
let vsize = (weight + 3) / 4;
let vsize = weight.div_ceil(4);
// Technically, if there isn't change, this TX may still pay enough of a fee to pass the
// minimum fee. Such edge cases aren't worth programming when they go against intent, as the
// specified fee rate is too low to be valid
Expand Down
3 changes: 1 addition & 2 deletions coins/monero/src/wallet/seed/polyseed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ fn birthday_decode(birthday: u16) -> u64 {
const SECRET_BITS: usize = 150;

const BITS_PER_BYTE: usize = 8;
// ceildiv of SECRET_BITS by BITS_PER_BYTE
const SECRET_SIZE: usize = (SECRET_BITS + BITS_PER_BYTE - 1) / BITS_PER_BYTE; // 19
const SECRET_SIZE: usize = SECRET_BITS.div_ceil(BITS_PER_BYTE); // 19
const CLEAR_BITS: usize = (SECRET_SIZE * BITS_PER_BYTE) - SECRET_BITS; // 2

// Polyseed calls this CLEAR_MASK and has a very complicated formula for this fundamental
Expand Down
66 changes: 52 additions & 14 deletions coordinator/src/db.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
use core::marker::PhantomData;

use blake2::{
digest::{consts::U32, Digest},
Blake2b,
};

use scale::{Encode, Decode};
use serai_client::{primitives::NetworkId, in_instructions::primitives::SignedBatch};
use serai_client::{
primitives::NetworkId,
in_instructions::primitives::{Batch, SignedBatch},
};

pub use serai_db::*;

Expand All @@ -15,14 +23,14 @@ impl<D: Db> MainDb<D> {
D::key(b"coordinator_main", dst, key)
}

fn handled_message_key(id: u64) -> Vec<u8> {
Self::main_key(b"handled_message", id.to_le_bytes())
fn handled_message_key(network: NetworkId, id: u64) -> Vec<u8> {
Self::main_key(b"handled_message", (network, id).encode())
}
pub fn save_handled_message(txn: &mut D::Transaction<'_>, id: u64) {
txn.put(Self::handled_message_key(id), []);
pub fn save_handled_message(txn: &mut D::Transaction<'_>, network: NetworkId, id: u64) {
txn.put(Self::handled_message_key(network, id), []);
}
pub fn handled_message<G: Get>(getter: &G, id: u64) -> bool {
getter.get(Self::handled_message_key(id)).is_some()
pub fn handled_message<G: Get>(getter: &G, network: NetworkId, id: u64) -> bool {
getter.get(Self::handled_message_key(network, id)).is_some()
}

fn acive_tributaries_key() -> Vec<u8> {
Expand Down Expand Up @@ -67,19 +75,37 @@ impl<D: Db> MainDb<D> {
res
}

fn first_preprocess_key(id: [u8; 32]) -> Vec<u8> {
Self::main_key(b"first_preprocess", id)
}
pub fn save_first_preprocess(txn: &mut D::Transaction<'_>, id: [u8; 32], preprocess: Vec<u8>) {
let key = Self::first_preprocess_key(id);
fn first_preprocess_key(network: NetworkId, id: [u8; 32]) -> Vec<u8> {
Self::main_key(b"first_preprocess", (network, id).encode())
}
pub fn save_first_preprocess(
txn: &mut D::Transaction<'_>,
network: NetworkId,
id: [u8; 32],
preprocess: Vec<u8>,
) {
let key = Self::first_preprocess_key(network, id);
if let Some(existing) = txn.get(&key) {
assert_eq!(existing, preprocess, "saved a distinct first preprocess");
return;
}
txn.put(key, preprocess);
}
pub fn first_preprocess<G: Get>(getter: &G, id: [u8; 32]) -> Option<Vec<u8>> {
getter.get(Self::first_preprocess_key(id))
pub fn first_preprocess<G: Get>(getter: &G, network: NetworkId, id: [u8; 32]) -> Option<Vec<u8>> {
getter.get(Self::first_preprocess_key(network, id))
}

fn expected_batch_key(network: NetworkId, id: u32) -> Vec<u8> {
Self::main_key(b"expected_batch", (network, id).encode())
}
pub fn save_expected_batch(txn: &mut D::Transaction<'_>, batch: &Batch) {
txn.put(
Self::expected_batch_key(batch.network, batch.id),
Blake2b::<U32>::digest(batch.instructions.encode()),
);
}
pub fn expected_batch<G: Get>(getter: &G, network: NetworkId, id: u32) -> Option<[u8; 32]> {
getter.get(Self::expected_batch_key(network, id)).map(|batch| batch.try_into().unwrap())
}

fn batch_key(network: NetworkId, id: u32) -> Vec<u8> {
Expand All @@ -93,4 +119,16 @@ impl<D: Db> MainDb<D> {
.get(Self::batch_key(network, id))
.map(|batch| SignedBatch::decode(&mut batch.as_ref()).unwrap())
}

fn last_verified_batch_key(network: NetworkId) -> Vec<u8> {
Self::main_key(b"last_verified_batch", network.encode())
}
pub fn save_last_verified_batch(txn: &mut D::Transaction<'_>, network: NetworkId, id: u32) {
txn.put(Self::last_verified_batch_key(network), id.to_le_bytes());
}
pub fn last_verified_batch<G: Get>(getter: &G, network: NetworkId) -> Option<u32> {
getter
.get(Self::last_verified_batch_key(network))
.map(|id| u32::from_le_bytes(id.try_into().unwrap()))
}
}
Loading

0 comments on commit 811fa5c

Please sign in to comment.