Skip to content

Improve deanonymization functionalities wasm#42

Merged
andreanistico merged 9 commits intodevfrom
HZN-2753/improve-deanonymization-functionalities-wasm
Mar 13, 2026
Merged

Improve deanonymization functionalities wasm#42
andreanistico merged 9 commits intodevfrom
HZN-2753/improve-deanonymization-functionalities-wasm

Conversation

@andreanistico
Copy link
Copy Markdown
Contributor

@andreanistico andreanistico commented Mar 4, 2026

…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
@andreanistico andreanistico requested review from alsala and saratnt March 9, 2026 09:29
Nonce: currentState.Nonce,
})
case "tx_history":
if instructions.Deanonymize == nil || instructions.Deanonymize.Address.IsZero() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instructions.Deanonymize == nil can be removed, reportType can be "tx_history" only if instructions.Deanonymize != nil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

From: from,
To: to,
Amount: amount,
Nonce: state.Nonce,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to have a timestamp or a way to retrieve a timestamp from the Nonce

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Copy Markdown
Contributor

@paolocappelletti paolocappelletti Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok seems reasonable.
let's add a max size constant @andreanistico (50?) and keep always the more recents

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a MaxTransactions constant and trim the state to that length, keeping the most recent

}
}
reportBytes, err = json.Marshal(TxHistoryReport{
Address: instructions.Deanonymize.Address,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added the balance in the report and the filter using the timestamps

@andreanistico andreanistico requested review from alsala and saratnt March 10, 2026 13:13
if tx.From != addr && tx.To != addr {
continue
}
if fromTs > 0 && tx.Timestamp < fromTs {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@andreanistico andreanistico requested a review from saratnt March 11, 2026 14:27
@andreanistico andreanistico merged commit 661c3b2 into dev Mar 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants