dshackle overrides: read chain-level disables from .env (DSHACKLE_<CHAIN>_METHOD_GROUPS_DISABLED) - flows from host_vars env_overrides through the standard envfile pipeline; host-local yaml remains as secondary source

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
rob
2026-07-10 15:05:27 +00:00
parent f85b2f457f
commit 091a759367

View File

@@ -65,10 +65,40 @@ def apply(upstream, ov):
return changed return changed
ENVFILE = '/root/rpc/.env'
def env_overrides():
"""Chain-level overrides from .env (rendered from host_vars env_overrides):
DSHACKLE_<CHAIN>_METHOD_GROUPS_DISABLED=trace,debug
DSHACKLE_<CHAIN>_METHODS_DISABLED=eth_getFilterLogs
<CHAIN> = dshackle chain name, upper, '-' -> '_' (e.g. BASE, ETH_BEACON_CHAIN)."""
spec = {}
if not os.path.exists(ENVFILE):
return spec
import re as _re
for line in open(ENVFILE):
m = _re.match(r'DSHACKLE_([A-Z0-9_]+)_(METHOD_GROUPS|METHODS)_DISABLED=(.*)', line.strip())
if not m:
continue
chain = m.group(1).lower().replace('_', '-')
key = 'method_groups_disabled' if m.group(2) == 'METHOD_GROUPS' else 'methods_disabled'
vals = [v.strip() for v in m.group(3).split(',') if v.strip()]
if vals:
spec.setdefault(f'chain:{chain}', {}).setdefault(key, []).extend(vals)
return spec
def main(): def main():
if not os.path.exists(OVERRIDES): spec = env_overrides()
return if os.path.exists(OVERRIDES):
spec = (yaml.safe_load(open(OVERRIDES)) or {}).get('upstreams') or {} for k, v in ((yaml.safe_load(open(OVERRIDES)) or {}).get('upstreams') or {}).items():
cur = spec.setdefault(k, {})
for kk, vv in (v or {}).items():
if isinstance(vv, list):
cur[kk] = sorted(set((cur.get(kk) or []) + vv))
else:
cur.setdefault(kk, vv)
if not spec: if not spec:
return return
total = 0 total = 0