Skip to content

Canvas driven topographical node#81

Merged
JamesEjembi merged 3 commits into
VeriNode-Labs:mainfrom
clintjeff2:Canvas-Driven-Topographical-Node
Jun 24, 2026
Merged

Canvas driven topographical node#81
JamesEjembi merged 3 commits into
VeriNode-Labs:mainfrom
clintjeff2:Canvas-Driven-Topographical-Node

Conversation

@clintjeff2

Copy link
Copy Markdown
Contributor

Motivation

  • Replace slow DOM/SVG rendering with a high-density canvas renderer that can display ~10,000 validators without heavy DOM pressure and maintain interactive performance.
  • Offload physics to a worker so layout ticks do not block the main thread and enable sustained 60Hz physics with 30Hz render updates.
  • Provide fast hit-testing and level-of-detail rendering to keep memory and CPU use within practical browser limits.

Description

  • Added a canvas-based topology renderer NodeTopologyMap (src/components/network/NodeTopologyMap.tsx) that implements a layered draw (grid, edges, nodes, selection), Path2D edge caching, distance-based LOD (tiny dots vs full labels/status), and latency-colored directional edge arrows.
  • Implemented spatial-hash hit-testing (CELL_SIZE = 100) with 3x3 neighborhood lookups to reduce hover/click checks from O(n) to constant-time in practice.
  • Added a worker-driven force layout: shared runForceLayout engine (src/lib/forceLayout.ts) and src/workers/forceLayout.worker.ts which runs physics at 60Hz and posts render snapshots at 30Hz.
  • Introduced deterministic synthetic topology data and types: useNodeTopology hook (src/hooks/useNodeTopology.ts) and new src/types/topology.ts.
  • Added a light compatibility wrapper NetworkGraph (src/components/network/NetworkGraph.tsx) and integrated the new canvas map into the network page (app/network/page.tsx).
  • Added a Playwright performance regression test e2e/topology-performance.spec.ts that samples requestAnimationFrame for 30s and asserts p95 frame time < 33ms.
  • Feature detection for GPU path is included (gpuMode) to surface that a WebGPU-based instanced point-sprite path could be used for >5,000 nodes in environments that support it.

Testing

  • Ran lint with npm run lint which completed (one unrelated react-hooks/exhaustive-deps warning remains in src/hooks/useNodeList.ts).
  • Type-check passed via npx tsc --noEmit.
  • Production build completed successfully with npm run build (Next.js static page generation succeeded).
  • The added Playwright e2e (e2e/topology-performance.spec.ts) was executed but the test run is blocked by the Playwright browser installation failing in this environment: npx playwright install chromium returned a 403 from the CDN so the browser executable was not available and the test could not complete.

Closes #2

@JamesEjembi JamesEjembi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JamesEjembi JamesEjembi merged commit dd080c1 into VeriNode-Labs:main Jun 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Canvas-Driven Topographical Node Mapping for High-Density Networks

2 participants