wownero / meta

archived repo, migrated to git.wownero.com
https://git.wownero.com/wownero/meta
1 stars 2 forks source link

Rebase Wownero to Monero master #17

Closed ghost closed 5 years ago

ghost commented 6 years ago

I've started to rebase on top of Monero Merge pull request #4927, however there are a few issues to sort out.

  1. Transition to new bulletproofs - Wownero adopted an older version of bulletproofs before the audit. There are substantial changes upstream. To switch over to the new version, we could deactivate the old bulletproofs in hard fork v11 and after a couple days, fork to v12 to activate new bulletproofs with fee per byte and then fork the next day to v13 to forbid borromean range proofs. Italo BP patched applied, requires review and further testing.

2. Generation of genesis block - When bootstrapping from 0, the rebased version prompts the following error:

3. Attempting to get cumulative difficulty - When starting rebased version from 0 ~~with a synced database, the following error is thrown:~~

4. Migrating blockchain - In addition, there is this error:

  1. Error::get_output_distribution - fix sanity check rct output distribution

6. Inaccurate network stats - node does not display correct net hash and difficulty with commands status and diff

7. Error::not_enough_money - error is thrown from new wallet with recently received txs. Error does not come up from wallet restored from seed.

stoffu commented 6 years ago

For point 1, it'll probably be quite a bit of work requiring a lot of care since the rebased version needs to verify both the old and the new BP types, whereas the upstream simply eliminated the old type, as it was only used in the testnet which was completely rolled back. Specifically, as in the upstream PR https://github.com/monero-project/monero/pull/4219, the old types RCTTypeFullBulletproof and RCTTypeSimpleBulletproof have been dropped and replaced by RCTTypeBulletproof, but Wownero will need to keep RCTTypeFullBulletproof and RCTTypeSimpleBulletproof in the code and adapt the verification rules in blockchain.cpp such that the old and the new types are correctly handled depending on the block height.

This is of course doable technically, and I don't know exactly how tricky/easy the task will be. Just my two cents.

For points 2 & 3, I've seen one person reporting a similar issue when I was working on rebasing Aeon (https://www.reddit.com/r/Aeon/comments/7xdr56/stoffu_rebase_testing/du995wh), but I couldn't figure out the cause because that person stopped replying.

For point 4, the issue seems easier to fix by looking down the call chain. If the rebase point is a while back, the issue might be due to a wrong fix I've sent to Monero, see https://github.com/monero-project/monero/pull/4635. EDIT: Yes, this seems to be the case.

ghost commented 6 years ago

Applied the patches from https://github.com/italocoin-project/italo/commit/6cebd0004534128344aebe50087d228ae685e109 and https://github.com/italocoin-project/italo/commit/1bc8afec2550c438cfdfb299e173d7b6472fa4f0 to rebase.

When bootstrapping a node from scratch, there is still a MDB_NOTFOUND: No matching key/data error in generating genesis block in addition these errors:

2018-12-05 15:09:31.671 [P2P0]  WARNING blockchain.db.lmdb  src/blockchain_db/lmdb/db_lmdb.cpp:73   Attempt to get cumulative difficulty from height 18446744073709551615 failed -- difficulty not in db

2018-12-05 15:10:37.320 [P2P4]  WARNING blockchain.db.lmdb  src/blockchain_db/lmdb/db_lmdb.cpp:73   Attempt to get timestamp from height 18446744073709551556 failed -- timestamp not in db

When starting node from a populated database, blockchain migration from DB version 1 to 3 is completed successfully and node syncs to network. However, usable is negative error periodically comes up.

Sending old and new BP transactions to network hasn't been tested yet.

ghost commented 6 years ago

Attempted to make a transfer, but got following error message:

2018-12-05 19:44:57.505     7fceace8abc0    DEBUG   wallet.wallet2  src/wallet/wallet2.cpp:7535 selected transfers: 9
2018-12-05 19:44:57.505     7fceace8abc0    DEBUG   wallet.wallet2  src/wallet/wallet2.cpp:7543 transfer: adding 10.00000000000, for a total of 10.01979070000
2018-12-05 19:44:57.505     7fceace8abc0    DEBUG   wallet.wallet2  src/wallet/wallet2.cpp:7609 wanted 10.01979070000, found 84.60079596000, fee 0.01979070000
2018-12-05 19:44:57.505     7fceace8abc0    DEBUG   wallet.wallet2  src/wallet/wallet2.cpp:6744 fake_outputs_count: 21
2018-12-05 19:44:57.591     7fceace8abc0    DEBUG   wallet.wallet2  src/wallet/wallet2.cpp:2862 Daemon is recent enough, requesting rct distribution
2018-12-05 19:44:57.678     7fceace8abc0    ERROR   wallet.wallet2  src/wallet/wallet2.cpp:6780 rct_offsets.back() <= max_rct_index. THROW EXCEPTION: error::get_output_distribution
2018-12-05 19:44:57.678     7fceace8abc0    WARNING net.http    src/wallet/wallet_errors.h:823  /src/wallet/wallet2.cpp:6780:N5tools5error23get_output_distributionE: failed to get output distribution, request = Daemon reports suspicious number of rct outputs
2018-12-05 19:44:57.678     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:133  Exception: tools::error::get_output_distribution
2018-12-05 19:44:57.678     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:134  Unwound call stack:
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [1]  0x11c) [0x5556b3602eb9]:__cxa_throw+0x11c) [0x5556b3602eb9]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [2]  0x192) [0x5556b37ea062]:_ZN5tools5error15throw_wallet_exINS0_23get_output_distributionEJA48_cEEEvONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEDpRKT0_+0x192) [0x5556b37ea062]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [3]  0xac5) [0x5556b37807b5]:_ZN5tools7wallet28get_outsERSt6vectorIS1_ISt5tupleIJmN6crypto10public_keyEN3rct3keyEEESaIS7_EESaIS9_EERKS1_ImSaImEEm+0xac5) [0x5556b37807b5]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [4]  0x263f) [0x5556b378a97f]:_ZN5tools7wallet221transfer_selected_rctESt6vectorIN10cryptonote20tx_destination_entryESaIS3_EERKS1_ImSaImEEmRS1_IS1_ISt5tupleIJmN6crypto10public_keyEN3rct3keyEEESaISF_EESaISH_EEmmRKS1_IhSaIhEERNS2_11transactionERNS0_10pending_txENSD_14RangeProofTypeE+0x263f) [0x5556b378a97f]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [5]  0x3b33) [0x5556b3791ab3]:_ZN5tools7wallet221create_transactions_2ESt6vectorIN10cryptonote20tx_destination_entryESaIS3_EEmmjRKS1_IhSaIhEEjSt3setIjSt4lessIjESaIjEE+0x3b33) [0x5556b3791ab3]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [6]  0x21fe) [0x5556b3672e6e]:_ZN10cryptonote13simple_wallet13transfer_mainEiRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE+0x21fe) [0x5556b3672e6e]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [7]  0x29e) [0x5556b36b7b7e]:_ZN4epee15command_handler19process_command_strERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x29e) [0x5556b36b7b7e]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [8]  0x4cc) [0x5556b36a2e2c]:_ZN4epee21async_console_handler3runIZNS0_3runIN5boost3_bi6bind_tIbNS3_4_mfi3mf1IbNS_15command_handlerERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEENS4_5list2INS4_5valueIPNS_23console_handlers_binderEEENS3_3argILi1EEEEEEEEEbT_St8functionIFSE_vEESG_SS_IFvvEEEUlSG_E_EEbSU_SG_RKSR_SW_+0x4cc) [0x5556b36a2e2c]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [9]  0x449) [0x5556b365ccf9]:_ZN10cryptonote13simple_wallet3runEv+0x449) [0x5556b365ccf9]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [10] ./wownero-wallet-cli(main+0x678) [0x5556b3622008] 
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [11]  0xf3) [0x7fceaf5f6223]:__libc_start_main+0xf3) [0x7fceaf5f6223]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172      [12]  0x2e) [0x5556b362e06e]:_start+0x2e) [0x5556b362e06e]
2018-12-05 19:44:57.688     7fceace8abc0    INFO    stacktrace  src/common/stack_trace.cpp:172  
2018-12-05 19:44:57.689     7fceace8abc0    ERROR   wallet.simplewallet src/simplewallet/simplewallet.cpp:401   RPC error: src/wallet/wallet2.cpp:6780:N5tools5error23get_output_distributionE: failed to get output distribution, request = Daemon reports suspicious number of rct outputs
2018-12-05 19:44:57.689     7fceace8abc0    ERROR   msgwriter   src/common/scoped_message_writer.h:102  Error: RPC error: failed to get output distribution

Edit Issue related to https://github.com/monero-project/monero/pull/4691/commits/7f0dd094e79d2b0bf536329475ff44adebe09233 I've temporarily commented out this commit and was able to send and receive txs.

ghost commented 5 years ago

Edit: fixed

I tried the rebase branch on wowario's fork. DB was successfully migrated, hashrate and diff were wrong, transfer failed with a different error:

2018-12-07 04:51:51.699     7f515d5fbbc0        ERROR   wallet.wallet2  src/wallet/wallet2.cpp:8504     needed_money + min_fee > balance_subtotal. THROW EXCEPTION: error::not_enough_money                        
2018-12-07 04:51:51.699     7f515d5fbbc0        WARNING net.http        src/wallet/wallet_errors.h:823  /build/wownero-f1fb848/src/wallet/wallet2.cpp:8504:N5tools5error16not_enough_moneyE: not enough money, available = 7.90781346000, tx_amount = 0.50000000000
2018-12-07 04:51:51.699     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:133  Exception: tools::error::not_enough_money                                                                  
2018-12-07 04:51:51.699     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:134  Unwound call stack:                                                                                        
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [1]  0x10d) [0x5619fcc2fefd]:__cxa_throw+0x10d) [0x5619fcc2fefd]                                       
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [2]  0x1e4) [0x5619fcb1cd64]:_ZN5tools5error15throw_wallet_exINS0_16not_enough_moneyEJmmiEEEvONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEDpRKT0_+0x1e4) [0x5619fcb1cd64]
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [3]  0x149f) [0x5619fcacbeef]:_ZN5tools7wallet221create_transactions_2ESt6vectorIN10cryptonote20tx_destination_entryESaIS3_EEmmjRKS1_IhSaIhEEjSt3setIjSt4lessIjESaIjEE+0x149f) [0x5619fcacbeef]
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [4]  0x1841) [0x5619fc9b0301]:_ZN10cryptonote13simple_wallet13transfer_mainEiRKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE+0x1841) [0x5619fc9b0301]
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [5]  0x302) [0x5619fca04192]:_ZN4epee15command_handler19process_command_strERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x302) [0x5619fca04192]
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [6]  0x4b8) [0x5619fc9d9e48]:_ZN4epee21async_console_handler3runIZNS0_3runIN5boost3_bi6bind_tIbNS3_4_mfi3mf1IbNS_15command_handlerERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEENS4_5list2INS4_5valueIPNS_23console_handlers_binderEEENS3_3argILi1EEEEEEEEEbT_St8functionIFSE_vEESG_SS_IFvvEEEUlSG_E_EEbSU_SG_RKSR_SW_+0x4b8) [0x5619fc9d9e48]
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [7]  0x490) [0x5619fc998790]:_ZN10cryptonote13simple_wallet3runEv+0x490) [0x5619fc998790]              
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [8] wownero-wallet-cli(main+0xa06) [0x5619fc959b56]                                                    
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [9]  0xee) [0x7f5159d85b8e]:__libc_start_main+0xee) [0x7f5159d85b8e]                                   
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172      [10]  0x2a) [0x5619fc9687ea]:_start+0x2a) [0x5619fc9687ea]                                             
2018-12-07 04:51:51.701     7f515d5fbbc0        INFO    stacktrace      src/common/stack_trace.cpp:172
2018-12-07 04:51:51.701     7f515d5fbbc0        WARNING wallet.simplewallet     src/simplewallet/simplewallet.cpp:420   not enough money to transfer, available only 7.90781346000, sent amount 0.50000000000      
2018-12-07 04:51:51.701     7f515d5fbbc0        ERROR   msgwriter       src/common/scoped_message_writer.h:102  Error: Not enough money in unlocked balance 
ghost commented 5 years ago

I did a trace on the wallet, it seems the fee is wrong:

src/wallet/wallet2.cpp:685    estimated bulletproof rct tx size for 1 inputs with ring size 22 and 2 outputs: 2574 (1504 saved) 
src/wallet/wallet2.cpp:8496   trace: fee_multiplier: 1                                                                                             
src/wallet/wallet2.cpp:8497   trace: base_fee: 659327000 
src/wallet/wallet2.cpp:8504   trace: needed_money:     100000000000
src/wallet/wallet2.cpp:8505   trace: min_fee:          1697110272000
src/wallet/wallet2.cpp:8506   trace: extimated_fee:    3296570000
src/wallet/wallet2.cpp:8506   trace: balance_subtotal: 790781346000

I compared with v0.4 and estimated_fee seems to be correct, so the min_fee is probably wrong for the old fee.

ghost commented 5 years ago

Edit: this should be fixed once 5 is fixed.

After disabling the fee check there's a new error:

src/wallet/wallet2.cpp:7054     Ignoring output 305957, too recent
src/wallet/wallet2.cpp:7058     !own_found. THROW EXCEPTION: error::wallet_internal_error
...
src/common/scoped_message_writer.h:102  Error: internal error: Known ring does not include the spent output: 305957

some more trace:

wallet.wallet2  src/wallet/wallet2.cpp:6994     20840 unlocked rct outputs                                                                                 
wallet.wallet2  src/wallet/wallet2.cpp:7019     Fake output makeup: 90 requested: 0 recent, 0 pre-fork, 0 post-fork, 90 full-chain                         
global  src/wallet/wallet2.cpp:7026     trace: rct_offsets.size: 4846                                                                                      
global  src/wallet/wallet2.cpp:7027     trace: num_outs: 20840
ghost commented 5 years ago

PR opened in Wownero's repo