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

Fix Hybrid Router clippy and tests #1291

Merged
merged 4 commits into from
Mar 29, 2024

Conversation

Chralt98
Copy link
Member

What does it do?

I can successfully run ./scripts/tests/clippy.sh and cargo test --all-features now.

What important points should reviewers know?

Is there something left for follow-up PRs?

What alternative implementations were considered?

Are there relevant PRs or issues?

References

@Chralt98 Chralt98 changed the base branch from main to chralt98-amm-cda-release March 26, 2024 12:58
@Chralt98 Chralt98 self-assigned this Mar 26, 2024
@Chralt98 Chralt98 added the s:review-needed The pull request requires reviews label Mar 26, 2024
Comment on lines 12 to 33

orml-asset-registry = { workspace = true, optional = true }
orml-currencies = { workspace = true, optional = true }
orml-tokens = { workspace = true, optional = true }
pallet-balances = { workspace = true, optional = true }
pallet-randomness-collective-flip = { workspace = true, optional = true }
pallet-timestamp = { workspace = true, optional = true }
pallet-treasury = { workspace = true, optional = true }
pallet-xcm = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
sp-io = { workspace = true, optional = true }
xcm = { workspace = true, optional = true }
xcm-builder = { workspace = true, optional = true }
zrml-authorized = { workspace = true, optional = true }
zrml-court = { workspace = true, optional = true }
zrml-global-disputes = { workspace = true, optional = true }
zrml-liquidity-mining = { workspace = true, optional = true }
zrml-neo-swaps = { workspace = true, optional = true }
zrml-orderbook = { workspace = true, optional = true }
zrml-prediction-markets = { workspace = true, optional = true }
zrml-simple-disputes = { workspace = true, optional = true }
zrml-swaps = { workspace = true, optional = true }
Copy link
Member

Choose a reason for hiding this comment

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

We definitely don't need all of these dependencies. Please reduce this to a minimal set and remove/mark everything else as dev dependency.

Copy link
Member Author

Choose a reason for hiding this comment

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

Your zrml-neo-swaps pallet uses the setup with feature mock too. The reason why I did this was because of compiling the crate zrml-hybrid-router with all features. I got this in the mock:

#[cfg(feature = "parachain")]
zrml_prediction_markets::impl_mock_registry! {
    MockRegistry,
    CurrencyId,
    Balance,
    zeitgeist_primitives::types::CustomMetadata
}

impl_mock_registry uses feature mock and parachain together here

Copy link
Member Author

Choose a reason for hiding this comment

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

You meant using the dev dependencies, right?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, my bad, you're right! Marking them as optional is actually correct. Still though: At the very least you don't need zrml-swaps in the dependencies.

@maltekliemann
Copy link
Member

You'll also have to add the hybrid router pallet to the configuration in scripts/ in order to get meaningful results from the CI.

@Chralt98 Chralt98 added s:in-progress The pull requests is currently being worked on and removed s:review-needed The pull request requires reviews labels Mar 26, 2024
@Chralt98 Chralt98 added s:review-needed The pull request requires reviews and removed s:in-progress The pull requests is currently being worked on labels Mar 27, 2024
@mergify mergify bot added s:in-progress The pull requests is currently being worked on and removed s:review-needed The pull request requires reviews labels Mar 28, 2024
@Chralt98 Chralt98 added s:review-needed The pull request requires reviews and removed s:in-progress The pull requests is currently being worked on labels Mar 28, 2024
@mergify mergify bot added s:in-progress The pull requests is currently being worked on and removed s:review-needed The pull request requires reviews labels Mar 28, 2024
@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 6 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (chralt98-amm-cda-release@f840ee7). Click here to learn what that means.

Files Patch % Lines
zrml/hybrid-router/src/weights.rs 0.00% 6 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             chralt98-amm-cda-release    #1291   +/-   ##
===========================================================
  Coverage                            ?   92.39%           
===========================================================
  Files                               ?      164           
  Lines                               ?    33325           
  Branches                            ?        0           
===========================================================
  Hits                                ?    30792           
  Misses                              ?     2533           
  Partials                            ?        0           
Flag Coverage Δ
tests 92.39% <88.23%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Chralt98 Chralt98 merged commit 3747b3d into chralt98-amm-cda-release Mar 29, 2024
19 of 21 checks passed
@Chralt98 Chralt98 deleted the chralt98-amm-cda-6-5 branch March 29, 2024 06:32
@Chralt98 Chralt98 added s:accepted This pull request is ready for merge and removed s:in-progress The pull requests is currently being worked on labels Mar 29, 2024
mergify bot pushed a commit that referenced this pull request Apr 12, 2024
* AMM-CDA-1: Switch to AmmCdaHybrid enum field (#1274)

* switch to AmmCdaHybrid enum field

* Update zrml/parimutuel/src/tests/buy.rs

Co-authored-by: Malte Kliemann <mail@maltekliemann.com>

* Update zrml/parimutuel/src/tests/claim.rs

Co-authored-by: Malte Kliemann <mail@maltekliemann.com>

* Update zrml/parimutuel/src/tests/refund.rs

Co-authored-by: Malte Kliemann <mail@maltekliemann.com>

* Update storage version to 11 and add MigrateScoringRuleAmmCdaHybrid

* Update primitives/src/market.rs

* update migration

---------

Co-authored-by: Malte Kliemann <mail@maltekliemann.com>

* merge amm-cda-3 changes

* merge amm-cda-2 changes

* merge amm-cda-4 changes

* correct clippy

* merge amm-cda-5 changes

* merge amm-cda-6 changes

* Fix Hybrid Router clippy and tests (#1291)

* glue everything together

* add hybrid router to configuration

* fix tests

* fix conditional tests

* AMM-CDA-8 Add event information for fees and aggregated amount_out (#1293)

* add event info

* use slice as function parameter

* update test amm amount out of event

* fix order book tests

* update documentation

* removed dependency

* AMM-CDA-9 Adds soft and hard failure distinction for AMM and order book errors (#1294)

* add event info

* use slice as function parameter

* update test amm amount out of event

* wip

* handle soft and hard failure

* add order book soft failure

* fix clippy

* fix CI

* remove swaps pallet dependency

* add compact to order book struct

* fix recursion overflow

* Fix of Hybrid Router after asset system merge (#1309)

* wip

* use asset conversions

* adapt hybrid router to new asset system

* apply review suggestions

* fmt

* rename Asset to Assets

* update copyrights

* update hybrid router crate version

* correct orderbook spelling

* add amount is zero tests

* add price limit too high test

* add max order exceeded test

* use saturated conversion

* use saturated conversion again

* remove unused code

* add tests for soft failures

* add skip order test

* add changelog for devs description

* add amm soft failure test

* add numerical soft failure test for sell

* correct failing test for parachain feature

* cover remaining is zero execution path

---------

Co-authored-by: Malte Kliemann <mail@maltekliemann.com>
mergify bot pushed a commit that referenced this pull request Apr 12, 2024
* Add market ID to `Market` struct (#1248)

* Add market ID to `Market` struct

* Add market builder struct

* Use `PredictionMarketBuilder`

* Fix issues

* Fix copyright

* Make `build` return a `Result`

* Let `build` raise an error on incomplete data.

* Fix formatting

* Refactor `MarketBuilder`

* Add missing files

* AMM-CDA-1: Switch to AmmCdaHybrid enum field (#1274)

* switch to AmmCdaHybrid enum field

* Update zrml/parimutuel/src/tests/buy.rs

Co-authored-by: Malte Kliemann <mail@maltekliemann.com>

* Update zrml/parimutuel/src/tests/claim.rs

Co-authored-by: Malte Kliemann <mail@maltekliemann.com>

* Update zrml/parimutuel/src/tests/refund.rs

Co-authored-by: Malte Kliemann <mail@maltekliemann.com>

* Update storage version to 11 and add MigrateScoringRuleAmmCdaHybrid

* Update primitives/src/market.rs

* update migration

---------

Co-authored-by: Malte Kliemann <mail@maltekliemann.com>

* merge amm-cda-3 changes

* merge amm-cda-2 changes

* merge amm-cda-4 changes

* correct clippy

* merge amm-cda-5 changes

* merge amm-cda-6 changes

* Fix Hybrid Router clippy and tests (#1291)

* glue everything together

* add hybrid router to configuration

* fix tests

* fix conditional tests

* AMM-CDA-8 Add event information for fees and aggregated amount_out (#1293)

* add event info

* use slice as function parameter

* update test amm amount out of event

* fix order book tests

* update documentation

* removed dependency

* Merge `main` into `mkl-market-id-feature` (#1302)

* Merge `main` into `mkl-mkl-market-id-feature`

* Remove unused `outcomes`

* Remove old migrations (#1301)

* AMM-CDA-9 Adds soft and hard failure distinction for AMM and order book errors (#1294)

* add event info

* use slice as function parameter

* update test amm amount out of event

* wip

* handle soft and hard failure

* add order book soft failure

* fix clippy

* fix CI

* remove swaps pallet dependency

* add compact to order book struct

* fix recursion overflow

* Migration: Add Market ID to Market (#1257)

* Add market ID to `Market` struct

* Add market builder struct

* Use `PredictionMarketBuilder`

* Fix issues

* Fix copyright

* Make `build` return a `Result`

* Let `build` raise an error on incomplete data.

* Fix formatting

* Refactor `MarketBuilder`

* Add missing files

* Add migration to new market

* Fix migration

* Fix missing import

* Fix duplicate import

* Fix formatting

* Remove unused `types/`

* Fix of Hybrid Router after asset system merge (#1309)

* wip

* use asset conversions

* adapt hybrid router to new asset system

* apply review suggestions

* fmt

* rename Asset to Assets

* update copyrights

* Make minor fixes after merge

* update hybrid router crate version

* correct orderbook spelling

* add amount is zero tests

* add price limit too high test

* add max order exceeded test

* use saturated conversion

* use saturated conversion again

* remove unused code

* Update changelog

* add tests for soft failures

* add skip order test

* add changelog for devs description

* add amm soft failure test

* add numerical soft failure test for sell

* Remove ZeitgeistAssetManager trait

* correct failing test for parachain feature

* cover remaining is zero execution path

* Fix try-runtime test

---------

Co-authored-by: Chralt <chralt.developer@gmail.com>
Co-authored-by: Chralt98 <chralt98@gmail.com>
Co-authored-by: Harald Heckmann <mail@haraldheckmann.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s:accepted This pull request is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants