Skip to content
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

Merged
merged 46 commits into from
Sep 5, 2020
Merged

Implement sighash #870

merged 46 commits into from
Sep 5, 2020

Conversation

yaahc
Copy link
Contributor

@yaahc yaahc commented Aug 11, 2020

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.

@yaahc yaahc requested a review from dconnolly August 11, 2020 01:05
Copy link
Contributor

@teor2345 teor2345 left a 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>
@yaahc yaahc added A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement E-med NU-1 Sapling Network Upgrade: Sapling specific tasks and removed rust labels Aug 11, 2020
@dconnolly dconnolly mentioned this pull request Aug 11, 2020
27 tasks
@yaahc yaahc requested a review from teor2345 August 26, 2020 23:27
Comment on lines +162 to +165
/// 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.
Copy link
Contributor Author

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

yaahc and others added 2 commits August 26, 2020 17:06
Co-authored-by: Deirdre Connolly <deirdre@zfnd.org>
@yaahc yaahc dismissed teor2345’s stale review September 1, 2020 19:03

addressed all comments

@yaahc yaahc requested a review from dconnolly September 1, 2020 21:30
dconnolly
dconnolly previously approved these changes Sep 5, 2020
Copy link
Contributor

@dconnolly dconnolly left a 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!

@dconnolly
Copy link
Contributor

@yaahc I can merge this by squashing, but a rebase has conflicts

@dconnolly dconnolly merged commit 6744f41 into main Sep 5, 2020
@dconnolly dconnolly deleted the sighash branch September 5, 2020 23:31
@yaahc
Copy link
Contributor Author

yaahc commented Sep 6, 2020

squash is preferred, tyty

yaahc added a commit that referenced this pull request Sep 10, 2020
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement NU-1 Sapling Network Upgrade: Sapling specific tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pull in/tidy up SIGHASH
4 participants