Skip to content
Open
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 @@
- Indexers fail to identify the types of older txs since these types use wasm hashes. If those hashes were overwritten by governance proposals, the indexer is unable to determine how to deserialize these txs. This PR adds a new key to storage which allows looking up a tx type from a wasm hash, even if that hash is of code no longer in use. ([\#4690](https://github.com/anoma/namada/pull/4690))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- For each inner tx, an event is emitted giving the human readable wasm name of the code contained in said tx.([\#4691](https://github.com/anoma/namada/pull/4691))
12 changes: 11 additions & 1 deletion crates/core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ impl Key {
}

/// Returns a key of wasm code's hash of the given name
pub fn wasm_code_name(code_name: String) -> Self {
pub fn wasm_code_hash(code_name: String) -> Self {
let mut segments =
Self::from(PARAMETERS.to_owned().to_db_key()).segments;
segments.push(DbKeySeg::StringSeg(WASM_KEY_PREFIX.to_owned()));
Expand Down Expand Up @@ -580,6 +580,16 @@ impl Key {
Key { segments }
}

/// Returns a key of the wasm name of the given code hash
pub fn wasm_code_name(code_hash: &Hash) -> Self {
let mut segments =
Self::from(PARAMETERS.to_owned().to_db_key()).segments;
segments.push(DbKeySeg::StringSeg(WASM_KEY_PREFIX.to_owned()));
segments.push(DbKeySeg::StringSeg(WASM_HASH_PREFIX.to_owned()));
segments.push(DbKeySeg::StringSeg(code_hash.to_string()));
Key { segments }
}

/// Returns a key of the validity predicate of the given address
/// Only this function can push "?" segment for validity predicate
pub fn validity_predicate(addr: &Address) -> Self {
Expand Down
14 changes: 14 additions & 0 deletions crates/events/src/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,20 @@ impl EventAttributeEntry<'static> for Height {
}
}

/// Extend an [`Event`] with the name of the wasm code.
pub struct CodeName(pub String);

impl EventAttributeEntry<'static> for CodeName {
type Value = String;
type ValueOwned = Self::Value;

const KEY: &'static str = "code-name";

fn into_value(self) -> Self::Value {
self.0
}
}

/// Extend an [`Event`] with transaction hash information.
pub struct TxHash(pub Hash);

Expand Down
1 change: 1 addition & 0 deletions crates/migrations/src/foreign_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use namada_macros::derive_typehash;

use crate::TypeHash;

derive_typehash!(String);
derive_typehash!(Vec::<u8>);
derive_typehash!(Vec::<String>);
derive_typehash!(u64);
Expand Down
Loading
Loading