Commit d0de085d authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #5739 from ethereum-optimism/felipe/cache-fix-b

fix(proxyd): clean up cache initialization
parents 4f228fe9 3eaf194c
...@@ -26,9 +26,7 @@ type ServerConfig struct { ...@@ -26,9 +26,7 @@ type ServerConfig struct {
} }
type CacheConfig struct { type CacheConfig struct {
Enabled bool `toml:"enabled"` Enabled bool `toml:"enabled"`
BlockSyncRPCURL string `toml:"block_sync_rpc_url"`
NumBlockConfirmations int `toml:"num_block_confirmations"`
} }
type RedisConfig struct { type RedisConfig struct {
......
...@@ -10,8 +10,6 @@ namespace = "proxyd" ...@@ -10,8 +10,6 @@ namespace = "proxyd"
[cache] [cache]
enabled = true enabled = true
block_sync_rpc_url = "$GOOD_BACKEND_RPC_URL"
[backends] [backends]
[backends.good] [backends.good]
......
...@@ -9,7 +9,6 @@ import ( ...@@ -9,7 +9,6 @@ import (
"time" "time"
"github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
...@@ -206,27 +205,12 @@ func Start(config *Config) (*Server, func(), error) { ...@@ -206,27 +205,12 @@ func Start(config *Config) (*Server, func(), error) {
rpcCache RPCCache rpcCache RPCCache
) )
if config.Cache.Enabled { if config.Cache.Enabled {
if config.Cache.BlockSyncRPCURL == "" {
return nil, nil, fmt.Errorf("block sync node required for caching")
}
blockSyncRPCURL, err := ReadFromEnvOrConfig(config.Cache.BlockSyncRPCURL)
if err != nil {
return nil, nil, err
}
if redisClient == nil { if redisClient == nil {
log.Warn("redis is not configured, using in-memory cache") log.Warn("redis is not configured, using in-memory cache")
cache = newMemoryCache() cache = newMemoryCache()
} else { } else {
cache = newRedisCache(redisClient, config.Redis.Namespace) cache = newRedisCache(redisClient, config.Redis.Namespace)
} }
// Ideally, the BlocKSyncRPCURL should be the sequencer or a HA replica that's not far behind
ethClient, err := ethclient.Dial(blockSyncRPCURL)
if err != nil {
return nil, nil, err
}
defer ethClient.Close()
rpcCache = newRPCCache(newCacheWithCompression(cache)) rpcCache = newRPCCache(newCacheWithCompression(cache))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment