fix(tracker): close alpha accounting review gaps
Address post-review blockers from the alpha hardening diff: charge non-stream completions that omit usage, include prompt tokens in max_charge_per_request enforcement, and wire the CLI to a persisted local registry contract by default. Verification: .venv/bin/python -m compileall -q packages tests; focused billing/CLI checks passed; full pytest: 314 passed, 3 skipped, 1 env failure from existing meshnet-node on port 7000.
This commit is contained in:
@@ -8,6 +8,8 @@ from .accounts import DEFAULT_ACCOUNTS_DB_PATH
|
||||
from .billing import DEFAULT_BILLING_DB_PATH
|
||||
from .server import TrackerServer, derive_relay_url_from_public_tracker_url
|
||||
|
||||
DEFAULT_REGISTRY_DB_PATH = "meshnet_registry.sqlite3"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
common = argparse.ArgumentParser(add_help=False)
|
||||
@@ -49,20 +51,34 @@ def main() -> None:
|
||||
f"(default: {DEFAULT_BILLING_DB_PATH}; ADR-0015)"
|
||||
),
|
||||
)
|
||||
common.add_argument(
|
||||
"--no-billing",
|
||||
action="store_true",
|
||||
help="Disable the USDT billing ledger",
|
||||
)
|
||||
common.add_argument(
|
||||
"--max-charge-per-request",
|
||||
type=float,
|
||||
default=None,
|
||||
help=(
|
||||
"Reject chat completion requests whose requested token limit would "
|
||||
"cost more than this many USDT"
|
||||
),
|
||||
)
|
||||
common.add_argument(
|
||||
"--no-billing",
|
||||
action="store_true",
|
||||
help="Disable the USDT billing ledger",
|
||||
)
|
||||
common.add_argument(
|
||||
"--max-charge-per-request",
|
||||
type=float,
|
||||
default=None,
|
||||
help=(
|
||||
"Reject chat completion requests whose prompt plus requested completion "
|
||||
"token bound would cost more than this many USDT"
|
||||
),
|
||||
)
|
||||
common.add_argument(
|
||||
"--registry-db",
|
||||
default=DEFAULT_REGISTRY_DB_PATH,
|
||||
metavar="PATH",
|
||||
help=(
|
||||
"SQLite database path for persisted strike/ban/reputation registry "
|
||||
f"state (default: {DEFAULT_REGISTRY_DB_PATH})"
|
||||
),
|
||||
)
|
||||
common.add_argument(
|
||||
"--no-registry-contracts",
|
||||
action="store_true",
|
||||
help="Disable the local contract registry used for strike/ban/reputation enforcement",
|
||||
)
|
||||
common.add_argument(
|
||||
"--accounts-db",
|
||||
default=DEFAULT_ACCOUNTS_DB_PATH,
|
||||
@@ -149,6 +165,11 @@ def main() -> None:
|
||||
treasury = SolanaCustodialTreasury(
|
||||
args.solana_rpc_url, args.usdt_mint, args.treasury_keypair,
|
||||
)
|
||||
contracts = None
|
||||
if not args.no_registry_contracts:
|
||||
from meshnet_contracts import LocalSolanaContracts # type: ignore[import-not-found]
|
||||
|
||||
contracts = LocalSolanaContracts(registry_db=args.registry_db)
|
||||
server = TrackerServer(
|
||||
host=args.host,
|
||||
port=args.port,
|
||||
@@ -158,9 +179,10 @@ def main() -> None:
|
||||
stats_db=getattr(args, "stats_db", None),
|
||||
relay_url=relay_url,
|
||||
enable_billing=not args.no_billing,
|
||||
billing_db=None if args.no_billing else args.billing_db,
|
||||
max_charge_per_request=args.max_charge_per_request,
|
||||
accounts_db=None if args.no_accounts else args.accounts_db,
|
||||
billing_db=None if args.no_billing else args.billing_db,
|
||||
max_charge_per_request=args.max_charge_per_request,
|
||||
contracts=contracts,
|
||||
accounts_db=None if args.no_accounts else args.accounts_db,
|
||||
treasury=treasury,
|
||||
settle_period=args.settle_period,
|
||||
payout_threshold=args.payout_threshold,
|
||||
|
||||
Reference in New Issue
Block a user