-
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
fix: misc fixes for cosmos-rosetta #13583
Conversation
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
Could you add the new module here too: |
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.
left a few comments, seems to be some straggling print statements. Otherwise looks good to me
@tac0turtle I have removed the "Println". |
Codecov Report
Additional details and impacted files@@ 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
|
LGTM, let's change the mod url and we can merge 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.
LGTM,
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 add the go mod here too: #13583 (comment)
docs/docs/run-node/04-rosetta.md
Outdated
@@ -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" |
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.
Can you update this?
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.
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
tools/rosetta/go.mod
Outdated
) | ||
|
||
replace ( | ||
github.com/coinbase/rosetta-sdk-go => github.com/coinbase/rosetta-sdk-go v0.8.2-0.20221007214527-e03849ba430a |
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.
Can we add a comment on why this is necessary?
tools/rosetta/go.mod
Outdated
|
||
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 |
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 should not be need anymore. We've moved to cosmos/gogoproto. Can you verify you use it too in Rosetta?
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 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
?
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 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.
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.
ok! done!
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 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") |
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.
errors.New
// using tendermint API | ||
genesisHash := os.Getenv(genesisHashEnv) | ||
if genesisHash == "" { | ||
_ = fmt.Sprintf("[Warning]- Genesis hash env '%s' is not properly set!", genesisHashEnv) |
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.
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.
tools/rosetta/lib/server/server.go
Outdated
@@ -41,6 +41,7 @@ type Server struct { | |||
} | |||
|
|||
func (h Server) Start() error { | |||
fmt.Printf("Rosetta server listening on add %s", h.addr) |
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.
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?
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.
Hi! is there any logging service inside the sdk that we can use to avoid these printf
?
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.
@raynaudoe probably github.com/tendermint/tendermint/libs/log
tools/rosetta/lib/server/server.go
Outdated
@@ -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()) |
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.
Same about using a logger.
I've fixed the rosetta-tests, now the only test failing is |
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.
Thank you! |
Sure, we're on 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.
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)) |
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.
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)) |
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.
After this log, should this return an error given we expected the genesis hash which is critical?
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.
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.
tools/rosetta/lib/server/server.go
Outdated
@@ -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())) |
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 use %v for the error and no need for err.Error()
Putting the |
great! I'll fix the conflicts ASAP. |
### 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)
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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
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...
!
in the type prefix if API or client breaking change