Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: switch to using merkle proofs to verify signing keys stored offchain #347

Closed
wants to merge 71 commits into from

Conversation

TomAFrench
Copy link

@TomAFrench TomAFrench commented May 19, 2021

This PR is a submission for the Open DeFI Hackathon project Off-Chain Storage & Management For Lido Validators' Keys
which aims to reduce the ETH transaction costs required for adding/using signing keys.

The general idea is that the public keys submitted by node operators are repeatedly hashed to calculate a merkle root which is then stored within the NodeOperator struct - reducing the storage usage to a single slot per node operator.

Each leaf of the tree is made up of a batch of 8 keys to minimise the number of merkle proofs to be verified later. These batches of signing keys are emitted as events which can be picked up within the subgraph (Or pulled out of the transaction data manually or even published in a less flashy web3 way).

The process that node operators have to follow is unchanged except they must provide a number of signing keys which neatly divides by 8 (to avoid half-filled leaves). All existing tooling can be used with this minor modification.

Keeper bots can pull the list of keys+sigs provided by each node operator, select which node operators are due to be chosen next (according to the existing rules on stake, etc.), choose unused leaves of the merkle trees and calculate merkle proofs. These can then be submitted to Lido.depositBufferedEther to be verified and then used to stake buffered ETH.

I've updated a number of the tests to make use of the new method of submitting. Most notably lido.test.js and node-operator-registry.test.js now use this new method of providing keys as a proof of concept. Feel free to reach out if you run into any issues testing this.

There's a fair bit of work remaining to get to a production ready state:

  • Complete migration of tests to support offchain keys
  • Add some missing view functions which are necessary for keeper bots (viewing which operators get keys next, verifying that a proof is valid, etc.)
  • The behaviour of Lido.depositBufferedEth should be modified as its implementation doesn't really account for depositing in batches nicely.
  • Add additional tests which are specific to using offchain keys.
  • Tooling to simply retrieve the keys + calculate merkle proofs for keeper bots to use.

closes #341

refactor: create functions to pad+concat an array of keys/sigs
feat: modify functions to invalidate keys to clear merkle root
The number of keys used by the operator at the time of a given batch's use is used as a nonce.
This condition is already enforced by checks on the number of keys available
@skozin skozin deleted the branch lidofinance:develop August 13, 2021 08:41
@skozin skozin closed this Aug 13, 2021
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.

2 participants