Skip to content

Commit

Permalink
feat: change public key
Browse files Browse the repository at this point in the history
  • Loading branch information
karlem committed Jul 18, 2024
1 parent 3d5b48d commit e8fe0c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fendermint/vm/interpreter/src/fvm/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ where
emit(CheckpointSigned {
height: height.value(),
hash: HexEncodableBlockHash(cp.block_hash.to_vec()),
validator: &hex::encode(validator_ctx.public_key.serialize()),
validator: validator_ctx.public_key,
});

tracing::debug!(?height, "submitted checkpoint signature");
Expand Down
19 changes: 13 additions & 6 deletions fendermint/vm/interpreter/src/fvm/observe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use prometheus::{
Histogram, IntCounter, IntGauge, IntGaugeVec, Registry,
};

use fendermint_crypto::PublicKey;
use fvm_shared::message::Message;

register_metrics! {
Expand Down Expand Up @@ -77,7 +78,7 @@ impl_traceables!(
TraceLevel::Info,
"Bottomup",
CheckpointCreated,
CheckpointSigned<'a>,
CheckpointSigned,
CheckpointFinalized
);

Expand All @@ -102,16 +103,16 @@ impl Recordable for CheckpointCreated {
}

#[derive(Debug)]
pub struct CheckpointSigned<'a> {
pub struct CheckpointSigned {
pub height: u64,
pub hash: HexEncodableBlockHash,
pub validator: &'a str,
pub validator: PublicKey,
}

impl Recordable for CheckpointSigned<'_> {
impl Recordable for CheckpointSigned {
fn record_metrics(&self) {
BOTTOMUP_CHECKPOINT_SIGNED_HEIGHT
.with_label_values(&[self.validator])
.with_label_values(&[format!("{:?}", self.validator).as_str()])
.set(self.height as i64);
}
}
Expand Down Expand Up @@ -141,9 +142,11 @@ mod tests {

#[test]
fn test_emit() {
use fendermint_crypto::SecretKey;
use fvm_ipld_encoding::RawBytes;
use fvm_shared::address::Address;
use fvm_shared::econ::TokenAmount;
use rand::thread_rng;

let message = Message {
version: 1,
Expand Down Expand Up @@ -173,10 +176,14 @@ mod tests {
msg_count: 2,
config_number: 3,
});

let mut r = thread_rng();
let secret_key = SecretKey::random(&mut r);

emit(CheckpointSigned {
height: 1,
hash: HexEncodableBlockHash(hash.clone()),
validator: "validator",
validator: secret_key.public_key(),
});
}
}

0 comments on commit e8fe0c2

Please sign in to comment.