-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sapling Integration: Chain + Wallet transaction manager. #1798
Sapling Integration: Chain + Wallet transaction manager. #1798
Conversation
15333b2
to
481e0b3
Compare
955b8c6
to
561c5d3
Compare
2fff9ec GetShieldedSpendsHash & GetShieldedOutputsHash assert txTo.sapData existence. (furszy) 3219140 transaction primitive: cleaning a weird GetTransaction function in the .cpp file. (furszy) ac88244 Validation: guard v2 shielded transaction serialization for pre-v5 upgrade window. (furszy) c613b4f Rename SIGVERSION_WITNESS_V0 to SIGVERSION_SAPLING. (furszy) 831f742 Not try to serialize empty fields in Sapling signature hash (furszy) d73ed0a Sapling signature hash (Custom version of ZIP 243) (furszy) b3cfc3c Introduce SignatureHash personalization updates. (furszy) 5e9a0d3 transaction: fix sapling version to 2. (furszy) 6d04323 make SaplingTxData Optional in transaction primitive (furszy) 34ef66a Transaction: add sapling data to toString (furszy) 3ed6bca Missing SaplingOutPoint::ToString() method implemented. (furszy) e8c0b48 [Sapling] Transaction GetShieldedValueIn & GetValueOut back port (furszy) 4ab08fa Fix sighash_tests. (furszy) cf77a5d sapling_transaction.h migrated to the new serialization (furszy) 12fc142 Add serialization for std:list objects. (furszy) abba85d Basic Sapling transaction primitive data. (furszy) fc3444c Backport zkSNARK compression. (furszy) b000a6f Transaction: Implement BaseOutPoint class. (furszy) 1d07756 Add serialization for primitive boost::optional<T>. (furszy) Pull request description: Work coming from #1798. Decoupled commits related to the Sapling transaction primitive data and the new signature hash to make the review a little bit easier there. Plus, squashed some of them. List of commits taken from #1798: Primitive data: * Add serialization for primitive boost::optional<T>. —> 659cc55 * Transaction: Implement BaseOutPoint class. —> f17b23c * Backport zkSNARK compression. —> 5dbc3c9 * Basic Sapling transaction primitive data --> c49594f * Add serialization for std:list objects. —> 7cc57f7 * sapling_transaction.h migrated to the new serialization —> dbb618f * Fix sighash_tests —> e1e3316 * Transaction GetShieldedValueIn & GetValueOut back port —> 0fbe023 * BugFix in GetShieldedValueIn —> 57ee1bc * Missing SaplingOutPoint::ToString() method implemented —> e1fe5bf7 * Transaction: add sapling data to toString —> 26ce38b * make SaplingTxData Optional in transaction primitive — PARTIALLY —> c3b1aed * Cleaning compiler warnings — PARTIALLY —> 644c381 * transaction: fix sapling version to 2. —> 8fc595f * Transaction: GetDustThreshold method implemented. —> dadf199. * Transaction:hasSaplingData check is enough checking for vShieldedOutput and vShieldedSpend emptiness. —> 57d3236 Signature hash: * Introduce SignatureHash personalization updates —> 550217f * Enable sigversion for Sapling transactions. —> c04abe1 * Sapling signature hash (Custom version of ZIP 243) —> eac206e * Not try to serialize empty fields in Sapling signature hash ---> ce5a467 ACKs for top commit: random-zebra: Nice. 🍻 ACK 2fff9ec Fuzzbawls: utACK 2fff9ec Tree-SHA512: 64eb110dad0ac67afbfbad506337ea1cea254c07d6739a71994bc0144a0fc4e5d35fa25ca588cea3a9d59a5f6164ca6cc28c41292da79d773127ea273450ac28
561c5d3
to
6afe5f6
Compare
…rtup. 520d889 BugFix: g_IsSaplingActive flag wasn't being updated at startup. (furszy) Pull request description: Small bug introduced in #1814, the flag is set on every new tip but not initialized at startup. Discovered rebasing #1798 on top of master and running any sapling functional test. As `g_IsSaplingActive` is false at startup, the transaction hash is different, making the merkle tree hash different, failing in `VerifyDB`. ACKs for top commit: random-zebra: utACK 520d889 Fuzzbawls: utACK 520d889 Tree-SHA512: 609d0257a524aa85a12296ab827b0cd9dc640e60455801203d52709672e79cd9837f606743b976e5cc64d9f0659d81bd19b5bb6ec6b339fd01eebf44af58677e
5dda553 migrate list ser to the newer ser form. (furszy) Pull request description: Straightforward and easy to check PR. The list serialization wasn't updated to the latest serialization format (`nType` and `nVersion` removal). Decoupled from #1798 --> 4053e97 . ACKs for top commit: Fuzzbawls: ACK 5dda553 random-zebra: utACK 5dda553 and merging... Tree-SHA512: eddf0db7ac17aa6a56cc3a293a2bb0787a0771271cb8452191520869a8f9dd3226a351b2eb01b403d99d6b9d91e1094f4b620bb5a65e5bfd8c37ecbcc6303e85
6afe5f6
to
56ace43
Compare
Rebased on top of master, solved the conflicts and adapted the code to all new changes on master. Linux travis job will continue failing in two unit test here for now, the solutions were directly included in #1870 and #1884 PRs. (1) json ser/deser, (2) boost filesystem error. Once them get merged, will rebase it again. |
626b0d9 incrementalmerkletree file added to cmake. (furszy) 4368a00 incremental merkle tree test: resolve invalid deserialization/serialization data equality check. (furszy) 9cfb0a7 rename sapling util file to not shadow src/util file. (furszy) 68d494d Incremental Merkle Tree + merkletree tests back port (furszy) Pull request description: This is coming from #1798, focused on include the incremental merkle tree primitive with all of its unit tests. This base primitive class is almost one to one with upstream. Decoupled the following commits: * Incremental Merkle Tree + merkletree tests back port —> 762d5f1 * Rename sapling util file to not shadow src/util file --> cae89d3 ACKs for top commit: random-zebra: ACK 626b0d9 Fuzzbawls: utACK 626b0d9 Tree-SHA512: 9bae913aa553ec42864b5f5f252f8ce6bd9fd6fd89011c63c31e1de06cba820dc99feeaabe38801f012a54abc81b8213aee0334695c4e0673591e48dc07d5954
b11b357 removing global namespace usage for noteencryption and sapling_note unit tests (furszy) 52da4e0 [Sapling] Note Encryption unit tests back ported. (furszy) 4d2f01a [Sapling] change cm() to cmu() in SaplingNote class (furszy) Pull request description: Another decoupling from #1798. Similar to #1870, these changes are part of the primitives unit test coverage back port work. Commits included: * change cm() to cmu() in SaplingNote class —> d437276 * Note Encryption unit tests back ported. —> e4c1bbf ACKs for top commit: Fuzzbawls: ACK b11b357 random-zebra: re-utACK b11b357 Tree-SHA512: 56914dba65ee239f7e6713a111abca5bd1a4e684fadcdbed4314295f499f3b6689271fa7999c7f182dcba069ebe29299bed944e7ee6b1bcb3aad987884811242
9260303
to
9fb808f
Compare
69db60e Update sighash tests to include Sapling transactions. (furszy) Pull request description: Decoupled from #1798 d0099f5 . Initial sighash unit test coverage for shielded transactions. ACKs for top commit: random-zebra: utACK 69db60e Fuzzbawls: ACK 69db60e Tree-SHA512: f75a9241d3f9fad1f9c6928e7926630dbc9e5d45c888732d45fa5bf481ac7a5e742142de6e62346cb7691bdda9705e90ecb09167fe2123c726c61abd74c1a82a
9fb808f
to
2c7502a
Compare
0903941
to
50bcaa8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really awesome stuff, left some more comments, but most of them can be tackled later.
ACK 50bcaa8
// We shouldn't be able to decrypt with the empty ovk | ||
BOOST_CHECK(!libzcash::AttemptSaplingOutDecryption( | ||
tx.sapData->vShieldedOutput[0].outCiphertext, | ||
uint256(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: UINT256_ZERO
self.num_nodes = 3 | ||
self.setup_clean_chain = True | ||
saplingUpgrade = ['-nuparams=v5_dummy:1'] | ||
self.extra_args = [saplingUpgrade, saplingUpgrade, saplingUpgrade] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same style nit as in the other test
connect_nodes_bi(self.nodes, 0, 1) | ||
connect_nodes_bi(self.nodes, 2, 1) | ||
connect_nodes_bi(self.nodes, 3, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why bidirectional connection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is a good question for the entire test suite after a node shutdown/restart actually.
|
||
verify_utxos(bob, amounts, bob_addr) | ||
verify_utxos(charlie, amounts, ipk_addr["address"]) | ||
verify_utxos(charlie, amounts, ipk_addr2["address"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to verify again, as we already ensured (line 106) that ipk_addr["address"]
and ipk_addr2["address"]
are equal.
RPC: Include shielded_sendmany non string params.
sapling_wallet.py test added to test_runner.py test suite: get_coinstake_address util method implemented.
Back port + adaptation to our sources.
…il the functionality gets implemented.
Commit from @Fuzzbawls :) .
50bcaa8
to
1af57c0
Compare
…tead of returning an error string.
1af57c0
to
1b6f701
Compare
Updated per feedback, left only few nit comments for another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-utACK 1b6f701 after last push
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 1b6f701
9047f74 SSPKM: getCredit improved using the SaplingNote cached amount. (furszy) b8a6a16 Cache note amount in the SaplingNoteData to not have to decrypt the note every time that the wallet needs to know the note value. (furszy) 56684af CWalletTx: calculate + cache shielded available credit and shielded change unit test. (furszy) 4e072de CWalletTx, shielded available credit cache flow implemented. (furszy) 565b3b1 Cache shielded change in CWalletTx. (furszy) 3a87eb1 Sapling wallet: Implemented GetShieldedChange (furszy) 9934f23 Unit test to validate the cached balance over shielded to remote shielded transactions. (furszy) 0d34607 Unit test verifying the cached shielded debit & credit balances. (furszy) b47e783 Move GetCredit CTransaction to CWalletTx to be able to decrypt the sapling note if needed. (furszy) 29c8641 Implement and connect to wallet GetDebit for shielded amounts. (furszy) 8f19bc7 Implement GetCredit for shielded amounts and connect it to the wallet. (furszy) 00ece7e Include shielded type to ismine enum. (furszy) 6ef8da4 Implement IsNoteSaplingChange simpler wrapper method. (furszy) 1742fc9 Wallet: decouple FindNotesData and AddMissingIVKToKeystore code from AddToWalletIfInvolvingMe. (furszy) 66fa102 Create method GetValidSaplingReceive to receive shielded balance from dummy transparent inputs. (furszy) d660344 Wallet::AddToWalletIfInvolvingMe use blockHash instead of CBlockIndex pointer. The block index is not needed and it will make unit tests simpler to code. (furszy) 2996db3 Wallet::Setup, memory only flag to not try to write the chain data in db (only used in unit tests). (furszy) Pull request description: Up until now, one of the several capabilities that #1798 introduced was the wallet's shielded transactions balances calculation, a purely on-demand process (which is not so performant as txs balances are requested more than once during the entire software lifecycle). This PR is going further, introducing a new wallet balance cache system for shielded transactions. Covered by a good amount of units tests that can be run pre and post the new cache system. This PR is obviously built on top of 1798. Part of the shielded GUI work that will be coming soon. ACKs for top commit: random-zebra: utACK 9047f74 (with few nits that can be ignored). Fuzzbawls: utACK 9047f74 Tree-SHA512: 3fa8131b44f93e3d9c058fe745a73ed6fd14c4a045f807e5e7b48d4ba14c6255b893ee1293618732fdfd7c4c7e8fc365b282a12bb24b6891cadde0d1f0a9a9cf
Sapling integration, milestone 3 and 4.
Essentially, Sapling running on the regtest network -- yeah :), 🎉 🎉 -- and being covered by a good amount of unit and functional tests . (Still, not enough tests. We definitely need more).
This is the last big PR for Sapling work that have (fulfilling the complete base protocol functionality). All of the remaining work can be covered in smaller PRs.
Covering the following points:
Sapling transaction data:
Sapling transactions management:
SaplingOperation
class to decouple the Shielded tx creation + broadcast flow from the wallet sources.Blockchain:
RPC Server:
New Commands:
Modified Commands:
Unit test coverage:
Functional tests:
TODO, upcoming work:
Need further discussion:
...........................................................................
Work based on the ECC implementation. It's NOT one-to-one. Have adapted it into our network + modified the architecture and improved specific areas of the sources. There is still lot of work to do, plenty of space for improvements :) .
...........................................................................
Sorry for the massive PR but couldn't resist myself 🙏 . We can definitely think on how to decouple it in smaller PRs if things get hard to review. As said above, commits should be atomic enough but i know that it's not, commit wise, a 100% incremental work.