From c918391d2b3e69acdb7561a7b0c1fbde7a22625d Mon Sep 17 00:00:00 2001 From: Krisztian Pinter Date: Tue, 10 Dec 2024 15:44:31 +0100 Subject: [PATCH 1/4] implement deregister command --- .../cli/smart-contracts-commands/src/lib.rs | 3 + .../smart-contracts-commands/src/register.rs | 40 ++++++- toolkit/offchain/src/register.rs | 113 ++++++++++++++++++ 3 files changed, 154 insertions(+), 2 deletions(-) diff --git a/toolkit/cli/smart-contracts-commands/src/lib.rs b/toolkit/cli/smart-contracts-commands/src/lib.rs index 94d25d745..7d4ae3fe9 100644 --- a/toolkit/cli/smart-contracts-commands/src/lib.rs +++ b/toolkit/cli/smart-contracts-commands/src/lib.rs @@ -16,6 +16,8 @@ pub enum SmartContractsCmd { UpsertDParameter(d_parameter::UpsertDParameterCmd), /// Register candidate Register(register::RegisterCmd), + /// Deregister candidate + Deregister(register::DeregisterCmd), } #[derive(Clone, Debug, clap::Parser)] @@ -34,6 +36,7 @@ impl SmartContractsCmd { Self::GetScripts(cmd) => cmd.execute().await, Self::UpsertDParameter(cmd) => cmd.execute().await, Self::Register(cmd) => cmd.execute().await, + Self::Deregister(cmd) => cmd.execute().await, } } diff --git a/toolkit/cli/smart-contracts-commands/src/register.rs b/toolkit/cli/smart-contracts-commands/src/register.rs index 5da81faeb..0b0ad4e03 100644 --- a/toolkit/cli/smart-contracts-commands/src/register.rs +++ b/toolkit/cli/smart-contracts-commands/src/register.rs @@ -1,5 +1,8 @@ use jsonrpsee::http_client::HttpClient; -use partner_chains_cardano_offchain::{await_tx::FixedDelayRetries, register::run_register}; +use partner_chains_cardano_offchain::{ + await_tx::FixedDelayRetries, + register::{run_deregister, run_register}, +}; use sidechain_domain::{ AdaBasedStaking, CandidateRegistration, MainchainPublicKey, MainchainSignature, PermissionedCandidateData, SidechainSignature, UtxoId, @@ -21,7 +24,7 @@ pub struct RegisterCmd { long, value_name = "PARTNERCHAIN_KEY:AURA_KEY:GRANDPA_KEY", alias = "sidechain-public-keys", - value_parser=parse_partnerchain_public_keys + value_parser = parse_partnerchain_public_keys )] partnerchain_public_keys: PermissionedCandidateData, #[arg(long, alias = "sidechain-signature")] @@ -61,3 +64,36 @@ impl RegisterCmd { Ok(()) } } + +#[derive(Clone, Debug, clap::Parser)] +pub struct DeregisterCmd { + #[clap(flatten)] + common_arguments: crate::CommonArguments, + #[arg(long)] + genesis_utxo: UtxoId, + #[arg(long)] + payment_key_file: String, + #[arg(long)] + spo_public_key: MainchainPublicKey, +} + +impl DeregisterCmd { + pub async fn execute(self) -> crate::CmdResult<()> { + let payment_signing_key = read_private_key_from_file(&self.payment_key_file)?; + let client = HttpClient::builder().build(self.common_arguments.ogmios_url)?; + let own_pkh = + crate::payment_signing_key_to_mainchain_address_hash(payment_signing_key.clone())?; + + run_deregister( + self.genesis_utxo, + payment_signing_key, + own_pkh, + self.spo_public_key, + &client, + FixedDelayRetries::two_minutes(), + ) + .await?; + + Ok(()) + } +} diff --git a/toolkit/offchain/src/register.rs b/toolkit/offchain/src/register.rs index 22431ed5f..ddb378ffa 100644 --- a/toolkit/offchain/src/register.rs +++ b/toolkit/offchain/src/register.rs @@ -135,6 +135,95 @@ pub async fn run_register< Ok(Some(result.transaction)) } +pub trait Deregister { + #[allow(async_fn_in_trait)] + async fn deregister( + &self, + genesis_utxo: UtxoId, + payment_signing_key: MainchainPrivateKey, + own_pkh: MainchainAddressHash, + stake_ownership_pub_key: MainchainPublicKey, + ) -> Result, OffchainError>; +} + +impl Deregister for T +where + T: QueryLedgerState + Transactions + QueryNetwork + QueryUtxoByUtxoId, +{ + async fn deregister( + &self, + genesis_utxo: UtxoId, + payment_signing_key: MainchainPrivateKey, + own_pkh: MainchainAddressHash, + stake_ownership_pub_key: MainchainPublicKey, + ) -> Result, OffchainError> { + run_deregister( + genesis_utxo, + payment_signing_key, + own_pkh, + stake_ownership_pub_key, + self, + FixedDelayRetries::two_minutes(), + ) + .await + .map_err(|e| OffchainError::InternalError(e.to_string())) + } +} + +pub async fn run_deregister< + C: QueryLedgerState + QueryNetwork + QueryUtxoByUtxoId + Transactions, + A: AwaitTx, +>( + genesis_utxo: UtxoId, + payment_signing_key: MainchainPrivateKey, + own_pkh: MainchainAddressHash, + stake_ownership_pub_key: MainchainPublicKey, + ogmios_client: &C, + await_tx: A, +) -> anyhow::Result> { + let ctx = TransactionContext::for_payment_key(payment_signing_key.0, ogmios_client).await?; + let validator = crate::scripts_data::registered_candidates_scripts(genesis_utxo)?; + let validator_address = validator.address_bech32(ctx.network)?; + let all_registration_utxos = ogmios_client.query_utxos(&[validator_address]).await?; + let own_registrations = + get_own_registrations(own_pkh, stake_ownership_pub_key.clone(), &all_registration_utxos); + + if own_registrations.is_empty() { + log::info!("✅ Candidate is not registered."); + return Ok(None); + } + + let own_registration_utxos = own_registrations.iter().map(|r| r.0.clone()).collect::>(); + let zero_ex_units = ExUnits::new(&0u64.into(), &0u64.into()); + let tx = deregister_tx(&validator, &own_registration_utxos, &ctx, zero_ex_units)?; + + let evaluate_response = + ogmios_client.evaluate_transaction(&tx.to_bytes()).await.map_err(|e| { + anyhow!( + "Evaluate candidate unregistration transaction request failed: {}, bytes: {}", + e, + hex::encode(tx.to_bytes()) + ) + })?; + let validator_redeemer_ex_units = get_first_validator_budget(evaluate_response)?; + let tx = deregister_tx(&validator, &own_registration_utxos, &ctx, validator_redeemer_ex_units)?; + let signed_tx = ctx.sign(&tx).to_bytes(); + let result = ogmios_client.submit_transaction(&signed_tx).await.map_err(|e| { + anyhow!( + "Submit candidate unregistration transaction request failed: {}, bytes: {}", + e, + hex::encode(tx.to_bytes()) + ) + })?; + let tx_id = result.transaction.id; + log::info!("✅ Transaction submitted. ID: {}", hex::encode(result.transaction.id)); + await_tx + .await_tx_output(ogmios_client, UtxoId { tx_hash: McTxHash(tx_id), index: UtxoIndex(0) }) + .await?; + + Ok(Some(result.transaction)) +} + fn get_own_registrations( own_pkh: MainchainAddressHash, spo_pub_key: MainchainPublicKey, @@ -210,6 +299,30 @@ fn register_tx( tx_builder.balance_update_and_build(ctx) } +fn deregister_tx( + validator: &PlutusScript, + own_registration_utxos: &[OgmiosUtxo], + ctx: &TransactionContext, + validator_redeemer_ex_units: ExUnits, +) -> Result { + let config = crate::csl::get_builder_config(ctx)?; + let mut tx_builder = TransactionBuilder::new(&config); + + { + let mut inputs = TxInputsBuilder::new(); + for own_registration_utxo in own_registration_utxos { + inputs.add_script_utxo_input( + own_registration_utxo, + validator, + validator_redeemer_ex_units.clone(), + )?; + } + tx_builder.set_inputs(&inputs); + } + + tx_builder.balance_update_and_build(ctx) +} + #[cfg(test)] mod tests { use super::register_tx; From b0e17c269cea8ca0dfd8651d58efef7e5e15df38 Mon Sep 17 00:00:00 2001 From: Krisztian Pinter Date: Wed, 11 Dec 2024 08:44:48 +0100 Subject: [PATCH 2/4] review comments --- toolkit/offchain/src/init_governance/mod.rs | 6 ++---- toolkit/offchain/src/register.rs | 22 ++++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/toolkit/offchain/src/init_governance/mod.rs b/toolkit/offchain/src/init_governance/mod.rs index 739315358..251e16a00 100644 --- a/toolkit/offchain/src/init_governance/mod.rs +++ b/toolkit/offchain/src/init_governance/mod.rs @@ -14,7 +14,7 @@ use ogmios_client::{ types::{OgmiosTx, OgmiosUtxo}, }; use partner_chains_plutus_data::version_oracle::VersionOracleDatum; -use sidechain_domain::{MainchainAddressHash, MainchainPrivateKey, McTxHash, UtxoId, UtxoIndex}; +use sidechain_domain::{MainchainAddressHash, MainchainPrivateKey, UtxoId}; #[cfg(test)] mod tests; @@ -128,9 +128,7 @@ pub async fn run_init_governance< let result = client.submit_transaction(&signed_transaction.to_bytes()).await?; let tx_id = result.transaction.id; log::info!("✅ Transaction submitted. ID: {}", hex::encode(result.transaction.id)); - await_tx - .await_tx_output(client, UtxoId { tx_hash: McTxHash(tx_id), index: UtxoIndex(0) }) - .await?; + await_tx.await_tx_output(client, UtxoId::new(tx_id, 0)).await?; Ok((genesis_utxo.to_domain(), result.transaction)) } diff --git a/toolkit/offchain/src/register.rs b/toolkit/offchain/src/register.rs index ddb378ffa..1d8ffffa6 100644 --- a/toolkit/offchain/src/register.rs +++ b/toolkit/offchain/src/register.rs @@ -18,7 +18,7 @@ use ogmios_client::{ query_ledger_state::{QueryLedgerState, QueryUtxoByUtxoId}, query_network::QueryNetwork, transactions::Transactions, - types::{OgmiosTx, OgmiosUtxo}, + types::OgmiosUtxo, }; use partner_chains_plutus_data::registered_candidates::{ candidate_registration_to_plutus_data, RegisterValidatorDatum, @@ -32,7 +32,7 @@ pub trait Register { genesis_utxo: UtxoId, candidate_registration: &CandidateRegistration, payment_signing_key: MainchainPrivateKey, - ) -> Result, OffchainError>; + ) -> Result, OffchainError>; } impl Register for T @@ -44,7 +44,7 @@ where genesis_utxo: UtxoId, candidate_registration: &CandidateRegistration, payment_signing_key: MainchainPrivateKey, - ) -> Result, OffchainError> { + ) -> Result, OffchainError> { run_register( genesis_utxo, candidate_registration, @@ -66,7 +66,7 @@ pub async fn run_register< payment_signing_key: MainchainPrivateKey, ogmios_client: &C, await_tx: A, -) -> anyhow::Result> { +) -> anyhow::Result> { let ctx = TransactionContext::for_payment_key(payment_signing_key.0, ogmios_client).await?; let validator = crate::scripts_data::registered_candidates_scripts(genesis_utxo)?; let validator_address = validator.address_bech32(ctx.network)?; @@ -132,7 +132,7 @@ pub async fn run_register< log::info!("✅ Transaction submitted. ID: {}", hex::encode(result.transaction.id)); await_tx.await_tx_output(ogmios_client, UtxoId::new(tx_id, 0)).await?; - Ok(Some(result.transaction)) + Ok(Some(McTxHash(result.transaction.id))) } pub trait Deregister { @@ -143,7 +143,7 @@ pub trait Deregister { payment_signing_key: MainchainPrivateKey, own_pkh: MainchainAddressHash, stake_ownership_pub_key: MainchainPublicKey, - ) -> Result, OffchainError>; + ) -> Result, OffchainError>; } impl Deregister for T @@ -156,7 +156,7 @@ where payment_signing_key: MainchainPrivateKey, own_pkh: MainchainAddressHash, stake_ownership_pub_key: MainchainPublicKey, - ) -> Result, OffchainError> { + ) -> Result, OffchainError> { run_deregister( genesis_utxo, payment_signing_key, @@ -180,7 +180,7 @@ pub async fn run_deregister< stake_ownership_pub_key: MainchainPublicKey, ogmios_client: &C, await_tx: A, -) -> anyhow::Result> { +) -> anyhow::Result> { let ctx = TransactionContext::for_payment_key(payment_signing_key.0, ogmios_client).await?; let validator = crate::scripts_data::registered_candidates_scripts(genesis_utxo)?; let validator_address = validator.address_bech32(ctx.network)?; @@ -217,11 +217,9 @@ pub async fn run_deregister< })?; let tx_id = result.transaction.id; log::info!("✅ Transaction submitted. ID: {}", hex::encode(result.transaction.id)); - await_tx - .await_tx_output(ogmios_client, UtxoId { tx_hash: McTxHash(tx_id), index: UtxoIndex(0) }) - .await?; + await_tx.await_tx_output(ogmios_client, UtxoId::new(tx_id, 0)).await?; - Ok(Some(result.transaction)) + Ok(Some(McTxHash(result.transaction.id))) } fn get_own_registrations( From fe04751593b5d95dee34d785968cd9c7a1714023 Mon Sep 17 00:00:00 2001 From: Krisztian Pinter Date: Thu, 12 Dec 2024 23:51:31 +0100 Subject: [PATCH 3/4] review comments --- Cargo.lock | 1 + toolkit/cli/smart-contracts-commands/src/lib.rs | 12 ------------ .../cli/smart-contracts-commands/src/register.rs | 5 +---- toolkit/offchain/src/register.rs | 10 +++------- toolkit/offchain/tests/integration_tests.rs | 2 +- toolkit/partner-chains-cli/src/cardano_key.rs | 14 +------------- .../prepare_main_chain_config.rs | 2 +- toolkit/primitives/domain/Cargo.toml | 2 ++ toolkit/primitives/domain/src/lib.rs | 15 +++++++++++++++ 9 files changed, 25 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 899d3b64f..495f380f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9949,6 +9949,7 @@ version = "1.4.0" dependencies = [ "blake2b_simd", "byte-string-derive", + "cardano-serialization-lib", "derive_more", "figment", "hex", diff --git a/toolkit/cli/smart-contracts-commands/src/lib.rs b/toolkit/cli/smart-contracts-commands/src/lib.rs index 7d4ae3fe9..632b936b8 100644 --- a/toolkit/cli/smart-contracts-commands/src/lib.rs +++ b/toolkit/cli/smart-contracts-commands/src/lib.rs @@ -79,18 +79,6 @@ pub(crate) fn parse_partnerchain_public_keys( } } -fn payment_signing_key_to_mainchain_address_hash( - payment_signing_key: MainchainPrivateKey, -) -> CmdResult { - Ok(cardano_serialization_lib::PrivateKey::from_normal_bytes(&payment_signing_key.0)? - .to_public() - .hash() - .to_bytes() - .as_slice() - .try_into() - .map(MainchainAddressHash)?) -} - #[cfg(test)] mod test { use crate::parse_partnerchain_public_keys; diff --git a/toolkit/cli/smart-contracts-commands/src/register.rs b/toolkit/cli/smart-contracts-commands/src/register.rs index 0b0ad4e03..7c77e0c75 100644 --- a/toolkit/cli/smart-contracts-commands/src/register.rs +++ b/toolkit/cli/smart-contracts-commands/src/register.rs @@ -46,7 +46,7 @@ impl RegisterCmd { }, partnerchain_pub_key: self.partnerchain_public_keys.sidechain_public_key, partnerchain_signature: self.partnerchain_signature, - own_pkh: crate::payment_signing_key_to_mainchain_address_hash(payment_key.clone())?, + own_pkh: payment_key.to_pub_key_hash(), registration_utxo: self.registration_utxo, aura_pub_key: self.partnerchain_public_keys.aura_public_key, grandpa_pub_key: self.partnerchain_public_keys.grandpa_public_key, @@ -81,13 +81,10 @@ impl DeregisterCmd { pub async fn execute(self) -> crate::CmdResult<()> { let payment_signing_key = read_private_key_from_file(&self.payment_key_file)?; let client = HttpClient::builder().build(self.common_arguments.ogmios_url)?; - let own_pkh = - crate::payment_signing_key_to_mainchain_address_hash(payment_signing_key.clone())?; run_deregister( self.genesis_utxo, payment_signing_key, - own_pkh, self.spo_public_key, &client, FixedDelayRetries::two_minutes(), diff --git a/toolkit/offchain/src/register.rs b/toolkit/offchain/src/register.rs index 1d8ffffa6..05f994698 100644 --- a/toolkit/offchain/src/register.rs +++ b/toolkit/offchain/src/register.rs @@ -141,7 +141,6 @@ pub trait Deregister { &self, genesis_utxo: UtxoId, payment_signing_key: MainchainPrivateKey, - own_pkh: MainchainAddressHash, stake_ownership_pub_key: MainchainPublicKey, ) -> Result, OffchainError>; } @@ -154,13 +153,11 @@ where &self, genesis_utxo: UtxoId, payment_signing_key: MainchainPrivateKey, - own_pkh: MainchainAddressHash, stake_ownership_pub_key: MainchainPublicKey, ) -> Result, OffchainError> { run_deregister( genesis_utxo, payment_signing_key, - own_pkh, stake_ownership_pub_key, self, FixedDelayRetries::two_minutes(), @@ -176,7 +173,6 @@ pub async fn run_deregister< >( genesis_utxo: UtxoId, payment_signing_key: MainchainPrivateKey, - own_pkh: MainchainAddressHash, stake_ownership_pub_key: MainchainPublicKey, ogmios_client: &C, await_tx: A, @@ -186,7 +182,7 @@ pub async fn run_deregister< let validator_address = validator.address_bech32(ctx.network)?; let all_registration_utxos = ogmios_client.query_utxos(&[validator_address]).await?; let own_registrations = - get_own_registrations(own_pkh, stake_ownership_pub_key.clone(), &all_registration_utxos); + get_own_registrations(payment_signing_key.to_pub_key_hash(), stake_ownership_pub_key.clone(), &all_registration_utxos); if own_registrations.is_empty() { log::info!("✅ Candidate is not registered."); @@ -200,7 +196,7 @@ pub async fn run_deregister< let evaluate_response = ogmios_client.evaluate_transaction(&tx.to_bytes()).await.map_err(|e| { anyhow!( - "Evaluate candidate unregistration transaction request failed: {}, bytes: {}", + "Evaluate candidate deregistration transaction request failed: {}, bytes: {}", e, hex::encode(tx.to_bytes()) ) @@ -210,7 +206,7 @@ pub async fn run_deregister< let signed_tx = ctx.sign(&tx).to_bytes(); let result = ogmios_client.submit_transaction(&signed_tx).await.map_err(|e| { anyhow!( - "Submit candidate unregistration transaction request failed: {}, bytes: {}", + "Submit candidate deregistration transaction request failed: {}, bytes: {}", e, hex::encode(tx.to_bytes()) ) diff --git a/toolkit/offchain/tests/integration_tests.rs b/toolkit/offchain/tests/integration_tests.rs index b13532a31..73abed7ef 100644 --- a/toolkit/offchain/tests/integration_tests.rs +++ b/toolkit/offchain/tests/integration_tests.rs @@ -183,7 +183,7 @@ async fn run_register Option { +) -> Option { let eve_utxos = client.query_utxos(&[EVE_ADDRESS.to_string()]).await.unwrap(); let registration_utxo = eve_utxos.first().unwrap().utxo_id(); client diff --git a/toolkit/partner-chains-cli/src/cardano_key.rs b/toolkit/partner-chains-cli/src/cardano_key.rs index c5d02b770..456d784af 100644 --- a/toolkit/partner-chains-cli/src/cardano_key.rs +++ b/toolkit/partner-chains-cli/src/cardano_key.rs @@ -1,6 +1,6 @@ use crate::IOContext; use anyhow::anyhow; -use sidechain_domain::{MainchainAddressHash, MainchainPrivateKey}; +use sidechain_domain::MainchainPrivateKey; #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] @@ -45,15 +45,3 @@ pub(crate) fn get_mc_pkey_from_file( ) -> anyhow::Result { Ok(MainchainPrivateKey(get_key_bytes_from_file(path, context)?)) } - -pub(crate) fn get_mc_address_hash_from_pkey(pkey: &MainchainPrivateKey) -> MainchainAddressHash { - let csl_private_key = cardano_serialization_lib::PrivateKey::from_normal_bytes(&pkey.0) - .expect("Conversion is infallible"); - let csl_public_key_hash = csl_private_key - .to_public() - .hash() - .to_bytes() - .try_into() - .expect("Bytes represent correct public key hash"); - MainchainAddressHash(csl_public_key_hash) -} diff --git a/toolkit/partner-chains-cli/src/prepare_configuration/prepare_main_chain_config.rs b/toolkit/partner-chains-cli/src/prepare_configuration/prepare_main_chain_config.rs index e6ce79984..b8d87f7b9 100644 --- a/toolkit/partner-chains-cli/src/prepare_configuration/prepare_main_chain_config.rs +++ b/toolkit/partner-chains-cli/src/prepare_configuration/prepare_main_chain_config.rs @@ -42,7 +42,7 @@ fn get_private_key_and_key_hash( let cardano_signig_key_file = config_fields::CARDANO_PAYMENT_SIGNING_KEY_FILE .prompt_with_default_from_file_and_save(context); let pkey = cardano_key::get_mc_pkey_from_file(&cardano_signig_key_file, context)?; - let addr_hash = cardano_key::get_mc_address_hash_from_pkey(&pkey); + let addr_hash = pkey.to_pub_key_hash(); Ok((pkey, addr_hash)) } diff --git a/toolkit/primitives/domain/Cargo.toml b/toolkit/primitives/domain/Cargo.toml index 7b5e80744..ae00d8b58 100644 --- a/toolkit/primitives/domain/Cargo.toml +++ b/toolkit/primitives/domain/Cargo.toml @@ -24,6 +24,7 @@ lazy_static = { workspace = true } blake2b_simd = { workspace = true } figment = { workspace = true, optional = true } thiserror = { workspace = true, optional = true } +cardano-serialization-lib = { workspace = true, optional = true } [dev-dependencies] serde_json = { workspace = true } @@ -38,6 +39,7 @@ std = [ "num-bigint/std", "figment", "thiserror", + "cardano-serialization-lib", ] serde = [ "dep:serde", diff --git a/toolkit/primitives/domain/src/lib.rs b/toolkit/primitives/domain/src/lib.rs index 9370a314e..9833c30c2 100644 --- a/toolkit/primitives/domain/src/lib.rs +++ b/toolkit/primitives/domain/src/lib.rs @@ -216,6 +216,21 @@ impl core::fmt::Debug for MainchainPrivateKey { } } +impl MainchainPrivateKey { + #[cfg(feature = "std")] + pub fn to_pub_key_hash(&self) -> MainchainAddressHash { + cardano_serialization_lib::PrivateKey::from_normal_bytes(&self.0) + .expect("impossible") + .to_public() + .hash() + .to_bytes() + .as_slice() + .try_into() + .map(MainchainAddressHash) + .expect("impossible") + } +} + impl TryFrom> for MainchainPublicKey { type Error = &'static str; From b1f4755dfeabd92925831a2dbde86beab6644d44 Mon Sep 17 00:00:00 2001 From: Krisztian Pinter Date: Fri, 13 Dec 2024 09:28:57 +0100 Subject: [PATCH 4/4] review comment --- toolkit/offchain/src/register.rs | 7 +++++-- toolkit/primitives/domain/src/lib.rs | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/toolkit/offchain/src/register.rs b/toolkit/offchain/src/register.rs index 05f994698..20d1e68b7 100644 --- a/toolkit/offchain/src/register.rs +++ b/toolkit/offchain/src/register.rs @@ -181,8 +181,11 @@ pub async fn run_deregister< let validator = crate::scripts_data::registered_candidates_scripts(genesis_utxo)?; let validator_address = validator.address_bech32(ctx.network)?; let all_registration_utxos = ogmios_client.query_utxos(&[validator_address]).await?; - let own_registrations = - get_own_registrations(payment_signing_key.to_pub_key_hash(), stake_ownership_pub_key.clone(), &all_registration_utxos); + let own_registrations = get_own_registrations( + payment_signing_key.to_pub_key_hash(), + stake_ownership_pub_key.clone(), + &all_registration_utxos, + ); if own_registrations.is_empty() { log::info!("✅ Candidate is not registered."); diff --git a/toolkit/primitives/domain/src/lib.rs b/toolkit/primitives/domain/src/lib.rs index 9833c30c2..2b5c7a197 100644 --- a/toolkit/primitives/domain/src/lib.rs +++ b/toolkit/primitives/domain/src/lib.rs @@ -220,14 +220,14 @@ impl MainchainPrivateKey { #[cfg(feature = "std")] pub fn to_pub_key_hash(&self) -> MainchainAddressHash { cardano_serialization_lib::PrivateKey::from_normal_bytes(&self.0) - .expect("impossible") + .expect("Conversion cannot fail on valid MainchainPrivateKey values") .to_public() .hash() .to_bytes() .as_slice() .try_into() .map(MainchainAddressHash) - .expect("impossible") + .expect("Conversion cannot fail as representation is the same") } }