Here is how we can do the hash disribution:
Let's say we have a GIVBacks round with a total of N GIVBacks.
We can divide the round into multiple batches defined as:
- i (the order of the batch)
- address[] 1..k(i)
- amount[] 1..k(i)
Where k(i) is the size of the batch
This structure forms a tree with a depth of 1:
root
|_ (1,address[], amount[])
|_ (2,address[], amount[])
.
|_ (n,address[], amount[])
The root hash is calculated as:
h(root)=h(h(b1)|h(b2)|...|h(bn))
The hash of each batch is calculated as:
h(b(i))=h(i|address(i)[]|amount(i)[]
The relayer contract stores the root hash
of the tree.
The validator must know:
- The order number of the batch
- Batch data
address[]
amount[]
- Hashes of other batches
Execute function would provide:
execute(uint256 batchNo, address[] accounts, uint256[] amounts, bytes32[] batchRoots)
The execute function will:
- Check if the
batchNo
is executed - Compute the hash of the
batchNo
batch - Compute the root hash
- Check if the root hash is valid
- Set the
batchNo
as executed - Call the
sendGivbacks
function