Sei Oracle Price Feeder
Overview
The Sei Oracle Price Feeder is a mandatory component for validators in networks utilizing the Sei oracle module. It ensures accurate and timely exchange rate data submission by fetching real-time market prices, aggregating data across multiple providers, and submitting periodic on-chain votes following network specifications.
Failure to maintain an active price feeder results in validator jailing and slashing due to missing oracle votes. The system expects consistent vote broadcasts within each oracle vote period.
Core Functionality
The price feeder relies on several key processes:
-
Price Data Collection
- Queries multiple supported exchanges for real-time market data
- Processes raw price data through cleaning and aggregation pipelines
- Applies deviation thresholds to filter outliers
-
Vote Construction and Submission
- Monitors on-chain oracle parameters for vote timing
- Creates and signs MsgAggregateExchangeRateVote messages
- Broadcasts transactions via configured endpoints
-
Health Monitoring
- Exposes metrics and health check endpoints
- Integrates with external monitoring services
- Provides real-time price data access
Setup
Installing the Binary
cd sei-chain
make install-price-feeder
This compiles and copies the price-feeder binary to /usr/local/bin/.
Account Configuration
Create and configure a dedicated feeder account to prevent sequence errors and enhance security:
# Create feeder account
seid keys add price-feeder-delegate
export PRICE_FEEDER_DELEGATE_ADDR=$(seid keys show -a price-feeder-delegate)
# Assign feeder to validator
seid tx oracle set-feeder $PRICE_FEEDER_DELEGATE_ADDR --from <validator-wallet> \
--fees 2000usei -b block -y --chain-id sei-chain
# Fund feeder account
seid tx bank send <validator-wallet> $PRICE_FEEDER_DELEGATE_ADDR 1000000usei \
--fees=2000usei -b block -y
Automatic Signing
export PRICE_FEEDER_PASS=<your_password>
For systemd services, add this environment variable to the [Service] section.
Configuration Details
The price feeder uses a single TOML configuration file that defines all operational parameters. Let's examine each major component:
Complete Configuration Template
gas_adjustment = 1.5
gas_prices = "0.00125usei"
enable_server = true
enable_voter = true
[server]
listen_addr = "0.0.0.0:7171"
read_timeout = "20s"
verbose_cors = true
write_timeout = "20s"
[[deviation_thresholds]]
base = "ETH"
threshold = "2"
[[currency_pairs]]
base = "ETH"
chain_denom = "ueth"
providers = ["huobi", "crypto", "coinbase", "kraken", "okx"]
quote = "USDT"
[account]
address = "FEEDER_ADDR" # e.g. $PRICE_FEEDER_DELEGATE_ADDR
chain_id = "CHAIN_ID" # e.g. sei-testnet-2 or sei-mainnet-xyz
validator = "VALIDATOR_ADDR"
prefix = "sei"
[keyring]
backend = "os"
dir = "/root/.sei"
[rpc]
grpc_endpoint = "localhost:9090"
rpc_timeout = "100ms"
tmrpc_endpoint = "http://localhost:26657"
[telemetry]
enable_hostname = true
enable_hostname_label = true
enable_service_label = true
enabled = true
global_labels = [["chain_id", "sei-chain"]]
service_name = "price-feeder"
prometheus_retention = 60
[[provider_endpoints]]
name = "binance"
rest = "https://api1.binance.com"
websocket = "stream.binance.com:9443"
[[healthchecks]]
url = "https://hc-ping.com/your-uuid"
timeout = "5s"
gas_adjustment = 1.5
gas_prices = "0.00125usei"
enable_server = true
enable_voter = true
provider_timeout = "500ms"
[server]
listen_addr = "0.0.0.0:7171"
read_timeout = "20s"
write_timeout = "20s"
[[deviation_thresholds]]
base = "ETH"
threshold = "2"
[[currency_pairs]]
base = "ETH"
chain_denom = "ueth"
providers = ["binance", "kraken", "coinbase"]
quote = "USDT"
[account]
address = "$PRICE_FEEDER_DELEGATE_ADDR"
chain_id = "sei-chain"
validator = "VALIDATOR_ADDR"
prefix = "sei"
[keyring]
backend = "os"
dir = "/root/.sei"
[rpc]
grpc_endpoint = "localhost:9090"
rpc_timeout = "500ms"
tmrpc_endpoint = "<http://localhost:26657>"
[telemetry]
enabled = true
enable_hostname = true
enable_service_label = true
service_name = "price-feeder"
global_labels = [["chain_id", "sei-chain"]]
prometheus_retention = 120
[[provider_endpoints]]
name = "binance"
rest = "<https://api1.binance.com>"
websocket = "stream.binance.com:9443"
[[healthchecks]]
url = "<https://hc-ping.com/your-uuid>"
timeout = "5s"
Configuration Section Explanations
-
Root Level Settings
- The gas_adjustment value of 1.5 provides a 50% buffer above estimated gas requirements
- gas_prices defines the fee denomination and amount
- enable_server activates the HTTP metrics endpoint
- enable_voter controls price voting participation
-
Server Configuration
- listen_addr determines the network interface and port for metrics
- Timeout settings control request handling durations
- verbose_cors enables detailed access logging
-
Price Data Settings
- deviation_thresholds prevent outlier prices from affecting aggregation
- currency_pairs define trading pairs, on-chain denominations, and data sources
- provider_endpoints specify exchange API connection details
-
Chain Integration
- account settings link to your validator and network
- keyring configuration manages transaction signing
- rpc settings enable chain communication
-
Monitoring
- telemetry enables Prometheus metric collection
- healthchecks integrate with external monitoring
- Both systems help prevent missed votes
Deployment
Systemd Service Configuration
Example Systemd Service File
[Unit]
Description=Sei Price Feeder
After=network-online.target
[Service]
User=root
Type=simple
Environment="PRICE_FEEDER_PASS=YOUR_KEYRING_PASSWORD"
ExecStart=/usr/local/bin/price-feeder /root/price_feeder_config.toml
Restart=on-failure
RestartSec=3
LimitNOFILE=6553500
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable price-feeder
sudo systemctl start price-feeder
Monitoring and Maintenance
Health Monitoring Endpoints
When enable_server = true, these endpoints become available:
# Health check
curl -s http://127.0.0.1:7171/healthz
# Current prices
curl -s http://127.0.0.1:7171/prices
# Metrics
curl -s http://127.0.0.1:7171/metrics
Log Monitoring
Monitor service logs:
journalctl -fu price-feeder -o cat
Prometheus Integration
Example Alert Rules
groups:
- name: validator_alerts
rules:
- alert: OraclePriceFeedDelay
expr: time() - sei_oracle_price_timestamp > 300
labels:
severity: critical
Operational Best Practices
-
Redundancy and Accuracy
- Configure multiple price providers for reliable data
- Set appropriate deviation thresholds
- Maintain sufficient transaction fees
-
Performance Optimization
- Co-locate feeder with validator node
- Configure appropriate RPC timeouts
- Monitor system resource usage
-
Monitoring and Recovery
- Implement comprehensive metrics collection
- Configure alerting for missed votes
- Maintain automated restart procedures
-
Security Considerations
- Use dedicated feeder accounts
- Secure key storage configuration
- Regular security audits
Troubleshooting Guide
Common Issues
-
Missing Votes
- Check feeder account balance
- Verify RPC connectivity
- Review log files for errors
-
Price Deviations
- Examine provider data quality
- Review threshold configurations
- Check for market anomalies
-
System Problems
- Monitor resource usage
- Verify network connectivity
- Check disk space and I/O