EchoEVM Configuration Guide
This document describes the configuration options available in EchoEVM and how to customize them.
Configuration Sources
EchoEVM supports configuration through multiple sources in the following order of precedence:
- Command line flags (highest priority)
- Environment variables
- Default constants (lowest priority)
Environment Variables
You can override default configuration values using the following environment variables:
Network Configuration
ECHOEVM_ETHEREUM_RPC: Ethereum RPC endpoint (default:https://cloudflare-eth.com)
Logging Configuration
ECHOEVM_LOG_LEVEL: Log level (default:info)ECHOEVM_LOG_FORMAT: Log format - "json" or "console" (default:console)ECHOEVM_LOG_OUTPUT: Log output - "stdout", "stderr", or file path (default:stdout)
EVM Configuration
ECHOEVM_GAS_LIMIT: Default gas limit for transactions (default:15000000)ECHOEVM_BLOCK_GAS_LIMIT: Default gas limit for blocks (default:15000000)ECHOEVM_CHAIN_ID: Default chain ID (default:1)ECHOEVM_EXECUTION_MODE: Default execution mode (default:full)
API Configuration
ECHOEVM_API_NAMESPACE: Default API namespace (default:eth)ECHOEVM_API_VERSION: Default API version (default:1.0)ECHOEVM_API_PUBLIC: Default API public flag (default:true)
Usage Examples
Setting Log Level
Setting Gas Limit
Setting Ethereum RPC Endpoint
Using JSON Logging
Configuration Constants
The following constants are defined in internal/config/constants.go:
EVM Constants
StackLimit: Maximum stack size (1024)DefaultGasLimit: Default transaction gas limit (15000000)DefaultBlockGasLimit: Default block gas limit (15000000)LogsBloomSize: Logs bloom filter size (256)DefaultTimestamp: Default block timestamp (1640995200)
Network Constants
DefaultEthereumRPC: Default Ethereum RPC endpoint ("https://cloudflare-eth.com")DefaultChainID: Default chain ID (1)
Logging Constants
DefaultLogLevel: Default log level ("info")DefaultLogFormat: Default log format ("console")DefaultLogOutput: Default log output ("stdout")DefaultLogComponent: Default log component ("echoevm")DefaultLogVersion: Default log version ("1.0.0")DefaultLogTimeFormat: Default log time format (time.RFC3339)DefaultLogFileMode: Default log file mode (0666)
API Constants
DefaultAPINamespace: Default API namespace ("eth")DefaultAPIVersion: Default API version ("1.0")DefaultAPIPublic: Default API public flag (true)
Execution Constants
DefaultExecutionMode: Default execution mode ("full")DefaultGasPrice: Default gas price (20000000000)DefaultValue: Default transaction value (0)
File Constants
DefaultFileMode: Default file mode (0644)DefaultDirectoryMode: Default directory mode (0755)
Best Practices
-
Use Environment Variables: For production deployments, use environment variables to configure the application rather than hardcoding values.
-
Logging: Use JSON format for production logging to enable better log aggregation and analysis.
-
Security: Be careful with file permissions when logging to files. The default file mode is 0666, but you may want to use more restrictive permissions in production.
-
Performance: Adjust gas limits and upstream RPC endpoints based on your specific use case and network conditions.
-
Monitoring: Use appropriate log levels to balance between debugging information and performance.
Migration from Hardcoded Values
If you're migrating from a version with hardcoded values, you can:
- Set environment variables to match your previous hardcoded values
- Gradually adjust them based on your new requirements
- Use the configuration system to make your deployment more flexible
Troubleshooting
Configuration Not Applied
- Check that environment variables are set before running the command
- Verify that the environment variable names are correct (case-sensitive)
- Ensure that the values are in the correct format
Invalid Values
- Gas limits must be positive integers
- Boolean values must be "true" or "false"
- Log levels must be one of: "trace", "debug", "info", "warn", "error"
Performance Issues
- Increase gas limits if transactions are failing due to out-of-gas errors
- Use appropriate log levels to reduce logging overhead