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: Batch Message serialization #1920

Merged
merged 16 commits into from
Jul 22, 2024
Merged

LPv2: Batch Message serialization #1920

merged 16 commits into from
Jul 22, 2024

Conversation

lemunozm
Copy link
Contributor

@lemunozm lemunozm commented Jul 17, 2024

Description

This PR is related to the batch message support. The batch logic itself will be in a next PR.

Serialization Notes

We need a custom serialization/deserialization due to the spetial requirements of how batches needs to be serialized:

  • REQ 1: Have the size of each submessage before the submessage as u16.
    • Technically, this is not needed for us because we know the structure of the message to deserialize.
    • Our workaround to get the message size is to serialize with our data format inside of the the serialization process.
  • REQ 2: Not having a number indicating the size of the batch
    • Technically, this is required for us. We need to know the size of the batch and how many submessages we need to deserialize. Without that information means that we enter the deserialization logic with no idea of how to finish.
    • The workaround solution is to finish when we find an error (an "unexpected EOF") deserializing the next length of a submessage.

Changes

  • Custom Batch serialization/deserialization
  • Type system protection to avoid nested batches

Next PR

  • Add Gateway::start_pack_batch() and Gateway::end_pack_batch()
  • Gateway required changes (new storage to keep at least the boolean state of above)
  • LPEncoding utilities to allow the Gateway to compose messages into batches without knowing the concrete Message type.

@lemunozm lemunozm self-assigned this Jul 17, 2024
@lemunozm lemunozm marked this pull request as ready for review July 18, 2024 10:03
@lemunozm
Copy link
Contributor Author

As a first step for the bench message feature, this should be ready.

@lemunozm lemunozm requested review from wischli, mustermeiszer and cdamian and removed request for wischli and mustermeiszer July 18, 2024 11:42
@lemunozm lemunozm changed the title WIP Lpv2: Batch Message serialization LPv2: Batch Message serialization Jul 18, 2024
Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 58.06452% with 26 lines in your changes missing coverage. Please review.

Project coverage is 46.15%. Comparing base (976eebe) to head (a771a96).

Files Patch % Lines
pallets/liquidity-pools/src/message.rs 54.71% 24 Missing ⚠️
pallets/liquidity-pools/src/gmpf/error.rs 33.33% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           feat/lp-v2    #1920      +/-   ##
==============================================
+ Coverage       45.97%   46.15%   +0.17%     
==============================================
  Files             179      179              
  Lines           12791    12849      +58     
==============================================
+ Hits             5881     5930      +49     
- Misses           6910     6919       +9     

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

@lemunozm
Copy link
Contributor Author

@mustermeiszer @wischli this is ready to review/merge. The logic itself goes in a nex PR

pallets/liquidity-pools/src/message.rs Outdated Show resolved Hide resolved
pallets/liquidity-pools/src/message.rs Show resolved Hide resolved
pallets/liquidity-pools/src/message.rs Show resolved Hide resolved
pallets/liquidity-pools/src/message.rs Show resolved Hide resolved
pallets/liquidity-pools/src/message.rs Show resolved Hide resolved
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.

LGTM! Great PR

@lemunozm lemunozm merged commit 69af655 into feat/lp-v2 Jul 22, 2024
9 checks passed
@lemunozm lemunozm deleted the lpv2/batch-message branch July 22, 2024 14:35
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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants