Skip to content

Room contract merge can exceed core's 5s execution budget on large rooms — contract stops converging network-wide #422

Description

@sanity

Problem

Production forensics on the nova gateway (freenet-core#4861) found a contract instance — behaviorally consistent with a River room (~154KB state, room-contract state/summary size profile) — whose every update_state merge exceeds freenet-core's 5-second WASM execution budget:

  • WASM execution timed out with elapsed_ms consistently 5001–5008, 100–220 times/hour, sustained 36h+
  • State frozen at 154,375 bytes: only 2 successful applies in 36h, 2,656 Merge rejected incoming state but local state is valid
  • Identical behavior on two independent peers (v0.2.100 and v0.2.101), so contract-intrinsic
  • Cost: ≈14–29% of one CPU core, continuously, on every peer hosting the contract (it is the only contract producing timeouts on the gateway — all-timeouts ≈ its timeouts every hour)

Contract instance key: Gsd2311PU4PFrFvptNToGjxswUKbMeouZF6sfjV3CVgQ. The room identification is a high-confidence hypothesis from behavior/sizes (the contract times out before it can emit identifying log lines); xqyyifd4… (confirmed room via its contract-emitted error) shows the same rejection signature at smaller cost.

freenet-core#4864 contains the core-side cost (enforced preemption + backoff), but the contract remains permanently unable to converge.

Ask

Profile room-contract update_state/validate on a ~150KB room state (many members/messages): what is O(·) in members × messages, and is per-delta signature re-verification over the whole state the driver? A merge that cannot complete within ~5s of CPU on commodity hardware means large rooms stop converging network-wide. Likely needs incremental validation (verify only the delta's additions) or a bounded merge.

Related: freenet/freenet-core#4861 (root-cause forensics), freenet/freenet-core#4864 (core containment).

[AI-assisted - Claude]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions