Commit Graph

107 Commits

Author SHA1 Message Date
wellweek 1cc97b10d0 fix: fix the wrong error return value
Signed-off-by: wellweek <xiezitai@outlook.com>
2025-03-21 13:45:42 -06:00
jimmycathy 82ebcbfd66 chore: fix comment
Signed-off-by: jimmycathy <clonecode@outlook.com>
2025-03-17 11:21:21 -06:00
Emerson Hall e720feb3f3 Operators can specify a Zcash donation address 2025-03-06 14:48:59 -07:00
Kris Nuttycombe 1e63bee761 Support empty block range end in `getaddresstxids` calls. 2024-10-16 12:08:53 -06:00
Kris Nuttycombe 13856f3596
Merge pull request #495 from nuttycom/getrawtransaction_parse_testing 2024-08-14 13:11:42 -06:00
Kris Nuttycombe 90116a7c55 Filter out mined transactions in `refreshMempoolTxns` 2024-08-13 16:20:06 -06:00
Kris Nuttycombe 56fe52a11a Uniformly return height 0 for mempool `RawTransaction` results. 2024-08-13 12:11:47 -06:00
Kris Nuttycombe 0f1ed05c41 Document & test the conversion from `getrawtransaction` response to `RawTransaction`
This also modifies the internal `common.ZcashdRpcReplyGetrawtransaction`
type to ensure that the reinterpretation of the `-1` height value from
a `getrawtransaction` response is not platform-dependent.
2024-08-13 12:08:50 -06:00
Kris Nuttycombe 8866a0be4c Add a test that demonstrates unmarshalling behavior for `getrawtransaction` results. 2024-08-13 12:05:31 -06:00
Daira-Emma Hopwood c83db0117b
Merge pull request #489 from LarryRuane/2024-07-zebrad-err-messages
zebrad instead of zcashd in error messages
2024-08-10 11:11:03 +01:00
Larry Ruane f24e0298a9 wait for zebrad or zcashd to reach sapling activation height
This has been broken for a long time. If, when starting up, lightwalletd
discovers that the backend node (zebrad or zcashd) has not yet synced to
the Sapling activation height (419200 for mainnet, 280000 for testnet),
it should wait until that happens, then sync along with the backend
node. But instead, lightwalletd gets stuck indefinitely. The only way
to escape the hang is to stop and restart lightwalletd.

This commit fixes the problem; the block ingestor retries every 2
minutes (which was always the intention), rather than trying once and
then giving up.
2024-07-10 12:07:00 -06:00
Larry Ruane 4492d60b31 zebrad instead of zcashd in error messages 2024-07-07 22:21:57 -06:00
Larry Ruane 6e3816b583 add --nocache option to disable compact block file cache
This fixes issue #480. Enabling this option decreases the performance of
gRPCs GetBlock and GetBlockRange, but conserves disk space (the size of
the database is currently around 17GB).

Note, specifying this option will also delete the existing cache (so if
you start again without --nocache, the cache will need to be recreated).
2024-06-27 13:24:57 -05:00
Larry Ruane 6071b06ace Reduce lightwalletd startup (if disk cache already exists)
Reduce the startup time from a couple of minutes to a few seconds (or
less) by removing the deserialization of all compact blocks in the disk
cache. This is an alternative to PR 482, see comment there for details.
2024-06-13 09:08:47 -06:00
Larry Ruane e8453e62f6 update dependencies: packages ioutil, errors
No functional changes.

As pointed out in lightwalletd/pull/469, the errors package we're using
has been deprecated, so this commit updates the code to use "errors"
instead of "github.com/pkg/errors". Same with "io/ioutil", which has
been superceded by "os".
2024-02-01 12:41:14 -07:00
Larry Ruane bfd4e0a53f test: add darkside support for GetSubtreeRoots gRPC
One new darksidewallet gRPC added, SetSubtreeRoots()
2024-01-11 12:48:10 -07:00
Larry Ruane 8003d7fb6e darksidewallet: GetLightdInfo with no blocks shouldn't crash
Instead, return a reasonable error message. Issue #451.
2023-09-04 15:06:00 -06:00
Larry Ruane 853016bfd2 darkside GetLightdInfo: return fake build info
Instead of returning empty strings for `ZcashdBuild` and
`ZcashdSubversion`, return fixed "darksidewallet" strings.
2023-09-04 15:06:00 -06:00
Larry Ruane 7971992989 darkside GetTreeState gRPC: support block hash or height
In production mode, the `GetTreeState` gRPC supports block specification
by either height or block hash. But until now, darkside emulation only
supports height. This commit adds support for block hash.

It also allows entries to be deleted (darkside `RemoveTreeState`) by
block hash (not just height).
2023-09-04 14:22:44 -06:00
Jack Grigg 8269810eee darkside: Store, track, and expose commitment tree sizes 2023-08-16 10:34:38 -06:00
Jack Grigg b9de328ea9 darkside: Introduce `activeBlock` struct 2023-08-16 10:34:38 -06:00
Jack Grigg f0e4c27ed6 Bring in latest `compact_formats.proto`
From zcash/librustzcash@c13c8c6678,
including the rework of how the commitment tree sizes are to be
represented in CompactBlocks.
2023-07-04 11:05:41 -06:00
Larry Ruane c506123a08 add GetSubtreeRoots() gRPC 2023-06-27 21:14:59 -06:00
Larry Ruane c97bd8cc23 improve startup logging (no functional change) 2023-06-05 15:33:50 -06:00
Larry Ruane d55679f301 add Sapling and Orchard tree commitment sizes to GetBlock result
And also to GetBlockRange. This requires an updated version of zcashd
`getblock` RPC that returns these values. These values are written to
the compact block cache (/var/lib/lightwalletd/db/main/blocks), but of
course older cached compact blocks won't have these values. To get these
values into all cached blocks, shut down lightwalletd, remove that file,
and restart (with, of course, an updated version of zcashd running).
2023-06-04 22:26:17 -06:00
Larry Ruane de8b6230ba extend darksidewallet locking
See https://github.com/zcash/lightwalletd/issues/433
2023-05-27 07:53:12 -06:00
Larry Ruane 5d174f7feb darkside: fix GetBlock intermittent (timing) failure
In PR 412 (darksidewallet fixes for tx v5), I added a failure condition
to the GetBlock gRPC based on a block being requested always being in
the cache. I believe my thinking was that since there is no asynchronous
independent zcashd, if it wasn't in the cache, it never would be. I
failed to take into account that the block ingestor takes time to run,
and a test can run quickly enough that the block ingestor hasn't had
time to process the block. I reproduced the problem by commenting out
the starting of the block ingestor.

I think that error condition can be removed, which is what this commit
does. I tested by leaving the block ingestor commented out, so that
GetBlock has to use the RPC interface to get the block, and it works.
2022-11-19 17:19:39 -07:00
Larry Ruane 4267cc9754 fix GetLatestBlock() gRPC (pure block cache)
See issue 397. If the block cache is still populating (lightwalletd is
syncing with zcashd), behave the same as if the cache was fully
populated, other than performance.

This turned out to affect only the GetLatestBlock() gRPC. Previously, it
would return the height and hash of the latest block in the cache. After
this commit, it queries zcashd using the getblockchaininfo, which
contains both of those values.

GetBlock() (and GetBlockRange()) already worked correctly; if the
requested block isn't in the cache, it requests it from zcashd.
2022-10-20 10:04:05 -06:00
Larry Ruane ad5ecda5fb fix darside ApplyStaged many blocks performance regression
If the darkside "getblock" RPC handler is given a block hash as argument
(rather than a height), it was deserializing all active blocks
sequentially to find the one with the given hash. This is slow if there
is a large of blocks.

I considered the most general solution of adding a block hash map to
darkside so that any block could be looked up by its hash, but that
turns out to be a lot of effort. So instead, maintain a one-block cache
because a block is always looked up by hash immediately after being
looked up by height (this was changed in PR 412).
2022-09-11 16:49:41 -06:00
Francisco Gindre 15fe0ced86 [#390] Support for GetTreeState on Darksidewalletd
This commit adds support for adding/removing/clearing TreeState
structs for lightwalletd to return as if they were TreeState
messages requested to Zcashd for a given height.

Closes #390
2022-08-29 14:24:14 -06:00
Larry Ruane bbe8d14ecc Fix darksidewallet for tx v5 changes
Darkside test framework broke due to the V5 txid changes (issue 392).
This change enhances darksideRawRequest("getblock") to allow the
argument to be either a height or a block hash, rather than only a
height.
2022-08-28 15:45:04 -06:00
Francisco Gindre c999c4fd29 [#388] Darksidewalletd does not tell developers why it failed when a method is invoked 2022-08-27 17:25:06 -06:00
Larry Ruane f53511cb03 Fix reorg race condition that can cause rare crashes
Fixes issue 408.

This bug was introduced by PR 393, which changed how txids are
determined. That PR changed each call to the zcash getblock call into a
pair of calls, the first to get the raw block data, the second to
retrieve the txids in the block. (Unfortunately, you can't get both in a
single getblock RPC.) But this ordering introduced a timing window in
which the block at the given height can change, if a reorg occurred
between the two calls.

This PR reorders the getblock calls, so that the first call gets the
transaction IDs, which also happens to return the block hash, so then
the second getblock call can specify the block hash, rather than the
height. This ensures that the two RPC calls return consistent data,
definitely the same block.
2022-08-23 13:14:09 -06:00
Larry Ruane af0f348a57 Fix GetMempoolTx bug returning no entries
This was broken by PR 393, which changed how txids are determined.
2022-07-21 11:23:55 -06:00
sasha de700e3d4c improve the getblock error message 2022-06-23 18:24:21 -06:00
Larry Ruane f12b37f0da Fix darksidewallet for missing transaction IDs (txids)
This commit extends The darkside's stub zcashd rpc handler to handle the
verbose form of `getblock` (that returns the txids of all transactions
in the block) and the rest of the darkside code has to set the txids in
the blocks and individual transactions it returns. Since lightwalletd
doesn't yet support V5 txid calculation, we use the old one, so it's not
accurate for V5 but that doesn't matter (during darkside wallet testing,
the code under test can't detect incorrect txids).
2022-06-14 08:45:09 -06:00
Larry Ruane 0d00588941 Get unit tests working again
Now "go test ./..." passes, it had broken due to the V5 transaction
(NU5) changes in #392. I didn't have time to fix the tests at the time.
Also, this fixes a few lint problems.
2022-06-12 12:50:42 -06:00
Larry Ruane ba1b931986 add --sync-from-height command-line option
This causes lightwalletd to discard cached blocks at the given height
and beyond. This in turn causes it to re-fetch those blocks from zcashd.
It's similar to --redownload, except that option discards all blocks
(equivalent to --sync-from-height 0, but the existing --redownload is
retained for compatibility).

This is mostly intended for testing. It's sometimes useful to force the
node to (re)sync some recent blocks, but redownloading all of them takes
around an hour.
2022-05-24 15:17:38 -05:00
Larry Ruane dfac02093d Fix V5 transaction txid (#392)
This is a shortcut fix. Instead of replicating the zip244 transaction
logic that's implemented in librustzcash:
zcash_primitives/src/transaction/components/orchard.rs

cheat by calling getblock with verbose level 1, which prints the txid
of each transaction. This currently requires calling getblock twice,
once for the raw hex (as we have always done), and again to get the
transaction IDs. An easy improvement would be to add the raw hex to
verbosity 1 result. (Or have a new verbosity that shows both.)
2022-05-24 09:23:15 -05:00
Steven Smith ab4c0fef70 Add support to GetTreeState to return Orchard final state 2022-05-10 23:21:26 -06:00
Larry Ruane bdaac63f3e improve reorg by using getbestblockhash 2021-08-30 16:41:24 -06:00
Larry Ruane b1f3687d83 add MempoolStream unit test 2021-07-29 13:47:53 -06:00
Larry Ruane 6357f7f15b Refactor mock Sleep, add mock Now time function
Instead of the Sleep function pointer being a standalong global
variable, move it into a new Time struct, and add a Now function
pointer, so that time.Now() can be mocked. Time.Now() isn't used yet.
This will be cleaner if we need to mock more time-related functions in
the future.
2021-07-29 13:47:53 -06:00
Larry Ruane 503b9b256b modifications to adityapk00 mempool streaming API
This commit is based on adityapk00 streaming mempool interface but
avoids using goroutines, which are difficult to reason about.

Co-authored-by: Aditya Kulkarni <adityapk@gmail.com>
2021-07-29 13:47:53 -06:00
Aditya Kulkarni c3e1b98d4f Mempool Streaming API 2021-07-29 13:47:53 -06:00
Larry Ruane a4cc08b89e GetBlockRange: allow start < end, return blocks in reverse order 2021-05-18 15:38:26 -06:00
Larry Ruane 4e561f2cfd add darksidewallet support for GetAddressUtxos
Add a new darksidewallet gRPC to add a utxo that can be returned by the
production GetAddressUtxos, for example:

grpcurl -plaintext -d '{"address":"t1g1HQJuwDoStGrYYLj8VhLu1J5igd8TNXV","txid":"1zjB42Z7FtwRZOBNMlTubCgx9l3dsZSqXxmWpuZXJto=","script": "dqkU8saQsCVS4mNwcByoGCtfOaHFaCiIrA==","valueZat": "3010000","height": "686773"}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/AddAddressUtxo

Then the following returns this entry:

grpcurl -plaintext -d '{"startHeight":0,"maxEntries":2,"addresses":["t1g1HQJuwDoStGrYYLj8VhLu1J5igd8TNXV"]}' localhost:9067 cash.z.wallet.sdk.rpc.CompactTxStreamer/GetAddressUtxos

You can also clear the list of entries:

grpcurl -plaintext localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/ClearAddressUtxo
2021-04-26 11:42:03 -06:00
Larry Ruane dcad72ed25 generalize GetAddressUtxos to accept taddr list 2021-04-08 11:22:12 -06:00
Larry Ruane ad739ce055 allow Ping testing grpc only if explicitly enabled 2021-03-08 12:25:02 -07:00
Larry Ruane 5c5c4b882f check disk write return values 2021-03-08 11:21:33 -07:00