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

Design a way to use the Rust view server with mock consensus integration tests #3913

Closed
hdevalence opened this issue Feb 29, 2024 · 3 comments · Fixed by #4471
Closed

Design a way to use the Rust view server with mock consensus integration tests #3913

hdevalence opened this issue Feb 29, 2024 · 3 comments · Fixed by #4471
Assignees
Labels
A-mock-consensus Area: Relates to the mock consensus engine
Milestone

Comments

@hdevalence
Copy link
Member

hdevalence commented Feb 29, 2024

Is your feature request related to a problem? Please describe.

Currently we are trying to expand the capability of our state machine tests, going depth-first: writing a few, targeted tests that incrementally expand the capability of the test harness and allow us to discover requirements.

These tests are intended to exercise functionality end to end, including client logic. Currently we do this with the MockClient, a minimal reference implementation of key Penumrba client logic.

However, a benefit and limitation of this approach is that we cannot automatically generate transaction plans, because the MovkClient cannot be used with a Planner. This is a benefit because we can write tests that are very precise about their state changes and do not rely on a much larger mass of code, but a limitation because more complex test logic would prefer to use the planner.

Additional context here: #3891 (comment)

Describe the solution you'd like

There are a lot of moving pieces and a lot of context to consider to figure out the right design. @cratelyn and I should pair to explore the best path forward.

🔗 related work

@github-project-automation github-project-automation bot moved this to 🗄️ Backlog in Penumbra Feb 29, 2024
@cratelyn cratelyn added the A-mock-consensus Area: Relates to the mock consensus engine label Feb 29, 2024
cratelyn added a commit that referenced this issue Mar 5, 2024
see #3913.

this is a speculative hack at providing a `ViewClient` implementation
for the mock client.

for now, only `todo!()` stubs are provided.
@cratelyn cratelyn self-assigned this Mar 5, 2024
@cratelyn cratelyn added this to the Sprint 1 milestone Mar 5, 2024
@cratelyn
Copy link
Contributor

cratelyn commented Mar 5, 2024

@hdevalence i prepared a scaffold in #3958, taking a small preparatory step towards using MockClient with Planner::plan().

@cratelyn
Copy link
Contributor

cratelyn commented Mar 6, 2024

#3896 is loosely related to this work.

@cratelyn cratelyn moved this from 🗄️ Backlog to In progress in Penumbra Mar 7, 2024
cratelyn added a commit that referenced this issue Mar 8, 2024
code motion, part 1 of 2.

see #3913. we want to run a view client in application tests, so that we
can use the `Planner` to build transactions. in order to create a view
client, we need to run a grpc server that it can talk to.

NB: we leave the "expensive" simulation service and the tendermint proxy
out of this function for now.
@cratelyn cratelyn modified the milestones: Sprint 1, Sprint 2 Mar 11, 2024
@cratelyn cratelyn moved this from In progress to 🗄️ Backlog in Penumbra Mar 11, 2024
cratelyn added a commit that referenced this issue Mar 12, 2024
see #3913, #3973 and #3588. this is a second attempt, following up on
#3980.

#### 🔭 background

NB: the difference between this and #3679 is that the latter (_which ran
afoul of a regression_) would have `penumbra-app` create a `Routes`,
that we would
[add](https://github.com/penumbra-zone/penumbra/pull/3679/files#diff-fbc4204ceb976c8cb30ed06168e2476700bae21bfd803e26281b2d026194d430R204)
to the builder (_which stays in `pd`_). here, i'm not trying to make
that cut between `Router` and `Routes`, and am attempting to hoist the
whole thing out of `pd`, without making changes to how we interact with
`tonic`. my aim is for us to be able to move this, without running into
that bug (#3697) again.

NB: after running into problems in #3980, i found a way to easily
reproduce the issue locally. my belief was that something related to our
dependencies' cargo features was at play. rather than isolate the issue,
it was easier to rewrite this (_it's just code motion, after all_) while
running some of the network integration tests in a loop.

unlike #3980, this moves the rpc server into `penumbra-app`, per
#3980 (comment)

#### 👁️ overview

we would like to use the rust view server in mock consensus tests. in
order to run the `penumbra_view::ViewServer` however, we need to spin up
the corresponding grpc endpoint for it to connect to.

this branch performs a bit of code motion, moving the `grpc_server` out
of `pd` and into `penumbra-app`. there will likely be other functional
changes to the code in question before we can use it in those tests, but
this PR is interested in moving that code into a place where our tests
can rely upon it.
@cratelyn cratelyn modified the milestones: Sprint 2, Sprint 3 Mar 18, 2024
@cratelyn cratelyn moved this from 🗄️ Backlog to Todo in Penumbra Mar 21, 2024
@aubrika aubrika modified the milestones: Sprint 2, Sprint 3 Mar 25, 2024
@cratelyn cratelyn moved this from Todo to Backlog in Penumbra Mar 27, 2024
@cratelyn
Copy link
Contributor

cratelyn commented May 6, 2024

#4081 has been fixed by #4312, so i am planning to pick this work back up.

@cratelyn cratelyn added this to the Sprint 6 milestone May 6, 2024
@cratelyn cratelyn moved this from Todo to In progress in Penumbra May 7, 2024
cratelyn added a commit that referenced this issue May 8, 2024
## describe your changes

this introduces some additional `tracing` instrumentation, used while
debugging
integration with the view server in mock consensus tests. because these
events
may be useful more broadly, and aren't strictly tied to testing, this is
cherry-picked out of that work for separate consideration.

## issue ticket number and link

* #3913

## checklist before requesting a review

- [x] if this code contains consensus-breaking changes, i have added the
"consensus-breaking" label. otherwise, i declare my belief that there
are not consensus-breaking changes, for the following reason:

this branch only makes changes to tracing spans and events. as this is
only altering telemetry, this is not consensus-breaking.

---------

Co-authored-by: Henry de Valence <[email protected]>
@aubrika aubrika modified the milestones: Sprint 6, Sprint 7 May 20, 2024
cratelyn added a commit that referenced this issue May 22, 2024
`check_worker()` is called by almost every public interface in the view
server, as a preliminary check that the worker task running in the
background has not recorded an error of some kind.

this commit makes a change to `check_worker()`, so that it does not need
to frivolously acquire, release, and subsequently reacquire the mutex in
the event of an error being stored in the slot.

tracing events and documentation are also added to this function.

x-ref: #3913
cratelyn added a commit that referenced this issue May 22, 2024
these are useful for the sake of following the sequence of function
calls when debugging issues related to the view server, the view server
worker, and integration tests making use of the `Planner`.

x-ref: #3913
cratelyn added a commit that referenced this issue May 22, 2024
`check_worker()` is called by almost every public interface in the view
server, as a preliminary check that the worker task running in the
background has not recorded an error of some kind.

this commit makes a change to `check_worker()`, so that it does not need
to frivolously acquire, release, and subsequently reacquire the mutex in
the event of an error being stored in the slot.

tracing events and documentation are also added to this function.

x-ref: #3913
cratelyn added a commit that referenced this issue May 22, 2024
these are useful for the sake of following the sequence of function
calls when debugging issues related to the view server, the view server
worker, and integration tests making use of the `Planner`.

x-ref: #3913
cratelyn added a commit that referenced this issue May 22, 2024
`check_worker()` is called by almost every public interface in the view
server, as a preliminary check that the worker task running in the
background has not recorded an error of some kind.

this commit makes a change to `check_worker()`, so that it does not need
to frivolously acquire, release, and subsequently reacquire the mutex in
the event of an error being stored in the slot.

tracing events and documentation are also added to this function.

x-ref: #3913
cratelyn added a commit that referenced this issue May 22, 2024
these are useful for the sake of following the sequence of function
calls when debugging issues related to the view server, the view server
worker, and integration tests making use of the `Planner`.

x-ref: #3913
cratelyn added a commit that referenced this issue May 24, 2024
 #### 💭 describe your changes

instead of accepting a `url::Url` and constructing specifically the
"real" `TendermintProxy`, tweak the signature of the router function so
that it accepts a `T: TendermintProxyService`.

in the future, this will allow mock consensus test cases to run an rpc
endpoint for the view server, without running a Tendermint/CometBFT
process.

 #### 🔖 issue ticket number and link

see #3913.

 #### ✅ checklist before requesting a review

- [x] if this code contains consensus-breaking changes, i have added the
  "consensus-breaking" label. otherwise, i declare my belief that there are not
  consensus-breaking changes, for the following reason:

    > this is a like-for-like refactoring, changing a function
    > signature.
cratelyn added a commit that referenced this issue May 24, 2024
 #### 💭 describe your changes

instead of accepting a `url::Url` and constructing specifically the
"real" `TendermintProxy`, tweak the signature of the router function so
that it accepts a `T: TendermintProxyService`.

in the future, this will allow mock consensus test cases to run an rpc
endpoint for the view server, without running a Tendermint/CometBFT
process.

 #### 🔖 issue ticket number and link

see #3913.

 #### ✅ checklist before requesting a review

- [x] if this code contains consensus-breaking changes, i have added the
  "consensus-breaking" label. otherwise, i declare my belief that there are not
  consensus-breaking changes, for the following reason:

    > this is a like-for-like refactoring, changing a function
    > signature.
cratelyn added a commit that referenced this issue May 24, 2024
see #3913.

this is the exciting culmination of work in pr's #3996, #4349, #4435,
 #4447, #4460, and #4468.

this adds a mock consensus test that spawns a gRPC server, creates a
view server, and then plans a transaction using the `Planner`. the
effects of this are then observed using the `ViewClient`.
cratelyn added a commit that referenced this issue May 29, 2024
see #3913.

this is the exciting culmination of work in pr's #3996, #4349, #4435,
 #4447, #4460, and #4468.

this adds a mock consensus test that spawns a gRPC server, creates a
view server, and then plans a transaction using the `Planner`. the
effects of this are then observed using the `ViewClient`.
cratelyn added a commit that referenced this issue May 30, 2024
see #3913.

this is the exciting culmination of work in pr's #3996, #4349, #4435,
 #4447, #4460, and #4468.

this adds a mock consensus test that spawns a gRPC server, creates a
view server, and then plans a transaction using the `Planner`. the
effects of this are then observed using the `ViewClient`.
cratelyn added a commit that referenced this issue May 31, 2024
see #3913.

this is the exciting culmination of work in pr's #3996, #4349, #4435,
 #4447, #4460, and #4468.

this adds a mock consensus test that spawns a gRPC server, creates a
view server, and then plans a transaction using the `Planner`. the
effects of this are then observed using the `ViewClient`.
cratelyn added a commit that referenced this issue May 31, 2024
see #3913.

this is the exciting culmination of work in pr's #3996, #4349, #4435,
 #4447, #4460, and #4468.

this adds a mock consensus test that spawns a gRPC server, creates a
view server, and then plans a transaction using the `Planner`. the
effects of this are then observed using the `ViewClient`.
cratelyn added a commit that referenced this issue Jun 3, 2024
see #3913.

this is the exciting culmination of work in pr's #3996, #4349, #4435,
 #4447, #4460, and #4468.

this adds a mock consensus test that spawns a gRPC server, creates a
view server, and then plans a transaction using the `Planner`. the
effects of this are then observed using the `ViewClient`.
@github-project-automation github-project-automation bot moved this from In progress to Done in Penumbra Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mock-consensus Area: Relates to the mock consensus engine
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants