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

integration-tests: Use latest version of fudge-polkadot-v0.9.43 #1590

Merged
merged 18 commits into from
Nov 8, 2023

Conversation

cdamian
Copy link
Contributor

@cdamian cdamian commented Oct 13, 2023

Fixing the integration test setup using the latest fudge version.

@cdamian
Copy link
Contributor Author

cdamian commented Oct 13, 2023

The xcm-related tests are still failing due to the same error thrown by the XCMP queue - ErrorDelivering.

Main reason for this being the "partial use" of the xcm-simulator, to be more specific:

  • as per the example provided here, the XCMP/DMP message handlers are mocked, whereas we use the actual XCMP/DMP queues.
  • another requirement for using this setup would be the usage of the ParachainXcmRouter found here.

Given the above, in the current approach I resumed to doing the following changes on the relay side:

  • manually setting the required storages for HRMP message handling here.
  • force-opening the HRMP channels here. Ideally this would've been done via the genesis config, however, the relevant field in there is not private...

However, the above relay changes are not sufficient given that certain storages have to be also populated accordingly on the parachain side.

When attempting to deliver an XCM message, the XCMP pallet attempts to retrieve the max message size for a channel here, which ends up querying the RelevantMessagingState storage of the parachain system pallet here.

The issue here is that this storage is set when set_validation_data is called during block building, as I found out during the work that I did on fudge recently.

Given that using the xcm-simulator might require us to use mocked components for the XCM messaging, I think we should re-consider the approach here and to discuss more about using fudge for this purpose since we already have a WIP PR that addresses this topic.

cc @NunoAlexandre @mustermeiszer

Cargo.toml Outdated Show resolved Hide resolved
@NunoAlexandre
Copy link
Contributor

The xcm-related tests are still failing due to the same error thrown by the XCMP queue - ErrorDelivering.

Main reason for this being the "partial use" of the xcm-simulator, to be more specific:

  • as per the example provided here, the XCMP/DMP message handlers are mocked, whereas we use the actual XCMP/DMP queues.
  • another requirement for using this setup would be the usage of the ParachainXcmRouter found here.

Given the above, in the current approach I resumed to doing the following changes on the relay side:

  • manually setting the required storages for HRMP message handling here.
  • force-opening the HRMP channels here. Ideally this would've been done via the genesis config, however, the relevant field in there is not private...

However, the above relay changes are not sufficient given that certain storages have to be also populated accordingly on the parachain side.

When attempting to deliver an XCM message, the XCMP pallet attempts to retrieve the max message size for a channel here, which ends up querying the RelevantMessagingState storage of the parachain system pallet here.

The issue here is that this storage is set when set_validation_data is called during block building, as I found out during the work that I did on fudge recently.

Thanks a lot for the throughout work and update, @cdamian.

Given that using the xcm-simulator might require us to use mocked components for the XCM messaging, I think we should re-consider the approach here and to discuss more about using fudge for this purpose since we already have a WIP PR that addresses this topic.

I wholeheartedly agree. I noticed that Acala, for instance, followed the same route but using Chopsticks. I agree this should be the way forward. We could delete or skip these failing tests on this update but I am afraid that by doing so we won't catch actual issues that will have our xcm setup break in production. When will the Fudge version that could support XCM testing be ready and when could we switch to using that? if it's in a matter of days I think it makes sense to align these two pieces of work and wait to merge this update until then. If it's longer, we need to think of an intermediary safe approach.

@cdamian
Copy link
Contributor Author

cdamian commented Oct 16, 2023

@NunoAlexandre I'm hoping that the fudge version with XCM support will be a matter of a couple of days, however, I have to double-check that with @mustermeiszer

@mustermeiszer
Copy link
Collaborator

@NunoAlexandre are we actually checking against the moonbeam runtime?

@NunoAlexandre
Copy link
Contributor

@NunoAlexandre are we actually checking against the moonbeam runtime?

The e2e tests are not using the actual Moonbeam runtime, no. We use our own runtime and thus mock those external runtimes. If we would use the real runtimes (Acala, Moonbeam, etc) we would be pulling yet more insanely heavy dependencies and when we tried doing this 1+ year ago it wasn't only super slow but also a nightmare to deal with duplicate dependencies (the latter would probably be easier now that we introduced cargo patch in the meantime)

@cdamian cdamian force-pushed the polkadot-v0.9.43-integration-tests branch from 535ca74 to e4f9f96 Compare October 30, 2023 13:28
@cdamian cdamian changed the title integration-tests: Use latest version of fudge-polkadot-v0.9.43 and a… integration-tests: Use latest version of fudge-polkadot-v0.9.43 Nov 6, 2023
@cdamian cdamian force-pushed the polkadot-v0.9.43-integration-tests branch from e82c1eb to 68698bc Compare November 7, 2023 13:21
@cdamian cdamian force-pushed the polkadot-v0.9.43-integration-tests branch from 4bfa443 to 9612869 Compare November 7, 2023 13:23
assert_eq!(current_balance, transfer_amount - fee(18));

// Sanity check for the actual amount Keyring::Bob ends up with
assert_eq!(current_balance, 4992960800000000000);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pallet_balances::Pallet::<FudgeRelayRuntime<T>>::free_balance(
&Keyring::Bob.into()
),
999907996044
Copy link
Contributor Author

Choose a reason for hiding this comment

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

orml_tokens::Pallet::<T>::free_balance(usdc_asset_id, &Keyring::Bob.into());

// Sanity check to ensure the calculated is what is expected
assert_eq!(bob_balance, 11992961);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

assert_eq!(current_balance, transfer_amount - fee(18));

// Sanity check for the actual amount Keyring::Bob ends up with
assert_eq!(current_balance, 4992960800000000000);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pallet_balances::Pallet::<FudgeRelayRuntime<T>>::free_balance(
&Keyring::Alice.into()
),
79628418552
Copy link
Contributor Author

Choose a reason for hiding this comment

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

orml_tokens::Pallet::<T>::free_balance(usdc_asset_id, &Keyring::Bob.into());

// Sanity check to ensure the calculated is what is expected
assert_eq!(bob_balance, 11992961);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

.await;
}
// #[tokio::test]
// async fn liquidity_rewards_runtime_api_works() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently failing since the 2nd attempt to distribute rewards is trying to mint a balance of 0 into the staker which throws a BelowMinimum error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@cdamian cdamian marked this pull request as ready for review November 7, 2023 16:14
@mustermeiszer mustermeiszer mentioned this pull request Nov 8, 2023
Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

LOVE IT! Just need to clarify a few things otherwise looks good!

@@ -10,10 +10,12 @@ repository = "https://github.com/centrifuge/centrifuge-chain"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0", default-features = false, features = ["derive"] }
fudge = { git = "https://github.com/centrifuge/fudge", branch = "polkadot-v0.9.43" }
fudge-core = { git = "https://github.com/centrifuge/fudge", branch = "polkadot-v0.9.43" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need core? Just out of interest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

WE should re-export taht ^^

runtime/integration-tests/src/generic/env.rs Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could allow submit now by using the exact same logic as 'RuntimeEvent' is using inside of a mutable state. Wdyt? We only need to take care of updating the relay state then too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean by updating the relay state. Can you be more specific please? ^^

Copy link
Collaborator

Choose a reason for hiding this comment

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

The update_para logic you implemented in fudge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean updating the para head in the relay after executing the extrinsic submission right?

// We need to HostConfiguration and use the default here.
//TODO(cdamian): Use RelayBlock
let mut state =
StateProvider::<TFullBackend<centrifuge::Block>, centrifuge::Block>::empty_default(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mustermeiszer Shouldn't this fail since we're not using the relay block?

Copy link
Collaborator

Choose a reason for hiding this comment

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

mmh. Probably we have the same as the relay.

@mustermeiszer mustermeiszer merged commit 57923d2 into polkadot-v0.9.43 Nov 8, 2023
10 checks passed
mustermeiszer added a commit that referenced this pull request Nov 10, 2023
* fix: docker relay

* feat: update rococo local to polkadot v0.9.43

* fix: bump relay docker img version

* Update most deps to 0.9.43

* Drop dependency on randomness-collective pallet

* Fix grandpa package

* cargo update

* toolchain: bump to 1.71.0

* bump

* Fix pool-system pallet

* Rename purestake to moonbeam-foundation

* Work on dup dependencies

* Fix dup dependencies

* Fixes fixes fixes

* fmt

* bump

* bump

* Fix restricted_tokens pallet

* wip on order-book

* Fix order-book with Reason = ()

* fmt

* Fix pallet-rewards

* fix runtime-common

* cu

* try: fix frame--system-benchmarking issues

* nix

Was trying to catch any new dup dep

* Fix lots of benchmarks

* bump

* Drop RandomnessCollectiveFlip

* weights

* bump

* Lots of evm-related fixes

* more evm fixes

* bump

* bump: xcm stuff

* more fixes

* fix evm stuff

* Deprecate Weight::from_ref_time

* Deprecate Weight::from_proof_size with from_parts

* more evm

* fixes++

* More fixes

* fmt

* Use polkadot xcm-simulator

* Use sp_io::offchain::random_seed

* wip: service + cli + command + evm + anchors

* wip

* wip

* Fix AuraConsensus::build SyncOracle trait bound issue

* Fix new_partial instantiation of frontier_backend

* Fix apis using FrontierBackend

* Last node fix

It now compiles but runtime_integrity_tests fails

* Remove some todos

* wip: fix rpc/evm create

* bump

* Done at rpc/evm create

* fmt

* Address rpc/evm create todos

* update todo

* bump toolchain to 1.74 nightly-2023-08-24

* Fix issue with assert_last_event

* fix: collator compose

* Use my fork of substrate

This fixes the weird compilation error and now shows our own compilation
errors under runtime/integration-tests

* e2e: Fix complilation errors

* fmt

* wip: clippy

* wip: clippy

* fixup

* Fix runtime_integrity_tests

Reduce MaxCandidates and MaxVoter from (1k, 10k) to (20, 100) like
Acala. We can discuss higher values that don't break block times during
the review process.

* Fix tests::<router>::send::success

* Fix ExistentialDeposit 0 issues

* wip

* Fix fungible_transfer_on_hold

* Fix pallets/restricted-tokens/src/tests

* Fix block-rewards/tests/joining_leaving_collators

So the issue here is that in do_init_collator we would mint the
StakeAmount into the collator's account and then call
Rewards::deposit_stake which in turn calls Currency::can_hold, which
fails because the new version of fungibles/tokens etc doesn't support
ExistentialDeposit = 0, so that can_hold check fails since it can NOT
hold the entire balance (i.e, the entire balance of said account). So
the solution here involves adding ExistentialDeposit as a Config value
and, when minting the balance in do_init_collator, add the
ExistentialDeposit to it. By doing so, the tests also need to take the
ED value into account when checking values.

* Add ExistentialDeposit to all block_rewards::Config

* Fix pallets/bridge tests

* fix Tokens fungible can_hold implementation

As far as I can see, we forgot to check with the underlying
`NativeFungible` implementation whether the account can actually hold
amount.

* fix order-book tests

* fix pallet-claims tests

* block_rewards: Fix single_claim_rewards

The error was that the reward value was lower than the ED, so such a
transfer (Reward :: Rewards account -> Dest Account) could not take
place. Increasing the Reward value to something above the ED fixed it.

* fix pallet-investments tests

* Fix most pallet-investments benchmarks

* fmt

* fix keystore benchmarking

* Merge remote-tracking branch 'origin/main' into polkadot-v0.9.43

fix: precompile_account_codes.rs migration

* chore: bump rust version

* chore: bump srtool version

* loan and investment benchmarks fixed (#1602)

* bench: fix investments

* tests: fix runtime api declarations

* tests: fix integration utils

* reverting to Nuno's change

* fixup

* fmt

* Migrate weight::from_deprecated

* fix weights

* clippy wip

* clippy

* clippy is happy!!!

* fixup

* fmt

* bench: fix anchors

* bench: fix keystore

* bench: fix pool-system

* bench: fix frame-system

* Fix mocks/src/liquidity_pools_gateway_routers

* fmt

* Drop tmp workaround

I needed this to run the tests through Clion.

* fix: Set MaxHolds to 1 for all mocks

* chore: fix + update restricted tokens

* refactor: use Currency API instead of hardcoded ED

* wip: address todos and fix tests

* drop more todos

* fix: assert_last_event

* fix: warnings

* chore: cleanup comments in tomls

* Align pallet_elections_phragmen runtime values

* clean up more todos

* fixup

* docker: Bump local relay to 0.9.43

* docker: Update relayer command options

* fix: run local relay in Polkadot v1.0.0

* Delete cautios change note on db_config_dir fn

* Drop leftover debug comments

* fix: enable client block production

* fix: run local collator

* fix: run docker collator

* feat: add backwards cmp for para docker compose

* ci: disable frame_system in check_benchmarks

* integration-tests: Use latest version of fudge-polkadot-v0.9.43 (#1590)

* integration-tests: Use latest version of fudge-polkadot-v0.9.43 and adapt testing setup

* integration-tests: Use fudge in development LP tests

* integration-tests: Drop unnecessary envs and funcs from development tests

* integration-tests: Add sibling to generic envs, fix LP tests

* integration-tests: Adapt LP kusama tests to use the generic framework

* integration-tests: Adapt LP polkadot tests to use the generic framework

* integration-tests: Don't evolve fudge env during creation

* development: Add max holds and max freezes to pallet-balances config.

* integration-tests: Remove unused imports

* integration-tests: Disable liquidity_rewards_runtime_api_works test

* investments: Remove commented code

* development: Remove MaxFreezes const

* integration-tests: Handle extrinsics errors, evolve fudge env on init

* integration-tests: Add missing LP foreign investment test

* integration-tests: Use correct sibling ID in convert_ausd for centrifuge runtime

* integration-tests: Test LP restricted call on all runtimes

* integration-tests: Update total fee in LP tests

* clippy: Obey

* fix: artifact Cargo.timl

* fix: align compose platform

* fix: adapt evm ratios

* fix: notes for unburned ED of stake currency

* fix: investments rm not needed order id update

* fix: rm debug artifacts

* fix: warning, note for dust handler

* fix: prt uses orml api and consistend non-dusting

* fix: locks of balances

* fix: impl metadata left overs

* fix: benches need holds. Moving it up to 10 for all

* fix: taplo

* feat: weights altair

* feat: weights centrifuge

* feat: weights development

* fix: revoer develppment pallet-xcm weight file

* fix: allowlist and other benches in dev

---------

Co-authored-by: William Freudenberger <[email protected]>
Co-authored-by: Luis Enrique Muñoz Martín <[email protected]>
Co-authored-by: Cosmin Damian <[email protected]>
Co-authored-by: Frederik Gartenmeister <[email protected]>
Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

Really good addition here @cdamian!

It's great to see it grow!

@@ -60,6 +61,8 @@ macro_rules! test_for_runtimes {
$(
#[tokio::test]
async fn $runtime_name() {
crate::utils::logs::init_logs();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want this for all tests by default? If it's for debugging purposes, why not add it during the debugging phase for the test that is currently failing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think having it here makes sense and one can tweak the log level when debugging tests individually, if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, my comment comes mainly from this issue, where the amount of stdout increases the CI time until the timeout.

I think successful tests should not give any output (nobody looks logs in successful tests), only the ones that fail. Not sure how to configure the logger to act in that way and also reduce the amount of stdout in CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yea, that makes sense. Well, we can set the default log level to error and then the logs would be minimal, I still think it's good to have them enabled by default so that it makes or lives easier when debugging and not having to look for the init func and add it in there manually, but then again, no strong feelings on this one.

@@ -228,6 +270,7 @@ mod tests {
balances: vec![(Keyring::Alice.to_account_id(), 1 * CFG)],
})
.storage(),
Genesis::<T>::default().storage(),
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT. I think Storage::default() works here.

mod utils {
use super::*;

pub fn register_ausd<T: Runtime + FudgeSupport>() {
Copy link
Contributor

@lemunozm lemunozm Nov 15, 2023

Choose a reason for hiding this comment

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

Just saw this. For these methods, you have a utility to define currencies in a way that later you can later refer to their properties easily in https://github.com/centrifuge/centrifuge-chain/blob/main/runtime/integration-tests/src/generic/utils/currency.rs

If you define AUSD there, for example, you can later write something like Ausd::ED for minting into an account

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that's pretty awesome, I guess I missed it while dealing with the test tornado ^^.

@NunoAlexandre NunoAlexandre deleted the polkadot-v0.9.43-integration-tests branch November 20, 2023 07:40
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.

4 participants