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

LPv2: Bump-up foreign investment. Fix failing investment ITs #1934

Merged
merged 13 commits into from
Aug 1, 2024

Conversation

lemunozm
Copy link
Contributor

@lemunozm lemunozm commented Jul 30, 2024

Description

Changes

  • Versioning
    • Bump-up version for pallet-foreign-investment
    • Finally, I've not bump-up the pallet-liquidity-pools-gateway because their storage does not change in a breaking way. Modifying the configuration of the pallet should no imply modifying the version number of a pallet.
  • Fix an issue of updating an investment with zero amount when it already has zero amount.
    • invest_cancel_full_before_swap passing
    • invest_cancel_full_after_swap_partially_inter_epoch_close passing
    • transfer_tranche_tokens_domain_to_local_to_domain passing
  • Getting 1 min of less computing for each test case after reducing the amount of configured investors

@lemunozm lemunozm added the I9-release A specific release. label Jul 30, 2024
@lemunozm lemunozm requested a review from wischli July 30, 2024 16:28
@lemunozm lemunozm self-assigned this Jul 30, 2024
@lemunozm lemunozm changed the title LPv2: Bump up required versions LPv2: Bump-up foreign investment. Fix failing investment ITs Jul 30, 2024
Copy link

codecov bot commented Jul 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.79%. Comparing base (a38c4f9) to head (94a0ea2).

Additional details and impacted files
@@              Coverage Diff               @@
##           feat/lp-v2    #1934      +/-   ##
==============================================
- Coverage       47.81%   47.79%   -0.03%     
==============================================
  Files             184      184              
  Lines           13036    13038       +2     
==============================================
- Hits             6233     6231       -2     
- Misses           6803     6807       +4     

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

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.

Unfortunately, transfer_tranche_tokens_domain_to_local_to_domain still fails but since Jeroen has confirmed this worked in practice, we can reconvert the tast back to ignore and finish up the LP branch

@@ -224,7 +224,7 @@ pub fn default_accounts() -> Vec<Keyring> {

/// Returns a Vector of default investor accounts
pub fn default_investors() -> Vec<Keyring> {
(0..=50).map(Keyring::TrancheInvestor).collect()
(1..=2).map(Keyring::TrancheInvestor).collect()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This reduces the time for each test case to more than a minute on my computer (around 70 seconds less per test case). I think we can enable again the all tag for these tests.

@@ -271,7 +272,9 @@ fn transfer_tranche_tokens_domain_to_local_to_domain<T: Runtime>() {
Token::FixedBytes(pool_a_tranche_1_id::<T>().into()),
Token::Uint(DOMAIN_EVM.into()),
Token::Uint(EVM_DOMAIN_CHAIN_ID.into()),
Token::Address(Keyring::TrancheInvestor(2).into()),
Token::FixedBytes(
AccountId::from(as_h160_32bytes(Keyring::TrancheInvestor(2))).to_raw_vec(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Damn, you were faster! Just came to the same conclusion after some debugging. Well done!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to reach the same solution, double confident about this!

Comment on lines +275 to +277
Token::FixedBytes(
AccountId::from(as_h160_32bytes(Keyring::TrancheInvestor(2))).to_raw_vec(),
),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes the test pass. We need an account coded in some way that later when obtaining the local representation the extra padding does not change. I think the current account conversions are quite confusing, and we should need to simplify this into the DomainAddress: ref

Copy link
Contributor

@wischli wischli Jul 31, 2024

Choose a reason for hiding this comment

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

Absolutely! I am wondering why this test has worked in the past..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously a Token::Address was passed as a parameter instead, which seems to be processed differently

Comment on lines +115 to +127
//
// NOTE: If the above file changes, this code needs to be adapted as follows:
// 1. Update the `liquidity-pools` submodule to the latest desired state
// 2. Build with `forge-build`
// 3. Go to `./out/PassthroughAdapter.sol` and copy-paste the
// `deployedBytecode` here.
// 4. Run tests and update mismatching hashes.
// 5. On Development chain, you might also have to update the
// `evm.accountCodes` storage via raw writing.
//
// Blake256 hash of the deployed passthrough router contract code as
// Encoded::encode(Vec<Code>):
// `0x283d01c648e109952e3120e8928a19614c5c694477c780920ac29a748f96babf`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The < character makes docs fail in they are computed as docs instead of normal comments.

Modified this to be a coder comment instead of a user docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah sorry for merging back that error. This branch had an outdated version though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably I think just pushed something in between your work. Now should pass 🤞🏻

>::try_from(
"A highly advanced tranche".as_bytes().to_vec()
)
>::try_from("A highly advanced tranche".as_bytes().to_vec())
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 this breaks cargo fmt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, already fixed. I don't know why but my IDE Rustrover keeps introducing this fmt error and I can only commit the fixed version manually without the IDE.... Small indie company JetBrains..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could it be done regarding the cargo version?

For me, what's works as CI is cargo +nightly fmt which is the action I've configured in my IDE

@lemunozm lemunozm merged commit a76c15f into feat/lp-v2 Aug 1, 2024
9 checks passed
lemunozm added a commit that referenced this pull request Aug 1, 2024
* feat: LPv2 message reorder (#1892)

* wip: add new msgs + reorder

* refactor: apply renaming

* fix: ITs

* feat: UpdateRestriction message

* fix: cancel_unprocessed_investment IT

* fix: fmt

* fix: clippy

* tests: reanchor solidity to reorder branch

* feat: apply hook to AddTranche msg

* tests: fix pool_management ITs

* wip: fix lp investments

* fmt

* fix: Tranche namespace

* refactor: remove fulfilled from FulfilledRedeemRequest

* chore: update lp submodule

* minor cleanup

* chore: update lp submodule

* chore: add missing cleanup

* fixes + ignore failing tests

* fmt

* tests: fix message indices

* ignore failing tests (#1910)

* LPv2: ForeignInvestments changes (#1895)

* add uts (#1905)

* main changes for FI

* fix correlation precission

* minor renames

* update investment UTs

* update redemption UTs

* miscelaneous UTs

* minor renames

* simplify correlation and embed to the only needed place

* doc change

* remove unused bound

* swapping calls into entities.rs file

* merge SwapDone methods into FulfilledSwapHook

* fix events

* working without pallet-swaps

* remove boilerplate for removing entries

* minor msg change

* minor simplification

* correct fulfilled sum after last collect

* check OrderIdToSwapId storage

* sending the message inside Info closure is not really a problem

* send msgs from the entities

* remove same currency check in impl.rs

* unify hooks

* remove pallet-swaps

* minor fmt

* add docs

* add architecture diagram

* return cancelled foreign amount from FI interface

* update liquidity-pools

* add messages to diagram

* implement hooks

* fix runtimes

* adapt integration-tests

* fix docs

* fix clippy

* fix clippy

* fix tests after merge

* fix foreign investment tests (#1918)

* ignore failing tests (#1919)

* fix previous merge

* LP v2: fix integration tests (#1915)

* chore: update submodule to latest `main` 6d7f242c0dd83b1b5a4f6d506370a1f3ecbef9ce

* wip: fix ITs

* chore: update submodule

* fix: remove sender param from `Transfer*` messages

* chore: cleanup

* docs: setup evm

* fix: msg tests

* fix: more ITs

* fix: missing refactor after rebase

* chore: update submodule to 223a0f36edabc675f8c74c47b20e366178df7ca3

* chore: improvements

* fmt

* Apply suggestions from code review

* chore: bump spec_version

* fmt: taplo

* LPv2: Batch Message serialization (#1920)

* custo serialize/deserialize for batch

* compiling solution

* serialization/deserialization working for batch message

* remove gmpf changes

* add batch nested protection

* faster serialization for submessages

* correct termination

* add tests for deserialize batch of batch

* add into_iter

* remove unused Box and add pack methods

* fix non_std compilation

* non_std

* fix max_encoded_len recursion issue

* fix submodules

* reduce batch limit

* feat: add domain hook storage (#1928)

* refactor: add domain hook address storage

* tests: add gateway lp admin account checks

* refactor: use GetByKey

* fix: outboundq mock

* refactor: hook 20 bytes instead of 32

* fix cargo fmt

* Feat/lp v2 gateway queue (#1930)

* pallets: Add LP Gateway queue pallet

* lp-gateway-queue: Add benchmarks

* integration-tests: Add LP gateway tests

* docs: Update LP gateway queue entry

* lp-gateway-queue: Use default weight for PostDispatchInfo

* lp-gateway-queue: Add DEFAULT_WEIGHT_REF_TIME const, extract message processing logic, use BaseArithmetic for nonce

* runtime: Add defensive weights for LP gateway queue

* lint: Obey

* taplo: Obey

* pallet: Use DispatchResult for extrinsics

* runtime: Update benchmarks and weight info

* benchmarks: Add default for Message type (wip)

* pallet: Add Default bound to Message type

* lp-v2: fix message fields (#1933)

* fix: add remark call to borrow proxy

* fix: add missing message fields

* chore: bump to v0.13.3

* chore: update submodule

* chore: enable fixed tests

---------

Co-authored-by: Frederik Gartenmeister <mustermeiszer@posteo.de>

* refactor: cleanup my leftovers (#1935)

* LPv2: Bump-up foreign investment. Fix failing investment ITs  (#1934)

* increase version for foreign investments

* fix investment issue

* fix solidity call for transfers_tokens

* fix tests

* minimize required tranche investors for IT

* fix docs

* fix docs

* docs: fix hyperlink

* refactor: enable ITs for centrifuge + dev runtimes (#1938)

* fix: enable ITs for centrifuge + dev runtimes

* fmt

* fix: revert some centrifuge ITs

* fmt

* revert centrifuge addition to ITs

---------

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

---------

Co-authored-by: William Freudenberger <w.freude@icloud.com>
Co-authored-by: Cosmin Damian <17934949+cdamian@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
I9-release A specific release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants