diff --git a/fendermint/app/src/cmd/run.rs b/fendermint/app/src/cmd/run.rs index 865ccecb9..9ddb9cf16 100644 --- a/fendermint/app/src/cmd/run.rs +++ b/fendermint/app/src/cmd/run.rs @@ -128,7 +128,7 @@ async fn run(settings: Settings) -> anyhow::Result<()> { .with_max_retries(settings.broadcast.max_retries) .with_retry_delay(settings.broadcast.retry_delay); - ValidatorContext::new(sk, broadcaster) + ValidatorContext::new(sk, addr, broadcaster) }); let testing_settings = match settings.testing.as_ref() { diff --git a/fendermint/vm/interpreter/src/fvm/checkpoint.rs b/fendermint/vm/interpreter/src/fvm/checkpoint.rs index ab9b2c0d5..b9ebd433a 100644 --- a/fendermint/vm/interpreter/src/fvm/checkpoint.rs +++ b/fendermint/vm/interpreter/src/fvm/checkpoint.rs @@ -261,7 +261,7 @@ where role: CheckpointSignedRole::Own, height: height.value(), hash: HexEncodableBlockHash(cp.block_hash.to_vec()), - validator: validator_ctx.public_key, + validator: validator_ctx.addr, }); tracing::debug!(?height, "submitted checkpoint signature"); diff --git a/fendermint/vm/interpreter/src/fvm/mod.rs b/fendermint/vm/interpreter/src/fvm/mod.rs index 42bbef7a5..e0fa04a26 100644 --- a/fendermint/vm/interpreter/src/fvm/mod.rs +++ b/fendermint/vm/interpreter/src/fvm/mod.rs @@ -24,6 +24,7 @@ pub use exec::FvmApplyRet; use fendermint_crypto::{PublicKey, SecretKey}; pub use fendermint_vm_message::query::FvmQuery; use fvm_ipld_blockstore::Blockstore; +use fvm_shared::address::Address; pub use query::FvmQueryRet; use tendermint_rpc::Client; @@ -40,18 +41,21 @@ pub struct ValidatorContext { secret_key: SecretKey, /// The public key identifying the validator (corresponds to the secret key.) public_key: PublicKey, + /// The address associated with the public key. + addr: Address, /// Used to broadcast transactions. It might use a different secret key for /// signing transactions than the validator's block producing key. broadcaster: Broadcaster, } impl ValidatorContext { - pub fn new(secret_key: SecretKey, broadcaster: Broadcaster) -> Self { + pub fn new(secret_key: SecretKey, addr: Address, broadcaster: Broadcaster) -> Self { // Derive the public keys so it's available to check whether this node is a validator at any point in time. let public_key = secret_key.public_key(); Self { secret_key, public_key, + addr, broadcaster, } } diff --git a/fendermint/vm/interpreter/src/fvm/observe.rs b/fendermint/vm/interpreter/src/fvm/observe.rs index d0304b879..e714981ca 100644 --- a/fendermint/vm/interpreter/src/fvm/observe.rs +++ b/fendermint/vm/interpreter/src/fvm/observe.rs @@ -1,6 +1,7 @@ // Copyright 2022-2024 Protocol Labs // SPDX-License-Identifier: Apache-2.0, MIT +use fvm_shared::address::Address; use ipc_observability::{ impl_traceable, impl_traceables, lazy_static, register_metrics, serde::HexEncodableBlockHash, Recordable, TraceLevel, Traceable, @@ -11,7 +12,6 @@ use prometheus::{ Histogram, IntCounter, IntGauge, IntGaugeVec, Registry, }; -use fendermint_crypto::PublicKey; use fvm_shared::message::Message; register_metrics! { @@ -110,13 +110,13 @@ pub struct CheckpointSigned { pub role: CheckpointSignedRole, pub height: u64, pub hash: HexEncodableBlockHash, - pub validator: PublicKey, + pub validator: Address, } impl Recordable for CheckpointSigned { fn record_metrics(&self) { BOTTOMUP_CHECKPOINT_SIGNED_HEIGHT - .with_label_values(&[format!("{:?}", self.validator).as_str()]) + .with_label_values(&[format!("{}", self.validator).as_str()]) .set(self.height as i64); } } @@ -146,11 +146,9 @@ 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, @@ -181,14 +179,11 @@ mod tests { config_number: 3, }); - let mut r = thread_rng(); - let secret_key = SecretKey::random(&mut r); - emit(CheckpointSigned { role: CheckpointSignedRole::Own, height: 1, hash: HexEncodableBlockHash(hash.clone()), - validator: secret_key.public_key(), + validator: Address::new_id(1), }); } }