Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(mock-consensus): 🔐 remove Keyring #4039

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions crates/test/mock-consensus/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
mod init_chain;

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

/// A buider, used to prepare and instantiate a new [`TestNode`].
Expand Down Expand Up @@ -57,9 +58,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.

23 changes: 21 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,9 +27,14 @@ pub struct TestNode<C> {
consensus: C,
last_app_hash: Vec<u8>,
height: tendermint::block::Height,
keyring: self::keyring::Keyring,
keyring: Keyring,
}

/// An ordered map of consensus keys.
///
/// Entries in this keyring consist of a [`VerificationKey`] and a [`SigningKey`].
type Keyring = BTreeMap<VerificationKey, SigningKey>;

impl<C> TestNode<C> {
pub const CHAIN_ID: &'static str = "penumbra-test-chain";

Expand All @@ -40,6 +49,16 @@ impl<C> TestNode<C> {
// - https://doc.rust-lang.org/std/fmt/#formatting-traits
format!("{:02X?}", self.last_app_hash)
}

/// Returns a reference to the test node's set of consensus keys.
pub fn keyring(&self) -> &Keyring {
&self.keyring
}

/// Returns a mutable reference to the test node's set of consensus keys.
pub fn keyring_mut(&mut self) -> &mut Keyring {
&mut self.keyring
}
}

impl<C> TestNode<C>
Expand Down
Loading