Neo N3 Service Layer

A centralized oracle service for the Neo N3 blockchain, providing functions execution in TEE, contract automation, price feeds, and more.
Features
- Functions Service: JavaScript functions execution in a Trusted Execution Environment (TEE)
- Secret Management: Secure storage and usage of user secrets
- Contract Automation: Event-based triggers for smart contract functions
- Gas Bank: Efficient gas management for service operations
- Random Number Generation: Secure random number generation for contracts
- Price Feed: Regular on-chain token price updates
- Oracle Service: Bringing external data to Neo N3 blockchain
Architecture
The Neo N3 Service Layer is built on Azure Confidential Computing for TEE capabilities and uses a modular architecture:
- API Layer: RESTful endpoints for user interaction
- Core Services: Business logic for all features
- TEE Environment: Secure execution of user functions and storage of secrets
- Neo N3 Blockchain Interface: Communication with Neo N3 blockchain
- Web Dashboard: Comprehensive user interface for service management
Current Development Status
The project is nearly complete with all core functionality implemented. We have successfully completed:
- Core services implementation (Functions, Secrets, Automation, Oracle, Price Feed, Random Number, Gas Bank)
- TEE integration with Azure Confidential Computing
- Transaction Management System for reliable blockchain interaction
- Web Dashboard with comprehensive user interfaces for all services
- API integration for all service components
- Neo N3 blockchain interface and smart contract integration
For a detailed view of the implementation status and next steps, see:
Compatibility Strategy
The service layer depends on several external dependencies, including the Neo-Go SDK, which may undergo API changes between versions. To handle this, we've implemented a compatibility layer approach:
- Isolation of External Dependencies: All direct interactions with external SDKs are wrapped in our compatibility layers in
internal/[package]/compat/ directories.
- Versioning: The
go.mod file explicitly defines the versions of dependencies we support.
- Adaptation: When upgrading dependencies, we update the compatibility layer rather than changing our core business logic.
For more details, see our compatibility documentation.
Recent Updates
- Fixed JavaScript runtime execution environment for TEE
- Added configuration fields for Azure Confidential Computing
- Created a compatibility layer for Neo-Go SDK
- Fixed import path conflicts and type duplication issues
- Added comprehensive documentation for components and their implementation status
For a detailed list of issues and their solutions, see SERVICE_LAYER_ISSUES.md.
Getting Started
Prerequisites
- Go 1.22 or higher
- Docker and Docker Compose
- PostgreSQL 14 or higher
- Redis 6 or higher
- Azure account with Confidential Computing capabilities
- Node.js 18+ and npm for web dashboard
Installation
-
Clone the repository:
git clone https://github.com/R3E-Network/service_layer.git
cd service_layer
-
Install dependencies:
go mod download
cd web && npm install && cd ..
-
Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
-
Start the development environment:
docker-compose up -d
-
Run database migrations:
make migrate-up
-
Start the server and web dashboard:
make run-all
Development
Project Structure
service_layer/
├── cmd/ # Command-line applications
├── configs/ # Configuration files
├── contracts/ # Sample Neo N3 contracts
├── docs/ # Documentation
├── internal/ # Private application code
│ ├── api/ # API handlers and routes
│ ├── config/ # Configuration structures
│ ├── core/ # Core business logic
│ ├── db/ # Database access
│ ├── models/ # Data models
│ └── tee/ # TEE integration
├── pkg/ # Public libraries
├── scripts/ # Utility scripts
├── tests/ # Test suites
└── web/ # Web dashboard application
├── public/ # Static assets
└── src/ # React application code
├── components/ # Reusable UI components
├── pages/ # Service-specific pages
└── services/ # API integration services
Running Tests
make test
Building for Production
make build
Documentation
The project includes comprehensive documentation:
Web Dashboard
The web dashboard provides a comprehensive user interface for all services:
- Functions management and execution
- Secrets storage and management
- Oracle data source configuration
- Price feed monitoring and configuration
- Random number generation and verification
- Gas bank balance and transaction management
- Contract automation trigger management
Access the dashboard at http://localhost:3000 when running in development mode.
API Documentation
API documentation is available at /swagger/index.html when the server is running. You can also find detailed API specifications in the docs/api directory.
Smart Contract Integration
For examples of how to integrate Neo N3 smart contracts with the Service Layer, see the following documentation:
Sample contracts can be found in the contracts directory.
Security
The Neo N3 Service Layer prioritizes security:
- All sensitive operations occur within the TEE
- User secrets are encrypted and only accessible within the TEE
- Authentication and authorization for all API endpoints
- Regular security audits and updates
- Secure transaction management for blockchain interactions
Security Testing Automation
We have implemented comprehensive security testing automation to ensure continuous validation of security controls:
- Automated Security Scanning: Scripts for scanning code, dependencies, and APIs for vulnerabilities
- CI/CD Integration: Security testing integrated into the CI/CD pipeline via GitHub Actions
- Vulnerability Management: Systematic approach to tracking and addressing security findings
Run security tests with:
make security-test
For more details, see:
Contributing
We welcome contributions from the community! Please read our Contributing Guidelines for details on the process for submitting pull requests to us, and our Code of Conduct for guidelines on community interaction.
Security
See the Security Policy for reporting security vulnerabilities and our approach to security.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Changelog
See the Changelog for a list of notable changes for each version of the project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments