diff --git a/Cargo.lock b/Cargo.lock index 458e574..3240594 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3606,7 +3606,7 @@ checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] name = "namada_account" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "namada_core", @@ -3618,7 +3618,7 @@ dependencies = [ [[package]] name = "namada_controller" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "namada_core", "smooth-operator", @@ -3628,7 +3628,7 @@ dependencies = [ [[package]] name = "namada_core" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "bech32 0.8.1", "borsh", @@ -3678,7 +3678,7 @@ dependencies = [ [[package]] name = "namada_ethereum_bridge" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "ethers", @@ -3706,7 +3706,7 @@ dependencies = [ [[package]] name = "namada_events" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "namada_core", @@ -3720,7 +3720,7 @@ dependencies = [ [[package]] name = "namada_gas" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "namada_core", @@ -3733,7 +3733,7 @@ dependencies = [ [[package]] name = "namada_governance" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "itertools 0.12.1", @@ -3756,7 +3756,7 @@ dependencies = [ [[package]] name = "namada_ibc" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "data-encoding", @@ -3786,7 +3786,7 @@ dependencies = [ [[package]] name = "namada_io" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "async-trait", "kdam", @@ -3799,7 +3799,7 @@ dependencies = [ [[package]] name = "namada_macros" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "data-encoding", "proc-macro2", @@ -3811,7 +3811,7 @@ dependencies = [ [[package]] name = "namada_merkle_tree" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "eyre", @@ -3826,7 +3826,7 @@ dependencies = [ [[package]] name = "namada_parameters" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "namada_core", "namada_macros", @@ -3841,7 +3841,7 @@ dependencies = [ [[package]] name = "namada_proof_of_stake" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "itertools 0.12.1", @@ -3865,7 +3865,7 @@ dependencies = [ [[package]] name = "namada_replay_protection" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "namada_core", ] @@ -3873,7 +3873,7 @@ dependencies = [ [[package]] name = "namada_sdk" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "async-trait", "bimap", @@ -3943,7 +3943,7 @@ dependencies = [ [[package]] name = "namada_shielded_token" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "async-trait", "borsh", @@ -3984,7 +3984,7 @@ dependencies = [ [[package]] name = "namada_state" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "clru", @@ -4007,7 +4007,7 @@ dependencies = [ [[package]] name = "namada_storage" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "itertools 0.12.1", @@ -4026,7 +4026,7 @@ dependencies = [ [[package]] name = "namada_systems" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "namada_core", "namada_events", @@ -4036,7 +4036,7 @@ dependencies = [ [[package]] name = "namada_token" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "namada_core", @@ -4051,7 +4051,7 @@ dependencies = [ [[package]] name = "namada_trans_token" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "konst", "namada_core", @@ -4067,7 +4067,7 @@ dependencies = [ [[package]] name = "namada_tx" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "ark-bls12-381", "bitflags 2.6.0", @@ -4096,7 +4096,7 @@ dependencies = [ [[package]] name = "namada_vm" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "clru", @@ -4118,7 +4118,7 @@ dependencies = [ [[package]] name = "namada_vote_ext" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "borsh", "namada_core", @@ -4130,7 +4130,7 @@ dependencies = [ [[package]] name = "namada_vp" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "namada_core", "namada_events", @@ -4146,7 +4146,7 @@ dependencies = [ [[package]] name = "namada_vp_env" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "derivative", "masp_primitives", @@ -4161,7 +4161,7 @@ dependencies = [ [[package]] name = "namada_wallet" version = "0.43.0" -source = "git+https://github.com/anoma/namada?rev=6c813dfc3cd3ba3757ee29923a78caa2124704e9#6c813dfc3cd3ba3757ee29923a78caa2124704e9" +source = "git+https://github.com/anoma/namada?rev=297ee2638dcebe3566286a504249bc66ad8a5e94#297ee2638dcebe3566286a504249bc66ad8a5e94" dependencies = [ "bimap", "borsh", diff --git a/Cargo.toml b/Cargo.toml index fa4c7a6..3abf407 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,9 +24,9 @@ diesel_migrations = { version = "2.2.0", default-features = false, features = [ futures = "0.3.30" itertools = "0.13.0" lazy_static = "1.4.0" -namada_core = { git = "https://github.com/anoma/namada", rev = "6c813dfc3cd3ba3757ee29923a78caa2124704e9" } -namada_sdk = { git = "https://github.com/anoma/namada", rev = "6c813dfc3cd3ba3757ee29923a78caa2124704e9" } -namada_tx = { git = "https://github.com/anoma/namada", rev = "6c813dfc3cd3ba3757ee29923a78caa2124704e9" } +namada_core = { git = "https://github.com/anoma/namada", rev = "297ee2638dcebe3566286a504249bc66ad8a5e94" } +namada_sdk = { git = "https://github.com/anoma/namada", rev = "297ee2638dcebe3566286a504249bc66ad8a5e94" } +namada_tx = { git = "https://github.com/anoma/namada", rev = "297ee2638dcebe3566286a504249bc66ad8a5e94" } orm = { path = "orm" } serde = { version = "1.0.138", features = [ "derive" ] } serde_json = "1.0" diff --git a/shared/src/block.rs b/shared/src/block.rs index 72dc853..f8c2a05 100644 --- a/shared/src/block.rs +++ b/shared/src/block.rs @@ -1,5 +1,6 @@ use std::fmt::Display; +use namada_sdk::events::extend::IndexedMaspData; use tendermint_rpc::endpoint::{block, block_results}; use crate::block_results::locate_masp_txs; @@ -27,21 +28,25 @@ impl Block { transactions: Vec::with_capacity(raw_block.block.data.len()), }; - for (block_index, masp_tx_refs) in indexed_masp_txs.locations { + for IndexedMaspData { + tx_index, + masp_refs, + } in indexed_masp_txs + { + let block_index = tx_index.0 as usize; let tx_bytes = &raw_block.block.data[block_index]; - let tx = - match Transaction::from_namada_tx(tx_bytes, &masp_tx_refs.0) { - Some(tx) => tx, - None => { - tracing::warn!( - block_hash = %block.hash, - block_index, - "Invalid Namada transaction in block" - ); - continue; - } - }; + let tx = match Transaction::from_namada_tx(tx_bytes, &masp_refs.0) { + Some(tx) => tx, + None => { + tracing::warn!( + block_hash = %block.hash, + block_index, + "Invalid Namada transaction in block" + ); + continue; + } + }; block.transactions.push((block_index, tx)); } diff --git a/shared/src/block_results.rs b/shared/src/block_results.rs index aec813e..0f70c3d 100644 --- a/shared/src/block_results.rs +++ b/shared/src/block_results.rs @@ -1,38 +1,18 @@ -use std::collections::BTreeMap; - use namada_sdk::events::extend::{ - MaspTxBatchRefs, MaspTxBlockIndex, MaspTxRefs, ReadFromEventAttributes, + IndexedMaspData, MaspDataRefs, ReadFromEventAttributes, }; use tendermint_rpc::endpoint::block_results; -pub struct IndexedMaspTxs { - /// Mapping of block indexes to valid masp tx ids. - pub locations: BTreeMap, -} - pub fn locate_masp_txs( raw_block_results: &block_results::Response, -) -> IndexedMaspTxs { - IndexedMaspTxs { - locations: raw_block_results - .end_block_events - .as_ref() - .unwrap_or(&vec![]) - .iter() - .filter_map(|event| { - let index = MaspTxBlockIndex::read_from_event_attributes( - &event.attributes, - ) - .ok()?; - - // Extract the references to the correct masp sections - let refs = MaspTxBatchRefs::read_from_event_attributes( - &event.attributes, - ) - .unwrap_or_default(); - - Some((index.0 as usize, refs)) - }) - .collect(), - } +) -> Vec { + raw_block_results + .end_block_events + .as_ref() + .unwrap_or(&vec![]) + .iter() + .filter_map(|event| { + MaspDataRefs::read_from_event_attributes(&event.attributes).ok() + }) + .collect() }