Commit Graph

45 Commits

Author SHA1 Message Date
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
Larry Ruane de8b6230ba extend darksidewallet locking
See https://github.com/zcash/lightwalletd/issues/433
2023-05-27 07:53:12 -06: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 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 bdaac63f3e improve reorg by using getbestblockhash 2021-08-30 16:41:24 -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 d7f35f2713 fix database file location bug introduced by PR320
PR 320 introduced a bug that causes the `blocks` and `lengths` database
files to be located one directory level higher than it they should be.

The bug doesn't cause any functional problem, it only makes the
lightwalletd do more work (re-download the block cache), and it also
makes it not possible to switch between testnet and mainnet.

This patch locates the database files back where they belong.
2021-01-11 12:19:51 -07:00
Larry Ruane 33e7312218 add zcashd versioning to GetLightdInfo result 2020-12-03 22:55:08 -07:00
Larry Ruane 7381129740 add GetMempoolTx() 2020-09-10 14:01:01 -06:00
Larry Ruane 31a19484e2
Improve error checking, README improvements (#278)
Deserialize blocks and transactions as they are staged, to catch errors
earlier (such as trying to stage transactions as blocks), improve logging,
improve error handling (don't crash if ApplyStaged is given a height
that's higher than one beyond the latest active block).
2020-06-03 19:18:04 -06:00
Larry Ruane faca1ecbef
increase the 252 per-block transaction limit (#273) 2020-06-03 18:58:26 -06:00
Taylor Hornby 2d8a55c53f Fix missing hex encoding of darksidewalletd's sendrawtransaction response 2020-05-28 16:05:43 -06:00
Larry Ruane 1dd63f2ca8 add --darkside-timeout option to override 30-minute default shutdown 2020-05-21 11:48:03 -06:00
Larry Ruane 0217670d8c add logging for darkside rpcs 2020-05-21 11:48:03 -06:00
Larry Ruane 007dbbf13c fix first block hash 2020-05-21 11:48:03 -06:00
Larry Ruane 2f0b2054ba Fix transaction staging
The following works:

grpcurl -plaintext -d '{"saplingActivation": 663150,"branchID": "bad", "chainName":"x"}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/Reset
grpcurl -plaintext -d '{"height":663150,"nonce":5,"count":3}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/StageBlocksCreate
grpcurl -plaintext -d '{"height":663152,"url":"https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/t-shielded-spend"}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/StageTransactions
grpcurl -plaintext -d '{"height":663152}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/ApplyStaged
grpcurl -plaintext -d '{"height":663152}' localhost:9067 cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlock
(shows the block with one transaction)
2020-05-21 11:48:03 -06:00
Larry Ruane 7ac1a3f983 small improvements to transaction stuff, small fixes 2020-05-21 11:48:03 -06:00
Larry Ruane 3defdcd1ee Improve error handling 2020-05-21 11:48:03 -06:00
Larry Ruane f8794dbe05 update submitblocks.sh, return an error if GetBlock height is too low, instead of crashing 2020-05-21 11:48:03 -06:00
Larry Ruane 39348100a9 fix StageTransactions, vendor = ECC LightWalletD 2020-05-21 11:48:03 -06:00
Larry Ruane 391e886afc better error handling, remove unused DarksideTx 2020-05-21 11:48:03 -06:00
Larry Ruane 7420d565a8 don't special-case darkside in SendTransaction, just use the mock rpc handler 2020-05-21 11:48:03 -06:00
Larry Ruane 3bada32bee fixes on last commit, especially StageBlocksCreate 2020-05-21 11:48:03 -06:00
Larry Ruane f1e793796f implement staging, not well tested 2020-05-21 11:48:03 -06:00
Larry Ruane 52ac837370 New "staging" api (StageBlocks, StageTransactions, ApplyStaged)
Also remove the initial block load (all blocks will come from the
Staging APIs), but there is still more to do (this does not even
start up correctly) but darkside.proto is correct, we believe.
2020-05-21 11:48:03 -06:00
Larry Ruane c8ee805933 remove Blockchaininfo json type assertions, no functional change 2020-05-21 11:48:03 -06:00
Larry Ruane d7e1005523 DarksideAddBlock(): remove generation of correct prevhash 2020-05-21 11:48:03 -06:00
Larry Ruane 22d5c97e7f SetBlocksURL: replace curl with http client 2020-05-21 11:48:03 -06:00
Larry Ruane d08d8980a8 add support for gRPC GetTransaction() (mined tx) 2020-05-21 11:48:03 -06:00
Larry Ruane e3aca9bec7 review comment: 30-minute shutdown improvement
Safer to shutdown darksidewalletd directly after 30 minutes, instead
of waiting for a zcashd rpc to occur (darksideRawRequest());
also using a goroutine is simpler.
2020-05-21 11:48:03 -06:00
Larry Ruane 5e37f408e3 address review comments 2020-05-21 11:48:03 -06:00
Larry Ruane 86fd87404b add darkside SetMetaState, SetBlocksURL for reorg testing 2020-05-21 11:48:03 -06:00
Larry Ruane c2a6306ce5 Misc cleanups and fixes
- improved corruption recovery (don't back up by just 1 block at a time)
- move darksidewallet gRPCs to their own .proto file
- this force-push removes my commits for reorg testing using SetState
2020-04-24 16:55:47 -06:00
Taylor Hornby 673a9635fc Run gofmt on server/main.go and common/darkside.go 2020-04-24 16:55:47 -06:00
Taylor Hornby d55d9b1c64 Add tool for generating fake blockchains 2020-04-24 16:55:47 -06:00
Taylor Hornby 1a93b8d97c Add darksidewalletd mode for reorg testing. 2020-04-24 16:55:47 -06:00