Move all business/round parameters into DB config, out of env entirely
RoundConfig gains round_duration_seconds, round_cooldown_seconds, min_amount_sats, fee_rate_sat_vb and rbf_timeout_seconds (plus a hardcoded default for the pre-existing bet_amount_sats) as column defaults on the model itself — get_round_config no longer seeds from Settings at all. Every call site that read these from settings (scheduler, bets, withdrawals, rounds service/route, RBF bumper) now reads the DB-backed RoundConfig instead. app/config.py now holds only true env-driven infra/secrets (database URL, Electrum connection, master key, JWT, admin token) — no business parameter has an env var anymore, matching an explicit decision to drop the "seed from settings" indirection entirely rather than keep a env fallback nobody should rely on. Migration backfills the existing round_config row via server_default (matching the old settings defaults) then drops the default, so future rows go through the ORM/model defaults instead of a stale constant. Tests updated: should_bump's timeout_seconds is now required (no settings fallback); test_scheduler.py seeds a RoundConfig row directly instead of monkeypatching settings; test_withdrawals.py and test_rounds_service.py use local constants mirroring the model defaults instead of reading them off settings. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+11
-4
@@ -74,15 +74,22 @@ class RoundParticipant(Base):
|
||||
class RoundConfig(Base):
|
||||
"""Single-row operational config, DB-backed so it's editable without a redeploy.
|
||||
|
||||
round_duration is intentionally NOT here: it stays env-var-driven per spec.
|
||||
Don't move it here without an explicit decision to change that.
|
||||
"""
|
||||
Everything business/round-related lives here (round timing, bet amount, fee
|
||||
rate, RBF timeout, minimum amount) so an operator can tune it live. Secrets
|
||||
and infra wiring (master key, JWT secret, Electrum host, admin token,
|
||||
database URL) deliberately stay env-var-driven — those require a restart
|
||||
anyway and aren't safe to hot-swap."""
|
||||
|
||||
__tablename__ = "round_config"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
fee_address: Mapped[str] = mapped_column(String(128))
|
||||
bet_amount_sats: Mapped[int] = mapped_column(BigInteger)
|
||||
bet_amount_sats: Mapped[int] = mapped_column(BigInteger, default=1_000_000_000)
|
||||
round_duration_seconds: Mapped[int] = mapped_column(default=600)
|
||||
round_cooldown_seconds: Mapped[int] = mapped_column(default=30)
|
||||
min_amount_sats: Mapped[int] = mapped_column(BigInteger, default=100_000_000)
|
||||
fee_rate_sat_vb: Mapped[int] = mapped_column(default=1)
|
||||
rbf_timeout_seconds: Mapped[int] = mapped_column(default=900)
|
||||
updated_at: Mapped[datetime] = mapped_column(default=utcnow, onupdate=utcnow)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user