feat: NFT Auctions
Adds NFT auctions with 3 auction types: English, TopUp and Candle
Early tech specification: https://www.notion.so/Auctions-6227f3d237e44baf8980e83eae74dbb7 https://github.com/w3f/Grants-Program/blob/master/applications/subauction.md
This should be merged to master with a call filter. Weights and benchmarks to be updated at a later point.
Crate versions that have not been updated:
- primitives: v6.4.0
- basilisk-runtime: v88.0.0
- common-runtime: v2.3.3
- testing-basilisk-runtime: v88.0.0
New crates:
- pallet-auctions: v1.0.0
Runtime version has not been increased.
Codecov Report
Base: 84.07% // Head: 83.97% // Decreases project coverage by -0.10% :warning:
Coverage data is based on head (
aa99e93) compared to base (4c24095). Patch coverage: 90.96% of modified lines in pull request are covered.
:exclamation: Current head aa99e93 differs from pull request most recent head 38960f2. Consider uploading reports for the commit 38960f2 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #168 +/- ##
==========================================
- Coverage 84.07% 83.97% -0.11%
==========================================
Files 15 26 +11
Lines 1777 2695 +918
==========================================
+ Hits 1494 2263 +769
- Misses 283 432 +149
| Impacted Files | Coverage Δ | |
|---|---|---|
| pallets/auctions/src/traits.rs | 0.00% <0.00%> (ø) |
|
| primitives/src/lib.rs | 75.00% <ø> (+75.00%) |
:arrow_up: |
| pallets/auctions/src/types/candle.rs | 85.13% <85.13%> (ø) |
|
| pallets/auctions/src/lib.rs | 89.49% <89.49%> (ø) |
|
| pallets/auctions/src/types/topup.rs | 92.42% <92.42%> (ø) |
|
| pallets/auctions/src/types/english.rs | 92.85% <92.85%> (ø) |
|
| pallets/auctions/src/benchmarking.rs | 96.13% <96.13%> (ø) |
|
| pallets/auctions/src/mocked_objects.rs | 100.00% <100.00%> (ø) |
|
| pallets/lbp/src/lib.rs | 80.41% <0.00%> (-1.62%) |
:arrow_down: |
| ...ntegration-tests/parachain-runtime-mock/src/lib.rs | ||
| ... and 17 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
🐍 https://github.com/kodadot/nft-gallery/issues/2776
On benchmarking: If you want to keep the current API surface/design I would write 3 benchmarks for each extrinsic and then pick the maximum at dispatch and refund according to the actual auction at the end (of the extrinsic execution). If you keep something like the current design for the individual auctions my sense is that the candle auction will be quite a bit more expensive because of the extra reads and writes.
About optimizing the candle auction extrinsic weight: You basically can trade-off between random access weight versus iteration weight. You get a trade-off dimension that consists of:
- StorageMap (one key-value entry per data point): fast random access (just mutate the correct key), slow iteration on close
- chunked StorageMap (putting the data into fewer bins than a naive storage map): can choose the trade-off between fast random access and fast iteration, but higher implementation complexity
- StorageValue (put all values into one storage value): slower random access (the more values there are), but fast iteration speed
In terms of the chunked map and the StorageValue you can choose between a Vec or a BTreeMap.
Closing this PR in favor of https://github.com/galacticcouncil/Basilisk-node/pull/592
The new PR has isolated English auction and resolved all applicable comments in this PR.
TopUp and Candle auctions are left for a future implementation. Here is a summary of the most important TODOs for the future from this PR:
- Use stronger randomness than randomness_collective_flip for determining candle auction winner (https://github.com/galacticcouncil/Basilisk-node/pull/168/files#r861909731)
- Optimize reads when determining winning range for candle auction (https://github.com/galacticcouncil/Basilisk-node/pull/168#pullrequestreview-957898672)
- Optimize cleaning stored winners by range for candle auction (https://github.com/galacticcouncil/Basilisk-node/pull/168#discussion_r861943603)
- Clean up ReservedAmounts map when closing a TopUp auction which has been won (https://app.clickup.com/t/2np0jxq https://github.com/galacticcouncil/Basilisk-node/pull/168#discussion_r881554036)
- Check test error cases on bid (topup & candle)