Skip to content

Commit

Permalink
fixup! sumbish
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Nov 24, 2023
1 parent afa3a64 commit b0a1fe3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion apps/src/lib/client/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
});
Expand Down
2 changes: 1 addition & 1 deletion apps/src/lib/config/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 5 additions & 5 deletions apps/src/lib/config/genesis/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
},
Expand Down Expand Up @@ -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()
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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")
}
Expand Down
38 changes: 21 additions & 17 deletions apps/src/lib/config/genesis/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>;
}
Expand Down Expand Up @@ -561,7 +561,7 @@ impl<T> Signed<T> {
}

/// Return the inner wrapped `T`.
pub const fn into_inner(self) -> T {
pub fn into_inner(self) -> T {
let Signed { data, .. } = self;
data
}
Expand Down Expand Up @@ -601,7 +601,7 @@ impl<T> Signed<T> {
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,
Expand Down Expand Up @@ -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()
},
Expand Down Expand Up @@ -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 \
Expand Down
6 changes: 3 additions & 3 deletions tests/src/e2e/ibc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))?;
Expand Down

0 comments on commit b0a1fe3

Please sign in to comment.