Dagna (ዳኛ)
LiveAn industrial-grade competitive programming online judge and contest arena executing untrusted code in multi-layer Linux sandboxes.
Live Application: dagna-beta.vercel.app
Source Repository: github.com/PROFESSOR-ADNAN/dagna
The problem
Running an algorithmic contest platform is fundamentally an adversarial security problem: you are inviting strangers on the internet to submit arbitrary source code in C++, Python, or Java to be compiled and executed on your hardware. Without strict isolation, malicious submissions can fork bomb the kernel, exfiltrate test cases from disk, open outbound sockets to launch DDoS attacks, or consume infinite CPU cycles.
Beyond security, contest organizers and ICPC/OI competitors expect instantaneous feedback: live scoreboards must dynamically shift in real time, contest freeze confidentiality must be preserved during the final hour, and rating calculations must be deterministic.
System architecture
Dagna partitions operational duties across two isolated network zones connected exclusively via an encrypted private WireGuard tunnel (10.100.0.0/24):
- Zone 1 — Web Gateway & State Engine (Public Facing): Handles HTTP/WebSocket traffic, user authentication, problem authoring, contest clock scheduling, and live scoreboards.
- Zone 2 — Judge Fleet Workers (Air-Gapped Execution): Pull-based worker daemon polling submission tasks over WireGuard. Judges compile and execute user binaries inside isolated ephemeral Linux environments, benchmark execution runtime down to the millisecond, and return structured verdicts (Accepted, Wrong Answer, Time Limit Exceeded, Memory Limit Exceeded, Runtime Error).
Engineering highlights
- Multi-layer Linux sandboxing: Untrusted code executes inside unprivileged Docker containers bounded by Linux control groups (
cgroups v2) for hard CPU time and RSS memory limits, combined with custom seccomp filters blocking network sockets, file access outside the sandbox mount, and dangerous syscalls. - Pull-based queue architecture: Judge nodes poll tasks using long-polling rather than having the central web server push work outwards. This prevents backpressure collapse during contest starts when hundreds of submissions land within seconds.
- Real-time leaderboard & contest freeze: Real-time contest scoreboard recalculations are broadcast to connected clients via WebSockets. Supports configurable "scoreboard freeze" windows where participants see their own submission verdicts while global standings freeze to build tension before final unfreezing.
- Deterministic Elo rating engine: Implements Codeforces-style multi-player rating transitions following rated rounds, calculating expected performance vs. actual rank with volatility dampening.
Review & architectural takeaways
Separating the untrusted execution environment from the database and web host over a private WireGuard network eliminates entire classes of lateral privilege escalation. By treating every submission as potentially malicious, Dagna achieves the reliability of production contest platforms while remaining lightweight and reproducible.
Next up
VimAscend →