From b0a1fe3e1fd6199d66fba45580fe8df310477ddc Mon Sep 17 00:00:00 2001 From: Tiago Carvalho Date: Fri, 24 Nov 2023 13:29:02 +0000 Subject: [PATCH] fixup! sumbish --- apps/src/lib/client/utils.rs | 2 +- apps/src/lib/config/genesis.rs | 2 +- apps/src/lib/config/genesis/chain.rs | 10 +++--- apps/src/lib/config/genesis/transactions.rs | 38 ++++++++++++--------- tests/src/e2e/ibc_tests.rs | 6 ++-- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index 4b9ebf7eac5..6c42648ab50 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -633,7 +633,7 @@ pub fn derive_genesis_addresses( .validator_account .unwrap_or_default() .into_iter() - .map(|acct| acct.address) + .map(|acct| acct.data.address) .collect(), ) }); diff --git a/apps/src/lib/config/genesis.rs b/apps/src/lib/config/genesis.rs index b335e150887..33d8fe90ba8 100644 --- a/apps/src/lib/config/genesis.rs +++ b/apps/src/lib/config/genesis.rs @@ -402,7 +402,7 @@ pub fn make_dev_genesis( .get(0) .unwrap(); let genesis_addr = - GenesisAddress::EstablishedAddress(tx.tx.address.raw.clone()); + GenesisAddress::EstablishedAddress(tx.tx.data.address.raw.clone()); let balance = *nam_balances.0.get(&genesis_addr).unwrap(); let bonded = { diff --git a/apps/src/lib/config/genesis/chain.rs b/apps/src/lib/config/genesis/chain.rs index 55f675b6d28..b5ff28d086a 100644 --- a/apps/src/lib/config/genesis/chain.rs +++ b/apps/src/lib/config/genesis/chain.rs @@ -182,7 +182,7 @@ impl Finalized { self.transactions.find_validator(tendermint_pk).map( |validator_tx| { ( - validator_tx.tx.net_address, + validator_tx.tx.data.net_address, validator_tx.derive_tendermint_address(), ) }, @@ -651,7 +651,7 @@ impl FinalizedTransactions { let validator_account = validator_account.map(|txs| { txs.into_iter() .map(|tx| FinalizedValidatorAccountTx { - address: Address::Established(tx.address.raw.clone()), + address: Address::Established(tx.data.address.raw.clone()), tx, }) .collect() @@ -670,7 +670,7 @@ impl FinalizedTransactions { let validator_accounts = self.validator_account.as_ref()?; validator_accounts .iter() - .find(|tx| &tx.tx.tendermint_node_key.pk.raw == tendermint_pk) + .find(|tx| &tx.tx.data.tendermint_node_key.pk.raw == tendermint_pk) } } @@ -754,12 +754,12 @@ impl FinalizedValidatorAccountTx { pub fn derive_tendermint_address(&self) -> TendermintAddress { // Derive the node ID from the node key let node_id: TendermintNodeId = - id_from_pk(&self.tx.tendermint_node_key.pk.raw); + id_from_pk(&self.tx.data.tendermint_node_key.pk.raw); // Build the list of persistent peers from the validators' node IDs TendermintAddress::from_str(&format!( "{}@{}", - node_id, self.tx.net_address, + node_id, self.tx.data.net_address, )) .expect("Validator address must be valid") } diff --git a/apps/src/lib/config/genesis/transactions.rs b/apps/src/lib/config/genesis/transactions.rs index c3de00dc632..679f61cc74d 100644 --- a/apps/src/lib/config/genesis/transactions.rs +++ b/apps/src/lib/config/genesis/transactions.rs @@ -32,7 +32,7 @@ use crate::config::genesis::GenesisAddress; use crate::wallet::CliWalletUtils; /// Helper trait to fetch tx data to sign. -trait TxToSign { +pub trait TxToSign { /// Return tx data to sign. fn tx_to_sign(&self) -> Vec; } @@ -561,7 +561,7 @@ impl Signed { } /// Return the inner wrapped `T`. - pub const fn into_inner(self) -> T { + pub fn into_inner(self) -> T { let Signed { data, .. } = self; data } @@ -601,7 +601,7 @@ impl Signed { let mut valid_sigs = 0; let tx_to_sign = data.tx_to_sign(); for pk in pks { - if let Some(sig) = signatures.get(&pk.raw) { + if let Some(sig) = signatures.get(&StringEncoded::new(pk.clone())) { valid_sigs += verify_standalone_sig::<_, SerializeWithBorsh>( &tx_to_sign, pk, @@ -816,19 +816,23 @@ pub fn validate( |validator_accounts| { validator_accounts .into_iter() - .map(|acct| ValidatorAccountTx { - address: acct.address, - vp: acct.vp, - commission_rate: acct.commission_rate, - max_commission_rate_change: acct - .max_commission_rate_change, - net_address: acct.net_address, - consensus_key: acct.consensus_key, - protocol_key: acct.protocol_key, - tendermint_node_key: acct.tendermint_node_key, - eth_hot_key: acct.eth_hot_key, - eth_cold_key: acct.eth_cold_key, - metadata: acct.metadata, + .map(|acct| SignedValidatorAccountTx { + signatures: acct.signatures, + data: ValidatorAccountTx { + address: acct.data.address, + vp: acct.data.vp, + commission_rate: acct.data.commission_rate, + max_commission_rate_change: acct + .data + .max_commission_rate_change, + net_address: acct.data.net_address, + consensus_key: acct.data.consensus_key, + protocol_key: acct.data.protocol_key, + tendermint_node_key: acct.data.tendermint_node_key, + eth_hot_key: acct.data.eth_hot_key, + eth_cold_key: acct.data.eth_cold_key, + metadata: acct.data.metadata, + }, }) .collect() }, @@ -1038,7 +1042,7 @@ pub fn validate_validator_account( true } } else { - let source = &tx.addr; + let source = &tx.address.raw; eprintln!( "Invalid validator account tx. Couldn't verify the underlying \ established account signatures, because the source account's \ diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index b0d0cf47d1b..0b20e3fa7ce 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -285,9 +285,9 @@ fn setup_two_single_node_nets() -> Result<(Test, Test)> { .iter_mut() .find(|val| val.address == validator_addr) .unwrap(); - let new_port = - validator_tx.tx.net_address.port() + setup::ANOTHER_CHAIN_PORT_OFFSET; - validator_tx.tx.net_address.set_port(new_port); + let new_port = validator_tx.tx.data.net_address.port() + + setup::ANOTHER_CHAIN_PORT_OFFSET; + validator_tx.tx.data.net_address.set_port(new_port); genesis_b .write_toml_files(&genesis_b_dir.join(test_a.net.chain_id.as_str())) .map_err(|_| eyre!("Could not write genesis toml files for test_b"))?;