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

Runtimes workspace dependencies & cleaning #1609

Merged
merged 16 commits into from
Nov 23, 2023
Merged

Runtimes workspace dependencies & cleaning #1609

merged 16 commits into from
Nov 23, 2023

Conversation

lemunozm
Copy link
Contributor

@lemunozm lemunozm commented Nov 16, 2023

Description

Refactorizations and cleanings in the runtime part.

The first step to get this: #1380

Fixes #1582

Changes and Descriptions

  • Reorganize the fees section in runtime-common
  • Remove scripts/runtime-weight-template.hbs because now we use the default from substrate.
  • runtime-common export a list with all pallets used in our runtimes, to avoid importing them if all of our runtimes.
    • There is an issue with the autogenerated weights where the default template is not valid if we reimport the pallets, we would need to maintain a template by us (the one we currently have is not used). Do we want to maintain the template to get this reexporting list?
      • Finally, it seems more painful to have an exporting list than to copy the pallet list.
  • Using workspace dependencies in runtime-common
  • Using workspace dependencies in development
  • Using workspace dependencies in altair
  • Using workspace dependencies in centrifuge
  • Using workspace dependencies in integration-tests
  • Factorize types from development into runtime-common => Other PR
  • Factorize types from altair into runtime-common=> Other PR
  • Factorize types from centrifuge into runtime-common => Other PR

@lemunozm lemunozm added Q5-hard Can be done by an experienced coder with a good knowledge of the codebase. I6-refactoring Code needs refactoring. dependencies Pull requests that update a dependency file. I11-cleaning No mandatory issue that leave the repo more readable/organized labels Nov 16, 2023
@lemunozm lemunozm requested a review from cdamian November 16, 2023 17:43
@lemunozm lemunozm self-assigned this Nov 16, 2023
@lemunozm lemunozm mentioned this pull request Nov 20, 2023
8 tasks
@lemunozm
Copy link
Contributor Author

Currently cargo complains (with a warning) about workspace inheritance with renaming packages (see the issue). We can:

  • Life with the warning until it be (hopefully) solved.
  • Change codec to parity_scale_codec everywhere in our database

@lemunozm lemunozm changed the title Runtimes refactor & cleaning Runtimes workspace dependencies & cleaning Nov 23, 2023
@lemunozm lemunozm marked this pull request as ready for review November 23, 2023 07:37
@@ -158,7 +352,7 @@ runtime-common = { path = "runtime/common" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "polkadot-v0.9.43" }
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "polkadot-v0.9.43" }
# integration testing
runtime-integration-tests = { path = "runtime/integration-tests", optional = true, default-features = false }
#runtime-integration-tests = { path = "runtime/integration-tests", optional = true, default-features = false }
Copy link
Collaborator

Choose a reason for hiding this comment

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

???

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why were we linking integration tests as a dependency of our node before?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought we needed it for some features. Fine then

Comment on lines -154 to -155
#[cfg(not(feature = "runtime-development"))]
polkadot_runtime_common::claims::PrevalidateAttests::<RelayRuntime>::new(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the removal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nongeneric tests are always run in CI under runtime-development, so this implies that that line is never compiled. In the case of other runtimes, we have now the generic part which should take care of that. Actually, we no longer have runtime-x features.

Please correct me if I'm missing something here, but CI will always tests against the development.

Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning up and making our future lives much easier! I have a few questions, overall LGTM.

Cargo.toml Outdated
license = "LGPL-3.0"
homepage = "https://centrifuge.io/"
repository = "https://github.com/centrifuge/centrifuge-chain"
documentation = "https://github.com/centrifuge/centrifuge-chain"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we want to point to our rustdocs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right! I thought I copied the correct link 🤦🏻‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@@ -158,7 +352,7 @@ runtime-common = { path = "runtime/common" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "polkadot-v0.9.43" }
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "polkadot-v0.9.43" }
# integration testing
runtime-integration-tests = { path = "runtime/integration-tests", optional = true, default-features = false }
#runtime-integration-tests = { path = "runtime/integration-tests", optional = true, default-features = false }
Copy link
Contributor

Choose a reason for hiding this comment

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

Artifact?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Answer above to Frederik, we do not want integration tests as a dependency of our centrifuge node, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

@lemunozm yeah good point but then we should remove these lines all together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right!

I'm in a new PR trying to move the node to its own folder using workspace dependencies. I'll do there.

@@ -222,7 +416,7 @@ std = [
"pallet-pool-system/std",
"polkadot-primitives/std",
"runtime-common/std",
"runtime-integration-tests/std",
#"runtime-integration-tests/std",
Copy link
Contributor

Choose a reason for hiding this comment

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

Artifact? Plus the other commented out features of runtime-integration-tests below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

related to the previous answer

"serde/std",
"log/std",

# Substrate related
Copy link
Contributor

Choose a reason for hiding this comment

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

🚀

]

# A feature that should be enabled when the runtime should be build for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
on-chain-release-build = [
"sp-api/disable-logging",
"runtime-common/on-chain-release-build",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you give some details about this addition?

Copy link
Contributor Author

@lemunozm lemunozm Nov 23, 2023

Choose a reason for hiding this comment

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

Yes, I understand that if we compile altair with on-chain-release-build we would want the runtime common used to have that related feature also. Am I wrong?

Comment on lines -1 to -5
//! Autogenerated weights for {{pallet}}
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}}
//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}`
//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can we remove the bench template?

Copy link
Contributor Author

@lemunozm lemunozm Nov 23, 2023

Choose a reason for hiding this comment

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

We're not using it, if we do not put any template in the CLI command it uses the default. That it's how it's working right now.

@lemunozm lemunozm enabled auto-merge (squash) November 23, 2023 13:50
@lemunozm lemunozm merged commit 5730d02 into main Nov 23, 2023
9 checks passed
@lemunozm lemunozm deleted the runtime-refactor branch November 23, 2023 15:08
wischli added a commit that referenced this pull request Nov 29, 2023
wischli added a commit that referenced this pull request Jan 23, 2024
* chore: init blank pool fees pallet

* chore: apply workspace #1609 to pool-fees dummy

* fix: docker-compose

* feat: add changeguard pool fees support

* wip: prepare payment logic

* refactor: use reserve instead of nav

* chore: add extrinsics

* feat: prep + pay disbursements

* refactor: Apply fees ChangeGuard to #1637

* feat: add pool fees to all runtimes

* feat: add fees pool registration

* fix: existing pool unit tests

* fix: existing integration tests

* docs: add pool fee types

* wip: init fees unit tests

* tests: extrinsics wip

* chore: add events

* tests: add pool fees unit tests

* fix: support retroactive disbursements

* refactor: add epoch transition hook

* refactor: add pool fee prefix to types

* refactor: remove redundand trait bounds

* wip: pool system integration tests

* refactor: move portfolio valuation from loans to cfg-types

* chore: add pool fee account id

* wip: pool fee nav

* wip: fix uts

* wip: fix apply review by @lemunozm

* fix: issues after rebase

* tests: add saturated_proration

* refactor: simplify pool fee amounts

* chore: aum + fix fees UTs

* chore: apply AUM to pool-system

* fix: remove AUM coupling in PoolFees

* fix: transfer on close, unit tests

* fix: use total nav

* fix: taplo

* fix: fee calc on nav closing

* feat: impl TimeAsSecs for timestamp mock

* fix: test on_closing instead of update_active_fees

* fix: clippy

* tests: fix + add missing pool fees

* refactor: make update fees result instead of void

* tests: add insufficient resource in p-system

* bench: add pool fees, apply to system + registry

* fix: tests

* refactor: explicitly use Seconds in FeeAmountProration impl

* docs: add PoolFeeAmount and NAV update

* refactor: update NAV, total assets after review from @mustermeiszer

* fix: clippy

* refactor: Add PoolFeePayable

* fix: clippy

* fix: correct epoch execution with fees (#1695)

* fix: correct epoch execution with fees

* refactor: use new nav syntax

* tests: fix auto epoch closing

* feat: epoch execution migration

* chore: add epoch migration to altair

---------

Co-authored-by: William Freudenberger <w.freude@icloud.com>

---------

Co-authored-by: Guillermo Perez <gpmayorga@users.noreply.github.com>
Co-authored-by: Frederik Gartenmeister <mustermeiszer@posteo.de>
wischli added a commit that referenced this pull request Jan 29, 2024
* chore: init blank pool fees pallet

* chore: apply workspace #1609 to pool-fees dummy

* fix: docker-compose

* feat: add changeguard pool fees support

* wip: prepare payment logic

* refactor: use reserve instead of nav

* chore: add extrinsics

* feat: prep + pay disbursements

* refactor: Apply fees ChangeGuard to #1637

* feat: add pool fees to all runtimes

* feat: add fees pool registration

* fix: existing pool unit tests

* fix: existing integration tests

* docs: add pool fee types

* wip: init fees unit tests

* tests: extrinsics wip

* chore: add events

* tests: add pool fees unit tests

* fix: support retroactive disbursements

* refactor: add epoch transition hook

* refactor: add pool fee prefix to types

* refactor: remove redundand trait bounds

* wip: pool system integration tests

* refactor: move portfolio valuation from loans to cfg-types

* chore: add pool fee account id

* wip: pool fee nav

* wip: fix uts

* wip: fix apply review by @lemunozm

* fix: issues after rebase

* tests: add saturated_proration

* refactor: simplify pool fee amounts

* chore: aum + fix fees UTs

* chore: apply AUM to pool-system

* fix: remove AUM coupling in PoolFees

* fix: transfer on close, unit tests

* fix: use total nav

* fix: taplo

* fix: fee calc on nav closing

* feat: impl TimeAsSecs for timestamp mock

* fix: test on_closing instead of update_active_fees

* fix: clippy

* tests: fix + add missing pool fees

* refactor: make update fees result instead of void

* tests: add insufficient resource in p-system

* bench: add pool fees, apply to system + registry

* fix: tests

* refactor: explicitly use Seconds in FeeAmountProration impl

* docs: add PoolFeeAmount and NAV update

* refactor: update NAV, total assets after review from @mustermeiszer

* fix: clippy

* refactor: Add PoolFeePayable

* fix: clippy

* fix: correct epoch execution with fees (#1695)

* fix: correct epoch execution with fees

* refactor: use new nav syntax

* tests: fix auto epoch closing

* feat: epoch execution migration

* chore: add epoch migration to altair

---------

Co-authored-by: William Freudenberger <w.freude@icloud.com>

---------

Co-authored-by: Guillermo Perez <gpmayorga@users.noreply.github.com>
Co-authored-by: Frederik Gartenmeister <mustermeiszer@posteo.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file. I6-refactoring Code needs refactoring. I11-cleaning No mandatory issue that leave the repo more readable/organized Q5-hard Can be done by an experienced coder with a good knowledge of the codebase.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants