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

fix: misc fixes for cosmos-rosetta #13583

Merged
merged 33 commits into from
Nov 4, 2022
Merged

Conversation

rllola
Copy link
Contributor

@rllola rllola commented Oct 18, 2022

Description

Closes:
#13083
#11402
#10678
#12358
#10776
#12934

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

rllola and others added 7 commits October 18, 2022 16:42
fix missing coma

should work

print block height answer

why index null

should fix getHeight

forgot fmt

fix get account at current height

check rosetta request

misc

misc

misc

misc

misc

misc

misc

misc

infinite loop
* Add go.mod for rosetta server

* Update go.mod files

* Fix go.mod
* Print messages when rosetta is online and when it cannot connect to rpc server

* Fix masking underlaying error

* Delete fmt output

* Avoid getting genesis block at Ready(), use Health and Status calls instead
* Get genesis hash from env

* Print error message if hash env is not set
@rllola rllola requested a review from a team as a code owner October 18, 2022 14:45
@raynaudoe raynaudoe mentioned this pull request Oct 18, 2022
19 tasks
@julienrbrt
Copy link
Member

server/rosetta/go.mod Outdated Show resolved Hide resolved
server/rosetta/go.mod Outdated Show resolved Hide resolved
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

left a few comments, seems to be some straggling print statements. Otherwise looks good to me

server/rosetta/client_online.go Outdated Show resolved Hide resolved
server/rosetta/client_online.go Outdated Show resolved Hide resolved
@rllola
Copy link
Contributor Author

rllola commented Oct 20, 2022

@tac0turtle I have removed the "Println".

@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Merging #13583 (d23da2f) into main (2bb114a) will increase coverage by 0.01%.
The diff coverage is 23.07%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13583      +/-   ##
==========================================
+ Coverage   56.03%   56.05%   +0.01%     
==========================================
  Files         646      659      +13     
  Lines       55790    57393    +1603     
==========================================
+ Hits        31264    32169     +905     
- Misses      21984    22631     +647     
- Partials     2542     2593      +51     
Impacted Files Coverage Δ
tools/rosetta/client_offline.go 0.00% <ø> (ø)
tools/rosetta/client_online.go 1.30% <0.00%> (ø)
tools/rosetta/codec.go 100.00% <ø> (ø)
tools/rosetta/config.go 0.00% <ø> (ø)
tools/rosetta/lib/errors/errors.go 69.84% <ø> (ø)
tools/rosetta/lib/errors/registry.go 100.00% <ø> (ø)
tools/rosetta/types.go 0.00% <ø> (ø)
tools/rosetta/util.go 0.00% <ø> (ø)
simapp/simd/cmd/root.go 70.23% <100.00%> (ø)
tools/rosetta/converter.go 56.75% <100.00%> (ø)
... and 16 more

@facundomedica
Copy link
Member

LGTM, let's change the mod url and we can merge it :)

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

LGTM,

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

Please add the go mod here too: #13583 (comment)

@@ -77,7 +77,7 @@ import (

"context"
"github.com/coinbase/rosetta-sdk-go/types"
"github.com/cosmos/cosmos-sdk/server/rosetta/lib"
"github.com/cosmos/cosmos-sdk/rosetta/lib"
Copy link
Member

Choose a reason for hiding this comment

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

Can you update this?

Copy link
Contributor

Choose a reason for hiding this comment

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

done!

Can you have a look at the last comments and the tests? Then it's ready to be merged :)

done with the comments, taking a look to the tests now

)

replace (
github.com/coinbase/rosetta-sdk-go => github.com/coinbase/rosetta-sdk-go v0.8.2-0.20221007214527-e03849ba430a
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a comment on why this is necessary?


replace (
github.com/coinbase/rosetta-sdk-go => github.com/coinbase/rosetta-sdk-go v0.8.2-0.20221007214527-e03849ba430a
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Copy link
Member

Choose a reason for hiding this comment

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

This should not be need anymore. We've moved to cosmos/gogoproto. Can you verify you use it too in Rosetta?

Copy link
Contributor

@raynaudoe raynaudoe Oct 25, 2022

Choose a reason for hiding this comment

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

I think we need it because we're importing this version of the sdk
https://github.com/Zondax/cosmos-sdk/blob/cee3d9f0e05e8658cd4908402a14805c5237cac1/tools/rosetta/go.mod#L9
is there a release/tag that is actually using cosmos/gogoproto ?

Copy link
Member

@julienrbrt julienrbrt Oct 25, 2022

Choose a reason for hiding this comment

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

I see, we don't have a tag yet. Cosmovisor uses v0.46.0-beta2.0.20220909113810-4882f933b1a1, which is fine to use I think, until we tag 0.47. IMO we should do the same here.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok! done!

@ainhoa-a ainhoa-a mentioned this pull request Oct 25, 2022
20 tasks
@github-actions github-actions bot added the C:Rosetta Issues and PR related to Rosetta label Oct 27, 2022
Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Thank you for this change @rllola! I've added some comments but the most important one is to examine if we can .Server's logger to avoid spamming os.Stdout yet the logs are inside a library/package and not in cmd/* code.

server/start.go Outdated
offlineMode = true
// If GRPC is not enabled rosetta cannot work in online mode, so we throw an error.
if !config.GRPC.Enable && !offlineMode {
return fmt.Errorf("'grpc' must be enable in online mode for Rosetta to work")
Copy link
Collaborator

Choose a reason for hiding this comment

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

errors.New

// using tendermint API
genesisHash := os.Getenv(genesisHashEnv)
if genesisHash == "" {
_ = fmt.Sprintf("[Warning]- Genesis hash env '%s' is not properly set!", genesisHashEnv)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean to invoke fmt.Printf instead? Why this if we are ignoring the string? I see a "Warning" hence we should figure out whether to return an error or not.

@@ -41,6 +41,7 @@ type Server struct {
}

func (h Server) Start() error {
fmt.Printf("Rosetta server listening on add %s", h.addr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is the server allowed to be chatted and just print out to os.Stdout? If so, is there a way to add a logger to Server and instead use that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi! is there any logging service inside the sdk that we can use to avoid these printf ?

Copy link
Member

Choose a reason for hiding this comment

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

@raynaudoe probably github.com/tendermint/tendermint/libs/log

@@ -108,6 +109,7 @@ func newOnlineAdapter(settings Settings) (crgtypes.API, error) {
for i := 0; i < settings.Retries; i++ {
err = settings.Client.Ready()
if err != nil {
fmt.Printf("[Rosetta]- Client is not ready: %s. Retrying ...", err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same about using a logger.

@raynaudoe
Copy link
Contributor

raynaudoe commented Oct 31, 2022

I've fixed the rosetta-tests, now the only test failing is Code scanning results / gosec but I'm seeing errors that were not introduced by this PR (maybe moving the affected files reactivated them?). Are they safe to skip?

@facundomedica
Copy link
Member

I've fixed the rosetta-tests, now the only test failing is Code scanning results / gosec but I'm seeing errors that were not introduced by this PR (maybe moving the affected files reactivated them?). Are they safe to skip?

I don't think the errors detected by gosec are too bad, I would say they are safe to skip. Ideally we would like to have none but I don't want to block this because of that.

  • Could you please allow maintainers to push to this branch? So we can pull update from main as many times as needed so we can merge it.
  • Were the concerns pointed out by @odeke-em solved?

Thank you!

@raynaudoe
Copy link
Contributor

I've fixed the rosetta-tests, now the only test failing is Code scanning results / gosec but I'm seeing errors that were not introduced by this PR (maybe moving the affected files reactivated them?). Are they safe to skip?

I don't think the errors detected by gosec are too bad, I would say they are safe to skip. Ideally we would like to have none but I don't want to block this because of that.

  • Could you please allow maintainers to push to this branch? So we can pull update from main as many times as needed so we can merge it.
  • Were the concerns pointed out by @odeke-em solved?

Thank you!

Sure, we're on it!

@JulianToledano
Copy link
Contributor

JulianToledano commented Nov 3, 2022

Thank you for this change @rllola! I've added some comments but the most important one is to examine if we can .Server's logger to avoid spamming os.Stdout yet the logs are inside a library/package and not in cmd/* code.

Changes are ready :) @odeke-em

Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Nice updates, thank you Zondax team. Just 3 more comments where 1 of them is critical to perhaps return an error when the genesis hash is empty, but otherwise now LGTM!

@@ -349,8 +349,8 @@ func sdkEventToBalanceOperations(status string, event abci.Event) (operations []
accountIdentifier = spender.String()

case banktypes.EventTypeCoinReceived:
receiver := sdk.MustAccAddressFromBech32(event.Attributes[0].Value)
coins, err := sdk.ParseCoinsNormalized(event.Attributes[1].Value)
receiver := sdk.MustAccAddressFromBech32(string(event.Attributes[0].Value))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this conversion necessary? Did this type change?

// using tendermint API
genesisHash := os.Getenv(genesisHashEnv)
if genesisHash == "" {
logger.Error(fmt.Sprintf("Genesis hash env '%s' is not properly set!", genesisHashEnv))
Copy link
Collaborator

Choose a reason for hiding this comment

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

After this log, should this return an error given we expected the genesis hash which is critical?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not having the genesis hash is not critical right now, however we have a fix ready for a next PR that contemplates the proper genesis block height and 'trust height' depending on the sync method used to sync the node.

@@ -108,10 +115,11 @@ func newOnlineAdapter(settings Settings) (crgtypes.API, error) {
for i := 0; i < settings.Retries; i++ {
err = settings.Client.Ready()
if err != nil {
logger.Error(fmt.Sprintf("[Rosetta]- Client is not ready: %s. Retrying ...", err.Error()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use %v for the error and no need for err.Error()

@julienrbrt
Copy link
Member

Putting the automerge tag. When you've rebased and fixed the conflicts, it'll automerge.
I'll tag rosetta after. Any preference qua version number? :)

@julienrbrt julienrbrt added the A:automerge Automatically merge PR once all prerequisites pass. label Nov 4, 2022
@raynaudoe
Copy link
Contributor

great! I'll fix the conflicts ASAP.
Regarding version number, no preferences at all!

@mergify mergify bot merged commit 39c5c07 into cosmos:main Nov 4, 2022
@julienrbrt julienrbrt mentioned this pull request Nov 4, 2022
19 tasks
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
### Description

Closes:
cosmos#13083
cosmos#11402
cosmos#10678
cosmos#12358
cosmos#10776
cosmos#12934

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [x] added a changelog entry to `CHANGELOG.md`
- [x] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [x] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
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:Rosetta Issues and PR related to Rosetta Type: CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rosetta: spin rosetta out into its own go.mod
7 participants