dusk-network / wallet-core

The library responsible for the core functionality of a wallet
Mozilla Public License 2.0
6 stars 9 forks source link

Crossover is used too eagerly #73

Closed ureeves closed 1 year ago

ureeves commented 1 year ago

Describe the bug The crossover is set in unstake and withdraw but its value is set to zero. Since the crossover is not necessary in these transactions, they will be taken at the end and a zero-value note generated and added to the transfer contract tree.

These notes are technically worthless and serve no purpose but to fill up the tree and slow down any sync procedure.

https://github.com/dusk-network/wallet-core/blob/66bda1d29370b1d4e7292c77ecfd92ee005cf038/src/imp.rs#L601-L608

Expected behaviour The crossover should not be set in unstake and withdraw.

Additional context Technically this could also be solved in rusk by not generating a note on a zero value crossover. This is incorrect since the value may be obfuscated.

herr-seppia commented 1 year ago

Adding some example from a current ITN wallet

Full transaction history

  BLOCK   |                              TX_ID                               |  METHOD  |      AMOUNT       |     FEE     
    29872 | ffdaf964fd65330a618f33a90b1878235c96aa9375e36c5430c3999502217106 | transfer |  +35000.000000000 | 
    29927 | b866b0877e934aaa9990f8a16e2f0c5b7b915068c9b607840128bd3723c2d908 |  stake   |  -33001.172034837 |  1.360531321
    68159 | 0558f64bf6530e3c46cbd524a5fb4010b0b86d6f93cbbd7eb6680c976f4bb209 | transfer |   +1100.000000000 | 
   238856 | 564720a703296e99685a9c5a706321a678adb5996fd64ffd9185a5e125442f05 | unstake  |  +32998.453553766 |  1.794989406
   238859 | 0b2dc82bfae64c6251a90de60ccdb6452e8d601b2b7edaebab095dc856970b05 | withdraw |   +4861.339332859 |  1.816405973
Pos   5090 - Height  29872 - Val    35000000000000 - FromOutput  true - Spent EKO/OS9weXEAPcEtzbeXE8mW0hF9pHNy1X3DYDl0vSM=
Pos   5095 - Height  29927 - Val     1997100000000 - FromOutput  true - Spent RFTGbeREv/zhmE5flE5P/JyOQVQaPMd28YgeoNTVRmU=
Pos   5096 - Height  29927 - Val        1727965163 - FromOutput false - Spent k5R3WmOY/Yp+4VfoGb3xz94Hfz1vfOVyMDFGbDc9aG0=
Pos  10075 - Height  68159 - Val     1100000000000 - FromOutput  true - Spent dq4qkZlq9k/3i3P9pdkFqroF1o7BWgRqGvyYI1q3w2E=
Pos  20706 - Height 238856 - Val     3095927965163 - FromOutput  true - Spent j0XJesDL0en6BtIJb5VG4LgSDmidRzATA81yaWUCNTI=
Pos  20707 - Height 238856 - Val    33000000000000 - FromOutput false - Spent ccjLbKTJWMmCU0Z15NqKUaxcBw5UalMUvL1z6jkiuFY=
Pos  20708 - Height 238856 - Val        1353553766 - FromOutput false - Spent He9hF5PShR7vsrbHb0Y5OjtAItEtzjfvhIAme10wWFE=
Pos  20709 - Height 238856 - Val                 0 - FromOutput false - Spent x3Dil4PTwLP8UI1aw+fI58dLFqrSW62nBFLQOftxj0g=
Pos  20710 - Height 238859 - Val    36094381518929 - FromOutput  true - Spent 
Pos  20711 - Height 238859 - Val     4862907237320 - FromOutput false - Spent 
Pos  20712 - Height 238859 - Val        1332095539 - FromOutput false - Spent 
Pos  20713 - Height 238859 - Val                 0 - FromOutput false - Spent 

Below the drill down of the notes generated by those operation. As you can see, there is an additional note valued 0 that is generated by the execution (since it doesn't belong to the transaction outputs) alongside with the fee change and the unstake/withdraw note

Unstake

Pos  20706 - Height 238856 - Val     3095927965163 - FromOutput  true - Spent j0XJesDL0en6BtIJb5VG4LgSDmidRzATA81yaWUCNTI=
Pos  20707 - Height 238856 - Val    33000000000000 - FromOutput false - Spent ccjLbKTJWMmCU0Z15NqKUaxcBw5UalMUvL1z6jkiuFY=
Pos  20708 - Height 238856 - Val        1353553766 - FromOutput false - Spent He9hF5PShR7vsrbHb0Y5OjtAItEtzjfvhIAme10wWFE=
Pos  20709 - Height 238856 - Val                 0 - FromOutput false - Spent x3Dil4PTwLP8UI1aw+fI58dLFqrSW62nBFLQOftxj0g=

Withdraw

Pos  20710 - Height 238859 - Val    36094381518929 - FromOutput  true - Spent 
Pos  20711 - Height 238859 - Val     4862907237320 - FromOutput false - Spent 
Pos  20712 - Height 238859 - Val        1332095539 - FromOutput false - Spent 
Pos  20713 - Height 238859 - Val                 0 - FromOutput false - Spent 
Neotamandua commented 1 year ago

Issue became obsolete imo due to big changes.