Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement benchmark and add weights for prediction market pallet #82

Merged
merged 46 commits into from Apr 29, 2021

Conversation

sea212
Copy link
Member

@sea212 sea212 commented Apr 19, 2021

Issue: #7
Solution: Implement benchmarks and add weights for every dispatchable function in the prediction market pallet.
Progress:

Benchmarks

  • admin_destroy_market
  • admin_move_market_to_closed
  • admin_move_market_to_resolved
  • approve_market
  • buy_complete_set
  • cancel_pending_market
  • create_categorical_market
  • create_scalar_market
  • deploy_swap_pool_for_market
  • dispute
  • global_dispute - function not implemented yet
  • on_initialize
  • redeem_shares
  • reject_market
  • report
  • sell_complete_set

Weights

  • admin_destroy_market
  • admin_move_market_to_closed
  • admin_move_market_to_resolved
  • approve_market
  • buy_complete_set
  • cancel_pending_market
  • create_categorical_market
  • create_scalar_market
  • deploy_swap_pool_for_market
  • dispute
  • global_dispute - function not implemented yet
  • on_initialize
  • redeem_shares
  • reject_market
  • report
  • sell_complete_set

This commit also fixed recently broken benchmark builds by adding new
dependencies to the runtime-benchmarks attribute in runtime crate.
It also updates serde to a more recent version.
This commit also changes the crate author to Zeitgeist PM
@sea212 sea212 changed the title [WIP] Implement benchmark and add weights for prediction market pallet Implement benchmark and add weights for prediction market pallet Apr 28, 2021
@sea212 sea212 marked this pull request as ready for review April 28, 2021 09:33
@sea212
Copy link
Member Author

sea212 commented Apr 28, 2021

I'll squash everything into 1 commit and rebase into main once it's approved

primitives/src/lib.rs Outdated Show resolved Hide resolved
sea212 and others added 3 commits April 28, 2021 13:42
easier to parse putting the amount first

Co-authored-by: Logan Saether <lsaether@protonmail.com>
Co-authored-by: Logan Saether <lsaether@protonmail.com>
fixed typos

Co-authored-by: Logan Saether <lsaether@protonmail.com>
Copy link
Contributor

@c410-f3r c410-f3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @sea212, thanks for the PR!
Taking aside the cargo test stuff, everything else looks good IMO.

zrml/prediction-markets/Cargo.toml Outdated Show resolved Hide resolved
Applies to prediction markets pallet and swaps pallet
@lsaether lsaether merged commit ff7a904 into main Apr 29, 2021
This was referenced Apr 29, 2021
@sea212 sea212 deleted the sea-benchmark-pm-weights branch April 29, 2021 15:12
c410-f3r pushed a commit to c410-f3r/zeitgeist that referenced this pull request Sep 14, 2021
…tgeistpm#82)

* Create benchmark scaffold for pallet prediction-markets

This commit also fixed recently broken benchmark builds by adding new
dependencies to the runtime-benchmarks attribute in runtime crate.
It also updates serde to a more recent version.

* Fix uncompilable benchmarks introduced in zeitgeistpm#76

This commit also changes the crate author to Zeitgeist PM

* Add benchmark: create_categorical_market

* Add weight: create_categorical_market

* Add benchmark: create_scalar_market

* Add weight: create_scalar_market

* Add benchmark: approve_market

* Add weight: approve_market

* Add benchmark: reject_market

* Add weight: reject_market

* Add benchmark: admin_destroy_market

* Add weight: admin_destroy_market

* Add benchmark: cancel_pending_market

* Add weight: cancel_pending_market

* Add benchmark: buy_complete_set

* Add weights & additional buy_complete_set benchmark

* Merge two buy_complete_set benchmarks into one

* Add benchmark: admin_move_market_to_closed

* Add weight: admin_move_market_to_closed

* Add benchmark: sell_complete_set

* Add weight: sell_complete_set

* Add benchmark: report

* Add weight: report

* Add benchmark: dispute

* Add weight: dispute

* Add benchmark: deploy_swap_pool_for_market

* Add weight: deploy_swap_pool_for_market

* Add benchmark: admin_destroy_reported_market

* Add benchmarks for admin_destroy_market

* Improve admin_destroy_market benchmark precision

* Add weight: admin_destroy_market

* Improve admin_destroy_market benchmark

The improvements will carry over to other functions that resolve markets, like in on_finalize

* Add benchmark: on_initialize

* Add weight: on_initialize

This commit also introduces an extensive benchmark of the internal_resolve function for different market types

* Add benchmark: admin_move_market_to_resolved

* Add weight: admin_move_market_to_resolved

* Add benchmark & weight: redeem_shares

* Cleanup

* Update primitives/src/lib.rs

easier to parse putting the amount first

Co-authored-by: Logan Saether <lsaether@protonmail.com>

* Update zrml/prediction-markets/src/lib.rs

Co-authored-by: Logan Saether <lsaether@protonmail.com>

* Update zrml/prediction-markets/src/lib.rs

fixed typos

Co-authored-by: Logan Saether <lsaether@protonmail.com>

* Fix failing benchmark tests

Applies to prediction markets pallet and swaps pallet

* Cargo fmt

* Integrate orml-currency into swaps mock

* Add comment about account number

Co-authored-by: Logan Saether <lsaether@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants