tangle-network / relayer

🕸️ The Webb Relayer Network
https://webb-tools.github.io/relayer/
Apache License 2.0
22 stars 13 forks source link

[TASK] Return Cached Leaves as different format instead of Arrays #508

Closed shekohex closed 1 year ago

shekohex commented 1 year ago

Overview

Currently the relayer returns the cached leaves/encrypted outputs as a bytes array which is not optimal size-wise, for comparison:

// This just one leaf and the total size is 118 bytes
[0,96,124,186,197,202,118,215,202,188,115,135,221,48,154,82,56,200,222,123,134,81,222,24,29,150,89,62,147,193,111,174]
// the same exact leaf and the total size is 66 bytes.
"00607cbac5ca76d7cabc7387dd309a5238c8de7b8651de181d96593e93c16fae"
// Even to reduce the size further, we could reduce the size even more by using base64 (instead of hex base16)
// to just 46 bytes
"AGB8usXKdtfKvHOH3TCaUjjI3nuGUd4YHZZZPpPBb64="

Task Checklist

shekohex commented 1 year ago

cc @AtelyPham @Nutomic and @salman01zp here to share your opinions.

AtelyPham commented 1 year ago

cc @AtelyPham @Nutomic and @salman01zp here to share your opinions.

+1 vote for base64 string

salman01zp commented 1 year ago

I will say the relayer should compute and store the Merkle root after caching leaves and just send Merkle root to Dapp. We should have separate lightweight APIs for Dapp

shekohex commented 1 year ago

I will say the relayer should compute and store the Merkle root after caching leaves and just send Merkle root to Dapp. We should have separate lightweight APIs for Dapp

The dApp does not just need the merkle roots, it also needs the leaves, so that they create a proving path of their mempership. If the dApp only needs the merkle roots, it is already stored in the smart contract!

salman01zp commented 1 year ago

will it be better as Hex String, since Dapp uses hex values to compute operations? @AtelyPham