Commit Graph

59 Commits

Author SHA1 Message Date
DragonX Developers
68c24b5701 zrpc: bound concurrency, and close idle connections before the node does
Review follow-ups to 73a93f1.

Bound in-flight calls. rpcclient's single sendPostHandler goroutine
imposed an accidental ceiling of one concurrent RPC; removing it without
putting anything in its place left no bound at all. grpc-go supplies
none either -- this server sets no MaxConcurrentStreams, so the default
is math.MaxUint32 -- and dragonxd answers RPC with 8 worker threads
behind a 4096-deep queue, shared on the pool node with getblocktemplate.
Overload would therefore surface as mining latency rather than as an
error we could back off on. MaxConnsPerHost blocks the caller at the
limit instead of dialling more, which is the backpressure wanted;
MaxIdleConnsPerHost alone would only cap reuse and let us exceed the
limit while churning connections. Default 8, matching the node's
DEFAULT_HTTP_THREADS, tunable with -rpc-max-concurrent. Even 8 removes
all of the head-of-line blocking this work set out to fix.

IdleConnTimeout 90s -> 20s. dragonxd closes idle connections at 30s
(DEFAULT_HTTP_SERVER_TIMEOUT, applied via evhttp_set_timeout and not
overridden in DRAGONX.conf). At 90s we were always the second to close,
so a request could be written into a connection the server had already
sent a FIN for, and Go will not retry a POST once bytes are on the wire.
Closing first removes the race.

Reject a negative -rpc-timeout, which silently meant "unbounded", the
same as the documented 0. The check has to run after flag.Parse(); it
was initially placed before it and never fired.

Also correct the coinsupply note: hush_coinsupply walks the block index
back to genesis, loading each block from disk and memoising newcoins and
zfunds into the CBlockIndex, so the first call pays for the whole chain
and later ones are nearly free. It is not a UTXO-set scan, as the
earlier comment claimed. The measured 48s/3s figures are unchanged.

Verified: five concurrent GetLightdInfo calls all return grpc-status 0
with no errors, 46 blocks ingested, and the daemon holds 2 sockets to
the node rather than one per request; a negative timeout exits 1.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FU87LdsJZiZkfq1eXubpeo
2026-08-26 11:44:52 -05:00
DragonX Developers
4e7a1c0f9b rpc: bound every dragonxd call with a timeout, and stop serialising them
lightwalletd used github.com/btcsuite/btcd/rpcclient for exactly one
method, RawRequest, and that package has two defects that together
produce the failure seen on the primary node:

  1. It has no timeout and no way to set one. The http.Client is built
     in an unexported newHTTPClient() and ConnConfig exposes no Timeout
     field, so a call can hang forever. Calls were observed running past
     five minutes against a healthy node that answered the same query
     from dragonx-cli in 2ms.

  2. In HTTP POST mode it runs ONE sendPostHandler goroutine which calls
     handleSendPostMessage synchronously, so the whole process has at
     most one RPC in flight. One stuck call therefore blocks the block
     ingestor, the mempool monitor and every user-facing gRPC handler at
     once.

These compound: a timeout alone would not have been enough, because
bounding the caller's wait still leaves the shared goroutine stuck
inside http.Client.Do with everything queued behind it. Only a timeout
on the HTTP client aborts the in-flight request, and only dropping the
shared goroutine lets independent callers proceed.

Patching the vendored copy is not an option here: go.mod declares
go 1.12, so automatic vendor mode (go >= 1.14) is off and the committed
vendor/ tree is silently ignored in favour of the module cache. It is
also stale -- vendor/modules.txt disagrees with go.mod on btcd,
protobuf, logrus, sqlite3 and six other modules, so -mod=vendor cannot
build at all, and `go mod vendor` would discard any patch.

Replace it with package zrpc: a ~150-line JSON-RPC client that is safe
for concurrent use and takes a timeout. The request envelope, ID
sequence, basic auth and error semantics are deliberately identical.
RPCError.Error() still renders as "<code>: <message>" because callers
recover the numeric code from the string -- common.GetSaplingInfo
checks for -8 via strings.SplitN(err.Error(), ":", 2) -- and the
non-JSON body path still reports `status code: %d, response: %q`.

Default timeout 120s, tunable with -rpc-timeout (0 disables). The bound
is set by the slowest legitimate call: coinsupply measured 48s against
a cold UTXO set, 3s once cached, so a tighter timeout would turn a
slow-but-working call into a hard failure.

Also drops rpcclient's Close=true, which opened a fresh TCP connection
per request and left hundreds of sockets in TIME_WAIT on a busy node;
idle connections are now reused and capped.

Verified against a live dragonxd: getblockchaininfo returns chain=main;
a bad height yields exactly "-8: Block height out of range" and parses
back to -8; a 1ns timeout aborts in 54us instead of hanging; and the
built daemon serves GetLightdInfo at the current height with no errors.
The pre-existing parser TestCompactBlocks failure is unrelated and
reproduces on the base commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FU87LdsJZiZkfq1eXubpeo
2026-08-26 11:44:52 -05:00
DragonX Developers
7f5474ef82 version: 0.1.2, from a single constant
Bump for the GetTransaction crash fix, and make the version one value
instead of two literals that could drift.

It was duplicated: cmd/server/main.go had `var version = "0.1.1"` for
--version, and frontend/service.go had "0.1.1-dragonxlightd" inline in
the LightdInfo reply. The gRPC one is the load-bearing copy -- it is
walletrpc/service.proto:48, so every client reads it, and it is the only
way to tell from off-box which build a node is running.

That property is the point of bumping now rather than later. With it, a
rollout can be verified by probing each endpoint over TLS and reading
the advertised version, instead of shelling in to compare binary
checksums, and instead of the only alternative positive test -- calling
GetTransaction on a mempool txid, which proves the fix by crashing any
node that does not have it.

Verified: --version prints 0.1.2, and a GetLightdInfo probe against a
test instance returns 0.1.2-dragonxlightd where production still returns
0.1.1-dragonxlightd.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FU87LdsJZiZkfq1eXubpeo
2026-08-26 10:33:51 -05:00
2bab58c6d2 lightwalletd: adaptive reorg-lag tip + non-blocking startup coinsupply
Adaptive-lag: advertise a tip that trails the real tip by a reorg-rate-driven
lag (GetLatestBlock/GetLightdInfo) so wallets anchor shielded spends at a
settled height during reorg churn. Configurable via
-adaptive-lag/-lag-min/-lag-max/-lag-window; monitor_lwd.sh runs
-lag-min 4 -lag-max 12 -lag-window 30.

Startup coinsupply: the informational startup coinsupply RPC (result used only
for a log line) blocked the gRPC bind for minutes on a node whose supply index
is cold, keeping the lite endpoint down on every restart while it also starved
the block-cache ingestor. Run it in a goroutine so the bind is never blocked;
clients still get coinsupply on demand via the GetCoinsupply RPC.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 01:05:10 -05:00
ec1c479156 Increase block cache size to 400k for faster wallet sync
- Increase default cache-size from 40,000 to 400,000 blocks
- Add Python gRPC protobuf bindings for testing
2026-03-21 03:50:55 -05:00
dan-s
daab197a01 update for dragonx binary changes, added monitor script 2026-03-04 15:28:02 -06:00
jahway603
749f2ee743 new lightwalletd deb build script 2021-10-24 01:39:15 -04:00
jahway603
edac479e7d changed to variable 2021-10-21 16:07:14 -04:00
jahway603
b33b4b476f working towards lightwalletd deb package 2021-09-29 02:04:48 -04:00
jahway603
0f21f457a6 changed DenioD's github lightwalletd links to git.hush.is lightwalletd links 2020-11-27 22:13:24 -05:00
Duke Leto
2824ad752e Update url in error message 2020-11-19 21:42:26 -05:00
Denio
01e1d766a0 add coinsupply rpc to lightwalletd 2019-12-05 21:37:35 +01:00
Denio
1608369f09 add no-tls 2019-12-02 21:37:56 +01:00
Denio
0978322f62 add longestchain and notarized to lightinfod 2019-12-02 11:42:50 +01:00
Denio
a269cd1e6b add difficulty to lightdinfo 2019-12-02 10:35:38 +01:00
DenioD
f6fa52fde1 port to hush 2019-10-15 14:38:55 +02:00
Aditya Kulkarni
769db4945f Require TLS 2019-10-14 12:52:44 -07:00
Aditya Kulkarni
0fcf593bb6 Custom cache size 2019-10-12 15:28:38 -07:00
Aditya Kulkarni
c688de510e Store serialized bytes in cache 2019-10-01 11:05:43 -07:00
Aditya Kulkarni
3c6742d526 Revert "Make default cache size 20k blocks"
This reverts commit 16d9ae0ea6.
2019-10-01 10:34:16 -07:00
Aditya Kulkarni
16d9ae0ea6 Make default cache size 20k blocks 2019-10-01 10:31:41 -07:00
Aditya Kulkarni
cacc23b220 Remove the old ingestor 2019-09-25 21:18:34 -07:00
Aditya Kulkarni
a8cc2424a2 Thread safe cache with separate ingestor 2019-09-25 21:15:32 -07:00
Aditya Kulkarni
fbb75e8f20 Return consensusBranchId 2019-09-25 17:46:05 -07:00
Aditya Kulkarni
d56fe7bf1a Remove SQL from grpc server 2019-09-25 13:28:55 -07:00
Aditya Kulkarni
b89062cd53 Remove Txtable 2019-09-25 12:17:36 -07:00
Aditya Kulkarni
8421285313 Merge error codes 2019-09-25 11:44:42 -07:00
Aditya Kulkarni
d59757571d Remove UTXOs call 2019-09-25 11:43:54 -07:00
Aditya Kulkarni
cf0b87ac9b Log sapling height 2019-09-20 14:49:47 -07:00
Aditya Kulkarni
3b4573c4f0 Add chainname and activation height to getinfo 2019-09-18 21:16:15 -07:00
Aditya Kulkarni
7bf4a8407b Read sapling activation height from RPC 2019-09-18 20:38:59 -07:00
Aditya Kulkarni
d36126ba9d Add transparent txns 2019-09-13 16:02:58 -07:00
Aditya Kulkarni
7644852fc6 Fix hash encoding, change module names 2019-09-12 12:08:53 -07:00
Aditya Kulkarni
b4796bc67e New RPC call 2019-09-10 16:34:01 -07:00
mdr0id
1e40cea877 Remove zmq references from README files 2019-08-27 14:41:25 -07:00
mdr0id
716930d028 name of app is missleading in log message 2019-08-27 14:15:00 -07:00
mdr0id
59975fc349 Remove zmq from scaffolding stuff in go 2019-08-27 14:07:42 -07:00
mdr0id
fec37dff9a Initial reorg fix 2019-07-16 19:14:58 -07:00
mdr0id
1002580cd9 Add storing prevhash to local db and logs 2019-07-09 15:52:35 -07:00
Larry Ruane
2454b05b52 add prev_hash to logging 2019-06-28 12:22:22 -05:00
mdr0id
0813d73e97 Add initial error handling for condition for zcashd down 2019-06-10 21:14:31 -07:00
mdr0id
d1e49493b0 Remove/add white space nits. Add comment for -8 value check in error conditional 2019-06-10 20:35:32 -07:00
mdr0id
3d48461e32 Clean up and organize imports 2019-06-10 20:25:43 -07:00
mdr0id
31576ff5fc Update ingest logic stream to start at actual Sapling testnet height 2019-06-07 14:13:22 -07:00
mdr0id
4354ec70c0 Update ingest logic stream to start at Sapling testnet height 2019-06-07 14:10:56 -07:00
mdr0id
1587db121c Remove 0mq logic, add getblock RPC wrapper, add RPC polling logic, and remove old packages 2019-06-06 17:49:47 -07:00
Jack Grigg
c4a48902db ingest: Log block and transaction hashes in display order
We should also be consistent in the SQLite database about either storing
as TEXT in display order, or storing as BLOB in wire order. But as
that's another breaking change, let's bundle it in with anything else we
need to do to address this problem.
2019-05-23 13:42:02 +01:00
George Tankersley
0cb0bb51af frontend: implement SendTransaction 2019-02-14 00:18:15 +00:00
George Tankersley
d08abe82b4 walletrpc: improve protobuf/grpc package naming 2019-02-14 00:18:14 +00:00
George Tankersley
7726a6752d cleanup: rename package and vendor dependencies for old go versions
Fixes #8 and begins to address deployability.
2019-01-03 19:14:51 +00:00