Commit Graph

12 Commits

Author SHA1 Message Date
Jane Lusby 246e7cd2a9
Start testing out new version of `eyre` and `color-eyre` in zebra (#526)
* port to new version of eyre without generics

* correctly setup color_eyre hooks

Co-authored-by: Jane Lusby <jane@zfnd.org>
2020-06-22 15:36:23 -07:00
teor 26a58b23de state: Make Response::Added return the block header hash
Move block header hashing from zebra-consensus to zebra-state.
Handle zebra-state AddBlock errors in zebra-consensus BlockVerifier.
Add unit tests for BlockVerifier state error handling.

Part of #428.
2020-06-12 09:46:18 -07:00
Henry de Valence cbb50ea506 Simplify `where` bounds on services.
Placing bounds on the service's future is less ideal, because the future is
already constrained by the `Service` trait, so the bounds can be expressed more
directly and simply by bounding the service itself.

If the verification service already has to have a generic parameter for the
future (the `ZSF`), it could instead be generic over `S`, the storage service.
This has the upside that it's no longer required for the verification service
to box the storage service, so we don't add any extra layers of indirection,
and the where bounds become more straightforward, since they're centered on the
requirements for the storage service itself, not the future it returns.
Finally, we can simplify the bounds by using the request / response types
directly rather than defining wrapper types.
2020-06-12 09:46:18 -07:00
Henry de Valence adf0769ac2 Get the round trip test to pass.
The reason the test failed is that the future returned by `call` on the state
service was immediately dropped, rather than being driven to completion.
Instead, we link the state update future with the verification future by
.awaiting it in an async block.

Note that the state update future is constructed outside of the async block
returned by the verification service.  Why?  Because calling
`self.state_service.call` requires mutable access to `state_service`, which we
only have in the body of the verification service's `call` method, and not
during execution of the async block it returns (which could happen at some
later point, or never).

In Tower's model, the `call` method itself only does the work necessary to
construct a future that represents completion of the service call, and the rest
of the work is done in the future itself.  In particular, the fact that
`Service::call` takes `&mut self` means two things:

1. the service's state can be mutated while setting up the future, but not
during the future's subsequent execution,

2. any nested service calls made *by* the service *to* sub-services (e.g., the
verification service calling the state service) must either be made upfront,
while constructing the response future, or must be made to a clone of the
sub-service owned by the the response future.
2020-06-12 09:46:18 -07:00
teor 15bc64aed9 consensus: add a (failing) verify round-trip test
This test doesn't work, because the futures are not used correctly.

Part of #428.
2020-06-12 09:46:18 -07:00
teor c2590ce526 consensus: Make future handling a little nicer
Part of #428.
2020-06-12 09:46:18 -07:00
teor 7b8707be1e consensus: Add a simple block verify test
Part of #428.
2020-06-12 09:46:18 -07:00
teor d0a833f3fb consensus: Make the state service pluggable in block verification
We want to allow different state service implementations, and wrapped
state services. So we make verify::init() take a state_service, and
store that service in the BlockVerifier state_service field.

Part of #428.
2020-06-12 09:46:18 -07:00
teor 4181c8a5d5 consensus: Make BlockVerifier respond with the BlockHeaderHash
Part of #428.
2020-06-12 09:46:18 -07:00
teor c019726fb1 consensus: Add a script verifier stub
Part of #428.
2020-06-12 09:46:18 -07:00
teor af1d64b218 consensus: Add a transaction verification stub
Part of #428.
2020-06-12 09:46:18 -07:00
teor 8f2ddef0a4 consensus: Add a block verification service
Part of #428.
2020-06-12 09:46:18 -07:00