How should we handle the Lockup Dynamic campaign's segments? #166
Replies: 6 comments 3 replies
-
General understandingIn theory we can store whatever we want in the Merkle Tree's leafs, so we can go for a hash of:
From my initial research, the frontend will have to
There's even a nice library from OZ to pre-verify this at frontend level. It accompanies the OZ Merkle Proof contract. Concrete answersNow, to address the points in the OP:
Well, it's a matter of file size mostly. The more data we fit into the raw claim list → the bigger the file → the heavier it gets to download it, parse it etc. Same for when we process it. I don't have numbers to back this up yet, but repeating the segments over and over again will definitely affect performance for lists > 1000 recipients (depending on how many segments there are). It is achievable nevertheless, but we can work on optimizing it.
Of course! I must explore this more thoroughly but we could optimize by:
I believe we should definitely prioritize Lockup Linear, but, I'd also love to bundle both when we being the audit. @PaulRBerg would love to hear your thoughts here. |
Beta Was this translation helpful? Give feedback.
-
Great catch @andreivladbrg and nice write-up. This finding makes me staunchly against continuing the integration of Lockup Dynamic into the first release of Airstreams. There is a risk of not being able to finish the project by the end of the year. I am suggesting a minimalistic and fallibilist approach:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for starting this discussion @andreivladbrg. I would like to share my perspective on the following concept:
I believe it might be improbable in practice for users to define a unique segment for each recipient. More commonly, users might prefer defining different sets of segments for different set of recipients, such as different vesting structures for LPs, shareholders, and employees. In such scenarios, users can create multiple Airstreams, each tailored to accommodate its unique set of segments for specific set of recipients. Having considered this, I align with @razgraf's proposition of storing a single set of segments globally with percentages of individual amounts. This can be an immutable variable and during the claiming process, we can convert percentages into amounts to construct Lockup Dynamic segment structure UpdateI now think storing different distribution segments wouldn't be overkill as well. We can introduce // segments is of the form {delta:86400, exponent:1, percentage:10}.
// Requirement sum(percentage) == 100
mapping(uint256 position => LockupDynamic.SegmentWithDelta[] segments) private allocationSegments;
.....
bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(index, recipient, amount, position)))); |
Beta Was this translation helpful? Give feedback.
-
If we implement LockupTranched instead of LockupDynamic, this whole issue becomes much easier to handle! |
Beta Was this translation helpful? Give feedback.
-
As I realized on the earlier call with @razgraf and @andreivladbrg, what I said above is a misconception. With LockupTranched, the "whole issue" does NOT become "much easier to handle". From the perspective of
I think the first approach wouldn't work because there would be rounding errors. But maybe I'm wrong - when we implement either LT or LD, we should perform some checks @andreivladbrg. |
Beta Was this translation helpful? Give feedback.
-
Can we close this, @andreivladbrg? |
Beta Was this translation helpful? Give feedback.
-
In one of our calls, the design decision regarding the Lockup Dynamic segments was to pass them into the constructor and hardcode them within the contract:
v2-periphery/src/SablierV2AirstreamCampaignLD.sol
Lines 27 to 29 in 5d55a7e
In practice, this won't work for winners with different airdrop amounts, because in the segment struct, we have an amount variable that, when summed up, it should be equal to the airdrop amount.
https://github.com/sablier-labs/v2-core/blob/456744002f62d0627f10b958d41937ed1e68d95e/src/libraries/Helpers.sol#L209-L213
One potential solution I've considered is including the segments (if not the all array of structs, we can include only the amounts) for each airdrop winner in the Merkle tree. However, I'm unsure how this might complicate the frontend and server-side aspects.
@razgraf, do you think this would be achievable?
What do you think? Are there other solutions we could explore?
Should we continue with the Lockup Dynamic campaign, or prioritize the release of the Lockup Linear campaign first?
Beta Was this translation helpful? Give feedback.
All reactions