mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Route blame between Processor and Coordinator (#427)
* Have processor report errors during the DKG to the coordinator * Add RemoveParticipant, InvalidDkgShare to coordinator * Route DKG blame around coordinator * Allow public construction of AdditionalBlameMachine Necessary for upcoming work on handling DKG blame in the processor and coordinator. Additionally fixes a publicly reachable panic when commitments parsed with one ThresholdParams are used in a machine using another set of ThresholdParams. Renames InvalidProofOfKnowledge to InvalidCommitments. * Remove unused error from dleq * Implement support for VerifyBlame in the processor * Have coordinator send the processor share message relevant to Blame * Remove desync between processors reporting InvalidShare and ones reporting GeneratedKeyPair * Route blame on sign between processor and coordinator Doesn't yet act on it in coordinator. * Move txn usage as needed for stable Rust to build * Correct InvalidDkgShare serialization
This commit is contained in:
@@ -87,11 +87,14 @@ impl<D: Db> TributaryDb<D> {
|
||||
fn fatal_slashes_key(genesis: [u8; 32]) -> Vec<u8> {
|
||||
Self::tributary_key(b"fatal_slashes", genesis)
|
||||
}
|
||||
fn fatally_slashed_key(account: [u8; 32]) -> Vec<u8> {
|
||||
Self::tributary_key(b"fatally_slashed", account)
|
||||
fn fatally_slashed_key(genesis: [u8; 32], account: [u8; 32]) -> Vec<u8> {
|
||||
Self::tributary_key(b"fatally_slashed", (genesis, account).encode())
|
||||
}
|
||||
pub fn is_fatally_slashed<G: Get>(getter: &G, genesis: [u8; 32], account: [u8; 32]) -> bool {
|
||||
getter.get(Self::fatally_slashed_key(genesis, account)).is_some()
|
||||
}
|
||||
pub fn set_fatally_slashed(txn: &mut D::Transaction<'_>, genesis: [u8; 32], account: [u8; 32]) {
|
||||
txn.put(Self::fatally_slashed_key(account), []);
|
||||
txn.put(Self::fatally_slashed_key(genesis, account), []);
|
||||
|
||||
let key = Self::fatal_slashes_key(genesis);
|
||||
let mut existing = txn.get(&key).unwrap_or(vec![]);
|
||||
@@ -105,6 +108,27 @@ impl<D: Db> TributaryDb<D> {
|
||||
txn.put(key, existing);
|
||||
}
|
||||
|
||||
fn share_for_blame_key(genesis: &[u8], from: Participant, to: Participant) -> Vec<u8> {
|
||||
Self::tributary_key(b"share_for_blame", (genesis, u16::from(from), u16::from(to)).encode())
|
||||
}
|
||||
pub fn save_share_for_blame(
|
||||
txn: &mut D::Transaction<'_>,
|
||||
genesis: &[u8],
|
||||
from: Participant,
|
||||
to: Participant,
|
||||
share: &[u8],
|
||||
) {
|
||||
txn.put(Self::share_for_blame_key(genesis, from, to), share);
|
||||
}
|
||||
pub fn share_for_blame<G: Get>(
|
||||
getter: &G,
|
||||
genesis: &[u8],
|
||||
from: Participant,
|
||||
to: Participant,
|
||||
) -> Option<Vec<u8>> {
|
||||
getter.get(Self::share_for_blame_key(genesis, from, to))
|
||||
}
|
||||
|
||||
// The plan IDs associated with a Substrate block
|
||||
fn plan_ids_key(genesis: &[u8], block: u64) -> Vec<u8> {
|
||||
Self::tributary_key(b"plan_ids", [genesis, block.to_le_bytes().as_ref()].concat())
|
||||
|
||||
Reference in New Issue
Block a user