You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(lit-api-server): enforce per-key spending rules on the hot path (lambda-parity PR 2)
Gateway side of the Lambda-parity work. Reads the on-chain hasSpendingRules gate
in the same multicall as the execute-permission check; keys without rules pay
zero extra work.
- accounts: can_execute_action_with_spending_rules -> (can_execute,
has_spending_rules), cached in BlockchainCache (new execute_and_spending
entry, same generation invalidation). Reads the new view via a scoped sol!
interface (read_only_client_and_address helper) so it tracks the workspace
alloy version instead of the regenerated giant binding.
- core::spending_rules: flag-gated enforcer. On a flagged key it fetches rules
(cached, TTL) from lit-payments /internal, then enforces a rolling spend cap
(402), a per-node token-bucket rate limit (429), and a per-node concurrency
cap (429). Spend is recorded off the response path (in-memory + fire-and-
forget POST). Inert unless LIT_PAYMENTS_INTERNAL_URL + INTERNAL_SERVICE_TOKEN
are set AND the key's on-chain flag is on.
- Wired into core_features::lit_action + the /lit_action route + main state.
- 429 (too_many_requests) ApiStatus helper.
Origin allowlist (P2.1) deferred. SWR background refresh for the rules cache is
a marked follow-up (currently TTL with inline cold-miss fetch). cargo check
clean; 4 unit tests for the token bucket, window reset, and hash format.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments