Skip to content

Commit

Permalink
Change default tombstone blocks to 10.
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-oudard committed May 4, 2021
1 parent 3bf1427 commit 1ae8db0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ curl -s localhost:9090/wallet \
| :------------- | :----------------------- | :------------------------ |
| `input_txo_ids` | Specific TXOs to use as inputs to this transaction | TXO IDs (obtain from `get_all_txos_for_account`) |
| `fee` | The fee amount to submit with this transaction | If not provided, uses `MINIMUM_FEE` = .01 MOB |
| `tombstone_block` | The block after which this transaction expires | If not provided, uses `cur_height` + 100 |
| `tombstone_block` | The block after which this transaction expires | If not provided, uses `cur_height` + 10 |
| `max_spendable_value` | The maximum amount for an input TXO selected for this transaction | |

Note, as the tx_proposal json object is quite large, you may wish to write the result to a file for use in the submit_transaction call, such as:
Expand Down
2 changes: 1 addition & 1 deletion full-service/src/json_rpc/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ mod e2e {

// Tombstone block = last ledger block at 11 + 2 new blocks + 100
let prefix_tombstone = tx_prefix.get("tombstone_block").unwrap();
assert_eq!(prefix_tombstone, "113");
assert_eq!(prefix_tombstone, "23");

// Get current balance
assert_eq!(ledger_db.num_blocks().unwrap(), 14);
Expand Down
2 changes: 1 addition & 1 deletion full-service/src/service/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ mod tests {
let txo_pubkey =
mc_util_serial::decode(&txos[0].txo.public_key).expect("Could not decode pubkey");
assert_eq!(receipt.public_key, txo_pubkey);
assert_eq!(receipt.tombstone_block, 112); // Ledger seeded up to block 11 at tx construction, then one appended + 100
assert_eq!(receipt.tombstone_block, 22); // Ledger seeded up to block 11 at tx construction, then one appended + 10
let txo: TxOut = mc_util_serial::decode(&txos[0].txo.txo).expect("Could not decode txo");
assert_eq!(receipt.amount, txo.amount);
assert_eq!(receipt.confirmation, confirmations[0].confirmation);
Expand Down
10 changes: 7 additions & 3 deletions full-service/src/service/transaction_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use mc_mobilecoind::{
UnspentTxOut,
};
use mc_transaction_core::{
constants::{MAX_TOMBSTONE_BLOCKS, MINIMUM_FEE, RING_SIZE},
constants::{MINIMUM_FEE, RING_SIZE},
onetime_keys::recover_onetime_private_key,
ring_signature::KeyImage,
tx::{TxOut, TxOutMembershipProof},
Expand All @@ -42,6 +42,10 @@ use diesel::prelude::*;
use rand::Rng;
use std::{convert::TryFrom, iter::FromIterator, str::FromStr, sync::Arc};

/// Default number of blocks in the future to set the transaction tombstone
/// block.
const DEFAULT_TOMBSTONE_BLOCKS: u64 = 10;

/// A builder of transactions constructed from this wallet.
pub struct WalletTransactionBuilder<FPR: FogPubkeyResolver + 'static> {
/// Account ID (hex-encoded) from which to construct a transaction.
Expand Down Expand Up @@ -174,7 +178,7 @@ impl<FPR: FogPubkeyResolver + 'static> WalletTransactionBuilder<FPR> {
tombstone
} else {
let last_block_index = self.ledger_db.num_blocks()? - 1;
last_block_index + MAX_TOMBSTONE_BLOCKS
last_block_index + DEFAULT_TOMBSTONE_BLOCKS
};
self.tombstone = tombstone_block;
Ok(())
Expand Down Expand Up @@ -821,7 +825,7 @@ mod tests {
// Not setting the tombstone results in tombstone = 0. This is an acceptable
// value,
let proposal = builder.build().unwrap();
assert_eq!(proposal.tx.prefix.tombstone_block, 112);
assert_eq!(proposal.tx.prefix.tombstone_block, 22);

// Build a transaction and explicitly set tombstone
let (recipient, mut builder) =
Expand Down

0 comments on commit 1ae8db0

Please sign in to comment.