From a1ffbd55ed40bab179b2008ce74e1ba7ae7c0327 Mon Sep 17 00:00:00 2001 From: david1alvarez Date: Thu, 3 Feb 2022 16:10:14 -0800 Subject: [PATCH 1/4] change tombstone block default to 10 --- .gitignore | 4 +++- docs/gift-codes/gift-code/build_gift_code.md | 2 +- .../transaction/build_and_submit_transaction.md | 2 +- docs/transactions/transaction/build_transaction.md | 2 +- full-service/src/json_rpc/e2e.rs | 8 ++++---- full-service/src/service/gift_code.rs | 3 +-- full-service/src/service/receipt.rs | 2 +- full-service/src/service/transaction_builder.rs | 4 ++-- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 61217137f..5f11b1488 100644 --- a/.gitignore +++ b/.gitignore @@ -67,4 +67,6 @@ ingest-enclave.css *.mdb -release/ \ No newline at end of file +release/ + +sgx_linux_x64_sdk_*.bin* \ No newline at end of file diff --git a/docs/gift-codes/gift-code/build_gift_code.md b/docs/gift-codes/gift-code/build_gift_code.md index 96449c1a1..98b4fb2d0 100644 --- a/docs/gift-codes/gift-code/build_gift_code.md +++ b/docs/gift-codes/gift-code/build_gift_code.md @@ -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. | | diff --git a/docs/transactions/transaction/build_and_submit_transaction.md b/docs/transactions/transaction/build_and_submit_transaction.md index 9e7009913..ed2542161 100644 --- a/docs/transactions/transaction/build_and_submit_transaction.md +++ b/docs/transactions/transaction/build_and_submit_transaction.md @@ -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 | | diff --git a/docs/transactions/transaction/build_transaction.md b/docs/transactions/transaction/build_transaction.md index 147112153..b6be7aa54 100644 --- a/docs/transactions/transaction/build_transaction.md +++ b/docs/transactions/transaction/build_transaction.md @@ -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 | diff --git a/full-service/src/json_rpc/e2e.rs b/full-service/src/json_rpc/e2e.rs index f3af95c42..d2af8abd3 100644 --- a/full-service/src/json_rpc/e2e.rs +++ b/full-service/src/json_rpc/e2e.rs @@ -736,10 +736,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(); @@ -941,10 +941,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); diff --git a/full-service/src/service/gift_code.rs b/full-service/src/service/gift_code.rs index f270e5d78..560111b98 100644 --- a/full-service/src/service/gift_code.rs +++ b/full-service/src/service/gift_code.rs @@ -641,8 +641,7 @@ 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 + 10); let tx = transaction_builder.build(&mut rng)?; let responder_ids = self.peer_manager.responder_ids(); diff --git a/full-service/src/service/receipt.rs b/full-service/src/service/receipt.rs index c32d62d79..8525f2220 100644 --- a/full-service/src/service/receipt.rs +++ b/full-service/src/service/receipt.rs @@ -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); diff --git a/full-service/src/service/transaction_builder.rs b/full-service/src/service/transaction_builder.rs index 71ecb040c..c7ebc3cc3 100644 --- a/full-service/src/service/transaction_builder.rs +++ b/full-service/src/service/transaction_builder.rs @@ -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 { @@ -828,7 +828,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) = From 06a85aad36c1532f3a08a2c522b171801a18bc1f Mon Sep 17 00:00:00 2001 From: david1alvarez Date: Thu, 3 Feb 2022 17:24:56 -0800 Subject: [PATCH 2/4] revert changes to gitignore --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5f11b1488..61217137f 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,4 @@ ingest-enclave.css *.mdb -release/ - -sgx_linux_x64_sdk_*.bin* \ No newline at end of file +release/ \ No newline at end of file From f1ea1a830fe378cb91b375f2513aaa33d69c4dc0 Mon Sep 17 00:00:00 2001 From: david1alvarez Date: Fri, 4 Feb 2022 14:56:04 -0800 Subject: [PATCH 3/4] use default const, linting fix --- full-service/src/db/models.rs | 4 ++-- full-service/src/service/gift_code.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/full-service/src/db/models.rs b/full-service/src/db/models.rs index 6527a9633..0568c4087 100644 --- a/full-service/src/db/models.rs +++ b/full-service/src/db/models.rs @@ -121,9 +121,9 @@ pub struct NewAccount<'a> { } /// A transaction output entity that either was received to an Account in this -/// wallet, or originated from an Account in this wallet. A transaction +/// wallet, or originated from an Account in this wallet. A transaction /// output can be in one of many states with respect to multiple accounts. -/// Managing these relationships and states is one of the main goals of +/// Managing these relationships and states is one of the main goals of /// the Full-Service wallet. #[derive(Clone, Serialize, Identifiable, Queryable, PartialEq, Debug)] #[primary_key(id)] diff --git a/full-service/src/service/gift_code.rs b/full-service/src/service/gift_code.rs index 560111b98..fa076135e 100644 --- a/full-service/src/service/gift_code.rs +++ b/full-service/src/service/gift_code.rs @@ -19,6 +19,7 @@ use crate::{ account::AccountServiceError, address::{AddressService, AddressServiceError}, transaction::{TransactionService, TransactionServiceError}, + transaction_builder::{DEFAULT_NEW_TX_BLOCK_ATTEMPTS}, WalletService, }, util::b58::{ @@ -641,7 +642,7 @@ 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 + 10); + 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(); From 556aac9d6ccc35e41fef564c166ae8e412a7fb11 Mon Sep 17 00:00:00 2001 From: david1alvarez Date: Fri, 4 Feb 2022 15:29:55 -0800 Subject: [PATCH 4/4] lint --- full-service/src/service/gift_code.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/full-service/src/service/gift_code.rs b/full-service/src/service/gift_code.rs index fa076135e..fc30f576b 100644 --- a/full-service/src/service/gift_code.rs +++ b/full-service/src/service/gift_code.rs @@ -19,7 +19,7 @@ use crate::{ account::AccountServiceError, address::{AddressService, AddressServiceError}, transaction::{TransactionService, TransactionServiceError}, - transaction_builder::{DEFAULT_NEW_TX_BLOCK_ATTEMPTS}, + transaction_builder::DEFAULT_NEW_TX_BLOCK_ATTEMPTS, WalletService, }, util::b58::{ @@ -642,7 +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 + DEFAULT_NEW_TX_BLOCK_ATTEMPTS); + 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();