Skip to main content

๐Ÿ”’ Constraints (Lock & Reserve)

XP can be constrained to control how it is used inside the runtime.

Constraints do not transfer XP.

They define how XP may be used, restricted, or committed.

There are two types:

  • ๐Ÿ“ฆ Reserve -> soft constraint
  • ๐Ÿ”’ Lock -> hard constraint

These mechanisms allow runtime logic to treat XP as a programmable resource rather than passive stored value.


Why Constraints Existโ€‹

Constraints allow XP to be:

  • allocated for specific purposes
  • restricted from immediate use
  • protected from misuse
  • controlled by runtime logic
  • connected to protocol behavior

This makes XP useful for governance, staking, participation systems, and long-term commitment models.


๐Ÿ“ฆ 1. Reserve (Soft Constraint)โ€‹

Reserved XP is allocated, not strictly restricted.

It represents intent rather than hard restriction.

Reserved XP still contributes to usable XP and can be released later.

Characteristicsโ€‹

  • still part of usable XP
  • temporarily allocated for a purpose
  • can be unreserved later
  • does not directly affect Pulse growth

Reserve is useful when XP must be marked for participation without fully removing access.

Examplesโ€‹

  • ๐Ÿ—ณ๏ธ Governance voting
  • ๐Ÿ“œ Proposal deposits
  • ๐Ÿ“Š Temporary allocations
  • ๐Ÿงพ Participation requirements

Reserve expresses usage intent.


๐Ÿ”’ 2. Lock (Hard Constraint)โ€‹

Locked XP is strictly restricted.

It represents commitment rather than temporary allocation.

Locked XP cannot be partially used while active.

Characteristicsโ€‹

  • unavailable for normal usage
  • cannot be partially withdrawn
  • represents commitment or staking intent
  • improves future Pulse progression

Lock is stronger than reserve because it changes both access and growth behavior.

Examplesโ€‹

  • ๐Ÿฆ Staking
  • โณ Long-term commitments
  • โš™๏ธ Protocol restrictions
  • ๐Ÿ›ก๏ธ Security guarantees

Lock expresses commitment.


โš–๏ธ Reserve vs Lockโ€‹

Feature๐Ÿ“ฆ Reserve๐Ÿ”’ Lock
RestrictionSoftHard
Usable XPโœ… YesโŒ No
PurposeAllocationCommitment
Pulse ImpactโŒ Noneโšก Accelerates future growth
WithdrawalFlexibleStrict

Both are constraints, but they serve very different protocol purposes.

Note: Reserved XP remains part of the XP identity's usable balance, but is earmarked for a specific purpose.


๐Ÿง  Reason-Based Constraintsโ€‹

Both reserve and lock are tied to a reason identifier.

IdXp<Reason, Value>

This means every constrained amount of XP is linked to why it exists.

The system tracks both:

  • the amount
  • the purpose

This creates precise runtime control.

Why Reasons Matterโ€‹

Reasons provide:

  • multiple independent constraints
  • no conflicts across pallets
  • clear ownership of intent
  • safe interoperability

Without reasons, multiple systems would overwrite each other's state.

Reasons make constraints composable.


Substrate Composite Enum Integrationโ€‹

XP integrates naturally with Substrate's native patterns:

  • ๐Ÿงฑ HoldReason
  • ๐ŸงŠ FreezeReason

This allows external pallets to define their own reserve and lock reasons without modifying pallet-xp.

Exampleโ€‹

#[pallet::composite_enum]
enum MyReserveReason {
Governance,
Proposal,
}

#[pallet::composite_enum]
enum MyLockReason {
Staking,
Commitment,
}

Used as:

IdXp<MyReserveReason, Value>
IdXp<MyLockReason, Value>

Each pallet controls its own semantic meaning.

Architectureโ€‹

This keeps the system modular and avoids centralized constraint logic.

Why This Is Powerfulโ€‹

  • ๐Ÿงฉ Fully modular
  • โš™๏ธ Native Substrate compatibility
  • ๐Ÿ”Œ Easy integration across pallets
  • ๐Ÿ›ก๏ธ Safe constraint isolation

It enables many independent runtime systems to safely share the same XP layer.


๐Ÿ”Œ Trait Adapter Compatibilityโ€‹

XP exposes constraints through native XP traits:

  • XpReserve
  • XpLock

and also supports compatibility through:

  • ๐Ÿช™ fungible::hold
  • โ„๏ธ fungible::freeze

This allows existing balance-oriented pallets to work with XP without requiring custom rewrites.

Resultโ€‹

Other pallets can:

  • reuse existing balance logic
  • treat XP like a constrained balance abstraction
  • avoid writing custom adapters
  • integrate with XP using familiar Substrate patterns

This is one of the strongest design advantages of the pallet.


Constraint Lifecycleโ€‹

Constraints are reversible.

They shape behavior without changing ownership.


Key Propertiesโ€‹

1. Reason-Based Isolationโ€‹

Every constraint is scoped by a reason.

This prevents interference between independent runtime modules.

2. Composable Designโ€‹

Multiple pallets can reserve or lock XP independently.

No single pallet owns the entire constraint system.

3. Runtime Integrationโ€‹

The model follows native Substrate patterns instead of introducing custom abstractions.

This improves maintainability and compatibility.

4. Flexible Usageโ€‹

The system supports both:

  • soft allocation (reserve)
  • strict commitment (lock)

This allows protocol designers to choose the right behavioral model.


Final Insightโ€‹

โš™๏ธ Constraints make XP a programmable resource, not just stored value.

Reserve defines intent.

Lock defines commitment.

Together, they turn XP into a runtime-native behavioral primitive.


๐Ÿš€ Next Stepsโ€‹

To understand how the full system fits together:

๐Ÿ‘‰ Architecture -> Overview