Skip to content

Commit

Permalink
remove unused validator fields and address nitpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser999 committed May 17, 2024
1 parent a1f5ee1 commit 6b05e11
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 44 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion crates/astria-core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use ed25519_consensus::{
Signature,
SigningKey as Ed25519SigningKey,
VerificationKey,
// VerificationKeyBytes,
};
use rand::{
CryptoRng,
Expand All @@ -19,6 +18,10 @@ use zeroize::{
ZeroizeOnDrop,
};

/// An Ed25519 signing key.
// *Implementation note*: this is currently a refinement type around
// ed25519_consensus::SigningKey overriding its Debug implementation
// to not accidentally leak it.
#[derive(Clone, Zeroize, ZeroizeOnDrop)]
pub struct SigningKey(Ed25519SigningKey);

Expand Down
1 change: 0 additions & 1 deletion crates/astria-sequencer-relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ axum = { workspace = true }
base64 = { workspace = true }
base64-serde = { workspace = true }
celestia-types = { workspace = true }
ed25519-consensus = { workspace = true }
futures = { workspace = true }
hex = { workspace = true, features = ["serde"] }
humantime = { workspace = true }
Expand Down
43 changes: 2 additions & 41 deletions crates/astria-sequencer-relayer/src/validator.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use std::path::Path;

use astria_core::crypto::SigningKey;
use astria_eyre::eyre::{
self,
bail,
WrapErr as _,
};
use ed25519_consensus::VerificationKey;
use tendermint::account;
use tendermint_config::PrivValidatorKey;
use tracing::instrument;
Expand All @@ -17,19 +14,7 @@ use tracing::instrument;
pub(crate) struct Validator {
/// The tendermint validator account address; defined as
/// Sha256(verification_key)[..20].
pub(crate) address: account::Id,

/// The ed25519 signing key of this validator.
// allow: this entire struct is due to get removed as part of
// https://github.com/astriaorg/astria/issues/1010
#[allow(dead_code)]
pub(crate) signing_key: SigningKey,

/// The ed25519 verification key of this validator.
// allow: this entire struct is due to get removed as part of
// https://github.com/astriaorg/astria/issues/1010
#[allow(dead_code)]
pub(crate) verification_key: VerificationKey,
pub(super) address: account::Id,
}

impl Validator {
Expand All @@ -41,32 +26,8 @@ impl Validator {
pub(crate) fn from_path(path: impl AsRef<Path>) -> eyre::Result<Self> {
let key = PrivValidatorKey::load_json_file(&path.as_ref())
.wrap_err("failed reading private validator key from file")?;
Self::from_priv_validator_key(key)
}

pub(crate) fn from_priv_validator_key(key: PrivValidatorKey) -> eyre::Result<Self> {
let PrivValidatorKey {
address,
pub_key,
priv_key,
} = key;
let Some(tendermint_signing_key) = priv_key.ed25519_signing_key().cloned() else {
bail!("deserialized private key was not ed25519");
};
let signing_key = tendermint_signing_key.as_bytes().try_into().wrap_err(
"failed constructing ed25519 signing key from deserialized tendermint private key",
)?;
let Some(tendermint_verification_key) = pub_key.ed25519() else {
bail!("deserialized public key was not ed25519");
};
let verification_key = tendermint_verification_key.try_into().wrap_err(
"failed constructing ed25519 verification key from deserialized tendermint public key",
)?;

Ok(Self {
address,
signing_key,
verification_key,
address: key.address,
})
}
}
Expand Down

0 comments on commit 6b05e11

Please sign in to comment.