From b7642bcd73b62b88007bdf2d3b7c30cc7a1c88c5 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 15 Aug 2014 14:20:31 -0400 Subject: [PATCH 01/32] Add signal to wallet, emitted when a new transaction is received. --- libraries/wallet/include/bts/wallet/wallet.hpp | 2 ++ libraries/wallet/wallet.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/libraries/wallet/include/bts/wallet/wallet.hpp b/libraries/wallet/include/bts/wallet/wallet.hpp index f294a68ee..8e15326a2 100644 --- a/libraries/wallet/include/bts/wallet/wallet.hpp +++ b/libraries/wallet/include/bts/wallet/wallet.hpp @@ -46,6 +46,8 @@ namespace bts { namespace wallet { //Emitted when wallet is locked or unlocked. Argument is true if wallet is now locked; false otherwise. fc::signal wallet_lock_state_changed; + //Emitted when wallet claims a new transaction. Argument is new ledger entry. + fc::signal wallet_claimed_transaction; /** * To generate predictable test results we need an option diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 4771c5dd4..77ea1d6bc 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -550,6 +550,8 @@ namespace bts { namespace wallet { transaction_record->created_time = block_timestamp; transaction_record->received_time = received_time; } + + bool new_transaction = !transaction_record->is_confirmed; transaction_record->record_id = record_id; transaction_record->block_num = block_num; @@ -639,6 +641,9 @@ namespace bts { namespace wallet { } } store_record |= has_deposit; + + if( has_deposit ) + self->wallet_claimed_transaction(transaction_record->ledger_entries.back()); /* Reconstruct fee */ if( has_withdrawal && !has_deposit ) From c6a3c16aa297c977d3f5de61194f30e1af186e8c Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 15 Aug 2014 14:25:38 -0400 Subject: [PATCH 02/32] Bump qt_wallet --- programs/qt_wallet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/qt_wallet b/programs/qt_wallet index 2f3830ef5..fb763f360 160000 --- a/programs/qt_wallet +++ b/programs/qt_wallet @@ -1 +1 @@ -Subproject commit 2f3830ef573ced92b3e305d3b5fc2785d3ae9e0c +Subproject commit fb763f36091e7293f45719879a13f3b3a0a86c58 From 7fa32054510336aec31716586fe20774e6cb3807 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 15 Aug 2014 14:25:38 -0400 Subject: [PATCH 03/32] Bump qt_wallet --- libraries/blockchain/asset_record.cpp | 11 +- libraries/blockchain/chain_database.cpp | 6 +- .../include/bts/blockchain/asset_record.hpp | 19 +- .../include/bts/blockchain/config.hpp | 4 +- libraries/blockchain/market_engine.cpp | 178 +++++++++--------- programs/qt_wallet | 2 +- 6 files changed, 109 insertions(+), 111 deletions(-) diff --git a/libraries/blockchain/asset_record.cpp b/libraries/blockchain/asset_record.cpp index 4d9d890e3..eeccc0a36 100644 --- a/libraries/blockchain/asset_record.cpp +++ b/libraries/blockchain/asset_record.cpp @@ -29,7 +29,16 @@ bool asset_record::is_null()const /** the asset is issued by the market and not by any user */ bool asset_record::is_market_issued()const { - return issuer_account_id == market_issued_asset; + switch( issuer_account_id ) + { + case market_issued_asset: + case market_feed_issued_asset: + return true; + } +} +bool asset_record::uses_market_feed()const +{ + return issuer_account_id == market_feed_issued_asset; } asset_record asset_record::make_null()const diff --git a/libraries/blockchain/chain_database.cpp b/libraries/blockchain/chain_database.cpp index b4d3f1e61..63058eec0 100644 --- a/libraries/blockchain/chain_database.cpp +++ b/libraries/blockchain/chain_database.cpp @@ -1822,8 +1822,8 @@ namespace bts { namespace blockchain { rec.collected_fees = 0; // need to transform the min_price according the precision // 1 XTS = price USD, which means 1 satoshi_XTS = (price * usd_precision / xts_precsion) satoshi_USD - rec.minimum_xts_price = price( ( asset.min_price * asset.precision ) / BTS_BLOCKCHAIN_PRECISION, asset_id, 0 ); - rec.maximum_xts_price = price( ( asset.max_price * asset.precision ) / BTS_BLOCKCHAIN_PRECISION, asset_id, 0 ); + //rec.minimum_xts_price = price( ( asset.min_price * asset.precision ) / BTS_BLOCKCHAIN_PRECISION, asset_id, 0 ); + //rec.maximum_xts_price = price( ( asset.max_price * asset.precision ) / BTS_BLOCKCHAIN_PRECISION, asset_id, 0 ); self->store_asset_record( rec ); } @@ -2250,7 +2250,7 @@ namespace bts { namespace blockchain { { if( collateral.is_null() ) my->_collateral_db.remove( key ); - else + else my->_collateral_db.store( key, collateral ); } diff --git a/libraries/blockchain/include/bts/blockchain/asset_record.hpp b/libraries/blockchain/include/bts/blockchain/asset_record.hpp index a06e5b7c7..357178ea4 100644 --- a/libraries/blockchain/include/bts/blockchain/asset_record.hpp +++ b/libraries/blockchain/include/bts/blockchain/asset_record.hpp @@ -9,7 +9,8 @@ namespace bts { namespace blockchain { { enum { - market_issued_asset = -2 + market_issued_asset = -2, + market_feed_issued_asset = -3 }; asset_record() @@ -23,6 +24,7 @@ namespace bts { namespace blockchain { bool is_null()const; /** the asset is issued by the market and not by any user */ bool is_market_issued()const; + bool uses_market_feed()const; asset_record make_null()const; uint64_t get_precision()const; @@ -40,17 +42,6 @@ namespace bts { namespace blockchain { share_type maximum_share_supply; share_type collected_fees; feed_id_type price_feed_id; - - /** - * Setting these values to a reasonable range helps the - * market filter out garbage data that could result in - * very large ratios. For example, assume a min - * market cap for XTS of $1 Million and a maximum - * market cap of $1 Trillion that gives us a trading - * range of $0.0005 and $500 for the price. - */ - price minimum_xts_price; // in this asset - price maximum_xts_price; // in this asset }; typedef fc::optional oasset_record; @@ -70,6 +61,4 @@ FC_REFLECT( bts::blockchain::asset_record, (maximum_share_supply) (collected_fees) (price_feed_id) - (minimum_xts_price) - (maximum_xts_price) - ) + ) diff --git a/libraries/blockchain/include/bts/blockchain/config.hpp b/libraries/blockchain/include/bts/blockchain/config.hpp index 0507da779..e63925fe8 100644 --- a/libraries/blockchain/include/bts/blockchain/config.hpp +++ b/libraries/blockchain/include/bts/blockchain/config.hpp @@ -11,7 +11,7 @@ */ #define BTS_BLOCKCHAIN_VERSION (109) #define BTS_WALLET_VERSION uint32_t(101) -#define BTS_BLOCKCHAIN_DATABASE_VERSION (122) +#define BTS_BLOCKCHAIN_DATABASE_VERSION (123) /** * The address prepended to string representation of @@ -36,7 +36,7 @@ */ #define BTS_BLOCKCHAIN_NUM_DELEGATES (101) #define BTS_BLOCKCHAIN_MAX_SLATE_SIZE (BTS_BLOCKCHAIN_NUM_DELEGATES) -#define BTS_BLOCKCHAIN_MIN_FEEDS ((BTS_BLOCKCHAIN_NUM_DELEGATES/2) + 1) +#define BTS_BLOCKCHAIN_MIN_FEEDS 3 // ((BTS_BLOCKCHAIN_NUM_DELEGATES/2) + 1) #define BTS_BLOCKCHAIN_MAX_UNDO_HISTORY (BTS_BLOCKCHAIN_NUM_DELEGATES*4) diff --git a/libraries/blockchain/market_engine.cpp b/libraries/blockchain/market_engine.cpp index 7df241049..908eb5c18 100644 --- a/libraries/blockchain/market_engine.cpp +++ b/libraries/blockchain/market_engine.cpp @@ -73,78 +73,66 @@ class market_engine market_stat->avg_price_24h = *median_price; } } - /* - auto feed_max_short_bid = *median_price; - feed_max_short_bid.ratio *= 4; - feed_max_short_bid.ratio /= 3; - - auto feed_min_ask = *median_price; - feed_min_ask.ratio *= 2; - feed_min_ask.ratio /= 3; - */ - - max_short_bid = market_stat->maximum_bid();//std::min( market_stat->maximum_bid(), feed_max_short_bid ); - min_cover_ask = market_stat->minimum_ask();//std::max( market_stat->minimum_ask(), feed_min_ask ); + max_short_bid = market_stat->maximum_bid(); + min_cover_ask = market_stat->minimum_ask(); } - - //wlog( "========================== LIQUIDATE FEES ${amount} =========================\n", ("amount", quote_asset->collected_fees) ); - - get_next_bid(); // this is necessary for get_next_ask to work with collateral - while( get_next_ask() ) + else // we only liquidate fees collected for user issued assets { - if( (asset(quote_asset->collected_fees,quote_id) * _current_ask->get_price()).amount < (10000 * BTS_BLOCKCHAIN_PRECISION) ) - break; - // idump( (_current_ask) ); - market_transaction mtrx; - mtrx.bid_price = _current_ask->get_price(); - mtrx.ask_price = _current_ask->get_price(); - mtrx.bid_owner = address(); - mtrx.ask_owner = _current_ask->get_owner(); - mtrx.bid_type = bid_order; - mtrx.ask_type = _current_ask->type; - - auto ask_quote_quantity = _current_ask->get_quote_quantity(); - auto quote_quantity_usd = std::min( quote_asset->collected_fees, ask_quote_quantity.amount ); - mtrx.ask_received = asset(quote_quantity_usd,quote_id); - mtrx.ask_paid = mtrx.ask_received * mtrx.ask_price; - mtrx.bid_paid = mtrx.ask_received; - mtrx.bid_received = mtrx.ask_paid; // these get directed to accumulated fees - - // mtrx.fees_collected = mtrx.ask_paid; - - if( mtrx.ask_paid.amount == 0 ) - break; - - push_market_transaction(mtrx); - if( mtrx.ask_received.asset_id == 0 ) - trading_volume += mtrx.ask_received; - else if( mtrx.bid_received.asset_id == 0 ) - trading_volume += mtrx.bid_received; - - if( mtrx.ask_type == ask_order ) - pay_current_ask( mtrx, *base_asset ); - else - pay_current_cover( mtrx, *quote_asset ); - - market_stat->ask_depth -= mtrx.ask_paid.amount; - - quote_asset->collected_fees -= mtrx.bid_paid.amount; - _pending_state->store_asset_record(*quote_asset); - _pending_state->store_asset_record(*base_asset); - - auto prev_accumulated_fees = _pending_state->get_accumulated_fees(); - _pending_state->set_accumulated_fees( prev_accumulated_fees + mtrx.ask_paid.amount ); + // wlog( "========================== LIQUIDATE FEES ${amount} =========================\n", ("amount", quote_asset->collected_fees) ); + + get_next_bid(); // this is necessary for get_next_ask to work with collateral + while( get_next_ask() ) + { + if( (asset(quote_asset->collected_fees,quote_id) * _current_ask->get_price()).amount < (10000 * BTS_BLOCKCHAIN_PRECISION) ) + break; + // idump( (_current_ask) ); + market_transaction mtrx; + mtrx.bid_price = _current_ask->get_price(); + mtrx.ask_price = _current_ask->get_price(); + mtrx.bid_owner = address(); + mtrx.ask_owner = _current_ask->get_owner(); + mtrx.bid_type = bid_order; + mtrx.ask_type = _current_ask->type; + + auto ask_quote_quantity = _current_ask->get_quote_quantity(); + auto quote_quantity_usd = std::min( quote_asset->collected_fees, ask_quote_quantity.amount ); + mtrx.ask_received = asset(quote_quantity_usd,quote_id); + mtrx.ask_paid = mtrx.ask_received * mtrx.ask_price; + mtrx.bid_paid = mtrx.ask_received; + mtrx.bid_received = mtrx.ask_paid; // these get directed to accumulated fees + + // mtrx.fees_collected = mtrx.ask_paid; + + if( mtrx.ask_paid.amount == 0 ) + break; + + push_market_transaction(mtrx); + if( mtrx.ask_received.asset_id == 0 ) + trading_volume += mtrx.ask_received; + else if( mtrx.bid_received.asset_id == 0 ) + trading_volume += mtrx.bid_received; + + if( mtrx.ask_type == ask_order ) + pay_current_ask( mtrx, *base_asset ); + else + pay_current_cover( mtrx, *quote_asset ); + + market_stat->ask_depth -= mtrx.ask_paid.amount; + + quote_asset->collected_fees -= mtrx.bid_paid.amount; + _pending_state->store_asset_record(*quote_asset); + _pending_state->store_asset_record(*base_asset); + + auto prev_accumulated_fees = _pending_state->get_accumulated_fees(); + _pending_state->set_accumulated_fees( prev_accumulated_fees + mtrx.ask_paid.amount ); + } + // wlog( "========================== DONE LIQUIDATE FEES BALANCE: ${amount}=========================\n", ("amount", quote_asset->collected_fees) ); } - // wlog( "========================== DONE LIQUIDATE FEES BALANCE: ${amount}=========================\n", ("amount", quote_asset->collected_fees) ); } - //edump( (_current_bid) ); - //edump( (_current_ask) ); + bool order_did_execute = false; while( get_next_bid() && get_next_ask() ) { - //idump((_current_bid) ); - //idump((_current_ask) ); - auto bid_quantity_xts = _current_bid->get_quantity(); auto ask_quantity_xts = _current_ask->get_quantity(); @@ -221,6 +209,7 @@ class market_engine continue; } + order_did_execute = true; pay_current_short( mtrx, xts_paid_by_short, *quote_asset ); pay_current_cover( mtrx, *quote_asset ); @@ -236,11 +225,18 @@ class market_engine break; // the call price has not been reached mtrx.ask_price = mtrx.bid_price; - auto usd_exchanged = std::min( current_bid_balance, current_ask_balance ); + auto max_usd_purchase = asset(*_current_ask->collateral,0) * mtrx.bid_price; + auto usd_exchanged = std::min( current_bid_balance, max_usd_purchase ); mtrx.bid_paid = usd_exchanged; mtrx.ask_received = usd_exchanged; - mtrx.ask_paid = usd_exchanged * mtrx.bid_price; + + // handl rounding errors + if( usd_exchanged == max_usd_purchase ) + mtrx.ask_paid = asset(*_current_ask->collateral,0); + else + mtrx.ask_paid = usd_exchanged * mtrx.bid_price; + mtrx.bid_received = mtrx.ask_paid; /** @@ -254,22 +250,8 @@ class market_engine continue; } - /** In the event that there is insufficient collateral, the networks version of - * FDIC insurance kicks in to buy back BitUSD. This helps keep BitUSD holders - * whole at the expense of XTS holders who are debased. This should only happen - * when the highest bid is at a price that consumes all collateral. - */ - if( mtrx.ask_paid.amount > *_current_ask->collateral ) - { - market_stat->ask_depth -= *_current_ask->collateral; - auto fdic_insurance = mtrx.ask_paid.amount - *_current_ask->collateral; - *_current_ask->collateral += fdic_insurance; - base_asset->current_share_supply += fdic_insurance; - } - else - { - market_stat->ask_depth -= mtrx.ask_paid.amount; - } + market_stat->ask_depth -= mtrx.ask_paid.amount; + order_did_execute = true; pay_current_bid( mtrx, *quote_asset ); pay_current_cover( mtrx, *quote_asset ); } @@ -299,6 +281,7 @@ class market_engine } FC_ASSERT( xts_paid_by_short <= _current_bid->get_balance() ); + order_did_execute = true; pay_current_short( mtrx, xts_paid_by_short, *quote_asset ); pay_current_ask( mtrx, *base_asset ); @@ -325,6 +308,7 @@ class market_engine { mtrx.bid_paid = current_bid_balance; } + order_did_execute = true; pay_current_bid( mtrx, *quote_asset ); pay_current_ask( mtrx, *base_asset ); @@ -412,13 +396,23 @@ class market_engine market_stat->last_error.reset(); - if( _current_bid && _current_ask ) + if( _current_bid && _current_ask && order_did_execute ) { // after the market is running solid we can use this metric... // TODO: rename avg_price_24h to average_price_1h market_stat->avg_price_24h.ratio *= (BTS_BLOCKCHAIN_BLOCKS_PER_HOUR-1); - market_stat->avg_price_24h.ratio += _current_bid->get_price().ratio; - market_stat->avg_price_24h.ratio += _current_ask->get_price().ratio; + + // limit the maximum movement rate of the price. + if( _current_bid->get_price() > min_cover_ask ) + market_stat->avg_price_24h.ratio += _current_bid->get_price().ratio; + else + market_stat->avg_price_24h.ratio += min_cover_ask.ratio; + + if( _current_ask->get_price() < max_short_bid ) + market_stat->avg_price_24h.ratio += _current_ask->get_price().ratio; + else + market_stat->avg_price_24h.ratio += max_short_bid.ratio; + market_stat->avg_price_24h.ratio /= (BTS_BLOCKCHAIN_BLOCKS_PER_HOUR+1); } @@ -544,12 +538,18 @@ class market_engine _current_ask->state.balance -= mtrx.bid_paid.amount; *(_current_ask->collateral) -= mtrx.ask_paid.amount; - quote_asset.current_share_supply -= mtrx.ask_received.amount; - FC_ASSERT( _current_ask->state.balance >= 0 ); FC_ASSERT( *_current_ask->collateral >= 0, "", ("mtrx",mtrx)("_current_ask", _current_ask) ); - if( _current_ask->state.balance == 0 ) // no more USD left + quote_asset.current_share_supply -= mtrx.ask_received.amount; + if( *_current_ask->collateral == 0 ) + { + quote_asset.current_share_supply -= _current_ask->state.balance; + _current_ask->state.balance = 0; + } + + + if( _current_ask->state.balance == 0 && *_current_ask->collateral > 0 ) // no more USD left { // send collateral home to mommy & daddy wlog( " collateral balance is now 0!" ); auto ask_balance_address = withdraw_condition( diff --git a/programs/qt_wallet b/programs/qt_wallet index 2f3830ef5..fb763f360 160000 --- a/programs/qt_wallet +++ b/programs/qt_wallet @@ -1 +1 @@ -Subproject commit 2f3830ef573ced92b3e305d3b5fc2785d3ae9e0c +Subproject commit fb763f36091e7293f45719879a13f3b3a0a86c58 From a43be1629d70d7d7b6eebe13487e0fb147edda8f Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 15:14:41 -0400 Subject: [PATCH 04/32] Update submodule --- programs/web_wallet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/web_wallet b/programs/web_wallet index 03a57b952..b0665bc78 160000 --- a/programs/web_wallet +++ b/programs/web_wallet @@ -1 +1 @@ -Subproject commit 03a57b9524f73c95564b7be94f1098b87007abb5 +Subproject commit b0665bc780c1963f860503ef138e05650bdae6de From 09c357b8fe5452b0c3bbbd64eb19f687a387c383 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 15:21:15 -0400 Subject: [PATCH 05/32] Fix deposit notification --- libraries/blockchain/operations.cpp | 58 ++++++++++++++++------------- libraries/wallet/wallet.cpp | 4 +- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/libraries/blockchain/operations.cpp b/libraries/blockchain/operations.cpp index 5df18fa5a..61d070ab5 100644 --- a/libraries/blockchain/operations.cpp +++ b/libraries/blockchain/operations.cpp @@ -1,34 +1,42 @@ -#include -//#include -#include -#include -#include #include -#include #include +#include #include -#include +#include +#include +#include +#include + #include +#include namespace bts { namespace blockchain { - const operation_type_enum define_delegate_slate_operation::type = define_delegate_slate_op_type; - const operation_type_enum withdraw_operation::type = withdraw_op_type; - const operation_type_enum deposit_operation::type = deposit_op_type; - const operation_type_enum create_asset_operation::type = create_asset_op_type; - const operation_type_enum update_asset_operation::type = update_asset_op_type; - const operation_type_enum issue_asset_operation::type = issue_asset_op_type; - const operation_type_enum register_account_operation::type = register_account_op_type; - const operation_type_enum update_account_operation::type = update_account_op_type; - const operation_type_enum withdraw_pay_operation::type = withdraw_pay_op_type; - const operation_type_enum submit_proposal_operation::type = submit_proposal_op_type; - const operation_type_enum vote_proposal_operation::type = vote_proposal_op_type; - const operation_type_enum bid_operation::type = bid_op_type; - const operation_type_enum ask_operation::type = ask_op_type; - const operation_type_enum short_operation::type = short_op_type; - const operation_type_enum cover_operation::type = cover_op_type; - const operation_type_enum add_collateral_operation::type = add_collateral_op_type; - const operation_type_enum remove_collateral_operation::type = remove_collateral_op_type; - const operation_type_enum update_feed_operation::type = update_feed_op_type; + const operation_type_enum withdraw_operation::type = withdraw_op_type; + const operation_type_enum deposit_operation::type = deposit_op_type; + + const operation_type_enum register_account_operation::type = register_account_op_type; + const operation_type_enum update_account_operation::type = update_account_op_type; + const operation_type_enum withdraw_pay_operation::type = withdraw_pay_op_type; + + const operation_type_enum create_asset_operation::type = create_asset_op_type; + const operation_type_enum update_asset_operation::type = update_asset_op_type; + const operation_type_enum issue_asset_operation::type = issue_asset_op_type; + + //const operation_type_enum fire_delegate_operation::type = fire_delegate_op_type; + + const operation_type_enum submit_proposal_operation::type = submit_proposal_op_type; + const operation_type_enum vote_proposal_operation::type = vote_proposal_op_type; + + const operation_type_enum bid_operation::type = bid_op_type; + const operation_type_enum ask_operation::type = ask_op_type; + const operation_type_enum short_operation::type = short_op_type; + const operation_type_enum cover_operation::type = cover_op_type; + const operation_type_enum add_collateral_operation::type = add_collateral_op_type; + const operation_type_enum remove_collateral_operation::type = remove_collateral_op_type; + + const operation_type_enum define_delegate_slate_operation::type = define_delegate_slate_op_type; + + const operation_type_enum update_feed_operation::type = update_feed_op_type; static bool first_chain = []()->bool{ bts::blockchain::operation_factory::instance().register_operation(); diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 77ea1d6bc..2f583ae59 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -642,8 +642,8 @@ namespace bts { namespace wallet { } store_record |= has_deposit; - if( has_deposit ) - self->wallet_claimed_transaction(transaction_record->ledger_entries.back()); + if( new_transaction && has_deposit ) + self->wallet_claimed_transaction( transaction_record->ledger_entries.back() ); /* Reconstruct fee */ if( has_withdrawal && !has_deposit ) From e4052dc7bcc38066f009eb95dd00188bf4773c42 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 15:22:40 -0400 Subject: [PATCH 06/32] Fix asset_record::is_market_issued() --- libraries/blockchain/asset_record.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/blockchain/asset_record.cpp b/libraries/blockchain/asset_record.cpp index eeccc0a36..56daf2b43 100644 --- a/libraries/blockchain/asset_record.cpp +++ b/libraries/blockchain/asset_record.cpp @@ -34,8 +34,11 @@ bool asset_record::is_market_issued()const case market_issued_asset: case market_feed_issued_asset: return true; + default: + return false; } } + bool asset_record::uses_market_feed()const { return issuer_account_id == market_feed_issued_asset; From 52929b3dbd4fc8a48f5b6d261f9a2a593d5959b4 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 15:43:05 -0400 Subject: [PATCH 07/32] Fix get_info crash --- libraries/blockchain/chain_database.cpp | 43 +++++++++++-------- .../include/bts/blockchain/exceptions.hpp | 1 + 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/libraries/blockchain/chain_database.cpp b/libraries/blockchain/chain_database.cpp index 63058eec0..87142eed2 100644 --- a/libraries/blockchain/chain_database.cpp +++ b/libraries/blockchain/chain_database.cpp @@ -1213,9 +1213,12 @@ namespace bts { namespace blockchain { return optional(); } FC_CAPTURE_AND_RETHROW( (transaction) ) } - signed_block_header chain_database::get_block_header( const block_id_type& block_id )const + signed_block_header chain_database::get_block_header( const block_id_type& block_id )const { try { - return *get_block_record( block_id ); + const auto record = get_block_record( block_id ); + if( !record.valid() ) + FC_THROW_EXCEPTION( unknown_block, "Unknown block!", ("block_id",block_id) ); + return *record; } FC_CAPTURE_AND_RETHROW( (block_id) ) } signed_block_header chain_database::get_block_header( uint32_t block_num )const @@ -1252,28 +1255,29 @@ namespace bts { namespace blockchain { } return result; } - digest_block chain_database::get_block_digest( const block_id_type& block_id )const + digest_block chain_database::get_block_digest( const block_id_type& block_id )const { return my->_block_id_to_block_record_db.fetch(block_id); } - digest_block chain_database::get_block_digest( uint32_t block_num )const + + digest_block chain_database::get_block_digest( uint32_t block_num )const { auto block_id = my->_block_num_to_id_db.fetch( block_num ); return get_block_digest( block_id ); } - full_block chain_database::get_block( const block_id_type& block_id )const + full_block chain_database::get_block( const block_id_type& block_id )const { try { return my->_block_id_to_block_data_db.fetch(block_id); } FC_CAPTURE_AND_RETHROW( (block_id) ) } - full_block chain_database::get_block( uint32_t block_num )const + full_block chain_database::get_block( uint32_t block_num )const { try { auto block_id = my->_block_num_to_id_db.fetch( block_num ); return get_block( block_id ); } FC_RETHROW_EXCEPTIONS( warn, "", ("block_num",block_num) ) } - signed_block_header chain_database::get_head_block()const + signed_block_header chain_database::get_head_block()const { return my->_head_block_header; } @@ -2311,26 +2315,29 @@ namespace bts { namespace blockchain { * @return a value betwee 0 and 100 */ double chain_database::get_average_delegate_participation()const - { - int32_t head_num = get_head_block_num(); - if( head_num < 1 ) return 0; - auto now = bts::blockchain::now(); - if( head_num < BTS_BLOCKCHAIN_NUM_DELEGATES ) + { try { + const auto head_num = get_head_block_num(); + const auto now = bts::blockchain::now(); + if( head_num < 1 ) + { + return 0; + } + else if( head_num < BTS_BLOCKCHAIN_NUM_DELEGATES ) { // what percent of the maximum total blocks that could have been produced // have been produced. - auto expected_blocks = (now - get_block_header( 1 ).timestamp).to_seconds() / BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; - return 100*double(head_num) / expected_blocks; + const auto expected_blocks = (now - get_block_header( 1 ).timestamp).to_seconds() / BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; + return 100*double( head_num ) / expected_blocks; } else { // if 10*N blocks ago is longer than 10*N*INTERVAL_SEC ago then we missed blocks, calculate // in terms of percentage time rather than percentage blocks. - auto starting_time = get_block_header( head_num - BTS_BLOCKCHAIN_NUM_DELEGATES ).timestamp; - auto expected_production = (now - starting_time).to_seconds() / BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; - return 100*double(BTS_BLOCKCHAIN_NUM_DELEGATES) / expected_production; + const auto starting_time = get_block_header( head_num - BTS_BLOCKCHAIN_NUM_DELEGATES ).timestamp; + const auto expected_production = (now - starting_time).to_seconds() / BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; + return 100*double( BTS_BLOCKCHAIN_NUM_DELEGATES ) / expected_production; } - } + } FC_RETHROW_EXCEPTIONS( warn, "" ) } optional chain_database::get_market_bid( const market_index_key& key )const { try { diff --git a/libraries/blockchain/include/bts/blockchain/exceptions.hpp b/libraries/blockchain/include/bts/blockchain/exceptions.hpp index 987724e4c..be9d6f99b 100644 --- a/libraries/blockchain/include/bts/blockchain/exceptions.hpp +++ b/libraries/blockchain/include/bts/blockchain/exceptions.hpp @@ -31,6 +31,7 @@ namespace bts { namespace blockchain { FC_DECLARE_DERIVED_EXCEPTION( invalid_delegate_signee, bts::blockchain::blockchain_exception, 30022, "invalid delegate signee" ); FC_DECLARE_DERIVED_EXCEPTION( failed_checkpoint_verification, bts::blockchain::blockchain_exception, 30023, "failed checkpoint verification" ); FC_DECLARE_DERIVED_EXCEPTION( wrong_chain_id, bts::blockchain::blockchain_exception, 30024, "wrong chain id" ); + FC_DECLARE_DERIVED_EXCEPTION( unknown_block, bts::blockchain::blockchain_exception, 30025, "unknown block" ); FC_DECLARE_EXCEPTION( evaluation_error, 31000, "Evaluation Error" ); From 51b1b2aad3caad3efcc675e3290bcf81085a48b1 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 15:51:11 -0400 Subject: [PATCH 08/32] Change p2p port based on testnet version number --- libraries/blockchain/genesis.json | 2 +- libraries/blockchain/include/bts/blockchain/config.hpp | 2 +- libraries/client/include/bts/client/client.hpp | 10 ++++++---- libraries/net/include/bts/net/config.hpp | 4 ++-- libraries/net/node.cpp | 4 +++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libraries/blockchain/genesis.json b/libraries/blockchain/genesis.json index 224b54b77..626e167d1 100644 --- a/libraries/blockchain/genesis.json +++ b/libraries/blockchain/genesis.json @@ -1,5 +1,5 @@ { - "timestamp" : "20140814T010000", + "timestamp" : "20140816T000000", "market_assets": [ { "symbol": "PTS", diff --git a/libraries/blockchain/include/bts/blockchain/config.hpp b/libraries/blockchain/include/bts/blockchain/config.hpp index e63925fe8..e21233bbf 100644 --- a/libraries/blockchain/include/bts/blockchain/config.hpp +++ b/libraries/blockchain/include/bts/blockchain/config.hpp @@ -4,7 +4,7 @@ /* Set to true only for test network */ #define BTS_TEST_NETWORK (true) -#define BTS_TEST_NETWORK_VERSION (15) +#define BTS_TEST_NETWORK_VERSION (16) /** @file bts/blockchain/config.hpp * @brief Defines global constants that determine blockchain behavior diff --git a/libraries/client/include/bts/client/client.hpp b/libraries/client/include/bts/client/client.hpp index dabff569e..746d4c7b3 100644 --- a/libraries/client/include/bts/client/client.hpp +++ b/libraries/client/include/bts/client/client.hpp @@ -71,10 +71,12 @@ namespace bts { namespace client { delegate_server( fc::ip::endpoint::from_string("0.0.0.0:0") ), default_delegate_peers( vector({"107.170.30.182:9988"}) ) { - default_peers[0]+=fc::to_string( BTS_NETWORK_DEFAULT_P2P_PORT ); - default_peers[1]+=fc::to_string( BTS_NETWORK_DEFAULT_P2P_PORT+1 ); - default_peers[2]+=fc::to_string( BTS_NETWORK_DEFAULT_P2P_PORT+2 ); - logging = fc::logging_config::default_config(); + uint32_t port = BTS_NET_DEFAULT_P2P_PORT; + if( BTS_TEST_NETWORK ) port += BTS_TEST_NETWORK_VERSION; + default_peers[0] += fc::to_string( port ); + default_peers[1] += fc::to_string( port + 100 ); + default_peers[2] += fc::to_string( port + 200 ); + logging = fc::logging_config::default_config(); } rpc_server_config rpc; diff --git a/libraries/net/include/bts/net/config.hpp b/libraries/net/include/bts/net/config.hpp index 053bfae95..9ab3f4807 100644 --- a/libraries/net/include/bts/net/config.hpp +++ b/libraries/net/include/bts/net/config.hpp @@ -26,7 +26,7 @@ #define BTS_NET_PEER_DISCONNECT_TIMEOUT 20 -#define BTS_NETWORK_DEFAULT_P2P_PORT 1776 +#define BTS_NET_DEFAULT_P2P_PORT 1700 #define BTS_NET_DEFAULT_DESIRED_CONNECTIONS 8 #define BTS_NET_DELEGATE_DESIRED_CONNECTIONS 100 #define BTS_NET_DEFAULT_MAX_CONNECTIONS 200 @@ -46,4 +46,4 @@ #define BTS_NET_MAX_INVENTORY_SIZE_IN_MINUTES 2 -#define BTS_NET_MAX_BLOCKS_PER_PEER_DURING_SYNCING 20 \ No newline at end of file +#define BTS_NET_MAX_BLOCKS_PER_PEER_DURING_SYNCING 20 diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 621eab537..e52eac1f6 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -3161,7 +3161,9 @@ namespace bts { namespace net { namespace detail { { _node_configuration = detail::node_configuration(); ilog( "generating new private key for this node" ); - _node_configuration.listen_endpoint.set_port( BTS_NETWORK_DEFAULT_P2P_PORT ); + uint32_t port = BTS_NET_DEFAULT_P2P_PORT; + if( BTS_TEST_NETWORK ) port += BTS_TEST_NETWORK_VERSION; + _node_configuration.listen_endpoint.set_port( port ); _node_configuration.wait_if_endpoint_is_busy = false; _node_configuration.private_key = fc::ecc::private_key::generate(); } From c4d091a7d06642c69005e86793bb75a0354d31be Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 18:14:28 -0400 Subject: [PATCH 09/32] Delete deprecated libraries/btsx --- libraries/CMakeLists.txt | 2 - libraries/btsx/CMakeLists.txt | 11 -- libraries/btsx/btsx_db.cpp | 36 ----- libraries/btsx/btsx_transaction_validator.cpp | 88 ----------- libraries/btsx/include/bts/btsx/btsx_db.hpp | 23 --- .../bts/btsx/btsx_transaction_validator.hpp | 35 ----- libraries/btsx/include/bts/btsx/outputs.hpp | 147 ------------------ libraries/btsx/include/bts/btsx/wallet.hpp | 23 --- libraries/btsx/outputs.cpp | 10 -- libraries/btsx/wallet.cpp | 102 ------------ 10 files changed, 477 deletions(-) delete mode 100644 libraries/btsx/CMakeLists.txt delete mode 100644 libraries/btsx/btsx_db.cpp delete mode 100644 libraries/btsx/btsx_transaction_validator.cpp delete mode 100644 libraries/btsx/include/bts/btsx/btsx_db.hpp delete mode 100644 libraries/btsx/include/bts/btsx/btsx_transaction_validator.hpp delete mode 100644 libraries/btsx/include/bts/btsx/outputs.hpp delete mode 100644 libraries/btsx/include/bts/btsx/wallet.hpp delete mode 100644 libraries/btsx/outputs.cpp delete mode 100644 libraries/btsx/wallet.cpp diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 297da7112..804f9b5c3 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -13,5 +13,3 @@ add_subdirectory( keyhotee ) add_subdirectory( mail ) #add_subdirectory( kid ) add_subdirectory( bitcoin ) -#add_subdirectory( btsx ) -#add_subdirectory( dns ) diff --git a/libraries/btsx/CMakeLists.txt b/libraries/btsx/CMakeLists.txt deleted file mode 100644 index fd6a7f18a..000000000 --- a/libraries/btsx/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/db/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/blockchain/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/wallet/include" ) - -add_library( bts_x - outputs.cpp - btsx_db.cpp - btsx_transaction_validator.cpp - wallet.cpp - ) diff --git a/libraries/btsx/btsx_db.cpp b/libraries/btsx/btsx_db.cpp deleted file mode 100644 index e715c38f0..000000000 --- a/libraries/btsx/btsx_db.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -namespace bts { namespace btsx { - - namespace detail - { - class btsx_db_impl - { - public: - - }; - - } // namespace detail - - btsx_db::btsx_db() - :my( new detail::btsx_db_impl() ) - { - set_transaction_validator( std::make_shared(this) ); - } - - btsx_db::~btsx_db() - { - } - - void btsx_db::open( const fc::path& dir, bool create ) - { try { - chain_database::open( dir, create ); - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - - void btsx_db::close() - { - chain_database::close(); - } - -} } // bts::btsx diff --git a/libraries/btsx/btsx_transaction_validator.cpp b/libraries/btsx/btsx_transaction_validator.cpp deleted file mode 100644 index 1f2eeceb9..000000000 --- a/libraries/btsx/btsx_transaction_validator.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include -#include -#include - - -namespace bts { namespace btsx { - - btsx_transaction_validator::btsx_transaction_validator( btsx_db* db ) - :transaction_validator(db) - { - } - - transaction_summary btsx_transaction_validator::evaluate( const signed_transaction& trx ) - { try { - btsx_evaluation_state state(trx); - return on_evaluate( state ); - } FC_RETHROW_EXCEPTIONS( warn, "", ("trx",trx) ) } - - void btsx_transaction_validator::validate_input( const meta_trx_input& in, transaction_evaluation_state& state ) - { try { - switch( in.output.claim_func ) - { - case claim_by_bid: - validate_bid_input( in, state ); - break; - case claim_by_long: - validate_long_input( in, state ); - break; - case claim_by_cover: - validate_cover_input( in, state ); - break; - case claim_by_cover_bid: - // TODO: implement this - default: - transaction_validator::validate_input( in, state ); - } - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - - void btsx_transaction_validator::validate_output( const trx_output& out, transaction_evaluation_state& state ) - { try { - switch( out.claim_func ) - { - case claim_by_bid: - validate_bid_output( out, state ); - break; - case claim_by_long: - validate_long_output( out, state ); - break; - case claim_by_cover: - validate_cover_output( out, state ); - break; - default: - transaction_validator::validate_output( out, state ); - } - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - - void btsx_transaction_validator::validate_bid_output( const trx_output& out, transaction_evaluation_state& state ) - { try { - - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - - void btsx_transaction_validator::validate_bid_input( const meta_trx_input& in, transaction_evaluation_state& state ) - { try { - - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - - void btsx_transaction_validator::validate_long_output( const trx_output& out, transaction_evaluation_state& state ) - { try { - - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - - void btsx_transaction_validator::validate_long_input( const meta_trx_input& in, transaction_evaluation_state& state ) - { try { - - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - - void btsx_transaction_validator::validate_cover_output( const trx_output& out, transaction_evaluation_state& state ) - { try { - - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - - void btsx_transaction_validator::validate_cover_input( const meta_trx_input& in, transaction_evaluation_state& state ) - { try { - - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - -} } // bts::btsx diff --git a/libraries/btsx/include/bts/btsx/btsx_db.hpp b/libraries/btsx/include/bts/btsx/btsx_db.hpp deleted file mode 100644 index 66a393a23..000000000 --- a/libraries/btsx/include/bts/btsx/btsx_db.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include - -namespace bts { namespace btsx { - using namespace bts::blockchain; - - namespace detail { class btsx_db_impl; } - - class btsx_db : public chain_database - { - public: - btsx_db(); - ~btsx_db(); - - void open( const fc::path& dir, bool create ); - void close(); - - private: - std::unique_ptr my; - }; - - -} } // bts::btsx diff --git a/libraries/btsx/include/bts/btsx/btsx_transaction_validator.hpp b/libraries/btsx/include/bts/btsx/btsx_transaction_validator.hpp deleted file mode 100644 index 13d60157f..000000000 --- a/libraries/btsx/include/bts/btsx/btsx_transaction_validator.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include - -namespace bts { namespace btsx { - using namespace bts::blockchain; - class btsx_db; - - class btsx_evaluation_state : public transaction_evaluation_state - { - public: - btsx_evaluation_state( const signed_transaction& trx ) - :transaction_evaluation_state( trx ){} - }; - - class btsx_transaction_validator : public bts::blockchain::transaction_validator - { - public: - btsx_transaction_validator( btsx_db* db ); - - virtual transaction_summary evaluate( const signed_transaction& trx ); - - virtual void validate_input( const meta_trx_input& in, transaction_evaluation_state& state ); - virtual void validate_output( const trx_output& out, transaction_evaluation_state& state ); - - virtual void validate_bid_output( const trx_output& out, transaction_evaluation_state& state ); - virtual void validate_bid_input( const meta_trx_input& in, transaction_evaluation_state& state ); - - virtual void validate_long_output( const trx_output& out, transaction_evaluation_state& state ); - virtual void validate_long_input( const meta_trx_input& in, transaction_evaluation_state& state ); - - virtual void validate_cover_output( const trx_output& out, transaction_evaluation_state& state ); - virtual void validate_cover_input( const meta_trx_input& in, transaction_evaluation_state& state ); - }; - -} } // bts::btsx diff --git a/libraries/btsx/include/bts/btsx/outputs.hpp b/libraries/btsx/include/bts/btsx/outputs.hpp deleted file mode 100644 index 960e4a804..000000000 --- a/libraries/btsx/include/bts/btsx/outputs.hpp +++ /dev/null @@ -1,147 +0,0 @@ -#pragma once -#include -#include -#include - -namespace bts { namespace btsx { - using namespace bts::blockchain; - - enum claim_type_enum - { - claim_by_bid = 10, ///< someone makes an acceptable bid - claim_by_long = 11, ///< someone agrees to go long against a short - claim_by_cover = 12, ///< someone covers a short, freeing collateral - claim_by_cover_bid = 13, ///< someone wanting to use their collateral to place a bid - claim_by_opt_execute = 14, ///< someone executes an option - }; - - /** - * There are only two ways to claim a bid output, as part of a valid market - * transaction occuring below the ask price per unit or as part of a cancel - * operation. - */ - struct claim_by_bid_input { static const claim_type_enum type; }; - struct claim_by_long_input { static const claim_type_enum type; }; - struct claim_by_cover_input { static const claim_type_enum type; }; - struct claim_by_cover_bid_input { static const claim_type_enum type; }; - struct claim_by_opt_execute_input { static const claim_type_enum type; }; - - /** - * The output of the claim trx specifies the amount of a - * specified asset unit we are offering in exchange for - * the ask unit where the price per unit specifies the - * minimum (or maximum) exchange rate depending upon whether - * the ask_unit is the base or quote unit of the price. - **/ - struct claim_by_bid_output - { - static const claim_type_enum type; - claim_by_bid_output(){} - claim_by_bid_output( const address& pay_addr, const price& ask ) - :pay_address(pay_addr),ask_price(ask){} - - bool is_bid(asset::type out_unit)const; - bool is_ask(asset::type out_unit)const; - - address pay_address; // where to send ask_unit (or cancel sig) - price ask_price; // price base per unit - - bool operator == ( const claim_by_bid_output& other )const; - }; - - /** - * This output may be spent via signature (to cancel) or via a market action - * of a miner. - * - * Assumptions: - * trx_output.unit == bts - * trx_output.amount == amount of bts held as collateral - * ask_price == price to convert to usd - */ - struct claim_by_long_output - { - static const claim_type_enum type; - claim_by_long_output(){} - - claim_by_long_output( const address& pay_addr, const price& ask ) - :pay_address(pay_addr),ask_price(ask){} - - bool operator == ( const claim_by_long_output& other )const; - address pay_address; ///< where to send ask_unit (or cancel sig) - price ask_price; ///< price per unit (base must be bts) - }; - - /** - * Given a transaction that destroys payoff_amount of payoff_unit and is - * signed by owner, then this output can be spent. Alternatively, the - * owner could transfer the short position to a new owner. - * - * This position could also be spent as part of a margin call. - * - * Assumptions: - * trx_output.unit = bts - * trx_output.amount = total collateral held - * - * payoff_amount / unit counts as a 'negative input' to the transaction. - */ - struct claim_by_cover_output - { - static const claim_type_enum type; - - claim_by_cover_output( const asset& pay, const address& own ) - :payoff(pay), owner(own){} - - claim_by_cover_output(){} - - price get_call_price( asset collat )const; - bool operator == ( const claim_by_cover_output& other )const; - - asset payoff; - address owner; - }; - - /** - * This output may be claimed by the optionor after the first block with a timestamp - * after the expire_time or by the optionee at any point prior to the expire_time provided - * it is part of a transaction that pays strike_amount of strike_unit to the optionor. - * - * Assumptions: - * trx.output.unit = the unit that may be bought provided strike unit/amount are provided - * trx.output.amount = the amount that may be bought - * If the option is exersized, the dividends earned go to the person who claims it. - * - * Option may be rolled forward by either the optionor or optioneee, failure to - * roll the option forward results in the same 5% fee plus dividend forfeiture as - * any other output balance. - */ - struct claim_by_opt_execute_output - { - static const claim_type_enum type; - - address optionor; // who to pay for this option (also who may cancel this offer) - fc::time_point_sec expire_time; - asset strike_amount; - address optionee; // who owns the right to this option. - }; - -} } // bts::btxs - -#include -FC_REFLECT( bts::btsx::claim_by_bid_output, (pay_address)(ask_price) ) -FC_REFLECT( bts::btsx::claim_by_long_output, (pay_address)(ask_price) ) -FC_REFLECT( bts::btsx::claim_by_cover_output, (payoff)(owner) ) -FC_REFLECT( bts::btsx::claim_by_opt_execute_output, (optionor)(expire_time)(strike_amount)(optionee) ) - -FC_REFLECT( bts::btsx::claim_by_bid_input, BOOST_PP_SEQ_NIL ) -FC_REFLECT( bts::btsx::claim_by_long_input, BOOST_PP_SEQ_NIL ) -FC_REFLECT( bts::btsx::claim_by_cover_input, BOOST_PP_SEQ_NIL ) -FC_REFLECT( bts::btsx::claim_by_opt_execute_input, BOOST_PP_SEQ_NIL ) - -FC_REFLECT_ENUM( bts::btsx::claim_type_enum, - (claim_by_bid) - (claim_by_long) - (claim_by_cover) - (claim_by_cover_bid) - (claim_by_opt_execute) - ) - diff --git a/libraries/btsx/include/bts/btsx/wallet.hpp b/libraries/btsx/include/bts/btsx/wallet.hpp deleted file mode 100644 index 9782cd9a7..000000000 --- a/libraries/btsx/include/bts/btsx/wallet.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include - -namespace bts { namespace btsx { - using namespace bts::blockchain; - - namespace detail { class wallet_impl; } - - class wallet : public bts::wallet::wallet - { - public: - wallet(); - ~wallet(); - - protected: - virtual void dump_output( const trx_output& out ); - virtual bool scan_output( const trx_output& out, const output_reference& ref, const bts::wallet::output_index& idx ); - - private: - std::unique_ptr my; - }; - -} } // bts::btsx diff --git a/libraries/btsx/outputs.cpp b/libraries/btsx/outputs.cpp deleted file mode 100644 index 11e626a03..000000000 --- a/libraries/btsx/outputs.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include - -namespace bts { namespace btsx { - - const claim_type_enum claim_by_bid_output::type = claim_type_enum::claim_by_bid; - const claim_type_enum claim_by_long_output::type = claim_type_enum::claim_by_long; - const claim_type_enum claim_by_cover_output::type = claim_type_enum::claim_by_cover; - const claim_type_enum claim_by_opt_execute_output::type = claim_type_enum::claim_by_opt_execute; - -} } // bts::btsx diff --git a/libraries/btsx/wallet.cpp b/libraries/btsx/wallet.cpp deleted file mode 100644 index e6e2bc283..000000000 --- a/libraries/btsx/wallet.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include -#include -#include -#include - -namespace bts { namespace btsx { - - namespace detail - { - class wallet_impl - { - - }; - } - - wallet::wallet() - :my( new detail::wallet_impl() ) - { - } - - wallet::~wallet() - { - } - - void wallet::dump_output( const trx_output& out ) - { - switch( out.claim_func ) - { - case claim_by_bid: - { - auto claim = out.as(); - std::cerr<(); - std::cerr<(); - std::cerr<().pay_address ) ) - { - cache_output( out, out_ref, oidx ); - return true; - } - return false; - } - case claim_by_long: - { - if( is_my_address( out.as().pay_address ) ) - { - cache_output( out, out_ref, oidx ); - return true; - } - return false; - break; - } - case claim_by_cover: - { - if( is_my_address( out.as().owner ) ) - { - cache_output( out, out_ref, oidx ); - return true; - } - return false; - } - default: - FC_ASSERT( !"Invalid Claim Type" ); - break; - } - } FC_RETHROW_EXCEPTIONS( warn, "" ) } - -} } // bts::btsx From 37f66ed8237521a45a35fa80f0fc267cbf611cc1 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 18:08:42 -0400 Subject: [PATCH 10/32] Delete deprecated libraries/dns --- libraries/dns/CMakeLists.txt | 21 - libraries/dns/dns_db.cpp | 86 - libraries/dns/dns_outputs.cpp | 46 - libraries/dns/dns_transaction_validator.cpp | 14 - libraries/dns/dns_wallet.cpp | 246 -- libraries/dns/include/bts/dns/dns_db.hpp | 35 - libraries/dns/include/bts/dns/dns_outputs.hpp | 71 - .../bts/dns/dns_transaction_validator.hpp | 49 - libraries/dns/include/bts/dns/dns_wallet.hpp | 61 - libraries/dns/p2p/CMakeLists.txt | 19 - .../dns/p2p/include/bts/dns/p2p/p2p_cli.hpp | 19 - .../include/bts/dns/p2p/p2p_rpc_server.hpp | 39 - .../bts/dns/p2p/p2p_transaction_validator.hpp | 92 - libraries/dns/p2p/p2p_cli.cpp | 30 - libraries/dns/p2p/p2p_rpc_server.cpp | 147 - .../dns/p2p/p2p_transaction_validator.cpp | 283 -- tests/CMakeLists.txt | 2 - tests/dns/CMakeLists.txt | 5 - tests/dns/p2p_tests.cpp | 3032 ----------------- 19 files changed, 4297 deletions(-) delete mode 100644 libraries/dns/CMakeLists.txt delete mode 100644 libraries/dns/dns_db.cpp delete mode 100644 libraries/dns/dns_outputs.cpp delete mode 100644 libraries/dns/dns_transaction_validator.cpp delete mode 100644 libraries/dns/dns_wallet.cpp delete mode 100644 libraries/dns/include/bts/dns/dns_db.hpp delete mode 100644 libraries/dns/include/bts/dns/dns_outputs.hpp delete mode 100644 libraries/dns/include/bts/dns/dns_transaction_validator.hpp delete mode 100644 libraries/dns/include/bts/dns/dns_wallet.hpp delete mode 100644 libraries/dns/p2p/CMakeLists.txt delete mode 100644 libraries/dns/p2p/include/bts/dns/p2p/p2p_cli.hpp delete mode 100644 libraries/dns/p2p/include/bts/dns/p2p/p2p_rpc_server.hpp delete mode 100644 libraries/dns/p2p/include/bts/dns/p2p/p2p_transaction_validator.hpp delete mode 100644 libraries/dns/p2p/p2p_cli.cpp delete mode 100644 libraries/dns/p2p/p2p_rpc_server.cpp delete mode 100644 libraries/dns/p2p/p2p_transaction_validator.cpp delete mode 100644 tests/dns/CMakeLists.txt delete mode 100644 tests/dns/p2p_tests.cpp diff --git a/libraries/dns/CMakeLists.txt b/libraries/dns/CMakeLists.txt deleted file mode 100644 index 2459f87e8..000000000 --- a/libraries/dns/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/blockchain/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/cli/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/client/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/db/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/net/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/rpc/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/wallet/include" ) - -file(GLOB HEADERS "include/bts/dns/*.hpp") - -add_library( bts_dns - dns_outputs.cpp - dns_db.cpp - dns_transaction_validator.cpp - dns_wallet.cpp - ${HEADERS} ) - -target_link_libraries( bts_dns bts_blockchain bts_db bts_rpc bts_wallet fc leveldb ) - -add_subdirectory( p2p ) diff --git a/libraries/dns/dns_db.cpp b/libraries/dns/dns_db.cpp deleted file mode 100644 index 01b58b8e8..000000000 --- a/libraries/dns/dns_db.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include -#include - -namespace bts { namespace dns { - -dns_db::dns_db() -{ - output_factory::instance().register_output(); -} - -dns_db::~dns_db() -{ - _dns2ref.close(); -} - -void dns_db::open(const fc::path& dir, bool create) -{ try { - chain_database::open(dir, create); - _dns2ref.open(dir / "dns2ref", create); -} FC_RETHROW_EXCEPTIONS(warn, "Error opening DNS database in dir=${dir} with create=${create}", ("dir", dir) ("create", create)) } - -void dns_db::close() -{ - _dns2ref.close(); - chain_database::close(); -} - -void dns_db::store(const trx_block& blk, const signed_transactions& deterministic_trxs, - const block_evaluation_state_ptr& state) -{ - chain_database::store(blk, deterministic_trxs, state); - - for (auto i = 0u; i < blk.trxs.size(); i++) - { - auto tx = blk.trxs[i]; - - for (auto output : tx.outputs) - { - if (!is_dns_output(output)) - continue; - - set_dns_ref(to_dns_output(output).key, output_reference(tx.id(), i)); - } - } -} - -void dns_db::set_dns_ref(const std::string& key, const output_reference& ref) -{ - _dns2ref.store(key, ref); -} - -output_reference dns_db::get_dns_ref(const std::string& key) -{ try { - return _dns2ref.fetch(key); -} FC_RETHROW_EXCEPTIONS(warn, "Could not fetch DNS key=${key}", ("key", key)) } - -bool dns_db::has_dns_ref(const std::string& key) -{ - return _dns2ref.find(key).valid(); -} - -std::map dns_db::filter(bool (*f)(const std::string&, const output_reference&, dns_db& db)) -{ - FC_ASSERT(f != nullptr, "null filter function"); - std::map map; - - bts::db::level_map::iterator iter = _dns2ref.begin(); - if (!iter.valid()) return map; - - std::string last; - _dns2ref.last(last); - - while (true) - { - if (f(iter.key(), iter.value(), *this)) - map[iter.key()] = iter.value(); - - if (iter.key() == last) break; - iter++; - } - - return map; -} - -} } // bts::dns diff --git a/libraries/dns/dns_outputs.cpp b/libraries/dns/dns_outputs.cpp deleted file mode 100644 index e415080cb..000000000 --- a/libraries/dns/dns_outputs.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include - -namespace bts { namespace dns { - -const claim_type_enum claim_dns_input::type = claim_type_enum::claim_dns; -const claim_type_enum claim_dns_output::type = claim_type_enum::claim_dns; - -claim_dns_output::claim_dns_output() -{ -} - -claim_dns_output::claim_dns_output(const std::string& k, const last_tx_type_enum& l, const address& o, - const std::vector& v) : key(k), last_tx_type(l), owner(o), value(v) -{ -} - -fc::sha256 dns_commit_secret(claim_dns_output claim) -{ - auto as_vector = fc::raw::pack(claim); - return fc::sha256::hash(std::string(as_vector.begin(), as_vector.end())); -} - -bool is_dns_output(const trx_output& output) -{ - return output.claim_func == claim_dns; -} - -claim_dns_output to_dns_output(const trx_output& output) -{ - return output.as(); -} - -std::vector serialize_value(const fc::variant& value) -{ - return fc::raw::pack(value); -} - -fc::variant unserialize_value(const std::vector& value) -{ - return fc::raw::unpack(value); -} - -} } // bts::dns diff --git a/libraries/dns/dns_transaction_validator.cpp b/libraries/dns/dns_transaction_validator.cpp deleted file mode 100644 index 3cb330188..000000000 --- a/libraries/dns/dns_transaction_validator.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include - -namespace bts { namespace dns { - -dns_transaction_validator::dns_transaction_validator(dns_db* db) : bts::blockchain::transaction_validator(db), _dns_db(db) -{ - FC_ASSERT(db != NULL); -} - -dns_transaction_validator::~dns_transaction_validator() -{ -} - -} } // bts::dns diff --git a/libraries/dns/dns_wallet.cpp b/libraries/dns/dns_wallet.cpp deleted file mode 100644 index 13d5f51f5..000000000 --- a/libraries/dns/dns_wallet.cpp +++ /dev/null @@ -1,246 +0,0 @@ -#include -#include - -namespace bts { namespace dns { - -dns_wallet::dns_wallet(const dns_db_ptr& db) : _db(db) -{ - FC_ASSERT(db != nullptr); - _transaction_validator = std::dynamic_pointer_cast(db->get_transaction_validator()); - FC_ASSERT(_transaction_validator != nullptr); -} - -dns_wallet::~dns_wallet() -{ -} - -signed_transaction dns_wallet::bid(const std::string& key, const asset& bid_price, - const signed_transactions& pending_txs) -{ try { - FC_ASSERT(_transaction_validator->is_valid_key(key), "Invalid key"); - - /* Key should be new, for auction, or expired */ - bool new_or_expired; - output_reference prev_output_ref; - FC_ASSERT(key_is_available(key, pending_txs, new_or_expired, prev_output_ref), "Key not available"); - - signed_transaction tx; - claim_dns_output dns_output(key, claim_dns_output::last_tx_type_enum::auction, new_receive_address("Key: " + key)); - - if (new_or_expired) - { - tx.outputs.push_back(trx_output(dns_output, bid_price)); - } - else - { - tx.inputs.push_back(trx_input(prev_output_ref)); - - auto prev_output = _db->fetch_output(prev_output_ref); - FC_ASSERT(_transaction_validator->is_valid_bid_price(bid_price, prev_output.amount), "Invalid bid price"); - auto transfer_amount = _transaction_validator->get_bid_transfer_amount(bid_price, prev_output.amount); - - /* Fee is implicit from difference */ - auto prev_dns_output = to_dns_output(prev_output); - tx.outputs.push_back(trx_output(claim_by_signature_output(prev_dns_output.owner), transfer_amount)); - tx.outputs.push_back(trx_output(dns_output, bid_price)); - } - - return collect_inputs_and_sign(tx, bid_price); -} FC_RETHROW_EXCEPTIONS(warn, "bid on key ${k} with price ${p}", ("k", key) ("p", bid_price)); } - -signed_transaction dns_wallet::ask(const std::string& key, const asset& ask_price, - const signed_transactions& pending_txs) -{ try { - FC_ASSERT(_transaction_validator->is_valid_key(key), "Invalid key"); - - /* Key should exist and be owned */ - output_reference prev_output_ref; - FC_ASSERT(key_is_useable(key, pending_txs, prev_output_ref), "Key unavailable"); - - auto prev_output = _db->fetch_output(prev_output_ref); - auto prev_dns_output = to_dns_output(prev_output); - - claim_dns_output dns_output(key, claim_dns_output::last_tx_type_enum::auction, prev_dns_output.owner); - - return update(dns_output, ask_price, prev_output_ref, prev_dns_output.owner); -} FC_RETHROW_EXCEPTIONS(warn, "ask on key ${k} with price ${p}", ("k", key) ("p", ask_price)); } - -signed_transaction dns_wallet::transfer(const std::string& key, const address& recipient, - const signed_transactions& pending_txs) -{ try { - FC_ASSERT(_transaction_validator->is_valid_key(key), "Invalid key"); - - /* Key should exist and be owned */ - output_reference prev_output_ref; - FC_ASSERT(key_is_useable(key, pending_txs, prev_output_ref), "Key unavailable"); - - auto prev_output = _db->fetch_output(prev_output_ref); - auto prev_dns_output = to_dns_output(prev_output); - - claim_dns_output dns_output(key, claim_dns_output::last_tx_type_enum::update, recipient, prev_dns_output.value); - - return update(dns_output, prev_output.amount, prev_output_ref, prev_dns_output.owner); -} FC_RETHROW_EXCEPTIONS(warn, "transfer key ${k} with recipient ${r}", ("k", key) ("r", recipient)); } - -signed_transaction dns_wallet::release(const std::string& key, - const signed_transactions& pending_txs) -{ try { - FC_ASSERT(_transaction_validator->is_valid_key(key), "Invalid key"); - - /* Key should exist and be owned */ - output_reference prev_output_ref; - FC_ASSERT(key_is_useable(key, pending_txs, prev_output_ref), "Key unavailable"); - - auto prev_output = _db->fetch_output(prev_output_ref); - auto prev_dns_output = to_dns_output(prev_output); - - claim_dns_output dns_output(key, claim_dns_output::last_tx_type_enum::release, prev_dns_output.owner); - - return update(dns_output, prev_output.amount, prev_output_ref, prev_dns_output.owner); -} FC_RETHROW_EXCEPTIONS(warn, "release key ${k}", ("k", key)); } - -signed_transaction dns_wallet::set(const std::string& key, const fc::variant& value, - const signed_transactions& pending_txs) -{ try { - FC_ASSERT(_transaction_validator->is_valid_key(key), "Invalid key"); - FC_ASSERT(_transaction_validator->is_valid_value(serialize_value(value)), "Invalid value"); - - /* Key should exist and be owned */ - output_reference prev_output_ref; - FC_ASSERT(key_is_useable(key, pending_txs, prev_output_ref), "Key unavailable"); - - auto prev_output = _db->fetch_output(prev_output_ref); - auto prev_dns_output = to_dns_output(prev_output); - - claim_dns_output dns_output(key, claim_dns_output::last_tx_type_enum::update, prev_dns_output.owner, serialize_value(value)); - - return update(dns_output, prev_output.amount, prev_output_ref, prev_dns_output.owner); -} FC_RETHROW_EXCEPTIONS(warn, "set key ${k} with value ${v}", ("k", key) ("v", value)); } - -// TODO: Also check current pending_txs -fc::variant dns_wallet::lookup(const std::string& key, - const signed_transactions& pending_txs) -{ try { - FC_ASSERT(_transaction_validator->is_valid_key(key), "Invalid key"); - FC_ASSERT(_db->has_dns_ref(key), "Key does not exist"); - - auto output = _db->fetch_output(_db->get_dns_ref(key)); - - return unserialize_value(to_dns_output(output).value); -} FC_RETHROW_EXCEPTIONS(warn, "lookup key ${k}", ("k", key)); } - -// TODO: Also check current pending_txs -std::vector dns_wallet::get_active_auctions() -{ - std::vector list; - - auto f = [](const std::string& k, const output_reference& r, dns_db& db)->bool - { - auto transaction_validator = std::dynamic_pointer_cast(db.get_transaction_validator()); - FC_ASSERT(transaction_validator != nullptr); - return !transaction_validator->auction_is_closed(r); - }; - - auto map = _db->filter(f); - - for (auto iter = map.begin(); iter != map.end(); iter++) - list.push_back(_db->fetch_output(iter->second)); - - return list; -} - -std::string dns_wallet::get_input_info_string(bts::blockchain::chain_database& db, const trx_input& in) -{ - //TODO this should print info about what we're claiming the output as (expired/auction etc) - return get_output_info_string(db.fetch_output(in.output_ref)); -} - -std::string dns_wallet::get_output_info_string(const trx_output& out) -{ - if (!is_dns_output(out)) - return wallet::get_output_info_string(out); - - std::stringstream ret; - auto dns_out = to_dns_output(out); - std::string owner_str = dns_out.owner; - ret << "DNS Claim\n Key: \"" << dns_out.key << "\"\n Owner: " << - owner_str << "\n Amount: " << std::string(out.amount); - return ret.str(); -} - -bool dns_wallet::scan_output(transaction_state& state, const trx_output& out, const output_reference& ref, - const output_index& idx) -{ - if (!is_dns_output(out)) - return wallet::scan_output(state, out, ref, idx); - - auto dns_output = to_dns_output(out); - - if (is_my_address(dns_output.owner)) - { - cache_output(state.trx.vote, out, ref, idx); - return true; - } - - return false; -} - -signed_transaction dns_wallet::update(const claim_dns_output& dns_output, const asset& amount, - const output_reference& prev_output_ref, const address& prev_owner) -{ try { - signed_transaction tx; - std::unordered_set
req_sigs; - - tx.inputs.push_back(trx_input(prev_output_ref)); - tx.outputs.push_back(trx_output(dns_output, amount)); - req_sigs.insert(prev_owner); - - return collect_inputs_and_sign(tx, asset(), req_sigs); -} FC_RETHROW_EXCEPTIONS(warn, "update on key ${k} with amount ${a}", ("k", dns_output.key) ("a", amount)); } - -std::vector dns_wallet::get_keys_from_txs(const signed_transactions& txs) -{ - std::vector keys; - - for (auto &tx : txs) - { - for (auto &output : tx.outputs) - { - if (!is_dns_output(output)) - continue; - - keys.push_back(to_dns_output(output).key); - } - } - - return keys; -} - -std::vector dns_wallet::get_keys_from_unspent(const std::map& unspent_outputs) -{ - std::vector keys; - - for (auto pair : unspent_outputs) - { - if (!is_dns_output(pair.second)) - continue; - - keys.push_back(to_dns_output(pair.second).key); - } - - return keys; -} - -bool dns_wallet::key_is_available(const std::string& key, const signed_transactions& pending_txs, bool& new_or_expired, - output_reference& prev_output_ref) -{ - return _transaction_validator->key_is_available(key, get_keys_from_txs(pending_txs), new_or_expired, prev_output_ref); -} - -bool dns_wallet::key_is_useable(const std::string& key, const signed_transactions& pending_txs, output_reference& prev_output_ref) -{ - return _transaction_validator->key_is_useable(key, get_keys_from_txs(pending_txs), - get_keys_from_unspent(get_unspent_outputs()), prev_output_ref); -} - -} } // bts::dns diff --git a/libraries/dns/include/bts/dns/dns_db.hpp b/libraries/dns/include/bts/dns/dns_db.hpp deleted file mode 100644 index a346de5fd..000000000 --- a/libraries/dns/include/bts/dns/dns_db.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace bts { namespace dns { - -using namespace bts::blockchain; - -class dns_db : public bts::blockchain::chain_database -{ - public: - dns_db(); - virtual ~dns_db() override; - - virtual void open(const fc::path& dir, bool create = true) override; - virtual void close() override; - virtual void store(const trx_block& blk, const signed_transactions& deterministic_trxs, - const block_evaluation_state_ptr& state) override; - - // TODO: Add delete operation - void set_dns_ref(const std::string& key, const output_reference& ref); - output_reference get_dns_ref(const std::string& key); - bool has_dns_ref(const std::string& key); - - std::map filter(bool (*f)(const std::string&, const output_reference&, dns_db& db)); - - private: - bts::db::level_map _dns2ref; -}; - -typedef std::shared_ptr dns_db_ptr; - -} } // bts::dns diff --git a/libraries/dns/include/bts/dns/dns_outputs.hpp b/libraries/dns/include/bts/dns/dns_outputs.hpp deleted file mode 100644 index 84f12dec8..000000000 --- a/libraries/dns/include/bts/dns/dns_outputs.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once - -#include - -namespace bts { namespace dns { - -using namespace bts::blockchain; - -enum claim_type_enum -{ - // 20->29 reserved for BitShares DNS - claim_dns = 20, /* Basic claim by single address */ - commit_dns = 21, /* Precommit to first bid */ -}; - -struct claim_dns_input -{ - static const claim_type_enum type; -}; - -struct claim_dns_output -{ - static const claim_type_enum type; - - // TODO the new spec requires us to distinguish a brand new auction from an - // auction started by someone who owns the name ("sell") - enum class last_tx_type_enum : uint8_t - { - auction, - update, - release - }; - - std::string key; - last_tx_type_enum last_tx_type; - address owner; - std::vector value; - - claim_dns_output(); - claim_dns_output(const std::string& k, const last_tx_type_enum& l, const address& o, - const std::vector& v = std::vector()); -}; - -struct claim_dns_commit_input -{ - static const claim_type_enum type; -}; - -/* Secret is computed in a canonical way from the claim_dns_output */ -struct claim_dns_commit_output -{ - fc::sha256 secret; - address owner; -}; - -fc::sha256 dns_commit_secret(claim_dns_output claim); - -bool is_dns_output(const trx_output& output); -claim_dns_output to_dns_output(const trx_output& output); - -std::vector serialize_value(const fc::variant& value); -fc::variant unserialize_value(const std::vector& value); - -} } //bts::dns - -FC_REFLECT_ENUM(bts::dns::claim_type_enum, (claim_dns)); -FC_REFLECT(bts::dns::claim_dns_input, BOOST_PP_SEQ_NIL); -FC_REFLECT(bts::dns::claim_dns_output, (key)(last_tx_type)(owner)(value)); -FC_REFLECT(bts::dns::claim_dns_commit_input, BOOST_PP_SEQ_NIL); -FC_REFLECT(bts::dns::claim_dns_commit_output, (secret)(owner)); -FC_REFLECT_ENUM(bts::dns::claim_dns_output::last_tx_type_enum, (auction)(update)(release)); diff --git a/libraries/dns/include/bts/dns/dns_transaction_validator.hpp b/libraries/dns/include/bts/dns/dns_transaction_validator.hpp deleted file mode 100644 index 8c3ebe255..000000000 --- a/libraries/dns/include/bts/dns/dns_transaction_validator.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace bts { namespace dns { - -using namespace bts::blockchain; - -class dns_transaction_validator : public bts::blockchain::transaction_validator -{ - public: - dns_transaction_validator(dns_db* db); - virtual ~dns_transaction_validator() override; - - virtual block_evaluation_state_ptr create_block_state() const override = 0; - - virtual transaction_summary evaluate(const signed_transaction& tx, - const block_evaluation_state_ptr& block_state) override = 0; - - virtual void validate_input(const meta_trx_input& in, transaction_evaluation_state& state, - const block_evaluation_state_ptr& block_state) override = 0; - - virtual void validate_output(const trx_output& out, transaction_evaluation_state& state, - const block_evaluation_state_ptr& block_state) override = 0; - - virtual bool is_valid_output(const claim_dns_output& output) = 0; - virtual bool is_valid_key(const std::string& key) = 0; - virtual bool is_valid_value(const std::vector& value) = 0; - - virtual bool is_valid_bid_price(const asset& bid_price, const asset& prev_bid_price) = 0; - virtual asset get_bid_transfer_amount(const asset& bid_price, const asset& prev_bid_price) = 0; - - virtual bool auction_is_closed(const output_reference& output_ref) = 0; - virtual bool key_is_expired(const output_reference& output_ref) = 0; - - virtual bool key_is_available(const std::string& key, const std::vector& pending_keys, - bool& new_or_expired, output_reference& prev_output_ref) = 0; - virtual bool key_is_useable(const std::string& key, const std::vector& pending_keys, - const std::vector& unspent_keys, output_reference& prev_output_ref) = 0; - - protected: - dns_db* _dns_db; -}; - -typedef std::shared_ptr dns_transaction_validator_ptr; - -} } // bts::dns diff --git a/libraries/dns/include/bts/dns/dns_wallet.hpp b/libraries/dns/include/bts/dns/dns_wallet.hpp deleted file mode 100644 index a77064a94..000000000 --- a/libraries/dns/include/bts/dns/dns_wallet.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include -#include - -namespace bts { namespace dns { - -using namespace bts::blockchain; -using namespace bts::wallet; - -class dns_wallet : public bts::wallet::wallet -{ - public: - dns_wallet(const dns_db_ptr& db); - virtual ~dns_wallet() override; - - signed_transaction bid(const std::string& key, const asset& bid_price, - const signed_transactions& pending_txs); - - signed_transaction ask(const std::string& key, const asset& ask_price, - const signed_transactions& pending_txs); - - signed_transaction transfer(const std::string& key, const address& recipient, - const signed_transactions& pending_txs); - - signed_transaction release(const std::string& key, - const signed_transactions& pending_txs); - - signed_transaction set(const std::string& key, const fc::variant& value, - const signed_transactions& pending_txs); - - fc::variant lookup(const std::string& key, - const signed_transactions& pending_txs); - - std::vector get_active_auctions(); - - virtual std::string get_input_info_string(chain_database& db, const trx_input& in) override; - virtual std::string get_output_info_string(const trx_output& out) override; - - protected: - virtual bool scan_output(transaction_state& state, const trx_output& out, const output_reference& ref, - const output_index& idx) override; - - private: - dns_db_ptr _db; - dns_transaction_validator_ptr _transaction_validator; - - signed_transaction update(const claim_dns_output& dns_output, const asset& amount, - const output_reference& prev_output_ref, const address& prev_owner); - - std::vector get_keys_from_txs(const signed_transactions& txs); - std::vector get_keys_from_unspent(const std::map& unspent_outputs); - - bool key_is_available(const std::string& key, const signed_transactions& pending_txs, bool& new_or_expired, - output_reference& prev_output_ref); - bool key_is_useable(const std::string& key, const signed_transactions& pending_txs, output_reference& prev_output_ref); -}; - -typedef std::shared_ptr dns_wallet_ptr; - -} } // bts::dns diff --git a/libraries/dns/p2p/CMakeLists.txt b/libraries/dns/p2p/CMakeLists.txt deleted file mode 100644 index bc02e44a3..000000000 --- a/libraries/dns/p2p/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/blockchain/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/cli/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/client/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/db/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/dns/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/net/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/rpc/include" ) -include_directories( "${CMAKE_SOURCE_DIR}/libraries/wallet/include" ) - -file(GLOB HEADERS "include/bts/dns/p2p/*.hpp") - -add_library( bts_dns_p2p - p2p_transaction_validator.cpp - p2p_rpc_server.cpp - p2p_cli.cpp - ${HEADERS} ) - -target_link_libraries( bts_dns_p2p bts_dns bts_blockchain bts_db bts_rpc bts_wallet fc leveldb ) diff --git a/libraries/dns/p2p/include/bts/dns/p2p/p2p_cli.hpp b/libraries/dns/p2p/include/bts/dns/p2p/p2p_cli.hpp deleted file mode 100644 index a16757108..000000000 --- a/libraries/dns/p2p/include/bts/dns/p2p/p2p_cli.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include - -namespace bts { namespace dns { namespace p2p { - - using namespace client; - - class p2p_cli : public bts::cli::cli - { - public: - p2p_cli(const client_ptr& client, const p2p_rpc_server_ptr& rpc_server); - virtual ~p2p_cli() override; - - virtual void format_and_print_result(const std::string& command, const fc::variant& result) override; - }; - -} } } // bts::dns::p2p diff --git a/libraries/dns/p2p/include/bts/dns/p2p/p2p_rpc_server.hpp b/libraries/dns/p2p/include/bts/dns/p2p/p2p_rpc_server.hpp deleted file mode 100644 index ce4aabb7e..000000000 --- a/libraries/dns/p2p/include/bts/dns/p2p/p2p_rpc_server.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include -#include - -#define P2P_RPC_METHOD_LIST \ - (bid_on_domain) \ - (auction_domain) \ - (transfer_domain) \ - (update_domain_record) \ - (lookup_domain_record) \ - (name_show) \ - (list_active_domain_auctions) - -namespace bts { namespace dns { namespace p2p { - -using namespace bts::rpc; - -class p2p_rpc_server : public bts::rpc::rpc_server -{ - private: -#define DECLARE_RPC_METHOD(r, data, METHOD) fc::variant METHOD(const fc::variants&); -#define DECLARE_RPC_METHODS(METHODS) BOOST_PP_SEQ_FOR_EACH(DECLARE_RPC_METHOD, data, METHODS) - - DECLARE_RPC_METHODS(P2P_RPC_METHOD_LIST) - -#undef DECLARE_RPC_METHOD -#undef DECLARE_RPC_METHODS - - public: - p2p_rpc_server(); - virtual ~p2p_rpc_server() override; - - dns_wallet_ptr get_dns_wallet(); -}; - -typedef std::shared_ptr p2p_rpc_server_ptr; - -} } } // bts::dns::p2p diff --git a/libraries/dns/p2p/include/bts/dns/p2p/p2p_transaction_validator.hpp b/libraries/dns/p2p/include/bts/dns/p2p/p2p_transaction_validator.hpp deleted file mode 100644 index 776b0107c..000000000 --- a/libraries/dns/p2p/include/bts/dns/p2p/p2p_transaction_validator.hpp +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once - -#include - -#define DNS_DEBUG - -#define DNS_MAX_KEY_LEN 128 -#define DNS_MAX_VALUE_LEN 1024 - -#ifndef DNS_DEBUG -#define DNS_AUCTION_DURATION_BLOCKS 864 /* Blocks from last bid */ -#define DNS_EXPIRE_DURATION_BLOCKS 105120 /* Blocks from max(end of auction, last update) */ -#else -#define DNS_AUCTION_DURATION_BLOCKS 3 /* Blocks from last bid */ -#define DNS_EXPIRE_DURATION_BLOCKS 5 /* Blocks from max(end of auction, last update) */ -#endif - -#define DNS_MIN_BID_FROM(bid) ((11 * (bid)) / 10) -#define DNS_BID_FEE_RATIO(bid) ((bid) / 2) - -namespace bts { namespace dns { namespace p2p { - -using namespace bts::blockchain; - -struct p2p_transaction_evaluation_state : public bts::blockchain::transaction_evaluation_state -{ - p2p_transaction_evaluation_state(const signed_transaction& tx) - : transaction_evaluation_state(tx), seen_dns_input(false), seen_dns_output(false) {} - - claim_dns_output dns_input; - asset dns_input_amount; - - /* Only one dns input/output per tx */ - bool seen_dns_input; - bool seen_dns_output; -}; - -struct p2p_block_evaluation_state : public bts::blockchain::block_evaluation_state -{ - p2p_block_evaluation_state(dns_db* db) : bts::blockchain::block_evaluation_state(db) {} - - std::vector pending_keys; -}; - -typedef std::shared_ptr p2p_block_evaluation_state_ptr; - -class p2p_transaction_validator : public bts::dns::dns_transaction_validator -{ - public: - p2p_transaction_validator(dns_db* db); - virtual ~p2p_transaction_validator() override; - - virtual block_evaluation_state_ptr create_block_state() const override; - - virtual transaction_summary evaluate(const signed_transaction& tx, - const block_evaluation_state_ptr& block_state) override; - - virtual void validate_input(const meta_trx_input& in, transaction_evaluation_state& state, - const block_evaluation_state_ptr& block_state) override; - - virtual void validate_output(const trx_output& out, transaction_evaluation_state& state, - const block_evaluation_state_ptr& block_state) override; - - virtual bool is_valid_output(const claim_dns_output& output) override; - virtual bool is_valid_key(const std::string& key) override; - virtual bool is_valid_value(const std::vector& value) override; - - virtual bool is_valid_bid_price(const asset& bid_price, const asset& prev_bid_price) override; - virtual asset get_bid_transfer_amount(const asset& bid_price, const asset& prev_bid_price) override; - - virtual bool auction_is_closed(const output_reference& output_ref) override; - virtual bool key_is_expired(const output_reference& output_ref) override; - - virtual bool key_is_available(const std::string& key, const std::vector& pending_keys, - bool& new_or_expired, output_reference& prev_output_ref) override; - virtual bool key_is_useable(const std::string& key, const std::vector& pending_keys, - const std::vector& unspent_keys, output_reference& prev_output_ref) override; - - private: - void validate_p2p_input(const claim_dns_output& input, const asset& amount, - p2p_transaction_evaluation_state& state, - const p2p_block_evaluation_state_ptr& block_state); - - void validate_p2p_output(const claim_dns_output& output, const asset& amount, - p2p_transaction_evaluation_state& state, - const p2p_block_evaluation_state_ptr& block_state); -}; - -} } } // bts::dns::p2p - -FC_REFLECT(bts::dns::p2p::p2p_transaction_evaluation_state, (seen_dns_input)(seen_dns_output)(dns_input)(dns_input_amount)); -FC_REFLECT(bts::dns::p2p::p2p_block_evaluation_state, (pending_keys)); diff --git a/libraries/dns/p2p/p2p_cli.cpp b/libraries/dns/p2p/p2p_cli.cpp deleted file mode 100644 index 14cab9335..000000000 --- a/libraries/dns/p2p/p2p_cli.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include - -namespace bts { namespace dns { namespace p2p { - -p2p_cli::p2p_cli(const client_ptr& client, const p2p_rpc_server_ptr& rpc_server) : bts::cli::cli(client, rpc_server) -{ -} - -p2p_cli::~p2p_cli() -{ -} - -void p2p_cli::format_and_print_result(const std::string& command, const fc::variant& result) -{ - if (command == "list_active_domain_auctions") - { - auto auctions = result.as>>(); - - for (auto auction : auctions) - std::cout << "[" << auction.first.amount << "] " << auction.second.key << "\n"; - } - else - { - bts::cli::cli::format_and_print_result(command, result); - } -} - -} } } // bts::dns::p2p diff --git a/libraries/dns/p2p/p2p_rpc_server.cpp b/libraries/dns/p2p/p2p_rpc_server.cpp deleted file mode 100644 index ac85d3cfa..000000000 --- a/libraries/dns/p2p/p2p_rpc_server.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include -#include - -namespace bts { namespace dns { namespace p2p { - -static rpc_server::method_data bid_on_domain_metadata { "bid_on_domain", nullptr, -/* description: */ "Place a bid for an unowned domain name", -/* returns: */ "bool", -/* params: name type required */ - {{"domain_name", "string", true}, - {"bid_price", "asset", true}}, -/* prerequisites: */ rpc_server::json_authenticated | rpc_server::wallet_open | rpc_server::wallet_unlocked }; -fc::variant p2p_rpc_server::bid_on_domain(const fc::variants& params) -{ - auto domain_name = params[0].as_string(); - auto bid_price = params[1].as(); - - auto tx = get_dns_wallet()->bid(domain_name, bid_price, get_client()->get_pending_transactions()); - get_client()->broadcast_transaction(tx); - - return fc::variant(true); -} - -static rpc_server::method_data auction_domain_metadata { "auction_domain", nullptr, -/* description: */ "Put and owned domain name up for auction", -/* returns: */ "bool", -/* params: name type required */ - {{"domain_name", "string", true}, - {"ask_price", "asset", true}}, -/* prerequisites: */ rpc_server::json_authenticated | rpc_server::wallet_open | rpc_server::wallet_unlocked }; -fc::variant p2p_rpc_server::auction_domain(const fc::variants& params) -{ - auto domain_name = params[0].as_string(); - auto ask_price = params[1].as(); - - auto tx = get_dns_wallet()->ask(domain_name, ask_price, get_client()->get_pending_transactions()); - get_client()->broadcast_transaction(tx); - - return fc::variant(true); -} - -static rpc_server::method_data transfer_domain_metadata { "transfer_domain", nullptr, -/* description: */ "Transfer a domain name to another address", -/* returns: */ "bool", -/* params: name type required */ - {{"domain_name", "string", true}, - {"to_address", "address", true}}, -/* prerequisites: */ rpc_server::json_authenticated | rpc_server::wallet_open | rpc_server::wallet_unlocked }; -fc::variant p2p_rpc_server::transfer_domain(const fc::variants& params) -{ - auto domain_name = params[0].as_string(); - auto to_address = params[1].as
(); - - auto tx = get_dns_wallet()->transfer(domain_name, to_address, get_client()->get_pending_transactions()); - get_client()->broadcast_transaction(tx); - - return fc::variant(true); -} - -static rpc_server::method_data update_domain_record_metadata { "update_domain_record", nullptr, -/* description: */ "Update a domain name's record", -/* returns: */ "bool", -/* params: name type required */ - {{"domain_name", "string", true}, - {"record", "string", true}}, -/* prerequisites: */ rpc_server::json_authenticated | rpc_server::wallet_open | rpc_server::wallet_unlocked }; -fc::variant p2p_rpc_server::update_domain_record(const fc::variants& params) -{ - auto domain_name = params[0].as_string(); - auto record = params[1].as_string(); - - auto tx = get_dns_wallet()->set(domain_name, record, get_client()->get_pending_transactions()); - get_client()->broadcast_transaction(tx); - - return fc::variant(true); -} - -static rpc_server::method_data lookup_domain_record_metadata { "lookup_domain_record", nullptr, -/* description: */ "Lookup a domain name's record", -/* returns: */ "string", -/* params: name type required */ - {{"domain_name", "string", true}}, -/* prerequisites: */ rpc_server::json_authenticated }; -fc::variant p2p_rpc_server::lookup_domain_record(const fc::variants& params) -{ - auto domain_name = params[0].as_string(); - - return get_dns_wallet()->lookup(domain_name, get_client()->get_pending_transactions()); -} - -static rpc_server::method_data name_show_metadata { "name_show", nullptr, -/* description: */ "Lookup a domain name's record", -/* returns: */ "string", -/* params: name type required */ - {{"domain_name", "string", true}}, -/* prerequisites: */ rpc_server::json_authenticated }; -fc::variant p2p_rpc_server::name_show(const fc::variants& params) -{ - return "{\"value\":{\"ip\":\"192.168.1.1\"}}"; -} - - -static rpc_server::method_data list_active_domain_auctions_metadata { "list_active_domain_auctions", nullptr, -/* description: */ "List currently active domain name auctions", -/* returns: */ "vector>", -/* params: name type required */ - {}, -/* prerequisites: */ rpc_server::json_authenticated }; -fc::variant p2p_rpc_server::list_active_domain_auctions(const fc::variants& params) -{ - auto active_domain_auctions = get_dns_wallet()->get_active_auctions(); - - std::vector> outputs; - outputs.reserve(active_domain_auctions.size()); - - for (auto auction : active_domain_auctions) - outputs.push_back(std::make_pair(auction.amount, to_dns_output(auction))); - - return fc::variant(outputs); -} - -p2p_rpc_server::p2p_rpc_server() -{ -#define REGISTER_RPC_METHOD(r, data, METHOD) \ - do { \ - method_data data_with_functor(BOOST_PP_CAT(METHOD, _metadata)); \ - data_with_functor.method = boost::bind(&p2p_rpc_server::METHOD, this, _1); \ - register_method(data_with_functor); \ - } while (0); -#define REGISTER_RPC_METHODS(METHODS) BOOST_PP_SEQ_FOR_EACH(REGISTER_RPC_METHOD, data, METHODS) - - REGISTER_RPC_METHODS(P2P_RPC_METHOD_LIST) - -#undef REGISTER_RPC_METHODS -#undef REGISTER_RPC_METHOD -} - -p2p_rpc_server::~p2p_rpc_server() -{ -} - -dns_wallet_ptr p2p_rpc_server::get_dns_wallet() -{ - return std::dynamic_pointer_cast(get_client()->get_wallet()); -} - -} } } // bts::dns::p2p diff --git a/libraries/dns/p2p/p2p_transaction_validator.cpp b/libraries/dns/p2p/p2p_transaction_validator.cpp deleted file mode 100644 index 2a393eac2..000000000 --- a/libraries/dns/p2p/p2p_transaction_validator.cpp +++ /dev/null @@ -1,283 +0,0 @@ -#include - -namespace bts { namespace dns { namespace p2p { - -p2p_transaction_validator::p2p_transaction_validator(dns_db* db) : bts::dns::dns_transaction_validator(db) -{ -} - -p2p_transaction_validator::~p2p_transaction_validator() -{ -} - -block_evaluation_state_ptr p2p_transaction_validator::create_block_state() const -{ - return std::make_shared(_dns_db); -} - -transaction_summary p2p_transaction_validator::evaluate(const signed_transaction& tx, - const block_evaluation_state_ptr& block_state) -{ try { - p2p_transaction_evaluation_state state(tx); - - return on_evaluate(state, block_state); -} FC_RETHROW_EXCEPTIONS( warn, "" ) } - -void p2p_transaction_validator::validate_input(const meta_trx_input& in, transaction_evaluation_state& state, - const block_evaluation_state_ptr& block_state) -{ try { - if (is_dns_output(in.output)) - { - claim_dns_output dns_input = to_dns_output(in.output); - p2p_transaction_evaluation_state& dns_state = dynamic_cast(state); - const p2p_block_evaluation_state_ptr dns_block_state = std::dynamic_pointer_cast(block_state); - FC_ASSERT(dns_block_state); - - validate_p2p_input(dns_input, in.output.amount, dns_state, dns_block_state); - } - else - { - transaction_validator::validate_input(in, state, block_state); - } -} FC_RETHROW_EXCEPTIONS( warn, "" ) } - -void p2p_transaction_validator::validate_output(const trx_output& out, transaction_evaluation_state& state, - const block_evaluation_state_ptr& block_state) -{ try { - if (is_dns_output(out)) - { - claim_dns_output dns_output = to_dns_output(out); - p2p_transaction_evaluation_state& dns_state = dynamic_cast(state); - const p2p_block_evaluation_state_ptr dns_block_state = std::dynamic_pointer_cast(block_state); - FC_ASSERT(dns_block_state); - - validate_p2p_output(dns_output, out.amount, dns_state, dns_block_state); - - /* Add key to pending keys list */ - dns_block_state->pending_keys.push_back(dns_output.key); - } - else - { - transaction_validator::validate_output(out, state, block_state); - } -} FC_RETHROW_EXCEPTIONS( warn, "" ) } - -bool p2p_transaction_validator::is_valid_output(const claim_dns_output& output) -{ - return (is_valid_key(output.key) && is_valid_value(output.value)); -} - -bool p2p_transaction_validator::is_valid_key(const std::string& key) -{ - return key.size() <= DNS_MAX_KEY_LEN; -} - -bool p2p_transaction_validator::is_valid_value(const std::vector& value) -{ - return value.size() <= DNS_MAX_VALUE_LEN; -} - -bool p2p_transaction_validator::is_valid_bid_price(const asset& bid_price, const asset& prev_bid_price) -{ - if (bid_price < asset(DNS_MIN_BID_FROM(prev_bid_price.amount), prev_bid_price.unit)) - return false; - - return true; -} - -asset p2p_transaction_validator::get_bid_transfer_amount(const asset& bid_price, const asset& prev_bid_price) -{ - FC_ASSERT(is_valid_bid_price(bid_price, prev_bid_price), "Invalid bid price"); - - return bid_price - DNS_BID_FEE_RATIO(bid_price - prev_bid_price); -} - -bool p2p_transaction_validator::auction_is_closed(const output_reference& output_ref) -{ - auto output = _dns_db->fetch_output(output_ref); - FC_ASSERT(is_dns_output(output)); - - auto dns_output = to_dns_output(output); - auto age = _dns_db->get_output_age(output_ref); - - if (dns_output.last_tx_type == claim_dns_output::last_tx_type_enum::auction - && age < DNS_AUCTION_DURATION_BLOCKS) - return false; - - return true; -} - -bool p2p_transaction_validator::key_is_expired(const output_reference& output_ref) -{ - auto output = _dns_db->fetch_output(output_ref); - FC_ASSERT(is_dns_output(output)); - - if (!auction_is_closed(output_ref)) - return false; - - auto dns_output = to_dns_output(output); - auto age = _dns_db->get_output_age(output_ref); - - if (dns_output.last_tx_type == claim_dns_output::last_tx_type_enum::auction) - return age >= (DNS_AUCTION_DURATION_BLOCKS + DNS_EXPIRE_DURATION_BLOCKS); - - FC_ASSERT(dns_output.last_tx_type == claim_dns_output::last_tx_type_enum::update); - - return age >= DNS_EXPIRE_DURATION_BLOCKS; -} - -/* Check if key is available for bid: new, in auction, or expired */ -bool p2p_transaction_validator::key_is_available(const std::string& key, const std::vector& pending_keys, - bool& new_or_expired, output_reference& prev_output_ref) -{ - new_or_expired = false; - - if (std::find(pending_keys.begin(), pending_keys.end(), key) != pending_keys.end()) - return false; - - if (!_dns_db->has_dns_ref(key)) - { - new_or_expired = true; - return true; - } - - prev_output_ref = _dns_db->get_dns_ref(key); - - if (key_is_expired(prev_output_ref)) - new_or_expired = true; - - return !auction_is_closed(prev_output_ref) || new_or_expired; -} - -/* Check if key is available for value update or auction */ -bool p2p_transaction_validator::key_is_useable(const std::string& key, const std::vector& pending_keys, - const std::vector& unspent_keys, output_reference& prev_output_ref) -{ - if (std::find(pending_keys.begin(), pending_keys.end(), key) != pending_keys.end()) - return false; - - if (!_dns_db->has_dns_ref(key)) - return false; - - prev_output_ref = _dns_db->get_dns_ref(key); - - if (!auction_is_closed(prev_output_ref)) - return false; - - if (key_is_expired(prev_output_ref)) - return false; - - /* Check if spendable */ - if (std::find(unspent_keys.begin(), unspent_keys.end(), key) == unspent_keys.end()) - return false; - - return true; -} - -void p2p_transaction_validator::validate_p2p_input(const claim_dns_output& input, const asset& amount, - p2p_transaction_evaluation_state& state, - const p2p_block_evaluation_state_ptr& block_state) -{ - ilog("Validating dns claim input"); - FC_ASSERT(!state.seen_dns_input, "More than one dns claim input in tx: ${tx}", ("tx", state.trx)); - FC_ASSERT(_dns_db->has_dns_ref(input.key), "Input references invalid key"); - - auto output_ref = _dns_db->get_dns_ref(input.key); - FC_ASSERT(!key_is_expired(output_ref), "Input key is expired"); - - if (auction_is_closed(output_ref)) - FC_ASSERT(state.has_signature(input.owner), "Non-bid input not signed by owner"); - - state.add_input_asset(amount); - state.dns_input = input; - state.dns_input_amount = amount; - state.seen_dns_input = true; -} - -void p2p_transaction_validator::validate_p2p_output(const claim_dns_output& output, const asset& amount, - p2p_transaction_evaluation_state& state, - const p2p_block_evaluation_state_ptr& block_state) -{ - ilog("Validating dns claim output"); - FC_ASSERT(!state.seen_dns_output, "More than one dns claim output in tx: ${tx}", ("tx", state.trx)); - FC_ASSERT(is_valid_output(output), "Invalid DNS output"); - - state.add_output_asset(amount); - state.seen_dns_output = true; - - /* Check key status */ - bool new_or_expired; - output_reference prev_output_ref; - auto available = key_is_available(output.key, block_state->pending_keys, new_or_expired, prev_output_ref); - - /* If we haven't seen a dns input then the only valid output is a new dns auction */ - if (!state.seen_dns_input) - { - ilog("Have not seen a dns claim input on this tx"); - FC_ASSERT(new_or_expired && available, "Key already exists (and is younger than 1 block-year)"); - //TODO this new auction must reference a precommit! - // one precommit in tx input, and dns_claim output must hash to precommit.secret - // ^^ dns_commit_secret(claim) - // "value" field contains a nonce - return; - } - - /* Otherwise, the transaction must have a dns input and it must exist in the database, - * and it can't be expired */ - ilog("Seen a dns input"); - FC_ASSERT(!new_or_expired, "Key new or expired"); - FC_ASSERT(output.key == state.dns_input.key, "Bid tx refers to different input and output keys"); - - /* Bid in existing auction */ - if (!auction_is_closed(prev_output_ref)) - { - ilog("Currently in an auction"); - FC_ASSERT(available, "Key not available"); - FC_ASSERT(state.dns_input.last_tx_type == claim_dns_output::last_tx_type_enum::auction, "Input not for auction"); - - FC_ASSERT(is_valid_bid_price(amount, state.dns_input_amount), "Invalid bid amount"); - auto amount_back = get_bid_transfer_amount(amount, state.dns_input_amount); - state.add_required_fees(amount - amount_back); - - /* Check for output to past owner */ - bool found = false; - for (auto other_out : state.trx.outputs) - { - bool right_claim = other_out.claim_func == claim_by_signature; - bool enough = other_out.amount >= amount_back; - bool to_owner = right_claim - && other_out.as().owner == state.dns_input.owner; - - if (right_claim && enough && to_owner) - { - found = true; - break; - } - } - - FC_ASSERT(found, "Bid did not pay enough to previous owner"); - - return; - } - - /* Update or sale */ - ilog("Auction is over."); - FC_ASSERT(!key_is_expired(prev_output_ref), "Key is expired"); - - /* Keep output amount constant when updating dns record */ - if (output.last_tx_type == claim_dns_output::last_tx_type_enum::update) - { - FC_ASSERT(amount == state.dns_input_amount, "Output amount should not change when updating record"); - } - else - { - FC_ASSERT(output.last_tx_type == claim_dns_output::last_tx_type_enum::auction, "Invalid last_tx_type"); - } - - /* If you're the owner, do whatever you like! */ - auto prev_dns_output = to_dns_output(_dns_db->fetch_output(prev_output_ref)); - FC_ASSERT(state.has_signature(prev_dns_output.owner), "DNS tx missing required signature: ${tx}", ("tx", state.trx)); - ilog("Tx signed by owner"); -} - -} } } // bts::dns::p2p diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b90ddd511..9d1917584 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -122,5 +122,3 @@ endif (false ) add_subdirectory( bitcoin ) #add_subdirectory( client_rpc_tests ) - -#add_subdirectory( dns ) diff --git a/tests/dns/CMakeLists.txt b/tests/dns/CMakeLists.txt deleted file mode 100644 index a99af89a0..000000000 --- a/tests/dns/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -include_directories( ${CMAKE_SOURCE_DIR}/libraries/dns/include ) -include_directories( ${CMAKE_SOURCE_DIR}/libraries/dns/p2p/include ) - -add_executable( p2p_tests p2p_tests.cpp ) -target_link_libraries( p2p_tests bts_dns_p2p bts_dns bts_wallet bts_blockchain bitcoin fc ${BOOST_LIBRARIES} ${OPENSSL_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${crypto_library}) diff --git a/tests/dns/p2p_tests.cpp b/tests/dns/p2p_tests.cpp deleted file mode 100644 index c60a26192..000000000 --- a/tests/dns/p2p_tests.cpp +++ /dev/null @@ -1,3032 +0,0 @@ -#define BOOST_TEST_MODULE DNSTests - -#include -#include - -#include -#include - -#include -#include -#include - -#define DNS_TEST_NUM_WALLET_ADDRS 10 -#define DNS_TEST_BLOCK_SECS (5 * 60) - -#define DNS_TEST_KEY "DNS_TEST_KEY" -#define DNS_TEST_VALUE "DNS_TEST_VALUE" - -#define DNS_TEST_PRICE1 asset(uint64_t(1)) -#define DNS_TEST_PRICE2 asset(uint64_t(2)) - -using namespace bts::blockchain; -using namespace bts::wallet; -using namespace bts::dns; -using namespace bts::dns::p2p; - -trx_block generate_genesis_block( const std::vector
& addr ) -{ - trx_block genesis; - genesis.version = BTS_BLOCKCHAIN_VERSION; - genesis.block_num = 0; - genesis.timestamp = fc::time_point::now(); - genesis.next_fee = block_header::min_fee(); - genesis.total_shares = 0; - - signed_transaction dtrx; - dtrx.vote = 0; - // create initial delegates - for( uint32_t i = 0; i < BTS_BLOCKCHAIN_NUM_DELEGATES; ++i ) - { - auto name = "delegate-"+fc::to_string( int64_t(i+1) ); - auto key_hash = fc::sha256::hash( name.c_str(), name.size() ); - auto key = fc::ecc::private_key::regenerate(key_hash); - dtrx.outputs.push_back( trx_output( claim_name_output( name, std::string(), i+1, key.get_public_key(), key.get_public_key() ), asset() ) ); - } - genesis.trxs.push_back( dtrx ); - - // generate an initial genesis block that evenly allocates votes among all - // delegates. - for( uint32_t i = 0; i < BTS_BLOCKCHAIN_NUM_DELEGATES; ++i ) - { - signed_transaction trx; - trx.vote = i + 1; - for( uint32_t o = 0; o < 5; ++o ) - { - uint64_t amnt = 200000; - trx.outputs.push_back( trx_output( claim_by_signature_output( addr[i] ), asset( amnt ) ) ); - genesis.total_shares += amnt; - } - genesis.trxs.push_back( trx ); - } - - genesis.trx_mroot = genesis.calculate_merkle_root(signed_transactions()); - - return genesis; -} - -/* State for simulating a DNS chain. Two default wallets initialized at genesis */ -class DNSTestState -{ - public: - std::shared_ptr validator; - fc::ecc::private_key auth; - fc::path path; - - bts::dns::dns_db_ptr db; - - bts::dns::dns_wallet_ptr wallet1; - bts::dns::dns_wallet_ptr wallet2; - - std::vector
addrs1; - std::vector
addrs2; - - DNSTestState() - { - validator = std::make_shared(fc::time_point::now()); - auth = fc::ecc::private_key::generate(); - fc::temp_directory dir; - path = dir.path(); - - db = std::make_shared(); - db->set_trustee(auth.get_public_key()); - db->set_pow_validator(validator); - db->set_transaction_validator(std::make_shared(db.get())); - db->open(path / "dns_test_db", true); - - wallet1 = std::make_shared(db); - wallet2 = std::make_shared(db); - - wallet1->create_internal(path / "dns_test_wallet1.dat", "password", "password", true); - wallet2->create_internal(path / "dns_test_wallet2.dat", "password", "password", true); - - addrs1 = std::vector
(); - addrs2 = std::vector
(); - - /* Start the blockchain with random balances in new addresses */ - for (auto i = 0; i < DNS_TEST_NUM_WALLET_ADDRS; ++i) - { - addrs1.push_back(wallet1->new_receive_address()); - addrs2.push_back(wallet2->new_receive_address()); - } - - std::vector
addrs = addrs1; - addrs.insert(addrs.end(), addrs2.begin(), addrs2.end()); - auto genblk = generate_genesis_block(addrs); - genblk.sign(auth); - db->push_block(genblk); - - wallet1->scan_chain(*db); - wallet2->scan_chain(*db); - } - - ~DNSTestState() - { - db->close(); - fc::remove_all(path); - } - - /* Put these transactions into a block */ - void next_block(dns_wallet_ptr &wallet, signed_transactions &txs) - { - validator->skip_time(fc::seconds(DNS_TEST_BLOCK_SECS)); - - if (txs.size() <= 0) - txs.push_back(wallet->send_to_address(asset(1), random_addr(wallet))); - - auto next_block = wallet->generate_next_block(*db, txs); - next_block.sign(auth); - db->push_block(next_block); - - wallet1->scan_chain(*db); - wallet2->scan_chain(*db); - txs.clear(); - } - - void next_block(signed_transactions &txs) - { - next_block(wallet1, txs); - } - - /* Get a random existing address. Good for avoiding dust in certain tests. */ - address random_addr(dns_wallet_ptr &wallet) - { - if (&wallet == &wallet1) - return addrs1[rand() % (addrs1.size())]; - else if (&wallet == &wallet2) - return addrs2[rand() % (addrs2.size())]; - - throw; - } - - address random_addr() - { - return random_addr(wallet1); - } -}; - -/* - */ -BOOST_AUTO_TEST_CASE (templ) -{ - try - { - /* All unit test logic here */ - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Current Tests: - * - * validator_bid_on_new - * validator_bid_on_auction - * validator_bid_on_expired - * wallet_and_validator_bid_on_new - * wallet_and_validator_bid_on_auction - * wallet_and_validator_bid_on_expired - * - * validator_bid_on_auction_insufficient_bid_price_fail - * validator_bid_on_owned_fail - * wallet_bid_on_auction_insufficient_bid_price_fail - * wallet_bid_on_owned_fail - * - * validator_bid_invalid_key_fail - * validator_bid_insufficient_funds_fail - * validator_bid_pending_txs_conflict_fail - * wallet_bid_invalid_key_fail - * wallet_bid_insufficient_funds_fail - * wallet_bid_pending_txs_conflict_fail - * - * validator_update - * wallet_and_validator_update - * - * validator_update_in_auction_fail - * validator_update_not_owner_fail - * validator_update_expired_fail - * wallet_update_in_auction_fail - * wallet_update_not_owner_fail - * wallet_update_expired_fail - * - * validator_update_invalid_key_fail - * validator_update_invalid_value_fail - * validator_update_pending_txs_conflict_fail - * wallet_update_invalid_key_fail - * wallet_update_invalid_value_fail - * wallet_update_pending_txs_conflict_fail - * - * validator_transfer - * wallet_and_validator_transfer - * - * validator_transfer_in_auction_fail - * validator_transfer_not_owner_fail - * validator_transfer_expired_fail - * wallet_transfer_in_auction_fail - * wallet_transfer_not_owner_fail - * wallet_transfer_expired_fail - * - * validator_transfer_invalid_key_fail - * validator_transfer_pending_txs_conflict_fail - * wallet_transfer_invalid_key_fail - * wallet_transfer_pending_txs_conflict_fail - * - * validator_auction - * wallet_and_validator_auction - * - * validator_auction_in_auction_fail - * validator_auction_not_owner_fail - * validator_auction_expired_fail - * wallet_auction_in_auction_fail - * wallet_auction_not_owner_fail - * wallet_auction_expired_fail - * - * validator_auction_invalid_key_fail - * validator_auction_pending_txs_conflict_fail - * wallet_auction_invalid_key_fail - * wallet_auction_pending_txs_conflict_fail - */ - -/* Validator shall accept a bid for a key that the network has never seen before */ -BOOST_AUTO_TEST_CASE(validator_bid_on_new) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transaction tx; - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - auto bid_price = DNS_TEST_PRICE1; - std::unordered_set
req_sigs; - - tx.outputs.push_back(trx_output(dns_output, bid_price)); - - tx = state.wallet1->collect_inputs_and_sign(tx, bid_price, req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall accept a bid for a key that is being auctioned */ -BOOST_AUTO_TEST_CASE(validator_bid_on_auction) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - auto bid_price = DNS_TEST_PRICE2; - std::unordered_set
req_sigs; - - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - tx.inputs.push_back(trx_input(prev_tx_ref)); - - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto transaction_validator = std::dynamic_pointer_cast(state.db->get_transaction_validator()); - FC_ASSERT(transaction_validator != nullptr); - auto transfer_amount = transaction_validator->get_bid_transfer_amount(bid_price, prev_output.amount); - - auto prev_dns_output = to_dns_output(prev_output); - tx.outputs.push_back(trx_output(claim_by_signature_output(prev_dns_output.owner), transfer_amount)); - tx.outputs.push_back(trx_output(dns_output, bid_price)); - - tx = state.wallet2->collect_inputs_and_sign(tx, bid_price, req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall accept a bid for a key that is expired */ -BOOST_AUTO_TEST_CASE(validator_bid_on_expired) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Let dns expire */ - for (auto i = 0; i < DNS_EXPIRE_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - auto bid_price = DNS_TEST_PRICE1; - std::unordered_set
req_sigs; - - tx.outputs.push_back(trx_output(dns_output, bid_price)); - - tx = state.wallet2->collect_inputs_and_sign(tx, bid_price, req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet can create a bid for a key that the network has never seen before */ -BOOST_AUTO_TEST_CASE(wallet_and_validator_bid_on_new) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Bid on dns */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet can create a bid for a key that is being auctioned */ -BOOST_AUTO_TEST_CASE(wallet_and_validator_bid_on_auction) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Bid on same dns from second wallet */ - tx = state.wallet2->bid(DNS_TEST_KEY, DNS_TEST_PRICE2, txs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet can create a bid for a key that is expired */ -BOOST_AUTO_TEST_CASE(wallet_and_validator_bid_on_expired) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Let dns expire */ - for (auto i = 0; i < DNS_EXPIRE_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Bid on same dns from second wallet */ - tx = state.wallet2->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a bid for a key that is being auctioned without exceeding the previous bid by a - * sufficient amount */ -BOOST_AUTO_TEST_CASE (validator_bid_on_auction_insufficient_bid_price_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE2, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - auto bid_price = DNS_TEST_PRICE1; /* Lower bid */ - std::unordered_set
req_sigs; - - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - tx.inputs.push_back(trx_input(prev_tx_ref)); - - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto transfer_amount = 0u; - - auto prev_dns_output = to_dns_output(prev_output); - tx.outputs.push_back(trx_output(claim_by_signature_output(prev_dns_output.owner), transfer_amount)); - tx.outputs.push_back(trx_output(dns_output, bid_price)); - - tx = state.wallet2->collect_inputs_and_sign(tx, bid_price, req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a bid for a key that has already been auctioned and is not expired */ -BOOST_AUTO_TEST_CASE(validator_bid_on_owned_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - auto bid_price = DNS_TEST_PRICE2; - std::unordered_set
req_sigs; - - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - tx.inputs.push_back(trx_input(prev_tx_ref)); - - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto transaction_validator = std::dynamic_pointer_cast(state.db->get_transaction_validator()); - FC_ASSERT(transaction_validator != nullptr); - auto transfer_amount = transaction_validator->get_bid_transfer_amount(bid_price, prev_output.amount); - - auto prev_dns_output = to_dns_output(prev_output); - tx.outputs.push_back(trx_output(claim_by_signature_output(prev_dns_output.owner), transfer_amount)); - tx.outputs.push_back(trx_output(dns_output, bid_price)); - - tx = state.wallet2->collect_inputs_and_sign(tx, bid_price, req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a bid for a key that is being auctioned without exceeding the previous bid by a - * sufficient amount */ -BOOST_AUTO_TEST_CASE (wallet_bid_on_auction_insufficient_bid_price_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE2, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Try to bid on key from second wallet with insufficient bid price */ - auto no_exception = false; - try - { - tx = state.wallet2->bid(DNS_TEST_KEY, DNS_TEST_PRICE1 , txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a bid for a key that has already been auctioned and is not expired */ -BOOST_AUTO_TEST_CASE(wallet_bid_on_owned_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Try to bid on same dns from second wallet */ - auto no_exception = false; - try - { - tx = state.wallet2->bid(DNS_TEST_KEY, DNS_TEST_PRICE2, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a bid for a key that has an invalid length */ -BOOST_AUTO_TEST_CASE(validator_bid_invalid_key_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Build invalid key */ - std::string key = ""; - for (int i = 0; i < DNS_MAX_KEY_LEN + 1; i++) - key.append("A"); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = key; /* Invalid key */ - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - auto bid_price = DNS_TEST_PRICE1; - std::unordered_set
req_sigs; - - tx.outputs.push_back(trx_output(dns_output, bid_price)); - - tx = state.wallet1->collect_inputs_and_sign(tx, bid_price, req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a bid for a key with a price exceeding available inputs */ -BOOST_AUTO_TEST_CASE (validator_bid_insufficient_funds_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transaction tx; - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - auto bid_price = DNS_TEST_PRICE1; - std::unordered_set
req_sigs; - - tx.outputs.push_back(trx_output(dns_output, state.wallet1->get_balance(0))); /* Invalid amount */ - - tx = state.wallet1->collect_inputs_and_sign(tx, bid_price, req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a bid for a key when there already exists a transaction for the same key in the - * current transaction pool */ -BOOST_AUTO_TEST_CASE (validator_bid_pending_txs_conflict_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - validator->evaluate(tx, block_state); - - /* Different dns bid */ - tx = state.wallet2->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a bid for a key that has an invalid length */ -BOOST_AUTO_TEST_CASE(wallet_bid_invalid_key_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Build invalid key */ - std::string key = ""; - for (int i = 0; i < DNS_MAX_KEY_LEN + 1; i++) - key.append("A"); - - /* Try to bid on key */ - auto no_exception = false; - try - { - tx = state.wallet1->bid(key, DNS_TEST_PRICE1, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a bid for a key with a price exceeding available inputs */ -BOOST_AUTO_TEST_CASE (wallet_bid_insufficient_funds_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Try to bid on key with an excessive bid price */ - auto no_exception = false; - try - { - tx = state.wallet1->bid(DNS_TEST_KEY, state.wallet1->get_balance(0), txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a bid for a key when there already exists a transaction for the same key in the - * current transaction pool */ -BOOST_AUTO_TEST_CASE (wallet_bid_pending_txs_conflict_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - - /* Try to bid on same dns from second wallet */ - auto no_exception = false; - try - { - tx = state.wallet2->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall accept an update for a key that has been acquired and is not expired */ -BOOST_AUTO_TEST_CASE(validator_update) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = serialize_value(DNS_TEST_VALUE); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet can create an update for a key that has been acquired and is not expired */ -BOOST_AUTO_TEST_CASE(wallet_and_validator_update) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Update dns record */ - tx = state.wallet1->set(DNS_TEST_KEY, DNS_TEST_VALUE, txs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an update for a key that is being auctioned */ -BOOST_AUTO_TEST_CASE(validator_update_in_auction_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = serialize_value(DNS_TEST_VALUE); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an update for a key that has been acquired by another owner */ -BOOST_AUTO_TEST_CASE(validator_update_not_owner_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = serialize_value(DNS_TEST_VALUE); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(state.random_addr(state.wallet2)); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet2->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an update for a key that has expired */ -BOOST_AUTO_TEST_CASE(validator_update_expired_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Let dns expire */ - for (auto i = 0; i < DNS_EXPIRE_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = serialize_value(DNS_TEST_VALUE); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an update for a key that is being auctioned */ -BOOST_AUTO_TEST_CASE(wallet_update_in_auction_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Try to update dns record */ - auto no_exception = false; - try - { - tx = state.wallet1->set(DNS_TEST_KEY, DNS_TEST_VALUE, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an update for a key that has been acquired by another owner */ -BOOST_AUTO_TEST_CASE(wallet_update_not_owner_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Try to update dns record from second wallet */ - auto no_exception = false; - try - { - tx = state.wallet2->set(DNS_TEST_KEY, DNS_TEST_VALUE, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an update for a key that has expired */ -BOOST_AUTO_TEST_CASE(wallet_update_expired_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Let dns expire */ - for (auto i = 0; i < DNS_EXPIRE_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Try to update dns record */ - auto no_exception = false; - try - { - tx = state.wallet1->set(DNS_TEST_KEY, DNS_TEST_VALUE, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an update for a key of invalid length */ -BOOST_AUTO_TEST_CASE (validator_update_invalid_key_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Build invalid key */ - std::string key = ""; - for (int i = 0; i < DNS_MAX_KEY_LEN + 1; i++) - key.append("A"); - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = key; - dns_output.value = serialize_value(DNS_TEST_VALUE); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an update for a key with a value of invalid length */ -BOOST_AUTO_TEST_CASE(validator_update_invalid_value_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Build invalid value */ - std::string str = ""; - for (auto i = 0; i < DNS_MAX_VALUE_LEN + 1; i++) - str.append("A"); - fc::variant value = str; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = serialize_value(value); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an update for a key when there already exists a transaction for the same key in the - * current transaction pool */ -BOOST_AUTO_TEST_CASE (validator_update_pending_txs_conflict_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Auction dns */ - tx = state.wallet1->ask(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - validator->evaluate(tx, block_state); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = serialize_value(DNS_TEST_VALUE); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an update for a key of invalid length */ -BOOST_AUTO_TEST_CASE (wallet_update_invalid_key_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Build invalid key */ - std::string key = ""; - for (int i = 0; i < DNS_MAX_KEY_LEN + 1; i++) - key.append("A"); - - /* Try to update dns record */ - auto no_exception = false; - try - { - tx = state.wallet1->set(key, DNS_TEST_VALUE, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an update for a key with a value of invalid length */ -BOOST_AUTO_TEST_CASE(wallet_update_invalid_value_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Build invalid value */ - std::string str = ""; - for (auto i = 0; i < DNS_MAX_VALUE_LEN + 1; i++) - str.append("A"); - fc::variant value = str; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Try to update dns record with value */ - auto no_exception = false; - try - { - tx = state.wallet1->set(DNS_TEST_KEY, value, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an update for a key when there already exists a transaction for the same key in the - * current transaction pool */ -BOOST_AUTO_TEST_CASE (wallet_update_pending_txs_conflict_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Auction dns */ - tx = state.wallet1->ask(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - - /* Try to update dns record */ - auto no_exception = false; - try - { - tx = state.wallet1->set(DNS_TEST_KEY, DNS_TEST_VALUE, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall accept a transfer for a key that has been acquired and is not expired */ -BOOST_AUTO_TEST_CASE(validator_transfer) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet can create a transfer for a key that has been acquired and is not expired */ -BOOST_AUTO_TEST_CASE(wallet_and_validator_transfer) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Update dns record */ - tx = state.wallet1->transfer(DNS_TEST_KEY, state.random_addr(state.wallet2), txs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a transfer for a key that is being auctioned */ -BOOST_AUTO_TEST_CASE(validator_transfer_in_auction_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a transfer for a key that has been acquired by another owner */ -BOOST_AUTO_TEST_CASE(validator_transfer_not_owner_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(state.random_addr(state.wallet2)); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet2->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a transfer for a key that has expired */ -BOOST_AUTO_TEST_CASE(validator_transfer_expired_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Let dns expire */ - for (auto i = 0; i < DNS_EXPIRE_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a transfer for a key that is being auctioned */ -BOOST_AUTO_TEST_CASE(wallet_transfer_in_auction_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Try to update dns record */ - auto no_exception = false; - try - { - tx = state.wallet1->transfer(DNS_TEST_KEY, state.random_addr(state.wallet2), txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a transfer for a key that has been acquired by another owner */ -BOOST_AUTO_TEST_CASE(wallet_transfer_not_owner_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Try to update dns record from second wallet */ - auto no_exception = false; - try - { - tx = state.wallet2->transfer(DNS_TEST_KEY, state.random_addr(state.wallet2), txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a transfer for a key that has expired */ -BOOST_AUTO_TEST_CASE(wallet_transfer_expired_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Let dns expire */ - for (auto i = 0; i < DNS_EXPIRE_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Try to update dns record */ - auto no_exception = false; - try - { - tx = state.wallet1->transfer(DNS_TEST_KEY, state.random_addr(state.wallet2), txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a transfer for a key of invalid length */ -BOOST_AUTO_TEST_CASE (validator_transfer_invalid_key_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Build invalid key */ - std::string key = ""; - for (int i = 0; i < DNS_MAX_KEY_LEN + 1; i++) - key.append("A"); - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = key; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept a transfer for a key when there already exists a transaction for the same key in the - * current transaction pool */ -BOOST_AUTO_TEST_CASE (validator_transfer_pending_txs_conflict_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Auction dns */ - tx = state.wallet1->ask(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - validator->evaluate(tx, block_state); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = state.random_addr(state.wallet2); - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::update; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, prev_output.amount)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a transfer for a key of invalid length */ -BOOST_AUTO_TEST_CASE (wallet_transfer_invalid_key_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Build invalid key */ - std::string key = ""; - for (int i = 0; i < DNS_MAX_KEY_LEN + 1; i++) - key.append("A"); - - /* Try to update dns record */ - auto no_exception = false; - try - { - tx = state.wallet1->transfer(key, state.random_addr(state.wallet2), txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create a transfer for a key when there already exists a transaction for the same key in the - * current transaction pool */ -BOOST_AUTO_TEST_CASE (wallet_transfer_pending_txs_conflict_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Auction dns */ - tx = state.wallet1->ask(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - - /* Try to update dns record */ - auto no_exception = false; - try - { - tx = state.wallet1->transfer(DNS_TEST_KEY, state.random_addr(state.wallet2), txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall accept an auction for a key that has been acquired and is not expired */ -BOOST_AUTO_TEST_CASE(validator_auction) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, DNS_TEST_PRICE1)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet can auction a key that has been acquired and is not expired */ -BOOST_AUTO_TEST_CASE(wallet_and_validator_auction) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Auction dns */ - tx = state.wallet1->ask(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Validate transaction */ - validator->evaluate(tx, block_state); - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an auction for a key that is being auctioned */ -BOOST_AUTO_TEST_CASE (validator_auction_in_auction_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, DNS_TEST_PRICE1)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an auction for a key that has been acquired by another owner */ -BOOST_AUTO_TEST_CASE(validator_auction_not_owner_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(state.random_addr(state.wallet2)); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, DNS_TEST_PRICE1)); - - tx = state.wallet2->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an auction for a key that has expired */ -BOOST_AUTO_TEST_CASE(validator_auction_expired_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Let dns expire */ - for (auto i = 0; i < DNS_EXPIRE_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, DNS_TEST_PRICE1)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an auction for a key that is being auctioned */ -BOOST_AUTO_TEST_CASE (wallet_auction_in_auction_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Try to auction dns */ - auto no_exception = false; - try - { - tx = state.wallet1->ask(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an auction for a key that has been acquired by another owner */ -BOOST_AUTO_TEST_CASE(wallet_auction_not_owner_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Try to auction dns from second wallet */ - auto no_exception = false; - try - { - tx = state.wallet2->ask(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an auction for a key that has expired */ -BOOST_AUTO_TEST_CASE(wallet_auction_expired_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Let dns expire */ - for (auto i = 0; i < DNS_EXPIRE_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Try to auction dns */ - auto no_exception = false; - try - { - tx = state.wallet1->ask(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an auction for a key of invalid length */ -BOOST_AUTO_TEST_CASE (validator_auction_invalid_key_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Build invalid key */ - std::string key = ""; - for (int i = 0; i < DNS_MAX_KEY_LEN + 1; i++) - key.append("A"); - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = key; - dns_output.value = std::vector(); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, DNS_TEST_PRICE1)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Validator shall not accept an auction for a key when there already exists a transaction for the same key in the - * current transaction pool */ -BOOST_AUTO_TEST_CASE (validator_auction_pending_txs_conflict_fail) -{ - try - { - DNSTestState state; - auto validator = state.db->get_transaction_validator(); - auto block_state = validator->create_block_state(); - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Update dns record */ - tx = state.wallet1->set(DNS_TEST_KEY, DNS_TEST_VALUE, txs); - wlog("tx: ${tx} ", ("tx", tx)); - validator->evaluate(tx, block_state); - - /* Get previous output */ - auto prev_tx_ref = state.db->get_dns_ref(DNS_TEST_KEY); - auto prev_output = state.db->fetch_output(prev_tx_ref); - auto prev_dns_output = to_dns_output(prev_output); - - /* Build dns output */ - claim_dns_output dns_output; - dns_output.key = DNS_TEST_KEY; - dns_output.value = std::vector(); - dns_output.owner = prev_dns_output.owner; - dns_output.last_tx_type = claim_dns_output::last_tx_type_enum::auction; - - /* Build full transaction */ - tx = signed_transaction(); - std::unordered_set
req_sigs; - req_sigs.insert(prev_dns_output.owner); - - tx.inputs.push_back(trx_input(prev_tx_ref)); - tx.outputs.push_back(trx_output(dns_output, DNS_TEST_PRICE1)); - - tx = state.wallet1->collect_inputs_and_sign(tx, asset(), req_sigs); - wlog("tx: ${tx} ", ("tx", tx)); - - /* Try to validate transaction */ - auto no_exception = false; - try - { - validator->evaluate(tx, block_state); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an auction for a key of invalid length */ -BOOST_AUTO_TEST_CASE (wallet_auction_invalid_key_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Build invalid key */ - std::string key = ""; - for (int i = 0; i < DNS_MAX_KEY_LEN + 1; i++) - key.append("A"); - - /* Try to auction dns */ - auto no_exception = false; - try - { - tx = state.wallet1->ask(key, DNS_TEST_PRICE1, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} - -/* Wallet shall not create an auction for a key when there already exists a transaction for the same key in the - * current transaction pool */ -BOOST_AUTO_TEST_CASE (wallet_auction_pending_txs_conflict_fail) -{ - try - { - DNSTestState state; - signed_transactions txs; - signed_transaction tx; - - /* Initial dns bid */ - tx = state.wallet1->bid(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - state.next_block(txs); - - /* Let auction end */ - for (auto i = 0; i < DNS_AUCTION_DURATION_BLOCKS; i++) - state.next_block(txs); - - /* Update dns record */ - tx = state.wallet1->set(DNS_TEST_KEY, DNS_TEST_VALUE, txs); - wlog("tx: ${tx} ", ("tx", tx)); - txs.push_back(tx); - - /* Try to auction dns */ - auto no_exception = false; - try - { - tx = state.wallet1->ask(DNS_TEST_KEY, DNS_TEST_PRICE1, txs); - - no_exception = true; - throw; - } - catch (const fc::exception &e) - { - if (no_exception) - throw; - } - } - catch (const fc::exception &e) - { - std::cerr << e.to_detail_string() << "\n"; - elog("${e}", ("e", e.to_detail_string())); - throw; - } -} From 0cb56cb57a1f68adbc5f661c8540ce679c873c5a Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 18:16:19 -0400 Subject: [PATCH 11/32] Delete deprecated libraries/kid --- libraries/CMakeLists.txt | 1 - libraries/kid/CMakeLists.txt | 12 - libraries/kid/include/bts/kid/kid_server.hpp | 57 --- libraries/kid/include/bts/kid/name_record.hpp | 64 --- libraries/kid/kid_server.cpp | 399 ------------------ 5 files changed, 533 deletions(-) delete mode 100644 libraries/kid/CMakeLists.txt delete mode 100644 libraries/kid/include/bts/kid/kid_server.hpp delete mode 100644 libraries/kid/include/bts/kid/name_record.hpp delete mode 100644 libraries/kid/kid_server.cpp diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 804f9b5c3..c54d5c1fa 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -11,5 +11,4 @@ add_subdirectory( rpc ) add_subdirectory( cli ) add_subdirectory( keyhotee ) add_subdirectory( mail ) -#add_subdirectory( kid ) add_subdirectory( bitcoin ) diff --git a/libraries/kid/CMakeLists.txt b/libraries/kid/CMakeLists.txt deleted file mode 100644 index 5757e2dca..000000000 --- a/libraries/kid/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -file(GLOB HEADERS "include/bts/kid/*.hpp") - -add_library( bts_kid kid_server.cpp ${HEADERS}) -target_link_libraries(bts_kid - PUBLIC fc - PRIVATE bts_db bts_blockchain leveldb -) - -target_include_directories(bts_kid - PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" -) - diff --git a/libraries/kid/include/bts/kid/kid_server.hpp b/libraries/kid/include/bts/kid/kid_server.hpp deleted file mode 100644 index 124066484..000000000 --- a/libraries/kid/include/bts/kid/kid_server.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once -#include - -namespace fc -{ - class path; - class sha256; - namespace ip { class endpoint; } -} // namespace fc - -namespace bts { namespace kid -{ - namespace detail { class server_impl; } - - struct name_index - { - name_index( uint32_t bn = 0, uint16_t rn = 0) - :block_num(bn),record_num(rn){} - - uint32_t block_num; - uint16_t record_num; - }; - struct history - { - std::vector updates; - }; - - class server - { - public: - server(); - ~server(); - - void set_trustee( const fc::ecc::private_key& k ); - void set_data_directory( const fc::path& dir ); - void listen( const fc::ip::endpoint& ep ); - - bool update_record( const signed_name_record& r ); - signed_name_record fetch_record_by_key( const std::string& name_b58 ); - signed_name_record fetch_record( const std::string& name ); - signed_name_record fetch_record( const name_index& n ); - history fetch_history( const std::string& name ); - - signed_block fetch_block( uint32_t block_num ); - signed_block head_block()const; - fc::sha256 head_block_id()const; - - void store_key( const std::string& name, const stored_key& key ); - stored_key fetch_key( const std::string& name ); - - private: - std::unique_ptr my; - }; -} } // namespace bts::kid - -FC_REFLECT( bts::kid::name_index, (block_num)(record_num) ) -FC_REFLECT( bts::kid::history, (updates) ) diff --git a/libraries/kid/include/bts/kid/name_record.hpp b/libraries/kid/include/bts/kid/name_record.hpp deleted file mode 100644 index 67940aaa9..000000000 --- a/libraries/kid/include/bts/kid/name_record.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include - -namespace bts { namespace kid -{ - struct name_record - { - name_record():nonce(0){} - - fc::sha256 digest()const; - fc::sha256 digest512()const; - uint64_t difficulty()const; - - std::string name; - fc::ecc::public_key master_key; - fc::ecc::public_key active_key; - fc::sha256 prev_block_id; - fc::time_point_sec last_update; - fc::time_point_sec first_update; - uint32_t nonce; // used to rate limit - }; - - struct signed_name_record : public name_record - { - fc::sha256 id()const; - fc::ecc::public_key get_signee()const; - void sign( const fc::ecc::private_key& master_key ); - fc::ecc::compact_signature master_signature; - }; - - struct block - { - block():number(0),difficulty(1000){} - fc::sha256 digest()const; - - uint32_t number; - fc::time_point_sec timestamp; - uint64_t difficulty; - std::vector records; - }; - - struct signed_block : public block - { - fc::sha256 id()const; - void sign( const fc::ecc::private_key& trustee_priv_key ); - void verify( const fc::ecc::public_key& trustee_pub_key ); - - fc::ecc::compact_signature trustee_signature; - }; - - struct stored_key - { - fc::ecc::public_key get_signee()const; - std::vector encrypted_key; - fc::ecc::compact_signature signature; - }; -} } // namespace bts::kid - -FC_REFLECT( bts::kid::name_record, (name)(master_key)(active_key)(prev_block_id)(last_update)(first_update)(nonce) ) -FC_REFLECT_DERIVED( bts::kid::signed_name_record, (bts::kid::name_record), (master_signature) ) -FC_REFLECT( bts::kid::block, (number)(timestamp)(difficulty)(records) ) -FC_REFLECT_DERIVED( bts::kid::signed_block, (bts::kid::block), (trustee_signature) ) -FC_REFLECT( bts::kid::stored_key, (encrypted_key)(signature) ) diff --git a/libraries/kid/kid_server.cpp b/libraries/kid/kid_server.cpp deleted file mode 100644 index 58d1790cf..000000000 --- a/libraries/kid/kid_server.cpp +++ /dev/null @@ -1,399 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -namespace bts { namespace kid { - uint64_t name_record::difficulty()const - { - return 1000 * bts::blockchain::difficulty( digest512() ); - } - - fc::ecc::public_key signed_name_record::get_signee()const - { - return fc::ecc::public_key( master_signature, digest() ); - } - fc::ecc::public_key stored_key::get_signee()const - { - FC_ASSERT( encrypted_key.size() > 0 ); - auto digest = fc::sha256::hash( encrypted_key.data(), encrypted_key.size() ); - return fc::ecc::public_key( signature, digest ); - } - fc::sha256 name_record::digest()const - { - fc::sha256::encoder enc; - fc::raw::pack( enc, *this ); - return enc.result(); - } - fc::sha256 name_record::digest512()const - { - fc::sha512::encoder enc; - fc::raw::pack( enc, *this ); - auto h512 = enc.result(); - return fc::sha256::hash( (char*)&h512, sizeof(h512) ); - } - - fc::sha256 signed_name_record::id()const - { - fc::sha256::encoder enc; - fc::raw::pack( enc, *this ); - return enc.result(); - } - - fc::sha256 block::digest()const - { - fc::sha256::encoder enc; - fc::raw::pack( enc, *this ); - return enc.result(); - } - - fc::sha256 signed_block::id()const - { - fc::sha256::encoder enc; - fc::raw::pack( enc, *this ); - return enc.result(); - } - - void signed_block::sign( const fc::ecc::private_key& trustee_priv_key ) - { - trustee_signature = trustee_priv_key.sign_compact( id() ); - } - - void signed_block::verify( const fc::ecc::public_key& trustee_pub_key ) - { - FC_ASSERT( fc::ecc::public_key( trustee_signature, id() ) == trustee_pub_key ) - } - - namespace detail - { - class server_impl - { - public: - server* _self; - fc::http::server _httpd; - bts::db::level_map _name_index; - bts::db::level_map _block_database; - bts::db::level_map _key_data; - bts::db::level_map _key_to_name; - - std::unordered_map _pending; - - fc::future _block_gen_loop_complete; - - signed_block _current_block; - fc::sha256 _current_block_id; - fc::ecc::private_key _trustee_key; - fc::path _data_dir; - - void block_generation_loop() - { - while( !_block_gen_loop_complete.canceled() ) - { - if( _pending.size() && (fc::time_point::now() - _current_block.timestamp) > fc::seconds(60) ) - { - signed_block next_block; - next_block.number = _current_block.number + 1; - auto next_diff = _current_block.difficulty * 500 / _pending.size(); - next_diff = (_current_block.difficulty * 99 + next_diff) / 100; - next_block.difficulty = std::max(next_diff, 1000 ); - next_block.timestamp = fc::time_point::now(); - - for( auto rec : _pending ) - { - next_block.records.push_back( rec.second ); - } - - next_block.sign( _trustee_key ); - _block_database.store(next_block.number,next_block); - - for( uint32_t rec = 0; rec < next_block.records.size(); ++rec ) - { - auto new_rec = next_block.records[rec]; - auto hist = _self->fetch_history( new_rec.name ); - hist.updates.push_back( name_index( next_block.number, rec ) ); - _name_index.store( new_rec.name, hist ); - _key_to_name.store( new_rec.active_key.to_base58(), new_rec.name ); - } - - _current_block = next_block; - _current_block_id = _current_block.id(); - - fc::path block_file = _data_dir / "block" / fc::to_string( uint64_t(_current_block.number) ); - - std::ofstream out( block_file.generic_string().c_str() ); - auto block_str = fc::json::to_pretty_string( _current_block ); - out.write( block_str.c_str(), block_str.size() ); - } - fc::usleep( fc::seconds( 1 ) ); - } - } - - void handle_request( const fc::http::request& r, const fc::http::server::response& s ) - { - //ilog( "handle request ${r}", ("r",r.path) ); - s.add_header( "Connection", "close" ); - - try { - auto pos = r.path.find( "/", 1 ); - auto first_dir = r.path.substr(1,pos); - //ilog( "command: ${command}", ("command",first_dir) ); - if( first_dir == "pending" ) - { - s.set_status( fc::http::reply::OK ); - auto pending_json = fc::json::to_string( _pending ); - s.set_length( pending_json.size() ); - s.write( pending_json.c_str(), pending_json.size() ); - } - else if( first_dir == "update_record" ) - { - FC_ASSERT( r.body.size() ); - std::string str(r.body.data(),r.body.size()); - auto rec = fc::json::from_string( str ).as(); - - _self->update_record( rec ); - - s.set_status( fc::http::reply::RecordCreated ); - s.set_length( 12 ); - s.write( "Record Created", 12 ); - } - else if( first_dir == "fetch_by_name/" ) - { - auto name = r.path.substr( pos+1, std::string::npos ); - auto record = _self->fetch_record( name ); - s.set_status( fc::http::reply::Found ); - auto blkjson = fc::json::to_string( record ); - s.set_length( blkjson.size() ); - s.write( blkjson.c_str(), blkjson.size() ); - } - else if( first_dir == "fetch_by_key/" ) - { - auto key = r.path.substr( pos+1, std::string::npos ); - auto record = _self->fetch_record_by_key( key ); - s.set_status( fc::http::reply::Found ); - - auto blkjson = fc::json::to_string( record ); - s.set_length( blkjson.size() ); - s.write( blkjson.c_str(), blkjson.size() ); - } - else if( first_dir == "store_key/" ) - { - auto name = r.path.substr( pos+1, std::string::npos ); - std::string str(r.body.data(),r.body.size()); - auto rec = fc::json::from_string( str ).as(); - - _self->store_key( name, rec ); - s.set_status( fc::http::reply::RecordCreated ); - s.set_length( 12 ); - s.write( "Record Created", 12 ); - } - else if( first_dir == "fetch_key/" ) - { - auto user_name = r.path.substr( pos+1, std::string::npos ); - auto key_data = _self->fetch_key( user_name ); - s.set_status( fc::http::reply::Found ); - - auto blkjson = fc::json::to_string( key_data ); - s.set_length( blkjson.size() ); - s.write( blkjson.c_str(), blkjson.size() ); - } - else if( first_dir == "fetch_block/" ) - { - auto block_num = r.path.substr( pos+1, std::string::npos ); - auto blk = _self->fetch_block( fc::to_uint64( block_num ) ); - s.set_status( fc::http::reply::Found ); - auto blkjson = fc::json::to_string( blk ); - s.set_length( blkjson.size() ); - s.write( blkjson.c_str(), blkjson.size() ); - } - else - { - auto dotpos = r.path.find( ".." ); - FC_ASSERT( dotpos == std::string::npos ); - auto filename = _data_dir / r.path.substr(1,std::string::npos); - if( fc::exists( filename ) ) - { - FC_ASSERT( !fc::is_directory( filename ) ); - auto file_size = fc::file_size( filename ); - FC_ASSERT( file_size != 0 ); - - fc::file_mapping fm( filename.generic_string().c_str(), fc::read_only ); - fc::mapped_region mr( fm, fc::read_only, 0, fc::file_size( filename ) ); - - s.set_status( fc::http::reply::OK ); - s.set_length( file_size ); - s.write( (const char*)mr.get_address(), mr.get_size() ); - return; - } - s.set_status( fc::http::reply::NotFound ); - s.set_length( 9 ); - s.write( "Not Found", 9 ); - } - } - catch ( const fc::exception& e ) - { - s.set_status( fc::http::reply::BadRequest ); - auto msg = e.to_detail_string(); - s.set_length( msg.size() ); - if( msg.size() ) - { - s.write( msg.c_str(), msg.size() ); - } - } - } - }; - } // namespace detail - - - server::server() - :my( new detail::server_impl() ) - { - my->_self = this; - my->_block_gen_loop_complete = fc::async( [=](){ my->block_generation_loop(); } ); - } - server::~server() - { - ilog( "waiting for block generation loop to exit" ); - try { - my->_block_gen_loop_complete.cancel(); - my->_block_gen_loop_complete.wait(); - } - catch ( const fc::canceled_exception& e ){} - catch ( const fc::exception& e ) - { - wlog( "${e}", ("e",e.to_detail_string()) ); - } - } - - void server::set_data_directory( const fc::path& dir ) - { - my->_data_dir = dir / "htdocs"; - fc::create_directories( my->_data_dir / "block" ); - my->_name_index.open( dir / "name_index" ); - my->_block_database.open( dir / "block_database" ); - my->_key_data.open( dir / "key_data" ); - my->_key_to_name.open( dir / "key_to_name" ); - - uint32_t last_block = 0; - if( my->_block_database.last( last_block ) ) - { - my->_current_block = fetch_block( last_block ); - my->_current_block_id = my->_current_block.id(); - } - else - { - ilog( "generating genesis block" ); - // generate genesis block... - my->_current_block.timestamp = fc::time_point::now(); - my->_current_block.number = 0; - my->_current_block.difficulty = 1000; - my->_current_block.sign( my->_trustee_key ); - my->_current_block_id = my->_current_block.id(); - my->_block_database.store( 0, my->_current_block ); - } - } - - void server::listen( const fc::ip::endpoint& ep ) - { - auto m = my.get(); - my->_httpd.listen(ep); - my->_httpd.on_request( [m]( const fc::http::request& r, const fc::http::server::response& s ){ m->handle_request( r, s ); } ); - } - - bool server::update_record( const signed_name_record& r ) - { try { - FC_ASSERT( my->_pending.size() < 20000 ); - FC_ASSERT( fc::trim_and_normalize_spaces( r.name ) == r.name ); - FC_ASSERT( fc::to_lower( r.name ) == r.name ); - FC_ASSERT( r.difficulty() >= my->_current_block.difficulty, "", - ("r.difficulty",r.difficulty())("current_difficulty",my->_current_block.difficulty)); - FC_ASSERT( my->_current_block_id == r.prev_block_id ); - FC_ASSERT( r.get_signee() == r.master_key ); - - auto pending_itr = my->_pending.find( r.name ); - FC_ASSERT( pending_itr == my->_pending.end() ); - auto hist = fetch_history( r.name ); - if( hist.updates.size() == 0 ) - { - my->_pending[r.name] = r; - return true; - } - - auto old_record = fetch_record( hist.updates.back() ); - FC_ASSERT( old_record.master_key == r.master_key ) - FC_ASSERT( r.first_update == old_record.first_update ); - FC_ASSERT( r.last_update > old_record.last_update ); - FC_ASSERT( fc::time_point::now() > fc::time_point(r.last_update) ); - FC_ASSERT( (fc::time_point::now() - fc::time_point(r.last_update)) < fc::seconds( 120 ) ); - my->_pending[r.name] = r; - return true; - } FC_RETHROW_EXCEPTIONS( warn, "unable to update record ${rec}", ("rec",r) ) } - - signed_name_record server::fetch_record( const std::string& name ) - { - auto pending_itr = my->_pending.find( name ); - if( pending_itr != my->_pending.end() ) - return pending_itr->second; - auto hist= fetch_history( name ); - FC_ASSERT( hist.updates.size() > 0 ); - - auto old_block = fetch_block( hist.updates.back().block_num ); - return fetch_record( hist.updates.back() ); - FC_ASSERT( old_block.records.size() > hist.updates.back().record_num ); - return old_block.records[hist.updates.back().record_num]; - } - - signed_name_record server::fetch_record( const name_index& index ) - { - auto old_block = fetch_block( index.block_num ); - FC_ASSERT( old_block.records.size() > index.record_num ); - return old_block.records[index.record_num]; - } - signed_name_record server::fetch_record_by_key( const std::string& key_b58 ) - { - auto name = my->_key_to_name.fetch( key_b58 ); - return fetch_record( name ); - } - - history server::fetch_history( const std::string& name ) - { - history hist; - auto itr = my->_name_index.find(name); - if( itr.valid() ) - hist = itr.value(); - return hist; - } - - void server::store_key( const std::string& name, const stored_key& k ) - { - auto cur_rec = fetch_record( name ); - FC_ASSERT( k.encrypted_key.size() < 1024*16 ); - FC_ASSERT( cur_rec.master_key == k.get_signee() ); - my->_key_data.store( name, k ); - } - - stored_key server::fetch_key( const std::string& name ) - { - return my->_key_data.fetch( name ); - } - - signed_block server::fetch_block( uint32_t block_num ) - { try { - return my->_block_database.fetch( block_num ); - } FC_RETHROW_EXCEPTIONS( warn, "unable to fetch block number ${n}", ("n",block_num) ) } - - void server::set_trustee( const fc::ecc::private_key& k ) - { - my->_trustee_key = k; - } - -} } // namespace bts::kid From 6e4dec103c379cae60bc69b886b34f29ec693697 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 18:12:31 -0400 Subject: [PATCH 12/32] Delete deprecated libraries/lotto --- .../lotto/include/bts/lotto/lotto_db.hpp | 71 ------------ .../lotto/include/bts/lotto/lotto_outputs.hpp | 47 -------- .../bts/lotto/lotto_transaction_validator.hpp | 36 ------ libraries/lotto/lotto_db.cpp | 80 -------------- .../lotto/lotto_transaction_validator.cpp | 104 ------------------ 5 files changed, 338 deletions(-) delete mode 100644 libraries/lotto/include/bts/lotto/lotto_db.hpp delete mode 100644 libraries/lotto/include/bts/lotto/lotto_outputs.hpp delete mode 100644 libraries/lotto/include/bts/lotto/lotto_transaction_validator.hpp delete mode 100644 libraries/lotto/lotto_db.cpp delete mode 100644 libraries/lotto/lotto_transaction_validator.cpp diff --git a/libraries/lotto/include/bts/lotto/lotto_db.hpp b/libraries/lotto/include/bts/lotto/lotto_db.hpp deleted file mode 100644 index 2e4fb9550..000000000 --- a/libraries/lotto/include/bts/lotto/lotto_db.hpp +++ /dev/null @@ -1,71 +0,0 @@ - -#pragma once -#include -#include -#include - -#include - -namespace bts { namespace lotto { - -namespace detail { class lotto_db_impl; } - -struct drawing_record -{ - drawing_record() - :total_jackpot(0),total_paid(0){} - - uint64_t total_jackpot; - uint64_t total_paid; -}; -struct block_summary -{ - block_summary() - :ticket_sales(0),amount_won(0){} - - uint64_t ticket_sales; - uint64_t amount_won; -}; - -class lotto_db : public bts::blockchain::chain_database -{ - public: - lotto_db(); - ~lotto_db(); - - void open( const fc::path& dir, bool create ); - void close(); - - uint64_t get_jackpot_for_ticket( uint64_t ticket_block_num, - fc::sha256& winning_number, - uint64_t& global_odds ); - - /** - * Performs global validation of a block to make sure that no two transactions conflict. In - * the case of the lotto only one transaction can claim the jackpot. - */ - virtual void validate( const trx_block& blk, const signed_transactions& deterministic_trxs ); - - /** - * Called after a block has been validated and appends - * it to the block chain storing all relevant transactions and updating the - * winning database. - */ - virtual void store( const trx_block& blk, const signed_transactions& deterministic_trxs ); - - /** - * When a block is popped from the chain, this method implements the necessary code - * to revert the blockchain database to the proper state. - */ - virtual trx_block pop_block(); - private: - std::unique_ptr my; - -}; - - -}} // bts::lotto - - -FC_REFLECT( bts::lotto::drawwing_record, (total_jackpot)(total_paid) ) -FC_REFLECT( bts::lotto::block_summary, (ticket_sales)(amount_won) ) diff --git a/libraries/lotto/include/bts/lotto/lotto_outputs.hpp b/libraries/lotto/include/bts/lotto/lotto_outputs.hpp deleted file mode 100644 index 9b0f72dbb..000000000 --- a/libraries/lotto/include/bts/lotto/lotto_outputs.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include - -namespace bts { namespace lotto { - - -enum claim_type_enum -{ - /** basic claim by single address */ - claim_ticket = 30, -}; - - -struct claim_ticket_input -{ - static const claim_type_enum type; -}; - -struct claim_ticket_output -{ - static const claim_type_enum type; - - claim_ticket_output():odds(1),lucky_number(0){} - - /** - * This is the number chosen by the user or at - * random, ie: their lotto ticket number. - */ - uint64_t lucky_number; - - /** - * Who owns the ticket and thus can claim the jackpot - */ - bts::blockchain::address owner; - - /** The probability of winning... increasing the odds will - * cause the amount won to grow by Jackpot * odds, but the - * probability of winning decreases by 2*odds. - */ - uint16_t odds; -}; - -}} //bts::lotto - -FC_REFLECT_ENUM(bts::lotto::claim_type_enum, (claim_ticket)); -FC_REFLECT(bts::lotto::claim_ticket_input, BOOST_PP_SEQ_NIL); -FC_REFLECT(bts::lotto::claim_ticket_output, (owner)(odds)); diff --git a/libraries/lotto/include/bts/lotto/lotto_transaction_validator.hpp b/libraries/lotto/include/bts/lotto/lotto_transaction_validator.hpp deleted file mode 100644 index 114c4a844..000000000 --- a/libraries/lotto/include/bts/lotto/lotto_transaction_validator.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include -#include -#include -#include - -namespace bts { namespace lotto { -using namespace bts::blockchain; - -class lotto_db; -class lotto_trx_evaluation_state : public bts::blockchain::transaction_evaluation_state -{ - public: - lotto_trx_evaluation_state( const signed_transaction& tx ) - :transaction_evaluation_state( tx ),total_ticket_sales(0){} - - uint64_t total_ticket_sales; - uint64_t ticket_winnings; -}; - -class lotto_transaction_validator : public bts::blockchain::transaction_validator -{ - public: - lotto_transaction_validator(lotto_db* db); - virtual ~lotto_transaction_validator(); - - virtual transaction_summary evaluate( const signed_transaction& trx ); - virtual void validate_input( const meta_trx_input& in, transaction_evaluation_state& state ); - virtual void validate_output( const trx_output& out, transaction_evaluation_state& state ); - - void validate_ticket_input(const meta_trx_input& in, transaction_evaluation_state& state); - void validate_ticket_output(const trx_output& out, transaction_evaluation_state& state); -}; - -}} // bts::lotto - diff --git a/libraries/lotto/lotto_db.cpp b/libraries/lotto/lotto_db.cpp deleted file mode 100644 index b328b7be5..000000000 --- a/libraries/lotto/lotto_db.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -#include -#include -#include - -namespace bts { namespace lotto { - - namespace detail - { - class lotto_db_impl - { - public: - lotto_db_impl(){} - // map drawning number to drawing record - bts::db::level_map _drawing2record; - bts::db::level_map _block2summary; - - }; - } - - lotto_db::lotto_db() - :my( new detail::lotto_db_impl() ) - { - set_transaction_validator( std::make_shared(this) ); - } - - lotto_db::~lotto_db() - { - } - - void lotto_db::open( const fc::path& dir, bool create ) - { - try { - chain_database::open( dir, create ); - my->drawing2record.open( dir / "drawing2record", create ); - my->block2summary.open( dir / "block2summary", create ); - } FC_RETHROW_EXCEPTIONS( warn, "Error loading domain database ${dir}", ("dir", dir)("create", create) ); - } - - void lotto_db::close() - { - my->name2record.close(); - } - - uint64_t lotto_db::get_jackpot_for_ticket( uint64_t ticket_block_num, - fc::sha256& winning_number, - uint64_t& global_odds ) - { - } - - /** - * Performs global validation of a block to make sure that no two transactions conflict. In - * the case of the lotto only one transaction can claim the jackpot. - */ - void lotto_db::validate( const trx_block& blk, const signed_transactions& deterministic_trxs ) - { - } - - /** - * Called after a block has been validated and appends - * it to the block chain storing all relevant transactions and updating the - * winning database. - */ - void lotto_db::store( const trx_block& blk, const signed_transactions& deterministic_trxs ) - { - } - - /** - * When a block is popped from the chain, this method implements the necessary code - * to revert the blockchain database to the proper state. - */ - trx_block lotto_db::pop_block() - { - auto blk = chain_database::pop_block(); - // TODO: remove block summary from DB - FC_ASSERT( !"Not Implemented" ); - return blk; - } - -}} // bts::lotto diff --git a/libraries/lotto/lotto_transaction_validator.cpp b/libraries/lotto/lotto_transaction_validator.cpp deleted file mode 100644 index c91bc7038..000000000 --- a/libraries/lotto/lotto_transaction_validator.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include -#include -#include -#include - -namespace bts { namespace lotto { - -lotto_transaction_validator::lotto_transaction_validator(lotto_db* db) -:transaction_validator(db) -{ -} - -lotto_transaction_validator::~lotto_transaction_validator() -{ -} - -transaction_summary lotto_transaction_validator::evaluate( const signed_transaction& tx) -{ - lotto_trx_evaluation_state state(tx); - return on_evaluate( state ); -} - - -void lotto_transaction_validator::validate_input( const meta_trx_input& in, transaction_evaluation_state& state ) -{ - switch( in.output.claim_func ) - { - case claim_ticket: - validate_ticket_input(in, state); - break; - default: - transaction_validator::validate_input( in, state ); - } -} - -void lotto_transaction_validator::validate_output( const trx_output& out, transaction_evaluation_state& state ) -{ - switch( out.claim_func ) - { - case claim_ticket: - validate_ticket_output(out, state); - break; - default: - transaction_validator::validate_output( out, state ); - } -} - -void lotto_transaction_validator::validate_ticket_input(const meta_trx_input& in, transaction_evaluation_state& state) -{ try { - auto lotto_state = dynamic_cast(state); - auto claim_ticket = in.output.as(); - - auto trx_loc = _db->fetch_trx_num( in.output_ref.trx_id ); - auto headnum = _db->head_block_num(); - - // ticket must have been purchased in the past 2 days - FC_ASSERT( headnum - trx_loc.block_num < (BTS_BLOCKCHAIN_BLOCKS_PER_DAY*2) ); - // ticket must be before the last drawing... - FC_ASSERT( trx_loc.block_num < (headnum/BTS_BLOCKCHAIN_BLOCKS_PER_DAY)*BTS_BLOCKCHAIN_BLOCKS_PER_DAY ); - // ticket must be signed by owner - FC_ASSERT( lotto_state.has_signature( claim_ticket.owner ) ); - - lotto_db* db = dynamic_cast(_db); - FC_ASSERT( db != nullptr ); - - fc::sha256 winning_number; - uint64_t global_odds = 0; - - // returns the jackpot based upon which lottery the ticket was for. - // throws an exception if the jackpot was already claimed. - uint64_t jackpot = db->get_jackpot_for_ticket( trx_loc.block_num, winning_number, global_odds ); - - fc::sha256::encoder enc; - enc.write( (char*)&claim_ticket.lucky_number, sizeof(claim_ticket.lucky_number) ); - enc.write( (char*)&winning_number, sizeof(winning_number) ); - fc::bigint result_bigint( enc.result() ); - - /** the ticket number must be below the winning threshold to claim the jackpot */ - auto winning_threshold = result_bigint % fc::bigint( global_odds * claim_ticket.odds ).to_int64(); - auto ticket_threshold = in.output.amount.get_rounded_amount() / claim_ticket.odds; - if( winning_threshold < ticket_threshold ) // we have a winner! - { - lotto_state.add_input_asset( asset( jackpot ) ); - lotto_state.ticket_winnings += jackpot; - } - - uint64_t winnings = db->get_winnings( in ); // throws if they did not win. - lotto_state.ticket_winnings += winnings; - add_input_asset( asset(winnings) ); -} FC_RETHROW_EXCEPTIONS( warn, "" ) } - -void lotto_transaction_validator::validate_ticket_output(const trx_output& out, transaction_evaluation_state& state) -{ try { - auto lotto_state = dynamic_cast(state); - lotto_state.total_ticket_sales += out.amount.get_rounded_amount(); - lotto_state.add_output_asset( out.amount ); - - auto claim_ticket = in.output.as(); - FC_ASSERT( claim_ticket.odds -} FC_RETHROW_EXCEPTIONS( warn, "" ) } - - -}} // bts::blockchain From 9a3624dd07b97440ee1bea7c93844c1f7e2bfc8e Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 18:05:19 -0400 Subject: [PATCH 13/32] Delete deprecated libraries/me --- libraries/me/include/bts/me/me_config.hpp | 6 ---- libraries/me/include/bts/me/me_db.hpp | 27 -------------- .../bts/me/me_transaction_validator.hpp | 36 ------------------- 3 files changed, 69 deletions(-) delete mode 100644 libraries/me/include/bts/me/me_config.hpp delete mode 100644 libraries/me/include/bts/me/me_db.hpp delete mode 100644 libraries/me/include/bts/me/me_transaction_validator.hpp diff --git a/libraries/me/include/bts/me/me_config.hpp b/libraries/me/include/bts/me/me_config.hpp deleted file mode 100644 index 3ac178507..000000000 --- a/libraries/me/include/bts/me/me_config.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -namespace bts { namespace me { - - -} } // bts::me diff --git a/libraries/me/include/bts/me/me_db.hpp b/libraries/me/include/bts/me/me_db.hpp deleted file mode 100644 index 7b7bc7dae..000000000 --- a/libraries/me/include/bts/me/me_db.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include -#include -#include - -namespace bts { namespace dns { - -namespace detail { class me_db_impl; } - -class me_db : public bts::blockchain::chain_database -{ - public: - me_db(); - ~me_db(); - - void open( const fc::path& dir, bool create ); - void close(); - - private: - std::unique_ptr my; -}; - - -}} // bts::dns - - -FC_REFLECT( bts::dns::dns_record, (owner)(value)(last_price)(last_update_ref) ); diff --git a/libraries/me/include/bts/me/me_transaction_validator.hpp b/libraries/me/include/bts/me/me_transaction_validator.hpp deleted file mode 100644 index 2fec93993..000000000 --- a/libraries/me/include/bts/me/me_transaction_validator.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include -#include -#include -#include - -namespace bts { namespace me { -using namespace bts::blockchain; - -class me_db; - -class me_tx_evaluation_state : public bts::blockchain::transaction_evaluation_state -{ - public: - me_tx_evaluation_state( const signed_transaction& tx ) - :transaction_evaluation_state( tx ) {} -}; - - -class me_transaction_validator : public bts::blockchain::transaction_validator -{ - public: - me_transaction_validator(me_db* db); - virtual ~me_transaction_validator(); - - virtual transaction_summary evaluate( const signed_transaction& tx ); - virtual void validate_input( const meta_trx_input& in, transaction_evaluation_state& state ); - virtual void validate_output( const trx_output& out, transaction_evaluation_state& state ); - - void validate_domain_input(const meta_trx_input& in, transaction_evaluation_state& state); - void validate_domain_output(const trx_output& out, transaction_evaluation_state& state); -}; - -}} // bts::me - -FC_REFLECT(bts::me::me_tx_evaluation_state, BOOST_PP_SEQ_NULL ) From 4850ef91b6433349c662297b047d21bb57d87e34 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 18:21:33 -0400 Subject: [PATCH 14/32] Disable libraries/mail compilation --- libraries/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index c54d5c1fa..0fe4287db 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -10,5 +10,5 @@ add_subdirectory( client ) add_subdirectory( rpc ) add_subdirectory( cli ) add_subdirectory( keyhotee ) -add_subdirectory( mail ) +#add_subdirectory( mail ) add_subdirectory( bitcoin ) From 0da6cbdb4d1c3e6509339d3f608395fb6935f446 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 18:05:41 -0400 Subject: [PATCH 15/32] Disable libraries/network compilation --- libraries/CMakeLists.txt | 2 +- libraries/client/CMakeLists.txt | 2 +- libraries/client/client.cpp | 2 +- tests/CMakeLists.txt | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 0fe4287db..6488777aa 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -5,7 +5,7 @@ add_subdirectory( utilities ) add_subdirectory( blockchain ) add_subdirectory( wallet ) add_subdirectory( net ) -add_subdirectory( network ) +#add_subdirectory( network ) add_subdirectory( client ) add_subdirectory( rpc ) add_subdirectory( cli ) diff --git a/libraries/client/CMakeLists.txt b/libraries/client/CMakeLists.txt index 9ac4c4075..ea7ec5b5e 100644 --- a/libraries/client/CMakeLists.txt +++ b/libraries/client/CMakeLists.txt @@ -7,6 +7,6 @@ add_library( bts_client target_link_libraries( bts_client PRIVATE bts_db bts_blockchain bitcoin fc leveldb - PUBLIC bts_api bts_net bts_wallet bts_cli bts_rpc bts_rpc_stubs bts_network ) + PUBLIC bts_api bts_net bts_wallet bts_cli bts_rpc bts_rpc_stubs ) target_include_directories( bts_client PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/client/client.cpp b/libraries/client/client.cpp index 898f33651..ab236eca9 100644 --- a/libraries/client/client.cpp +++ b/libraries/client/client.cpp @@ -22,7 +22,7 @@ #include #include -#include +//#include #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9d1917584..375f292ba 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -57,11 +57,11 @@ target_link_libraries( wallet_tests deterministic_openssl_rand bts_client bts_cl add_executable( dev_tests dev_tests.cpp ) target_link_libraries( dev_tests deterministic_openssl_rand bts_client bts_cli bts_wallet bts_blockchain bts_net bitcoin fc ) -add_executable( server_node server_node.cpp ) -target_link_libraries( server_node bts_client bts_network bts_net fc bts_cli ) +#add_executable( server_node server_node.cpp ) +#target_link_libraries( server_node bts_client bts_network bts_net fc bts_cli ) -add_executable( client_node client_node.cpp ) -target_link_libraries( client_node bts_client bts_network bts_net fc bts_cli ) +#add_executable( client_node client_node.cpp ) +#target_link_libraries( client_node bts_client bts_network bts_net fc bts_cli ) include_directories( ${CMAKE_SOURCE_DIR}/libraries/client/include ) From 70feab54dc2b1addf53f8b895acf118e73eee733 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Tue, 12 Aug 2014 19:55:02 -0400 Subject: [PATCH 16/32] Delete deprecated fee rate references Conflicts: libraries/blockchain/include/bts/blockchain/exceptions.hpp --- libraries/blockchain/block.cpp | 7 ------ libraries/blockchain/chain_database.cpp | 8 ------- libraries/blockchain/chain_interface.cpp | 15 +----------- .../include/bts/blockchain/block.hpp | 2 -- .../bts/blockchain/chain_interface.hpp | 13 +++-------- .../include/bts/blockchain/config.hpp | 10 +------- .../include/bts/blockchain/exceptions.hpp | 13 ++++------- .../transaction_evaluation_state.cpp | 23 ++++++------------- libraries/client/client.cpp | 2 -- 9 files changed, 17 insertions(+), 76 deletions(-) diff --git a/libraries/blockchain/block.cpp b/libraries/blockchain/block.cpp index 42f2fec2e..57a53defe 100644 --- a/libraries/blockchain/block.cpp +++ b/libraries/blockchain/block.cpp @@ -46,13 +46,6 @@ namespace bts { namespace blockchain { return fc::sha256::hash( enc.result() ); } - int64_t block_header::next_fee( int64_t current_fee, size_t block_size )const - { - uint64_t next_fee_base = block_size * current_fee / BTS_BLOCKCHAIN_TARGET_BLOCK_SIZE; - uint64_t next_fee = ((BTS_BLOCKCHAIN_BLOCKS_PER_DAY-1)*current_fee + next_fee_base) / BTS_BLOCKCHAIN_BLOCKS_PER_DAY; - return std::max(next_fee,BTS_BLOCKCHAIN_MIN_FEE); - } - full_block::operator digest_block()const { digest_block db( (signed_block_header&)*this ); diff --git a/libraries/blockchain/chain_database.cpp b/libraries/blockchain/chain_database.cpp index 87142eed2..2b649329b 100644 --- a/libraries/blockchain/chain_database.cpp +++ b/libraries/blockchain/chain_database.cpp @@ -244,7 +244,6 @@ namespace bts { namespace blockchain { rebuild_index = true; } self->set_property( chain_property_enum::database_version, BTS_BLOCKCHAIN_DATABASE_VERSION ); - self->set_property( chain_property_enum::current_fee_rate, BTS_BLOCKCHAIN_MIN_FEE ); self->set_property( chain_property_enum::accumulated_fees, 0 ); self->set_property( chain_property_enum::dirty_markets, variant( map() ) ); } @@ -623,10 +622,6 @@ namespace bts { namespace blockchain { if( block_data.timestamp > (now + BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC*2) ) FC_CAPTURE_AND_THROW( time_in_future, (block_data.timestamp)(now)(delta_seconds) ); - - // TODO: move to state update - //auto expected_next_fee = block_data.next_fee( self->get_fee_rate(), block_size ); - digest_block digest_data(block_data); if( NOT digest_data.validate_digest() ) FC_CAPTURE_AND_THROW( invalid_block_digest ); @@ -820,9 +815,6 @@ namespace bts { namespace blockchain { update_random_seed( block_data.previous_secret, pending_state ); - // update fee rate - pending_state->set_fee_rate( block_data.next_fee( pending_state->get_fee_rate(), block_data.block_size() ) ); - save_undo_state( block_id, pending_state ); // TODO: verify that apply changes can be called any number of diff --git a/libraries/blockchain/chain_interface.cpp b/libraries/blockchain/chain_interface.cpp index 2b5884bba..90df7ff2e 100644 --- a/libraries/blockchain/chain_interface.cpp +++ b/libraries/blockchain/chain_interface.cpp @@ -35,11 +35,6 @@ namespace bts{ namespace blockchain { return (get_delegate_pay_rate() * BTS_BLOCKCHAIN_ASSET_REGISTRATION_FEE); } - share_type chain_interface::calculate_data_fee(size_t bytes) const - { - return (get_fee_rate() * bytes)/1000; - } - bool chain_interface::is_valid_account_name( const std::string& str )const { if( str.size() < BTS_BLOCKCHAIN_MIN_NAME_SIZE ) return false; @@ -200,15 +195,6 @@ namespace bts{ namespace blockchain { { set_property( accumulated_fees, variant(fees) ); } - share_type chain_interface::get_fee_rate()const - { - return get_property( current_fee_rate ).as_int64(); - } - - void chain_interface::set_fee_rate( share_type fees ) - { - set_property( current_fee_rate, variant(fees) ); - } map chain_interface::get_dirty_markets()const { @@ -219,6 +205,7 @@ namespace bts{ namespace blockchain { return map(); } } + void chain_interface::set_dirty_markets( const map& d ) { set_property( dirty_markets, fc::variant(d) ); diff --git a/libraries/blockchain/include/bts/blockchain/block.hpp b/libraries/blockchain/include/bts/blockchain/block.hpp index c5cfb92b5..b02647369 100644 --- a/libraries/blockchain/include/bts/blockchain/block.hpp +++ b/libraries/blockchain/include/bts/blockchain/block.hpp @@ -10,8 +10,6 @@ namespace bts { namespace blockchain { block_header():block_num(0){} - share_type next_fee( share_type prev_fee_rate, size_t block_size )const; - block_id_type previous; uint32_t block_num; fc::time_point_sec timestamp; diff --git a/libraries/blockchain/include/bts/blockchain/chain_interface.hpp b/libraries/blockchain/include/bts/blockchain/chain_interface.hpp index ccef27cd4..80cea9950 100644 --- a/libraries/blockchain/include/bts/blockchain/chain_interface.hpp +++ b/libraries/blockchain/include/bts/blockchain/chain_interface.hpp @@ -35,10 +35,9 @@ namespace bts { namespace blockchain { */ confirmation_requirement = 6, database_version = 7, // database version, to know when we need to upgrade - current_fee_rate = 8, // database version, to know when we need to upgrade - accumulated_fees = 9, // database version, to know when we need to upgrade - dirty_markets = 10, - last_feed_id = 11 // used for allocating new data feeds + accumulated_fees = 8, + dirty_markets = 9, + last_feed_id = 10 // used for allocating new data feeds }; typedef uint32_t chain_property_type; @@ -79,17 +78,12 @@ namespace bts { namespace blockchain { share_type get_accumulated_fees()const; void set_accumulated_fees( share_type fees ); - share_type get_fee_rate()const; - void set_fee_rate( share_type fees ); - - /** return the current fee rate in millishares */ virtual odelegate_slate get_delegate_slate( slate_id_type id )const = 0; virtual void store_delegate_slate( slate_id_type id, const delegate_slate& slate ) = 0; virtual share_type get_delegate_registration_fee()const; virtual share_type get_asset_registration_fee()const; - virtual share_type calculate_data_fee(size_t bytes) const; virtual int64_t get_required_confirmations()const; virtual fc::variant get_property( chain_property_enum property_id )const = 0; @@ -185,7 +179,6 @@ FC_REFLECT_ENUM( bts::blockchain::chain_property_enum, (chain_id) (confirmation_requirement) (database_version) - (current_fee_rate) (accumulated_fees) (dirty_markets) (last_feed_id) diff --git a/libraries/blockchain/include/bts/blockchain/config.hpp b/libraries/blockchain/include/bts/blockchain/config.hpp index e21233bbf..14ecce8de 100644 --- a/libraries/blockchain/include/bts/blockchain/config.hpp +++ b/libraries/blockchain/include/bts/blockchain/config.hpp @@ -11,7 +11,7 @@ */ #define BTS_BLOCKCHAIN_VERSION (109) #define BTS_WALLET_VERSION uint32_t(101) -#define BTS_BLOCKCHAIN_DATABASE_VERSION (123) +#define BTS_BLOCKCHAIN_DATABASE_VERSION (124) /** * The address prepended to string representation of @@ -125,16 +125,8 @@ /** defines the maximum block size allowed, 2 MB per hour */ #define BTS_BLOCKCHAIN_MAX_BLOCK_SIZE (10 * BTS_BLOCKCHAIN_AVERAGE_TRX_SIZE * BTS_BLOCKCHAIN_MAX_PENDING_QUEUE_SIZE ) -/** defines the target block size, fees will be adjusted to maintain this target */ -#define BTS_BLOCKCHAIN_TARGET_BLOCK_SIZE (BTS_BLOCKCHAIN_MAX_BLOCK_SIZE/2) - #define BTS_BLOCKCHAIN_INACTIVE_FEE_APR (10) // 10% per year -/** - * defines the min fee in milli-shares per byte - */ -#define BTS_BLOCKCHAIN_MIN_FEE (1000) - /** This constant defines the number of blocks a delegate must produce before they are expected to break even on registration costs with their earned income. diff --git a/libraries/blockchain/include/bts/blockchain/exceptions.hpp b/libraries/blockchain/include/bts/blockchain/exceptions.hpp index be9d6f99b..30d5420e7 100644 --- a/libraries/blockchain/include/bts/blockchain/exceptions.hpp +++ b/libraries/blockchain/include/bts/blockchain/exceptions.hpp @@ -26,13 +26,11 @@ namespace bts { namespace blockchain { FC_DECLARE_DERIVED_EXCEPTION( invalid_block_time, bts::blockchain::blockchain_exception, 30017, "invalid block time" ); FC_DECLARE_DERIVED_EXCEPTION( time_in_past, bts::blockchain::blockchain_exception, 30018, "time is in the past" ); FC_DECLARE_DERIVED_EXCEPTION( time_in_future, bts::blockchain::blockchain_exception, 30019, "time is in the future" ); - FC_DECLARE_DERIVED_EXCEPTION( invalid_fee_rate, bts::blockchain::blockchain_exception, 30020, "invalid fee rate" ); - FC_DECLARE_DERIVED_EXCEPTION( invalid_block_digest, bts::blockchain::blockchain_exception, 30021, "invalid block digest" ); - FC_DECLARE_DERIVED_EXCEPTION( invalid_delegate_signee, bts::blockchain::blockchain_exception, 30022, "invalid delegate signee" ); - FC_DECLARE_DERIVED_EXCEPTION( failed_checkpoint_verification, bts::blockchain::blockchain_exception, 30023, "failed checkpoint verification" ); - FC_DECLARE_DERIVED_EXCEPTION( wrong_chain_id, bts::blockchain::blockchain_exception, 30024, "wrong chain id" ); - FC_DECLARE_DERIVED_EXCEPTION( unknown_block, bts::blockchain::blockchain_exception, 30025, "unknown block" ); - + FC_DECLARE_DERIVED_EXCEPTION( invalid_block_digest, bts::blockchain::blockchain_exception, 30020, "invalid block digest" ); + FC_DECLARE_DERIVED_EXCEPTION( invalid_delegate_signee, bts::blockchain::blockchain_exception, 30021, "invalid delegate signee" ); + FC_DECLARE_DERIVED_EXCEPTION( failed_checkpoint_verification, bts::blockchain::blockchain_exception, 30022, "failed checkpoint verification" ); + FC_DECLARE_DERIVED_EXCEPTION( wrong_chain_id, bts::blockchain::blockchain_exception, 30023, "wrong chain id" ); + FC_DECLARE_DERIVED_EXCEPTION( unknown_block, bts::blockchain::blockchain_exception, 30024, "unknown block" ); FC_DECLARE_EXCEPTION( evaluation_error, 31000, "Evaluation Error" ); FC_DECLARE_DERIVED_EXCEPTION( negative_deposit, bts::blockchain::evaluation_error, 31001, "negative deposit" ); @@ -67,7 +65,6 @@ namespace bts { namespace blockchain { //FC_DECLARE_DERIVED_EXCEPTION( invalid_fire_operation, bts::blockchain::evaluation_error, 33001, "invalid fire operation" ); FC_DECLARE_DERIVED_EXCEPTION( not_a_delegate_signature, bts::blockchain::evaluation_error, 33002, "not delegates signature" ); - FC_DECLARE_DERIVED_EXCEPTION( invalid_vote_message_size, bts::blockchain::evaluation_error, 34001, "invalid vote message size" ); FC_DECLARE_DERIVED_EXCEPTION( unknown_proposal_id, bts::blockchain::evaluation_error, 34002, "unknown proposal id" ); diff --git a/libraries/blockchain/transaction_evaluation_state.cpp b/libraries/blockchain/transaction_evaluation_state.cpp index 139fbe1ec..8fb80131a 100644 --- a/libraries/blockchain/transaction_evaluation_state.cpp +++ b/libraries/blockchain/transaction_evaluation_state.cpp @@ -58,7 +58,7 @@ namespace bts { namespace blockchain { { auto asset_rec = _current_state->get_asset_record( asset_id_type() ); - for( auto del_vote : net_delegate_votes ) + for( const auto& del_vote : net_delegate_votes ) { auto del_rec = _current_state->get_account_record( del_vote.first ); FC_ASSERT( !!del_rec ); @@ -87,16 +87,9 @@ namespace bts { namespace blockchain { */ void transaction_evaluation_state::post_evaluate() { try { - // NOTE: this line was removed in favor of trusting delegates to set the required fees rather - // than charging per byte. This allows the network to scale without hard fork. - // - // By removing this check I am reducing restrictions so the current blockchain should still validate - // - // required_fees += asset(_current_state->calculate_data_fee(fc::raw::pack_size(trx)),0); - // Should this be here? We may not have fees in XTS now... balance[0]; // make sure we have something for this. - for( auto fee : balance ) + for( const auto& fee : balance ) { if( fee.second < 0 ) FC_CAPTURE_AND_THROW( negative_fee, (fee) ); // if the fee is already in XTS or the fee balance is zero, move along... @@ -114,8 +107,7 @@ namespace bts { namespace blockchain { } } - - for( auto fee : balance ) + for( const auto& fee : balance ) { if( fee.second < 0 ) FC_CAPTURE_AND_THROW( negative_fee, (fee) ); if( fee.second > 0 ) // if a fee was paid... @@ -131,8 +123,7 @@ namespace bts { namespace blockchain { } } - - for( auto required_deposit : required_deposits ) + for( const auto& required_deposit : required_deposits ) { auto provided_itr = provided_deposits.find( required_deposit.first ); @@ -175,7 +166,7 @@ namespace bts { namespace blockchain { if( !_skip_signature_check ) { auto digest = trx_arg.digest( _chain_id ); - for( auto sig : trx.signatures ) + for( const auto& sig : trx.signatures ) { auto key = fc::ecc::public_key( sig, digest ).serialize(); signed_keys.insert( address(key) ); @@ -185,7 +176,7 @@ namespace bts { namespace blockchain { signed_keys.insert( address(pts_address(key,true,0) ) ); } } - for( auto op : trx.operations ) + for( const auto& op : trx.operations ) { evaluate_operation( op ); } @@ -211,7 +202,7 @@ namespace bts { namespace blockchain { { auto slate = _current_state->get_delegate_slate( slate_id ); if( !slate ) FC_CAPTURE_AND_THROW( unknown_delegate_slate, (slate_id) ); - for( auto delegate_id : slate->supported_delegates ) + for( const auto& delegate_id : slate->supported_delegates ) { if( BTS_BLOCKCHAIN_ENABLE_NEGATIVE_VOTES && delegate_id < signed_int(0) ) net_delegate_votes[abs(delegate_id)].votes_for -= amount; diff --git a/libraries/client/client.cpp b/libraries/client/client.cpp index ab236eca9..3b3b73462 100644 --- a/libraries/client/client.cpp +++ b/libraries/client/client.cpp @@ -2577,12 +2577,10 @@ config load_config( const fc::path& datadir ) info["genesis_timestamp"] = _chain_db->get_genesis_timestamp(); info["block_interval"] = BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; - info["target_block_size"] = BTS_BLOCKCHAIN_TARGET_BLOCK_SIZE; info["max_block_size"] = BTS_BLOCKCHAIN_MAX_BLOCK_SIZE; info["max_blockchain_size"] = BTS_BLOCKCHAIN_MAX_SIZE; info["address_prefix"] = BTS_ADDRESS_PREFIX; - info["min_block_fee"] = BTS_BLOCKCHAIN_MIN_FEE / double( 1000 ); info["inactivity_fee_apr"] = BTS_BLOCKCHAIN_INACTIVE_FEE_APR; info["priority_fee"] = _chain_db->get_priority_fee(); From d17ac54b894621e752f2a093d9514beadcd44bae Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 17:51:31 -0400 Subject: [PATCH 17/32] Separate transaction relay fee and wallet transaction fee --- libraries/api/wallet_api.json | 8 +- libraries/blockchain/chain_database.cpp | 158 +++++++++--------- .../include/bts/blockchain/chain_database.hpp | 4 +- .../include/bts/blockchain/config.hpp | 44 +++-- .../include/bts/blockchain/exceptions.hpp | 3 +- libraries/cli/cli.cpp | 2 +- libraries/cli/pretty.cpp | 10 +- libraries/client/client.cpp | 14 +- libraries/net/include/bts/net/config.hpp | 8 +- libraries/net/include/bts/net/exceptions.hpp | 6 +- libraries/net/node.cpp | 6 +- .../wallet/include/bts/wallet/config.hpp | 13 +- .../wallet/include/bts/wallet/wallet.hpp | 4 +- libraries/wallet/wallet.cpp | 65 +++---- 14 files changed, 173 insertions(+), 172 deletions(-) diff --git a/libraries/api/wallet_api.json b/libraries/api/wallet_api.json index 9470f43a4..9b20bd655 100644 --- a/libraries/api/wallet_api.json +++ b/libraries/api/wallet_api.json @@ -968,18 +968,18 @@ "aliases" : ["pay_delegate"] }, { - "method_name" : "wallet_set_priority_fee", - "description" : "Set the priority fee to add to new transactions", + "method_name" : "wallet_set_transaction_fee", + "description" : "Set the fee to add to new transactions", "return_type" : "asset", "parameters" : [ { "name" : "fee", "type" : "real_amount", - "description" : "the wallet priority fee to set" + "description" : "the wallet transaction fee to set" } ], "prerequisites" : ["wallet_open"], - "aliases" : ["set_priority_fee", "settrxfee"] + "aliases" : ["wallet_set_priority_fee", "set_priority_fee", "settrxfee", "setfee", "set_fee"] }, { "method_name" : "wallet_market_submit_bid", diff --git a/libraries/blockchain/chain_database.cpp b/libraries/blockchain/chain_database.cpp index 2b649329b..59698d433 100644 --- a/libraries/blockchain/chain_database.cpp +++ b/libraries/blockchain/chain_database.cpp @@ -75,7 +75,7 @@ namespace bts { namespace blockchain { public: chain_database_impl():self(nullptr){} - #include "market_engine.cpp" + #include "market_engine.cpp" digest_type initialize_genesis( const optional& genesis_file, bool chain_id_only = false ); @@ -91,7 +91,7 @@ namespace bts { namespace blockchain { void apply_transactions( const signed_block_header& block, const std::vector&, const pending_chain_state_ptr& ); - void pay_delegate( const block_id_type& block_id, + void pay_delegate( const block_id_type& block_id, const pending_chain_state_ptr&, const public_key_type& block_signee ); void save_undo_state( const block_id_type& id, @@ -124,11 +124,11 @@ namespace bts { namespace blockchain { auto trx = itr.value(); auto trx_id = trx.id(); try { - auto eval_state = self->evaluate_transaction( trx, _priority_fee ); + auto eval_state = self->evaluate_transaction( trx, _relay_fee ); share_type fees = eval_state->get_fees(); _pending_fee_index[ fee_index( fees, trx_id ) ] = eval_state; _pending_transaction_db.store( trx_id, trx ); - } + } catch ( const fc::exception& e ) { trx_to_discard.push_back(trx_id); @@ -143,7 +143,7 @@ namespace bts { namespace blockchain { } fc::future _revalidate_pending; fc::mutex _push_block_mutex; - + /** * Used to track the cumulative effect of all pending transactions that are known, * new incomming transactions are evaluated relative to this state. @@ -157,7 +157,7 @@ namespace bts { namespace blockchain { unordered_set _observers; digest_type _chain_id; bool _skip_signature_verification; - share_type _priority_fee; + share_type _relay_fee; bts::db::level_map > _market_transactions_db; bts::db::level_map _slate_db; @@ -249,7 +249,7 @@ namespace bts { namespace blockchain { } else if( database_version && !database_version->is_null() && database_version->as_int64() > BTS_BLOCKCHAIN_DATABASE_VERSION ) { - FC_CAPTURE_AND_THROW( new_database_version, (database_version)(BTS_BLOCKCHAIN_DATABASE_VERSION) ); + FC_CAPTURE_AND_THROW( new_database_version, (database_version)(BTS_BLOCKCHAIN_DATABASE_VERSION) ); } _market_transactions_db.open( data_dir / "index/market_transactions_db" ); _fork_number_db.open( data_dir / "index/fork_number_db" ); @@ -314,12 +314,12 @@ namespace bts { namespace blockchain { _pending_fee_index.clear(); - // this schedules the revalidate-pending-transactions task to execute in this thread + // this schedules the revalidate-pending-transactions task to execute in this thread // as soon as this current task (probably pushing a block) gets around to yielding. // This was changed from waiting on the old _revalidate_pending to prevent yielding // during the middle of pushing a block. If that happens, the database is in an // inconsistent state and it confuses the p2p network code. - if( !_revalidate_pending.valid() || _revalidate_pending.ready() ) + if( !_revalidate_pending.valid() || _revalidate_pending.ready() ) _revalidate_pending = fc::async( [=](){ revalidate_pending(); }, "revalidate_pending" ); _pending_trx_state = std::make_shared( self->shared_from_this() ); @@ -439,7 +439,7 @@ namespace bts { namespace blockchain { else { elog( " we don't know about its previous: ${p}", ("p",block_data.previous) ); - + // create it... we do not know about the previous block so // we must create it and assume it is not linked... prev_fork_data.next_blocks.insert(block_id); @@ -538,7 +538,7 @@ namespace bts { namespace blockchain { //ilog( "evaluation: ${e}", ("e",*trx_eval_state) ); // TODO: capture the evaluation state with a callback for wallets... // summary.transaction_states.emplace_back( std::move(trx_eval_state) ); - + transaction_location trx_loc( block.block_num, trx_num ); //ilog( "store trx location: ${loc}", ("loc",trx_loc) ); @@ -596,7 +596,7 @@ namespace bts { namespace blockchain { auto old_id = self->get_block_id( block_num - BTS_BLOCKCHAIN_MAX_UNDO_HISTORY ); try { _undo_state_db.remove( old_id ); - } + } catch( const fc::key_not_found_exception& ) { // ignore this... @@ -717,24 +717,24 @@ namespace bts { namespace blockchain { pending_state->set_property( confirmation_requirement, required_confirmations ); } - void chain_database_impl::update_random_seed( secret_hash_type new_secret, + void chain_database_impl::update_random_seed( secret_hash_type new_secret, const pending_chain_state_ptr& pending_state ) { auto current_seed = pending_state->get_current_random_seed(); fc::sha512::encoder enc; fc::raw::pack( enc, new_secret ); fc::raw::pack( enc, current_seed ); - pending_state->set_property( last_random_seed_id, + pending_state->set_property( last_random_seed_id, fc::variant(fc::ripemd160::hash( enc.result() )) ); } - - void chain_database_impl::update_active_delegate_list( const full_block& block_data, + + void chain_database_impl::update_active_delegate_list( const full_block& block_data, const pending_chain_state_ptr& pending_state ) { if( block_data.block_num % BTS_BLOCKCHAIN_NUM_DELEGATES == 0 ) { // perform a random shuffle of the sorted delegate list. - + auto active_del = self->next_round_active_delegates(); auto rand_seed = fc::sha256::hash(self->get_current_random_seed()); size_t num_del = active_del.size(); @@ -749,7 +749,7 @@ namespace bts { namespace blockchain { } } void chain_database_impl::execute_markets( const fc::time_point_sec& timestamp, const pending_chain_state_ptr& pending_state ) - { try { + { try { elog( "execute markets ${e}", ("e", pending_state->get_dirty_markets()) ); map collected_fees; @@ -757,11 +757,11 @@ namespace bts { namespace blockchain { vector market_transactions; // = pending_state.market_transactions; for( const auto& market_pair : pending_state->get_dirty_markets() ) { - FC_ASSERT( market_pair.first > market_pair.second ) + FC_ASSERT( market_pair.first > market_pair.second ) market_engine engine( pending_state, *this ); engine.execute( market_pair.first, market_pair.second, timestamp ); market_transactions.insert( market_transactions.end(), engine._market_transactions.begin(), engine._market_transactions.end() ); - } + } ilog( "market trxs: ${trx}", ("trx", fc::json::to_pretty_string( market_transactions ) ) ); pending_state->set_dirty_markets( pending_state->_dirty_markets ); pending_state->set_market_transactions( std::move( market_transactions ) ); @@ -804,7 +804,7 @@ namespace bts { namespace blockchain { // apply any deterministic operations such as market operations before we perturb indexes //apply_deterministic_updates(pending_state); - + pay_delegate( block_id, pending_state, block_signee ); apply_transactions( block_data, block_data.user_transactions, pending_state ); @@ -842,7 +842,7 @@ namespace bts { namespace blockchain { // just in case something changes while calling observer for( const auto& o : _observers ) { - try { + try { ilog( "... block applied ... " ); //Schedule the observer notifications for later; the chain is in a //non-premptable state right now, and observers may yield. @@ -858,7 +858,7 @@ namespace bts { namespace blockchain { * Traverse the previous links of all blocks in fork until we find one that is_included * * The last item in the result will be the only block id that is already included in - * the blockchain. + * the blockchain. */ std::vector chain_database_impl::get_fork_history( const block_id_type& id ) { try { @@ -879,7 +879,7 @@ namespace bts { namespace blockchain { } auto prev_fork_data = _fork_db.fetch( header.previous ); - /// this shouldn't happen if the database invariants are properly maintained + /// this shouldn't happen if the database invariants are properly maintained FC_ASSERT( prev_fork_data.is_linked, "we hit a dead end, this fork isn't really linked!" ); if( prev_fork_data.is_included ) { @@ -926,7 +926,7 @@ namespace bts { namespace blockchain { { my->self = this; my->_skip_signature_verification = true; - my->_priority_fee = BTS_BLOCKCHAIN_DEFAULT_PRIORITY_FEE; + my->_relay_fee = BTS_BLOCKCHAIN_DEFAULT_RELAY_FEE; } chain_database::~chain_database() @@ -1050,7 +1050,7 @@ namespace bts { namespace blockchain { auto trx = pending_itr.value(); wlog( " laoding pending transaction ${trx}", ("trx",trx) ); auto trx_id = trx.id(); - auto eval_state = evaluate_transaction( trx, my->_priority_fee ); + auto eval_state = evaluate_transaction( trx, my->_relay_fee ); share_type fees = eval_state->get_fees(); my->_pending_fee_index[ fee_index( fees, trx_id ) ] = eval_state; my->_pending_transaction_db.store( trx_id, trx ); @@ -1178,7 +1178,7 @@ namespace bts { namespace blockchain { trx_eval_state->evaluate( trx ); auto fees = trx_eval_state->get_fees(); if( fees < required_fees ) - FC_CAPTURE_AND_THROW( insufficient_priority_fee, (fees)(required_fees) ); + FC_CAPTURE_AND_THROW( insufficient_relay_fee, (fees)(required_fees) ); // apply changes from this transaction to _pending_trx_state pend_state->apply_changes(); @@ -1196,7 +1196,7 @@ namespace bts { namespace blockchain { eval_state->evaluate( transaction ); auto fees = eval_state->get_fees(); if( fees < min_fee ) - FC_CAPTURE_AND_THROW( insufficient_priority_fee, (fees)(min_fee) ); + FC_CAPTURE_AND_THROW( insufficient_relay_fee, (fees)(min_fee) ); } catch( fc::exception& e ) { @@ -1285,7 +1285,7 @@ namespace bts { namespace blockchain { // this method is not re-entrant. fc::unique_lock lock( my->_push_block_mutex ); - // The above check probably isn't enough. We need to make certain that + // The above check probably isn't enough. We need to make certain that // no other code sees the chain_database in an inconsistent state. // The lock above prevents two push_blocks from happening at the same time, // but we also need to ensure the wallet, blockchain, delegate, &c. loops don't @@ -1354,7 +1354,7 @@ namespace bts { namespace blockchain { auto itr = my->_asset_db.find( id ); if( itr.valid() ) { - return itr.value(); + return itr.value(); } return oasset_record(); } @@ -1388,7 +1388,7 @@ namespace bts { namespace blockchain { { try { return get_asset_record(symbol).valid(); } FC_CAPTURE_AND_RETHROW( (symbol) ) } - + oasset_record chain_database::get_asset_record( const string& symbol )const { try { auto symbol_id_itr = my->_symbol_index_db.find( symbol ); @@ -1451,7 +1451,7 @@ namespace bts { namespace blockchain { { ++itr; } - my->_delegate_vote_index_db.remove( vote_del( old_rec->net_votes(), + my->_delegate_vote_index_db.remove( vote_del( old_rec->net_votes(), record_to_store.id ) ); itr = my->_delegate_vote_index_db.begin(); while( itr.valid() ) @@ -1473,7 +1473,7 @@ namespace bts { namespace blockchain { if( old_rec.valid() && old_rec->is_delegate() ) { - my->_delegate_vote_index_db.remove( vote_del( old_rec->net_votes(), + my->_delegate_vote_index_db.remove( vote_del( old_rec->net_votes(), record_to_store.id ) ); } @@ -1481,7 +1481,7 @@ namespace bts { namespace blockchain { if( record_to_store.is_delegate() ) { my->_delegate_vote_index_db.store( vote_del( record_to_store.net_votes(), - record_to_store.id ), + record_to_store.id ), 0/*dummy value*/ ); } } @@ -1513,7 +1513,7 @@ namespace bts { namespace blockchain { FC_ASSERT( trx_rec->trx.id() == trx_id,"", ("trx_rec->id",trx_rec->trx.id()) ); return trx_rec; } - + ilog( "... lower bound...?" ); auto itr = my->_id_to_transaction_record_db.lower_bound( trx_id ); if( itr.valid() ) @@ -1528,8 +1528,8 @@ namespace bts { namespace blockchain { return otransaction_record(); } FC_CAPTURE_AND_RETHROW( (trx_id)(exact) ) } - void chain_database::store_transaction( const transaction_id_type& record_id, - const transaction_record& record_to_store ) + void chain_database::store_transaction( const transaction_id_type& record_id, + const transaction_record& record_to_store ) { try { if( record_to_store.trx.operations.size() == 0 ) { @@ -1582,21 +1582,21 @@ namespace bts { namespace blockchain { auto current_itr = my->_pending_transaction_db.find( trx_id ); if( current_itr.valid() ) return nullptr; - share_type priority_fee = my->_priority_fee; + share_type relay_fee = my->_relay_fee; if( !override_limits ) { if( my->_pending_fee_index.size() > BTS_BLOCKCHAIN_MAX_PENDING_QUEUE_SIZE ) { auto overage = my->_pending_fee_index.size() - BTS_BLOCKCHAIN_MAX_PENDING_QUEUE_SIZE; - priority_fee = my->_priority_fee * overage * overage; + relay_fee = my->_relay_fee * overage * overage; } } - auto eval_state = evaluate_transaction( trx, priority_fee ); + auto eval_state = evaluate_transaction( trx, relay_fee ); share_type fees = eval_state->get_fees(); - //if( fees < my->_priority_fee ) - // FC_CAPTURE_AND_THROW( insufficient_priority_fee, (fees)(my->_priority_fee) ); + //if( fees < my->_relay_fee ) + // FC_CAPTURE_AND_THROW( insufficient_relay_fee, (fees)(my->_relay_fee) ); my->_pending_fee_index[ fee_index( fees, trx_id ) ] = eval_state; my->_pending_transaction_db.store( trx_id, trx ); @@ -1863,7 +1863,7 @@ namespace bts { namespace blockchain { } optional chain_database::get_block_fork_data( const block_id_type& id )const { - return my->_fork_db.fetch_optional(id); + return my->_fork_db.fetch_optional(id); } uint32_t chain_database::get_block_num( const block_id_type& block_id )const @@ -1925,9 +1925,9 @@ namespace bts { namespace blockchain { FC_ASSERT( start_block >= 0 ); FC_ASSERT( end_block >= start_block ); std::stringstream out; - out << "digraph G { \n"; + out << "digraph G { \n"; out << "rankdir=LR;\n"; - + bool first = true; fc::time_point_sec start_time; std::map > nodes_by_rank; @@ -1985,7 +1985,7 @@ namespace bts { namespace blockchain { out << "l" << item.first; } out << ";\n"; - out << "}"; + out << "}"; if( filename == "" ) return out.str(); @@ -2037,7 +2037,7 @@ namespace bts { namespace blockchain { throw; } } - + return fork_blocks; } @@ -2058,7 +2058,7 @@ namespace bts { namespace blockchain { return my->_property_db.fetch( property_id ); } FC_RETHROW_EXCEPTIONS( warn, "", ("property_id",property_id) ) } - void chain_database::set_property( chain_property_enum property_id, + void chain_database::set_property( chain_property_enum property_id, const fc::variant& property_value ) { if( property_value.is_null() ) @@ -2083,7 +2083,7 @@ namespace bts { namespace blockchain { { return my->_proposal_db.fetch_optional(id); } - + void chain_database::store_proposal_vote( const proposal_vote& r ) { if( r.is_null() ) @@ -2188,14 +2188,14 @@ namespace bts { namespace blockchain { return my->_bid_db.fetch_optional(key); } - omarket_order chain_database::get_lowest_ask_record( asset_id_type quote_id, asset_id_type base_id ) + omarket_order chain_database::get_lowest_ask_record( asset_id_type quote_id, asset_id_type base_id ) { omarket_order result; auto itr = my->_ask_db.lower_bound( market_index_key( price(0,quote_id,base_id) ) ); if( itr.valid() ) { auto market_index = itr.key(); - if( market_index.order_price.quote_asset_id == quote_id && + if( market_index.order_price.quote_asset_id == quote_id && market_index.order_price.base_asset_id == base_id ) return market_order( ask_order, market_index, itr.value() ); } @@ -2216,8 +2216,8 @@ namespace bts { namespace blockchain { { return my->_collateral_db.fetch_optional(key); } - - void chain_database::store_bid_record( const market_index_key& key, const order_record& order ) + + void chain_database::store_bid_record( const market_index_key& key, const order_record& order ) { if( order.is_null() ) my->_bid_db.remove( key ); @@ -2225,7 +2225,7 @@ namespace bts { namespace blockchain { my->_bid_db.store( key, order ); } - void chain_database::store_ask_record( const market_index_key& key, const order_record& order ) + void chain_database::store_ask_record( const market_index_key& key, const order_record& order ) { wlog( "STORE ASK ${k} ${o}", ("k",key)("o",order) ); if( order.is_null() ) @@ -2242,11 +2242,11 @@ namespace bts { namespace blockchain { my->_short_db.store( key, order ); } - void chain_database::store_collateral_record( const market_index_key& key, const collateral_record& collateral ) + void chain_database::store_collateral_record( const market_index_key& key, const collateral_record& collateral ) { if( collateral.is_null() ) my->_collateral_db.remove( key ); - else + else my->_collateral_db.store( key, collateral ); } @@ -2289,10 +2289,10 @@ namespace bts { namespace blockchain { ++aitr; } -// FC_ASSERT( total_votes == total.amount, "", +// FC_ASSERT( total_votes == total.amount, "", // ("total_votes",total_votes) // ("total_shares",total) ); - + auto ar = get_asset_record( asset_id_type(0) ); FC_ASSERT( ar.valid() ); FC_ASSERT( ar->current_share_supply == total.amount, "", ("ar",ar)("total",total)("delta",ar->current_share_supply-total.amount) ); @@ -2316,12 +2316,12 @@ namespace bts { namespace blockchain { } else if( head_num < BTS_BLOCKCHAIN_NUM_DELEGATES ) { - // what percent of the maximum total blocks that could have been produced + // what percent of the maximum total blocks that could have been produced // have been produced. const auto expected_blocks = (now - get_block_header( 1 ).timestamp).to_seconds() / BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; return 100*double( head_num ) / expected_blocks; } - else + else { // if 10*N blocks ago is longer than 10*N*INTERVAL_SEC ago then we missed blocks, calculate // in terms of percentage time rather than percentage blocks. @@ -2340,8 +2340,8 @@ namespace bts { namespace blockchain { return optional(); } FC_CAPTURE_AND_RETHROW( (key) ) } - vector chain_database::get_market_bids( const string& quote_symbol, - const string& base_symbol, + vector chain_database::get_market_bids( const string& quote_symbol, + const string& base_symbol, uint32_t limit ) { try { auto quote_asset_id = get_asset_id( quote_symbol ); @@ -2362,7 +2362,7 @@ namespace bts { namespace blockchain { else break; - if( results.size() == limit ) + if( results.size() == limit ) return results; ++market_itr; @@ -2379,7 +2379,7 @@ namespace bts { namespace blockchain { return optional(); } FC_CAPTURE_AND_RETHROW( (key) ) } - vector chain_database::get_market_shorts( const string& quote_symbol, + vector chain_database::get_market_shorts( const string& quote_symbol, uint32_t limit ) { try { auto quote_asset_id = get_asset_id( quote_symbol ); @@ -2403,7 +2403,7 @@ namespace bts { namespace blockchain { break; } - if( results.size() == limit ) + if( results.size() == limit ) return results; ++market_itr; @@ -2427,9 +2427,9 @@ namespace bts { namespace blockchain { if( key.order_price.quote_asset_id == quote_asset_id && key.order_price.base_asset_id == base_asset_id ) { - results.push_back( {cover_order, - key, - order_record(market_itr.value().payoff_balance), + results.push_back( {cover_order, + key, + order_record(market_itr.value().payoff_balance), market_itr.value().collateral_balance } ); } else @@ -2437,7 +2437,7 @@ namespace bts { namespace blockchain { break; } - if( results.size() == limit ) + if( results.size() == limit ) return results; ++market_itr; @@ -2455,8 +2455,8 @@ namespace bts { namespace blockchain { return optional(); } FC_CAPTURE_AND_RETHROW( (key) ) } - vector chain_database::get_market_asks( const string& quote_symbol, - const string& base_symbol, + vector chain_database::get_market_asks( const string& quote_symbol, + const string& base_symbol, uint32_t limit ) { try { auto quote_asset_id = get_asset_id( quote_symbol ); @@ -2479,7 +2479,7 @@ namespace bts { namespace blockchain { break; } - if( results.size() == limit ) + if( results.size() == limit ) return results; ++market_itr; @@ -2498,7 +2498,7 @@ namespace bts { namespace blockchain { return my->_slate_db.fetch_optional( id ); } - void chain_database::store_delegate_slate( slate_id_type id, const delegate_slate& slate ) + void chain_database::store_delegate_slate( slate_id_type id, const delegate_slate& slate ) { if( slate.supported_delegates.size() == 0 ) my->_slate_db.remove( id ); @@ -2589,14 +2589,14 @@ namespace bts { namespace blockchain { my->_skip_signature_verification = state; } - void chain_database::set_priority_fee( share_type shares ) + void chain_database::set_relay_fee( share_type shares ) { - my->_priority_fee = shares; + my->_relay_fee = shares; } - share_type chain_database::get_priority_fee() + share_type chain_database::get_relay_fee() { - return my->_priority_fee; + return my->_relay_fee; } void chain_database::set_market_transactions( vector trxs ) @@ -2626,7 +2626,7 @@ namespace bts { namespace blockchain { } ofeed_record chain_database::get_feed( const feed_index& i )const - { + { return my->_feed_db.fetch_optional( i ); } @@ -2655,7 +2655,7 @@ namespace bts { namespace blockchain { prices.pop_back(); } } - } + } catch ( ... ) { // we want to catch any exceptions caused attempted to interpret value as a price and simply ignore // the data feed... diff --git a/libraries/blockchain/include/bts/blockchain/chain_database.hpp b/libraries/blockchain/include/bts/blockchain/chain_database.hpp index fc5012fa7..72dba4be9 100644 --- a/libraries/blockchain/include/bts/blockchain/chain_database.hpp +++ b/libraries/blockchain/include/bts/blockchain/chain_database.hpp @@ -98,8 +98,8 @@ namespace bts { namespace blockchain { void add_observer( chain_observer* observer ); void remove_observer( chain_observer* observer ); - void set_priority_fee( share_type shares ); - share_type get_priority_fee(); + void set_relay_fee( share_type shares ); + share_type get_relay_fee(); void sanity_check()const; diff --git a/libraries/blockchain/include/bts/blockchain/config.hpp b/libraries/blockchain/include/bts/blockchain/config.hpp index 14ecce8de..6d6f10dd4 100644 --- a/libraries/blockchain/include/bts/blockchain/config.hpp +++ b/libraries/blockchain/include/bts/blockchain/config.hpp @@ -3,15 +3,14 @@ #include /* Set to true only for test network */ -#define BTS_TEST_NETWORK (true) -#define BTS_TEST_NETWORK_VERSION (16) +#define BTS_TEST_NETWORK true +#define BTS_TEST_NETWORK_VERSION 16 /** @file bts/blockchain/config.hpp * @brief Defines global constants that determine blockchain behavior */ -#define BTS_BLOCKCHAIN_VERSION (109) -#define BTS_WALLET_VERSION uint32_t(101) -#define BTS_BLOCKCHAIN_DATABASE_VERSION (124) +#define BTS_BLOCKCHAIN_VERSION 109 +#define BTS_BLOCKCHAIN_DATABASE_VERSION 124 /** * The address prepended to string representation of @@ -23,29 +22,28 @@ #define BTS_BLOCKCHAIN_SYMBOL "XTS" #define BTS_BLOCKCHAIN_NAME "BitShares XTS" #define BTS_BLOCKCHAIN_DESCRIPTION "BitShares X Test Network" -#define BTS_BLOCKCHAIN_PRECISION (100000) +#define BTS_BLOCKCHAIN_PRECISION 100000 #define BTS_BLOCKCHAIN_MAX_TRANSACTION_EXPIRATION_SEC (60*60*24*2) #define BTS_BLOCKCHAIN_DEFAULT_TRANSACTION_EXPIRATION_SEC (60*60*2) -#define BTS_BLOCKCHAIN_ENABLE_NEGATIVE_VOTES (false) - -#define BTS_BLOCKCHAIN_DEFAULT_PRIORITY_FEE (10000) // XTS +#define BTS_BLOCKCHAIN_DEFAULT_RELAY_FEE 10000 // XTS /** * The number of delegates that the blockchain is designed to support */ -#define BTS_BLOCKCHAIN_NUM_DELEGATES (101) -#define BTS_BLOCKCHAIN_MAX_SLATE_SIZE (BTS_BLOCKCHAIN_NUM_DELEGATES) +#define BTS_BLOCKCHAIN_NUM_DELEGATES 101 +#define BTS_BLOCKCHAIN_MAX_SLATE_SIZE BTS_BLOCKCHAIN_NUM_DELEGATES #define BTS_BLOCKCHAIN_MIN_FEEDS 3 // ((BTS_BLOCKCHAIN_NUM_DELEGATES/2) + 1) #define BTS_BLOCKCHAIN_MAX_UNDO_HISTORY (BTS_BLOCKCHAIN_NUM_DELEGATES*4) +#define BTS_BLOCKCHAIN_ENABLE_NEGATIVE_VOTES false /** * To prevent a delegate from producing blocks on split network, * we check the connection count. This means no blocks get produced * until at least a minimum number of clients are on line. */ -#define BTS_MIN_DELEGATE_CONNECTION_COUNT (5) +#define BTS_MIN_DELEGATE_CONNECTION_COUNT 1 /** * Defines the number of seconds that should elapse between blocks @@ -63,13 +61,13 @@ * Adjusting this value will change the effective fee charged on transactions */ #define BTS_BLOCKCHAIN_MAX_SIZE (1024*1024*1024*int64_t(100)) // 100 GB -#define BTS_BLOCKCHAIN_MIN_NAME_SIZE (1) -#define BTS_BLOCKCHAIN_MAX_NAME_SIZE (63) +#define BTS_BLOCKCHAIN_MIN_NAME_SIZE 1 +#define BTS_BLOCKCHAIN_MAX_NAME_SIZE 63 #define BTS_BLOCKCHAIN_MAX_NAME_DATA_SIZE (1024*64) -#define BTS_BLOCKCHAIN_MAX_MEMO_SIZE (19) // bytes -#define BTS_BLOCKCHAIN_MAX_SYMBOL_SIZE (5) // characters -#define BTS_BLOCKCHAIN_MIN_SYMBOL_SIZE (3) // characters -#define BTS_BLOCKCHAIN_PROPOSAL_VOTE_MESSAGE_MAX_SIZE (1024) // bytes +#define BTS_BLOCKCHAIN_MAX_MEMO_SIZE 19 // bytes +#define BTS_BLOCKCHAIN_MAX_SYMBOL_SIZE 5 // characters +#define BTS_BLOCKCHAIN_MIN_SYMBOL_SIZE 3 // characters +#define BTS_BLOCKCHAIN_PROPOSAL_VOTE_MESSAGE_MAX_SIZE 1024 // bytes /** * The maximum amount that can be issued for user assets. @@ -85,7 +83,7 @@ * Initial shares read from the genesis block are scaled to this number. It is divided * by 100 so that new shares may be issued without exceeding BTS_BLOCKCHAIN_MAX_SHARES */ -#define BTS_BLOCKCHAIN_INITIAL_SHARES (BTS_BLOCKCHAIN_MAX_SHARES / 5) +#define BTS_BLOCKCHAIN_INITIAL_SHARES (BTS_BLOCKCHAIN_MAX_SHARES/5) /** * How much XTS must be allocated between the short/ask sides of the market before @@ -118,14 +116,14 @@ */ #define BTS_BLOCKCHAIN_BLOCKS_PER_YEAR (BTS_BLOCKCHAIN_BLOCKS_PER_DAY*int64_t(365)) -#define BTS_BLOCKCHAIN_AVERAGE_TRX_SIZE (512) // just a random assumption used to calibrate TRX per SEC -#define BTS_BLOCKCHAIN_MAX_TRX_PER_SECOND (1) // (10) -#define BTS_BLOCKCHAIN_MAX_PENDING_QUEUE_SIZE (10) // (BTS_BLOCKCHAIN_MAX_TRX_PER_SECOND * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC) +#define BTS_BLOCKCHAIN_AVERAGE_TRX_SIZE 512 // just a random assumption used to calibrate TRX per SEC +#define BTS_BLOCKCHAIN_MAX_TRX_PER_SECOND 1 // (10) +#define BTS_BLOCKCHAIN_MAX_PENDING_QUEUE_SIZE 10 // (BTS_BLOCKCHAIN_MAX_TRX_PER_SECOND * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC) /** defines the maximum block size allowed, 2 MB per hour */ #define BTS_BLOCKCHAIN_MAX_BLOCK_SIZE (10 * BTS_BLOCKCHAIN_AVERAGE_TRX_SIZE * BTS_BLOCKCHAIN_MAX_PENDING_QUEUE_SIZE ) -#define BTS_BLOCKCHAIN_INACTIVE_FEE_APR (10) // 10% per year +#define BTS_BLOCKCHAIN_INACTIVE_FEE_APR 10 // 10% per year /** This constant defines the number of blocks a delegate must produce before diff --git a/libraries/blockchain/include/bts/blockchain/exceptions.hpp b/libraries/blockchain/include/bts/blockchain/exceptions.hpp index 30d5420e7..039b6f7d6 100644 --- a/libraries/blockchain/include/bts/blockchain/exceptions.hpp +++ b/libraries/blockchain/include/bts/blockchain/exceptions.hpp @@ -82,8 +82,7 @@ namespace bts { namespace blockchain { FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, bts::blockchain::evaluation_error, 36002, "insufficient fee" ); FC_DECLARE_DERIVED_EXCEPTION( negative_fee, bts::blockchain::evaluation_error, 36003, "negative fee" ); FC_DECLARE_DERIVED_EXCEPTION( missing_deposit, bts::blockchain::evaluation_error, 36004, "missing deposit" ); - FC_DECLARE_DERIVED_EXCEPTION( insufficient_priority_fee, bts::blockchain::evaluation_error, 36005, "insufficient priority fee" ); - + FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, bts::blockchain::evaluation_error, 36005, "insufficient relay fee" ); FC_DECLARE_DERIVED_EXCEPTION( invalid_market, bts::blockchain::evaluation_error, 37001, "invalid market" ); FC_DECLARE_DERIVED_EXCEPTION( unknown_market_order, bts::blockchain::evaluation_error, 37002, "unknown market order" ); diff --git a/libraries/cli/cli.cpp b/libraries/cli/cli.cpp index 4cf269ca3..46fa08a96 100644 --- a/libraries/cli/cli.cpp +++ b/libraries/cli/cli.cpp @@ -1141,7 +1141,7 @@ namespace bts { namespace cli { *_out << "\n"; } } - else if( method_name == "wallet_set_priority_fee" ) + else if( method_name == "wallet_set_transaction_fee" ) { const auto fee = result.as(); *_out << _client->get_chain()->to_pretty_asset( fee ) << "\n"; diff --git a/libraries/cli/pretty.cpp b/libraries/cli/pretty.cpp index fbcca63be..0b7b53392 100644 --- a/libraries/cli/pretty.cpp +++ b/libraries/cli/pretty.cpp @@ -182,8 +182,8 @@ string pretty_blockchain_info( fc::mutable_variant_object info, cptr client ) const auto inactivity_fee = info["inactivity_fee_apr"].as(); info["inactivity_fee_apr"] = client->get_chain()->to_pretty_asset( asset( inactivity_fee ) ); - const auto priority_fee = info["priority_fee"].as(); - info["priority_fee"] = client->get_chain()->to_pretty_asset( asset( priority_fee ) ); + const auto relay_fee = info["relay_fee"].as(); + info["relay_fee"] = client->get_chain()->to_pretty_asset( asset( relay_fee ) ); const auto delegate_reg_fee = info["delegate_reg_fee"].as(); info["delegate_reg_fee"] = client->get_chain()->to_pretty_asset( asset( delegate_reg_fee ) ); @@ -223,10 +223,10 @@ string pretty_wallet_info( fc::mutable_variant_object info, cptr client ) info["scan_progress"] = pretty_percent( scan_progress, 1 ); } - if( !info["priority_fee"].is_null() ) + if( !info["transaction_fee"].is_null() ) { - const auto priority_fee = info["priority_fee"].as(); - info["priority_fee"] = client->get_chain()->to_pretty_asset( priority_fee ); + const auto transaction_fee = info["transaction_fee"].as(); + info["transaction_fee"] = client->get_chain()->to_pretty_asset( transaction_fee ); } out << fc::json::to_pretty_string( info ) << "\n"; diff --git a/libraries/client/client.cpp b/libraries/client/client.cpp index 3b3b73462..ab5f308db 100644 --- a/libraries/client/client.cpp +++ b/libraries/client/client.cpp @@ -1139,11 +1139,9 @@ config load_config( const fc::path& datadir ) } return false; } - catch (const bts::blockchain::insufficient_priority_fee& original_exception) + catch (const bts::blockchain::insufficient_relay_fee& original_exception) { - // was just going to FC_THROW_EXCEPTION(bts::net::insufficient_priority_fee, (original_exception)); - // but I get errors with reflection? - FC_THROW_EXCEPTION(bts::net::insufficient_priority_fee, "Insufficient priority fee, do not propagate.", + FC_THROW_EXCEPTION(bts::net::insufficient_relay_fee, "Insufficient relay fee; do not propagate!", ("original_exception", original_exception.to_detail_string())); } } @@ -2582,7 +2580,7 @@ config load_config( const fc::path& datadir ) info["address_prefix"] = BTS_ADDRESS_PREFIX; info["inactivity_fee_apr"] = BTS_BLOCKCHAIN_INACTIVE_FEE_APR; - info["priority_fee"] = _chain_db->get_priority_fee(); + info["relay_fee"] = _chain_db->get_relay_fee(); info["delegate_num"] = BTS_BLOCKCHAIN_NUM_DELEGATES; info["delegate_reg_fee"] = _chain_db->get_delegate_registration_fee(); @@ -2937,12 +2935,12 @@ config load_config( const fc::path& datadir ) return trx; } - asset client_impl::wallet_set_priority_fee( double fee ) + asset client_impl::wallet_set_transaction_fee( double fee ) { try { oasset_record asset_record = _chain_db->get_asset_record( asset_id_type() ); FC_ASSERT( asset_record.valid() ); - _wallet->set_priority_fee( asset( fee * asset_record->precision ) ); - return _wallet->get_priority_fee(); + _wallet->set_transaction_fee( asset( fee * asset_record->precision ) ); + return _wallet->get_transaction_fee(); } FC_CAPTURE_AND_RETHROW( (fee) ) } bool client_impl::blockchain_is_synced() const diff --git a/libraries/net/include/bts/net/config.hpp b/libraries/net/include/bts/net/config.hpp index 9ab3f4807..90fcd9869 100644 --- a/libraries/net/include/bts/net/config.hpp +++ b/libraries/net/include/bts/net/config.hpp @@ -2,10 +2,10 @@ #define BTS_NET_PROTOCOL_VERSION 104 -/** +/** * Define this to enable debugging code in the p2p network interface. * This is code that would never be executed in normal operation, but is - * used for automated testing (creating artificial net splits, + * used for automated testing (creating artificial net splits, * tracking where messages came from and when) */ #define ENABLE_P2P_DEBUGGING_API 1 @@ -33,7 +33,7 @@ #define BTS_NET_MAXIMUM_QUEUED_MESSAGES_IN_BYTES (1024 * 1024) -/** +/** * We prevent a peer from offering us a list of blocks which, if we fetched them * all, would result in a blockchain that extended into the future. * This parameter gives us some wiggle room, allowing a peer to give us blocks @@ -42,7 +42,7 @@ */ #define BTS_NET_FUTURE_SYNC_BLOCKS_GRACE_PERIOD_SEC (60 * 60) -#define BTS_NET_INSUFFICIENT_PRIORITY_FEE_PENALTY_SEC 15 +#define BTS_NET_INSUFFICIENT_RELAY_FEE_PENALTY_SEC 15 #define BTS_NET_MAX_INVENTORY_SIZE_IN_MINUTES 2 diff --git a/libraries/net/include/bts/net/exceptions.hpp b/libraries/net/include/bts/net/exceptions.hpp index 1c205b2dd..871caedf6 100644 --- a/libraries/net/include/bts/net/exceptions.hpp +++ b/libraries/net/include/bts/net/exceptions.hpp @@ -5,8 +5,8 @@ namespace bts { namespace net { // registered in node.cpp FC_DECLARE_EXCEPTION( net_exception, 90000, "P2P Networking Exception" ); - FC_DECLARE_DERIVED_EXCEPTION( send_queue_overflow, bts::net::net_exception, 90001, "send queue for this peer exceeded maximum size" ); - FC_DECLARE_DERIVED_EXCEPTION( insufficient_priority_fee, bts::net::net_exception, 90002, "insufficient priority fee" ); - FC_DECLARE_DERIVED_EXCEPTION( already_connected_to_requested_peer, bts::net::net_exception, 90003, "already connected to requested peer" ); + FC_DECLARE_DERIVED_EXCEPTION( send_queue_overflow, bts::net::net_exception, 90001, "send queue for this peer exceeded maximum size" ); + FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, bts::net::net_exception, 90002, "insufficient relay fee" ); + FC_DECLARE_DERIVED_EXCEPTION( already_connected_to_requested_peer, bts::net::net_exception, 90003, "already connected to requested peer" ); } } diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index e52eac1f6..d4998ed80 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -83,7 +83,7 @@ namespace bts { namespace net { FC_REGISTER_EXCEPTIONS( (net_exception) (send_queue_overflow) - (insufficient_priority_fee) + (insufficient_relay_fee) (already_connected_to_requested_peer) ) namespace detail @@ -2727,12 +2727,12 @@ namespace bts { namespace net { namespace detail { _delegate->handle_message(message_to_process, false); message_validated_time = fc::time_point::now(); } - catch ( const insufficient_priority_fee& ) + catch ( const insufficient_relay_fee& ) { // flooding control. The message was valid but we can't handle it now. assert(message_to_process.msg_type == bts::client::trx_message_type); // we only support throttling transactions. if (message_to_process.msg_type == bts::client::trx_message_type) - originating_peer->transaction_fetching_inhibited_until = fc::time_point::now() + fc::seconds(BTS_NET_INSUFFICIENT_PRIORITY_FEE_PENALTY_SEC); + originating_peer->transaction_fetching_inhibited_until = fc::time_point::now() + fc::seconds(BTS_NET_INSUFFICIENT_RELAY_FEE_PENALTY_SEC); return; } catch ( const fc::exception& e ) diff --git a/libraries/wallet/include/bts/wallet/config.hpp b/libraries/wallet/include/bts/wallet/config.hpp index 46d3ab9fb..6c2fff417 100644 --- a/libraries/wallet/include/bts/wallet/config.hpp +++ b/libraries/wallet/include/bts/wallet/config.hpp @@ -1,9 +1,10 @@ #pragma once -#define BTS_WALLET_MIN_PASSWORD_LENGTH (8) -#define BTS_WALLET_MIN_BRAINKEY_LENGTH (32) +#define BTS_WALLET_VERSION uint32_t(102) -/** - * Define the default wallet priority fee for transaction - */ -#define BTS_WALLET_DEFAULT_UNLOCK_TIME_SEC (60*60) +#define BTS_WALLET_MIN_PASSWORD_LENGTH (8) +#define BTS_WALLET_MIN_BRAINKEY_LENGTH (32) + +#define BTS_WALLET_DEFAULT_UNLOCK_TIME_SEC (60*60) + +#define BTS_WALLET_DEFAULT_TRANSACTION_FEE 50000 // XTS diff --git a/libraries/wallet/include/bts/wallet/wallet.hpp b/libraries/wallet/include/bts/wallet/wallet.hpp index 8e15326a2..2c2889529 100644 --- a/libraries/wallet/include/bts/wallet/wallet.hpp +++ b/libraries/wallet/include/bts/wallet/wallet.hpp @@ -97,8 +97,8 @@ namespace bts { namespace wallet { void set_transaction_scanning( bool enabled ); bool get_transaction_scanning()const; - void set_priority_fee( const asset& fee ); - asset get_priority_fee()const; + void set_transaction_fee( const asset& fee ); + asset get_transaction_fee()const; float get_scan_progress()const; diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 2f583ae59..07c5bba86 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1412,7 +1412,7 @@ namespace bts { namespace wallet { self->set_automatic_backups( true ); self->auto_backup( "version_upgrade" ); self->set_transaction_scanning( self->get_my_delegates( enabled_delegate_status ).empty() ); - self->set_priority_fee( asset( BTS_BLOCKCHAIN_DEFAULT_PRIORITY_FEE ) ); + self->set_transaction_fee( asset( BTS_WALLET_DEFAULT_TRANSACTION_FEE ) ); /* Check for old index format genesis claim virtual transactions */ auto present = false; @@ -1471,6 +1471,11 @@ namespace bts { namespace wallet { } } + if( current_version < 102 ) + { + self->set_transaction_fee( asset( BTS_WALLET_DEFAULT_TRANSACTION_FEE ) ); + } + if( _unlocked_upgrade_tasks.empty() ) { _wallet_db.set_property( version, variant( BTS_WALLET_VERSION ) ); @@ -1605,7 +1610,7 @@ namespace bts { namespace wallet { set_automatic_backups( true ); set_transaction_scanning( true ); my->_wallet_db.set_property( last_unlocked_scanned_block_number, variant( my->_blockchain->get_head_block_num() ) ); - set_priority_fee( asset( BTS_BLOCKCHAIN_DEFAULT_PRIORITY_FEE ) ); + set_transaction_fee( asset( BTS_WALLET_DEFAULT_TRANSACTION_FEE ) ); my->_wallet_db.close(); my->_wallet_db.open( wallet_file_path ); @@ -2770,7 +2775,7 @@ namespace bts { namespace wallet { current_account->id, fc::variant() ); } - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); if( required_fees.amount < current_account->delegate_pay_balance() ) { @@ -2837,7 +2842,7 @@ namespace bts { namespace wallet { optional() ); my->authorize_update( required_signatures, current_account ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); if( required_fees.amount < current_account->delegate_pay_balance() ) { @@ -2936,7 +2941,7 @@ namespace bts { namespace wallet { share_type amount_to_transfer((share_type)(real_amount_to_transfer * precision)); asset asset_to_transfer( amount_to_transfer, asset_id ); - //FC_ASSERT( amount_to_transfer > get_priority_fee( amount_to_transfer_symbol ).amount ); + //FC_ASSERT( amount_to_transfer > get_transaction_fee( amount_to_transfer_symbol ).amount ); /** * TODO: until we support paying fees in other assets, this will not function @@ -2954,7 +2959,7 @@ namespace bts { namespace wallet { public_key_type sender_public_key = sender_private_key.get_public_key(); address sender_account_address( sender_private_key.get_public_key() ); - asset total_fee = get_priority_fee(); + asset total_fee = get_transaction_fee(); asset amount_collected( 0, asset_id ); const auto items = my->_wallet_db.get_balances(); @@ -3106,7 +3111,7 @@ namespace bts { namespace wallet { FC_ASSERT( delegate_account_record.valid() ); FC_ASSERT( delegate_account_record->is_delegate() ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); FC_ASSERT( delegate_account_record->delegate_info->pay_balance >= (amount_to_withdraw + required_fees.amount), "", ("delegate_account_record",delegate_account_record)); @@ -3179,7 +3184,7 @@ namespace bts { namespace wallet { signed_transaction trx; unordered_set
required_signatures; - const auto required_fees = get_priority_fee(); + const auto required_fees = get_transaction_fee(); if( required_fees.asset_id == asset_to_transfer.asset_id ) { my->withdraw_to_transaction( required_fees + asset_to_transfer, @@ -3249,7 +3254,7 @@ namespace bts { namespace wallet { unordered_set
required_signatures; asset total_asset_to_transfer( 0, asset_id ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); vector
to_addresses; for( const auto& address_amount : to_address_amounts ) @@ -3342,7 +3347,7 @@ namespace bts { namespace wallet { signed_transaction trx; unordered_set
required_signatures; - const auto required_fees = get_priority_fee(); + const auto required_fees = get_transaction_fee(); if( required_fees.asset_id == asset_to_transfer.asset_id ) { my->withdraw_to_transaction( required_fees + asset_to_transfer, @@ -3451,7 +3456,7 @@ namespace bts { namespace wallet { } } - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); bool as_delegate = false; if( delegate_pay_rate <= 100 ) @@ -3504,7 +3509,7 @@ namespace bts { namespace wallet { signed_transaction trx; unordered_set
required_signatures; - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); required_fees += asset(my->_blockchain->get_asset_registration_fee(),0); @@ -3571,7 +3576,7 @@ namespace bts { namespace wallet { signed_transaction trx; unordered_set
required_signatures; - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); auto asset_record = my->_blockchain->get_asset_record( symbol ); FC_ASSERT(asset_record.valid(), "no such asset record"); @@ -3654,7 +3659,7 @@ namespace bts { namespace wallet { FC_THROW_EXCEPTION( unknown_account, "Unknown account!", ("account_to_update",account_to_update) ); auto account_public_key = get_account_public_key( account_to_update ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); if( account->is_delegate() ) { @@ -3739,7 +3744,7 @@ namespace bts { namespace wallet { my->_wallet_db.store_key(new_key); } - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); my->withdraw_to_transaction( required_fees, payer_public_key, @@ -3789,7 +3794,7 @@ namespace bts { namespace wallet { auto delegate_account = my->_blockchain->get_account_record( delegate_account_name ); FC_ASSERT(delegate_account.valid(), "No such account: ${acct}", ("acct", delegate_account_name)); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); trx.submit_proposal( delegate_account->id, subject, body, proposal_type, data ); @@ -3851,7 +3856,7 @@ namespace bts { namespace wallet { FC_ASSERT(message.size() < BTS_BLOCKCHAIN_PROPOSAL_VOTE_MESSAGE_MAX_SIZE ); trx.vote_proposal( proposal_id, delegate_account->id, vote, message ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); /* my->withdraw_to_transaction( required_fees, @@ -3926,7 +3931,7 @@ namespace bts { namespace wallet { edump( (order) ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); if( balance.amount == 0 ) FC_CAPTURE_AND_THROW( zero_amount, (order) ); @@ -4047,7 +4052,7 @@ namespace bts { namespace wallet { private_key_type from_private_key = get_active_private_key( from_account_name ); address from_address( from_private_key.get_public_key() ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); if( cost_shares.asset_id == 0 ) { @@ -4159,7 +4164,7 @@ namespace bts { namespace wallet { private_key_type from_private_key = get_active_private_key( from_account_name ); address from_address( from_private_key.get_public_key() ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); if( cost_shares.asset_id == 0 ) { @@ -4270,7 +4275,7 @@ namespace bts { namespace wallet { private_key_type from_private_key = get_active_private_key( from_account_name ); address from_address( from_private_key.get_public_key() ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); idump( (cost_shares)(required_fees) ); my->withdraw_to_transaction( cost_shares + required_fees, @@ -4365,7 +4370,7 @@ namespace bts { namespace wallet { trx, required_signatures ); - auto required_fees = get_priority_fee(); + auto required_fees = get_transaction_fee(); bool fees_paid = false; auto collateral_recovered = asset(); @@ -4426,17 +4431,17 @@ namespace bts { namespace wallet { return trx; } FC_CAPTURE_AND_RETHROW( (from_account_name)(real_quantity_usd)(quote_symbol)(owner_address)(sign) ) } - void wallet::set_priority_fee( const asset& fee ) + void wallet::set_transaction_fee( const asset& fee ) { try { FC_ASSERT( is_open() ); if( fee.amount < 0 || fee.asset_id != 0 ) - FC_THROW_EXCEPTION( invalid_fee, "Invalid priority fee!", ("fee",fee) ); + FC_THROW_EXCEPTION( invalid_fee, "Invalid transaction fee!", ("fee",fee) ); my->_wallet_db.set_property( default_transaction_priority_fee, variant( fee ) ); } FC_CAPTURE_AND_RETHROW( (fee) ) } - asset wallet::get_priority_fee()const + asset wallet::get_transaction_fee()const { try { FC_ASSERT( is_open() ); // TODO: support price conversion using price from blockchain @@ -4921,11 +4926,11 @@ namespace bts { namespace wallet { { try { map transaction_errors; const auto& transaction_records = get_pending_transactions(); - const auto priority_fee = my->_blockchain->get_priority_fee(); + const auto relay_fee = my->_blockchain->get_relay_fee(); for( const auto& transaction_record : transaction_records ) { FC_ASSERT( !transaction_record.is_virtual && !transaction_record.is_confirmed ); - const auto error = my->_blockchain->get_transaction_error( transaction_record.trx, priority_fee ); + const auto error = my->_blockchain->get_transaction_error( transaction_record.trx, relay_fee ); if( !error.valid() ) continue; transaction_errors[ transaction_record.trx.id() ] = *error; } @@ -5024,7 +5029,7 @@ namespace bts { namespace wallet { /** * Looks up the public key for an account whether local or in the blockchain, with - * the blockchain taking priority. + * the blockchain taking precendence. */ public_key_type wallet::get_account_public_key( const string& account_name )const { try { @@ -5318,7 +5323,7 @@ namespace bts { namespace wallet { info["automatic_backups"] = variant(); info["transaction_scanning"] = variant(); info["last_scanned_block_num"] = variant(); - info["priority_fee"] = variant(); + info["transaction_fee"] = variant(); info["unlocked"] = variant(); info["unlocked_until"] = variant(); @@ -5334,7 +5339,7 @@ namespace bts { namespace wallet { info["automatic_backups"] = get_automatic_backups(); info["transaction_scanning"] = get_transaction_scanning(); info["last_scanned_block_num"] = my->_wallet_db.get_property( last_unlocked_scanned_block_number ).as(); - info["priority_fee"] = get_priority_fee(); + info["transaction_fee"] = get_transaction_fee(); info["unlocked"] = is_unlocked(); From 7b0049cb1f9c74f02787fd46961d601e0c01bc89 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sat, 16 Aug 2014 19:04:54 -0400 Subject: [PATCH 18/32] Fix regression tests --- .../blockchain_get_asset.log | 24 +----- .../blockchain_get_block_transactions.log | 12 +-- .../blockchain_get_feeds_for_asset.log | 48 ++++++------ .../blockchain_get_info.log | 9 +-- .../blockchain_list_pending_transactions.log | 6 +- ...hain_list_recently_registered_accounts.log | 16 ++-- .../blockchain_markets/blockchain_markets.log | 74 +++++++++---------- .../regression_tests/issue_633/issue_633.log | 20 ++--- .../simple_wallet_commands.log | 8 +- .../regression_tests/stolen_names/client0.log | 4 +- tests/regression_tests/titan/client0.log | 8 +- tests/regression_tests/titan/client1.log | 4 +- .../update_active_key/client0.log | 28 +++---- .../update_active_key/client1.log | 12 +-- .../wallet_account_register.log | 6 +- .../wallet_account_update_active_key.log | 26 +++---- .../wallet_account_update_registration.log | 12 +-- .../wallet_asset/wallet_asset.log | 18 ++--- .../wallet_get_info/wallet_get_info.log | 4 +- .../wallet_market_submit_ask.log | 36 ++++----- .../wallet_market_submit_bid.log | 40 +++++----- .../wallet_publish_price_feed.log | 74 +++++++++---------- .../wallet_publish_slate.log | 8 +- .../wallet_relock/wallet_relock.log | 12 +-- .../wallet_set_transaction_scanning.log | 12 +-- .../wallet_transfer/wallet_transfer.log | 4 +- .../wallet_transfer_from.log | 10 +-- 27 files changed, 260 insertions(+), 275 deletions(-) diff --git a/tests/regression_tests/blockchain_get_asset/blockchain_get_asset.log b/tests/regression_tests/blockchain_get_asset/blockchain_get_asset.log index 77cd95436..aec18d54c 100644 --- a/tests/regression_tests/blockchain_get_asset/blockchain_get_asset.log +++ b/tests/regression_tests/blockchain_get_asset/blockchain_get_asset.log @@ -24,17 +24,7 @@ aliases: get_asset "current_share_supply": 199999999999901, "maximum_share_supply": 1000000000000000, "collected_fees": 0, - "price_feed_id": 0, - "minimum_xts_price": { - "ratio": "0.", - "quote_asset_id": 0, - "base_asset_id": 0 - }, - "maximum_xts_price": { - "ratio": "0.", - "quote_asset_id": 0, - "base_asset_id": 0 - } + "price_feed_id": 0 } (wallet closed) >>> blockchain_get_asset 0 { @@ -50,16 +40,6 @@ aliases: get_asset "current_share_supply": 199999999999901, "maximum_share_supply": 1000000000000000, "collected_fees": 0, - "price_feed_id": 0, - "minimum_xts_price": { - "ratio": "0.", - "quote_asset_id": 0, - "base_asset_id": 0 - }, - "maximum_xts_price": { - "ratio": "0.", - "quote_asset_id": 0, - "base_asset_id": 0 - } + "price_feed_id": 0 } (wallet closed) >>> quit diff --git a/tests/regression_tests/blockchain_get_block_transactions/blockchain_get_block_transactions.log b/tests/regression_tests/blockchain_get_block_transactions/blockchain_get_block_transactions.log index 862aeabea..7e6e0daa6 100644 --- a/tests/regression_tests/blockchain_get_block_transactions/blockchain_get_block_transactions.log +++ b/tests/regression_tests/blockchain_get_block_transactions/blockchain_get_block_transactions.log @@ -6,7 +6,7 @@ xts:test:XTS5drpKagoTFiMsg1urDXvrtY7Fkuyb4vkgBUCxrsnrer8ioRGrp default (unlocked) >>> wallet_transfer 100 XTS delegate0 test RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 test 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 test 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait_for_block_by_number 2 @@ -23,7 +23,7 @@ Returns: blockchain_transaction_record_map default (unlocked) >>> blockchain_get_block_transactions 2 [[ - "cf139ec446f3ae34f4520f97167ee446e7e93155",{ + "63e2c073d5a52ab66cf97bfa948affdcef7e66fb",{ "trx": { "expiration": "20140620T164030", "delegate_slate_id": null, @@ -31,7 +31,7 @@ default (unlocked) >>> blockchain_get_block_transactions 2 "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10010000, + "amount": 10050000, "claim_input_data": "" } },{ @@ -54,7 +54,7 @@ default (unlocked) >>> blockchain_get_block_transactions 2 } ], "signatures": [ - "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6c2d958c8c457999674b52081c080b31ab9ed5530fcc135636cc66ae0fbd6b3623" + "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6ceedfb97d0948e4d36a66a3b5b4c9f5c7153ca920b47d94e819cb80f9964d4fac" ] }, "signed_keys": [ @@ -82,14 +82,14 @@ default (unlocked) >>> blockchain_get_block_transactions 2 ], "withdraws": [[ 0,{ - "amount": 10010000, + "amount": 10050000, "asset_id": 0 } ] ], "balance": [[ 0, - 10000 + 50000 ] ], "net_delegate_votes": [], diff --git a/tests/regression_tests/blockchain_get_feeds_for_asset/blockchain_get_feeds_for_asset.log b/tests/regression_tests/blockchain_get_feeds_for_asset/blockchain_get_feeds_for_asset.log index 3d97aca82..9c98172d1 100644 --- a/tests/regression_tests/blockchain_get_feeds_for_asset/blockchain_get_feeds_for_asset.log +++ b/tests/regression_tests/blockchain_get_feeds_for_asset/blockchain_get_feeds_for_asset.log @@ -6,7 +6,7 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "CREATI "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -23,8 +23,8 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "CREATI } ], "signatures": [ - "1fa31bf8b475b41b5848cba70b97c7a5d9ab6323ae5849d8f6f14618b817e67f8e067a4c81e7d9a5bf03480ac9cf60ab15d9f1f9db054c7be4e94e3226e55ad36f", - "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6c7841c10c0f72f696cfe8d55980ace721e7e6a8480d5a123e04e7439b62d8d815" + "1fa31bf8b475b41b5848cba70b97c7a5d9ab6323ae5849d8f6f14618b817e67f8ec9bb67add33345b1aca42c0875db882615dfeb141448c980f7cdf6fc1e44786c", + "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6cdb88f77fa54974af600bbe50780d93087af5f1ac831c482d9c9140d41169346f" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -52,14 +52,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate0 2 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9334c03d890bcc9341dfc55678a3a2c478b5ae24c493afa7279c7a5213e5bc4ee", - "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f06749602ed7c5bf432afe37b0fed2c97706465c6b145e14f7ba9c926f730631e202280b" + "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d96d0cd6e9d62f2b75f1afa99ce13574307636c01955bd3f267432cf47853f0e2e", + "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f06749606caa0dae3966c31393cfdccd006db3efa5646d48df5c63e88f39fe415e21857b" ] } default (unlocked) >>> wallet_publish_price_feed delegate1 .2 XMO @@ -83,14 +83,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate1 .2 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTS3V5xQc7Rgzs5SogiQWuVGq5wfK8EFrBoL", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d2211fda5a26230e5791f587846deeada3c201a651d931c72e4f9b9c66658a1b58d", - "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98b4ae6402f1ee765aadf2b99676877472a400261d75d46ffcfc474681c21cff2d6" + "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d22533f3192aa6b5e8e793ed8e928332f265886c74c4c3bfcbbb21aad9639bee47b", + "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98ba9582c206d1ad18432862ba84b98bf889db54bb96577404ff3bde132875da254" ] } default (unlocked) >>> wallet_publish_price_feed delegate2 1 XMO @@ -114,14 +114,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate2 1 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTSAaFwcyBGLmPChJgmp2mzZoHsXBi8CkYf5", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1fab2bf36b55531a00ea24d3800060f1901760c1b339cd38359d1f3af7c0b2e4c0e4f4ae346febf54a036c73f8171a7940f4c82a16bffc08fdeaab47315dddeb40", - "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b9b8b5c64afe0544a84ce82947f734860715db432b6d05890db9c28aee8853538b" + "1fab2bf36b55531a00ea24d3800060f1901760c1b339cd38359d1f3af7c0b2e4c007f8c94b1d79db57c2518ab9cba6d3227049eca16204dec8cb0e6e7694dd5d50", + "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b99f221892261cc98594c6ef72d2cbab5c10e55a2576ac5fbb4ad76f2b0fe9cb0b" ] } default (unlocked) >>> wallet_publish_price_feed delegate3 -100 XMO @@ -152,14 +152,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate4 2.5 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTS813o8XNCGxjSvE9zUKRvi1p5SiizkWyWs", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f0028e9a22867436c24ebc9a0e1aca4f822e8b84da58a4d5f0eed5b99763b7d16fa", - "20ae62ef753099e1d7cdd372e87ceca3e98a91b042f98a71f8e13c9bdf36977e6670f3ad49388c338281c3002979696d24dfff6b78469d99e2df9d8970f09b6323" + "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f0028fa16e9eda18c1c9e80fd897d9b86e4a4cbe96a59abf4e86b5a5c5344423000", + "20ae62ef753099e1d7cdd372e87ceca3e98a91b042f98a71f8e13c9bdf36977e66d89dc9cb055f3e91b451d03eedb07cfc2c1dcaac8ce8e0f94930e47d91577cee" ] } default (unlocked) >>> wallet_publish_price_feed delegate5 -.5 XMO @@ -190,14 +190,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate6 .01 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTSCLchKcwkBbqVmgGAkQYwXZRVFhc8ukdSX", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20bfac1dcd372e3bcec5d453a614f5ed978275929cfed5235283433d3bbac5ac0c1baa7b5b8e4e9b9b3d092126d0562eced5b7a618bf29db614535d079ca26e419", - "1fdc1f3d4d907a562b44d59ccdb8c4a5e7598a9d24b4d52ecc84f09a49ac1be907d646655d7fd1f10531c4d97a2d594b730ff3850c20607afba06f2d253a327e9e" + "20bfac1dcd372e3bcec5d453a614f5ed978275929cfed5235283433d3bbac5ac0c0e830975aa2eaa785867889fa6e7ccd275a11f1bb6d57dc18fdd7bfc57dabc20", + "1fdc1f3d4d907a562b44d59ccdb8c4a5e7598a9d24b4d52ecc84f09a49ac1be907459412a44fe04bec5fdaf612d7517df672c662a71b52f0bed3dda739c9a36651" ] } default (unlocked) >>> wallet_publish_price_feed delegate7 2 XMO @@ -221,14 +221,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate7 2 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTSARFWU4ENn4FrB3bdHux3YZaqmz8pEZfx9", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1f9b0bb127f3cbcd85f3a518363be91ee050dc7d222614725b07c13cd97717e31a71b535fe655c6352318e4f2341164059d8e35d51e17aa4ba8b5654ae04fa65c0", - "20d5486259515fea1ce8c892354db75ceda339f99b6e8f014264668e472b02b96f628d529320d0d2f56f88427e7b65bafbc26120c0e702daec07fd508c35f4ccf9" + "1f9b0bb127f3cbcd85f3a518363be91ee050dc7d222614725b07c13cd97717e31ae8c8b137dd9da799bdba72fd341109f77fa5d23313f7b9d1aad801958782e45f", + "20d5486259515fea1ce8c892354db75ceda339f99b6e8f014264668e472b02b96f2c598d48e206f177e3452ab29f8e3ca24935ca74d82f301e63c9aaed0584be30" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -282,6 +282,12 @@ default (unlocked) >>> blockchain_get_feeds_for_asset XMO "last_update": "20140620T144040", "asset_symbol": null, "median_price": null + },{ + "delegate_name": "MARKET", + "price": 0, + "last_update": "20140620T144050", + "asset_symbol": "XMO", + "median_price": 2 } ] default (unlocked) >>> quit diff --git a/tests/regression_tests/blockchain_get_info/blockchain_get_info.log b/tests/regression_tests/blockchain_get_info/blockchain_get_info.log index 106d7eaba..2ea79630e 100644 --- a/tests/regression_tests/blockchain_get_info/blockchain_get_info.log +++ b/tests/regression_tests/blockchain_get_info/blockchain_get_info.log @@ -16,16 +16,14 @@ aliases: getconfig, get_config, config, blockchain_get_config "symbol": "XTS", "name": "BitShares XTS", "version": 109, - "db_version": 122, + "db_version": 124, "genesis_timestamp": "[redacted]", "block_interval": 10, - "target_block_size": 25600, "max_block_size": 51200, "max_blockchain_size": 107374182400, "address_prefix": "XTS", - "min_block_fee": "0.00001 XTS", "inactivity_fee_apr": "0.00010 XTS", - "priority_fee": "0.10000 XTS", + "relay_fee": "0.10000 XTS", "delegate_num": 101, "delegate_reg_fee": "0.00000 XTS", "name_size_max": 63, @@ -38,6 +36,7 @@ aliases: getconfig, get_config, config, blockchain_get_config "min_market_depth": "2,000,000.00000 XTS", "proposal_vote_message_max": 1024, "max_pending_queue_size": 10, - "max_trx_per_second": 1 + "max_trx_per_second": 1, + "min_block_fee": "0.00000 XTS" } (wallet closed) >>> quit diff --git a/tests/regression_tests/blockchain_list_pending_transactions/blockchain_list_pending_transactions.log b/tests/regression_tests/blockchain_list_pending_transactions/blockchain_list_pending_transactions.log index 81f9351c2..001a156c0 100644 --- a/tests/regression_tests/blockchain_list_pending_transactions/blockchain_list_pending_transactions.log +++ b/tests/regression_tests/blockchain_list_pending_transactions/blockchain_list_pending_transactions.log @@ -12,11 +12,11 @@ No balances found. default (unlocked) >>> wallet_transfer 100 XTS delegate0 test RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 test 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 test 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> wallet_account_balance delegate0 ACCOUNT BALANCE ============================================================ -delegate0 19,801,880.09801 XTS +delegate0 19,801,879.69801 XTS default (unlocked) >>> wallet_account_balance test No balances found. default (unlocked) >>> help blockchain_list_pending_transactions @@ -50,7 +50,7 @@ No pending transactions. default (unlocked) >>> wallet_account_balance delegate0 ACCOUNT BALANCE ============================================================ -delegate0 19,801,880.09801 XTS +delegate0 19,801,879.69801 XTS default (unlocked) >>> wallet_account_balance test ACCOUNT BALANCE ============================================================ diff --git a/tests/regression_tests/blockchain_list_recently_registered_accounts/blockchain_list_recently_registered_accounts.log b/tests/regression_tests/blockchain_list_recently_registered_accounts/blockchain_list_recently_registered_accounts.log index 9b7f68321..d095f25e6 100644 --- a/tests/regression_tests/blockchain_list_recently_registered_accounts/blockchain_list_recently_registered_accounts.log +++ b/tests/regression_tests/blockchain_list_recently_registered_accounts/blockchain_list_recently_registered_accounts.log @@ -44,13 +44,13 @@ default (unlocked) >>> wallet_account_register testaccount1 delegate0 null 100 "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1fa31bf8b475b41b5848cba70b97c7a5d9ab6323ae5849d8f6f14618b817e67f8e6f5881099cbcf27a994db47f1d11f87ae708610db2455d97b19fa3570b41f93a" + "1fa31bf8b475b41b5848cba70b97c7a5d9ab6323ae5849d8f6f14618b817e67f8e0d291c0acdefa371390f480b141b012468d1ba7c16b7af08b0b342643a4ca503" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -110,13 +110,13 @@ default (unlocked) >>> wallet_account_register testaccount2 delegate0 null 90 "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "208513ec7641898a4a37e0bfe8617a37bef25351eada00e9d0c04e79869bd335f6a8be0ecb7f7cf0e1d2c50197b1f3bafe3cb0da62b8db4cce2958188139247d20" + "208513ec7641898a4a37e0bfe8617a37bef25351eada00e9d0c04e79869bd335f64154323c7a49c6f0a12fcf5640409efa7e8efe04dbdb1d76fbeabdb42e4727e1" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -188,13 +188,13 @@ default (unlocked) >>> wallet_account_register testaccount3 delegate0 null 10 "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f0674960bc03642e4acbfd9e2ab3f4b2dd044a07f1ab56cffde70225a492b69663a9ad39" + "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f067496052be9eb5ae00c2084a868ab5118618bc1b3d2a396ff14013f76f0fe548c07111" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -288,13 +288,13 @@ default (unlocked) >>> wallet_account_register testaccount4 delegate0 null 100 "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50007, "claim_input_data": "" } } ], "signatures": [ - "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98b89a71eabb40ee6ca567b655015055be21b564f46883e1fce981dc274d431ff8f" + "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98bd317e564857174dd9b3ec6906b5a36366193cd064aaae282f7f78caaa8936752" ] } default (unlocked) >>> debug_advance_time 1 blocks diff --git a/tests/regression_tests/blockchain_markets/blockchain_markets.log b/tests/regression_tests/blockchain_markets/blockchain_markets.log index e0cf5b9e6..2accd8588 100644 --- a/tests/regression_tests/blockchain_markets/blockchain_markets.log +++ b/tests/regression_tests/blockchain_markets/blockchain_markets.log @@ -6,7 +6,7 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASS "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -23,8 +23,8 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASS } ], "signatures": [ - "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6ccc54b200a2c253753014f05861b8642427b3275129f37066a2ce00be49d4577f", - "208513ec7641898a4a37e0bfe8617a37bef25351eada00e9d0c04e79869bd335f6f598f82fd88edd5751c4a65d34ce2cfe8fe4abfcc5b1fb99216499842584e853" + "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6caafe1218dd2777e74560fc2af83e9d883936abfd9aacb72ec2b2cb4d83756842", + "208513ec7641898a4a37e0bfe8617a37bef25351eada00e9d0c04e79869bd335f6ecbf610b48773cfcc12a6291d0910d2cd97b53498780e82553037496ce08216c" ] } default (unlocked) >>> debug_wait_for_block_by_number 1 relative @@ -49,11 +49,11 @@ xts:testaccount2:XTS7CCZsSumbT4xCvu5t21C2ic9msdiYf9oRuNyLBoJz18LTkArfs default (unlocked) >>> wallet_transfer 100 XTS delegate0 testaccount1 RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 testaccount1 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> wallet_transfer 10000 XTS delegate0 testaccount2 RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 testaccount2 10,000.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> wallet_asset_issue 10000 XMO testaccount1 "Sending some assets" { "expiration": "20140620T164040", @@ -62,7 +62,7 @@ default (unlocked) >>> wallet_asset_issue 10000 XMO testaccount1 "Sending some a "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -93,8 +93,8 @@ default (unlocked) >>> wallet_asset_issue 10000 XMO testaccount1 "Sending some a } ], "signatures": [ - "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f002173da5c998eddc04c07254876ddee0617ae57d8a90581b443f8d147d9cbb361", - "20ae62ef753099e1d7cdd372e87ceca3e98a91b042f98a71f8e13c9bdf36977e66f4b568c30ac3dc2b2fb318c7dd432d90f489a13c6ffa0e371cf05f6759f03288" + "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f0040462225df9299824373f62898a6a6f28b2c8bacb19bd61e90b442ca54c19f79", + "20ae62ef753099e1d7cdd372e87ceca3e98a91b042f98a71f8e13c9bdf36977e66097c7f8631e07027db162084fade909d95a712c5b0dc5222bdf5066cc7528db4" ] } default (unlocked) >>> debug_wait_for_block_by_number 1 relative @@ -104,7 +104,7 @@ OK default (unlocked) >>> balance ACCOUNT BALANCE ============================================================ -delegate0 19,791,879.79801 XTS +delegate0 19,791,878.19801 XTS delegate1 19,801,980.19801 XTS delegate2 19,801,980.19801 XTS delegate3 19,801,980.19801 XTS @@ -120,10 +120,10 @@ RECEIVED BLOCK FROM TO AMOUNT [redacted] 0 GENESIS delegate3 19,801,980.19801 XTS claim PrAqJzqCULC3guyYGpQmggCDkQepFkLYmt 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate2 19,801,980.19801 XTS claim PpTMxwrSXcGKVMwmF9MptTN9tFDhhxfVLV 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate1 19,801,980.19801 XTS claim Pf8LAwjSFbjX3mzYhzThhcFqo1SweKsD6c 0.00000 XTS [redacted] -[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount2 10,000.00000 XTS 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 100.00000 XTS 0.10000 XTS [redacted] +[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> blockchain_list_assets ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY =========================================================================================================================================================== @@ -161,7 +161,7 @@ default (unlocked) >>> wallet_market_submit_bid testaccount1 500 XTS 3 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTSMHyhBmQy6YvaSk3ebPF8gzCxa9odiRXBC", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -180,9 +180,9 @@ default (unlocked) >>> wallet_market_submit_bid testaccount1 500 XTS 3 XMO } ], "signatures": [ - "1f9b0bb127f3cbcd85f3a518363be91ee050dc7d222614725b07c13cd97717e31a30161824df761d59d0b9727887cfaaa7c90e311847cc1cbe739c82e62cc001cc", - "20d5486259515fea1ce8c892354db75ceda339f99b6e8f014264668e472b02b96fbde07970af74ac07cb2cf4e1a1af64ab7688538314f8ccbe5d519a49e9dcb22c", - "20cefb525e31270f268abb362101d80a91ebdc2cf47469c2887593a6dcc4ca94d9391481de22ad598067f2cb62b0bb97afa067de79879672cbc9dd7b39cf41f38c" + "1f9b0bb127f3cbcd85f3a518363be91ee050dc7d222614725b07c13cd97717e31ac6ee912834b9134cfe3e19726eb0102c6bf43c642f12608a3d4171d03f20e455", + "20d5486259515fea1ce8c892354db75ceda339f99b6e8f014264668e472b02b96f73ed6962c7912eeffc7b38e874ad4d6b9271ddb58ade2334cb0d39966cedf98c", + "20cefb525e31270f268abb362101d80a91ebdc2cf47469c2887593a6dcc4ca94d9c9b095bda5f13f5e3863be94926f18889d0367e7beab8b2dfb618919d07996ac" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -192,13 +192,13 @@ OK default (unlocked) >>> balance ACCOUNT BALANCE ============================================================ -delegate0 19,791,879.79801 XTS +delegate0 19,791,878.19801 XTS delegate1 19,801,980.19801 XTS delegate2 19,801,980.19801 XTS delegate3 19,801,980.19801 XTS delegate4 19,801,980.19801 XTS testaccount1 8,500.00 XMO - 99.90000 XTS + 99.50000 XTS testaccount2 10,000.00000 XTS default (unlocked) >>> history RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID @@ -208,11 +208,11 @@ RECEIVED BLOCK FROM TO AMOUNT [redacted] 0 GENESIS delegate3 19,801,980.19801 XTS claim PrAqJzqCULC3guyYGpQmggCDkQepFkLYmt 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate2 19,801,980.19801 XTS claim PpTMxwrSXcGKVMwmF9MptTN9tFDhhxfVLV 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate1 19,801,980.19801 XTS claim Pf8LAwjSFbjX3mzYhzThhcFqo1SweKsD6c 0.00000 XTS [redacted] -[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount2 10,000.00000 XTS 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 100.00000 XTS 0.10000 XTS [redacted] -[redacted] 4 testaccount1 BID-NMzxHFAC 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.10000 XTS [redacted] +[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] +[redacted] 4 testaccount1 BID-NMzxHFAC 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> blockchain_market_list_bids XMO XTS TYPE QUANTITY PRICE BALANCE COST COLLATERAL ID ================================================================================================================================ @@ -246,7 +246,7 @@ default (unlocked) >>> wallet_market_submit_ask testaccount2 100 XTS 4 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTS9w1GAF5Qyhv7WCf1wrcZ3EDW64ZCAKaEr", - "amount": 10010000, + "amount": 10050000, "claim_input_data": "" } },{ @@ -265,8 +265,8 @@ default (unlocked) >>> wallet_market_submit_ask testaccount2 100 XTS 4 XMO } ], "signatures": [ - "1fc5c666f15451b2c5c022028ec5b0ea34e27957c6ffd97a12e74d7f47176fd38edd61e12b88a82d71aea68192fa656b653b4ab518bb3f937b98ea52f9b073a385", - "1f455a71954b4076ff59ae182c2a126a6613aa460678af030cae007dd220eb55a7ff3efc61cf6a8a632f173b0f4037d0c2cae8a3760825c8f0d0e4bcfe75e2fe66" + "1fc5c666f15451b2c5c022028ec5b0ea34e27957c6ffd97a12e74d7f47176fd38e909c02c4ce294e8e58051cc0f9a8341ba4175c1505f4e785efc898244479ebe2", + "1f455a71954b4076ff59ae182c2a126a6613aa460678af030cae007dd220eb55a7055b6811efc8a31994e0eb252d726797173c63d83f4fb531edc38526987f9964" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -276,14 +276,14 @@ OK default (unlocked) >>> balance ACCOUNT BALANCE ============================================================ -delegate0 19,791,879.79801 XTS +delegate0 19,791,878.19801 XTS delegate1 19,801,980.19801 XTS delegate2 19,801,980.19801 XTS delegate3 19,801,980.19801 XTS delegate4 19,801,980.19801 XTS testaccount1 8,500.00 XMO - 99.90000 XTS -testaccount2 9,899.90000 XTS + 99.50000 XTS +testaccount2 9,899.50000 XTS default (unlocked) >>> history RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== @@ -292,12 +292,12 @@ RECEIVED BLOCK FROM TO AMOUNT [redacted] 0 GENESIS delegate3 19,801,980.19801 XTS claim PrAqJzqCULC3guyYGpQmggCDkQepFkLYmt 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate2 19,801,980.19801 XTS claim PpTMxwrSXcGKVMwmF9MptTN9tFDhhxfVLV 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate1 19,801,980.19801 XTS claim Pf8LAwjSFbjX3mzYhzThhcFqo1SweKsD6c 0.00000 XTS [redacted] -[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount2 10,000.00000 XTS 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 100.00000 XTS 0.10000 XTS [redacted] -[redacted] 4 testaccount1 BID-NMzxHFAC 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.10000 XTS [redacted] -[redacted] 6 testaccount2 ASK-8gMh2aDJ 100.00000 XTS sell XTS @ 4. XMO / XTS 0.10000 XTS [redacted] +[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] +[redacted] 4 testaccount1 BID-NMzxHFAC 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] +[redacted] 6 testaccount2 ASK-8gMh2aDJ 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> blockchain_market_list_asks XMO XTS TYPE QUANTITY PRICE BALANCE COST COLLATERAL ID ================================================================================================================================ @@ -353,7 +353,7 @@ default (unlocked) >>> blockchain_market_status XMO XTS "bid_depth": 0, "ask_depth": 10000000, "avg_price_24h": { - "ratio": "0.000019390581717451", + "ratio": "0.", "quote_asset_id": 0, "base_asset_id": 0 }, diff --git a/tests/regression_tests/issue_633/issue_633.log b/tests/regression_tests/issue_633/issue_633.log index e565768a8..2ee2eac73 100644 --- a/tests/regression_tests/issue_633/issue_633.log +++ b/tests/regression_tests/issue_633/issue_633.log @@ -6,7 +6,7 @@ xts:test:XTS5drpKagoTFiMsg1urDXvrtY7Fkuyb4vkgBUCxrsnrer8ioRGrp default (unlocked) >>> wallet_transfer 100 XTS delegate0 test RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 test 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 test 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait 2 @@ -35,13 +35,13 @@ default (unlocked) >>> wallet_account_register test test null 100 "type": "withdraw_op_type", "data": { "balance_id": "XTSMiTysKtNmHwurQpnyHjpSGiRBzDiYXKUF", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9ee026a13194fc0fcccee50edf0fd5b900f76985acdd325cee664204d48bdb80d" + "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9cb73612ea738d13db87cb7454b300c8ce5429f4b5be41b8d6df4aad52172212d" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -63,7 +63,7 @@ ID NAME (* next in line) APPROVAL PRODUCED MISSED RELIABILI default (unlocked) >>> balance test ACCOUNT BALANCE ============================================================ -test 99.90000 XTS +test 99.50000 XTS default (unlocked) >>> wallet_account_update_active_key test test { "expiration": "20140620T164050", @@ -72,7 +72,7 @@ default (unlocked) >>> wallet_account_update_active_key test test "type": "withdraw_op_type", "data": { "balance_id": "XTSMiTysKtNmHwurQpnyHjpSGiRBzDiYXKUF", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -86,14 +86,14 @@ default (unlocked) >>> wallet_account_update_active_key test test } ], "signatures": [ - "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d2294546c3a65fd3978d92449c82e0402a2c95e6981d00b5a0156d179f73fa9075b", - "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98bde106ed7c1f00f87a00b4f2fa6a383c2e1b3306bf69b31cb7cfdf57f7f30e4a4" + "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d2270caa623d8028b0a6847e7d927d129bf6c37b96681a16d402431abf7ca21d9ce", + "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98b0d95e677fbf04840782b65f904f561982bc4fbfb4e0577d1813ff4566813cf6c" ] } default (unlocked) >>> balance test ACCOUNT BALANCE ============================================================ -test 99.80000 XTS +test 99.00000 XTS default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> wallet_rescan_blockchain @@ -103,7 +103,7 @@ OK default (unlocked) >>> balance test ACCOUNT BALANCE ============================================================ -test 99.80000 XTS +test 99.00000 XTS default (unlocked) >>> wallet_account_update_active_key test test Command failed with exception: insufficient funds (20010) @@ -115,5 +115,5 @@ Command failed with exception: insufficient funds (20010) default (unlocked) >>> balance test ACCOUNT BALANCE ============================================================ -test 99.80000 XTS +test 99.00000 XTS default (unlocked) >>> quit diff --git a/tests/regression_tests/simple_wallet_commands/simple_wallet_commands.log b/tests/regression_tests/simple_wallet_commands/simple_wallet_commands.log index 83f3d923a..03a538109 100644 --- a/tests/regression_tests/simple_wallet_commands/simple_wallet_commands.log +++ b/tests/regression_tests/simple_wallet_commands/simple_wallet_commands.log @@ -8,12 +8,12 @@ wallet (unlocked) >>> wallet_get_info "automatic_backups": true, "transaction_scanning": true, "last_scanned_block_num": 0, - "priority_fee": "0.10000 XTS", + "transaction_fee": "0.50000 XTS", "unlocked": true, "unlocked_until": "[redacted]", "unlocked_until_timestamp": "[redacted]", "scan_progress": "100.00 %", - "version": 101 + "version": 102 } wallet (unlocked) >>> wallet_set_automatic_backups false false @@ -100,12 +100,12 @@ wallet (unlocked) >>> wallet_get_info "automatic_backups": false, "transaction_scanning": true, "last_scanned_block_num": 0, - "priority_fee": "99,999.00000 XTS", + "transaction_fee": "99,999.00000 XTS", "unlocked": true, "unlocked_until": "[redacted]", "unlocked_until_timestamp": "[redacted]", "scan_progress": "100.00 %", - "version": 101 + "version": 102 } wallet (unlocked) >>> wallet_close OK diff --git a/tests/regression_tests/stolen_names/client0.log b/tests/regression_tests/stolen_names/client0.log index b31e0e3d8..57d39b6f0 100644 --- a/tests/regression_tests/stolen_names/client0.log +++ b/tests/regression_tests/stolen_names/client0.log @@ -21,13 +21,13 @@ default (unlocked) >>> wallet_account_register thief delegate0 "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "208513ec7641898a4a37e0bfe8617a37bef25351eada00e9d0c04e79869bd335f63a4b789a9ffd271a44a05f482aaa272d8301efceb86449dc69120942a3491ede" + "208513ec7641898a4a37e0bfe8617a37bef25351eada00e9d0c04e79869bd335f6ff688caad972a7c41933e0ce98dc27e1aade6a7ff2f886f9d81783bdbaae1400" ] } default (unlocked) >>> debug_advance_time 1 blocks diff --git a/tests/regression_tests/titan/client0.log b/tests/regression_tests/titan/client0.log index 87511e14c..37acd798d 100644 --- a/tests/regression_tests/titan/client0.log +++ b/tests/regression_tests/titan/client0.log @@ -7,7 +7,7 @@ OK default (unlocked) >>> wallet_transfer 150 XTS delegate0 account-for-client1 "send this back" RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 account-for-client1 150.00000 XTS send this back 0.10000 XTS [redacted] +[redacted] PENDING delegate0 account-for-client1 150.00000 XTS send this back 0.50000 XTS [redacted] default (unlocked) >>> wallet_account_create test-account @@ -31,13 +31,13 @@ default (unlocked) >>> wallet_account_register test-account delegate0 "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f0674960c4d5cf606a73366be313a4a390189fee977e0a3d97532ec165dfa3eacd9536e1" + "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f067496065ca1cb6aac6dd0c1b29d318239268bc5231d9fdb65ca3a555c0a4c7d5acdcea" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -47,7 +47,7 @@ OK default (unlocked) >>> wallet_account_balance delegate0 ACCOUNT BALANCE ============================================================ -delegate0 19,801,829.99801 XTS +delegate0 19,801,829.19801 XTS default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait 2 diff --git a/tests/regression_tests/titan/client1.log b/tests/regression_tests/titan/client1.log index 4e59fb921..49508a640 100644 --- a/tests/regression_tests/titan/client1.log +++ b/tests/regression_tests/titan/client1.log @@ -11,7 +11,7 @@ account-for-client1 150.00000 XTS default (unlocked) >>> wallet_transfer 100 XTS account-for-client1 test-account "take this" RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING account-for-client1 test-account 100.00000 XTS take this 0.10000 XTS [redacted] +[redacted] PENDING account-for-client1 test-account 100.00000 XTS take this 0.50000 XTS [redacted] default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait 2 @@ -19,5 +19,5 @@ OK default (unlocked) >>> wallet_account_balance account-for-client1 ACCOUNT BALANCE ============================================================ -account-for-client1 49.90000 XTS +account-for-client1 49.50000 XTS default (unlocked) >>> quit diff --git a/tests/regression_tests/update_active_key/client0.log b/tests/regression_tests/update_active_key/client0.log index 41ae85703..257c490dd 100644 --- a/tests/regression_tests/update_active_key/client0.log +++ b/tests/regression_tests/update_active_key/client0.log @@ -10,7 +10,7 @@ default (unlocked) >>> wallet_account_update_active_key delegate4 delegate4 "type": "withdraw_op_type", "data": { "balance_id": "XTS813o8XNCGxjSvE9zUKRvi1p5SiizkWyWs", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -24,8 +24,8 @@ default (unlocked) >>> wallet_account_update_active_key delegate4 delegate4 } ], "signatures": [ - "208513ec7641898a4a37e0bfe8617a37bef25351eada00e9d0c04e79869bd335f6a87a2e52401a78780e622dbe44958f0fb4a87663c31d483a447fe4d31aac5d4f", - "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9e59e6490f828633dd97833f8ced0febfd0eae14c2969dd3cbde84fe8e7d238ac" + "208513ec7641898a4a37e0bfe8617a37bef25351eada00e9d0c04e79869bd335f63f8d8f4304c7d3eb8d005c152d6247bfb7f35798a45648b39e7fa747c385243a", + "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d94f0a1aba55f27a4e16ff7688e20cb53d93536ec658c7734b62043070d72f487c" ] } default (unlocked) >>> wallet_account_update_active_key delegate5 delegate5 "5JDQmM7RDjLr7LR9MVceuckKLE61BfiBePgJfqY1Eaa55whVaFR" @@ -36,7 +36,7 @@ default (unlocked) >>> wallet_account_update_active_key delegate5 delegate5 "5JD "type": "withdraw_op_type", "data": { "balance_id": "XTSCYxycACPxN2L78BcRdtSUcomALMaYZiJf", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -50,8 +50,8 @@ default (unlocked) >>> wallet_account_update_active_key delegate5 delegate5 "5JD } ], "signatures": [ - "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f0674960238261f97dc0b381d3b0da39fe757d15795fb509c3bf63f40c8f211378f7c909", - "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d22f86209201ed1a6d4ac5ecea8fd31e8b091894d51bc3d7049ddd98f921c8b2c0c" + "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f06749605c8bc38abd638281290b3f704bded2a08619e072a61b50492a9e78259635a0be", + "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d22d1075afe4024bc865a8e2fbb3a5e0eea2396e5e135dde4caf34663807dc98fb5" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -133,7 +133,7 @@ OK default (unlocked) >>> transfer 30 XTS delegate0 delegate4 RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 delegate4 30.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 delegate4 30.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait_for_block_by_number 4 @@ -166,7 +166,7 @@ default (unlocked) >>> wallet_account_update_active_key delegate4 delegate4 "type": "withdraw_op_type", "data": { "balance_id": "XTSEXfr9hUi5jMRvLAQ5x4Q1bnWckdSB4dDj", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -180,8 +180,8 @@ default (unlocked) >>> wallet_account_update_active_key delegate4 delegate4 } ], "signatures": [ - "1fc5c666f15451b2c5c022028ec5b0ea34e27957c6ffd97a12e74d7f47176fd38e5f9a26860147f8ee9aef20894ffa32c7a10a982a422e2678b4b1edcb1ce03176", - "1f455a71954b4076ff59ae182c2a126a6613aa460678af030cae007dd220eb55a79407f3aa93759956d912a2844668a949d99c749cc5161f26151f86fbd84bb6ca" + "1fc5c666f15451b2c5c022028ec5b0ea34e27957c6ffd97a12e74d7f47176fd38edc20efd26aae4d5bcec62b2a1fde62281c426a6ffbc79a9012ebd3c608f542db", + "1f455a71954b4076ff59ae182c2a126a6613aa460678af030cae007dd220eb55a7f6813160c66bc4329fa76653bfe836531f6106fd58000bff8aeb8debbe4a1783" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -199,8 +199,8 @@ default (unlocked) >>> history delegate4 RECEIVED BLOCK FROM TO AMOUNT MEMO BALANCE FEE ID ============================================================================================================================================================================================== [redacted] 0 GENESIS delegate4 19,801,980.19801 XTS claim PkrWFQgshsBX5YGkPm581QT1NL7nfNhzpc 19,801,980.19801 XTS 0.00000 XTS [redacted] -[redacted] 2 delegate4 delegate4 0.00000 XTS update delegate4 active key 19,801,980.09801 XTS 0.10000 XTS [redacted] -[redacted] 4 delegate0 delegate4 30.00000 XTS 19,802,010.09801 XTS 0.00000 XTS [redacted] -[redacted] 7 delegate4 delegate5 10.00000 XTS 19,801,999.99801 XTS 0.10000 XTS [redacted] -[redacted] 10 delegate4 delegate4 0.00000 XTS update delegate4 active key 19,801,999.89801 XTS 0.10000 XTS [redacted] +[redacted] 2 delegate4 delegate4 0.00000 XTS update delegate4 active key 19,801,979.69801 XTS 0.50000 XTS [redacted] +[redacted] 4 delegate0 delegate4 30.00000 XTS 19,802,009.69801 XTS 0.00000 XTS [redacted] +[redacted] 7 delegate4 delegate5 10.00000 XTS 19,801,999.19801 XTS 0.50000 XTS [redacted] +[redacted] 10 delegate4 delegate4 0.00000 XTS update delegate4 active key 19,801,998.69801 XTS 0.50000 XTS [redacted] default (unlocked) >>> quit diff --git a/tests/regression_tests/update_active_key/client1.log b/tests/regression_tests/update_active_key/client1.log index 3d8e78997..25f892bb2 100644 --- a/tests/regression_tests/update_active_key/client1.log +++ b/tests/regression_tests/update_active_key/client1.log @@ -13,7 +13,7 @@ OK default (unlocked) >>> history RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] 4 delegate0 delegate4 30.00000 XTS 0.10000 XTS [redacted] +[redacted] 4 delegate0 delegate4 30.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> wallet_account_balance ACCOUNT BALANCE ============================================================ @@ -29,7 +29,7 @@ OK default (unlocked) >>> transfer 10 XTS delegate4 delegate5 RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate4 delegate5 10.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate4 delegate5 10.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait_for_block_by_number 7 @@ -39,7 +39,7 @@ OK default (unlocked) >>> balance ACCOUNT BALANCE ============================================================ -delegate4 19.90000 XTS +delegate4 19.50000 XTS delegate5 10.00000 XTS default (unlocked) >>> debug_wait_for_block_by_number 10 OK @@ -57,7 +57,7 @@ OK default (unlocked) >>> history RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] 4 delegate0 delegate4 30.00000 XTS 0.10000 XTS [redacted] -[redacted] 7 delegate4 delegate5 10.00000 XTS 0.10000 XTS [redacted] -[redacted] 10 delegate4 delegate4 0.00000 XTS update delegate4 0.10000 XTS [redacted] +[redacted] 4 delegate0 delegate4 30.00000 XTS 0.50000 XTS [redacted] +[redacted] 7 delegate4 delegate5 10.00000 XTS 0.50000 XTS [redacted] +[redacted] 10 delegate4 delegate4 0.00000 XTS update delegate4 0.50000 XTS [redacted] default (unlocked) >>> quit diff --git a/tests/regression_tests/wallet_account_register/wallet_account_register.log b/tests/regression_tests/wallet_account_register/wallet_account_register.log index 40dc79353..64841638d 100644 --- a/tests/regression_tests/wallet_account_register/wallet_account_register.log +++ b/tests/regression_tests/wallet_account_register/wallet_account_register.log @@ -6,7 +6,7 @@ xts:test:XTS5drpKagoTFiMsg1urDXvrtY7Fkuyb4vkgBUCxrsnrer8ioRGrp default (unlocked) >>> wallet_transfer 100 XTS delegate0 test RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 test 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 test 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait 2 @@ -35,13 +35,13 @@ default (unlocked) >>> wallet_account_register test test null 100 "type": "withdraw_op_type", "data": { "balance_id": "XTSMiTysKtNmHwurQpnyHjpSGiRBzDiYXKUF", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9ee026a13194fc0fcccee50edf0fd5b900f76985acdd325cee664204d48bdb80d" + "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9cb73612ea738d13db87cb7454b300c8ce5429f4b5be41b8d6df4aad52172212d" ] } default (unlocked) >>> debug_advance_time 1 blocks diff --git a/tests/regression_tests/wallet_account_update_active_key/wallet_account_update_active_key.log b/tests/regression_tests/wallet_account_update_active_key/wallet_account_update_active_key.log index c781bbc63..1ea7e3348 100644 --- a/tests/regression_tests/wallet_account_update_active_key/wallet_account_update_active_key.log +++ b/tests/regression_tests/wallet_account_update_active_key/wallet_account_update_active_key.log @@ -6,7 +6,7 @@ xts:test:XTS5drpKagoTFiMsg1urDXvrtY7Fkuyb4vkgBUCxrsnrer8ioRGrp default (unlocked) >>> wallet_transfer 100 XTS delegate0 test RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 test 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 test 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait 2 @@ -35,13 +35,13 @@ default (unlocked) >>> wallet_account_register test test "type": "withdraw_op_type", "data": { "balance_id": "XTSMiTysKtNmHwurQpnyHjpSGiRBzDiYXKUF", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d99da522fbea68cb77a7dfce13043b0156a3586629df36f9577ca0535498637812" + "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9908d44a1072a96019509eb417cc6310cf96842392d1e121af9399b7aaebce27b" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -64,7 +64,7 @@ default (unlocked) >>> wallet_account_update_registration test test null 100 "type": "withdraw_op_type", "data": { "balance_id": "XTSMiTysKtNmHwurQpnyHjpSGiRBzDiYXKUF", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -78,8 +78,8 @@ default (unlocked) >>> wallet_account_update_registration test test null 100 } ], "signatures": [ - "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d22b48ddd2233ba3b8ec54d08bf000f355007895111020a19469cc878685fd3fa3b", - "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98bf77401484806e4f52f1d135b87b477f0f2d586f1dd825bdb110c1849b274797b" + "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d229026e377bca18e8af5cfc1b88a2a4fc3746583ff543fe7342a428ed1a5eacb14", + "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98b08454c7f337ba9f9e33f0c9e991d56205039564fec8550511fbf55a43b3bc9c0" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -101,11 +101,11 @@ ID NAME (* next in line) APPROVAL PRODUCED MISSED RELIABILI default (unlocked) >>> balance test ACCOUNT BALANCE ============================================================ -test 99.80000 XTS +test 99.00000 XTS default (unlocked) >>> balance delegate0 ACCOUNT BALANCE ============================================================ -delegate0 19,801,880.09801 XTS +delegate0 19,801,879.69801 XTS default (unlocked) >>> wallet_account_update_active_key test test 5KgPRATnTBkT4nfNAy9AHrDDmCQxEQPkSwCgtm8cpSyZnGHrnJn Command failed with exception: key belongs to other account (20032) Key already belongs to another account! @@ -116,11 +116,11 @@ Key already belongs to another account! default (unlocked) >>> balance test ACCOUNT BALANCE ============================================================ -test 99.80000 XTS +test 99.00000 XTS default (unlocked) >>> balance delegate0 ACCOUNT BALANCE ============================================================ -delegate0 19,801,880.09801 XTS +delegate0 19,801,879.69801 XTS default (unlocked) >>> blockchain_get_account test Name: test Registered: [redacted] @@ -141,7 +141,7 @@ default (unlocked) >>> wallet_account_update_active_key test test "type": "withdraw_op_type", "data": { "balance_id": "XTSMiTysKtNmHwurQpnyHjpSGiRBzDiYXKUF", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -155,8 +155,8 @@ default (unlocked) >>> wallet_account_update_active_key test test } ], "signatures": [ - "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b968774b9483af537faff233abeda05dec365d6a7c58f04d5051b8c93429c479c8", - "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f009b011e90e84f71656950a8a767d75de8321ed47d0a0a87d086e73bc733f4fbaf" + "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b94087c54a103a45bedecd5dbb1f5fced5c8d743a572a607d42a137f01ab7f2c65", + "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f000190f2c04fed17d06b09441cbbd28c4d74efc960f50d2faa4a44a3f9b917cd26" ] } default (unlocked) >>> debug_advance_time 1 blocks diff --git a/tests/regression_tests/wallet_account_update_registration/wallet_account_update_registration.log b/tests/regression_tests/wallet_account_update_registration/wallet_account_update_registration.log index 3a8c8a144..83d4982f1 100644 --- a/tests/regression_tests/wallet_account_update_registration/wallet_account_update_registration.log +++ b/tests/regression_tests/wallet_account_update_registration/wallet_account_update_registration.log @@ -6,7 +6,7 @@ xts:test:XTS5drpKagoTFiMsg1urDXvrtY7Fkuyb4vkgBUCxrsnrer8ioRGrp default (unlocked) >>> wallet_transfer 100 XTS delegate0 test RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 test 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 test 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait 2 @@ -35,13 +35,13 @@ default (unlocked) >>> wallet_account_register test test "type": "withdraw_op_type", "data": { "balance_id": "XTSMiTysKtNmHwurQpnyHjpSGiRBzDiYXKUF", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d99da522fbea68cb77a7dfce13043b0156a3586629df36f9577ca0535498637812" + "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9908d44a1072a96019509eb417cc6310cf96842392d1e121af9399b7aaebce27b" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -64,7 +64,7 @@ default (unlocked) >>> wallet_account_update_registration test test null 100 "type": "withdraw_op_type", "data": { "balance_id": "XTSMiTysKtNmHwurQpnyHjpSGiRBzDiYXKUF", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -78,8 +78,8 @@ default (unlocked) >>> wallet_account_update_registration test test null 100 } ], "signatures": [ - "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d22b48ddd2233ba3b8ec54d08bf000f355007895111020a19469cc878685fd3fa3b", - "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98bf77401484806e4f52f1d135b87b477f0f2d586f1dd825bdb110c1849b274797b" + "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d229026e377bca18e8af5cfc1b88a2a4fc3746583ff543fe7342a428ed1a5eacb14", + "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98b08454c7f337ba9f9e33f0c9e991d56205039564fec8550511fbf55a43b3bc9c0" ] } default (unlocked) >>> debug_advance_time 1 blocks diff --git a/tests/regression_tests/wallet_asset/wallet_asset.log b/tests/regression_tests/wallet_asset/wallet_asset.log index 30e5ffa60..d1edb715d 100644 --- a/tests/regression_tests/wallet_asset/wallet_asset.log +++ b/tests/regression_tests/wallet_asset/wallet_asset.log @@ -6,7 +6,7 @@ xts:test:XTS75ngXKr5VCgxFU6iQTkwQzXXYwQz5em6AwEtH6hAzo4sW5j81v default (unlocked) >>> wallet_transfer 100 XTS delegate0 test RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 test 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 test 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_wait_for_block_by_number 1 relative OK default (unlocked) >>> debug_wait 2 @@ -19,7 +19,7 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "CREATI "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -36,8 +36,8 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "CREATI } ], "signatures": [ - "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f06749608848f257da5978b222badb0a05709afb3c3273f51bbd3717c929f58083d70ec6", - "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d22c6e2baa22c808109d3ad5a709bad6180b049ff669f2a6ba090beeb0aeea07b82" + "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f06749609d2c89fb47f02766c0bd2dada70c6c5d4a796735a3c9a04ed07ec67518303ae8", + "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d2289faeb2ea8c5ae9453f47529a16e4f02b2ead3a6734155bd1674e3ab3263c8f0" ] } default (unlocked) >>> wallet_account_balance test @@ -49,8 +49,8 @@ OK default (unlocked) >>> blockchain_list_blocks HEIGHT TIMESTAMP SIGNING DELEGATE # TXS SIZE TOTAL FEES LATENCY PROCESSING TIME =================================================================================================================== -2 [redacted] [redacted] 1 392 0.10000 XTS [redacted][redacted] -1 [redacted] [redacted] 1 410 0.10000 XTS [redacted][redacted] +2 [redacted] [redacted] 1 392 0.50000 XTS [redacted][redacted] +1 [redacted] [redacted] 1 410 0.50000 XTS [redacted][redacted] default (unlocked) >>> blockchain_list_assets ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY =========================================================================================================================================================== @@ -64,7 +64,7 @@ default (unlocked) >>> wallet_asset_issue 1 XMO test "Sending some assets" "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -95,8 +95,8 @@ default (unlocked) >>> wallet_asset_issue 1 XMO test "Sending some assets" } ], "signatures": [ - "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b93575edb9ad826b12910bc61efa6e7f811060c1a1754ce5c51e27cb92eb358d31", - "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f0070b64da3777b7b9c4d4e176eeaeae326cdfb71aa1b17cc35786daadfb840d5b0" + "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b9b1c81645a9144210499956207f89ce3a2f789ef45305364a8c229124ef787ba4", + "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f006fbc2955382ee6ae4fa914efb6cb14a71a7cb9ec34bb63c643a60c3036e116ba" ] } default (unlocked) >>> debug_wait_for_block_by_number 1 relative diff --git a/tests/regression_tests/wallet_get_info/wallet_get_info.log b/tests/regression_tests/wallet_get_info/wallet_get_info.log index eb8492300..62dbcda04 100644 --- a/tests/regression_tests/wallet_get_info/wallet_get_info.log +++ b/tests/regression_tests/wallet_get_info/wallet_get_info.log @@ -16,11 +16,11 @@ default (unlocked) >>> wallet_get_info "automatic_backups": false, "transaction_scanning": true, "last_scanned_block_num": 0, - "priority_fee": "0.10000 XTS", + "transaction_fee": "0.50000 XTS", "unlocked": true, "unlocked_until": "[redacted]", "unlocked_until_timestamp": "[redacted]", "scan_progress": "100.00 %", - "version": 101 + "version": 102 } default (unlocked) >>> quit diff --git a/tests/regression_tests/wallet_market_submit_ask/wallet_market_submit_ask.log b/tests/regression_tests/wallet_market_submit_ask/wallet_market_submit_ask.log index fd77e636c..2556d583f 100644 --- a/tests/regression_tests/wallet_market_submit_ask/wallet_market_submit_ask.log +++ b/tests/regression_tests/wallet_market_submit_ask/wallet_market_submit_ask.log @@ -6,7 +6,7 @@ xts:testaccount2:XTS75ngXKr5VCgxFU6iQTkwQzXXYwQz5em6AwEtH6hAzo4sW5j81v default (unlocked) >>> wallet_transfer 10000 XTS delegate0 testaccount2 RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 testaccount2 10,000.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_wait_for_block_by_number 1 relative OK default (unlocked) >>> debug_wait 2 @@ -19,7 +19,7 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASS "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -36,7 +36,7 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASS } ], "signatures": [ - "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f06749602c4354c91087714ed7fd9a0d939d143030b2c7d96910bd9701ea1ba5a54663a0" + "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f0674960feed53136d3e2c104bfea159b5e1ff8a1ac188e00b403aee39c114f4bf2ffb62" ] } default (unlocked) >>> wallet_account_balance testaccount2 @@ -51,8 +51,8 @@ default (unlocked) >>> blockchain_list_blocks HEIGHT TIMESTAMP SIGNING DELEGATE # TXS SIZE TOTAL FEES LATENCY PROCESSING TIME =================================================================================================================== 3 [redacted] [redacted] 0 166 0.00000 XTS [redacted][redacted] -2 [redacted] [redacted] 1 318 0.10000 XTS [redacted][redacted] -1 [redacted] [redacted] 1 410 0.10000 XTS [redacted][redacted] +2 [redacted] [redacted] 1 318 0.50000 XTS [redacted][redacted] +1 [redacted] [redacted] 1 410 0.50000 XTS [redacted][redacted] default (unlocked) >>> blockchain_list_assets ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY =========================================================================================================================================================== @@ -101,7 +101,7 @@ default (unlocked) >>> wallet_market_submit_ask testaccount2 100 XTS 4 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTSBwY6Z9FyseFkJdyphjZTwbFzW8cHdowXW", - "amount": 10010000, + "amount": 10050000, "claim_input_data": "" } },{ @@ -120,18 +120,18 @@ default (unlocked) >>> wallet_market_submit_ask testaccount2 100 XTS 4 XMO } ], "signatures": [ - "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f0077a347d31f3166f2cdc009add70950a28ac7761088870c064047195162cbaf91", - "20ae62ef753099e1d7cdd372e87ceca3e98a91b042f98a71f8e13c9bdf36977e6621a5d4db1ca1db248b6f8b73919d4e0b9e45ab3c0961c3e71b2acad7a8d920d4" + "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f00d9fabdf11461525421ffeafa616211712a076ca5e8d1e119d9c93e5ebd4cf618", + "20ae62ef753099e1d7cdd372e87ceca3e98a91b042f98a71f8e13c9bdf36977e6699ca979d32c60b40229d29d579206290a76e954cc59456897cd7dd1ce05f02ff" ] } default (unlocked) >>> balance testaccount2 ACCOUNT BALANCE ============================================================ -testaccount2 9,899.90000 XTS +testaccount2 9,899.50000 XTS default (unlocked) >>> wallet_account_balance testaccount2 ACCOUNT BALANCE ============================================================ -testaccount2 9,899.90000 XTS +testaccount2 9,899.50000 XTS default (unlocked) >>> blockchain_list_assets ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY =========================================================================================================================================================== @@ -149,13 +149,13 @@ RECEIVED BLOCK FROM TO AMOUNT [redacted] 0 GENESIS delegate3 19,801,980.19801 XTS claim PrAqJzqCULC3guyYGpQmggCDkQepFkLYmt 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate2 19,801,980.19801 XTS claim PpTMxwrSXcGKVMwmF9MptTN9tFDhhxfVLV 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate1 19,801,980.19801 XTS claim Pf8LAwjSFbjX3mzYhzThhcFqo1SweKsD6c 0.00000 XTS [redacted] -[redacted] 1 delegate0 testaccount2 10,000.00000 XTS 0.10000 XTS [redacted] -[redacted] 2 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.10000 XTS [redacted] -[redacted] 6 testaccount2 ASK-MVVWT3x5 100.00000 XTS sell XTS @ 4. XMO / XTS 0.10000 XTS [redacted] +[redacted] 1 delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] +[redacted] 2 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +[redacted] 6 testaccount2 ASK-MVVWT3x5 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> balance testaccount2 ACCOUNT BALANCE ============================================================ -testaccount2 9,899.90000 XTS +testaccount2 9,899.50000 XTS default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait 2 @@ -168,9 +168,9 @@ RECEIVED BLOCK FROM TO AMOUNT [redacted] 0 GENESIS delegate3 19,801,980.19801 XTS claim PrAqJzqCULC3guyYGpQmggCDkQepFkLYmt 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate2 19,801,980.19801 XTS claim PpTMxwrSXcGKVMwmF9MptTN9tFDhhxfVLV 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate1 19,801,980.19801 XTS claim Pf8LAwjSFbjX3mzYhzThhcFqo1SweKsD6c 0.00000 XTS [redacted] -[redacted] 1 delegate0 testaccount2 10,000.00000 XTS 0.10000 XTS [redacted] -[redacted] 2 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.10000 XTS [redacted] -[redacted] 6 testaccount2 ASK-MVVWT3x5 100.00000 XTS sell XTS @ 4. XMO / XTS 0.10000 XTS [redacted] +[redacted] 1 delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] +[redacted] 2 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +[redacted] 6 testaccount2 ASK-MVVWT3x5 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> blockchain_market_list_asks XMO XTS TYPE QUANTITY PRICE BALANCE COST COLLATERAL ID ================================================================================================================================ @@ -178,7 +178,7 @@ ask_order 100.00000 XTS 4. XMO / XTS 100.00000 XTS default (unlocked) >>> balance testaccount2 ACCOUNT BALANCE ============================================================ -testaccount2 9,899.90000 XTS +testaccount2 9,899.50000 XTS default (unlocked) >>> wallet_market_order_list XMO XTS TYPE QUANTITY PRICE BALANCE COST COLLATERAL ID ================================================================================================================================ diff --git a/tests/regression_tests/wallet_market_submit_bid/wallet_market_submit_bid.log b/tests/regression_tests/wallet_market_submit_bid/wallet_market_submit_bid.log index fbb848fa3..54719e0ef 100644 --- a/tests/regression_tests/wallet_market_submit_bid/wallet_market_submit_bid.log +++ b/tests/regression_tests/wallet_market_submit_bid/wallet_market_submit_bid.log @@ -6,7 +6,7 @@ xts:testaccount1:XTS75ngXKr5VCgxFU6iQTkwQzXXYwQz5em6AwEtH6hAzo4sW5j81v default (unlocked) >>> wallet_transfer 100 XTS delegate0 testaccount1 RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 testaccount1 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASSET" null 5000000 100 { "expiration": "20140620T164030", @@ -15,7 +15,7 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASS "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -32,8 +32,8 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASS } ], "signatures": [ - "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d965dcd5e08ff846cf50d25fffc04136307d248bf7e65b75b18daf25a180fe44c5", - "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f06749605cec0ca37c3842222dadb7818454a593910df9cce446269f10ce0eacd194769d" + "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9d9ab6568e742c6ef87305c79a069281aea954cc4965ffe3aac6248d1c3c8f572", + "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f067496039ae52f8de3899211dc0eb300abb2ea380da8aa3326390dc78f89e59ebe7d88f" ] } default (unlocked) >>> debug_wait_for_block_by_number 1 relative @@ -43,7 +43,7 @@ OK default (unlocked) >>> blockchain_list_blocks HEIGHT TIMESTAMP SIGNING DELEGATE # TXS SIZE TOTAL FEES LATENCY PROCESSING TIME =================================================================================================================== -1 [redacted] [redacted] 2 627 0.20000 XTS [redacted][redacted] +1 [redacted] [redacted] 2 627 1.00000 XTS [redacted][redacted] default (unlocked) >>> wallet_account_balance testaccount1 ACCOUNT BALANCE ============================================================ @@ -61,7 +61,7 @@ default (unlocked) >>> wallet_asset_issue 10000 XMO testaccount1 "Sending some a "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -92,8 +92,8 @@ default (unlocked) >>> wallet_asset_issue 10000 XMO testaccount1 "Sending some a } ], "signatures": [ - "1fab2bf36b55531a00ea24d3800060f1901760c1b339cd38359d1f3af7c0b2e4c04069f56c39b885d1408cf27a374c47e17b2666d839231cab500fc1197e6710cf", - "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b9b47fecc0a4535ff0fffb0cbd1e51cb1825078318c426f525cf80643a0699a78c" + "1fab2bf36b55531a00ea24d3800060f1901760c1b339cd38359d1f3af7c0b2e4c0a5eeb3729e2b38039c7a2af5dd824c00ca03def59b58b59341f357fad71ac631", + "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b9fd0439c691816da79e8a3e463848ef0f93e3977ec3b5ea19c206fc3ccdc8b7a9" ] } default (unlocked) >>> debug_wait_for_block_by_number 1 relative @@ -127,9 +127,9 @@ RECEIVED BLOCK FROM TO AMOUNT [redacted] 0 GENESIS delegate3 19,801,980.19801 XTS claim PrAqJzqCULC3guyYGpQmggCDkQepFkLYmt 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate2 19,801,980.19801 XTS claim PpTMxwrSXcGKVMwmF9MptTN9tFDhhxfVLV 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate1 19,801,980.19801 XTS claim Pf8LAwjSFbjX3mzYhzThhcFqo1SweKsD6c 0.00000 XTS [redacted] -[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.10000 XTS [redacted] -[redacted] 1 delegate0 testaccount1 100.00000 XTS 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.10000 XTS [redacted] +[redacted] 1 delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] +[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] default (unlocked) >>> blockchain_list_assets ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY =========================================================================================================================================================== @@ -172,7 +172,7 @@ default (unlocked) >>> wallet_market_submit_bid testaccount1 500 XTS 3 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTSBwY6Z9FyseFkJdyphjZTwbFzW8cHdowXW", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -191,9 +191,9 @@ default (unlocked) >>> wallet_market_submit_bid testaccount1 500 XTS 3 XMO } ], "signatures": [ - "20bfac1dcd372e3bcec5d453a614f5ed978275929cfed5235283433d3bbac5ac0c00d2a35dd207bb250b3e2c265611442565af6bd0ce5005c04652d6ae268a6168", - "1fdc1f3d4d907a562b44d59ccdb8c4a5e7598a9d24b4d52ecc84f09a49ac1be90799bee0b02a20ed9e40f171ac0dd1632db9ed6c09ee1d4cdff66d2a5f4aa0262d", - "1f9b0bb127f3cbcd85f3a518363be91ee050dc7d222614725b07c13cd97717e31a2ef29b9713e9a4b6d078405dff4989204e6b416983f430b078e2715a6ccfe59b" + "20bfac1dcd372e3bcec5d453a614f5ed978275929cfed5235283433d3bbac5ac0c38a86c9fd3dfcfa9da3c906d82c72c67f89942e32e3a0b9247a462d0d4f65dd3", + "1fdc1f3d4d907a562b44d59ccdb8c4a5e7598a9d24b4d52ecc84f09a49ac1be907b53cb995234e4a8691f2148860336352f8e6e91aef00a757c87cde6a9d559da3", + "1f9b0bb127f3cbcd85f3a518363be91ee050dc7d222614725b07c13cd97717e31adb2dab347acb77f10f692ffe872272553e381cb16cba7da4d9346f89fa4e72bb" ] } default (unlocked) >>> debug_wait_for_block_by_number 1 relative @@ -204,7 +204,7 @@ default (unlocked) >>> balance testaccount1 ACCOUNT BALANCE ============================================================ testaccount1 8,500.00 XMO - 99.90000 XTS + 99.50000 XTS default (unlocked) >>> wallet_account_transaction_history RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== @@ -213,10 +213,10 @@ RECEIVED BLOCK FROM TO AMOUNT [redacted] 0 GENESIS delegate3 19,801,980.19801 XTS claim PrAqJzqCULC3guyYGpQmggCDkQepFkLYmt 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate2 19,801,980.19801 XTS claim PpTMxwrSXcGKVMwmF9MptTN9tFDhhxfVLV 0.00000 XTS [redacted] [redacted] 0 GENESIS delegate1 19,801,980.19801 XTS claim Pf8LAwjSFbjX3mzYhzThhcFqo1SweKsD6c 0.00000 XTS [redacted] -[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.10000 XTS [redacted] -[redacted] 1 delegate0 testaccount1 100.00000 XTS 0.10000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.10000 XTS [redacted] -[redacted] 4 testaccount1 BID-MVVWT3x5 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.10000 XTS [redacted] +[redacted] 1 delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] +[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +[redacted] 2 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] +[redacted] 4 testaccount1 BID-MVVWT3x5 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> blockchain_market_list_bids XMO XTS TYPE QUANTITY PRICE BALANCE COST COLLATERAL ID ================================================================================================================================ diff --git a/tests/regression_tests/wallet_publish_price_feed/wallet_publish_price_feed.log b/tests/regression_tests/wallet_publish_price_feed/wallet_publish_price_feed.log index b46904855..93ae03243 100644 --- a/tests/regression_tests/wallet_publish_price_feed/wallet_publish_price_feed.log +++ b/tests/regression_tests/wallet_publish_price_feed/wallet_publish_price_feed.log @@ -6,7 +6,7 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "CREATI "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } },{ @@ -23,8 +23,8 @@ default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "CREATI } ], "signatures": [ - "1fa31bf8b475b41b5848cba70b97c7a5d9ab6323ae5849d8f6f14618b817e67f8e067a4c81e7d9a5bf03480ac9cf60ab15d9f1f9db054c7be4e94e3226e55ad36f", - "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6c7841c10c0f72f696cfe8d55980ace721e7e6a8480d5a123e04e7439b62d8d815" + "1fa31bf8b475b41b5848cba70b97c7a5d9ab6323ae5849d8f6f14618b817e67f8ec9bb67add33345b1aca42c0875db882615dfeb141448c980f7cdf6fc1e44786c", + "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6cdb88f77fa54974af600bbe50780d93087af5f1ac831c482d9c9140d41169346f" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -64,14 +64,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate0 2 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d9334c03d890bcc9341dfc55678a3a2c478b5ae24c493afa7279c7a5213e5bc4ee", - "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f06749602ed7c5bf432afe37b0fed2c97706465c6b145e14f7ba9c926f730631e202280b" + "20dfdcb1892751ce8aa98d5e6a7451ffc3919df60b3f75fa648dbc10a4604e32d96d0cd6e9d62f2b75f1afa99ce13574307636c01955bd3f267432cf47853f0e2e", + "20382ad2a5971b8edce40b362dff9b7abb41f041fced4e98032567d7e7f06749606caa0dae3966c31393cfdccd006db3efa5646d48df5c63e88f39fe415e21857b" ] } default (unlocked) >>> wallet_publish_price_feed delegate1 .2 XMO @@ -95,14 +95,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate1 .2 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTS3V5xQc7Rgzs5SogiQWuVGq5wfK8EFrBoL", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d2211fda5a26230e5791f587846deeada3c201a651d931c72e4f9b9c66658a1b58d", - "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98b4ae6402f1ee765aadf2b99676877472a400261d75d46ffcfc474681c21cff2d6" + "1fec3855dbe1166043791cf143099f7024debaf18f71738d70aa254eccbdfc9d22533f3192aa6b5e8e793ed8e928332f265886c74c4c3bfcbbb21aad9639bee47b", + "20ed3b89cfd9161f3bb98d23ffae80a5b0184ec70371312d17e5aec38e6810b98ba9582c206d1ad18432862ba84b98bf889db54bb96577404ff3bde132875da254" ] } default (unlocked) >>> wallet_publish_price_feed delegate2 1 XMO @@ -126,14 +126,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate2 1 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTSAaFwcyBGLmPChJgmp2mzZoHsXBi8CkYf5", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1fab2bf36b55531a00ea24d3800060f1901760c1b339cd38359d1f3af7c0b2e4c0e4f4ae346febf54a036c73f8171a7940f4c82a16bffc08fdeaab47315dddeb40", - "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b9b8b5c64afe0544a84ce82947f734860715db432b6d05890db9c28aee8853538b" + "1fab2bf36b55531a00ea24d3800060f1901760c1b339cd38359d1f3af7c0b2e4c007f8c94b1d79db57c2518ab9cba6d3227049eca16204dec8cb0e6e7694dd5d50", + "1f4d113578c1008f397175971fddbcd23df8895fc1032838efee4b465927e420b99f221892261cc98594c6ef72d2cbab5c10e55a2576ac5fbb4ad76f2b0fe9cb0b" ] } default (unlocked) >>> wallet_publish_price_feed delegate3 -100 XMO @@ -164,14 +164,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate4 2.5 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTS813o8XNCGxjSvE9zUKRvi1p5SiizkWyWs", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f0028e9a22867436c24ebc9a0e1aca4f822e8b84da58a4d5f0eed5b99763b7d16fa", - "20ae62ef753099e1d7cdd372e87ceca3e98a91b042f98a71f8e13c9bdf36977e6670f3ad49388c338281c3002979696d24dfff6b78469d99e2df9d8970f09b6323" + "208b9e609254fe9bb3e477541bd399ef415ab2aa3d293cb7011d71eb416d0e7f0028fa16e9eda18c1c9e80fd897d9b86e4a4cbe96a59abf4e86b5a5c5344423000", + "20ae62ef753099e1d7cdd372e87ceca3e98a91b042f98a71f8e13c9bdf36977e66d89dc9cb055f3e91b451d03eedb07cfc2c1dcaac8ce8e0f94930e47d91577cee" ] } default (unlocked) >>> wallet_publish_price_feed delegate5 -.5 XMO @@ -202,14 +202,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate6 .01 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTSCLchKcwkBbqVmgGAkQYwXZRVFhc8ukdSX", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "20bfac1dcd372e3bcec5d453a614f5ed978275929cfed5235283433d3bbac5ac0c1baa7b5b8e4e9b9b3d092126d0562eced5b7a618bf29db614535d079ca26e419", - "1fdc1f3d4d907a562b44d59ccdb8c4a5e7598a9d24b4d52ecc84f09a49ac1be907d646655d7fd1f10531c4d97a2d594b730ff3850c20607afba06f2d253a327e9e" + "20bfac1dcd372e3bcec5d453a614f5ed978275929cfed5235283433d3bbac5ac0c0e830975aa2eaa785867889fa6e7ccd275a11f1bb6d57dc18fdd7bfc57dabc20", + "1fdc1f3d4d907a562b44d59ccdb8c4a5e7598a9d24b4d52ecc84f09a49ac1be907459412a44fe04bec5fdaf612d7517df672c662a71b52f0bed3dda739c9a36651" ] } default (unlocked) >>> wallet_publish_price_feed delegate7 2 XMO @@ -233,14 +233,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate7 2 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTSARFWU4ENn4FrB3bdHux3YZaqmz8pEZfx9", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1f9b0bb127f3cbcd85f3a518363be91ee050dc7d222614725b07c13cd97717e31a71b535fe655c6352318e4f2341164059d8e35d51e17aa4ba8b5654ae04fa65c0", - "20d5486259515fea1ce8c892354db75ceda339f99b6e8f014264668e472b02b96f628d529320d0d2f56f88427e7b65bafbc26120c0e702daec07fd508c35f4ccf9" + "1f9b0bb127f3cbcd85f3a518363be91ee050dc7d222614725b07c13cd97717e31ae8c8b137dd9da799bdba72fd341109f77fa5d23313f7b9d1aad801958782e45f", + "20d5486259515fea1ce8c892354db75ceda339f99b6e8f014264668e472b02b96f2c598d48e206f177e3452ab29f8e3ca24935ca74d82f301e63c9aaed0584be30" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -253,7 +253,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate0 "price": 2, "last_update": "20140620T144040", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> blockchain_get_feeds_from_delegate delegate1 @@ -262,7 +262,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate1 "price": 0.20000000000000001, "last_update": "20140620T144040", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> blockchain_get_feeds_from_delegate delegate2 @@ -271,7 +271,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate2 "price": 1, "last_update": "20140620T144040", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> blockchain_get_feeds_from_delegate delegate3 @@ -282,7 +282,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate4 "price": 2.5, "last_update": "20140620T144040", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> blockchain_get_feeds_from_delegate delegate5 @@ -293,7 +293,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate6 "price": 0.01, "last_update": "20140620T144040", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> blockchain_get_feeds_from_delegate delegate7 @@ -302,7 +302,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate7 "price": 2, "last_update": "20140620T144040", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> wallet_publish_price_feed delegate0 99999 XMO @@ -326,14 +326,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate0 99999 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1f54e72a315d17c29cd01dacc9cae8a820b97886b13a3b4442c4cf45d4aede3e5f3c5e323e00b9d57d150ff23c1ae98456a6a3745ccfaf54c35196ea4e97c91b64", - "1fc630e99ecb62dc41eda3012b64c0ab0dd090651f41eaf6cb0965e3e46c80926a7a1c39c913ebc2f8765b2320a58dd9fb14cd817dac6fd0e3678512bff9ea49a6" + "1f54e72a315d17c29cd01dacc9cae8a820b97886b13a3b4442c4cf45d4aede3e5fe4f69fd9efc9c66308077cad36b22c02f722a57e34fa0f7a51400064ae75b925", + "1fc630e99ecb62dc41eda3012b64c0ab0dd090651f41eaf6cb0965e3e46c80926a1daeabab66984b9aca45afa7b0413a005b1c651cd42388c1c6cfb1a68f4eb206" ] } default (unlocked) >>> wallet_publish_price_feed delegate1 .00002 XMO @@ -357,14 +357,14 @@ default (unlocked) >>> wallet_publish_price_feed delegate1 .00002 XMO "type": "withdraw_op_type", "data": { "balance_id": "XTS3V5xQc7Rgzs5SogiQWuVGq5wfK8EFrBoL", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1fc5c666f15451b2c5c022028ec5b0ea34e27957c6ffd97a12e74d7f47176fd38eefd074bedec5f202a9f72cbcd2be1246ec86667949c9c9063336725befd81420", - "1f455a71954b4076ff59ae182c2a126a6613aa460678af030cae007dd220eb55a767d15059043ddd79057f765398b3b47327598284802bd6b3da787d48e81015a6" + "1fc5c666f15451b2c5c022028ec5b0ea34e27957c6ffd97a12e74d7f47176fd38ed0caf725d7d098702ed3acbfd3afa6fbe3ff05b89329ed1c63d1207381557017", + "1f455a71954b4076ff59ae182c2a126a6613aa460678af030cae007dd220eb55a7e578f012204fefffe2426e8a08b5ed107cc0932630aae52600020239f9e8c121" ] } default (unlocked) >>> blockchain_get_feeds_from_delegate delegate0 @@ -373,7 +373,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate0 "price": 2, "last_update": "20140620T144040", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> blockchain_get_feeds_from_delegate delegate1 @@ -382,7 +382,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate1 "price": 0.20000000000000001, "last_update": "20140620T144040", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> debug_advance_time 1 blocks @@ -395,7 +395,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate0 "price": 99999, "last_update": "20140620T144050", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> blockchain_get_feeds_from_delegate delegate1 @@ -404,7 +404,7 @@ default (unlocked) >>> blockchain_get_feeds_from_delegate delegate1 "price": 2.0000000000000002e-05, "last_update": "20140620T144050", "asset_symbol": "XMO", - "median_price": null + "median_price": 2 } ] default (unlocked) >>> quit diff --git a/tests/regression_tests/wallet_publish_slate/wallet_publish_slate.log b/tests/regression_tests/wallet_publish_slate/wallet_publish_slate.log index 55f566fcb..9496a34eb 100644 --- a/tests/regression_tests/wallet_publish_slate/wallet_publish_slate.log +++ b/tests/regression_tests/wallet_publish_slate/wallet_publish_slate.log @@ -41,14 +41,14 @@ default (unlocked) >>> wallet_publish_slate delegate0 "type": "withdraw_op_type", "data": { "balance_id": "XTS6GvhLUV93rQZLJSstvyhMeoU9cnZ578kz", - "amount": 10000, + "amount": 50000, "claim_input_data": "" } } ], "signatures": [ - "1fa31bf8b475b41b5848cba70b97c7a5d9ab6323ae5849d8f6f14618b817e67f8e0e72d741775b628b15cb3b50e2d53bd7db1789265a79c9597147a3a8a746e100", - "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6c9cede0a97d2b3b5a8866fa7e5b56381f856491851d86f7daa512d1b4637afd90" + "1fa31bf8b475b41b5848cba70b97c7a5d9ab6323ae5849d8f6f14618b817e67f8ee71865354ee2c8f39a831e3b3ea0cad5d9c3d9a21bad4dc678fbd3b4733d9f12", + "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6caee2d97b3700b7fe626642364cc4156944c05e4d9ab01aeda852167c34c5e601" ] } default (unlocked) >>> debug_advance_time 1 blocks @@ -59,5 +59,5 @@ default (unlocked) >>> history delegate0 RECEIVED BLOCK FROM TO AMOUNT MEMO BALANCE FEE ID ============================================================================================================================================================================================== [redacted] 0 GENESIS delegate0 19,801,980.19801 XTS claim PiAmLNkx6fJD9e9GhigEhcyRSMmxmFkyns 19,801,980.19801 XTS 0.00000 XTS [redacted] -[redacted] 2 delegate0 delegate0 0.00000 XTS publish slate 13761713000375254272 19,801,980.09801 XTS 0.10000 XTS [redacted] +[redacted] 2 delegate0 delegate0 0.00000 XTS publish slate 13761713000375254272 19,801,979.69801 XTS 0.50000 XTS [redacted] default (unlocked) >>> quit diff --git a/tests/regression_tests/wallet_relock/wallet_relock.log b/tests/regression_tests/wallet_relock/wallet_relock.log index ef416c500..da023fbc0 100644 --- a/tests/regression_tests/wallet_relock/wallet_relock.log +++ b/tests/regression_tests/wallet_relock/wallet_relock.log @@ -8,12 +8,12 @@ default (locked) >>> wallet_get_info "automatic_backups": false, "transaction_scanning": true, "last_scanned_block_num": 0, - "priority_fee": "0.10000 XTS", + "transaction_fee": "0.50000 XTS", "unlocked": false, "unlocked_until": null, "unlocked_until_timestamp": null, "scan_progress": null, - "version": 101 + "version": 102 } default (locked) >>> help wallet_unlock Usage: @@ -57,12 +57,12 @@ default (locked) >>> wallet_get_info "automatic_backups": false, "transaction_scanning": true, "last_scanned_block_num": 0, - "priority_fee": "0.10000 XTS", + "transaction_fee": "0.50000 XTS", "unlocked": false, "unlocked_until": null, "unlocked_until_timestamp": null, "scan_progress": null, - "version": 101 + "version": 102 } default (locked) >>> debug_wait 6 OK @@ -74,11 +74,11 @@ default (locked) >>> wallet_get_info "automatic_backups": false, "transaction_scanning": true, "last_scanned_block_num": 0, - "priority_fee": "0.10000 XTS", + "transaction_fee": "0.50000 XTS", "unlocked": false, "unlocked_until": null, "unlocked_until_timestamp": null, "scan_progress": null, - "version": 101 + "version": 102 } default (locked) >>> quit diff --git a/tests/regression_tests/wallet_set_transaction_scanning/wallet_set_transaction_scanning.log b/tests/regression_tests/wallet_set_transaction_scanning/wallet_set_transaction_scanning.log index 1e2f9a60c..0babec0fe 100644 --- a/tests/regression_tests/wallet_set_transaction_scanning/wallet_set_transaction_scanning.log +++ b/tests/regression_tests/wallet_set_transaction_scanning/wallet_set_transaction_scanning.log @@ -6,12 +6,12 @@ default (unlocked) >>> wallet_get_info "automatic_backups": false, "transaction_scanning": true, "last_scanned_block_num": 0, - "priority_fee": "0.10000 XTS", + "transaction_fee": "0.50000 XTS", "unlocked": true, "unlocked_until": "[redacted]", "unlocked_until_timestamp": "[redacted]", "scan_progress": "100.00 %", - "version": 101 + "version": 102 } default (unlocked) >>> wallet_set_transaction_scanning false false @@ -23,12 +23,12 @@ default (unlocked) >>> wallet_get_info "automatic_backups": false, "transaction_scanning": false, "last_scanned_block_num": 0, - "priority_fee": "0.10000 XTS", + "transaction_fee": "0.50000 XTS", "unlocked": true, "unlocked_until": "[redacted]", "unlocked_until_timestamp": "[redacted]", "scan_progress": "100.00 %", - "version": 101 + "version": 102 } default (unlocked) >>> wallet_set_transaction_scanning true true @@ -40,11 +40,11 @@ default (unlocked) >>> wallet_get_info "automatic_backups": false, "transaction_scanning": true, "last_scanned_block_num": 0, - "priority_fee": "0.10000 XTS", + "transaction_fee": "0.50000 XTS", "unlocked": true, "unlocked_until": "[redacted]", "unlocked_until_timestamp": "[redacted]", "scan_progress": "100.00 %", - "version": 101 + "version": 102 } default (unlocked) >>> quit diff --git a/tests/regression_tests/wallet_transfer/wallet_transfer.log b/tests/regression_tests/wallet_transfer/wallet_transfer.log index 61ac7bf5b..4188fc007 100644 --- a/tests/regression_tests/wallet_transfer/wallet_transfer.log +++ b/tests/regression_tests/wallet_transfer/wallet_transfer.log @@ -29,7 +29,7 @@ aliases: transfer default (unlocked) >>> wallet_transfer 100 XTS delegate0 test RECEIVED BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== -[redacted] PENDING delegate0 test 100.00000 XTS 0.10000 XTS [redacted] +[redacted] PENDING delegate0 test 100.00000 XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_advance_time 1 blocks OK default (unlocked) >>> debug_wait 2 @@ -37,7 +37,7 @@ OK default (unlocked) >>> wallet_account_balance delegate0 ACCOUNT BALANCE ============================================================ -delegate0 19,801,880.09801 XTS +delegate0 19,801,879.69801 XTS default (unlocked) >>> wallet_account_balance test ACCOUNT BALANCE ============================================================ diff --git a/tests/regression_tests/wallet_transfer_from/wallet_transfer_from.log b/tests/regression_tests/wallet_transfer_from/wallet_transfer_from.log index d89c6bfb4..5ef10644b 100644 --- a/tests/regression_tests/wallet_transfer_from/wallet_transfer_from.log +++ b/tests/regression_tests/wallet_transfer_from/wallet_transfer_from.log @@ -32,7 +32,7 @@ Returns: default (unlocked) >>> wallet_transfer_from 100 XTS delegate1 delegate0 test { "index": 414, - "record_id": "7ed593209d21850d6a9991f42d5fa2234838f2bc", + "record_id": "9f0fad037607d57266cb20d94ed39e5b4cce8f7a", "block_num": 0, "is_virtual": false, "is_confirmed": false, @@ -44,7 +44,7 @@ default (unlocked) >>> wallet_transfer_from 100 XTS delegate1 delegate0 test "type": "withdraw_op_type", "data": { "balance_id": "XTS3V5xQc7Rgzs5SogiQWuVGq5wfK8EFrBoL", - "amount": 10010000, + "amount": 10050000, "claim_input_data": "" } },{ @@ -67,7 +67,7 @@ default (unlocked) >>> wallet_transfer_from 100 XTS delegate1 delegate0 test } ], "signatures": [ - "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6c8e50f3f576bb9521302aafc1131592ab343e56b0b0c8a7dbdfd52361385827cc" + "1f2c364618493f85455491b476687b015918324bb75417411b3c3909281a3cca6c5426665c551f38d03382e1df95d53955bc09be226812e0cca5d96d53b516167d" ] }, "ledger_entries": [{ @@ -82,7 +82,7 @@ default (unlocked) >>> wallet_transfer_from 100 XTS delegate1 delegate0 test } ], "fee": { - "amount": 10000, + "amount": 50000, "asset_id": 0 }, "created_time": "20140620T144030", @@ -104,7 +104,7 @@ delegate0 19,801,980.19801 XTS default (unlocked) >>> wallet_account_balance delegate1 ACCOUNT BALANCE ============================================================ -delegate1 19,801,880.09801 XTS +delegate1 19,801,879.69801 XTS default (unlocked) >>> wallet_account_balance test ACCOUNT BALANCE ============================================================ From d0a798b8e2929249dd8e19158c5306a66363d92f Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Sun, 17 Aug 2014 21:46:45 +0000 Subject: [PATCH 19/32] update feed.py --- programs/feed.py | 2 +- programs/qt_wallet | 2 +- programs/web_wallet | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/programs/feed.py b/programs/feed.py index 40004d67d..28097f639 100644 --- a/programs/feed.py +++ b/programs/feed.py @@ -13,7 +13,7 @@ port = int(sys.argv[3]) delegates = [] if len(sys.argv[4]) < 3: - for i in range(30): + for i in range(51): delegates.append("init" + str(i)) else: delegates = eval(sys.argv[4]) diff --git a/programs/qt_wallet b/programs/qt_wallet index fb763f360..d36ac7574 160000 --- a/programs/qt_wallet +++ b/programs/qt_wallet @@ -1 +1 @@ -Subproject commit fb763f36091e7293f45719879a13f3b3a0a86c58 +Subproject commit d36ac7574cd30f7b0147f6705610517fbfdef1b7 diff --git a/programs/web_wallet b/programs/web_wallet index b0665bc78..1166d40df 160000 --- a/programs/web_wallet +++ b/programs/web_wallet @@ -1 +1 @@ -Subproject commit b0665bc780c1963f860503ef138e05650bdae6de +Subproject commit 1166d40df5a128cd331ffd9cac5f5366ec8910af From 127c70867d7cedf07d491c6bd8ec734d63499fcd Mon Sep 17 00:00:00 2001 From: Gandalf-the-Grey Date: Mon, 18 Aug 2014 10:18:05 -0400 Subject: [PATCH 20/32] Enable qt_wallet in Win32 jenkins build, ensure getting npm deps to proper location. --- HelperScripts/jenkins_build32.bat | 8 +++++++- setenv.bat | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/HelperScripts/jenkins_build32.bat b/HelperScripts/jenkins_build32.bat index 0f27ad3f6..cb370614e 100644 --- a/HelperScripts/jenkins_build32.bat +++ b/HelperScripts/jenkins_build32.bat @@ -20,10 +20,16 @@ if exist leveldb-win ( cd %WORKSPACE% call bitshares_toolkit/setenv.bat || exit /b 26 + +call npm install grunt +call npm install lineman -g --prefix=%NPM_INSTALL_PREFIX% +call npm install lineman-angular +call npm install lineman-less + if exist build ( rmdir /Q /S build || exit /b 27 ) mkdir build cd build -cmake -G "Visual Studio 12" ../bitshares_toolkit || exit /b 28 +cmake -DINCLUDE_QT_WALLET=TRUE -DFORCE_BUILDWEB_GENERATION=TRUE -G "Visual Studio 12" ../bitshares_toolkit || exit /b 28 msbuild.exe /M:%NUMBER_OF_PROCESSORS% /p:Configuration=RelWithDebinfo /p:Platform=Win32 /target:rebuild /clp:ErrorsOnly BitShares.sln || exit /b 30 diff --git a/setenv.bat b/setenv.bat index b06da0e3e..d7c677e1d 100644 --- a/setenv.bat +++ b/setenv.bat @@ -10,7 +10,8 @@ set QTDIR=%BITSHARES_ROOT%\QT set ICUROOT=%BITSHARES_ROOT%\ICU set BOOST_ROOT=%BITSHARES_ROOT%\boost_1.55 -set PATH=%APPDATA%\npm;%QTDIR%\bin;%ICUROOT%\bin;%ICUROOT%\lib;%BITSHARES_ROOT%\bin;%BITSHARES_ROOT%\Cmake\bin;%BOOST_ROOT%\stage\lib;%PATH% +set NPM_INSTALL_PREFIX=%BITSHARES_ROOT%\npm +set PATH=%NPM_INSTALL_PREFIX%;%APPDATA%\npm;%QTDIR%\bin;%ICUROOT%\bin;%ICUROOT%\lib;%BITSHARES_ROOT%\bin;%BITSHARES_ROOT%\Cmake\bin;%BOOST_ROOT%\stage\lib;%PATH% set CMAKE_PREFIX_PATH=%QTDIR% set QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%\plugins\platforms From 53053be7b1e49c176aa086efc35626931c35ac9b Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Mon, 18 Aug 2014 11:16:15 -0400 Subject: [PATCH 21/32] updating market engine --- libraries/blockchain/market_engine.cpp | 138 +++++++++++------------- libraries/blockchain/market_records.cpp | 3 +- programs/qt_wallet | 2 +- programs/web_wallet | 2 +- 4 files changed, 68 insertions(+), 77 deletions(-) diff --git a/libraries/blockchain/market_engine.cpp b/libraries/blockchain/market_engine.cpp index 908eb5c18..dd53e105f 100644 --- a/libraries/blockchain/market_engine.cpp +++ b/libraries/blockchain/market_engine.cpp @@ -20,7 +20,7 @@ class market_engine auto quote_asset = _pending_state->get_asset_record( _quote_id ); auto base_asset = _pending_state->get_asset_record( _base_id ); - // the order book is soreted from low to high price, so to get the last item (highest bid), we need to go to the first item in the + // the order book is sorted from low to high price, so to get the last item (highest bid), we need to go to the first item in the // next market class and then back up one auto next_pair = base_id+1 == quote_id ? price( 0, quote_id+1, 0) : price( 0, quote_id, base_id+1 ); _bid_itr = _db_impl._bid_db.lower_bound( market_index_key( next_pair ) ); @@ -43,9 +43,6 @@ class market_engine if( _collateral_itr.valid() ) --_collateral_itr; else _collateral_itr = _db_impl._collateral_db.last(); - asset consumed_bid_depth(0,base_id); - asset consumed_ask_depth(0,base_id); - asset trading_volume(0, base_id); omarket_status market_stat = _pending_state->get_market_status( _quote_id, _base_id ); @@ -164,27 +161,30 @@ class market_engine _current_ask.reset(); continue; } + + if( mtrx.bid_price > max_short_bid ) + { + wlog( "skipping short ${x} < max_short_bid ${b}", ("x",mtrx.bid_price)("b", max_short_bid) ); + _current_bid.reset(); + continue; + } + mtrx.ask_price = mtrx.bid_price; // we want to sell enough XTS to cover our balance. - ask_quantity_xts = current_ask_balance * mtrx.ask_price; + ask_quantity_xts = current_ask_balance * mtrx.bid_price; + + if( ask_quantity_xts.amount > *_current_ask->collateral ) + ask_quantity_xts.amount = *_current_ask->collateral; + auto quantity_xts = std::min( bid_quantity_xts, ask_quantity_xts ); - if( ask_quantity_xts == quantity_xts ) - { - mtrx.ask_received = current_ask_balance; - mtrx.bid_paid = current_ask_balance; - xts_paid_by_short = quantity_xts; - } - else - { - mtrx.ask_received = quantity_xts * mtrx.ask_price; - mtrx.bid_paid = current_bid_balance * mtrx.bid_price; - xts_paid_by_short = current_bid_balance; - } + mtrx.bid_paid = quantity_xts * mtrx.bid_price; + mtrx.ask_received = mtrx.bid_paid; + xts_paid_by_short = quantity_xts; // rounding errors go into collateral, round to the nearest 1 XTS - if( bid_quantity_xts.amount - quantity_xts.amount < BTS_BLOCKCHAIN_PRECISION ) + if( bid_quantity_xts.amount - xts_paid_by_short.amount < BTS_BLOCKCHAIN_PRECISION ) xts_paid_by_short = bid_quantity_xts; mtrx.ask_paid = quantity_xts; @@ -193,21 +193,7 @@ class market_engine // the short always pays the quantity. FC_ASSERT( xts_paid_by_short <= current_bid_balance ); - - if( mtrx.ask_paid.amount > *_current_ask->collateral ) - { - wlog( "skipping margin call because best bid is insufficient to cover" ); - // skip it... - _current_ask.reset(); - continue; - } - - if( mtrx.bid_price < min_cover_ask ) - { - wlog( "skipping short price ${x} < min_cover_ask ${b}", ("x",_current_bid->get_price())("b", min_cover_ask) ); - _current_ask.reset(); - continue; - } + FC_ASSERT( mtrx.ask_paid.amount <= *_current_ask->collateral ); order_did_execute = true; pay_current_short( mtrx, xts_paid_by_short, *quote_asset ); @@ -225,6 +211,18 @@ class market_engine break; // the call price has not been reached mtrx.ask_price = mtrx.bid_price; + + /** + * Don't cover at prices below the minimum cover price this is designed to prevent manipulation + * where the cover must accept very low USD valuations + */ + if( mtrx.bid_price < min_cover_ask ) + { + wlog( "skipping ${x} < min_cover_ask ${b}", ("x",_current_bid->get_price())("b", min_cover_ask) ); + _current_ask.reset(); + continue; + } + auto max_usd_purchase = asset(*_current_ask->collateral,0) * mtrx.bid_price; auto usd_exchanged = std::min( current_bid_balance, max_usd_purchase ); @@ -239,16 +237,6 @@ class market_engine mtrx.bid_received = mtrx.ask_paid; - /** - * Don't cover at prices below the minimum cover price this is designed to prevent manipulation - * where the cover must accept very low USD valuations - */ - if( mtrx.bid_price < min_cover_ask ) - { - wlog( "skipping ${x} < min_cover_ask ${b}", ("x",_current_bid->get_price())("b", min_cover_ask) ); - _current_ask.reset(); - continue; - } market_stat->ask_depth -= mtrx.ask_paid.amount; order_did_execute = true; @@ -259,6 +247,14 @@ class market_engine { if( mtrx.bid_price < mtrx.ask_price ) break; FC_ASSERT( quote_asset->is_market_issued() && base_id == 0 ); + + if( mtrx.bid_price > max_short_bid ) + { + wlog( "skipping short ${x} < max_short_bid ${b}", ("x",mtrx.bid_price)("b", max_short_bid) ); + _current_bid.reset(); + continue; + } + auto quantity_xts = std::min( bid_quantity_xts, ask_quantity_xts ); mtrx.bid_paid = quantity_xts * mtrx.bid_price; @@ -273,12 +269,6 @@ class market_engine if( bid_quantity_xts.amount - quantity_xts.amount < BTS_BLOCKCHAIN_PRECISION ) xts_paid_by_short = bid_quantity_xts; - if( mtrx.bid_price > max_short_bid ) - { - wlog( "skipping short ${x} < max_short_bid ${b}", ("x",mtrx.bid_price)("b", max_short_bid) ); - _current_bid.reset(); - continue; - } FC_ASSERT( xts_paid_by_short <= _current_bid->get_balance() ); order_did_execute = true; @@ -322,6 +312,7 @@ class market_engine trading_volume += mtrx.ask_received; else if( mtrx.bid_received.asset_id == 0 ) trading_volume += mtrx.bid_received; + accumulate_fees( mtrx, *quote_asset ); } // while( next bid && next ask ) @@ -472,8 +463,9 @@ class market_engine quote_asset.current_share_supply += mtrx.bid_paid.amount; auto collateral = xts_paid_by_short + mtrx.ask_paid; - if( mtrx.bid_paid.amount <= 0 ) + if( mtrx.bid_paid.amount <= 0 ) // WHY is this ever negitive?? { + FC_ASSERT( mtrx.bid_paid.amount >= 0 ); //ulog( "bid paid ${c} collateral ${xts} \nbid: ${current}\nask: ${ask}", ("c",mtrx.bid_paid)("xts",xts_paid_by_short)("current", (*_current_bid))("ask",*_current_ask) ); _current_bid->state.balance -= xts_paid_by_short.amount; return; @@ -551,7 +543,7 @@ class market_engine if( _current_ask->state.balance == 0 && *_current_ask->collateral > 0 ) // no more USD left { // send collateral home to mommy & daddy - wlog( " collateral balance is now 0!" ); + //wlog( " collateral balance is now 0!" ); auto ask_balance_address = withdraw_condition( withdraw_with_signature(_current_ask->get_owner()), _base_id ).get_address(); @@ -596,31 +588,29 @@ class market_engine void pay_current_ask( const market_transaction& mtrx, asset_record& base_asset ) { try { - if( _current_ask->type == ask_order ) // update ask + payout - { - _current_ask->state.balance -= mtrx.ask_paid.amount; - FC_ASSERT( _current_ask->state.balance >= 0 ); - - auto ask_balance_address = withdraw_condition( withdraw_with_signature(mtrx.ask_owner), _quote_id ).get_address(); - auto ask_payout = _pending_state->get_balance_record( ask_balance_address ); - if( !ask_payout ) - ask_payout = balance_record( mtrx.ask_owner, asset(0,_quote_id), 0 ); - ask_payout->balance += mtrx.ask_received.amount; - ask_payout->last_update = _pending_state->now(); - - _pending_state->store_balance_record( *ask_payout ); - - - // if the balance is less than 1 XTS then it gets collected as fees. - if( (_current_ask->get_quantity() * _current_ask->get_price()).amount == 0 ) - { - base_asset.collected_fees += _current_ask->get_quantity().amount; - _current_ask->state.balance = 0; - } - _pending_state->store_ask_record( _current_ask->market_index, _current_ask->state ); + FC_ASSERT( _current_ask->type == ask_order ) // update ask + payout + + _current_ask->state.balance -= mtrx.ask_paid.amount; + FC_ASSERT( _current_ask->state.balance >= 0 ); + + auto ask_balance_address = withdraw_condition( withdraw_with_signature(mtrx.ask_owner), _quote_id ).get_address(); + auto ask_payout = _pending_state->get_balance_record( ask_balance_address ); + if( !ask_payout ) + ask_payout = balance_record( mtrx.ask_owner, asset(0,_quote_id), 0 ); + ask_payout->balance += mtrx.ask_received.amount; + ask_payout->last_update = _pending_state->now(); + + _pending_state->store_balance_record( *ask_payout ); - } else { // if cover_order + + // if the balance is less than 1 XTS * PRICE < .001 USD XTS goes to fees + if( (_current_ask->get_quantity() * _current_ask->get_price()).amount == 0 ) + { + base_asset.collected_fees += _current_ask->get_quantity().amount; + _current_ask->state.balance = 0; } + _pending_state->store_ask_record( _current_ask->market_index, _current_ask->state ); + } FC_CAPTURE_AND_RETHROW( (mtrx) ) } // pay_current_ask void accumulate_fees( const market_transaction& mtrx, asset_record& quote_asset ) diff --git a/libraries/blockchain/market_records.cpp b/libraries/blockchain/market_records.cpp index c7fb48661..e58135798 100644 --- a/libraries/blockchain/market_records.cpp +++ b/libraries/blockchain/market_records.cpp @@ -89,7 +89,8 @@ asset market_order::get_quote_quantity()const default: FC_ASSERT( !"Not Implemented" ); } - return get_balance() * get_price(); + // NEVER GET HERE..... + // return get_balance() * get_price(); } } } // bts::blockchain diff --git a/programs/qt_wallet b/programs/qt_wallet index fb763f360..2f3830ef5 160000 --- a/programs/qt_wallet +++ b/programs/qt_wallet @@ -1 +1 @@ -Subproject commit fb763f36091e7293f45719879a13f3b3a0a86c58 +Subproject commit 2f3830ef573ced92b3e305d3b5fc2785d3ae9e0c diff --git a/programs/web_wallet b/programs/web_wallet index b0665bc78..668975192 160000 --- a/programs/web_wallet +++ b/programs/web_wallet @@ -1 +1 @@ -Subproject commit b0665bc780c1963f860503ef138e05650bdae6de +Subproject commit 668975192301e9f5df3c5610a97f85e0691a551e From d81473394e7094022810466254308c8ecccda641 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Mon, 18 Aug 2014 11:35:46 -0400 Subject: [PATCH 22/32] Add callback to {client,chain_database}::open to give reindexing status --- libraries/blockchain/chain_database.cpp | 14 ++++++++++---- .../include/bts/blockchain/chain_database.hpp | 7 ++++++- libraries/client/client.cpp | 6 +++--- libraries/client/include/bts/client/client.hpp | 5 +++-- programs/qt_wallet | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/libraries/blockchain/chain_database.cpp b/libraries/blockchain/chain_database.cpp index 59698d433..3e196d869 100644 --- a/libraries/blockchain/chain_database.cpp +++ b/libraries/blockchain/chain_database.cpp @@ -985,7 +985,7 @@ namespace bts { namespace blockchain { return sorted_delegates; } FC_RETHROW_EXCEPTIONS( warn, "" ) } - void chain_database::open( const fc::path& data_dir, fc::optional genesis_file ) + void chain_database::open( const fc::path& data_dir, fc::optional genesis_file, std::function reindex_status_callback ) { try { bool is_new_data_dir = !fc::exists( data_dir ); try @@ -1017,16 +1017,22 @@ namespace bts { namespace blockchain { my->open_database( data_dir ); my->initialize_genesis( genesis_file ); - std::cout << "Please be patient, this could take a few minutes.\r\nRe-indexing database... [/]" << std::flush; + if( !reindex_status_callback ) + std::cout << "Please be patient, this could take a few minutes.\r\nRe-indexing database... [/]" << std::flush; + else + reindex_status_callback(0u); const char spinner[] = "-\\|/"; - int blocks_indexed = 0; + uint32_t blocks_indexed = 0; auto start_time = blockchain::now(); auto block_itr = my->_block_id_to_block_data_db.begin(); while( block_itr.valid() ) { - std::cout << "\rRe-indexing database... [" << spinner[blocks_indexed++ % 4] << "]" << std::flush; + if( !reindex_status_callback ) + std::cout << "\rRe-indexing database... [" << spinner[blocks_indexed++ % 4] << "]" << std::flush; + else + reindex_status_callback(blocks_indexed); auto block = block_itr.value(); ++block_itr; diff --git a/libraries/blockchain/include/bts/blockchain/chain_database.hpp b/libraries/blockchain/include/bts/blockchain/chain_database.hpp index 72dba4be9..65b59a95b 100644 --- a/libraries/blockchain/include/bts/blockchain/chain_database.hpp +++ b/libraries/blockchain/include/bts/blockchain/chain_database.hpp @@ -92,7 +92,12 @@ namespace bts { namespace blockchain { chain_database(); virtual ~chain_database()override; - void open( const fc::path& data_dir, fc::optional genesis_file ); + /** + * @brief open Open the databases, reindexing as necessary + * @param reindex_status_callback Called for each reindexed block, with the count of blocks reindexed so far + */ + void open(const fc::path& data_dir, fc::optional genesis_file , + std::function reindex_status_callback = std::function()); void close(); void add_observer( chain_observer* observer ); diff --git a/libraries/client/client.cpp b/libraries/client/client.cpp index ab5f308db..17bea19ac 100644 --- a/libraries/client/client.cpp +++ b/libraries/client/client.cpp @@ -1477,7 +1477,7 @@ config load_config( const fc::path& datadir ) my->_simulate_disconnect = state; } - void client::open( const path& data_dir, fc::optional genesis_file_path ) + void client::open( const path& data_dir, fc::optional genesis_file_path, std::function reindex_status_callback ) { try { my->_config = load_config(data_dir); @@ -1526,7 +1526,7 @@ config load_config( const fc::path& datadir ) try { - my->_chain_db->open( data_dir / "chain", genesis_file_path ); + my->_chain_db->open( data_dir / "chain", genesis_file_path, reindex_status_callback ); } catch( const db::db_in_use_exception& e ) { @@ -1534,7 +1534,7 @@ config load_config( const fc::path& datadir ) { elog("Chain database corrupted. Deleting it and attempting to recover."); fc::remove_all( data_dir / "chain" ); - my->_chain_db->open( data_dir / "chain", genesis_file_path ); + my->_chain_db->open( data_dir / "chain", genesis_file_path, reindex_status_callback ); } } catch( const fc::exception& e ) diff --git a/libraries/client/include/bts/client/client.hpp b/libraries/client/include/bts/client/client.hpp index 746d4c7b3..964a74f7f 100644 --- a/libraries/client/include/bts/client/client.hpp +++ b/libraries/client/include/bts/client/client.hpp @@ -112,8 +112,9 @@ namespace bts { namespace client { void start_networking(std::function network_started_callback = std::function()); void configure_from_command_line(int argc, char** argv); fc::future start(); - void open( const path& data_dir, - optional genesis_file_path = optional()); + void open(const path& data_dir, + optional genesis_file_path = optional(), + std::function reindex_status_callback = std::function()); void init_cli(); void set_daemon_mode(bool daemon_mode); diff --git a/programs/qt_wallet b/programs/qt_wallet index fb763f360..f720287ea 160000 --- a/programs/qt_wallet +++ b/programs/qt_wallet @@ -1 +1 @@ -Subproject commit fb763f36091e7293f45719879a13f3b3a0a86c58 +Subproject commit f720287ea63eef1fdcd0c60e49ae06700684fe34 From e1dec2da74d3f79b7970dd6bb98f94f9285704e2 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Mon, 18 Aug 2014 15:37:35 +0000 Subject: [PATCH 23/32] bump test net iteration --- libraries/blockchain/include/bts/blockchain/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/blockchain/include/bts/blockchain/config.hpp b/libraries/blockchain/include/bts/blockchain/config.hpp index 6d6f10dd4..f7df7ba7b 100644 --- a/libraries/blockchain/include/bts/blockchain/config.hpp +++ b/libraries/blockchain/include/bts/blockchain/config.hpp @@ -4,7 +4,7 @@ /* Set to true only for test network */ #define BTS_TEST_NETWORK true -#define BTS_TEST_NETWORK_VERSION 16 +#define BTS_TEST_NETWORK_VERSION 17 /** @file bts/blockchain/config.hpp * @brief Defines global constants that determine blockchain behavior From 1694f79a8a1719447039e97c1a04f1dd307ef3ff Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Mon, 18 Aug 2014 11:39:59 -0400 Subject: [PATCH 24/32] Update submodules --- programs/qt_wallet | 2 +- programs/web_wallet | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/qt_wallet b/programs/qt_wallet index fb763f360..f720287ea 160000 --- a/programs/qt_wallet +++ b/programs/qt_wallet @@ -1 +1 @@ -Subproject commit fb763f36091e7293f45719879a13f3b3a0a86c58 +Subproject commit f720287ea63eef1fdcd0c60e49ae06700684fe34 diff --git a/programs/web_wallet b/programs/web_wallet index b0665bc78..420387d25 160000 --- a/programs/web_wallet +++ b/programs/web_wallet @@ -1 +1 @@ -Subproject commit b0665bc780c1963f860503ef138e05650bdae6de +Subproject commit 420387d257d5a27cfb5ae8239d4a661c805b4e3d From 05993607222d86b4c0fb5a37d5284311d0c5bcf4 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Mon, 18 Aug 2014 17:45:25 -0400 Subject: [PATCH 25/32] Fix FDIC accounting and prices in order book --- libraries/blockchain/market_engine.cpp | 2 +- libraries/client/client.cpp | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/libraries/blockchain/market_engine.cpp b/libraries/blockchain/market_engine.cpp index dd53e105f..8a6b76f71 100644 --- a/libraries/blockchain/market_engine.cpp +++ b/libraries/blockchain/market_engine.cpp @@ -536,7 +536,7 @@ class market_engine quote_asset.current_share_supply -= mtrx.ask_received.amount; if( *_current_ask->collateral == 0 ) { - quote_asset.current_share_supply -= _current_ask->state.balance; + quote_asset.collected_fees -= _current_ask->state.balance; _current_ask->state.balance = 0; } diff --git a/libraries/client/client.cpp b/libraries/client/client.cpp index 17bea19ac..4c0276e0c 100644 --- a/libraries/client/client.cpp +++ b/libraries/client/client.cpp @@ -960,14 +960,6 @@ config load_config( const fc::path& datadir ) void client_impl::rebroadcast_pending() { -#ifndef NDEBUG - static bool currently_running = false; - struct checker { - bool& var; - checker(bool& var) : var(var) { assert(!var); var = true; } - ~checker() { var = false; } - } _checker(currently_running); -#endif // !NDEBUG if (_sync_mode) { wlog("skip rebroadcast_pending while syncing"); From 2c6afdd05dd8df59585a84e3ca9f2b1ab56e0746 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Mon, 18 Aug 2014 17:56:50 -0400 Subject: [PATCH 26/32] Add test of market failure (insufficient collateral to cover) --- libraries/cli/cli.cpp | 34 ++++++++--------- tests/nathan_tests.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 18 deletions(-) create mode 100644 tests/nathan_tests.cpp diff --git a/libraries/cli/cli.cpp b/libraries/cli/cli.cpp index 46fa08a96..0459e72af 100644 --- a/libraries/cli/cli.cpp +++ b/libraries/cli/cli.cpp @@ -998,29 +998,27 @@ namespace bts { namespace cli { } } - auto recent_average_price = _client->get_chain()->get_median_delegate_price( quote_id ); + auto recent_average_price = _client->get_chain()->get_market_status(quote_id, base_id)->avg_price_24h; *_out << "Average Price in Recent Trades: " - << (recent_average_price ? _client->get_chain()->to_pretty_price( *recent_average_price ) : "NO FEEDS" ) - <<" "; + << _client->get_chain()->to_pretty_price(recent_average_price) + << " "; auto status = _client->get_chain()->get_market_status( quote_id, base_id ); if( status ) { - if( recent_average_price ) - { - auto maximum_short_price = *recent_average_price; - maximum_short_price.ratio *= 4; - maximum_short_price.ratio /= 3; - auto minimum_cover_price = *recent_average_price; - minimum_cover_price.ratio *= 2; - minimum_cover_price.ratio /= 3; - *_out << "Maximum Short Price: " - << _client->get_chain()->to_pretty_price( maximum_short_price ) - <<" "; - *_out << "Minimum Cover Price: " - << _client->get_chain()->to_pretty_price( minimum_cover_price ) - <<"\n"; - } + auto maximum_short_price = recent_average_price; + maximum_short_price.ratio *= 4; + maximum_short_price.ratio /= 3; + auto minimum_cover_price = recent_average_price; + minimum_cover_price.ratio *= 2; + minimum_cover_price.ratio /= 3; + *_out << "Maximum Short Price: " + << _client->get_chain()->to_pretty_price( maximum_short_price ) + <<" "; + *_out << "Minimum Cover Price: " + << _client->get_chain()->to_pretty_price( minimum_cover_price ) + <<"\n"; + *_out << "Bid Depth: " << _client->get_chain()->to_pretty_asset( asset(status->bid_depth, base_id) ) <<" "; *_out << "Ask Depth: " << _client->get_chain()->to_pretty_asset( asset(status->ask_depth, base_id) ) <<" "; *_out << "Min Depth: " << _client->get_chain()->to_pretty_asset( asset(BTS_BLOCKCHAIN_MARKET_DEPTH_REQUIREMENT) ) <<"\n"; diff --git a/tests/nathan_tests.cpp b/tests/nathan_tests.cpp new file mode 100644 index 000000000..e91e821b1 --- /dev/null +++ b/tests/nathan_tests.cpp @@ -0,0 +1,83 @@ +#define BOOST_TEST_MODULE BlockchainTests2cc +#include +#include "dev_fixture.hpp" + +BOOST_FIXTURE_TEST_CASE( printing_dollars, chain_fixture ) +{ try { + enable_logging(); + exec(clienta, "scan"); + exec(clientb, "scan"); + exec(clienta, "wallet_delegate_set_block_production ALL true"); + exec(clientb, "wallet_delegate_set_block_production ALL true"); + exec(clienta, "wallet_set_transaction_scanning true"); + exec(clientb, "wallet_set_transaction_scanning true"); + exec(clienta, "balance"); + exec(clientb, "balance"); + + exec(clienta, "wallet_asset_create USD \"Federal Reserve Floats\" delegate21 \"100% Genuine United States Fiat\" \"arbitrary data!\" 1000000000 10000 true"); + + produce_block(clienta); + + exec(clientb, "wallet_publish_price_feed delegate22 .02 USD" ); + exec(clientb, "wallet_publish_price_feed delegate24 .02 USD" ); + exec(clientb, "wallet_publish_price_feed delegate26 .02 USD" ); + exec(clientb, "wallet_publish_price_feed delegate28 .02 USD" ); + exec(clienta, "wallet_publish_price_feed delegate23 .02 USD" ); + exec(clienta, "wallet_publish_price_feed delegate25 .02 USD" ); + exec(clienta, "wallet_publish_price_feed delegate27 .02 USD" ); + exec(clienta, "wallet_publish_price_feed delegate29 .02 USD" ); + exec(clienta, "wallet_publish_price_feed delegate31 .02 USD" ); + exec(clienta, "wallet_publish_price_feed delegate33 .02 USD" ); + + produce_block(clienta); + std::cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; + + exec(clienta, "short delegate21 10000 .001 USD"); + exec(clientb, "ask delegate20 10000000 XTS .05 USD"); + + produce_block(clienta); + + exec(clienta, "short delegate23 100 .01 USD"); + exec(clientb, "ask delegate22 10000 XTS .01 USD"); + + produce_block(clienta); + produce_block(clienta); + + exec(clientb, "wallet_market_cancel_order XTS6qdRRcxniUpYkvo7kBZQVEqyQDTEXC4uV"); + exec(clientb, "ask delegate20 9000000 XTS .005 USD"); + + for (int i = 0; i < 360 - 92; ++i) + { + exec(clienta, "ask delegate23 100 XTS .002 USD"); + exec(clientb, "bid delegate22 100 XTS .002 USD"); + produce_block(clienta); + produce_block(clienta); + exec(clientb, "ask delegate22 100 XTS .002 USD"); + exec(clienta, "bid delegate23 100 XTS .002 USD"); + produce_block(clienta); + produce_block(clienta); + } + + exec(clienta, "blockchain_get_asset USD"); + + exec(clientb, "bid delegate22 25000 XTS .004 USD"); + + produce_block(clienta); + produce_block(clienta); + + exec(clienta, "balance"); + exec(clientb, "balance"); + exec(clienta, "blockchain_market_order_history USD XTS"); + exec(clienta, "blockchain_market_order_book USD XTS"); + + exec(clienta, "blockchain_get_asset USD"); + + string cmd; + std::getline(std::cin, cmd); + while (!cmd.empty()) { + exec(clienta, cmd); + exec(clientb, cmd); + std::getline(std::cin, cmd); + } + +} FC_LOG_AND_RETHROW() } From 4d67f6fcf34ea7e382a929696adb970509ee7614 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Mon, 18 Aug 2014 18:42:43 -0400 Subject: [PATCH 27/32] Fix get_info next round time and next block production time --- libraries/cli/pretty.cpp | 5 ++--- libraries/client/client.cpp | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/cli/pretty.cpp b/libraries/cli/pretty.cpp index 0b7b53392..e8ade8277 100644 --- a/libraries/cli/pretty.cpp +++ b/libraries/cli/pretty.cpp @@ -115,7 +115,7 @@ string pretty_info( fc::mutable_variant_object info, cptr client ) info["blockchain_next_round_timestamp"] = pretty_timestamp( *next_round_timestamp ); if( !info["blockchain_next_round_time"].is_null() ) - info["blockchain_next_round_time"] = pretty_age( *next_round_timestamp, true ); + info["blockchain_next_round_time"] = "at least " + pretty_age( *next_round_timestamp, true ); } const auto data_dir = info["client_data_dir"].as(); @@ -148,15 +148,14 @@ string pretty_info( fc::mutable_variant_object info, cptr client ) if( !info["wallet_next_block_production_timestamp"].is_null() ) { const auto next_block_timestamp = info["wallet_next_block_production_timestamp"].as(); + info["wallet_next_block_production_timestamp"] = pretty_timestamp( next_block_timestamp ); if( !next_round_timestamp.valid() || next_block_timestamp < *next_round_timestamp ) { - info["wallet_next_block_production_timestamp"] = pretty_timestamp( next_block_timestamp ); if( !info["wallet_next_block_production_time"].is_null() ) info["wallet_next_block_production_time"] = pretty_age( next_block_timestamp, true ); } else { - info["wallet_next_block_production_timestamp"] = variant(); if( !info["wallet_next_block_production_time"].is_null() ) info["wallet_next_block_production_time"] = "at least " + pretty_age( *next_round_timestamp, true ); } diff --git a/libraries/client/client.cpp b/libraries/client/client.cpp index 4c0276e0c..1b5c83e23 100644 --- a/libraries/client/client.cpp +++ b/libraries/client/client.cpp @@ -2636,7 +2636,8 @@ config load_config( const fc::path& datadir ) info["blockchain_next_round_timestamp"] = variant(); if( head_block_num > 0 ) { - const auto next_round_timestamp = head_block_timestamp + (blocks_left * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC); + const auto current_round_timestamp = blockchain::get_slot_start_time( now ); + const auto next_round_timestamp = current_round_timestamp + (blocks_left * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC); info["blockchain_next_round_time"] = ( next_round_timestamp - now ).to_seconds(); info["blockchain_next_round_timestamp"] = next_round_timestamp; } From 98e054abc03ecbb7d46ee7a837a7fc8633441fde Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Mon, 18 Aug 2014 18:54:31 -0400 Subject: [PATCH 28/32] Compile nathan_tests by default --- .gitignore | 1 + tests/CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index db42d98a7..e02f9ff26 100644 --- a/.gitignore +++ b/.gitignore @@ -42,5 +42,6 @@ tests/client_node tests/client_rpc_tests/client_rpc_tests tests/deterministic_signature_test tests/dev_tests +tests/nathan_tests tests/server_node tests/wallet_tests diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 375f292ba..eb1d0279c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -57,6 +57,9 @@ target_link_libraries( wallet_tests deterministic_openssl_rand bts_client bts_cl add_executable( dev_tests dev_tests.cpp ) target_link_libraries( dev_tests deterministic_openssl_rand bts_client bts_cli bts_wallet bts_blockchain bts_net bitcoin fc ) +add_executable( nathan_tests nathan_tests.cpp ) +target_link_libraries( nathan_tests deterministic_openssl_rand bts_client bts_cli bts_wallet bts_blockchain bts_net bitcoin fc ) + #add_executable( server_node server_node.cpp ) #target_link_libraries( server_node bts_client bts_network bts_net fc bts_cli ) From adf6e09e3a276764aaabf7a2bbcdc3460676dae4 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Mon, 18 Aug 2014 18:58:04 -0400 Subject: [PATCH 29/32] Restore accidentally deleted code --- libraries/client/client.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/client/client.cpp b/libraries/client/client.cpp index 1b5c83e23..df058b523 100644 --- a/libraries/client/client.cpp +++ b/libraries/client/client.cpp @@ -960,6 +960,14 @@ config load_config( const fc::path& datadir ) void client_impl::rebroadcast_pending() { +#ifndef NDEBUG + static bool currently_running = false; + struct checker { + bool& var; + checker(bool& var) : var(var) { assert(!var); var = true; } + ~checker() { var = false; } + } _checker(currently_running); +#endif // !NDEBUG if (_sync_mode) { wlog("skip rebroadcast_pending while syncing"); From 8680aac29f68ba9af4c124084a0476ca7bafcad7 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Mon, 18 Aug 2014 19:00:10 -0400 Subject: [PATCH 30/32] Bump BTS_BLOCKCHAIN_DATABASE_VERSION --- libraries/blockchain/include/bts/blockchain/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/blockchain/include/bts/blockchain/config.hpp b/libraries/blockchain/include/bts/blockchain/config.hpp index f7df7ba7b..a8ba15300 100644 --- a/libraries/blockchain/include/bts/blockchain/config.hpp +++ b/libraries/blockchain/include/bts/blockchain/config.hpp @@ -10,7 +10,7 @@ * @brief Defines global constants that determine blockchain behavior */ #define BTS_BLOCKCHAIN_VERSION 109 -#define BTS_BLOCKCHAIN_DATABASE_VERSION 124 +#define BTS_BLOCKCHAIN_DATABASE_VERSION 125 /** * The address prepended to string representation of From 03dbac9fd674aae29d50cdab2685318c47c89667 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Mon, 18 Aug 2014 19:07:12 -0400 Subject: [PATCH 31/32] Update submodule --- programs/web_wallet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/web_wallet b/programs/web_wallet index 420387d25..ac6cea2e1 160000 --- a/programs/web_wallet +++ b/programs/web_wallet @@ -1 +1 @@ -Subproject commit 420387d257d5a27cfb5ae8239d4a661c805b4e3d +Subproject commit ac6cea2e1589523232af16d84172413eb1533b0a From c403f9be88b44c81bd6cbe5a92564d584a669600 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Mon, 18 Aug 2014 19:18:16 -0400 Subject: [PATCH 32/32] Fix build --- libraries/blockchain/transaction_evaluation_state.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libraries/blockchain/transaction_evaluation_state.cpp b/libraries/blockchain/transaction_evaluation_state.cpp index 3a7f17028..10995246c 100644 --- a/libraries/blockchain/transaction_evaluation_state.cpp +++ b/libraries/blockchain/transaction_evaluation_state.cpp @@ -89,13 +89,6 @@ namespace bts { namespace blockchain { */ void transaction_evaluation_state::post_evaluate() { try { - // NOTE: this line was removed in favor of trusting delegates to set the required fees rather - // than charging per byte. This allows the network to scale without hard fork. - // - // By removing this check I am reducing restrictions so the current blockchain should still validate - if( _current_state->get_head_block_num() < BTS_BLOCKCHAIN_FORK_MARKET_BLOCK_NUM ) - required_fees += asset( _current_state->calculate_data_fee( fc::raw::pack_size( trx ) ), 0 ); - // Should this be here? We may not have fees in XTS now... balance[0]; // make sure we have something for this. for( const auto& fee : balance )