Skip to content

Commit

Permalink
refactor(mock-consensus): 🔐 remove Keyring
Browse files Browse the repository at this point in the history
previously, we added a `Keyring` newtype. this was a low-effort, thin
newtype wrapper around a `BTreeMap<VerificationKey, SigningKey>`.

this commit removes it.

NB: this is based on #4001.
  • Loading branch information
cratelyn committed Mar 18, 2024
1 parent 3ca8c46 commit 18df408
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 137 deletions.
20 changes: 14 additions & 6 deletions crates/test/mock-consensus/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
mod init_chain;

use {
crate::{keyring::Keyring, TestNode},
crate::TestNode,
bytes::Bytes,
ed25519_consensus::{SigningKey, VerificationKey},
std::collections::BTreeMap,
};

/// A buider, used to prepare and instantiate a new [`TestNode`].
#[derive(Default)]
pub struct Builder {
pub app_state: Option<Bytes>,
pub keyring: Keyring,
pub keyring: BTreeMap<VerificationKey, SigningKey>,
}

impl TestNode<()> {
Expand Down Expand Up @@ -57,9 +59,15 @@ impl Builder {
);
}

Self {
keyring: Keyring::new_with_size(1),
..self
}
// Generate a consensus key.
let sk = ed25519_consensus::SigningKey::new(rand_core::OsRng);
let vk = sk.verification_key();
tracing::trace!(verification_key = ?vk, "generated consensus key");

// Place it into the keyring.
let mut keyring = BTreeMap::new();
keyring.insert(vk, sk);

Self { keyring, ..self }
}
}
129 changes: 0 additions & 129 deletions crates/test/mock-consensus/src/keyring.rs

This file was deleted.

8 changes: 6 additions & 2 deletions crates/test/mock-consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
//
// see penumbra-zone/penumbra#3588.

use {
ed25519_consensus::{SigningKey, VerificationKey},
std::collections::BTreeMap,
};

pub mod block;
pub mod builder;
pub mod keyring;

mod abci;

Expand All @@ -23,7 +27,7 @@ pub struct TestNode<C> {
consensus: C,
last_app_hash: Vec<u8>,
height: tendermint::block::Height,
keyring: self::keyring::Keyring,
keyring: BTreeMap<VerificationKey, SigningKey>,
}

impl<C> TestNode<C> {
Expand Down

0 comments on commit 18df408

Please sign in to comment.