-
Notifications
You must be signed in to change notification settings - Fork 637
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
Fix escrow proto E2E #3517
Fix escrow proto E2E #3517
Conversation
@mark-rushakoff provided the following insight to help debug the problem. Thank you! ================================================================= The SDK is using gogo/proto (by way of our fork, https://github.com/cosmos/gogoproto). The TLDR is incompatibilities with gogoproto and official google.golang.org/protobuf. The one I was running into was just a plain We tell it to serialize on the wire as a string (effectively (*big.Int).String(). But the gogoproto-generated struct still uses a sdkmath.Int field. I think the correct answer here is:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix, @chatton; and thank you @mark-rushakoff for the insight that got us here!
I need this is in draft yet, but I just left a couple of suggestions. If the test pass, I am good going with this direction.
|
||
return &types.QueryTotalEscrowForDenomResponse{ | ||
Amount: denomAmount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to return a string
, we can just do denomAmount.String()
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this would be a bit nicer, I will play with this idea
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3517 +/- ##
==========================================
- Coverage 78.78% 78.76% -0.02%
==========================================
Files 182 182
Lines 12688 12688
==========================================
- Hits 9996 9994 -2
- Misses 2261 2262 +1
- Partials 431 432 +1
|
} else { | ||
suite.Require().PanicsWithValue("amount cannot be negative: -1", func() { | ||
suite.chainA.GetSimApp().TransferKeeper.SetTotalEscrowForDenom(ctx, denom, expAmount) | ||
suite.Require().PanicsWithError("negative coin amount: -1", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the panic now happens in the sdk.NewCoin
function instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the original behaviour is desirable, we can create a coin literal instead of using the NewCoin
function.
@damiannolan can you take over this pr next week? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've addressed the comments left by @colin-axner. PR looks good to me and tests are all passing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. Thanks @chatton and @damiannolan ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followup ACK, thanks @damiannolan!
* wip: experiement with string value for proto * apply PR suggestions and fix unit tests * added extension method to gRPC response * refactor, change response return type to sdk Coin * rm commented out proto import * remove empty sdk.Coin literal in e2e/grpc_query * reference same type in relay.go in favour of creating new sdk.Coin * adding code comment regarding zero value coin return * fix typo, linter --------- Co-authored-by: Damian Nolan <[email protected]> (cherry picked from commit 1006426) # Conflicts: # e2e/tests/transfer/base_test.go # e2e/testsuite/grpc_query.go # modules/apps/transfer/keeper/grpc_query.go # modules/apps/transfer/keeper/keeper.go # modules/apps/transfer/keeper/relay.go
* modify total escrow to take in sdk.Coin in function APIs/proto (#3517) * wip: experiement with string value for proto * apply PR suggestions and fix unit tests * added extension method to gRPC response * refactor, change response return type to sdk Coin * rm commented out proto import * remove empty sdk.Coin literal in e2e/grpc_query * reference same type in relay.go in favour of creating new sdk.Coin * adding code comment regarding zero value coin return * fix typo, linter --------- Co-authored-by: Damian Nolan <[email protected]> (cherry picked from commit 1006426) # Conflicts: # e2e/tests/transfer/base_test.go # e2e/testsuite/grpc_query.go # modules/apps/transfer/keeper/grpc_query.go # modules/apps/transfer/keeper/keeper.go # modules/apps/transfer/keeper/relay.go * rm -rf e2e --------- Co-authored-by: Cian Hatton <[email protected]> Co-authored-by: Damian Nolan <[email protected]>
Description
closes: #XXXX
We were getting this error
In our E2E tests. This PR is being used to debug this proto issue.
By making the Amount field a string we can serialize it properly.
EDIT: After discussion with @colin-axner , we decided that an
sdk.Coin
makes more sense and will be less confusing. Serialization works as expected with this type.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.
docs/
) or specification (x/<module>/spec/
).godoc
comments.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.