Skip to content

chore(deps): migrate jrpc2 v0 → v1.3.5#19

Draft
moralpriest wants to merge 5 commits into
DEROFDN:community-devfrom
moralpriest:chore/deps/jrpc2-v1-migration
Draft

chore(deps): migrate jrpc2 v0 → v1.3.5#19
moralpriest wants to merge 5 commits into
DEROFDN:community-devfrom
moralpriest:chore/deps/jrpc2-v1-migration

Conversation

@moralpriest

Copy link
Copy Markdown

What

Migrate github.com/creachadair/jrpc2 from the vendored v0 to the latest release (v1.3.5).

Why

  • derohe vendors jrpc2 v0 (pre-release, outdated)
  • All wallets that interact with the DERO daemon via RPC depend on this library
  • jrpc2 v1.3.5 has breaking API changes that require derohe patches before wallets can upgrade

Breaking Changes Addressed

Change Impact Resolution
jrpc2/code subpackage removed Error constants (InvalidParams, ParseError, etc.) moved to root jrpc2 package Updated imports in xswd.go and xswd_test.go
ServerOptions.DecodeContext removed Was used to inject timing context for per-method metrics Replaced with timedHandler wrapper around each RPC handler
ServerOptions.Metrics removed Was unused (empty field) No action needed
JSON-RPC 2.0 strict param validation SignData/CheckSignature were called with string params (accepted by v0, rejected by v1) Changed method signatures to [1][]byte to match spec

Pre-existing Fixes (unrelated to jrpc2, but required for compilation)

These issues existed before this migration and would block a clean build:

Issue File Fix
readline.KickReader() deprecated cmd/dero-wallet-cli/prompt.go Replaced with Instance.Close()
nbio v1.6.9 API change cmd/derod/rpc/websocket_getwork_server.go Removed redundant type assertion on Upgrade return
kcp-go/v5 v5.6.72 removed FECShortShards go.mod Pinned to v5.5.0

Files Changed

Core jrpc2 migration:

  • walletapi/xswd/xswd.go — imports, error code constants, handler call
  • walletapi/xswd/methods.goSignData/CheckSignature param types for JSON-RPC 2.0 compliance
  • walletapi/xswd/xswd_test.go — test assertions and param arrays
  • cmd/derod/rpc/websocket_server.goDecodeContext removed, handler wrapper for metrics timing
  • go.mod / go.sum — jrpc2 v1.3.5, Go 1.25.0

Pre-existing fixes:

  • cmd/dero-wallet-cli/prompt.go — readline API update
  • cmd/derod/rpc/websocket_getwork_server.go — nbio API update
  • go.mod / go.sum — kcp-go/v5 pin

Testing

  • ✅ All XSWD unit tests pass (JSON-RPC 2.0 param compliance verified)
  • ✅ derod builds and starts — getinfo, getheight, getblockcount, getblockheaderbytopoheight return valid JSON-RPC 2.0 responses
  • walletapi/rpcserver builds
  • ✅ Handler wrapper metrics timing implemented and verified
  • ✅ Rebased onto latest upstream (includes PrunedHeight in getinfo, gas estimate fix, proof arithmetic hardening)

Unchanged Files

These files use stable jrpc2 APIs (jrpc2.Request, jrpc2.Server, jrpc2.NewClient, handler.Map, handler.New) that survived v1 — no changes needed:

  • cmd/dero-wallet-cli/easymenu_post_open.go
  • cmd/dero-wallet-cli/prompt.go (already modified for readline)
  • cmd/explorer/explorerlib/explorerlib.go
  • cmd/simulator/wallets.go
  • walletapi/daemon_connectivity.go
  • walletapi/daemon_connectivity_wasm.go
  • walletapi/daemon_communication.go
  • walletapi/rpcserver/rpc_websocket_server.go (uses NewContext, still exists in v1)

References

- Remove jrpc2/code subpackage imports (constants moved to root package)
- Update error code references: code.* -> jrpc2.*
- Change custom error code types: code.Code -> jrpc2.Code
- Replace DecodeContext with handler wrapper for metrics timing
- Update SignData/CheckSignature to use [1][]byte for JSON-RPC 2.0 compliance
- Fix xswd tests to send params as arrays (JSON-RPC 2.0 spec)
- Update test assertions to use jrpc2.* constants

Breaking changes in jrpc2 v1:
- jrpc2/code subpackage removed
- ServerOptions.DecodeContext removed
- ServerOptions.Metrics removed
- Params must be array/object (not string)

Pre-existing issues (not from this migration):
- metrics: kcp.FECShortShards undefined (kcp version mismatch)
- wallet-cli: readline.Operation.KickReader undefined
- cmd/dero-wallet-cli/prompt.go: replace deprecated readline.KickReader with Instance.Close()
- cmd/derod/rpc/websocket_getwork_server.go: fix nbio v1.6.9 API (Upgrade return type, OnReadBufferAlloc/Free signatures)
- cmd/derod/rpc/websocket_server.go: remove unused encoding/json import
@moralpriest moralpriest force-pushed the chore/deps/jrpc2-v1-migration branch from 15e852b to 4b1f737 Compare June 7, 2026 20:45
- Remove  deprecated FECShortShards metric
- Add new FEC metrics
- Reorganize imports using grouped import syntax for better readability
@moralpriest moralpriest force-pushed the chore/deps/jrpc2-v1-migration branch from 4b1f737 to 018a95f Compare June 7, 2026 22:31
@moralpriest moralpriest marked this pull request as draft June 8, 2026 00:42
@moralpriest

Copy link
Copy Markdown
Author

Status: Draft

Converting to draft pending consensus-critical fix patches.

This PR is functionally complete (jrpc2 v0 → v1.3.5, XSWD tests pass, builds clean) but must not be deployed to mainnet consensus nodes without the follow-up fixes documented in `docs/go-1.26-upgrade-audit.md`.

The Go runtime upgrade (1.17 → 1.26.0, forced by jrpc2 v1.3.5 minimum of 1.25.0) introduces 8 consensus-critical map iteration sites that produce divergent state hashes. A follow-up PR will land the deterministic-sort fixes.

See audit doc §5 for the 8 sites and §15 for the 7 patch files.

- go.mod: bump go directive from 1.25.0 → 1.26.0
- docs/go-1.26-upgrade-audit.md: full audit (17 sections)
- docs/go-1.26-fix-patches/: 6 deterministic-sort patches + gob replacement
- docs/go-1.26-differential-test-spec.md: shadow testnet spec
- consensus/go126_compat_test.go: runtime compat tests
- PR DEROFDN#19 converted to draft pending fix PR

Refs:
- jrpc2 v1.3.5 requires go 1.25.0 minimum; we adopt 1.26.0
- Audit identified 8 consensus-critical map iteration sites
- 7 fix patches documented in docs/go-1.26-fix-patches/
- DO NOT deploy to mainnet consensus until patches land
Reclassifies 6 of 7 consensus-critical sites as mitigated by
operator-set GODEBUG=randmapiter=0 env var rather than requiring
code patches.

Changes:
- docs/go-1.26-upgrade-audit.md: reclassify sites, add §18 §19
- docs/go-1.26-fix-patches/README.md: mark 1-6 deferred, 7 mandatory
- docs/go-1.26-differential-test-spec.md: add Workaround C option
- docs/go-1.26-operator-guide.md: NEW (operator quick-start)
- consensus/godebug_check_test.go: NEW (placeholder test)
- consensus/go126_compat_test.go: augment with self-check test

Still required in a follow-up code PR:
- cmd/derod/godebug_check.go (~25 lines, init() self-check)
- p2p/chunk_server.go gob → custom encoding (patch 07)
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.

1 participant