scrtlabs / Grants

Repository for grant proposal submissions
41 stars 22 forks source link

Delayed Write Buffers, WebSocket Multiplexer, Secret HEAPS, & SNIP-250 #148

Open blake-regalia opened 7 months ago

blake-regalia commented 7 months ago

Summary

Privacy Hardening and Network Scaling on Secret by Blake Regalia and Ben Adams, Solar Republic LLC

This is an R&D proposal seeking to address and overcome specific challenges facing the network related to storage access patterns, metadata leakage, and scalability.

Delayed Write Buffers is a novel approach to solving storage access patterns for Secret tokens. The solution is done entirely within the contract, i.e., without any changes to the network, without off-chain computation, and without the need for client intelligence. It is both cheaper and more effective than decoys, maintains compatibility with existing interfaces, and allows existing tokens to adopt through contract upgrade.

Creating a Tendermint events multiplexer service would allow wallets and frontends to immediately reduce the loads being put on Secret query nodes, which by default are limited to 100 simultaneous clients, with a maximum of 5 subscriptions per client. Additionally, apps that start leveraging SNIP-52 notifications (instead of polling contracts with queries every 6 seconds in anticipation of an event or action) will not only benefit their end-users through a more responsive experience, but will also substantially improve the availability and resource utilization of query nodes.

Secret H.E.A.P.S. (Fully Homomorphically-Encrypted & Authenticated Private Storage) is an L2 storage mechanism hosted outside the enclave for Secret contracts that serves clients in a way that is private, unidirectional, authenticated, and oblivious. Secret HEAPS reduces loads on query nodes by allowing private data to be accessed without the use of smart queries. However, the primary benefit of using HEAPS comes from its performance. Instead of waiting between 8 to 30 seconds retrieving up to 20 token different balances as is the case now, dozens of simultaneous HEAPS queries would only take on the order of milliseconds.

Proposal Objectives

  1. Publish a blog post and/or docs.scrt.network technical article detailing Delayed Write Buffers
  2. Add a SNIP-52 notification library to Secret Toolkit
  3. Develop and deploy WebSocket multiplexer for Tendermint events capable of rewind, search, and filter
  4. Develop and deploy prototype of Secret HEAPS node
  5. Develop the SNIP-250 reference implementation to supersede the SNIP-2x token implementation, consisting of delayed write buffers + SNIP-50 gas evaporation + SNIP-52 private notifications for tokens spent/received and allowances granted/received + the contract-side of Secret HEAPS

Funding & Milestones

  1. Delayed Write Buffers docs & sample impl - $10k
    • $5k initial, $5k upon delivery
  2. Adding SNIP-52 to Secret Toolkit - Pro bono
  3. Tendermint event WebSocket multiplexer - $6k
    • $2k initial, $2k upon delivery, $2k upon deployment in cloud and use in StarShell
  4. Secret HEAPS node software impl - $8k
    • $2k initial, $3k upon delivery, $3k upon deployment and use serving at least 500 queries per day
  5. SNIP-250 spec & ref impl - $10k
    • $2k initial, $4k upon delivery, $4k upon mainnet deployment

Team

The core StarShell developers: