2023-04-11 13:21:35 +00:00
|
|
|
[package]
|
2023-07-03 12:09:41 +00:00
|
|
|
name = "serai-coordinator"
|
2023-04-11 13:21:35 +00:00
|
|
|
version = "0.1.0"
|
|
|
|
description = "Serai coordinator to prepare batches and sign transactions"
|
|
|
|
license = "AGPL-3.0-only"
|
|
|
|
repository = "https://github.com/serai-dex/serai/tree/develop/coordinator"
|
|
|
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
|
|
|
keywords = []
|
|
|
|
edition = "2021"
|
|
|
|
publish = false
|
|
|
|
|
|
|
|
[package.metadata.docs.rs]
|
|
|
|
all-features = true
|
|
|
|
rustdoc-args = ["--cfg", "docsrs"]
|
|
|
|
|
|
|
|
[dependencies]
|
2023-10-31 11:41:23 +00:00
|
|
|
async-trait = { version = "0.1", default-features = false }
|
2023-04-16 04:51:56 +00:00
|
|
|
|
2023-10-31 11:41:23 +00:00
|
|
|
zeroize = { version = "^1.5", default-features = false, features = ["std"] }
|
|
|
|
rand_core = { version = "0.6", default-features = false, features = ["std"] }
|
|
|
|
rand_chacha = { version = "0.3", default-features = false, features = ["std"] }
|
2023-04-15 21:38:47 +00:00
|
|
|
|
2023-10-31 11:41:23 +00:00
|
|
|
blake2 = { version = "0.10", default-features = false, features = ["std"] }
|
2023-04-11 23:04:53 +00:00
|
|
|
|
2023-10-31 11:41:23 +00:00
|
|
|
transcript = { package = "flexible-transcript", path = "../crypto/transcript", default-features = false, features = ["std", "recommended"] }
|
|
|
|
ciphersuite = { path = "../crypto/ciphersuite", default-features = false, features = ["std"] }
|
|
|
|
schnorr = { package = "schnorr-signatures", path = "../crypto/schnorr", default-features = false, features = ["std"] }
|
2023-04-11 23:04:53 +00:00
|
|
|
frost = { package = "modular-frost", path = "../crypto/frost" }
|
2023-08-14 10:08:55 +00:00
|
|
|
frost-schnorrkel = { path = "../crypto/schnorrkel" }
|
2023-04-11 23:04:53 +00:00
|
|
|
|
2023-10-31 11:41:23 +00:00
|
|
|
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std", "derive"] }
|
2023-04-22 14:49:52 +00:00
|
|
|
|
2023-07-20 22:53:03 +00:00
|
|
|
serai-db = { path = "../common/db", features = ["rocksdb"] }
|
2023-07-18 05:53:51 +00:00
|
|
|
serai-env = { path = "../common/env" }
|
2023-04-15 21:38:47 +00:00
|
|
|
|
2023-07-03 12:09:41 +00:00
|
|
|
processor-messages = { package = "serai-processor-messages", path = "../processor/messages" }
|
2023-07-18 05:53:51 +00:00
|
|
|
message-queue = { package = "serai-message-queue", path = "../message-queue" }
|
2023-04-11 23:04:53 +00:00
|
|
|
tributary = { package = "tributary-chain", path = "./tributary" }
|
|
|
|
|
Add a cosigning protocol to ensure finalizations are unique (#433)
* Add a function to deterministically decide which Serai blocks should be co-signed
Has a 5 minute latency between co-signs, also used as the maximal latency
before a co-sign is started.
* Get all active tributaries we're in at a specific block
* Add and route CosignSubstrateBlock, a new provided TX
* Split queued cosigns per network
* Rename BatchSignId to SubstrateSignId
* Add SubstrateSignableId, a meta-type for either Batch or Block, and modularize around it
* Handle the CosignSubstrateBlock provided TX
* Revert substrate_signer.rs to develop (and patch to still work)
Due to SubstrateSigner moving when the prior multisig closes, yet cosigning
occurring with the most recent key, a single SubstrateSigner can be reused.
We could manage multiple SubstrateSigners, yet considering the much lower
specifications for cosigning, I'd rather treat it distinctly.
* Route cosigning through the processor
* Add note to rename SubstrateSigner post-PR
I don't want to do so now in order to preserve the diff's clarity.
* Implement cosign evaluation into the coordinator
* Get tests to compile
* Bug fixes, mark blocks without cosigners available as cosigned
* Correct the ID Batch preprocesses are saved under, add log statements
* Create a dedicated function to handle cosigns
* Correct the flow around Batch verification/queueing
Verifying `Batch`s could stall when a `Batch` was signed before its
predecessors/before the block it's contained in was cosigned (the latter being
inevitable as we can't sign a block containing a signed batch before signing
the batch).
Now, Batch verification happens on a distinct async task in order to not block
the handling of processor messages. This task is the sole caller of verify in
order to ensure last_verified_batch isn't unexpectedly mutated.
When the processor message handler needs to access it, or needs to queue a
Batch, it associates the DB TXN with a lock preventing the other task from
doing so.
This lock, as currently implemented, is a poor and inefficient design. It
should be modified to the pattern used for cosign management. Additionally, a
new primitive of a DB-backed channel may be immensely valuable.
Fixes a standing potential deadlock and a deadlock introduced with the
cosigning protocol.
* Working full-stack tests
After the last commit, this only required extending a timeout.
* Replace "co-sign" with "cosign" to make finding text easier
* Update the coordinator tests to support cosigning
* Inline prior_batch calculation to prevent panic on rotation
Noticed when doing a final review of the branch.
2023-11-15 21:57:21 +00:00
|
|
|
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] }
|
2023-10-31 11:41:23 +00:00
|
|
|
serai-client = { path = "../substrate/client", default-features = false, features = ["serai"] }
|
2023-04-15 21:38:47 +00:00
|
|
|
|
2023-10-31 11:41:23 +00:00
|
|
|
hex = { version = "0.4", default-features = false, features = ["std"] }
|
|
|
|
bincode = { version = "1", default-features = false }
|
2023-11-12 17:04:34 +00:00
|
|
|
serde = "1"
|
2023-10-31 11:41:23 +00:00
|
|
|
serde_json = { version = "1", default-features = false, features = ["std"] }
|
2023-08-01 23:00:48 +00:00
|
|
|
|
2023-10-31 11:41:23 +00:00
|
|
|
log = { version = "0.4", default-features = false, features = ["std"] }
|
|
|
|
env_logger = { version = "0.10", default-features = false, features = ["humantime"] }
|
2023-08-01 23:00:48 +00:00
|
|
|
|
2023-10-31 11:41:23 +00:00
|
|
|
futures = { version = "0.3", default-features = false, features = ["std"] }
|
|
|
|
tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "sync", "time", "macros"] }
|
|
|
|
libp2p = { version = "0.52", default-features = false, features = ["tokio", "tcp", "noise", "yamux", "gossipsub", "mdns", "macros"] }
|
2023-04-11 23:04:53 +00:00
|
|
|
|
|
|
|
[dev-dependencies]
|
2023-10-31 11:41:23 +00:00
|
|
|
futures = { version = "0.3", default-features = false, features = ["std"] }
|
2023-04-11 23:04:53 +00:00
|
|
|
tributary = { package = "tributary-chain", path = "./tributary", features = ["tests"] }
|
2023-10-31 11:41:23 +00:00
|
|
|
sp-application-crypto = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] }
|
|
|
|
sp-runtime = { git = "https://github.com/serai-dex/substrate", default-features = false, features = ["std"] }
|