local-network

작성자: convex-dev

로컬 Convex 테스트 네트워크를 개발용으로 실행합니다. 라이브 네트워크에 대한 변경 사항을 테스트하거나, 피어 문제를 재현하거나, 원격 네트워크가 없을 때 사용합니다.

npx skills add https://github.com/convex-dev/convex --skill local-network

Run a Local Convex Network

A local network is the default way to exercise changes in this repository. It needs no credentials, no remote host, and can be thrown away and recreated freely. Prefer it over a remote network for anything that is not specifically about remote behaviour.

Requires a built convex.jar — see the build-convex skill.

Start a Temporary Network

java -jar convex.jar local start

Starts a throwaway test network. State is not preserved between runs, which is what you want for testing.

Useful options:

OptionEffect
--count NNumber of peers to launch
--ports ...Specific peer ports (default: assigned automatically)
--api-port NPort for the REST API
--norestDo not start the REST server
--no-trayNo system tray icon
--protocol-version NPin the protocol version

Start with the Peer Manager GUI

java -jar convex.jar local gui

Launches the same local network under the peer manager GUI — useful for watching consensus and inspecting peer state visually.

Talking to It

Once running, point the client commands at the local peer:

java -jar convex.jar client query --host localhost --port <PORT> '(balance #12)'
java -jar convex.jar client status --host localhost --port <PORT>

Notes for Tests

Do not start a network from a JUnit test by shelling out to the CLI. Tests construct peers or lattice nodes in-process.

For consensus/CVM peer tests, follow the fixtures in convex-peer. For lattice replication, use NodeServer; for the bundled P2P and social regions, use P2PNode. See convex-peer/src/test/java/convex/node/LatticeNetworkTest.java and convex-p2p/src/test/java/convex/p2p/P2PSocialSyncTest.java.

For a small lattice network test:

  1. Give each node its own store and key pair.
  2. Use NodeConfig.localNetwork(). It binds port 0, then publishes the actual OS-assigned loopback port in the node's signed NodeInfo.
  3. Set an inbound propagator policy before launch. P2PNode.serveAllInbound() is suitable for a deliberately public test node.
  4. Tell one node about the other with nodeA.connect(nodeBKey, nodeB.getNodeServer().getHostAddress()). The future completes after B proves its node key and A's own signed [:p2p :nodes] record has been merged by B. B then discovers A from that path-scoped lattice update and establishes the reverse authenticated connection automatically. Use nodeB.whenConnected(nodeAKey) when a test must wait for that reverse admission before publishing in both directions. For three nodes, a useful discovery topology is to tell both leaves only about one rendezvous node. Wait until its signed registry has reached both leaves, then use whenConnected to prove the leaves discovered each other without another configured endpoint.
  5. After an application write, call the root application's sync() to publish the complete root. When batching several edits for one signed social owner, fork the SocialUser, apply its feed and follow actions, sync that fork once, then sync the application root. A Social fork is outside the owner boundary and therefore still signs each user edit inside the unpublished fork.
  6. Automatic gossip is fire-and-forget. To verify it without sleeping, capture nextAnnounce() before publishing and re-arm it until the expected application state is present. The announce signals completed acquisition, merge and root publication. Use an explicit receivingServer.pull(connection).get(timeout) only when the test is specifically about pull synchronisation. A ping only establishes transport ordering and does not prove acquisition is complete.
  7. Close nodes before closing their stores.

Treat a node key as its P2P/transport signer, not automatically as an application user's identity or signing key. For an OwnerLattice keyed by an indirect owner such as a DID, install a fail-closed owner verifier in the LatticeContext; without one, indirect owners use the compatibility-lenient fallback. Give identity-sensitive tests separate node keys and application owner/signing keys. The social cursor API currently accepts AccountKey owners, so use a separate application key and state that limitation explicitly. Once its DID migration lands, cover did:key, did:convex and did:web with pinned local state or deterministic resolver fixtures—never depend on public web resolution in a unit test. serveAllInbound() controls network access and does not replace owner authorisation.

Remember that an AccountKey is a typed JVM view over a canonical 32-byte Blob. A key stored as ordinary CAD3 application data can therefore decode as a Blob. Domain readers should parse compatible Blob values with AccountKey.parse or AccountKey.create; do not use instanceof AccountKey as a wire-format validity check.

The rules in AGENTS.md apply: never bind fixed ports and never sleep. Wait on futures, latches or another API whose contract represents the required state.

Stop the network when finished — it holds ports and a temporary store.

convex-dev의 다른 스킬

account
convex-dev
Convex 계정을 생성하거나 조회합니다. 사용자가 새 계정을 설정하거나, 계정 세부 정보를 확인하거나, 키를 관리하려 할 때 사용하세요.
account
convex-dev
Convex 계정을 생성하거나 조회합니다. 사용자가 새 계정을 설정하거나, 계정 세부 정보를 확인하거나, 키를 관리하려 할 때 사용하세요.
token
convex-dev
Convex에서 대체 가능한 토큰을 생성하고 관리합니다. 사용자가 새 토큰을 만들거나, 토큰 잔액을 확인하거나, 토큰 공급량을 관리하려 할 때 사용하세요.
build-convex
convex-dev
Convex 프로젝트를 소스에서 빌드합니다. 기여자가 Convex를 컴파일, 테스트 또는 패키징하려 할 때 사용합니다.
convex-db
convex-dev
Convex DB(래티스 기반 SQL 데이터베이스)를 사용하세요. 사용자가 쿼리 작성, JDBC 또는 PostgreSQL 클라이언트를 통한 연결, 테이블 생성, 데이터 삽입/조회 등을 도와야 할 때 사용합니다.
convex-lisp
convex-dev
Convex Lisp 언어 참조 — CVM 규칙, 라이브러리 코드 호출, 액터 정의, juice 및 오류 코드. CVM 소스를 작성하거나 디버깅할 때 사용합니다…
deploy
convex-dev
액터(스마트 계약)를 Convex 네트워크에 배포합니다. 사용자가 내보낸 함수를 가진 새로운 온체인 액터를 생성하려 할 때 사용하세요.
ecosystem
convex-dev
Convex 생태계에서의 방향 안내 — 어떤 리포지토리에 무엇이 있는지, 사양과 문서가 어디에 있는지, 그리고 어떤 클라이언트 라이브러리가 존재하는지. 컨텍스트가 필요할 때 사용하세요…