Skip to content

Commit

Permalink
Merge pull request #19 from anoma/tiago/rm-fee-unshielding
Browse files Browse the repository at this point in the history
remove fee unshielding
  • Loading branch information
sug0 authored Aug 13, 2024
2 parents 17ac659 + b5f8c2f commit 51f6335
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 28 deletions.
14 changes: 4 additions & 10 deletions chain/src/entity/tx_notes_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ use orm::notes_index::NotesIndexInsertDb;
use shared::indexed_tx::IndexedTx;

#[derive(Default, Clone, Debug)]
pub struct TxNoteMap(BTreeMap<IndexedTx, (bool, usize)>);
pub struct TxNoteMap(BTreeMap<IndexedTx, usize>);

impl TxNoteMap {
pub fn insert(
&mut self,
indexed_tx: IndexedTx,
is_fee_unshielding: bool,
note_pos: usize,
) {
self.0.insert(indexed_tx, (is_fee_unshielding, note_pos));
pub fn insert(&mut self, indexed_tx: IndexedTx, note_pos: usize) {
self.0.insert(indexed_tx, note_pos);
}

pub fn is_empty(&self) -> bool {
Expand All @@ -30,9 +25,8 @@ impl TxNoteMap {
block_index,
masp_tx_index,
},
&(is_fee_unshielding, note_pos),
&note_pos,
)| NotesIndexInsertDb {
is_fee_unshielding,
block_index: block_index.0 as i32,
note_position: note_pos as i32,
block_height: block_height.0 as i32,
Expand Down
3 changes: 1 addition & 2 deletions chain/src/services/masp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ pub fn update_witness_map(
shielded: &namada_core::masp_primitives::transaction::Transaction,
) -> anyhow::Result<()> {
let mut note_pos = commitment_tree.size();
tx_notes_index
.insert(indexed_tx, false /* is_fee_unshielding */, note_pos);
tx_notes_index.insert(indexed_tx, note_pos);

for so in shielded
.sapling_bundle()
Expand Down
1 change: 0 additions & 1 deletion orm/migrations/2024-04-17-131702_notes_map/up.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
CREATE TABLE notes_index (
note_position INT PRIMARY KEY,
block_index INT NOT NULL,
is_fee_unshielding BOOLEAN NOT NULL,
block_height INT NOT NULL,
masp_tx_index INT NOT NULL
);
Expand Down
2 changes: 0 additions & 2 deletions orm/src/notes_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::schema::notes_index;
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct NotesIndexDb {
pub block_index: i32,
pub is_fee_unshielding: bool,
pub note_position: i32,
pub block_height: i32,
pub masp_tx_index: i32,
Expand All @@ -19,7 +18,6 @@ pub struct NotesIndexDb {
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct NotesIndexInsertDb {
pub block_index: i32,
pub is_fee_unshielding: bool,
pub note_position: i32,
pub block_height: i32,
pub masp_tx_index: i32,
Expand Down
1 change: 0 additions & 1 deletion orm/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ diesel::table! {
notes_index (note_position) {
note_position -> Int4,
block_index -> Int4,
is_fee_unshielding -> Bool,
block_height -> Int4,
masp_tx_index -> Int4,
}
Expand Down
1 change: 0 additions & 1 deletion shared/src/extracted_masp_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ use namada_core::masp_primitives::transaction::Transaction;

#[derive(Debug, Clone)]
pub struct ExtractedMaspTx {
pub fee_unshielding: Option<(BTreeSet<String>, Transaction)>,
pub inner_tx: Option<(BTreeSet<String>, Transaction)>,
}
2 changes: 0 additions & 2 deletions shared/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::tx_index::MaspTxIndex;
pub struct Transaction {
pub hash: Id,
pub masp_txs: Vec<(MaspTxIndex, NamadaMaspTransaction)>,
pub fee_unshielding_tx: Option<NamadaMaspTransaction>, // TODO
}

impl Transaction {
Expand Down Expand Up @@ -72,7 +71,6 @@ impl Transaction {
Some(Transaction {
masp_txs,
hash: Id::from(transaction_id),
fee_unshielding_tx: None,
})
}
}
Expand Down
3 changes: 0 additions & 3 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ components:
items:
type: object
properties:
is_fee_unshielding:
type: boolean
description: Whether this is a fee unshielding.
block_height:
type: integer
minimum: 0
Expand Down
5 changes: 1 addition & 4 deletions webserver/src/response/notes_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,25 @@ pub struct NotesIndexResponse {

#[derive(Clone, Debug, Deserialize, Serialize, Default)]
pub struct Note {
pub is_fee_unshielding: bool,
pub block_height: u64,
pub block_index: u64,
pub masp_tx_index: u64,
pub note_position: u64,
}

impl NotesIndexResponse {
pub fn new(notes_index: Vec<(bool, u64, u64, u64, u64)>) -> Self {
pub fn new(notes_index: Vec<(u64, u64, u64, u64)>) -> Self {
Self {
notes_index: notes_index
.into_iter()
.map(
|(
is_fee_unshielding,
block_height,
block_index,
masp_tx_index,
note_position,
)| {
Note {
is_fee_unshielding,
block_height,
block_index,
masp_tx_index,
Expand Down
3 changes: 1 addition & 2 deletions webserver/src/service/notes_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ impl NotesIndexService {
pub async fn get_notes_index(
&self,
from_block_height: u64,
) -> anyhow::Result<Vec<(bool, u64, u64, u64, u64)>> {
) -> anyhow::Result<Vec<(u64, u64, u64, u64)>> {
Ok(self
.notes_index_repo
.get_notes_index(from_block_height as i32)
.await?
.into_iter()
.map(|notes_index_entry| {
(
notes_index_entry.is_fee_unshielding,
notes_index_entry.block_height as u64,
notes_index_entry.block_index as u64,
notes_index_entry.masp_tx_index as u64,
Expand Down

0 comments on commit 51f6335

Please sign in to comment.