Commit Graph

454 Commits

Author SHA1 Message Date
Larry Ruane 2dd37cf119 some tweaks to prices.go (GetZECPrice, GetCurrentZECPrice)
Simplified locking; there is no need for a read-write mutex, this code
is not performance-critical. Removed some of the go routines because
they're not needed and the locking and concurrency are easier to reason
about without them.

NOTE: there is some test code left in here, search for "XXX testing" and
remove before committing! This test code makes things happen faster:
Instead of fetching prices every 15 minutes, do it every minute. Also,
write historical data every minute, instead of once per day.

Another change needed is to remove some of the logging. It's good for
now during testing, but it's too much for production.
2022-06-12 13:10:36 -06:00
Larry Ruane 5e4e4272ab fix average calculation 2022-06-12 13:10:36 -06:00
Aditya Kulkarni 8fe7c0ca1b Implementation 2022-06-12 13:10:29 -06:00
Aditya Kulkarni c6e8adbe73 Price API stub implementation 2022-06-12 13:06:17 -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 34f4f23466 remove vendor, clean up module files and Makefile
It's better not to have the vendor directory; it was needed before
modules worked well in Go. These days, the `go.mod` and `go.sum` files
nail down the exact versions of each dependency as well as the vendor
directory did. There are many modern Go projects, such as
docker/compose, that don't have a vendor directory.

So don't run `go vendor`, or if you do, don't git-add the files that
are downloaded.

Another advantage of removing the vendor directory is that the repo is
only 9% of its former size.

Another thing I did as part of this commit is to remove all the
`require` lines in `go.mod` and then ran `go tidy`. This repopulated the
require lines but with the latest versions. This may fix #378 but I'm
not sure (because I still see `gopkg.in/yaml.v2 v2.4.0 // indirect`
in `go.mod`.
2022-06-10 14:47:01 -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 68789356fb update RTD index.html for Orchard
This file is generated from the *.proto files, and had gotten out of date.
Updating it required installing docker; I followed these instructions:
https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

I also needed to:

$ sudo chmod 666 /var/run/docker.sock
2022-04-19 11:38:26 -07:00
Larry Ruane 26df6f0992 add V5 transaction (orchard) parsing test 2022-04-12 00:05:29 -06:00
Larry Ruane 631bb16404 fix orchard action ciphertext comment
No functional change. See:
https://github.com/zcash/librustzcash/pull/515#discussion_r808624455
2022-02-16 22:22:46 -07:00
Larry Ruane e53167b6a1 go mod tidy && go mod vendor (update dependencies) 2022-02-16 22:11:50 -07:00
Larry Ruane 7c9bbfa9aa upgrade protoc toolchain 2022-02-16 22:11:50 -07:00
Larry Ruane 83bb19918f restore gRPC GetMempoolTx
This was removed as part of PR #358 (commit "remove gRPC GetMempoolTx")
but should not have been, so it's being restored.
2021-12-09 15:26:55 -07:00
teor c7b1be9fd2 Update list of RPC methods in README 2021-12-08 14:23:52 -07:00
Dimitris Apostolou 13de3232b3 Fix typos 2021-11-30 17:12:35 -07:00
Larry Ruane c006cfe5fb compact blocks should include Orchard transactions
In previous commit, I forgot to include Orchard transactions in compact
blocks (so they will now include transactions with either Sapling or
Orchard transactions).
2021-11-30 14:23:18 -07:00
Larry Ruane 4e1910aeea add NU5 Orchard transaction data to CompactBlock 2021-11-30 10:16:28 -07:00
Larry Ruane fdc54babf2 performance: don't deserialize unused tx fields 2021-11-30 08:36:09 -07:00
Larry Ruane 6d7d9f11a6 improve tx parser memory behavior
This is a non-functional change. Instead of `rawTransaction` (which
carries the result of parsing a full transaction from zcashd) containing
slices of _pointers_ to separately-allocated memory (one allocation for
each spend, for example), allocate a slice of spends (one contiguous
range of memory). A quick benchmark shows sync improves by about 8%.
2021-11-29 18:24:44 -07:00
Larry Ruane ddf3781a60 parse V5 (nu5) transactions
TODO:
- store, instead of just skip over, nu5 transaction fields
- add relevant nu5 fields to CompactBlock
- restore disabled V4 unit tests
- add V5 test vectors to unit tests

The reason most of the V4 transaction and block unit tests are removed
is that they used V3 transactions, which lightwalletd never sees in
production, since lightwalletd starts at Sapling activation (which has
V4 transactions). So these tests were always wrong, in a way. This
commit simplifies the parsing code by removing support for V3 (since it
was never needed). The tests need to be updated to V4, but we'll do
that in a later PR.
2021-10-24 13:30:35 -06:00
Sasha 9263e7f111
Merge pull request #366 from zcash/sasha-doc-updates
Improve documentation for use with docker-compose
2021-09-28 20:37:24 -05:00
Sasha 52ec73c884
Merge pull request #365 from superbaud/master
Improve documentation for use with docker-compose
2021-09-28 20:27:36 -05:00
Taylor Hornby 2defc2501d
Fix em-dashes and add instructions to use a random password 2021-09-28 18:32:19 -06:00
Sasha e150fa7790
clarify that we're exposing lwd to the network 2021-09-28 19:16:43 -05:00
Sasha f84af8fe71
added notes on the multiple zcashd.conf files 2021-09-28 19:13:35 -05:00
Sasha ca4905a6a2
correct typos 2021-09-28 18:55:45 -05:00
adityapk00 33d3d53d34 Verify rawtx 2021-09-07 14:25:20 -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 4f00783f48 remove gRPC GetMempoolTx
This RPC has never been used, and is now superceded by GetMempoolStream.
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 3f669c3d19 added unit test 2021-07-26 23:20:05 -06:00
Aditya Kulkarni 39179a9721 Return hashes from getlatestblock 2021-07-26 23:20:05 -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 d292bfaea5 update to latest go, protobufs, grpc toolchain
Should be no functional differences. This patch was generated by
installing the latest tools and running `make update-grpc`.
2021-04-07 12:58:01 -06:00
Larry Ruane 0995e130f4 eliminate genblocks compile warning
testtools/genblocks/main.go:91:74: conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
https://github.com/golang/go/issues/32479
2021-04-07 10:45:46 -06:00
Larry Ruane 17c47cfebe call checkTaddress() for each given taddress 2021-03-08 12:25:02 -07:00
Larry Ruane 824cb8dc8e check SplitN() return value to prevent indexing beyond end of slice 2021-03-08 12:25:02 -07:00
Larry Ruane ad739ce055 allow Ping testing grpc only if explicitly enabled 2021-03-08 12:25:02 -07:00
Larry Ruane 86a76a96cb check txid (hash0 length argument, must be 64 2021-03-08 11:23:05 -07:00
Larry Ruane 5c5c4b882f check disk write return values 2021-03-08 11:21:33 -07:00
Larry Ruane 22dda4a28d check all json.Unmarshal() error returns 2021-03-08 11:14:48 -07:00
Larry Ruane c7c5da1fda don't log method names to stderr unless --grpc-logging-insecure 2021-03-08 11:12:26 -07:00
Larry Ruane d9d12998b2 remove error logging that client requests can cause 2021-03-08 10:51:31 -07:00