Architecture
Overview
The Bloxchain Protocol is a unique blockchain security framework built around a state machine architecture that provides comprehensive security, access control, and transaction management capabilities. Unlike traditional smart contract patterns, Bloxchain uses a centralized state management system called SecureOperationState that acts as the core engine for all security operations.
Core Architecture Principles
1. State Machine Pattern
Bloxchain implements a centralized state machine where all security operations, access control, and transaction management flow through a single, well-defined state engine (SecureOperationState).
2. Unified Security Model
All Bloxchain contracts inherit from a common security foundation that provides:
Multi-phase transaction processing
Role-based access control (RBAC)
Time-locked operations
Meta-transaction support
Event forwarding
3. Modular Design
The framework is built with modularity in mind:
Core libraries provide foundational security
Definition libraries standardize operation types and schemas
Contract implementations inherit and extend core functionality
SecureOperationState: The Core Engine
The SecureOperationState struct is the heart of the Bloxchain protocol, acting as a comprehensive state machine that manages all aspects of secure operations.
State Machine Components
State Machine Responsibilities
1. Transaction Lifecycle Management
Request Phase: Transactions are submitted and validated
Pending Phase: Time-locked transactions wait for approval
Approval Phase: Authorized users can approve pending transactions
Execution Phase: Approved transactions are executed
Completion Phase: Transaction results are recorded and events emitted
2. Role-Based Access Control
Role Definition: Define custom roles with specific permissions and wallet limits
Permission Management: Grant/revoke permissions for functions and operations via batch configuration
Dynamic Role Assignment: Roles can be modified during contract lifecycle
Function-Level Permissions: Action-level permissions (request, approve, cancel, meta-sign, meta-execute)
Handler Selectors: Support for handler functions with execution selector permissions
3. Function Schema Management
Function Registration: Runtime function schema registration with action-level permissions
Function Schemas: Define function signatures, operation types, and supported actions
Handler Functions: Support for handler functions that manage execution selector permissions
Function Target Whitelisting: Per-function selector target address restrictions for security
Function Hooks: External hook contract attachment per function selector
4. Time-Lock Security
Configurable Time Locks: Set different time-lock periods for different operations
Multi-Phase Operations: Support for operations requiring multiple phases
Emergency Overrides: Built-in mechanisms for emergency situations
Audit Trail: Complete history of all time-locked operations
Architecture Layers
Layer 1: Core Libraries
Purpose: Provide foundational security and state management
EngineBlox.sol: Core state machine implementationSharedValidation.sol: Common validation functionsBaseDefinitionLoader.sol: Base functionality for definition loading
Layer 2: Definition Libraries
Purpose: Standardize operation types, function schemas, and role permissions
SecureOwnableDefinitions.sol: Standard definitions for ownership operationsRuntimeRBACDefinitions.sol: Standard definitions for RBAC operationsGuardControllerDefinitions.sol: Standard definitions for execution workflows
Layer 3: Base Contracts
Purpose: Provide foundational contract implementations
BaseStateMachine.sol: Core state machine functionality with meta-transaction supportSecureOwnable.sol: Multi-role security with Owner, Broadcaster, and Recovery rolesRuntimeRBAC.sol: Runtime role-based access control with batch configurationGuardController.sol: Execution workflows and time-locked transaction managementHookManager.sol: External hook contract attachment for state machine actions
Layer 4: Template Contracts
Purpose: Provide ready-to-use template implementations
AccountBlox.sol: Complete implementation with GuardController, RuntimeRBAC, and SecureOwnable
Layer 5: Application Contracts
Purpose: DApp-specific implementations using Bloxchain security
SimpleVault.sol: Example vault implementation using SecureOwnableSimpleRWA20.sol: Example RWA token implementation using SecureOwnable
State Machine Flow
1. Initialization Phase
2. Operation Request Phase
3. Approval Phase
4. Execution Phase
Key Benefits of State Machine Architecture
1. Centralized Security
All security logic flows through a single, audited state machine
Consistent security policies across all operations
Reduced attack surface through centralized validation
2. Predictable Behavior
Well-defined state transitions
Clear operation lifecycle
Deterministic security outcomes
3. Auditability
Complete transaction history
Clear state transitions
Comprehensive event logging
4. Flexibility
Configurable time locks
Dynamic role management
Custom operation types
Extensible permission system
5. Gas Efficiency
Optimized state management
Batch operations support
Efficient storage patterns
Integration with TypeScript SDK
The TypeScript SDK provides comprehensive interfaces to interact with Bloxchain contracts:
SecureOwnable Integration
RuntimeRBAC Integration
State Machine Security Features
1. Reentrancy Protection
State machine prevents reentrancy through centralized state management
All operations flow through validated state transitions
2. Access Control
Role-based permissions enforced at state machine level
Dynamic role management with audit trails
3. Time-Lock Security
Configurable time locks for different operation types
Multi-phase operation support
4. Meta-Transaction Support
Built-in support for meta-transactions
Nonce management for replay protection
5. Event Forwarding
Centralized event management
Comprehensive audit trails
Best Practices
1. State Machine Initialization
Always initialize the state machine after deployment
Configure appropriate time locks for your use case
Set up required roles and permissions
2. Operation Design
Design operations to follow state machine patterns
Use standardized operation types when possible
Implement proper validation for custom operations
3. Role Management
Follow principle of least privilege
Use role hierarchies for complex permission structures
Regularly audit role assignments
4. Time Lock Configuration
Set appropriate time locks for different operation types
Consider emergency override mechanisms
Document time lock policies
Conclusion
The Bloxchain Protocol's state machine architecture provides a robust, secure, and flexible foundation for blockchain applications. By centralizing security logic in the SecureOperationState engine, Bloxchain ensures consistent, auditable, and efficient security operations across all contract implementations.
The TypeScript SDK provides comprehensive tools for analyzing, validating, and interacting with Bloxchain contracts, making it easy for developers to leverage the full power of the Bloxchain state machine architecture.
Last updated
Was this helpful?