You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This RFC proposes enhancing current halt system with an extensible architecture. This enhancement will enable flexible addition and management of various halt policies.
2. Motivation
Need for flexible halt policies to respond to various real-world conditions
Extensiblity requirement for halt policies as new features are added
Systematic halt policy management and improved testability
Need for fine-grained control mechanisms to protect user assets
3. Design Principles
Easy-to-Extent: Both single and composite policies can be easily added, modified, and extended.
Type safety guarantees: Ensure reliable policy evaluation through a strongly typed system.
Functional Style: By adopting a functional style, the policy evaluation logic is clear and easy-to-test.
Composite Policy Support: Multiple halt policies can be combined through logical operators such as AND/OR. (Optional)
4. Technical Specification
4.1 Core Interface
Operation Interface
The Operation interface defines the contract for protocol operations that can be subject to halt conditions. It provides a standardized way to identify and describe different types of operations in the system.
The HaltLevel interface defines the contract for different halt states in the system. It encapsulates the logic for determining which operations are allowed under specific halt conditions.
typeHaltLevelinterface {
Level() uint8// Returns the numeric level of the halt stateName() string// Returns a human-readable name for the halt levelDescription() string// Provides a detailed description of the halt levelIsOperationAllowed(Operation) bool// Determines if a given operation is permitted at this halt level
}
4.2 Base Implementations
Basic Operation
BasicOperation provides a standard implementation of the Operation interface. It serves as a base structure for defining protocol operations.
BasicHaltLevel provides a standard implementation of the HaltLevel interface. It implements a simple permission-based system using a map of allowed operations.
Support for combining multiple halt policies. by setting and AND or OR value in the operator field to determine whether all or only one of the child policies should be allowed.
The HaltManager is the central component that coordinates the halt system. It maintains the current halt state and manages the registration and lookup of operations and halt levels.
Providing a centralized point for halt-related queries
5. Usage Example
5.1 Basic Usage
// Usage in Mint functionfuncMint(...) {
common.AssertOperation(OpTypeLiquidity)
// ...
}
// Usage in Swap functionfuncSwap(...) {
common.AssertOperation(OpTypeSwap)
// ...
}
5.2 Adding New Operation
// Define new operation typeconstOpTypeNewFeatureOperationType="someFeature"// Register operationmanager.RegisterOperation(NewOperation(
OpTypeNewFeature,
"NewFeature",
"new feature operations"
))
5.3 Adding New Halt-Levels
// Define and register new halt levelmanager.RegisterHaltLevel(NewHaltLevel(
4, // level"NewFeatureHalt",
"New features disabled, other operations allowed",
map[OperationType]bool{
OpTypeSwap: true,
OpTypeLiquidity: true,
OpTypeWithdraw: true,
OpTypeNewFeature: false,
}
))
Whether the current transition rules that only allow one step are sufficient,
or if additional transition constraints are needed (e.g., logging, limiting the time interval between transitions).
Event Logging Enhancements:
Is there a need to enhance auditing by including additional metadata such as state transitions, timestamps, transaction IDs, etc.
The text was updated successfully, but these errors were encountered:
1. Overview
This RFC proposes enhancing current
halt
system with an extensible architecture. This enhancement will enable flexible addition and management of various halt policies.2. Motivation
3. Design Principles
AND
/OR
. (Optional)4. Technical Specification
4.1 Core Interface
Operation Interface
The
Operation
interface defines the contract for protocol operations that can be subject to halt conditions. It provides a standardized way to identify and describe different types of operations in the system.Halt-Level Interface
The
HaltLevel
interface defines the contract for different halt states in the system. It encapsulates the logic for determining which operations are allowed under specific halt conditions.4.2 Base Implementations
Basic Operation
BasicOperation
provides a standard implementation of theOperation
interface. It serves as a base structure for defining protocol operations.Basic Halt-Level
BasicHaltLevel
provides a standard implementation of theHaltLevel
interface. It implements a simple permission-based system using a map of allowed operations.Compoisite Halt-Level
Support for combining multiple halt policies. by setting and
AND
orOR
value in the operator field to determine whether all or only one of the child policies should be allowed.Halt Manager
The
HaltManager
is the central component that coordinates the halt system. It maintains the current halt state and manages the registration and lookup of operations and halt levels.Key responsibilities of the
HaltManager
include:5. Usage Example
5.1 Basic Usage
5.2 Adding New Operation
5.3 Adding New Halt-Levels
5.4 Implementing Custom Halt Policies
6. Default Halt-Levels
NoHalt
SwapHalt
LiquidityHalt
EmergencyHalt
CompleteHalt
7. Security Considerations
7.1 Access Control
7.2 State Change Control
8. Open Questions
or if additional transition constraints are needed (e.g., logging, limiting the time interval between transitions).
The text was updated successfully, but these errors were encountered: