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 gRPC Simulate endpoint #7035

Merged
merged 33 commits into from
Aug 24, 2020
Merged

Implement gRPC Simulate endpoint #7035

merged 33 commits into from
Aug 24, 2020

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Aug 13, 2020

Description

closes: #5922


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@codecov
Copy link

codecov bot commented Aug 13, 2020

Codecov Report

Merging #7035 into master will decrease coverage by 0.24%.
The diff coverage is 35.25%.

@@            Coverage Diff             @@
##           master    #7035      +/-   ##
==========================================
- Coverage   54.96%   54.72%   -0.25%     
==========================================
  Files         560      563       +3     
  Lines       38188    38405     +217     
==========================================
+ Hits        20989    21016      +27     
- Misses      15495    15681     +186     
- Partials     1704     1708       +4     

@amaury1093 amaury1093 marked this pull request as ready for review August 18, 2020 13:38
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

utACK. I still don't know how to use this simulate. Adding docs for it would be nice

//
// NOTE: This codec will be deprecated in favor of AppCodec once all modules are
// migrated.
func MakeCodec(bm module.BasicManager) *codec.LegacyAmino {
Copy link
Contributor Author

@amaury1093 amaury1093 Aug 18, 2020

Choose a reason for hiding this comment

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

I ran into some nasty import cycles, in tests only:

import cycle not allowed in test
package github.com/cosmos/cosmos-sdk/x/auth/tx (test)
    imports github.com/cosmos/cosmos-sdk/std
    imports github.com/cosmos/cosmos-sdk/baseapp
    imports github.com/cosmos/cosmos-sdk/client/grpc/simulate
    imports github.com/cosmos/cosmos-sdk/x/auth/tx
FAIL    github.com/cosmos/cosmos-sdk/x/auth/tx [setup failed]

All imports made sense to me, except maybe std imports baseapp. So I refactored:

  • remove mention of baseapp from std
  • put std/consensus_params.go into params keeper
  • remove mention of types/module from std (another import cycle)
  • this function MakeCodec was only used in tests in simapp, so that's where I put it.

@amaury1093
Copy link
Contributor Author

amaury1093 commented Aug 18, 2020

@fedekunze yes, I agree some docs would be nice. But I'm not 100% sure where to put them. And I'm not sure also how these docs would actually look like: this endpoint is just another endpoint amongst all the gRPC endpoints we have, maybe some unified client request docs would make more sense (i.e. either send a gRPC request to the gRPC server, or send a HTTP request to the gateway server).

cc @clevinson

@clevinson clevinson added this to the v0.40 [Stargate] milestone Aug 21, 2020
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Excellent work @amaurymartiny 👏

x/auth/tx/builder.go Outdated Show resolved Hide resolved
@alexanderbez
Copy link
Contributor

Not sure if we want to wait on @aaronc's review. Feel free to merge whenever you'd like.

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Aug 24, 2020
@mergify mergify bot merged commit 3d969a1 into master Aug 24, 2020
@mergify mergify bot deleted the am-5922-tx-sim branch August 24, 2020 14:41
@@ -0,0 +1,33 @@
syntax = "proto3";
package cosmos.base.simulate.v1beta1;
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be in base, it should be in cosmos.tx

Copy link
Member

Choose a reason for hiding this comment

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

Let's fix this when we address #7355. Originally this was in a single tx Service in #6872. Ideally those are the same gRPC service. I'm not sure why we would need to separate them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, this endpoint could definitely go in with those in #7355

Note: there are some other TM rpc methods which we might or might not want to wrap under gRPC at some point. To avoid having too many services, we could regroup them under one big module-agnostic service, maybe not called Tx though. There's also the reflection service, which could also be merged into it.

Copy link
Member

Choose a reason for hiding this comment

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

Let's bundle together stuff that is related. Simulate, get tx by hash, etc. all depend on Tx. The original tx Service was intended to cover all that stuff. Reflection doesn't depend on Tx so IMHO should remain separate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I was pointing out that our bundling will then be different than TM's bundling (e.g. getTxByHash goes in Info, not in Tx, see link above), which might be confusing for people, esp. if one day TM has its own gRPC.

larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
* Implement simulate endpoint

* Add GetProtoTx()

* Add signing in test

* Add txBuilderFromProto

* Remove stray println

* Update to master

* Merge master

* Fix tests

* Make tests pass

* Integrate in router

* Make proto-gen

* Fix lint

* Really fix lint

* Refactor to fix import cycles

* Rename builder -> wrapper

* Update proto/cosmos/base/reflection/v1beta1/reflection.proto

* Fix after merge

* t->w

Co-authored-by: Alexander Bezobchuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:baseapp C:Simulations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gRPC Transaction Simulation Service
5 participants