Skip to content

Settlement Locking 2nd Approach #1820

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

Merged
merged 8 commits into from
May 5, 2025

Conversation

HenriqueNogara
Copy link
Contributor

@HenriqueNogara HenriqueNogara commented Apr 30, 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

  • Added the following error variants to the settlement pallet: LockTimestampNotFound, ExceededMaximumLockingPeriod, FailedAssetTransferringConditions;

@HenriqueNogara HenriqueNogara force-pushed the settlement-small-improvements branch from 302aabd to 6d1de4d Compare May 1, 2025 12:53
@HenriqueNogara HenriqueNogara changed the title WIP: Add lock instruction; Allow manual execution for locked instructions;… WIP: Settlement Locking 2nd Approach May 1, 2025
@HenriqueNogara HenriqueNogara force-pushed the locking-2nd-approach branch from efa3519 to 021cb98 Compare May 1, 2025 13:07
@HenriqueNogara HenriqueNogara requested a review from Copilot May 2, 2025 17:40
Copy link

@Copilot 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 new workflow for settlement locking and extends the settlement pallet with additional API endpoints, error variants, and runtime/storage configurations to support lock-based instruction processing. Key changes include:

  • Adding new extrinsics and RPC methods (lock_instruction_weight, instruction_asset_count) along with corresponding runtime API definitions.
  • Updating error variants and arithmetic operations (using saturating operations) to improve reliability.
  • Modifying benchmarks and tests to cover the new settlement locking workflow and updating runtime constants (e.g. MaximumLockPeriod).

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rpc/src/settlement.rs Adds new RPC methods and adjusts API calls for lock_instruction_weight and instruction_asset_count.
rpc/runtime-api/src/settlement.rs Updates API signatures and documentation to expose new runtime methods.
primitives/src/settlement.rs Adjusts derive macros and adds new settlement variants (LockedForExecution, SettleAfterLock).
pallets/sto/src/lib.rs Removes unused WeightMeter parameter in asset transfers.
pallets/settlement/src/benchmarking.rs Updates benchmarks to test the new locking flow and changes asset count ranges.
pallets/runtime/tests/* Updates tests to reflect new error variants and locking behavior.
pallets/runtime/* Adds MaximumLockPeriod constant and integrates new runtime APIs.
pallets/nft/src/lib.rs & pallets/asset/src/lib.rs Replaces direct arithmetic with saturating methods and adds simplified transfer functions.
Comments suppressed due to low confidence (1)

pallets/runtime/common/src/runtime.rs:1164

  • [nitpick] The function name 'get_execute_instruction_info' implies that it returns execute instruction details, but it calls 'manual_execution_weight'. Consider ensuring that the naming of the API aligns with its functionality or updating it for clarity.
fn get_execute_instruction_info(instruction_id: InstructionId) -> Option<ExecuteInstructionInfo> { Settlement::manual_execution_weight(instruction_id) }

@@ -468,8 +468,7 @@ benchmarks! {
}: _(alice.origin, InstructionId(1), receipt_details, portfolios)

execute_manual_instruction {
Copy link
Preview

Copilot AI May 2, 2025

Choose a reason for hiding this comment

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

[nitpick] The change to begin the test range at 0 (instead of 1) for fungible assets may be intentional to test edge-case scenarios. Consider adding a brief comment to clarify that this edge-case is deliberate.

Suggested change
execute_manual_instruction {
execute_manual_instruction {
// Start the range at 0 to deliberately test edge-case scenarios for fungible assets.

Copilot uses AI. Check for mistakes.

@HenriqueNogara HenriqueNogara changed the title WIP: Settlement Locking 2nd Approach Settlement Locking 2nd Approach May 2, 2025
@HenriqueNogara HenriqueNogara requested a review from Neopallium May 2, 2025 17:46
@Neopallium Neopallium mentioned this pull request May 5, 2025
@Neopallium Neopallium merged commit df5ef0e into settlement-small-improvements May 5, 2025
17 checks passed
@Neopallium Neopallium deleted the locking-2nd-approach branch May 5, 2025 12:22
@Neopallium
Copy link
Contributor

Merged into PR #1818 for easier review.

Neopallium pushed a commit that referenced this pull request May 6, 2025
* 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
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