Basilisk-node icon indicating copy to clipboard operation
Basilisk-node copied to clipboard

feat: NFT Auctions

Open green-jay opened this issue 4 years ago • 5 comments

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.

green-jay avatar Sep 23 '21 14:09 green-jay

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.

github-actions[bot] avatar Feb 22 '22 14:02 github-actions[bot]

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.

codecov[bot] avatar Feb 22 '22 14:02 codecov[bot]

🐍 https://github.com/kodadot/nft-gallery/issues/2776

vikiival avatar Apr 06 '22 16:04 vikiival

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.

apopiak avatar Apr 29 '22 16:04 apopiak

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:

  1. StorageMap (one key-value entry per data point): fast random access (just mutate the correct key), slow iteration on close
  2. 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
  3. 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.

apopiak avatar May 10 '22 15:05 apopiak

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)

cl0w5 avatar Jan 15 '23 18:01 cl0w5