Configuration File Format
Ubu-Block uses TOML configuration files. Create aconfig.toml file in your node directory:
Configuration Structure
The configuration is defined incrates/types/src/config.rs:7-15:
Core Options
Database Configuration
main_db
Connection string for the main blockchain database. Stores blocks, transactions, and electoral data.
- SQLite:
sqlite://path/to/database.db - In-memory SQLite:
sqlite::memory: - Relative paths:
sqlite://../../data/blockchain.db - Absolute paths:
sqlite:///home/user/data/blockchain.db
private_db
Connection string for the private database. Stores node-specific data not shared with the network.
Network Configuration
node_addr
Address and port for the P2P network interface. Used for blockchain protocol communications.
IP:PORT
- Use
127.0.0.1for localhost only - Use
0.0.0.0to listen on all interfaces - Port range: 1024-65535 (avoid privileged ports)
http_addr
Address and port for the HTTP API server. Used for REST API endpoints.
IP:PORT
Peer Configuration
peers
Map of peer names to addresses. The node will attempt to connect to all listed peers on startup.
- Peer names (keys) are arbitrary identifiers
- Values must be valid socket addresses
- Connections are established asynchronously
- Failed connections are logged but don’t stop startup
P2P Protocol Configuration
peer_config
Advanced P2P network settings. Uses defaults if not specified.
crates/types/src/p2p.rs:94-112:
| Option | Type | Default | Description |
|---|---|---|---|
max_peers | integer | 50 | Maximum number of peer connections |
ping_interval_secs | integer | 30 | Seconds between keep-alive pings |
connection_timeout_secs | integer | 10 | Connection timeout in seconds |
sync_batch_size | integer | 100 | Number of blocks per sync batch |
max_message_size | integer | 10485760 | Maximum message size in bytes (10MB) |
Configuration Examples
Single Submission Node
Submission Node with Peers
Production Configuration
Development Multi-Node Setup
config1.toml:Loading Configuration
Configuration files are loaded at startup using the--config flag:
nodes/submission/src/main.rs:23-28:
Environment Variables
While most configuration is in TOML files, some settings use environment variables:RUST_LOG
Controls logging verbosity:
Configuration Validation
The node validates configuration on startup:Required fields:
main_db- Always requiredprivate_db- Always requirednode_addr- Required for submission nodeshttp_addr- Required for submission nodes
Security Best Practices
Database Security
Database Security
- Use absolute paths for production databases
- Set appropriate file permissions (600 for database files)
- Regular database backups
- Separate main and private databases
- Use encrypted storage for sensitive data
Network Security
Network Security
- Bind to
127.0.0.1for local-only access - Use firewall rules to restrict P2P ports
- Keep HTTP API on internal network only
- Use reverse proxy for external access
- Enable TLS for production deployments
Peer Security
Peer Security
- Only connect to trusted peers
- Verify peer certificates (when implemented)
- Monitor peer connection logs
- Set reasonable max_peers limit
- Use peer allowlists for production
Troubleshooting
Configuration File Not Found
Invalid TOML Syntax
- Check for missing quotes around strings
- Verify table headers use
[section]format - Ensure key-value pairs use
=separator - Use a TOML validator online
Port Already in Use
Database Connection Failed
- Ensure the directory exists:
mkdir -p data - Check file permissions
- Verify SQLite is installed
- Use absolute paths for production
Next Steps
Observer Node
Run an observer node
Submission Node
Run a submission node
Verification Node
Learn about verification