-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[rosetta] implement balance tracking and redo tx construction #8729
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8729 +/- ##
==========================================
- Coverage 59.44% 59.15% -0.29%
==========================================
Files 563 570 +7
Lines 31286 31764 +478
==========================================
+ Hits 18598 18791 +193
- Misses 10522 10774 +252
- Partials 2166 2199 +33
|
I'd like to get this merged because it has got really big, and do immediately a follow up PR with extra tests. |
Linter is failing |
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.
Excellent job!! We are very close!!
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.
LGTM pending changelog entry
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.
only reviewed part of it.
} | ||
|
||
txBytes, err := TxConfig.TxEncoder()(txBldr.GetTx()) | ||
// now we need to parse the operations to cosmos sdk messages | ||
tx, err := c.converter.ToSDK().UnsignedTx(req.Operations) |
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.
Probably we can cache this operation (ToSDK) in the converter structure.
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.
there's a lot of performance improvements that can be done (there's a double unmarshal on operations for example) but since I plan to do a follow up PR with extra tests immediately after this one is merged, I'd rather tackle the improvements in that, because this PR has got really big and its hard to review as it is. WDYT?
server/rosetta/client_online.go
Outdated
txConfig := authtx.NewTxConfig(cfg.Codec, authtx.DefaultSignModes) | ||
|
||
var supportedOperations []string | ||
for _, ii := range cfg.InterfaceRegistry.ListImplementations("cosmos.base.v1beta1.Msg") { |
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.
please don't hardcode the message name. Instead:
let's create const
in types/codec.go
and export it.
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.
do you have any preference in the naming? I was thinking of having a name which contains the version of the interface such as: MsgV1Beta1InterfaceName
, although it looks ugly.
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.
How about MsgProtoName
? This is what we would get from the following call:
proto.MessageName((*Msg)(nil))
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.
Added few more comments. For few general things:
- godoc is missing for exported methods
docs/core/baseapp.md
Outdated
@@ -104,7 +104,7 @@ Finally, a few more important parameterd: | |||
|
|||
```go | |||
func NewBaseApp( | |||
name string, logger log.Logger, db dbm.DB, txDecoder sdk.TxDecoder, options ...func(*BaseApp), | |||
name string, logger log.Logger, db dbm.DB, txDecode sdk.TxDecoder, options ...func(*BaseApp), |
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 think the original name is better.
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 refactored something somewhere in the code and this got affected too! thanks for pointing it out!
}, nil | ||
} | ||
|
||
func (c *Client) accountInfo(ctx context.Context, addr string, height *int64) (auth.AccountI, error) { | ||
// Bootstrap is gonna connect the client to the endpoints | ||
func (c *Client) Bootstrap() error { |
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.
Let's rename this method to Dial
or Connect
.
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.
this is part of interface implementation
} | ||
|
||
func (c *Client) Balances(ctx context.Context, addr string, height *int64) ([]*types.Amount, error) { | ||
func (c *Client) Balances(ctx context.Context, addr string, height *int64) ([]*rosettatypes.Amount, error) { |
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.
godoc is missing
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.
godocs are missing because those methods are part of an interface implementation - which is in itself throughly documented - I will add the comments that those methods implement the said interface
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" | ||
|
||
"github.com/coinbase/rosetta-sdk-go/types" | ||
rosettatypes "github.com/coinbase/rosetta-sdk-go/types" |
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.
imports are not ordered correctly
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.
goimports does not give warnings, nor edit the files if I do run it against the rosetta dir.
do you use some other tooling?
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.
Yes, goimports
is not able to reorder lines that are blank-separated. It's a known limitation. We can fix this in a separate PR
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" | ||
bank "github.com/cosmos/cosmos-sdk/x/bank/types" |
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.
ditto
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.
See #8729 (comment)
s.Require().ErrorIs(err, crgerrs.ErrBadArgument) | ||
}) | ||
|
||
s.Run("codec type but not sdk.Msg", 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.
this could be converted to table tests.
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.
@fdymylja can you address this in your follow up PR, please?
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Description
This PR fully implements balance tracking via data API using balance tracking events.
On top of that, now construction supports out of the box any message in any possible application that passes through the /tx endpoint without requiring any message extension.
closes: #8705
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.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes