Skip to content

Commit

Permalink
change tombstone block default to 10 (#246)
Browse files Browse the repository at this point in the history
* change tombstone block default to 10

* revert changes to gitignore

* use default const, linting fix

* lint

Co-authored-by: Brian <brian.william.corbin@gmail.com>
  • Loading branch information
david1alvarez and briancorbin authored Feb 7, 2022
1 parent 05b74df commit 3b50c66
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/gift-codes/gift-code/build_gift_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description: Build a gift code in a tx_proposal that you can fund and submit to
| :--- | :--- | :--- |
| `input_txo_ids` | The 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` + 50. |
| `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. | |
| `memo` | Memo for whoever claims the gift code. | |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ description: >-
| `addresses_and_values` | An array of public addresses and value tuples | addresses are b58-encoded public addresses, value is in pmob |
| `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` + 50 |
| `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 | |
| `comment` | Comment to annotate this transaction in the transaction log | |

Expand Down
2 changes: 1 addition & 1 deletion docs/transactions/transaction/build_transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ description: >-
| `addresses_and_values` | An array of public addresses and value tuples | addresses are b58-encoded public addresses, value is in pmob |
| `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` + 50 |
| `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 | |
| `log_tx_proposal` | Whether or not to log the tx proposal on build | If not provided, is false |

Expand Down
8 changes: 4 additions & 4 deletions full-service/src/json_rpc/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,10 @@ mod e2e {
.unwrap();
assert_eq!(outlay_confirmation_numbers.len(), 1);

// Tombstone block = ledger height (12 to start + 2 new blocks + 50 default
// Tombstone block = ledger height (12 to start + 2 new blocks + 10 default
// tombstone)
let prefix_tombstone = tx_prefix.get("tombstone_block").unwrap();
assert_eq!(prefix_tombstone, "64");
assert_eq!(prefix_tombstone, "24");

let json_tx_proposal: json_rpc::tx_proposal::TxProposal =
serde_json::from_value(tx_proposal.clone()).unwrap();
Expand Down Expand Up @@ -939,10 +939,10 @@ mod e2e {
.unwrap();
assert_eq!(outlay_confirmation_numbers.len(), 1);

// Tombstone block = ledger height (12 to start + 2 new blocks + 50 default
// Tombstone block = ledger height (12 to start + 2 new blocks + 10 default
// tombstone)
let prefix_tombstone = tx_prefix.get("tombstone_block").unwrap();
assert_eq!(prefix_tombstone, "64");
assert_eq!(prefix_tombstone, "24");

// Get current balance
assert_eq!(ledger_db.num_blocks().unwrap(), 14);
Expand Down
5 changes: 3 additions & 2 deletions full-service/src/service/gift_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
account::AccountServiceError,
address::{AddressService, AddressServiceError},
transaction::{TransactionService, TransactionServiceError},
transaction_builder::DEFAULT_NEW_TX_BLOCK_ATTEMPTS,
WalletService,
},
util::b58::{
Expand Down Expand Up @@ -641,8 +642,8 @@ where
transaction_builder.set_fee(Mob::MINIMUM_FEE)?;

let num_blocks_in_ledger = self.ledger_db.num_blocks()?;
transaction_builder.set_tombstone_block(num_blocks_in_ledger + 50);

transaction_builder
.set_tombstone_block(num_blocks_in_ledger + DEFAULT_NEW_TX_BLOCK_ATTEMPTS);
let tx = transaction_builder.build(&mut rng)?;

let responder_ids = self.peer_manager.responder_ids();
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 @@ -449,7 +449,7 @@ mod tests {
let txo_pubkey =
mc_util_serial::decode(&txos[0].public_key).expect("Could not decode pubkey");
assert_eq!(receipt.public_key, txo_pubkey);
assert_eq!(receipt.tombstone_block, 63); // Ledger seeded with 12 blocks at tx construction, then one appended + 50
assert_eq!(receipt.tombstone_block, 23); // Ledger seeded with 12 blocks at tx construction, then one appended + 10
let txo: TxOut = mc_util_serial::decode(&txos[0].txo).expect("Could not decode txo");
assert_eq!(receipt.amount, txo.amount);
assert_eq!(receipt.confirmation, confirmations[0].confirmation);
Expand Down
4 changes: 2 additions & 2 deletions full-service/src/service/transaction_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use std::{convert::TryFrom, str::FromStr, sync::Arc};
/// Default number of blocks used for calculating transaction tombstone block
/// number.
// TODO support for making this configurable
pub const DEFAULT_NEW_TX_BLOCK_ATTEMPTS: u64 = 50;
pub const DEFAULT_NEW_TX_BLOCK_ATTEMPTS: u64 = 10;

/// A builder of transactions constructed from this wallet.
pub struct WalletTransactionBuilder<FPR: FogPubkeyResolver + 'static> {
Expand Down Expand Up @@ -823,7 +823,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, 63);
assert_eq!(proposal.tx.prefix.tombstone_block, 23);

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

0 comments on commit 3b50c66

Please sign in to comment.