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

client: print sha256 of proposal wasm #3617

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
)?;
Comment on lines -125 to -132
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grarco I think this is not needed in this branch right?

Copy link
Contributor

@grarco grarco Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct and I don't know why it is still there. I swear we talked about this thing already a few months ago and we fixed it.

Anyway, I also see that execute_pgf_funding_proposal returns a boolean that we never use so we might remove that too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im now using the result to improve the print statement

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it looks to me that execute_pgf_funding_proposal only ever returns Ok(true)

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