This is a monitoring and proxy service for the Optimism stack that:
- Monitors L1 deposits to the OptimismPortal contract
- Checks incoming addresses against a FrozenAccounts contract
- Blocks deposits from frozen accounts
- Monitors L2 deposit confirmations
- Collects metrics for Prometheus
- Acts as a JSON-RPC proxy for other services
rpc_proxy/
├── cmd/
│ └── server/
│ └── main.go # Entry point
├── internal/
│ ├── config/
│ │ └── config.go # Configuration loading
│ ├── ethereum/
│ │ ├── client.go # Ethereum client initialization
│ │ ├── events.go # Event definitions and processing
│ │ └── frozen.go # Checking frozen accounts
│ ├── metrics/
│ │ └── metrics.go # Prometheus metrics
│ ├── monitor/
│ │ ├── l1_monitor.go # L1 deposit monitoring
│ │ └── l2_monitor.go # L2 confirmation monitoring
│ └── proxy/
│ ├── handlers.go # RPC request/response handlers
│ └── server.go # Proxy server
├── pkg/
│ └── utils/
│ └── utils.go # Helper functions
├── .env # Environment variables (create from .env.example)
├── go.mod # Go module file
└── README.md # Project documentation
- Clone the repository
- Copy
.env.exampleto.envand update with your values - Run the following commands:
# Install dependencies
go mod download
# Build the application
go build -o rpc_proxy ./cmd/server
# Run the application
./rpc_proxyThe following environment variables need to be set in the .env file:
| Name | Description |
|---|---|
| L1_RPC_URL | Ethereum L1 RPC URL |
| L1_RPC_URL_WS | Ethereum L1 WebSocket URL for event subscription |
| L2_RPC_URL | Optimism L2 RPC URL |
| FROZEN_CONTRACT_ADDRESS | Address of the FrozenAccounts contract |
| OPTIMISM_PORTAL_ADDRESS | Address of the OptimismPortal contract |
| PROXY_PORT | Port for the RPC proxy server (default: 8545) |
| METRICS_PORT | Port for Prometheus metrics (default: 9100) |
The service exposes the following Prometheus metrics on http://localhost:{METRICS_PORT}/metrics:
| Metric | Description |
|---|---|
| opstack_total_deposits | Total number of deposits through OptimismPortal |
| opstack_blocked_deposits | Total number of blocked deposits from frozen accounts |
| opstack_deposit_value_total | Total ETH value of all deposits in wei |
| opstack_deposits_by_account | Number of deposits grouped by sender account |
After starting the service, you can:
- Use it as a drop-in replacement for your Ethereum RPC endpoint
- Monitor the logs for deposit information and frozen account checks
- Configure Prometheus to scrape the metrics endpoint
- Build Grafana dashboards using the exposed metrics