keep-network / keep-core

The smart contracts and reference client behind the Keep network
https://keep.network
MIT License
118 stars 73 forks source link

Submit only t+1 valid signatures supporting DKG result in phase 14 #931

Open pdyraga opened 5 years ago

pdyraga commented 5 years ago

When submitting DKG result in phase 14, it is enough to submit t + 1 supporting signatures, assuming all those signatures were validated in the previous phase and they are all correct. This would allow us to reduce the cost of an on-chain validation.

t stands for threshold <=> minHonest/maxMalicious

lukasz-zimnoch commented 4 years ago

There are two possible solutions here:

  1. Off-chain: select only t signatures in phase 14 before submitting DKG result to the contract
  2. On-chain: select only t signatures after submitting DKG result to the contract (verifySignatures in KeepRandomBeaconOperator.sol)

I've done some tests in order to check the expected estimated gas cost reduction of both solutions. Average estimated gas costs of submitting DKG result are taken from 5 samples. I've assumed a gas price of 22 Gwei (according to ethgasstation) in order to calculate costs in dollar.

Group size: 5 | Threshold: 3

Group size: 50 | Threshold: 26

ngrinkevich commented 4 years ago

ok some initial findings: looks like the most expensive thing in DKG submission is actually sortition of submitted tickets, even with t signatures we still need to sort all the submitted tickets. I'm investigating whether it's cheaper to spread this cost across all members, i.e. re-sort tickets on every ticket submit + maybe allow submit tickets in batch