Skip to content

Comments

Settlement Locking#1818

Merged
Neopallium merged 11 commits intodevelopfrom
settlement-small-improvements
May 22, 2025
Merged

Settlement Locking#1818
Neopallium merged 11 commits intodevelopfrom
settlement-small-improvements

Conversation

@HenriqueNogara
Copy link
Contributor

@HenriqueNogara HenriqueNogara commented Apr 29, 2025

changelog

new features

  • Adds a new workflow for SettleAfterLock instructions;

new external API

  • Added the MaximumLockPeriod associated type to the settlement pallet;
  • Added the following storage to the settlement pallet: LockedTimestamp;
  • Added the following extrinsic to the settlement pallet: lock_instruction;
  • Added the following runtime api: lock_instruction_weight, instruction_asset_count;

new events

  • Added the InstructionLocked variant to the settlement pallet;

other

  • venue_for_management is now called ensure_venue_creator;
  • Improve reject_instruction weight calculation;
  • Improve prune_instruction performance;
  • Add ensure_valid_caller function for removing code duplication;
  • Adds the following errors to the settlement pallet: UnexpectedSettlementType, InvalidInstructionStatusForRejection;
  • Added the following error variants to the settlement pallet: LockTimestampNotFound, ExceededMaximumLockingPeriod, FailedAssetTransferringConditions;

@HenriqueNogara HenriqueNogara requested a review from Copilot April 29, 2025 12:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a set of small improvements and refactorings in the settlement module. Key changes include:

  • Renaming of "venue_for_management" to "ensure_venue_creator" and the addition of a new "ensure_valid_caller" function to reduce code duplication.
  • Refinement of weight calculation functions, including new functions (prune_instruction, valid_caller_portfolio, valid_caller_venue, valid_caller_mediator) and updated arithmetic in reject_instruction_common.
  • Updates to error types and benchmarking tests to align error messages and expected outcomes with the new logic.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pallets/weights/src/pallet_settlement.rs Refactored weight functions and removed deprecated reject_instruction.
pallets/settlement/src/benchmarking.rs Added benchmarks for the new caller-validating functions and instruction pruning.
pallets/runtime/tests/src/settlement_test.rs Updated tests to reflect error renaming and changes in behavior.
Comments suppressed due to low confidence (2)

pallets/weights/src/pallet_settlement.rs:1118

  • The write multipliers in reject_instruction_common have been significantly reduced compared to the previous implementation. Please verify that the revised weight increments accurately reflect the intended resource costs.
.saturating_add(DbWeight::get().writes(1))

pallets/runtime/tests/src/settlement_test.rs:2450

  • The error type was updated from Error::Unauthorized to Error::CallerIsNotAParty. Ensure that this change is reflected in the documentation and that all parts of the codebase consistently use the new error code.
error: Error::CallerIsNotAParty.into()

@HenriqueNogara HenriqueNogara force-pushed the settlement-small-improvements branch from 302aabd to 6d1de4d Compare May 1, 2025 12:53
…_management

Run benchmarks

Add ensure_valid_cost check back
* Add lock instruction; Allow manual execution for locked instructions; Add simplified transfer

* Add lock_instruction common benchmark

* Improve benchmarks

* Add unit tests

* Add sample weights

* Add rpc calls

* Remove useless test

* Fix benchmarks
@Neopallium Neopallium force-pushed the settlement-small-improvements branch from df5ef0e to 2b42b65 Compare May 6, 2025 11:04
@HenriqueNogara HenriqueNogara changed the title Settlement small improvements Settlement Locking May 10, 2025
@HenriqueNogara HenriqueNogara requested a review from Neopallium May 20, 2025 18:00
@Neopallium Neopallium merged commit 6a62eca into develop May 22, 2025
17 checks passed
@Neopallium Neopallium deleted the settlement-small-improvements branch May 22, 2025 17:36
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