Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge queue: embarking main (511f079), #3507 and #3617 together #3623

Closed
wants to merge 10 commits into from
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/3507-decode-asset-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Decode asset types to addresses when generating test vectors if possible.
([\#3507](https://github.com/anoma/namada/pull/3507))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Display the hash of the proposal wasm code when querying proposals with
associated wasm payload. ([\#3617](https://github.com/anoma/namada/pull/3617))
21 changes: 17 additions & 4 deletions crates/governance/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::collections::{BTreeMap, BTreeSet};
use namada_core::address::Address;
use namada_core::borsh::BorshDeserialize;
use namada_core::collections::HashSet;
use namada_core::hash::Hash;
use namada_core::storage::Epoch;
use namada_core::token;
use namada_state::{
Expand Down Expand Up @@ -169,17 +170,29 @@ where
let proposal_type: Option<ProposalType> =
storage.read(&proposal_type_key)?;

let proposal = proposal_type.map(|proposal_type| StorageProposal {
let proposal_type = if let Some(proposal_type) = proposal_type {
if let ProposalType::DefaultWithWasm(_) = proposal_type {
let proposal_code_key = governance_keys::get_proposal_code_key(id);
let proposal_code: Vec<u8> =
storage.read(&proposal_code_key)?.unwrap_or_default();
let proposal_code_hash = Hash::sha256(proposal_code);
ProposalType::DefaultWithWasm(proposal_code_hash)
} else {
proposal_type
}
} else {
return Ok(None);
};

Ok(Some(StorageProposal {
id,
content: content.unwrap(),
author: author.unwrap(),
r#type: proposal_type,
voting_start_epoch: voting_start_epoch.unwrap(),
voting_end_epoch: voting_end_epoch.unwrap(),
activation_epoch: activation_epoch.unwrap(),
});

Ok(proposal)
}))
}

/// Query all the votes for a proposal_id
Expand Down
10 changes: 1 addition & 9 deletions crates/node/src/shell/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@ where
TallyResult::Passed => {
let proposal_event = match proposal_type {
ProposalType::Default => {
let proposal_code =
gov_api::get_proposal_code(&shell.state, id)?
.unwrap_or_default();
let _result = execute_default_proposal(
shell,
id,
proposal_code.clone(),
)?;
tracing::info!(
"Governance proposal #{} (default) has passed.",
id,
Expand Down Expand Up @@ -176,7 +168,7 @@ where
}
ProposalType::PGFPayment(payments) => {
let native_token = &shell.state.get_native_token()?;
let _result = execute_pgf_funding_proposal(
execute_pgf_funding_proposal(
&mut shell.state,
events,
native_token,
Expand Down
39 changes: 30 additions & 9 deletions crates/sdk/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ async fn make_ledger_amount_asset(
));
} else {
output.extend(vec![
format!("{}Token : {}", prefix, token),
format!("{}Token : {}", prefix, decoded.token),
format!(
"{}Amount : {}",
prefix,
Expand Down Expand Up @@ -1020,9 +1020,10 @@ pub async fn to_ledger_vector(
Error::from(EncodingError::Conversion(err.to_string()))
})?;

tv.name = "Init_Validator_0".to_string();
tv.name = "Become_Validator_0".to_string();

tv.output.extend(vec!["Type : Init Validator".to_string()]);
tv.output
.extend(vec!["Type : Become Validator".to_string()]);
tv.output.extend(vec![
format!("Address : {}", init_validator.address),
format!("Consensus key : {}", init_validator.consensus_key),
Expand All @@ -1036,6 +1037,9 @@ pub async fn to_ledger_vector(
),
format!("Email : {}", init_validator.email),
]);
if let Some(name) = &init_validator.name {
tv.output.push(format!("Name : {}", name));
}
if let Some(description) = &init_validator.description {
tv.output.push(format!("Description : {}", description));
}
Expand All @@ -1046,6 +1050,9 @@ pub async fn to_ledger_vector(
tv.output
.push(format!("Discord handle : {}", discord_handle));
}
if let Some(avatar) = &init_validator.avatar {
tv.output.push(format!("Avatar : {}", avatar));
}

tv.output_expert.extend(vec![
format!("Address : {}", init_validator.address),
Expand All @@ -1060,6 +1067,9 @@ pub async fn to_ledger_vector(
),
format!("Email : {}", init_validator.email),
]);
if let Some(name) = &init_validator.name {
tv.output_expert.push(format!("Name : {}", name));
}
if let Some(description) = &init_validator.description {
tv.output_expert
.push(format!("Description : {}", description));
Expand All @@ -1071,6 +1081,9 @@ pub async fn to_ledger_vector(
tv.output_expert
.push(format!("Discord handle : {}", discord_handle));
}
if let Some(avatar) = &init_validator.avatar {
tv.output_expert.push(format!("Avatar : {}", avatar));
}
} else if code_sec.tag == Some(TX_INIT_PROPOSAL.to_string()) {
let init_proposal_data = InitProposalData::try_from_slice(
&tx.data(cmt)
Expand Down Expand Up @@ -1302,7 +1315,6 @@ pub async fn to_ledger_vector(
"Receiver : {}",
transfer.message.packet_data.receiver
),
format!("Memo : {}", transfer.message.packet_data.memo),
format!(
"Timeout height : {}",
transfer.message.timeout_height_on_b
Expand All @@ -1329,7 +1341,14 @@ pub async fn to_ledger_vector(
"Receiver : {}",
transfer.message.packet_data.receiver
),
format!("Memo : {}", transfer.message.packet_data.memo),
]);
if !transfer.message.packet_data.memo.to_string().is_empty() {
tv.output_expert.push(format!(
"Memo : {}",
transfer.message.packet_data.memo
));
}
tv.output_expert.extend(vec![
format!(
"Timeout height : {}",
transfer.message.timeout_height_on_b
Expand Down Expand Up @@ -1427,9 +1446,6 @@ pub async fn to_ledger_vector(
transfer.message.packet_data.receiver
),
]);
if let Some(memo) = &transfer.message.packet_data.memo {
tv.output.push(format!("Memo: {}", memo));
}
tv.output.extend(vec![
format!(
"Timeout height : {}",
Expand Down Expand Up @@ -1499,7 +1515,9 @@ pub async fn to_ledger_vector(
),
]);
if let Some(memo) = &transfer.message.packet_data.memo {
tv.output_expert.push(format!("Memo: {}", memo));
if !memo.to_string().is_empty() {
tv.output_expert.push(format!("Memo: {}", memo));
}
}
tv.output_expert.extend(vec![
format!(
Expand Down Expand Up @@ -1693,6 +1711,9 @@ pub async fn to_ledger_vector(
let mut other_items = vec![];
other_items
.push(format!("Validator : {}", metadata_change.validator));
if let Some(name) = metadata_change.name {
other_items.push(format!("Name : {}", name));
}
if let Some(email) = metadata_change.email {
other_items.push(format!("Email : {}", email));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tx/src/data/pgf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub mod tests {
/// Generate an arbitraary steward commission update
pub fn arb_update_steward_commission()(
steward in arb_non_internal_address(),
commission in collection::hash_map(arb_non_internal_address(), arb_dec(), 0..10),
commission in collection::btree_map(arb_non_internal_address(), arb_dec(), 0..10),
) -> UpdateStewardCommission {
UpdateStewardCommission {
steward,
Expand Down
2 changes: 1 addition & 1 deletion examples/generate_txs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use proptest::test_runner::{Reason, TestRunner};

#[tokio::main]
async fn main() -> Result<(), Reason> {
let mut runner = TestRunner::default();
let mut runner = TestRunner::deterministic();
let wallet = FsWalletUtils::new(PathBuf::from("wallet.toml"));
let mut debug_vectors = vec![];
let mut test_vectors = vec![];
Expand Down