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

Add prototype implementation of CometMock #1

Merged
merged 25 commits into from
May 9, 2023
Merged

Conversation

p-offtermatt
Copy link
Member

@p-offtermatt p-offtermatt commented May 5, 2023

Closes cosmos/interchain-security#917

Description

This PR implements a prototype for CometMock, a Go implementation of Tendermock https://github.com/informalsystems/tendermock.

Its goal is to replace Tendermint in End-To-End tests.
It provides the essential RPC functions that Tendermint provides,
and itself calls an application via ABCI over grpc.

Structure of the implementation

The files are split into three parts:

  • ABCI Client:
    • cometmock/abci_client/client.go: Handles calling ABCI endpoints of the application
  • RPC Server:
    • cometmock/rpc_server/rpc_server.go: Mostly code taken from cometbft. Provides an RPC server. This supports a subset of the calls outlined in https://docs.cometbft.com/v0.34/rpc/#/, which will grow over time as necessary. This is mostly boilerplate. Eventually, this should also support extra and more nuanced calls, like a way to AdvanceTime,
      or to SetSigners for the next block
    • cometmock/rpc_server/routes.go: The actual implementation of the RPC endpoints. This is the less boilerplatey part of the server
  • Command Line Interface
    • Logic for starting CometMock. Lives in cometmock/main.go

Implemented functionality

CometMock is essentially on feature parity with the old implementation of Tendermock.
It can:

  • Interface with multiple applications
  • Check their responses for nondeterminism (this is likely a bit too sensitive right now, since fields are included in the check that are allowed to be nondeterministic, but no application actually behaved nondeterministically even there in my tests yet)
  • Broadcast transactions
  • Perform ABCI queries
  • Query for blocks

Many responses are not faithful yet, i.e. they may return results with fields that are empty even when CometBFT behaviour would be to return information in those fields. These will be included as they are necessary for tests.

@p-offtermatt p-offtermatt requested a review from MSalopek May 9, 2023 12:31
Copy link
Collaborator

@MSalopek MSalopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome!

I hope this gets used soon, it will greatly reduce the runtimes of e2e tests and allows us to run non-determinism tests on basically every commit to figure out if there are any state-breaking change

@p-offtermatt p-offtermatt merged commit da985dc into main May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spike: Implement CometMock prototype in Go
2 participants