From cf0af500edb32159d7d8e6480f6e4ccff486a54c Mon Sep 17 00:00:00 2001 From: grzegorzs Date: Tue, 23 Sep 2014 08:42:21 +0200 Subject: [PATCH 01/20] [GS] Update regression tests --- .../blockchain_get_asset.log | 8 +++---- .../blockchain_get_info.log | 3 +-- .../blockchain_markets/blockchain_markets.log | 6 ++--- .../wallet_market_submit_bid.log | 23 ++++++++----------- 4 files changed, 18 insertions(+), 22 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 8d084cf5c..6c9a5b071 100644 --- a/tests/regression_tests/blockchain_get_asset/blockchain_get_asset.log +++ b/tests/regression_tests/blockchain_get_asset/blockchain_get_asset.log @@ -19,8 +19,8 @@ aliases: get_asset "public_data": "", "issuer_account_id": 0, "precision": 100000, - "registration_date": "20140620T144027", - "last_update": "20140620T144027", + "registration_date": "20200101T000000", + "last_update": "20200101T000000", "current_share_supply": 199999999999901, "maximum_share_supply": 1000000000000000, "collected_fees": 0 @@ -34,8 +34,8 @@ aliases: get_asset "public_data": "", "issuer_account_id": 0, "precision": 100000, - "registration_date": "20140620T144027", - "last_update": "20140620T144027", + "registration_date": "20200101T000000", + "last_update": "20200101T000000", "current_share_supply": 199999999999901, "maximum_share_supply": 1000000000000000, "collected_fees": 0 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 7fe53cd50..2cb67ea52 100644 --- a/tests/regression_tests/blockchain_get_info/blockchain_get_info.log +++ b/tests/regression_tests/blockchain_get_info/blockchain_get_info.log @@ -12,7 +12,7 @@ Returns: aliases: getconfig, get_config, config, blockchain_get_config (wallet closed) >>> blockchain_get_info { - "blockchain_id": "3622ad3cbd09f839b921bace52bf4432b91f636d625f53401bbf6b6cb01f754c", + "blockchain_id": "7cb60eb8be0e3dcd434120b451fa7a8226fe78a41834b637f5a95740ba0e35c7", "symbol": "XTS", "name": "BitShares XTS", "version": 109, @@ -33,7 +33,6 @@ aliases: getconfig, get_config, config, blockchain_get_config "symbol_size_min": 3, "asset_reg_fee": "0.00000 XTS", "asset_shares_max": 1000000000000000, - "min_market_depth": "0.00000 XTS", "max_pending_queue_size": 10, "max_trx_per_second": 1, "min_block_fee": "0.00000 XTS" diff --git a/tests/regression_tests/blockchain_markets/blockchain_markets.log b/tests/regression_tests/blockchain_markets/blockchain_markets.log index 2637f61b0..c8c2f6a40 100644 --- a/tests/regression_tests/blockchain_markets/blockchain_markets.log +++ b/tests/regression_tests/blockchain_markets/blockchain_markets.log @@ -55,9 +55,9 @@ TIMESTAMP BLOCK FROM TO AMOUNT [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.50000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 100.00000 XTS 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 =========================================================================================================================================================== @@ -108,9 +108,9 @@ TIMESTAMP BLOCK FROM TO AMOUNT [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.50000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 100.00000 XTS 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-5854ea64 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 @@ -165,9 +165,9 @@ TIMESTAMP BLOCK FROM TO AMOUNT [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.50000 XTS [redacted] -[redacted] 2 delegate0 testaccount1 100.00000 XTS 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-5854ea64 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] [redacted] 5 testaccount2 ASK-ea791a42 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> blockchain_market_list_asks XMO XTS 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 5d82acfc0..698f5851c 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,18 +6,19 @@ default (unlocked) >>> wallet_transfer 100 XTS delegate0 testaccount1 TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== [redacted] PENDING delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] +default (unlocked) >>> debug_wait_for_block_by_number 1 relative +OK default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASSET" null 5000000 100 TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== [redacted] PENDING delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] default (unlocked) >>> debug_wait_for_block_by_number 1 relative OK -default (unlocked) >>> debug_wait 2 -OK default (unlocked) >>> blockchain_list_blocks HEIGHT TIMESTAMP SIGNING DELEGATE # TXS SIZE LATENCY PROCESSING TIME =================================================================================================== -1 [redacted] [redacted] 2 627 [redacted][redacted] +2 [redacted] [redacted] 1 383 [redacted][redacted] +1 [redacted] [redacted] 1 410 [redacted][redacted] default (unlocked) >>> wallet_account_balance testaccount1 ACCOUNT BALANCE ============================================================ @@ -31,9 +32,7 @@ default (unlocked) >>> wallet_asset_issue 10000 XMO testaccount1 "Sending some a TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== [redacted] PENDING delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] -default (unlocked) >>> debug_wait_for_block_by_number 1 relative -OK -default (unlocked) >>> debug_wait 2 +default (unlocked) >>> debug_wait_for_block_by_number 2 relative OK default (unlocked) >>> blockchain_list_assets XMO ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY @@ -63,8 +62,8 @@ TIMESTAMP BLOCK FROM TO AMOUNT [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 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] 2 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +[redacted] 3 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 =========================================================================================================================================================== @@ -98,8 +97,6 @@ TIMESTAMP BLOCK FROM TO AMOUNT [redacted] PENDING testaccount1 BID-5854ea64 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> debug_wait_for_block_by_number 1 relative OK -default (unlocked) >>> debug_wait 2 -OK default (unlocked) >>> balance testaccount1 ACCOUNT BALANCE ============================================================ @@ -114,9 +111,9 @@ TIMESTAMP BLOCK FROM TO AMOUNT [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 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-5854ea64 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] +[redacted] 2 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +[redacted] 3 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] +[redacted] 5 testaccount1 BID-5854ea64 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 ================================================================================================================================ From 229f1ad680eadc0ca8ef70e2c79bf44730771fe4 Mon Sep 17 00:00:00 2001 From: grzegorzs Date: Wed, 24 Sep 2014 11:58:50 +0200 Subject: [PATCH 02/20] [GS] Fix regression tests --- .../blockchain_markets/blockchain_markets.log | 82 ++++++++----------- .../blockchain_markets/test.config | 2 +- .../wallet_asset/wallet_asset.log | 3 +- .../wallet_market_submit_ask.log | 31 ++----- 4 files changed, 44 insertions(+), 74 deletions(-) diff --git a/tests/regression_tests/blockchain_markets/blockchain_markets.log b/tests/regression_tests/blockchain_markets/blockchain_markets.log index c8c2f6a40..ae4c6c599 100644 --- a/tests/regression_tests/blockchain_markets/blockchain_markets.log +++ b/tests/regression_tests/blockchain_markets/blockchain_markets.log @@ -1,16 +1,3 @@ -default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASSET" null 5000000 100 -TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID -====================================================================================================================================================================== -[redacted] PENDING delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] -default (unlocked) >>> debug_wait_for_block_by_number 1 relative -OK -default (unlocked) >>> debug_wait 2 -OK -default (unlocked) >>> blockchain_list_assets -ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY -=========================================================================================================================================================== -1 XMO DIGITAL_DEVICE1 AN ASSET delegate0 0.00 % 0.00 XMO -0 XTS BitShares XTS BitShares X Test Network GENESIS N/A 1,999,999,999.99901 XTS default (unlocked) >>> wallet_account_create testaccount1 Account created successfully. You may give the following link to others to allow them to add you as a contact and send you funds: @@ -19,6 +6,10 @@ default (unlocked) >>> wallet_account_create testaccount2 Account created successfully. You may give the following link to others to allow them to add you as a contact and send you funds: xts:testaccount2:XTS7CCZsSumbT4xCvu5t21C2ic9msdiYf9oRuNyLBoJz18LTkArfs +default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASSET" null 5000000 100 +TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID +====================================================================================================================================================================== +[redacted] PENDING delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] default (unlocked) >>> wallet_transfer 100 XTS delegate0 testaccount1 TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== @@ -27,25 +18,31 @@ default (unlocked) >>> wallet_transfer 10000 XTS delegate0 testaccount2 TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== [redacted] PENDING delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] -default (unlocked) >>> wallet_asset_issue 10000 XMO testaccount1 "Sending some assets" -TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID -====================================================================================================================================================================== -[redacted] PENDING delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] -default (unlocked) >>> debug_wait_for_block_by_number 1 relative -OK -default (unlocked) >>> debug_wait 2 +default (unlocked) >>> debug_wait_for_block_by_number 2 relative OK +default (unlocked) >>> blockchain_list_assets +ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY +=========================================================================================================================================================== +1 XMO DIGITAL_DEVICE1 AN ASSET delegate0 0.00 % 0.00 XMO +0 XTS BitShares XTS BitShares X Test Network GENESIS N/A 1,999,999,999.99901 XTS +default (unlocked) >>> blockchain_list_pending_transactions +No pending transactions. default (unlocked) >>> balance ACCOUNT BALANCE ============================================================ -delegate0 19,791,878.19801 XTS +delegate0 19,791,878.69801 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 100.00000 XTS - 10,000.00 XMO testaccount2 10,000.00000 XTS +default (unlocked) >>> wallet_asset_issue 10000 XMO testaccount1 "Sending some assets" +TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID +====================================================================================================================================================================== +[redacted] PENDING delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] +default (unlocked) >>> debug_wait_for_block_by_number 2 relative +OK default (unlocked) >>> history TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== @@ -54,10 +51,10 @@ TIMESTAMP 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.50000 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] 1 delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] +[redacted] 3 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 =========================================================================================================================================================== @@ -84,9 +81,7 @@ default (unlocked) >>> wallet_market_submit_bid testaccount1 500 XTS 3 XMO TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== [redacted] PENDING testaccount1 BID-5854ea64 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] -default (unlocked) >>> debug_advance_time 1 blocks -OK -default (unlocked) >>> debug_wait 2 +default (unlocked) >>> debug_wait_for_block_by_number 2 relative OK default (unlocked) >>> balance ACCOUNT BALANCE @@ -107,11 +102,11 @@ TIMESTAMP 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.50000 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-5854ea64 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] +[redacted] 1 delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] +[redacted] 3 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] +[redacted] 5 testaccount1 BID-5854ea64 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 ================================================================================================================================ @@ -141,9 +136,7 @@ default (unlocked) >>> wallet_market_submit_ask testaccount2 100 XTS 4 XMO TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== [redacted] PENDING testaccount2 ASK-ea791a42 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] -default (unlocked) >>> debug_advance_time 1 blocks -OK -default (unlocked) >>> debug_wait 2 +default (unlocked) >>> debug_wait_for_block_by_number 2 relative OK default (unlocked) >>> balance ACCOUNT BALANCE @@ -164,12 +157,12 @@ TIMESTAMP 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.50000 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-5854ea64 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] -[redacted] 5 testaccount2 ASK-ea791a42 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] +[redacted] 1 delegate0 testaccount1 100.00000 XTS 0.50000 XTS [redacted] +[redacted] 3 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] +[redacted] 5 testaccount1 BID-5854ea64 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] +[redacted] 7 testaccount2 ASK-ea791a42 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 ================================================================================================================================ @@ -198,15 +191,6 @@ default (unlocked) >>> blockchain_market_order_book XMO XTS TOTAL QUANTITY PRICE | PRICE QUANTITY TOTAL COLLATERAL ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1,500.00 XMO 500.00000 XTS 3.000000000000 XMO | 4.000000000000 XMO 100.00000 XTS 400.00 XMO -default (unlocked) >>> debug_advance_time 1 blocks -OK -default (unlocked) >>> debug_wait 2 -OK -default (unlocked) >>> blockchain_market_order_book XMO XTS - BIDS (* Short Wall) | ASKS -TOTAL QUANTITY PRICE | PRICE QUANTITY TOTAL COLLATERAL -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -1,500.00 XMO 500.00000 XTS 3.000000000000 XMO | 4.000000000000 XMO 100.00000 XTS 400.00 XMO default (unlocked) >>> help blockchain_market_status Usage: blockchain_market_status Returns the status of a particular market, including any trading errors. diff --git a/tests/regression_tests/blockchain_markets/test.config b/tests/regression_tests/blockchain_markets/test.config index 100dc3149..2ab41a8df 100644 --- a/tests/regression_tests/blockchain_markets/test.config +++ b/tests/regression_tests/blockchain_markets/test.config @@ -1,2 +1,2 @@ -blockmaker --input-log=../_common_logs/init.log --input-log=../_common_logs/create_wallet.log --input-log=../_common_logs/import_delegate_keys.log --input-log=../_common_logs/enable_delegates.log --input-log=../_common_logs/advance_5_blocks.log +blockmaker --input-log=../_common_logs/init.log --input-log=../_common_logs/create_wallet.log --input-log=../_common_logs/import_delegate_keys.log --input-log=../_common_logs/enable_delegates.log --input-log=../_common_logs/advance_10_blocks.log transactor --input-log=../_common_logs/init.log --input-log=../_common_logs/create_wallet.log --input-log=../_common_logs/import_5_delegate_keys.log --input-log=blockchain_markets.log diff --git a/tests/regression_tests/wallet_asset/wallet_asset.log b/tests/regression_tests/wallet_asset/wallet_asset.log index 0522e87ca..cc9c010ad 100644 --- a/tests/regression_tests/wallet_asset/wallet_asset.log +++ b/tests/regression_tests/wallet_asset/wallet_asset.log @@ -23,7 +23,8 @@ OK default (unlocked) >>> blockchain_list_blocks HEIGHT TIMESTAMP SIGNING DELEGATE # TXS SIZE LATENCY PROCESSING TIME =================================================================================================== -2 [redacted] [redacted] 1 392 [redacted][redacted] +3 [redacted] [redacted] 1 392 [redacted][redacted] +2 [redacted] [redacted] 0 166 [redacted][redacted] 1 [redacted] [redacted] 1 410 [redacted][redacted] default (unlocked) >>> blockchain_list_assets ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY 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 b46bdf1bf..b2ee3be22 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,37 +6,26 @@ default (unlocked) >>> wallet_transfer 10000 XTS delegate0 testaccount2 TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== [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 -OK default (unlocked) >>> wallet_asset_create XMO DIGITAL_DEVICE1 delegate0 "AN ASSET" null 5000000 100 true TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== [redacted] PENDING delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] +default (unlocked) >>> debug_wait_for_block_by_number 2 relative +OK default (unlocked) >>> wallet_account_balance testaccount2 ACCOUNT BALANCE ============================================================ testaccount2 10,000.00000 XTS -default (unlocked) >>> debug_wait_for_block_by_number 1 relative -OK -default (unlocked) >>> debug_wait 2 -OK default (unlocked) >>> blockchain_list_blocks HEIGHT TIMESTAMP SIGNING DELEGATE # TXS SIZE LATENCY PROCESSING TIME =================================================================================================== -3 [redacted] [redacted] 0 166 [redacted][redacted] -2 [redacted] [redacted] 1 318 [redacted][redacted] -1 [redacted] [redacted] 1 410 [redacted][redacted] +2 [redacted] [redacted] 0 166 [redacted][redacted] +1 [redacted] [redacted] 2 562 [redacted][redacted] default (unlocked) >>> blockchain_list_assets ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY =========================================================================================================================================================== 1 XMO DIGITAL_DEVICE1 AN ASSET MARKET N/A 0.00 XMO 0 XTS BitShares XTS BitShares X Test Network GENESIS N/A 1,999,999,999.99901 XTS -default (unlocked) >>> debug_advance_time 1 blocks -OK -default (unlocked) >>> debug_wait 2 -OK default (unlocked) >>> blockchain_list_assets XMO ID SYMBOL NAME DESCRIPTION ISSUER ISSUED SUPPLY =========================================================================================================================================================== @@ -87,8 +76,6 @@ ID SYMBOL NAME DESCRIPTION 0 XTS BitShares XTS BitShares X Test Network GENESIS N/A 1,999,999,999.99901 XTS default (unlocked) >>> debug_wait_for_block_by_number 1 relative OK -default (unlocked) >>> debug_wait 2 -OK default (unlocked) >>> wallet_account_transaction_history TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== @@ -97,17 +84,15 @@ TIMESTAMP 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.50000 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-f3482357 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] +[redacted] 3 testaccount2 ASK-f3482357 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> balance testaccount2 ACCOUNT BALANCE ============================================================ testaccount2 9,899.50000 XTS default (unlocked) >>> debug_advance_time 1 blocks OK -default (unlocked) >>> debug_wait 2 -OK default (unlocked) >>> wallet_account_transaction_history TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID ====================================================================================================================================================================== @@ -116,9 +101,9 @@ TIMESTAMP 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.50000 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-f3482357 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] +[redacted] 3 testaccount2 ASK-f3482357 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 ================================================================================================================================ From 591984958a900f8839796f08a7359a52d6ec3602 Mon Sep 17 00:00:00 2001 From: grzegorzs Date: Wed, 24 Sep 2014 12:42:01 +0200 Subject: [PATCH 03/20] [GS] Update regression tests --- tests/regression_tests/issue_633/issue_633.log | 12 ++++-------- .../simple_wallet_commands.log | 4 ++-- .../wallet_get_info/wallet_get_info.log | 2 +- .../regression_tests/wallet_relock/wallet_relock.log | 6 +++--- .../wallet_set_transaction_fee.log | 8 ++++---- .../wallet_set_transaction_scanning.log | 6 +++--- 6 files changed, 17 insertions(+), 21 deletions(-) diff --git a/tests/regression_tests/issue_633/issue_633.log b/tests/regression_tests/issue_633/issue_633.log index ead7f7362..9efa85cdf 100644 --- a/tests/regression_tests/issue_633/issue_633.log +++ b/tests/regression_tests/issue_633/issue_633.log @@ -59,15 +59,11 @@ ACCOUNT BALANCE ============================================================ test 99.00000 XTS default (unlocked) >>> wallet_account_update_active_key test test -Command failed with exception: insufficient funds (20010) - - - - - - +TIMESTAMP BLOCK FROM TO AMOUNT MEMO FEE ID +====================================================================================================================================================================== +[redacted] PENDING test test 0.00000 XTS update test active key 0.50000 XTS [redacted] default (unlocked) >>> balance test ACCOUNT BALANCE ============================================================ -test 99.00000 XTS +test 98.50000 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 9fd79ee51..d172632e4 100644 --- a/tests/regression_tests/simple_wallet_commands/simple_wallet_commands.log +++ b/tests/regression_tests/simple_wallet_commands/simple_wallet_commands.log @@ -6,7 +6,7 @@ wallet (unlocked) >>> wallet_get_info "open": true, "name": "wallet", "automatic_backups": true, - "transaction_scanning": false, + "transaction_scanning_enabled": false, "last_scanned_block_num": null, "last_scanned_block_timestamp": null, "transaction_fee": "0.50000 XTS", @@ -99,7 +99,7 @@ wallet (unlocked) >>> wallet_get_info "open": true, "name": "wallet", "automatic_backups": false, - "transaction_scanning": true, + "transaction_scanning_enabled": true, "last_scanned_block_num": null, "last_scanned_block_timestamp": null, "transaction_fee": "99,999.00000 XTS", 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 4a628ee9c..fecd2c61d 100644 --- a/tests/regression_tests/wallet_get_info/wallet_get_info.log +++ b/tests/regression_tests/wallet_get_info/wallet_get_info.log @@ -14,7 +14,7 @@ default (unlocked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": false, + "transaction_scanning_enabled": false, "last_scanned_block_num": null, "last_scanned_block_timestamp": null, "transaction_fee": "0.50000 XTS", diff --git a/tests/regression_tests/wallet_relock/wallet_relock.log b/tests/regression_tests/wallet_relock/wallet_relock.log index 213e01741..6d85fd35c 100644 --- a/tests/regression_tests/wallet_relock/wallet_relock.log +++ b/tests/regression_tests/wallet_relock/wallet_relock.log @@ -6,7 +6,7 @@ default (locked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": false, + "transaction_scanning_enabled": false, "last_scanned_block_num": null, "last_scanned_block_timestamp": null, "transaction_fee": "0.50000 XTS", @@ -57,7 +57,7 @@ default (locked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": false, + "transaction_scanning_enabled": false, "last_scanned_block_num": null, "last_scanned_block_timestamp": null, "transaction_fee": "0.50000 XTS", @@ -76,7 +76,7 @@ default (locked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": false, + "transaction_scanning_enabled": false, "last_scanned_block_num": null, "last_scanned_block_timestamp": null, "transaction_fee": "0.50000 XTS", diff --git a/tests/regression_tests/wallet_set_transaction_fee/wallet_set_transaction_fee.log b/tests/regression_tests/wallet_set_transaction_fee/wallet_set_transaction_fee.log index 34eb18c81..6914ab346 100644 --- a/tests/regression_tests/wallet_set_transaction_fee/wallet_set_transaction_fee.log +++ b/tests/regression_tests/wallet_set_transaction_fee/wallet_set_transaction_fee.log @@ -8,7 +8,7 @@ default (unlocked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": true, + "transaction_scanning_enabled": true, "last_scanned_block_num": 1, "last_scanned_block_timestamp": "[redacted]", "transaction_fee": "0.50000 XTS", @@ -43,7 +43,7 @@ default (unlocked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": true, + "transaction_scanning_enabled": true, "last_scanned_block_num": 1, "last_scanned_block_timestamp": "[redacted]", "transaction_fee": "0.00001 XTS", @@ -72,7 +72,7 @@ default (unlocked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": true, + "transaction_scanning_enabled": true, "last_scanned_block_num": 1, "last_scanned_block_timestamp": "[redacted]", "transaction_fee": "123.45600 XTS", @@ -95,7 +95,7 @@ default (unlocked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": true, + "transaction_scanning_enabled": true, "last_scanned_block_num": 1, "last_scanned_block_timestamp": "[redacted]", "transaction_fee": "0.10000 XTS", 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 6ee54ed84..1f7c7f1e0 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 @@ -4,7 +4,7 @@ default (unlocked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": true, + "transaction_scanning_enabled": true, "last_scanned_block_num": 1, "last_scanned_block_timestamp": "[redacted]", "transaction_fee": "0.50000 XTS", @@ -23,7 +23,7 @@ default (unlocked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": false, + "transaction_scanning_enabled": false, "last_scanned_block_num": 1, "last_scanned_block_timestamp": "[redacted]", "transaction_fee": "0.50000 XTS", @@ -42,7 +42,7 @@ default (unlocked) >>> wallet_get_info "open": true, "name": "default", "automatic_backups": false, - "transaction_scanning": true, + "transaction_scanning_enabled": true, "last_scanned_block_num": 1, "last_scanned_block_timestamp": "[redacted]", "transaction_fee": "0.50000 XTS", From 0977780fe157894c61423820dc53a4293309cb99 Mon Sep 17 00:00:00 2001 From: grzegorzs Date: Wed, 24 Sep 2014 14:13:08 +0200 Subject: [PATCH 04/20] [GS] Fix regression tests --- .../blockchain_get_asset/blockchain_get_asset.log | 8 ++++---- .../blockchain_get_info/blockchain_get_info.log | 2 +- .../blockchain_markets/blockchain_markets.log | 6 +++--- .../wallet_market_submit_ask/wallet_market_submit_ask.log | 4 ++-- 4 files changed, 10 insertions(+), 10 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 6c9a5b071..8d084cf5c 100644 --- a/tests/regression_tests/blockchain_get_asset/blockchain_get_asset.log +++ b/tests/regression_tests/blockchain_get_asset/blockchain_get_asset.log @@ -19,8 +19,8 @@ aliases: get_asset "public_data": "", "issuer_account_id": 0, "precision": 100000, - "registration_date": "20200101T000000", - "last_update": "20200101T000000", + "registration_date": "20140620T144027", + "last_update": "20140620T144027", "current_share_supply": 199999999999901, "maximum_share_supply": 1000000000000000, "collected_fees": 0 @@ -34,8 +34,8 @@ aliases: get_asset "public_data": "", "issuer_account_id": 0, "precision": 100000, - "registration_date": "20200101T000000", - "last_update": "20200101T000000", + "registration_date": "20140620T144027", + "last_update": "20140620T144027", "current_share_supply": 199999999999901, "maximum_share_supply": 1000000000000000, "collected_fees": 0 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 2cb67ea52..7dc500e7d 100644 --- a/tests/regression_tests/blockchain_get_info/blockchain_get_info.log +++ b/tests/regression_tests/blockchain_get_info/blockchain_get_info.log @@ -12,7 +12,7 @@ Returns: aliases: getconfig, get_config, config, blockchain_get_config (wallet closed) >>> blockchain_get_info { - "blockchain_id": "7cb60eb8be0e3dcd434120b451fa7a8226fe78a41834b637f5a95740ba0e35c7", + "blockchain_id": "3622ad3cbd09f839b921bace52bf4432b91f636d625f53401bbf6b6cb01f754c", "symbol": "XTS", "name": "BitShares XTS", "version": 109, diff --git a/tests/regression_tests/blockchain_markets/blockchain_markets.log b/tests/regression_tests/blockchain_markets/blockchain_markets.log index ae4c6c599..80d9454f4 100644 --- a/tests/regression_tests/blockchain_markets/blockchain_markets.log +++ b/tests/regression_tests/blockchain_markets/blockchain_markets.log @@ -52,8 +52,8 @@ TIMESTAMP BLOCK FROM TO AMOUNT [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.50000 XTS [redacted] -[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 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] 3 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 @@ -103,8 +103,8 @@ TIMESTAMP BLOCK FROM TO AMOUNT [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.50000 XTS [redacted] -[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 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] 3 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] [redacted] 5 testaccount1 BID-5854ea64 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> blockchain_market_list_bids XMO XTS @@ -158,8 +158,8 @@ TIMESTAMP BLOCK FROM TO AMOUNT [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.50000 XTS [redacted] -[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 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] 3 delegate0 testaccount1 10,000.00 XMO issue 10,000.00 XMO 0.50000 XTS [redacted] [redacted] 5 testaccount1 BID-5854ea64 1,500.00 XMO buy XTS @ 3. XMO / XTS 0.50000 XTS [redacted] [redacted] 7 testaccount2 ASK-ea791a42 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] 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 b2ee3be22..090535d66 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 @@ -84,8 +84,8 @@ TIMESTAMP 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.50000 XTS [redacted] [redacted] 1 delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] +[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] [redacted] 3 testaccount2 ASK-f3482357 100.00000 XTS sell XTS @ 4. XMO / XTS 0.50000 XTS [redacted] default (unlocked) >>> balance testaccount2 ACCOUNT BALANCE @@ -101,8 +101,8 @@ TIMESTAMP 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.50000 XTS [redacted] [redacted] 1 delegate0 testaccount2 10,000.00000 XTS 0.50000 XTS [redacted] +[redacted] 1 delegate0 delegate0 0.00000 XTS create XMO (DIGITAL_DEVICE1) 0.50000 XTS [redacted] [redacted] 3 testaccount2 ASK-f3482357 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 From 6da8c1501ee3f92134c3486802ec7280a703feda Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 24 Sep 2014 09:55:43 -0400 Subject: [PATCH 05/20] Squelch dirty submodules warnings --- .gitmodules | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 53484e2e2..dd33062f5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,16 +1,20 @@ [submodule "vendor"] path = vendor url = https://github.com/BitShares/vendor.git + ignore = dirty [submodule "libraries/fc"] path = libraries/fc url = https://github.com/InvictusInnovations/fc.git + ignore = dirty [submodule "programs/web_wallet"] path = programs/web_wallet url = https://github.com/BitShares/web_wallet.git + ignore = dirty [submodule "programs/qt_wallet"] path = programs/qt_wallet url = https://github.com/BitShares/qt_wallet.git + ignore = dirty [submodule "libraries/leveldb"] path = libraries/leveldb url = https://github.com/bitcoin/leveldb.git - ignore = dirty + ignore = dirty From 891d59bc344b162614178be351e8eb8c0bec610b Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 24 Sep 2014 10:27:39 -0400 Subject: [PATCH 06/20] Check shorting with price limit below center price --- tests/nathan_tests.cpp | 95 +++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 42 deletions(-) diff --git a/tests/nathan_tests.cpp b/tests/nathan_tests.cpp index 1afcfde58..205590d33 100644 --- a/tests/nathan_tests.cpp +++ b/tests/nathan_tests.cpp @@ -99,49 +99,60 @@ class nathan_fixture : public chain_fixture { } }; -BOOST_FIXTURE_TEST_CASE( mail_server, chain_fixture ) +//BOOST_FIXTURE_TEST_CASE( mail_server, chain_fixture ) +//{ try { +// config aconfig = clienta->configure(clienta_dir.path()); +// aconfig.mail_server_enabled = true; +// fc::json::save_to_file(aconfig, clienta_dir.path() / "config.json"); +// clienta->open(clienta_dir.path(), clienta_dir.path() / "genesis.json"); + +// bts::mail::signed_email_message sem; +// string subject = "A subject line"; +// string body = "A body\n\nSincerely, Nathan"; +// attachment attach; +// attach.data = fc::raw::pack(map({{string("hello"),string("world")}})); +// sem.subject = subject; +// sem.body = body; +// sem.attachments.push_back(attach); + +// fc::ecc::private_key my_key = fc::ecc::private_key::generate(); +// fc::ecc::private_key one_time_key = fc::ecc::private_key::generate(); +// fc::ecc::private_key his_key = fc::ecc::private_key::generate(); + +// sem.sign(my_key); +// BOOST_CHECK_EQUAL(sem.from().to_base58(), my_key.get_public_key().to_base58()); + +// fc::time_point before = fc::time_point::now(); +// message m(message(sem).encrypt(one_time_key, his_key.get_public_key())); +// clienta->mail_store_message(his_key.get_public_key(), m); +// fc::time_point after = fc::time_point::now(); +// BOOST_CHECK(after > before); + +// BOOST_CHECK(clienta->mail_fetch_inventory(his_key.get_public_key(), after).size() == 0); +// auto inventory = clienta->mail_fetch_inventory(his_key.get_public_key(), before); +// BOOST_CHECK(inventory.size() == 1); + +// message received_message = clienta->mail_fetch_message(inventory[0].second); +// BOOST_CHECK(received_message.type == encrypted); +// signed_email_message rm = received_message.as().decrypt(his_key).as(); + +// BOOST_CHECK_EQUAL(rm.from().to_base58(), my_key.get_public_key().to_base58()); +// BOOST_CHECK_EQUAL(rm.subject, subject); +// BOOST_CHECK_EQUAL(rm.body, body); +// BOOST_CHECK_EQUAL(rm.attachments.size(), 1); +// BOOST_CHECK_EQUAL(rm.attachments[0].name, attach.name); +// BOOST_CHECK(rm.attachments[0].data == attach.data); +//} FC_LOG_AND_RETHROW() } + +BOOST_FIXTURE_TEST_CASE( short_below_feed, nathan_fixture ) { try { - config aconfig = clienta->configure(clienta_dir.path()); - aconfig.mail_server_enabled = true; - fc::json::save_to_file(aconfig, clienta_dir.path() / "config.json"); - clienta->open(clienta_dir.path(), clienta_dir.path() / "genesis.json"); - - bts::mail::signed_email_message sem; - string subject = "A subject line"; - string body = "A body\n\nSincerely, Nathan"; - attachment attach; - attach.data = fc::raw::pack(map({{string("hello"),string("world")}})); - sem.subject = subject; - sem.body = body; - sem.attachments.push_back(attach); - - fc::ecc::private_key my_key = fc::ecc::private_key::generate(); - fc::ecc::private_key one_time_key = fc::ecc::private_key::generate(); - fc::ecc::private_key his_key = fc::ecc::private_key::generate(); - - sem.sign(my_key); - BOOST_CHECK_EQUAL(sem.from().to_base58(), my_key.get_public_key().to_base58()); - - fc::time_point before = fc::time_point::now(); - message m(message(sem).encrypt(one_time_key, his_key.get_public_key())); - clienta->mail_store_message(his_key.get_public_key(), m); - fc::time_point after = fc::time_point::now(); - BOOST_CHECK(after > before); - - BOOST_CHECK(clienta->mail_fetch_inventory(his_key.get_public_key(), after).size() == 0); - auto inventory = clienta->mail_fetch_inventory(his_key.get_public_key(), before); - BOOST_CHECK(inventory.size() == 1); - - message received_message = clienta->mail_fetch_message(inventory[0].second); - BOOST_CHECK(received_message.type == encrypted); - signed_email_message rm = received_message.as().decrypt(his_key).as(); - - BOOST_CHECK_EQUAL(rm.from().to_base58(), my_key.get_public_key().to_base58()); - BOOST_CHECK_EQUAL(rm.subject, subject); - BOOST_CHECK_EQUAL(rm.body, body); - BOOST_CHECK_EQUAL(rm.attachments.size(), 1); - BOOST_CHECK_EQUAL(rm.attachments[0].name, attach.name); - BOOST_CHECK(rm.attachments[0].data == attach.data); + exec(clienta, "short delegate21 100 USD 5 .195"); + exec(clientb, "ask delegate20 10 XTS .19 USD"); + + produce_block(clienta); + produce_block(clientb); + + prompt(); } FC_LOG_AND_RETHROW() } /* From 375c7343f5a4ca6e1eed2d4636e25c1bcdecd43a Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Wed, 24 Sep 2014 10:46:01 -0400 Subject: [PATCH 07/20] Fix add_collateral_operation evaluation --- libraries/blockchain/market_operations.cpp | 21 +++++++++++---------- programs/qt_wallet | 2 +- programs/web_wallet | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/libraries/blockchain/market_operations.cpp b/libraries/blockchain/market_operations.cpp index b480b397b..442393d22 100644 --- a/libraries/blockchain/market_operations.cpp +++ b/libraries/blockchain/market_operations.cpp @@ -109,7 +109,7 @@ namespace bts { namespace blockchain { auto market_stat = eval_state._current_state->get_market_status( ask_index.order_price.quote_asset_id, ask_index.order_price.base_asset_id ); if( !market_stat ) - market_stat = market_status(ask_index.order_price.quote_asset_id, ask_index.order_price.base_asset_id, 0,0); + market_stat = market_status( ask_index.order_price.quote_asset_id, ask_index.order_price.base_asset_id, 0, 0 ); market_stat->ask_depth += delta_amount.amount; eval_state._current_state->store_market_status( *market_stat ); @@ -134,7 +134,7 @@ namespace bts { namespace blockchain { #endif /** if the USD amount of the order is effectively then don't bother */ - FC_ASSERT( llabs(delta_quote.amount) > 0, "", ("delta_quote",delta_quote)("order",*this)); + FC_ASSERT( llabs( delta_quote.amount ) > 0, "", ("delta_quote",delta_quote)("order",*this)); eval_state.validate_asset( delta_amount ); auto asset_to_short = eval_state._current_state->get_asset_record( short_index.order_price.quote_asset_id ); @@ -175,7 +175,7 @@ namespace bts { namespace blockchain { auto market_stat = eval_state._current_state->get_market_status( short_index.order_price.quote_asset_id, short_index.order_price.base_asset_id ); if( !market_stat ) - market_stat = market_status(short_index.order_price.quote_asset_id, short_index.order_price.base_asset_id, 0,0); + market_stat = market_status( short_index.order_price.quote_asset_id, short_index.order_price.base_asset_id, 0, 0 ); market_stat->bid_depth += delta_amount.amount; @@ -224,19 +224,19 @@ namespace bts { namespace blockchain { if( current_cover->payoff_balance > 0 ) { - auto new_call_price = asset(current_cover->payoff_balance, delta_amount.asset_id) / - asset((current_cover->collateral_balance*2)/3, 0); + auto new_call_price = asset( current_cover->payoff_balance, delta_amount.asset_id) / + asset( (current_cover->collateral_balance*2)/3, cover_index.order_price.base_asset_id ); if( this->new_cover_price && (*this->new_cover_price > new_call_price) ) - eval_state._current_state->store_collateral_record( market_index_key( *this->new_cover_price, this->cover_index.owner), + eval_state._current_state->store_collateral_record( market_index_key( *this->new_cover_price, this->cover_index.owner ), *current_cover ); else - eval_state._current_state->store_collateral_record( market_index_key( new_call_price, this->cover_index.owner), + eval_state._current_state->store_collateral_record( market_index_key( new_call_price, this->cover_index.owner ), *current_cover ); } else // withdraw the collateral to the transaction to be deposited at owners discretion / cover fees { - eval_state.add_balance( asset( current_cover->collateral_balance, 0 ) ); + eval_state.add_balance( asset( current_cover->collateral_balance, cover_index.order_price.base_asset_id ) ); auto market_stat = eval_state._current_state->get_market_status( cover_index.order_price.quote_asset_id, cover_index.order_price.base_asset_id ); FC_ASSERT( market_stat, "this should be valid for there to even be a position to cover" ); @@ -271,8 +271,8 @@ namespace bts { namespace blockchain { // and insert a new one. eval_state._current_state->store_collateral_record( this->cover_index, collateral_record() ); - auto new_call_price = asset(current_cover->payoff_balance, delta_amount.asset_id) / - asset((current_cover->collateral_balance*2)/3, 0); + auto new_call_price = asset( current_cover->payoff_balance, cover_index.order_price.quote_asset_id ) / + asset( (current_cover->collateral_balance*2)/3, cover_index.order_price.base_asset_id ); eval_state._current_state->store_collateral_record( market_index_key( new_call_price, this->cover_index.owner), *current_cover ); @@ -287,6 +287,7 @@ namespace bts { namespace blockchain { void remove_collateral_operation::evaluate( transaction_evaluation_state& eval_state ) { // Should this even be allowed? + FC_ASSERT( !"Not implemented!" ); } } } // bts::blockchain diff --git a/programs/qt_wallet b/programs/qt_wallet index 964bf4770..ee68635a2 160000 --- a/programs/qt_wallet +++ b/programs/qt_wallet @@ -1 +1 @@ -Subproject commit 964bf47703035a991d20d0c81789fae2b1491c03 +Subproject commit ee68635a2cd0f5c53b25ad9aabc983629730de7b diff --git a/programs/web_wallet b/programs/web_wallet index 513642699..9f2179dab 160000 --- a/programs/web_wallet +++ b/programs/web_wallet @@ -1 +1 @@ -Subproject commit 5136426998fc6a7e56a9cbf80283bf2f4c3b4c5d +Subproject commit 9f2179dabaf247dadd503956246b77cbdd104e6b From f3c51a53dc51bacf91b2f0257a1cc15dca16c138 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 24 Sep 2014 11:29:04 -0400 Subject: [PATCH 08/20] Modify blockchain_market_order_book to show shorts below center price --- libraries/cli/print_result.cpp | 31 +++++++++++++++++++++++-------- tests/nathan_tests.cpp | 13 ++++++++++++- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/libraries/cli/print_result.cpp b/libraries/cli/print_result.cpp index 1c314c79d..34feeaf25 100644 --- a/libraries/cli/print_result.cpp +++ b/libraries/cli/print_result.cpp @@ -699,7 +699,7 @@ namespace bts { namespace cli { return; } - out << std::string(18, ' ') << "BIDS (* Short Wall)" + out << std::string(18, ' ') << "BIDS (* Short)" << std::string(39, ' ') << " | " << std::string(34, ' ') << "ASKS" << std::string(34, ' ') << "\n" @@ -736,6 +736,11 @@ namespace bts { namespace cli { shorts = client->blockchain_market_list_shorts(arguments[0].as_string()); else shorts = client->blockchain_market_list_shorts(arguments[0].as_string(), arguments[2].as_int64()); + + std::copy_if(shorts.begin(), shorts.end(), std::back_inserter(bids_asks.first), [&max_short_price](const market_order& order) -> bool { + return order.state.short_price_limit && *order.state.short_price_limit < max_short_price; + }); + shorts.erase(std::remove_if(shorts.begin(), shorts.end(), [&max_short_price](const market_order& short_order) -> bool { //Filter out if insufficient collateral (i.e. XTS/USD < 1/max_short_price) or if price limit (i.e. USD/XTS) is less than short execution price return short_order.get_price() > max_short_price || (short_order.state.short_price_limit.valid()? @@ -754,22 +759,32 @@ namespace bts { namespace cli { return !(a.market_index == b.market_index) && !(a.market_index < b.market_index); }); if (short_wall.state.balance != 0) - { bids_asks.first.insert(pos, short_wall); - bid_itr = bids_asks.first.begin(); - } } + //bid_itr may be invalidated by now... reset it. + bid_itr = bids_asks.first.begin(); + while(bid_itr != bids_asks.first.end() || ask_itr != bids_asks.second.end()) { if(bid_itr != bids_asks.first.end()) { bool short_wall = (bid_itr->get_owner() == address()); - out << std::left << std::setw(26) << client->get_chain()->to_pretty_asset(bid_itr->get_balance()) - << std::setw(20) << client->get_chain()->to_pretty_asset(bid_itr->get_quantity()) - << std::right << std::setw(30) << (fc::to_string(client->get_chain()->to_pretty_price_double(bid_itr->get_price())) + " " + quote_asset_record->symbol); + bool is_short_order = bid_itr->type == short_order; + + if (is_short_order) + { + asset quantity(bid_itr->get_quote_quantity() * (*bid_itr->state.short_price_limit)); + out << std::left << std::setw(26) << client->get_chain()->to_pretty_asset(bid_itr->get_quote_quantity()) + << std::setw(20) << client->get_chain()->to_pretty_asset(quantity) + << std::right << std::setw(30) << (fc::to_string(client->get_chain()->to_pretty_price_double(*bid_itr->state.short_price_limit)) + " " + quote_asset_record->symbol); + } else { + out << std::left << std::setw(26) << client->get_chain()->to_pretty_asset(bid_itr->get_balance()) + << std::setw(20) << client->get_chain()->to_pretty_asset(bid_itr->get_quantity()) + << std::right << std::setw(30) << (fc::to_string(client->get_chain()->to_pretty_price_double(bid_itr->get_price())) + " " + quote_asset_record->symbol); + } - if (short_wall) + if (short_wall || is_short_order) out << "*"; else out << " "; diff --git a/tests/nathan_tests.cpp b/tests/nathan_tests.cpp index 205590d33..2545b1b18 100644 --- a/tests/nathan_tests.cpp +++ b/tests/nathan_tests.cpp @@ -90,10 +90,12 @@ class nathan_fixture : public chain_fixture { void prompt() { string cmd; + std::cout << ">>> "; std::getline(std::cin, cmd); while (!cmd.empty()) { exec(clienta, cmd); exec(clientb, cmd); + std::cout << ">>> "; std::getline(std::cin, cmd); } } @@ -147,10 +149,19 @@ class nathan_fixture : public chain_fixture { BOOST_FIXTURE_TEST_CASE( short_below_feed, nathan_fixture ) { try { exec(clienta, "short delegate21 100 USD 5 .195"); + produce_block(clienta); + produce_block(clientb); + + exec(clientb, "blockchain_market_order_book USD XTS"); + exec(clientb, "blockchain_market_list_shorts USD"); exec(clientb, "ask delegate20 10 XTS .19 USD"); - produce_block(clienta); produce_block(clientb); + exec(clientb, "blockchain_market_order_book USD XTS"); + exec(clientb, "blockchain_market_list_shorts USD"); + produce_block(clientb); + exec(clientb, "blockchain_market_order_book USD XTS"); + exec(clientb, "blockchain_market_list_shorts USD"); prompt(); } FC_LOG_AND_RETHROW() } From 9a0fa61a722acbc725d59fcc0bb70bef72a6ec13 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 24 Sep 2014 15:40:34 +0000 Subject: [PATCH 09/20] bump testnet version --- libraries/blockchain/genesis.json | 2 +- .../include/bts/blockchain/config.hpp | 2 +- programs/feed.py | 22 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/libraries/blockchain/genesis.json b/libraries/blockchain/genesis.json index 488186879..dcea60516 100644 --- a/libraries/blockchain/genesis.json +++ b/libraries/blockchain/genesis.json @@ -1,5 +1,5 @@ { - "timestamp" : "20140916T000000", + "timestamp" : "20140924T000000", "market_assets": [ { "symbol": "PTS", diff --git a/libraries/blockchain/include/bts/blockchain/config.hpp b/libraries/blockchain/include/bts/blockchain/config.hpp index e046c050f..a59351f36 100644 --- a/libraries/blockchain/include/bts/blockchain/config.hpp +++ b/libraries/blockchain/include/bts/blockchain/config.hpp @@ -4,7 +4,7 @@ /* Comment out this line for a non-test network */ #define BTS_TEST_NETWORK -#define BTS_TEST_NETWORK_VERSION 28 +#define BTS_TEST_NETWORK_VERSION 29 /** @file bts/blockchain/config.hpp * @brief Defines global constants that determine blockchain behavior diff --git a/programs/feed.py b/programs/feed.py index afc83be3b..4c7d3fb05 100644 --- a/programs/feed.py +++ b/programs/feed.py @@ -48,6 +48,28 @@ url = "http://" + user + ":" + password + "@localhost:" + str(port) + "/rpc" print url + count = 0 + for name in delegates: + payload = { + "method": "wallet_transfer", + "params": [5, "XTS", "init0", "init" + str(count)], + "jsonrpc": "2.0", + "id": 0, + } + + print payload + + headers = { + 'content-type': 'application/json', + 'Authorization': "Basic YTph" + } + response = requests.post(url, data=json.dumps(payload), headers=headers) + print response + print response.json() + + count += 1 + + for name in delegates: payload = { "method": "wallet_publish_price_feed", From 8176af8e67655a676f98dc16efa1dfad868c62e3 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 24 Sep 2014 11:59:26 -0400 Subject: [PATCH 10/20] Use blockchain time for mail proof-of-work --- libraries/mail/client.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/mail/client.cpp b/libraries/mail/client.cpp index 4dd8ed99e..8a1f897a7 100644 --- a/libraries/mail/client.cpp +++ b/libraries/mail/client.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -324,7 +325,7 @@ class client_impl { std::unique_ptr> slave_handle_uptr(new fc::future()); fc::future* slave_handle = slave_handle_uptr.get(); while (email->content.id() > email->proof_of_work_target) { - email->content.timestamp = fc::time_point::now(); + email->content.timestamp = blockchain::now(); _processing_db.store(email->id, *email); try { From 2f0920eee1937a68bcd6ec159388de9dbcc9195b Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Wed, 24 Sep 2014 12:21:25 -0400 Subject: [PATCH 11/20] Switch back to using a randomly-generated node-id for preventing multiple connections to the same peer. We transmit the node's public key as well, we just don't use it for uniqueness checking. Should fix #794. Make the command-line bitshares_client and qt_wallet report different user_agent strings. Disable some excessive p2p logging. --- libraries/client/client.cpp | 17 +- .../client/include/bts/client/client.hpp | 5 +- .../net/include/bts/net/core_messages.hpp | 8 +- libraries/net/include/bts/net/node.hpp | 10 +- .../net/include/bts/net/peer_connection.hpp | 9 +- libraries/net/message_oriented_connection.cpp | 2 + libraries/net/node.cpp | 220 ++++++++++-------- libraries/net/peer_connection.cpp | 2 + programs/client/main.cpp | 5 +- programs/utils/map_bts_network.cpp | 4 +- tests/dev_fixture.hpp | 6 +- tests/wallet_tests.cpp | 12 +- 12 files changed, 178 insertions(+), 122 deletions(-) diff --git a/libraries/client/client.cpp b/libraries/client/client.cpp index 277370104..802b67a25 100644 --- a/libraries/client/client.cpp +++ b/libraries/client/client.cpp @@ -569,8 +569,9 @@ config load_config( const fc::path& datadir, bool enable_ulog ) fc::thread* _thread; }; - client_impl(bts::client::client* self) : + client_impl(bts::client::client* self, const std::string& user_agent) : _self(self), + _user_agent(user_agent), _last_sync_status_message_indicated_in_sync(true), _last_sync_status_head_block(0), _remaining_items_to_sync(0), @@ -668,7 +669,8 @@ config load_config( const fc::path& datadir, bool enable_ulog ) virtual void error_encountered(const std::string& message, const fc::oexception& error) override; /// @} - bts::client::client* _self = nullptr; + bts::client::client* _self; + std::string _user_agent; bts::cli::cli* _cli = nullptr; #ifndef DISABLE_DELEGATE_NETWORK @@ -1617,13 +1619,14 @@ config load_config( const fc::path& datadir, bool enable_ulog ) } // end namespace detail - client::client() - :my( new detail::client_impl(this)) + client::client(const std::string& user_agent) + :my(new detail::client_impl(this, user_agent)) { } - client::client(bts::net::simulated_network_ptr network_to_connect_to) - : my( new detail::client_impl(this) ) + client::client(const std::string& user_agent, + bts::net::simulated_network_ptr network_to_connect_to) + : my( new detail::client_impl(this, user_agent) ) { network_to_connect_to->add_node_delegate(my.get()); my->_p2p_node = network_to_connect_to; @@ -1721,7 +1724,7 @@ config load_config( const fc::path& datadir, bool enable_ulog ) //if we are using a simulated network, _p2p_node will already be set by client's constructor if (!my->_p2p_node) - my->_p2p_node = std::make_shared(); + my->_p2p_node = std::make_shared(my->_user_agent); my->_p2p_node->set_node_delegate(my.get()); my->start_rebroadcast_pending_loop(); diff --git a/libraries/client/include/bts/client/client.hpp b/libraries/client/include/bts/client/client.hpp index 3197e2f1c..deb94ec8c 100644 --- a/libraries/client/include/bts/client/client.hpp +++ b/libraries/client/include/bts/client/client.hpp @@ -115,8 +115,9 @@ namespace bts { namespace client { public std::enable_shared_from_this { public: - client(); - client(bts::net::simulated_network_ptr network_to_connect_to); + client(const std::string& user_agent); + client(const std::string& user_agent, + bts::net::simulated_network_ptr network_to_connect_to); void simulate_disconnect( bool state ); diff --git a/libraries/net/include/bts/net/core_messages.hpp b/libraries/net/include/bts/net/core_messages.hpp index 0016e874f..bbcc651e1 100644 --- a/libraries/net/include/bts/net/core_messages.hpp +++ b/libraries/net/include/bts/net/core_messages.hpp @@ -144,7 +144,7 @@ namespace bts { namespace net { fc::ip::address inbound_address; uint16_t inbound_port; uint16_t outbound_port; - node_id_t node_id; + node_id_t node_public_key; fc::ecc::compact_signature signed_shared_secret; fc::sha256 chain_id; fc::variant_object user_data; @@ -155,7 +155,7 @@ namespace bts { namespace net { const fc::ip::address& inbound_address, uint16_t inbound_port, uint16_t outbound_port, - const node_id_t& node_id_arg, + const node_id_t& node_public_key, const fc::ecc::compact_signature& signed_shared_secret, const fc::sha256& chain_id_arg, const fc::variant_object& user_data ) : @@ -164,7 +164,7 @@ namespace bts { namespace net { inbound_address(inbound_address), inbound_port(inbound_port), outbound_port(outbound_port), - node_id(node_id_arg), + node_public_key(node_public_key), signed_shared_secret(signed_shared_secret), chain_id(chain_id_arg), user_data(user_data) @@ -389,7 +389,7 @@ FC_REFLECT( bts::net::hello_message, (user_agent) (inbound_address) (inbound_port) (outbound_port) - (node_id) + (node_public_key) (signed_shared_secret) (chain_id) (user_data) ) diff --git a/libraries/net/include/bts/net/node.hpp b/libraries/net/include/bts/net/node.hpp index 41b6c8e93..1015c1e51 100644 --- a/libraries/net/include/bts/net/node.hpp +++ b/libraries/net/include/bts/net/node.hpp @@ -145,7 +145,7 @@ namespace bts { namespace net { class node : public std::enable_shared_from_this { public: - node(); + node(const std::string& user_agent); ~node(); void close(); @@ -200,7 +200,7 @@ namespace bts { namespace net { /** * @return a list of peers that are currently connected. */ - std::vector get_connected_peers()const; + std::vector get_connected_peers() const; /** return the number of peers we're actively connected to */ virtual uint32_t get_connection_count() const; @@ -217,7 +217,7 @@ namespace bts { namespace net { */ virtual void sync_from( const item_id& ); - bool is_connected()const; + bool is_connected() const; void set_advanced_node_parameters(const fc::variant_object& params); fc::variant_object get_advanced_node_parameters(); @@ -237,7 +237,7 @@ namespace bts { namespace net { fc::variant_object network_get_info() const; fc::variant_object network_get_usage_stats() const; - std::vector get_potential_peers()const; + std::vector get_potential_peers() const; void disable_peer_advertising(); fc::variant_object get_call_statistics() const; @@ -249,7 +249,7 @@ namespace bts { namespace net { { public: ~simulated_network(); - + simulated_network(const std::string& user_agent) : node(user_agent) {} void listen_to_p2p_network() override {} void connect_to_p2p_network() override {} void connect_to(const fc::ip::endpoint& ep) override {} diff --git a/libraries/net/include/bts/net/peer_connection.hpp b/libraries/net/include/bts/net/peer_connection.hpp index 989a51a6b..2c9707f6b 100644 --- a/libraries/net/include/bts/net/peer_connection.hpp +++ b/libraries/net/include/bts/net/peer_connection.hpp @@ -113,7 +113,13 @@ namespace bts { namespace net /// data about the peer node /// @{ - node_id_t node_id; + /** node_public_key from the hello message, zero-initialized before we get the hello */ + node_id_t node_public_key; + /** the unique identifier we'll use to refer to the node with. zero-initialized before + * we receive the hello message, at which time it will be filled with either the "node_id" + * from the user_data field of the hello, or if none is present it will be filled with a + * copy of node_public_key */ + node_id_t node_id; uint32_t core_protocol_version; std::string user_agent; fc::optional bitshares_git_revision_sha; @@ -121,6 +127,7 @@ namespace bts { namespace net fc::optional fc_git_revision_sha; fc::optional fc_git_revision_unix_timestamp; fc::optional platform; + fc::optional bitness; // for inbound connections, these fields record what the peer sent us in // its hello message. For outbound, they record what we sent the peer diff --git a/libraries/net/message_oriented_connection.cpp b/libraries/net/message_oriented_connection.cpp index fc7ffcfa0..b344196ca 100644 --- a/libraries/net/message_oriented_connection.cpp +++ b/libraries/net/message_oriented_connection.cpp @@ -206,6 +206,7 @@ namespace bts { namespace net { void message_oriented_connection_impl::send_message(const message& message_to_send) { VERIFY_CORRECT_THREAD(); +#if 0 // this gets too verbose #ifndef NDEBUG fc::optional remote_endpoint; if (_sock.get_socket().is_open()) @@ -215,6 +216,7 @@ namespace bts { namespace net { scope_logger(const fc::optional& endpoint) : endpoint(endpoint) { dlog("entering message_oriented_connection::send_message() for peer ${endpoint}", ("endpoint", endpoint)); } ~scope_logger() { dlog("leaving message_oriented_connection::send_message() for peer ${endpoint}", ("endpoint", endpoint)); } } send_message_scope_logger(remote_endpoint); +#endif #endif struct verify_no_send_in_progress { bool& var; diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 87cd71631..bc0fcc45e 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -434,7 +434,20 @@ namespace bts { namespace net { namespace detail { fc::future _terminate_inactive_connections_loop_done; std::string _user_agent_string; - node_id_t _node_id; + /** _node_public_key is a key automatically generated when the client is first run, stored in + * node_config.json. It doesn't really have much of a purpose yet, there was just some thought + * that we might someday have a use for nodes having a private key (sent in hello messages) + */ + node_id_t _node_public_key; + /** + * _node_id is a random number generated each time the client is launched, used to prevent us + * from connecting to the same client multiple times (sent in hello messages). + * Since this was introduced after the hello_message was finalized, this is sent in the + * user_data field. + * While this shares the same underlying type as a public key, it is really just a random + * number. + */ + node_id_t _node_id; /** if we have less than `_desired_number_of_connections`, we will try to connect with more nodes */ uint32_t _desired_number_of_connections; @@ -508,7 +521,7 @@ namespace bts { namespace net { namespace detail { bool _node_is_shutting_down; // set to true when we begin our destructor, used to prevent us from starting new tasks while we're shutting down - node_impl(); + node_impl(const std::string& user_agent); virtual ~node_impl(); void save_node_configuration(); @@ -540,7 +553,7 @@ namespace bts { namespace net { namespace detail { bool is_wanting_new_connections(); uint32_t get_number_of_connections(); - bool is_already_connected_to_id( const node_id_t node_id ); + bool is_already_connected_to_id(const node_id_t& node_id); bool merge_address_info_with_potential_peer_database( const std::vector addresses ); void display_current_connections(); uint32_t calculate_unsynced_block_count_from_all_peers(); @@ -709,7 +722,7 @@ namespace bts { namespace net { namespace detail { # define VERIFY_CORRECT_THREAD() do {} while (0) #endif - node_impl::node_impl() : + node_impl::node_impl(const std::string& user_agent) : #ifdef P2P_IN_DEDICATED_THREAD _thread(std::make_shared("p2p")), #endif // P2P_IN_DEDICATED_THREAD @@ -719,15 +732,15 @@ namespace bts { namespace net { namespace detail { _suspend_fetching_sync_blocks(false), _items_to_fetch_updated(false), _items_to_fetch_sequence_counter(0), - _user_agent_string( "bts::net::node" ), - _desired_number_of_connections( BTS_NET_DEFAULT_DESIRED_CONNECTIONS ), - _maximum_number_of_connections( BTS_NET_DEFAULT_MAX_CONNECTIONS ), - _peer_connection_retry_timeout( BTS_NET_DEFAULT_PEER_CONNECTION_RETRY_TIME ), - _peer_inactivity_timeout( BTS_NET_PEER_HANDSHAKE_INACTIVITY_TIMEOUT ), - _most_recent_blocks_accepted( _maximum_number_of_connections ), - _total_number_of_unfetched_items( 0 ), - _rate_limiter( 0, 0 ), - _last_reported_number_of_connections( 0 ), + _user_agent_string(user_agent), + _desired_number_of_connections(BTS_NET_DEFAULT_DESIRED_CONNECTIONS), + _maximum_number_of_connections(BTS_NET_DEFAULT_MAX_CONNECTIONS), + _peer_connection_retry_timeout(BTS_NET_DEFAULT_PEER_CONNECTION_RETRY_TIME), + _peer_inactivity_timeout(BTS_NET_PEER_HANDSHAKE_INACTIVITY_TIMEOUT), + _most_recent_blocks_accepted(_maximum_number_of_connections), + _total_number_of_unfetched_items(0), + _rate_limiter(0, 0), + _last_reported_number_of_connections(0), _peer_advertising_disabled(false), _average_network_read_speed_seconds(60), _average_network_write_speed_seconds(60), @@ -740,6 +753,7 @@ namespace bts { namespace net { namespace detail { _node_is_shutting_down(false) { _rate_limiter.set_actual_rate_time_constant(fc::seconds(2)); + fc::rand_pseudo_bytes(&_node_id.data[0], _node_id.size()); } node_impl::~node_impl() @@ -1470,24 +1484,24 @@ namespace bts { namespace net { namespace detail { return (uint32_t)(_handshaking_connections.size() + _active_connections.size()); } - bool node_impl::is_already_connected_to_id( const node_id_t node_id ) + bool node_impl::is_already_connected_to_id(const node_id_t& node_id) { VERIFY_CORRECT_THREAD(); - if( _node_id == node_id ) + if (node_id == _node_id) { - dlog( "is_already_connected_to_id returning true because the peer is us" ); + dlog("is_already_connected_to_id returning true because the peer is us"); return true; } - for( const peer_connection_ptr active_peer : _active_connections ) - if( active_peer->node_id == node_id ) + for (const peer_connection_ptr active_peer : _active_connections) + if (node_id == active_peer->node_id) { - dlog( "is_already_connected_to_id returning true because the peer is already in our active list" ); + dlog("is_already_connected_to_id returning true because the peer is already in our active list"); return true; } - for( const peer_connection_ptr handshaking_peer : _handshaking_connections ) - if( handshaking_peer->node_id == node_id ) + for (const peer_connection_ptr handshaking_peer : _handshaking_connections) + if (node_id == handshaking_peer->node_id) { - dlog( "is_already_connected_to_id returning true because the peer is already in our handshaking list" ); + dlog("is_already_connected_to_id returning true because the peer is already in our handshaking list"); return true; } return false; @@ -1515,19 +1529,25 @@ namespace bts { namespace net { namespace detail { void node_impl::display_current_connections() { VERIFY_CORRECT_THREAD(); - dlog( "Currently have ${current} of [${desired}/${max}] connections", - ( "current", get_number_of_connections() ) - ( "desired", _desired_number_of_connections ) - ( "max", _maximum_number_of_connections ) ); - dlog( " my id is ${id}", ("id", _node_id ) ); - - for( const peer_connection_ptr& active_connection : _active_connections ) - { - dlog( " active: ${endpoint} with ${id} [${direction}]", ("endpoint",active_connection->get_remote_endpoint() )("id",active_connection->node_id )("direction",active_connection->direction ) ); + dlog("Currently have ${current} of [${desired}/${max}] connections", + ("current", get_number_of_connections()) + ("desired", _desired_number_of_connections) + ("max", _maximum_number_of_connections)); + dlog(" my id is ${id}", ("id", _node_id)); + + for (const peer_connection_ptr& active_connection : _active_connections) + { + dlog(" active: ${endpoint} with ${id} [${direction}]", + ("endpoint", active_connection->get_remote_endpoint()) + ("id", active_connection->node_id) + ("direction", active_connection->direction)); } - for( const peer_connection_ptr& handshaking_connection : _handshaking_connections ) + for (const peer_connection_ptr& handshaking_connection : _handshaking_connections) { - dlog( " handshaking: ${endpoint} with ${id} [${direction}]", ("endpoint",handshaking_connection->get_remote_endpoint() )("id",handshaking_connection->node_id )("direction",handshaking_connection->direction ) ); + dlog(" handshaking: ${endpoint} with ${id} [${direction}]", + ("endpoint", handshaking_connection->get_remote_endpoint()) + ("id", handshaking_connection->node_id) + ("direction", handshaking_connection->direction)); } } @@ -1626,57 +1646,75 @@ namespace bts { namespace net { namespace detail { #else user_data["platform"] = "other"; #endif + user_data["bitness"] = sizeof(void*) * 8; + + user_data["node_id"] = _node_id; + return user_data; } - void node_impl::parse_hello_user_data_for_peer( peer_connection* originating_peer, const fc::variant_object& user_data ) + void node_impl::parse_hello_user_data_for_peer(peer_connection* originating_peer, const fc::variant_object& user_data) { VERIFY_CORRECT_THREAD(); // try to parse data out of the user_agent string - if( user_data.contains("bitshares_git_revision_sha" ) ) + if (user_data.contains("bitshares_git_revision_sha")) originating_peer->bitshares_git_revision_sha = user_data["bitshares_git_revision_sha"].as_string(); - if( user_data.contains("bitshares_git_revision_unix_timestamp" ) ) - originating_peer->bitshares_git_revision_unix_timestamp = fc::time_point_sec( user_data["bitshares_git_revision_unix_timestamp"].as() ); - if( user_data.contains("fc_git_revision_sha" ) ) + if (user_data.contains("bitshares_git_revision_unix_timestamp")) + originating_peer->bitshares_git_revision_unix_timestamp = fc::time_point_sec(user_data["bitshares_git_revision_unix_timestamp"].as()); + if (user_data.contains("fc_git_revision_sha")) originating_peer->fc_git_revision_sha = user_data["fc_git_revision_sha"].as_string(); - if( user_data.contains("fc_git_revision_unix_timestamp" ) ) - originating_peer->fc_git_revision_unix_timestamp = fc::time_point_sec( user_data["fc_git_revision_unix_timestamp"].as() ); - if( user_data.contains("platform" ) ) + if (user_data.contains("fc_git_revision_unix_timestamp")) + originating_peer->fc_git_revision_unix_timestamp = fc::time_point_sec(user_data["fc_git_revision_unix_timestamp"].as()); + if (user_data.contains("platform")) originating_peer->platform = user_data["platform"].as_string(); + if (user_data.contains("bitness")) + originating_peer->bitness = user_data["bitness"].as(); + if (user_data.contains("node_id")) + originating_peer->node_id = user_data["node_id"].as(); } void node_impl::on_hello_message( peer_connection* originating_peer, const hello_message& hello_message_received ) { VERIFY_CORRECT_THREAD(); - // this check must come before we fill in peer data below - bool already_connected_to_this_peer = is_already_connected_to_id( hello_message_received.node_id ); + // this already_connected check must come before we fill in peer data below + node_id_t peer_node_id = hello_message_received.node_public_key; + try + { + peer_node_id = hello_message_received.user_data["node_id"].as(); + } + catch (const fc::exception&) + { + // either it's not there or it's not a valid session id. either way, ignore. + } + bool already_connected_to_this_peer = is_already_connected_to_id(peer_node_id); // validate the node id fc::sha256::encoder shared_secret_encoder; fc::sha512 shared_secret = originating_peer->get_shared_secret(); shared_secret_encoder.write(shared_secret.data(), sizeof(shared_secret)); - fc::ecc::public_key expected_node_id(hello_message_received.signed_shared_secret, shared_secret_encoder.result()); + fc::ecc::public_key expected_node_public_key(hello_message_received.signed_shared_secret, shared_secret_encoder.result()); // store off the data provided in the hello message originating_peer->user_agent = hello_message_received.user_agent; - originating_peer->node_id = hello_message_received.node_id; + originating_peer->node_public_key = hello_message_received.node_public_key; + originating_peer->node_id = hello_message_received.node_public_key; // will probably be overwritten in parse_hello_user_data_for_peer() originating_peer->core_protocol_version = hello_message_received.core_protocol_version; originating_peer->inbound_address = hello_message_received.inbound_address; originating_peer->inbound_port = hello_message_received.inbound_port; originating_peer->outbound_port = hello_message_received.outbound_port; - parse_hello_user_data_for_peer( originating_peer, hello_message_received.user_data ); + parse_hello_user_data_for_peer(originating_peer, hello_message_received.user_data); // now decide what to do with it - if( originating_peer->their_state == peer_connection::their_connection_state::just_connected ) + if (originating_peer->their_state == peer_connection::their_connection_state::just_connected) { - if (hello_message_received.node_id != expected_node_id.serialize()) + if (hello_message_received.node_public_key != expected_node_public_key.serialize()) { wlog("Invalid signature in hello message from peer ${peer}", ("peer", originating_peer->get_remote_endpoint())); std::string rejection_message("Invalid signature in hello message"); - connection_rejected_message connection_rejected( _user_agent_string, core_protocol_version, + connection_rejected_message connection_rejected(_user_agent_string, core_protocol_version, originating_peer->get_socket().remote_endpoint(), rejection_reason_code::invalid_hello_message, - rejection_message ); + rejection_message); originating_peer->their_state = peer_connection::their_connection_state::connection_rejected; originating_peer->send_message( message(connection_rejected ) ); @@ -1684,7 +1722,7 @@ namespace bts { namespace net { namespace detail { disconnect_from_peer( originating_peer, "Invalid signature in hello message" ); return; } - if( hello_message_received.chain_id != _chain_id ) + if (hello_message_received.chain_id != _chain_id) { wlog( "Received hello message from peer on a different chain: ${message}", ("message", hello_message_received ) ); std::ostringstream rejection_message; @@ -1700,32 +1738,32 @@ namespace bts { namespace net { namespace detail { // for this type of message, we're immediately disconnecting this peer, instead of trying to // allowing her to ask us for peers (any of our peers will be on the same chain as us, so there's no // benefit of sharing them) - disconnect_from_peer( originating_peer, "You are on a different chain from me" ); + disconnect_from_peer(originating_peer, "You are on a different chain from me"); return; } - if( already_connected_to_this_peer ) + if (already_connected_to_this_peer) { connection_rejected_message connection_rejected; - if( _node_id == hello_message_received.node_id ) - connection_rejected = connection_rejected_message( _user_agent_string, core_protocol_version, + if (_node_id == originating_peer->node_id) + connection_rejected = connection_rejected_message(_user_agent_string, core_protocol_version, originating_peer->get_socket().remote_endpoint(), rejection_reason_code::connected_to_self, - "I'm connecting to myself" ); + "I'm connecting to myself"); else - connection_rejected = connection_rejected_message( _user_agent_string, core_protocol_version, + connection_rejected = connection_rejected_message(_user_agent_string, core_protocol_version, originating_peer->get_socket().remote_endpoint(), rejection_reason_code::already_connected, - "I'm already connected to you" ); + "I'm already connected to you"); originating_peer->their_state = peer_connection::their_connection_state::connection_rejected; - originating_peer->send_message( message(connection_rejected ) ); - dlog( "Received a hello_message from peer ${peer} that I'm already connected to (with id ${id} ), rejection", - ( "peer", originating_peer->get_remote_endpoint() ) - ( "id", hello_message_received.node_id ) ); + originating_peer->send_message(message(connection_rejected)); + dlog("Received a hello_message from peer ${peer} that I'm already connected to (with id ${id}), rejection", + ("peer", originating_peer->get_remote_endpoint()) + ("id", originating_peer->node_id)); } #ifdef ENABLE_P2P_DEBUGGING_API - else if( !_allowed_peers.empty() && - _allowed_peers.find( originating_peer->node_id ) == _allowed_peers.end() ) + else if(!_allowed_peers.empty() && + _allowed_peers.find(originating_peer->node_id) == _allowed_peers.end()) { connection_rejected_message connection_rejected( _user_agent_string, core_protocol_version, originating_peer->get_socket().remote_endpoint(), @@ -1862,15 +1900,14 @@ namespace bts { namespace net { namespace detail { { potential_peer_record updated_peer_record = _potential_peer_db.lookup_or_create_entry_for_endpoint( *active_peer->get_remote_endpoint() ); updated_peer_record.last_seen_time = fc::time_point::now(); - _potential_peer_db.update_entry( updated_peer_record ); - - address_info info_for_peer( *active_peer->get_remote_endpoint(), - fc::time_point::now(), - active_peer->round_trip_delay, - active_peer->node_id, - active_peer->direction, - active_peer->is_firewalled ); - reply.addresses.push_back( std::move(info_for_peer ) ); + _potential_peer_db.update_entry(updated_peer_record); + + reply.addresses.emplace_back(address_info(*active_peer->get_remote_endpoint(), + fc::time_point::now(), + active_peer->round_trip_delay, + active_peer->node_id, + active_peer->direction, + active_peer->is_firewalled)); } } //for( const potential_peer_record& record : _potential_peer_db ) @@ -2866,8 +2903,8 @@ namespace bts { namespace net { namespace detail { // TODO } - void node_impl::on_check_firewall_message( peer_connection* originating_peer, - const check_firewall_message& check_firewall_message_received ) + void node_impl::on_check_firewall_message(peer_connection* originating_peer, + const check_firewall_message& check_firewall_message_received) { VERIFY_CORRECT_THREAD(); // TODO @@ -2877,8 +2914,8 @@ namespace bts { namespace net { namespace detail { reply.result = firewall_check_result::unable_to_check; } - void node_impl::on_check_firewall_reply_message( peer_connection* originating_peer, - const check_firewall_reply_message& check_firewall_reply_message_received ) + void node_impl::on_check_firewall_reply_message(peer_connection* originating_peer, + const check_firewall_reply_message& check_firewall_reply_message_received) { VERIFY_CORRECT_THREAD(); // TODO @@ -3340,7 +3377,7 @@ namespace bts { namespace net { namespace detail { local_endpoint.get_address(), listening_port, local_endpoint.port(), - _node_id, + _node_public_key, signature, _chain_id, generate_hello_user_data() ); @@ -3475,7 +3512,7 @@ namespace bts { namespace net { namespace detail { _node_configuration.private_key = fc::ecc::private_key::generate(); } - _node_id = _node_configuration.private_key.get_public_key().serialize(); + _node_public_key = _node_configuration.private_key.get_public_key().serialize(); fc::path potential_peer_database_file_name( _node_configuration_directory / POTENTIAL_PEER_DATABASE_FILENAME ); try @@ -3510,7 +3547,7 @@ namespace bts { namespace net { namespace detail { return; } - assert( _node_id != fc::ecc::public_key_data() ); + assert(_node_public_key != fc::ecc::public_key_data()); fc::ip::endpoint listen_endpoint = _node_configuration.listen_endpoint; if( listen_endpoint.port() != 0 ) @@ -3598,7 +3635,7 @@ namespace bts { namespace net { namespace detail { void node_impl::connect_to_p2p_network() { VERIFY_CORRECT_THREAD(); - assert(_node_id != fc::ecc::public_key_data()); + assert(_node_public_key != fc::ecc::public_key_data()); assert(!_accept_loop_complete.valid() && !_p2p_network_connect_loop_done.valid() && @@ -4024,19 +4061,19 @@ namespace bts { namespace net { namespace detail { VERIFY_CORRECT_THREAD(); return _node_id; } - void node_impl::set_allowed_peers( const std::vector& allowed_peers ) + void node_impl::set_allowed_peers(const std::vector& allowed_peers) { VERIFY_CORRECT_THREAD(); #ifdef ENABLE_P2P_DEBUGGING_API _allowed_peers.clear(); - _allowed_peers.insert( allowed_peers.begin(), allowed_peers.end() ); + _allowed_peers.insert(allowed_peers.begin(), allowed_peers.end()); std::list peers_to_disconnect; - if( !_allowed_peers.empty() ) - for( const peer_connection_ptr& peer : _active_connections ) - if( _allowed_peers.find(peer->node_id) == _allowed_peers.end() ) - peers_to_disconnect.push_back( peer ); - for( const peer_connection_ptr& peer : peers_to_disconnect ) - disconnect_from_peer( peer.get(), "My allowed_peers list has changed, and you're no longer allowed. Bye." ); + if (!_allowed_peers.empty()) + for (const peer_connection_ptr& peer : _active_connections) + if (_allowed_peers.find(peer->node_id) == _allowed_peers.end()) + peers_to_disconnect.push_back(peer); + for (const peer_connection_ptr& peer : peers_to_disconnect) + disconnect_from_peer(peer.get(), "My allowed_peers list has changed, and you're no longer allowed. Bye."); #endif // ENABLE_P2P_DEBUGGING_API } void node_impl::clear_peer_database() @@ -4069,6 +4106,7 @@ namespace bts { namespace net { namespace detail { VERIFY_CORRECT_THREAD(); fc::mutable_variant_object info; info["listening_on"] = _actual_listening_endpoint; + info["node_public_key"] = _node_public_key; info["node_id"] = _node_id; return info; } @@ -4118,8 +4156,8 @@ namespace bts { namespace net { namespace detail { return my->method_name(__VA_ARGS__) #endif // P2P_IN_DEDICATED_THREAD - node::node() : - my( new detail::node_impl ) + node::node(const std::string& user_agent) : + my(new detail::node_impl(user_agent)) { } diff --git a/libraries/net/peer_connection.cpp b/libraries/net/peer_connection.cpp index 8b7ed08e8..3d51f0b3f 100644 --- a/libraries/net/peer_connection.cpp +++ b/libraries/net/peer_connection.cpp @@ -56,12 +56,14 @@ namespace bts { namespace net { VERIFY_CORRECT_THREAD(); +#if 0 // this gets too verbose #ifndef NDEBUG struct scope_logger { fc::optional endpoint; scope_logger(const fc::optional& endpoint) : endpoint(endpoint) { dlog("entering peer_connection::destroy() for peer ${endpoint}", ("endpoint", endpoint)); } ~scope_logger() { dlog("leaving peer_connection::destroy() for peer ${endpoint}", ("endpoint", endpoint)); } } send_message_scope_logger(get_remote_endpoint()); +#endif #endif try diff --git a/programs/client/main.cpp b/programs/client/main.cpp index 383e5123b..04add1f4e 100644 --- a/programs/client/main.cpp +++ b/programs/client/main.cpp @@ -26,8 +26,9 @@ int main( int argc, char** argv ) { - try { - bts::client::client_ptr client = std::make_shared(); + try + { + bts::client::client_ptr client = std::make_shared("bitshares_client"); client->configure_from_command_line(argc,argv); client->start().wait(); } diff --git a/programs/utils/map_bts_network.cpp b/programs/utils/map_bts_network.cpp index ae28964fa..3056a926f 100644 --- a/programs/utils/map_bts_network.cpp +++ b/programs/utils/map_bts_network.cpp @@ -104,7 +104,9 @@ class peer_probe : public bts::net::peer_connection_delegate void on_hello_message(bts::net::peer_connection* originating_peer, const bts::net::hello_message& hello_message_received) { - _node_id = hello_message_received.node_id; + _node_id = hello_message_received.node_public_key; + if (hello_message_received.user_data.contains("node_id")) + originating_peer->node_id = hello_message_received.user_data["node_id"].as(); originating_peer->send_message(bts::net::connection_rejected_message()); } diff --git a/tests/dev_fixture.hpp b/tests/dev_fixture.hpp index 692195314..3f0b70d97 100644 --- a/tests/dev_fixture.hpp +++ b/tests/dev_fixture.hpp @@ -40,7 +40,7 @@ struct chain_fixture ilog( "." ); try { - sim_network = std::make_shared(); + sim_network = std::make_shared("dev_fixture"); bts::blockchain::start_simulated_time(fc::time_point::from_iso_string( "20200101T000000" )); set_random_seed_for_testing( fc::sha512() ); @@ -169,14 +169,14 @@ struct chain_fixture fc::json::save_to_file( config, clienta_dir.path() / "genesis.json" ); fc::json::save_to_file( config, clientb_dir.path() / "genesis.json" ); - clienta = std::make_shared(sim_network); + clienta = std::make_shared("dev_fixture", sim_network); clienta->open( clienta_dir.path(), clienta_dir.path() / "genesis.json" ); clienta->configure_from_command_line( 0, nullptr ); clienta->set_daemon_mode(true); clienta->start(); ilog( "... " ); - clientb = std::make_shared(sim_network); + clientb = std::make_shared("dev_fixture", sim_network); clientb->open( clientb_dir.path(), clientb_dir.path() / "genesis.json" ); clientb->configure_from_command_line( 0, nullptr ); clientb->set_daemon_mode(true); diff --git a/tests/wallet_tests.cpp b/tests/wallet_tests.cpp index fa79062c0..14f0347f4 100644 --- a/tests/wallet_tests.cpp +++ b/tests/wallet_tests.cpp @@ -103,14 +103,14 @@ BOOST_AUTO_TEST_CASE( master_test ) fc::temp_directory clientb_dir; fc::json::save_to_file( config, clientb_dir.path() / "genesis.json" ); - auto sim_network = std::make_shared(); + bts::net::simulated_network_ptr sim_network = std::make_shared("wallet_tests"); - auto clienta = std::make_shared(sim_network); + bts::client::client_ptr clienta = std::make_shared("wallet_tests", sim_network); clienta->open( clienta_dir.path(), clienta_dir.path() / "genesis.json" ); clienta->configure_from_command_line( 0, nullptr ); clienta->start().wait(); - auto clientb = std::make_shared(sim_network); + bts::client::client_ptr clientb = std::make_shared("wallet_tests", sim_network); clientb->open( clientb_dir.path(), clientb_dir.path() / "genesis.json" ); clientb->configure_from_command_line( 0, nullptr ); clientb->start().wait(); @@ -478,7 +478,7 @@ void run_regression_test(fc::path test_dir, bool with_network) std::ifstream test_config_file(test_config_file_name.string()); //create one client per line and run each client's input commands - auto sim_network = std::make_shared(); + auto sim_network = std::make_shared("wallet_tests"); vector tests; string line; std::vector clients; @@ -547,7 +547,7 @@ void run_regression_test(fc::path test_dir, bool with_network) } else { - bts::client::client_ptr client = std::make_shared(sim_network); + bts::client::client_ptr client = std::make_shared("wallet_tests", sim_network); clients.push_back(client); client->configure_from_command_line(argc, argv); client_done = client->start(); @@ -590,7 +590,7 @@ BOOST_AUTO_TEST_CASE(replay_chain_database) { fc::temp_directory client_dir; //auto sim_network = std::make_shared(); - bts::net::simulated_network_ptr sim_network = std::make_shared(); + bts::net::simulated_network_ptr sim_network = std::make_shared("wallet_tests"); bts::client::client_ptr client = std::make_shared(sim_network); client->open( client_dir.path() ); client->configure_from_command_line( 0, nullptr ); From ecd2b1cfa5122f28ab6025db11d2ecd4f46ff497 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 24 Sep 2014 14:12:06 -0400 Subject: [PATCH 12/20] Mail server now sanity checks incoming messages before storing --- libraries/mail/client.cpp | 2 +- libraries/mail/include/bts/mail/config.hpp | 3 +++ libraries/mail/server.cpp | 28 +++++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/libraries/mail/client.cpp b/libraries/mail/client.cpp index 8a1f897a7..1a446fefe 100644 --- a/libraries/mail/client.cpp +++ b/libraries/mail/client.cpp @@ -279,7 +279,7 @@ class client_impl { } //TODO: Contact mail servers, get their PoW requirements, set target to min() of these - email.proof_of_work_target = ripemd160("000000fffdeadbeeffffffffffffffffffffffff"); + email.proof_of_work_target = BTS_MAIL_PROOF_OF_WORK_TARGET; _processing_db.store(message_id, email); schedule_proof_of_work(message_id); diff --git a/libraries/mail/include/bts/mail/config.hpp b/libraries/mail/include/bts/mail/config.hpp index acf05f856..d9b0fb47f 100644 --- a/libraries/mail/include/bts/mail/config.hpp +++ b/libraries/mail/include/bts/mail/config.hpp @@ -1,3 +1,6 @@ #pragma once #define BTS_MAIL_INVENTORY_FETCH_LIMIT 4096 +#define BTS_MAIL_MAX_MESSAGE_SIZE_BYTES (1024*1024) +#define BTS_MAIL_MAX_MESSAGE_AGE (fc::minutes(5)) +#define BTS_MAIL_PROOF_OF_WORK_TARGET (fc::ripemd160("000000fffdeadbeeffffffffffffffffffffffff")) diff --git a/libraries/mail/server.cpp b/libraries/mail/server.cpp index 8d96c6286..68f290656 100644 --- a/libraries/mail/server.cpp +++ b/libraries/mail/server.cpp @@ -1,7 +1,10 @@ #include +#include #include #include +#include #include +#include #include namespace bts { namespace mail { @@ -61,7 +64,8 @@ namespace bts { namespace mail { /** * Prevent the same message from going to multiple accounts. */ - FC_ASSERT( !_mail_data_db.fetch_optional(inventory_id) ); + if( _mail_data_db.fetch_optional(inventory_id) ) + FC_THROW_EXCEPTION( message_already_stored, "Message already stored on server." ); _mail_inventory_db.store( mail_index{owner,fc::time_point::now()}, inventory_id ); _mail_data_db.store( inventory_id, msg ); @@ -95,6 +99,27 @@ namespace bts { namespace mail { return _mail_data_db.fetch( inventory_id ); } FC_CAPTURE_AND_RETHROW( (inventory_id) ) } + void check_incoming_message( const message& msg ) + { try { + auto now = blockchain::now(); + if( msg.timestamp > now ) + FC_THROW_EXCEPTION( timestamp_in_future, + "Incoming message has timestamp ${message_stamp}, but current time is ${now}", + ("message_stamp", msg.timestamp)("now", now) ); + if( now - msg.timestamp > BTS_MAIL_MAX_MESSAGE_AGE ) + FC_THROW_EXCEPTION( timestamp_too_old, + "Incoming message has timestamp ${message_stamp}, but current time is ${now}", + ("message_stamp", msg.timestamp)("now", now) ); + if( msg.id() > BTS_MAIL_PROOF_OF_WORK_TARGET ) + FC_THROW_EXCEPTION( invalid_proof_of_work, + "Incoming message ID ${id} does not meet proof-of-work requirement ${req}", + ("id", msg.id())("req", BTS_MAIL_PROOF_OF_WORK_TARGET) ); + if( msg.data.size() > BTS_MAIL_MAX_MESSAGE_SIZE_BYTES ) + FC_THROW_EXCEPTION( message_too_large, + "Incoming message size is ${size}, larger than one megabyte.", + ("size", msg.data.size()) ); + } FC_CAPTURE_AND_RETHROW( (msg) ) } + private: bts::db::level_pod_map< mail_index, message_id_type > _mail_inventory_db; bts::db::level_map< message_id_type, message > _mail_data_db; @@ -117,6 +142,7 @@ namespace bts { namespace mail { void server::store( const bts::blockchain::address& owner, const message& msg ) { + my->check_incoming_message(msg); my->store(owner,msg); } From fefa7e6b687a9d00089cb1ee50d68cd32e088798 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 24 Sep 2014 15:18:28 -0400 Subject: [PATCH 13/20] Fix bug in market engine matching undercollateralized short --- libraries/blockchain/market_engine.cpp | 9 ++++++--- libraries/blockchain/market_operations.cpp | 6 +----- tests/nathan_tests.cpp | 5 ++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libraries/blockchain/market_engine.cpp b/libraries/blockchain/market_engine.cpp index a4102fe18..24f9c0c55 100644 --- a/libraries/blockchain/market_engine.cpp +++ b/libraries/blockchain/market_engine.cpp @@ -277,9 +277,12 @@ class market_engine mtrx.bid_collateral = mtrx.bid_paid / collateral_rate; - // Handle rounding errors - if( (*mtrx.bid_collateral - _current_bid->get_balance()).amount < BTS_BLOCKCHAIN_PRECISION ) - mtrx.bid_collateral = _current_bid->get_balance(); + if( (*mtrx.bid_collateral - mtrx.ask_paid).amount < 0 ) + { + edump( (mtrx) ); + _current_bid.reset(); + continue; + } // If too little collateral at this price if( *mtrx.bid_collateral < mtrx.ask_paid ) diff --git a/libraries/blockchain/market_operations.cpp b/libraries/blockchain/market_operations.cpp index 442393d22..9655d6b27 100644 --- a/libraries/blockchain/market_operations.cpp +++ b/libraries/blockchain/market_operations.cpp @@ -129,10 +129,6 @@ namespace bts { namespace blockchain { asset delta_amount = this->get_amount(); asset delta_quote = delta_amount * this->short_index.order_price; -#ifndef WIN32 // TODO... remove this warning once BTSX updates -#warning BTSX should assert that delta_amount.asset_id == 0 -#endif - /** if the USD amount of the order is effectively then don't bother */ FC_ASSERT( llabs( delta_quote.amount ) > 0, "", ("delta_quote",delta_quote)("order",*this)); @@ -140,7 +136,7 @@ namespace bts { namespace blockchain { auto asset_to_short = eval_state._current_state->get_asset_record( short_index.order_price.quote_asset_id ); FC_ASSERT( asset_to_short.valid() ); FC_ASSERT( asset_to_short->is_market_issued(), "${symbol} is not a market issued asset", ("symbol",asset_to_short->symbol) ); - + FC_ASSERT( !this->short_price_limit || *(this->short_price_limit) >= this->short_index.order_price, "Insufficient collateral at price limit" ); auto current_short = eval_state._current_state->get_short_record( this->short_index ); //if( current_short ) wdump( (current_short) ); diff --git a/tests/nathan_tests.cpp b/tests/nathan_tests.cpp index 2545b1b18..ca767d8fa 100644 --- a/tests/nathan_tests.cpp +++ b/tests/nathan_tests.cpp @@ -148,7 +148,10 @@ class nathan_fixture : public chain_fixture { BOOST_FIXTURE_TEST_CASE( short_below_feed, nathan_fixture ) { try { - exec(clienta, "short delegate21 100 USD 5 .195"); + //This should fail. + exec(clienta, "short delegate21 100 USD 5 .194"); + //This should work. + exec(clienta, "short delegate21 100 USD 10 .195"); produce_block(clienta); produce_block(clientb); From 347fb934b9a2dff39a2e2b1b72ce64e48cbf4aec Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 24 Sep 2014 16:22:27 -0400 Subject: [PATCH 14/20] Further revisions to market engine, allowing buying normal shorts --- libraries/blockchain/market_engine.cpp | 38 ++++++-------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/libraries/blockchain/market_engine.cpp b/libraries/blockchain/market_engine.cpp index 24f9c0c55..f6643f456 100644 --- a/libraries/blockchain/market_engine.cpp +++ b/libraries/blockchain/market_engine.cpp @@ -167,17 +167,10 @@ class market_engine mtrx.bid_collateral = mtrx.bid_paid / collateral_rate; // Handle rounding errors - if( (*mtrx.bid_collateral - _current_bid->get_balance()).amount < BTS_BLOCKCHAIN_PRECISION ) + if( ((_current_bid->get_balance() - *mtrx.bid_collateral).amount < 100 ) && + (_current_bid->get_balance() > *mtrx.bid_collateral) ) mtrx.bid_collateral = _current_bid->get_balance(); - // If too little collateral at this price - if( *mtrx.bid_collateral < mtrx.ask_paid ) - { - edump( (mtrx) ); - _current_bid.reset(); - continue; - } - pay_current_short( mtrx, *quote_asset ); pay_current_cover( mtrx, *quote_asset ); @@ -262,7 +255,7 @@ class market_engine // Bound collateral ratio price collateral_rate = _current_bid->get_price(); if( collateral_rate > _market_stat.center_price ) - collateral_rate = _market_stat.center_price; + collateral_rate = _market_stat.center_price; const asset ask_quantity_usd = _current_ask->get_quote_quantity(); const asset short_quantity_usd = _current_bid->get_balance() / collateral_rate; @@ -277,20 +270,10 @@ class market_engine mtrx.bid_collateral = mtrx.bid_paid / collateral_rate; - if( (*mtrx.bid_collateral - mtrx.ask_paid).amount < 0 ) - { - edump( (mtrx) ); - _current_bid.reset(); - continue; - } - - // If too little collateral at this price - if( *mtrx.bid_collateral < mtrx.ask_paid ) - { - edump( (mtrx) ); - _current_bid.reset(); - continue; - } + // Handle rounding errors + if( ((_current_bid->get_balance() - *mtrx.bid_collateral).amount < 100 ) && + (_current_bid->get_balance() > *mtrx.bid_collateral) ) + mtrx.bid_collateral = _current_bid->get_balance(); pay_current_short( mtrx, *quote_asset ); pay_current_ask( mtrx, *quote_asset ); @@ -463,15 +446,10 @@ class market_engine FC_ASSERT( _current_bid->type == short_order ); FC_ASSERT( mtrx.bid_type == short_order ); - /** NOTE: the short may pay extra XTS to the collateral in the event rounding occurs. This - * just checks to make sure it is reasonable. - */ - FC_ASSERT( mtrx.ask_paid <= *mtrx.bid_collateral, "", ("mtrx",mtrx) ); - quote_asset.current_share_supply += mtrx.bid_paid.amount; auto collateral = *mtrx.bid_collateral + mtrx.ask_paid; - if( mtrx.bid_paid.amount <= 0 ) // WHY is this ever negitive?? + if( mtrx.bid_paid.amount <= 0 ) // WHY is this ever negative?? { FC_ASSERT( mtrx.bid_paid.amount >= 0 ); _current_bid->state.balance -= mtrx.bid_collateral->amount; From 05e53a515410eb4cac16b3ef94004b5b28df2a1b Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 24 Sep 2014 16:36:14 -0400 Subject: [PATCH 15/20] Test covering into short wall as well as normal sale --- tests/dev_tests.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/dev_tests.cpp b/tests/dev_tests.cpp index 547c20cec..22e2ec0f1 100644 --- a/tests/dev_tests.cpp +++ b/tests/dev_tests.cpp @@ -211,7 +211,12 @@ BOOST_FIXTURE_TEST_CASE( basic_commands, chain_fixture ) exec(clienta, "wallet_publish_price_feed delegate51 .74 BUSD" ); produce_block(clientb); - exec( clienta, "bid delegate31 67 XTS .69 BUSD" ); + exec( clienta, "bid delegate31 37 XTS .69 BUSD" ); + + produce_block(clientb); + produce_block(clientb); + + exec( clienta, "short delegate35 500 BUSD 30" ); produce_block(clientb); produce_block(clientb); From 04f3e7683e464ebe843e61731a7b149d1e2806be Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 24 Sep 2014 16:58:46 -0400 Subject: [PATCH 16/20] Add missing exceptions.hpp in mail --- libraries/mail/include/bts/mail/exceptions.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 libraries/mail/include/bts/mail/exceptions.hpp diff --git a/libraries/mail/include/bts/mail/exceptions.hpp b/libraries/mail/include/bts/mail/exceptions.hpp new file mode 100644 index 000000000..3110b738a --- /dev/null +++ b/libraries/mail/include/bts/mail/exceptions.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace bts { namespace mail { + FC_DECLARE_EXCEPTION(mail_exception, 70000, "Mail Exception"); + FC_DECLARE_DERIVED_EXCEPTION(timestamp_too_old, mail_exception, 70001, "timestamp too old"); + FC_DECLARE_DERIVED_EXCEPTION(timestamp_in_future, mail_exception, 70002, "timestamp in future"); + FC_DECLARE_DERIVED_EXCEPTION(invalid_proof_of_work, mail_exception, 70003, "invalid proof-of-work"); + FC_DECLARE_DERIVED_EXCEPTION(message_too_large, mail_exception, 70004, "message too large"); + FC_DECLARE_DERIVED_EXCEPTION(message_already_stored, mail_exception, 70005, "message already stored"); +} } // namespace bts::mail From fb779fc0e62fac76e72f015082de0242f2d98929 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Tue, 23 Sep 2014 14:52:22 -0400 Subject: [PATCH 17/20] Initial notes on new wallet transaction record format and scanning --- .../wallet/include/bts/wallet/wallet_db.hpp | 12 +- .../include/bts/wallet/wallet_records.hpp | 206 ++++++++++++++---- libraries/wallet/wallet.cpp | 200 +++++++++++++++++ libraries/wallet/wallet_db.cpp | 3 +- programs/qt_wallet | 2 +- programs/web_wallet | 2 +- 6 files changed, 375 insertions(+), 50 deletions(-) diff --git a/libraries/wallet/include/bts/wallet/wallet_db.hpp b/libraries/wallet/include/bts/wallet/wallet_db.hpp index 61eda6871..ed01392b3 100644 --- a/libraries/wallet/include/bts/wallet/wallet_db.hpp +++ b/libraries/wallet/include/bts/wallet/wallet_db.hpp @@ -24,13 +24,13 @@ namespace bts { namespace wallet { bool is_open()const; - int32_t new_wallet_record_index(); - int32_t new_key_child_index( const address& parent_account_address ); - private_key_type get_private_key( const fc::sha512& password, int index ); + int32_t new_wallet_record_index(); + int32_t new_key_child_index( const address& parent_account_address ); + private_key_type get_private_key( const fc::sha512& password, int index ); - private_key_type new_private_key( const fc::sha512& password, - const address& parent_account_address = address(), - bool store_key = true ); + private_key_type new_private_key( const fc::sha512& password, + const address& parent_account_address = address(), + bool store_key = true ); void set_property( property_enum property_id, const fc::variant& v ); fc::variant get_property( property_enum property_id )const; diff --git a/libraries/wallet/include/bts/wallet/wallet_records.hpp b/libraries/wallet/include/bts/wallet/wallet_records.hpp index d70b9d25a..87cd5da4c 100644 --- a/libraries/wallet/include/bts/wallet/wallet_records.hpp +++ b/libraries/wallet/include/bts/wallet/wallet_records.hpp @@ -96,7 +96,7 @@ namespace bts { namespace wallet { int8_t approved = 0; bool is_favorite = false; bool block_production_enabled = false; - uint32_t last_used_gen_sequence = 10000; + uint32_t last_used_gen_sequence = 10000; }; template @@ -167,6 +167,85 @@ namespace bts { namespace wallet { vector
extra_addresses; }; + // don't use -- work in progress + /* + * Example ledger entries + * +claim genesis + addr1 -> payee | amount + addr2 -> payee | amount + … + +register account + payer -> NETWORK | fee + +update account + payer -> NETWORK | fee + +create asset + payer -> NETWORK | fee + +update asset + payer -> NETWORK | fee + +issue asset + payer -> NETWORK | fee + NETWORK -> payee | amount + +create order + payer -> NETWORK | fee + payer -> ORDER | amount + +cancel order ??? + ORDER -> NETWORK | fee + ORDER -> payee | amount + +withdraw_pay + INCOME-name -> NETWORK | fee + INCOME-name -> payee + +publish_price/feed + INCOME-name -> NETWORK | fee + +normal transfer + payer -> NETWORK | fee + payer -> payee | amount + NETWORK -> payer | yield + +burn + payer -> NETWORK | fee + payer -> NOBODY | amount + * + */ + struct transaction_ledger_entry + { + transaction_id_type id; + uint32_t block_num = -1; + time_point_sec timestamp; + + struct line_item + { + // string (or public key?) + // possible entities: + // { name, INCOME-name, GENESIS, {ASK,BID,SHORT,COVER}-id, NETWORK, ANONYMOUS, UNKNOWN } + string payer; + string payee; + //fix labels on account rename -- rare operation + + asset amount; + + string description; + }; + vector line_items; + + optional transaction_id; + + //variant user_data; + + bool is_confirmed()const { return block_num != -1; } + bool is_virtual()const { return !transaction_id.valid(); } + }; + #if 0 struct market_order_status { @@ -194,12 +273,14 @@ namespace bts { namespace wallet { }; /** cached blockchain data */ + // TODO: Only cache balance ids typedef wallet_record< bts::blockchain::balance_record, balance_record_type > wallet_balance_record; /** records unique to the wallet */ typedef wallet_record< transaction_data, transaction_record_type > wallet_transaction_record; typedef wallet_record< master_key, master_key_record_type > wallet_master_key_record; typedef wallet_record< key_data, key_record_type > wallet_key_record; + // TODO: Do not derive from blockchain account record typedef wallet_record< account, account_record_type > wallet_account_record; typedef wallet_record< wallet_property, property_record_type > wallet_property_record; //typedef wallet_record< market_order_status, market_order_record_type> wallet_market_order_status_record; @@ -216,6 +297,22 @@ namespace bts { namespace wallet { } } // bts::wallet +FC_REFLECT_ENUM( bts::wallet::wallet_record_type_enum, + (master_key_record_type) + (account_record_type) + (key_record_type) + (transaction_record_type) + (balance_record_type) + (property_record_type) + (market_order_record_type) + (setting_record_type) + ) + +FC_REFLECT( bts::wallet::generic_wallet_record, + (type) + (data) + ) + FC_REFLECT_ENUM( bts::wallet::property_enum, (version) (next_record_number) @@ -227,49 +324,78 @@ FC_REFLECT_ENUM( bts::wallet::property_enum, (transaction_expiration_sec) ) -FC_REFLECT_ENUM( bts::wallet::wallet_record_type_enum, - (master_key_record_type) - (account_record_type) - (key_record_type) - (transaction_record_type) - (balance_record_type) - (property_record_type) - (market_order_record_type) - (setting_record_type) - ) - -FC_REFLECT( bts::wallet::wallet_property, (key)(value) ) -FC_REFLECT( bts::wallet::generic_wallet_record, (type)(data) ) -FC_REFLECT( bts::wallet::master_key, (encrypted_key)(checksum) ) -FC_REFLECT( bts::wallet::key_data, (account_address)(public_key)(encrypted_private_key)(memo)(gen_seq_number) ) - -FC_REFLECT( bts::wallet::ledger_entry, (from_account)(to_account)(amount)(memo)(memo_from_account) ); -FC_REFLECT( bts::wallet::transaction_data, - (record_id) - (block_num) - (is_virtual) - (is_confirmed) - (is_market) - (trx) - (ledger_entries) - (fee) - (created_time) - (received_time) - (extra_addresses) - ) +FC_REFLECT( bts::wallet::wallet_property, + (key) + (value) + ) FC_REFLECT_DERIVED( bts::wallet::account, (bts::blockchain::account_record), - (account_address) - (private_data) - (is_my_account) - (approved) - (is_favorite) - (block_production_enabled) - (last_used_gen_sequence) - ) + (account_address) + (private_data) + (is_my_account) + (approved) + (is_favorite) + (block_production_enabled) + (last_used_gen_sequence) + ) + +FC_REFLECT( bts::wallet::master_key, + (encrypted_key) + (checksum) + ) + +FC_REFLECT( bts::wallet::key_data, + (account_address) + (public_key) + (encrypted_private_key) + (valid_from_signature) + (memo) + (gen_seq_number) + ) + +FC_REFLECT( bts::wallet::ledger_entry, + (from_account) + (to_account) + (amount) + (memo) + (memo_from_account) + ) + +FC_REFLECT( bts::wallet::transaction_data, + (record_id) + (block_num) + (is_virtual) + (is_confirmed) + (is_market) + (trx) + (ledger_entries) + (fee) + (created_time) + (received_time) + (extra_addresses) + ) //FC_REFLECT( bts::wallet::market_order_status, (order)(proceeds)(transactions) ) -FC_REFLECT( bts::wallet::setting, (name)(value) ) + +FC_REFLECT( bts::wallet::setting, + (name) + (value) + ) + +// do not use -- see above +FC_REFLECT( bts::wallet::transaction_ledger_entry, + (id) + (block_num) + (timestamp) + (line_items) + (transaction_id) + ) +FC_REFLECT( bts::wallet::transaction_ledger_entry::line_item, + (payer) + (payee) + (amount) + (description) + ) /** * Implement generic reflection for wallet record types diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 10af26ded..0c165027d 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -115,6 +115,15 @@ namespace bts { namespace wallet { bool overwrite_existing = false ); + void scan_transaction_new( + const signed_transaction& transaction, + uint32_t block_num, + const time_point_sec& block_timestamp, + const vector& keys, + const time_point_sec& received_time, + bool overwrite_existing = false + ); + bool scan_withdraw( const withdraw_operation& op, wallet_transaction_record& trx_rec, asset& total_fee, public_key_type& from_pub_key ); bool scan_withdraw_pay( const withdraw_pay_operation& op, wallet_transaction_record& trx_rec, asset& total_fee ); @@ -570,6 +579,194 @@ namespace bts { namespace wallet { scan_market_transaction( market_trx, block_num, block.timestamp, received_time ); } + void wallet_impl::scan_transaction_new( + const signed_transaction& transaction, + uint32_t block_num, + const time_point_sec& block_timestamp, + const vector& keys, + const time_point_sec& received_time, + bool overwrite_existing ) + { try { + // go thru all ops to decide if this trx is relevant to me + // and classify trx based on ops + // fill out transaction ledger entry as classified above + + const auto id = transaction.id(); + + //auto transaction_record = _wallet_db.lookup_transaction( record_id ); + + //const auto already_exists = transaction_record.valid(); + //if( !already_exists ) + //{ + transaction_ledger_entry record; + record.id = id; + record.block_num = block_num; + record.timestamp = block_timestamp; // really min of existing + record.transaction_id = id; + + const otransaction_record blockchain_record = _blockchain->get_transaction( id, true ); + FC_ASSERT( blockchain_record.valid() ); + + // TODO: this should be passed in from the outermost call + const account_balance_id_summary_type balance_ids = self->get_account_balance_ids( "" ); + map id_map; + for( const auto& item : balance_ids ) + { + for( const auto& id : item.second ) + id_map[ id ] = item.first; + } + string payer; + + // TODO: we only support single "payer" account transactions + for( const auto& generic_op : transaction.operations ) + { + switch( operation_type_enum( generic_op.type ) ) + { + case withdraw_op_type: + { + const auto op = generic_op.as(); + payer = id_map[ op.balance_id ]; + break; + } + default: + break; + } + } + + for( const auto& generic_op : transaction.operations ) + { + switch( operation_type_enum( generic_op.type ) ) + { + case withdraw_op_type: + { + break; + } + case deposit_op_type: + { + break; + } + case register_account_op_type: + { + const auto op = generic_op.as(); + + transaction_ledger_entry::line_item line; + // line payer should be whoever did the withdraw + line.payer = payer; + line.payee = "NETWORK"; + // TODO: fix this hardcode + line.amount = asset( blockchain_record->balance.at( asset_id_type( 0 ) ) ); + line.description = "register account: " + op.name; + record.line_items.push_back( line ); + break; + } + case update_account_op_type: + { + break; + } + case withdraw_pay_op_type: + { + break; + } + case create_asset_op_type: + { + break; + } + case update_asset_op_type: + { + break; + } + case issue_asset_op_type: + { + break; + } + case bid_op_type: + { + break; + } + case ask_op_type: + { + const auto op = generic_op.as(); + if( op.amount >= 0 ) // create new ask + { + { + transaction_ledger_entry::line_item line; + // line payer should be whoever did the withdraw + line.payer = payer; + line.payee = "NETWORK"; + // TODO: fix this hardcode + line.amount = asset( blockchain_record->balance.at( asset_id_type( 0 ) ) ); + line.description = "pay fee"; + record.line_items.push_back( line ); + } + { + transaction_ledger_entry::line_item line; + // line payer should be whoever did the withdraw + line.payer = payer; + line.payee = "ASK-..."; + // TODO: fix this hardcode + line.amount = asset( op.amount ); + line.description = "create ask blah blah"; + record.line_items.push_back( line ); + } + } + else // cancel ask + { + { + transaction_ledger_entry::line_item line; + // line payer should be whoever did the withdraw + line.payer = "ASK-..."; + line.payee = "NETWORK"; + // TODO: fix this hardcode + line.amount = asset( blockchain_record->balance.at( asset_id_type( 0 ) ) ); + line.description = "pay fee"; + record.line_items.push_back( line ); + } + { + transaction_ledger_entry::line_item line; + // line payer should be whoever did the withdraw + line.payer = "ASK-..."; + //line.payee = payer; // my account as dest of deposit op + // TODO: fix this hardcode + line.amount = asset( op.amount ); // TODO fix this + line.description = "cancel ask blah blah"; + record.line_items.push_back( line ); + } + } + break; + } + case short_op_type: + { + break; + } + case cover_op_type: + { + break; + } + case define_delegate_slate_op_type: + { + break; + } + case update_feed_op_type: + { + break; + } + case burn_op_type: + { + break; + } + case link_account_op_type: + { + break; + } + default: + break; + } + } + + ulog( "${rec}", ("rec",record) ); + + } FC_RETHROW_EXCEPTIONS( warn, "" ) } + wallet_transaction_record wallet_impl::scan_transaction( const signed_transaction& transaction, uint32_t block_num, @@ -578,6 +775,9 @@ namespace bts { namespace wallet { const time_point_sec& received_time, bool overwrite_existing ) { try { + + //scan_transaction_new( transaction, block_num, block_timestamp, keys, received_time, overwrite_existing ); + const auto record_id = transaction.id(); auto transaction_record = _wallet_db.lookup_transaction( record_id ); const auto already_exists = transaction_record.valid(); diff --git a/libraries/wallet/wallet_db.cpp b/libraries/wallet/wallet_db.cpp index 3e84e1226..54fa6e8b3 100644 --- a/libraries/wallet/wallet_db.cpp +++ b/libraries/wallet/wallet_db.cpp @@ -380,7 +380,6 @@ namespace bts { namespace wallet { { // FC_ASSERT(oacct.valid(), "expecting an account to existing at this point"); oacct->is_my_account = true; - store_record( *oacct ); cache_account( *oacct ); /* ilog( "WALLET: storing private key for ${key} under account '${account_name}' address: (${account})", @@ -461,7 +460,7 @@ namespace bts { namespace wallet { FC_ASSERT( fc::exists( filename ) ); FC_ASSERT( is_open() ); - auto records = fc::json::from_file< std::vector >( filename ); + auto records = fc::json::from_file>( filename ); for( const auto& record : records ) store_generic_record( record ); } FC_RETHROW_EXCEPTIONS( warn, "", ("filename",filename) ) } diff --git a/programs/qt_wallet b/programs/qt_wallet index ee68635a2..00162608e 160000 --- a/programs/qt_wallet +++ b/programs/qt_wallet @@ -1 +1 @@ -Subproject commit ee68635a2cd0f5c53b25ad9aabc983629730de7b +Subproject commit 00162608e6e32488f83990a2b2776e5fa415c41e diff --git a/programs/web_wallet b/programs/web_wallet index 9f2179dab..1fa72667b 160000 --- a/programs/web_wallet +++ b/programs/web_wallet @@ -1 +1 @@ -Subproject commit 9f2179dabaf247dadd503956246b77cbdd104e6b +Subproject commit 1fa72667b24011d6c52ac53555bb3aa969ca1a98 From e3298fe7ed1f5f486ae253e048198dd1fdf05ef4 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Wed, 24 Sep 2014 18:29:01 -0400 Subject: [PATCH 18/20] Apply pending changes after canceling all shorts --- libraries/blockchain/market_engine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/blockchain/market_engine.cpp b/libraries/blockchain/market_engine.cpp index f6643f456..57d1eb115 100644 --- a/libraries/blockchain/market_engine.cpp +++ b/libraries/blockchain/market_engine.cpp @@ -28,6 +28,8 @@ class market_engine cancel_current_short( mtrx, market_idx.order_price.quote_asset_id ); push_market_transaction( mtrx ); } + + _pending_state->apply_changes(); } void execute( asset_id_type quote_id, asset_id_type base_id, const fc::time_point_sec& timestamp ) From 268a00839f8920acd891e7ab1d23b6674ce8accb Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Wed, 24 Sep 2014 18:30:34 -0400 Subject: [PATCH 19/20] Add missing hardfork check to short eval --- libraries/blockchain/market_operations.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/blockchain/market_operations.cpp b/libraries/blockchain/market_operations.cpp index b12bc24dc..5719ec7c8 100644 --- a/libraries/blockchain/market_operations.cpp +++ b/libraries/blockchain/market_operations.cpp @@ -143,7 +143,11 @@ namespace bts { namespace blockchain { auto asset_to_short = eval_state._current_state->get_asset_record( short_index.order_price.quote_asset_id ); FC_ASSERT( asset_to_short.valid() ); FC_ASSERT( asset_to_short->is_market_issued(), "${symbol} is not a market issued asset", ("symbol",asset_to_short->symbol) ); - FC_ASSERT( !this->short_price_limit || *(this->short_price_limit) >= this->short_index.order_price, "Insufficient collateral at price limit" ); + + if( eval_state._current_state->get_head_block_num() >= BTSX_MARKET_FORK_8_BLOCK_NUM ) + { + FC_ASSERT( !this->short_price_limit || *(this->short_price_limit) >= this->short_index.order_price, "Insufficient collateral at price limit" ); + } auto current_short = eval_state._current_state->get_short_record( this->short_index ); //if( current_short ) wdump( (current_short) ); From bebfa23765df2bb3f3c682e856d7ed7111ff4783 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Wed, 24 Sep 2014 18:42:24 -0400 Subject: [PATCH 20/20] 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 1b648c4a0..1be650fc2 160000 --- a/programs/qt_wallet +++ b/programs/qt_wallet @@ -1 +1 @@ -Subproject commit 1b648c4a014144993b6f4870e9db3d7a27f0e601 +Subproject commit 1be650fc2d0d476b4712978f1268fcd72d51d235 diff --git a/programs/web_wallet b/programs/web_wallet index 127c30199..59ee488c7 160000 --- a/programs/web_wallet +++ b/programs/web_wallet @@ -1 +1 @@ -Subproject commit 127c30199ea137f389dfb092dbeaedb1983bd8eb +Subproject commit 59ee488c7602f4ac71cc1a5b1ce2b75337515cec