Add a test to the coordinator for running a Tributary

Impls a LocalP2p for testing.

Moves rebroadcasting into Tendermint, since it's what knows if a message is
fully valid + original.

Removes TributarySpec::validators() HashMap, as its non-determinism caused
different instances to have different round robin schedules. It was already
prior moved to a Vec for this issue, so I'm unsure why this remnant existed.

Also renames the GH no-std workflow from the prior commit.
This commit is contained in:
Luke Parker
2023-04-22 10:49:52 -04:00
parent 1e448dec21
commit 8c74576cf0
13 changed files with 259 additions and 69 deletions

View File

@@ -97,7 +97,7 @@ impl<D: Db> TributaryDb<D> {
genesis: [u8; 32],
id: [u8; 32],
attempt: u32,
signer: &<Ristretto as Ciphersuite>::G,
signer: <Ristretto as Ciphersuite>::G,
) -> Vec<u8> {
Self::tributary_key(
b"data",
@@ -117,7 +117,7 @@ impl<D: Db> TributaryDb<D> {
genesis: [u8; 32],
id: [u8; 32],
attempt: u32,
signer: &<Ristretto as Ciphersuite>::G,
signer: <Ristretto as Ciphersuite>::G,
) -> Option<Vec<u8>> {
getter.get(Self::data_key(label, genesis, id, attempt, signer))
}
@@ -127,7 +127,7 @@ impl<D: Db> TributaryDb<D> {
genesis: [u8; 32],
id: [u8; 32],
attempt: u32,
signer: &<Ristretto as Ciphersuite>::G,
signer: <Ristretto as Ciphersuite>::G,
data: &[u8],
) -> u16 {
let received_key = Self::data_received_key(label, genesis, id, attempt);

View File

@@ -91,12 +91,8 @@ impl TributarySpec {
None
}
pub fn validators(&self) -> HashMap<<Ristretto as Ciphersuite>::G, u64> {
let mut res = HashMap::new();
for (key, amount) in self.validators.clone() {
res.insert(key, amount);
}
res
pub fn validators(&self) -> Vec<(<Ristretto as Ciphersuite>::G, u64)> {
self.validators.clone()
}
}

View File

@@ -70,7 +70,7 @@ async fn handle_block<D: Db, Pro: Processor, P: P2p>(
// If they've already published a TX for this attempt, slash
if let Some(data) =
TributaryDb::<D>::data(label, &txn, tributary.genesis(), id, attempt, &signed.signer)
TributaryDb::<D>::data(label, &txn, tributary.genesis(), id, attempt, signed.signer)
{
if data != bytes {
// TODO: Full slash
@@ -99,17 +99,18 @@ async fn handle_block<D: Db, Pro: Processor, P: P2p>(
tributary.genesis(),
id,
attempt,
&signed.signer,
signed.signer,
&bytes,
);
// If we have all the needed commitments/preprocesses/shares, tell the processor
// TODO: This needs to be coded by weight, not by validator count
if received == needed {
let mut data = HashMap::new();
for validator in spec.validators().keys() {
for validator in spec.validators().iter().map(|validator| validator.0) {
data.insert(
spec.i(*validator).unwrap(),
if validator == &signed.signer {
spec.i(validator).unwrap(),
if validator == signed.signer {
bytes.split_off(0)
} else if let Some(data) =
TributaryDb::<D>::data(label, &txn, tributary.genesis(), id, attempt, validator)