-
Notifications
You must be signed in to change notification settings - Fork 119
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
Implement sighash #870
Implement sighash #870
Conversation
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.
I'm not sure if you wanted reviews yet, but I noticed a few things that might be helpful.
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: teor <teor@riseup.net>
/// The `input` argument indicates the transparent Input for which we are | ||
/// producing a sighash. It is comprised of the index identifying the | ||
/// transparent::Input within the transaction and the transparent::Output | ||
/// representing the UTXO being spent by that input. |
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.
not positive this description is correct
Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
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.
OK! I walked through the ZIP143 and ZIP243 descriptions and reference impls and this looks good to go (of course the test vectors are already passing but still), yay!
@yaahc I can merge this by squashing, but a rebase has conflicts |
squash is preferred, tyty |
add test for checking that we can verify a checkpoint reorg things a little switch to easier to use lines api cleanup test itself cleanup config logic make semantics more obvious fix failing tests include extra info in test child errors and increase timeout chain: add Transaction::hash() method. This makes Transaction and Block have a consistent API. chain: add transaction hash test. chain: add docs about transaction and block hashes. chain: impl Display for {block, transaction}::Hash Also add a Display/FromStr round-trip proptest. chain: rename blockheaderhash reference. Rename old references to BlockHeaderHash and BlockHeight (#1002) * rename some references * Apply suggestions from code review Co-authored-by: Deirdre Connolly <durumcrustulum@gmail.com> Co-authored-by: teor <teor@riseup.net> Co-authored-by: Deirdre Connolly <durumcrustulum@gmail.com> Co-authored-by: teor <teor@riseup.net> Implement sighash (#870) * Implement sighash * move sighash logic to a separate module * start filling in more of the alg * start setting up a test case * make the test useful * Iter transaction inputs * better error message for expect * add support for zip243 sighash * ohey first testvector is passing, yayyy * pass the second testvector * add last testvector * move a use statement * use common deserialization code for amount everywhere * cleanup attributes * bring in fixed preimage * fix discrepancy with spec * always deserialize as a signed value * Update zebra-chain/src/transaction/sighash.rs * update unreachable statements * add serialization impls for nonnegative amounts * Apply suggestions from code review * document sighash fn * tweek docs * fix mistake in translation for zip243 * consistent error messages * reorder because i like it more that way * document more panics * Update zebra-chain/src/amount.rs * Add comment regarding the serialization of spend descriptions in sighash Co-authored-by: teor <teor@riseup.net> Co-authored-by: Deirdre Connolly <deirdre@zfnd.org> build(deps): bump indexmap from 1.5.2 to 1.6.0 Bumps [indexmap](https://github.com/bluss/indexmap) from 1.5.2 to 1.6.0. - [Release notes](https://github.com/bluss/indexmap/releases) - [Commits](indexmap-rs/indexmap@1.5.2...1.6.0) Signed-off-by: dependabot[bot] <support@github.com> network: add AddressBook::potentially_connected_peers(). network: add Network::default_port(). Add test for metrics and tracing endpoints (#1000) * add metrics and tracking endpoint tests * test endpoints more * add change filter test for tracing * add await to post * separate metrics and tracing tests * Apply suggestions from code review Co-authored-by: teor <teor@riseup.net> Co-authored-by: teor <teor@riseup.net> network: fix bug in inventory advertisement handling (#1022) * network: fix bug in inventory advertisement handling The RFC https://zebra.zfnd.org/dev/rfcs/0003-inventory-tracking.html described the use of a `broadcast` channel in place of an `mpsc` channel to get ring-buffer behavior, keeping a bound on the size of the channel but dropping old entries when the channel is full. However, it didn't explicitly describe how this works (the `broadcast` channel returns a `RecvError::Lagged(u64)` to inform receivers that they lost messages), so the lag-handling wasn't implemented and I didn't notice in review. Instead, the ? operator bubbled the lag error all the way up from `InventoryRegistry::poll_inventory` through `<PeerSet as Service>::poll_ready` through various Tower wrappers to users of the peer set. The error propagation is bad enough, because it caused client errors that shouldn't have happened, but there's a worse interaction. The `Service` contract distinguishes between request errors (from `Service::call`, scoped to the request) and service errors (from `Service::poll_ready`, scoped to the service). The `Service` contract specifies that once a service returns an error from `poll_ready`, the service can be assumed to be failed permanently. I believe (but haven't tested or carefully worked through the details) that this caused various tower middleware to report the entire peer set service as permanently failed due to a transient inventory "error" (more of an indicator), and I suspect that this is the cause of #1003, where all of the sync component's requests end up failing because the peer set reported that it failed permanently. I am able to reproduce #1003 locally before this change and unable to reproduce it locally after this change, though I have not tested exhaustively. * network: add metric for dropped inventory advertisements Co-authored-by: teor <teor@riseup.net> Co-authored-by: teor <teor@riseup.net>
This can be merged as-is with the understanding that no other code should be using it yet, and the associated issue 306 is not complete, to unblock a reorg of the zebra-chain crate.