๐ 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 |
|---|---|---|
| Restriction | Soft | Hard |
| Usable XP | โ Yes | โ No |
| Purpose | Allocation | Commitment |
| Pulse Impact | โ None | โก Accelerates future growth |
| Withdrawal | Flexible | Strict |
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:
XpReserveXpLock
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