Improve deanonymization functionalities wasm#42
Conversation
…ties-wasm v0.0.25 # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCgAdFiEEqaxwdbYv64XeN1Hi1lp9woOrPCMFAmmoRDUACgkQ1lp9woOr # PCMdUA/7B1nFct4JOBcgLfWiUCR6kWUpAnGi/z3YIrcF22NbaioGpBJx5IZWhzaY # UqRgCDP35UHxC2eTYDS0D0Ky46f1FafOJz3O2/UJWOASutQDnEWbMdgPitre5rgn # zMzn5Fch4EU+V2qE7lA/RvA6obW2FUkTWf8+agq7VR+sxloUWnLX2JtUmpQ38xFK # nfsH/Htc5RY16ALGsdl3sHExuvx5SJos/Y1hCYPZS0ae+9Vq1VyHKEwj6nMbDEce # WA2csCbhBrXzq6Ldj3PBvugweOAnmux4bf/7pybK4DwGFEOEsIg5LDE98MPbPzUv # 2JXCA/unOwnf6LEj3N8A4a/AT2O92rXZYwoeXC0J6BuXjl+Fe/QKagv3DqclbfJr # lT1tw9ghXg9a6MNVcFfuZtMvrhfaHQ/nV/WwxXTaJkhsmJ4P2VMejlnlkw8i++Fj # FW+31Hg8akxXyns5zYdYgjZ4j3ksyEYPWb12Z7sZvecsTy5mjPyETSIbk7Q46l15 # XSZCCIBFMyGaYFQ111u8yd7xnJnoBgUKleFsdrHNRxruoFW/mHE1A7o4RVGvPhIU # AxsD5JrLU2dAziczvoPkEMGxCLYt3x6Y/zwv+nOqtySM+nEceAACh8ndOfHiJ5sn # 9jXIb56jXCo0x3HReoHmEnKKURKIDJvizQQh/yZFt60toDW265U= # =CG6B # -----END PGP SIGNATURE----- # gpg: Signature made Wed Mar 4 15:39:49 2026 CET # gpg: using RSA key A9AC7075B62FEB85DE3751E2D65A7DC283AB3C23 # gpg: Can't check signature: No public key # Conflicts: # wallet/cmd/requestreport.go
runtime/wasm-go/app/app.go
Outdated
| Nonce: currentState.Nonce, | ||
| }) | ||
| case "tx_history": | ||
| if instructions.Deanonymize == nil || instructions.Deanonymize.Address.IsZero() { |
There was a problem hiding this comment.
instructions.Deanonymize == nil can be removed, reportType can be "tx_history" only if instructions.Deanonymize != nil
| From: from, | ||
| To: to, | ||
| Amount: amount, | ||
| Nonce: state.Nonce, |
There was a problem hiding this comment.
It would be useful to have a timestamp or a way to retrieve a timestamp from the Nonce
There was a problem hiding this comment.
i added a timestamp
| // recordTransaction appends a transaction record to the state's transaction log. | ||
| // Must be called after state.Nonce++ so the nonce matches the corresponding event. | ||
| func recordTransaction(state *ApplicationInternalState, txType string, from, to types.Address, amount *types.Uint256, invoiceID string) { | ||
| state.Transactions = append(state.Transactions, TransactionRecord{ |
There was a problem hiding this comment.
state.Transactions will grow indefinetely and it will be a problem to manage a state too big. We need or to put a cap on the number of transactions saved and discard the oldest ones or we need to implement in Vela a way to manage big states. @paolocappelletti what do you think?
There was a problem hiding this comment.
I would postpone to next impromevements.
Long term goal: the state should not be passed entirely to the wasm, but only accessed "on-request": the wasm interface should provide more low level primitives. es: a key-value access with methods get(key) set(key,value). then there will be a protocol for handling the call: executor -> encryption/decryption of the value -> manager -> db (commit only upon success of the request).
(This will allow also to charge fees for storage access/update as solidity does)
Will add some tickets in the backlog!
There was a problem hiding this comment.
I would add anyway a simple check that prevents that the list of transactions becomes too big, in the meantime we develop a better solution. Just to be on the safer side...
There was a problem hiding this comment.
ok seems reasonable.
let's add a max size constant @andreanistico (50?) and keep always the more recents
There was a problem hiding this comment.
I added a MaxTransactions constant and trim the state to that length, keeping the most recent
runtime/wasm-go/app/app.go
Outdated
| } | ||
| } | ||
| reportBytes, err = json.Marshal(TxHistoryReport{ | ||
| Address: instructions.Deanonymize.Address, |
There was a problem hiding this comment.
It would be nice to have also the current balance. In addition, in order to limit the loop looking for transactions, it would be nice to add a range, eg the txs between 2 nonces (better on a timestamp but there is no timestamp at the moment)
There was a problem hiding this comment.
i added the balance in the report and the filter using the timestamps
| if tx.From != addr && tx.To != addr { | ||
| continue | ||
| } | ||
| if fromTs > 0 && tx.Timestamp < fromTs { |
There was a problem hiding this comment.
Considering the way currentState.Transactions is implemented, the transactions should be ordered by timestamp, so the loop could be stopped the moment the transactions timestamps are outside the requested range
https://horizenlabs.atlassian.net/browse/HZN-2753
https://horizenlabs.atlassian.net/browse/HZN-2754