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

API server #323

Merged
merged 22 commits into from
Feb 11, 2021
Merged

API server #323

merged 22 commits into from
Feb 11, 2021

Conversation

jackzampolin
Copy link
Member

@jackzampolin jackzampolin commented Nov 6, 2020

@akhilkumarpilli
Copy link
Contributor

@jackzampolin, Can you share me checklist of api endpoints here so it would be easy for us to implement them.

@jackzampolin
Copy link
Member Author

@akhilkumarpilli Done! I've got them all stubbed out

@anilcse anilcse changed the title WIP API server API server Dec 18, 2020
@anilcse
Copy link
Collaborator

anilcse commented Dec 18, 2020

@akhilkumarpilli can you fix the conflicts?

@lgtm-com
Copy link

lgtm-com bot commented Dec 19, 2020

This pull request introduces 7 alerts when merging 124eacd into 031ecc2 - view on LGTM.com

new alerts:

  • 4 for Uncontrolled data used in path expression
  • 2 for Incorrect conversion between integer types
  • 1 for Uncontrolled data used in network request

Copy link

@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 @akhilkumarpilli @jackzampolin for this change! Just a drive-by review for security and nits, I've added some comments, please take a look.

helpers/light.go Outdated Show resolved Hide resolved
helpers/light.go Outdated Show resolved Hide resolved
helpers/light.go Outdated Show resolved Hide resolved
helpers/query.go Outdated Show resolved Hide resolved
helpers/query.go Outdated Show resolved Hide resolved
relayer/query.go Show resolved Hide resolved
relayer/query.go Outdated Show resolved Hide resolved
relayer/strategies.go Outdated Show resolved Hide resolved
relayer/strategies.go Outdated Show resolved Hide resolved
helpers/api.go Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Dec 22, 2020

This pull request introduces 7 alerts when merging 9aed68d into f8acf82 - view on LGTM.com

new alerts:

  • 4 for Uncontrolled data used in path expression
  • 2 for Incorrect conversion between integer types
  • 1 for Uncontrolled data used in network request

@lgtm-com
Copy link

lgtm-com bot commented Dec 22, 2020

This pull request introduces 7 alerts when merging 2e1b5e9 into f8acf82 - view on LGTM.com

new alerts:

  • 4 for Uncontrolled data used in path expression
  • 2 for Incorrect conversion between integer types
  • 1 for Uncontrolled data used in network request

@lgtm-com
Copy link

lgtm-com bot commented Jan 15, 2021

This pull request introduces 7 alerts when merging dea3362 into 978a993 - view on LGTM.com

new alerts:

  • 4 for Uncontrolled data used in path expression
  • 2 for Incorrect conversion between integer types
  • 1 for Uncontrolled data used in network request

@colin-axner
Copy link
Contributor

I will review this sometime this week, just haven't gotten a chance yet since there are a lot of changes

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Overall LGTM. I did my best to review this, but it is a lot of diffs, and most of it looks like a refactor of old function structuring. Just left a couple questions on the rest response writing

Would appreciate another reviewer to take a look at this, but it does only touch client code so it's ok if bugs are not caught during review.

@akhilkumarpilli have you tested this manually for a couple of the rest routes? Could you add a quick document on how to interact with this?

cmd/api.go Outdated
// Data for this should be stored in the ServicesManager struct
r.HandleFunc("/listen/{path}/{strategy}/{name}", PostRelayerListenHandler(sm)).Methods("POST")

// TODO: do we want to add the transaction commands here to?
Copy link
Contributor

Choose a reason for hiding this comment

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

client/connection/channel commands change the config during execution so we would want to make sure we are aware of that when addressing this TODO

Copy link
Contributor

Choose a reason for hiding this comment

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

@colin-axner , do we need to remove this TODO since we thought of not implementing APIS for tx commands?

Copy link
Contributor

Choose a reason for hiding this comment

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

lets remove

cmd/api.go Outdated
// tx transfer
// POST /paths/{name}/transfers

// TODO: listen validation in config
Copy link
Contributor

Choose a reason for hiding this comment

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

We should open issues for every TODO

helpers/query.go Outdated Show resolved Hide resolved
helpers/api.go Outdated Show resolved Hide resolved
helpers/api.go Outdated Show resolved Hide resolved
@colin-axner
Copy link
Contributor

also waiting on review from @fedekunze

@lgtm-com
Copy link

lgtm-com bot commented Feb 3, 2021

This pull request introduces 7 alerts when merging a237c8b into 2f1a812 - view on LGTM.com

new alerts:

  • 4 for Uncontrolled data used in path expression
  • 2 for Incorrect conversion between integer types
  • 1 for Uncontrolled data used in network request

@lgtm-com
Copy link

lgtm-com bot commented Feb 3, 2021

This pull request introduces 7 alerts when merging 16bf3df into 2f1a812 - view on LGTM.com

new alerts:

  • 4 for Uncontrolled data used in path expression
  • 2 for Incorrect conversion between integer types
  • 1 for Uncontrolled data used in network request

@akhilkumarpilli
Copy link
Contributor

@akhilkumarpilli have you tested this manually for a couple of the rest routes? Could you add a quick document on how to interact with this?

@colin-axner , We will setup swagger docs for rest APIs in a separate PR.

@colin-axner
Copy link
Contributor

Adding swagger docs later sounds fine, but I think someone should manually test to at least ensure one route works. Is there a reason why this cannot be done? Is it because we'd need some third party code to submit the rest requests?

@akhilkumarpilli
Copy link
Contributor

Not a problem, I will add a short document regarding how to start rest server and interact with routes. We thought swagger docs might be helpful since we can test routes directly from it. We will add swagger docs later in other PR and push a quick document now.

@colin-axner
Copy link
Contributor

sounds perfect, thanks @akhilkumarpilli

@lgtm-com
Copy link

lgtm-com bot commented Feb 4, 2021

This pull request introduces 7 alerts when merging bc84060 into cb3edfc - view on LGTM.com

new alerts:

  • 4 for Uncontrolled data used in path expression
  • 2 for Incorrect conversion between integer types
  • 1 for Uncontrolled data used in network request

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, although I think this API could be further refactored / cleaned up. Can you also fix the alerts from lgtm-com?

cmd/api.go Outdated

// VERSION
// version get
r.HandleFunc(fmt.Sprintf("/%s", version), VersionHandler).Methods("GET")
Copy link
Collaborator

Choose a reason for hiding this comment

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

these are really hard to read, what's the need for fmt.Sprintf? I think the value of having the endpoints as constants is less than using a plain string

cmd/keys.go Outdated Show resolved Hide resolved
}

// PostRelayerListenHandler returns a handler for a listener that can listen on many IBC paths
func PostRelayerListenHandler(sm *ServicesManager) func(w http.ResponseWriter, r *http.Request) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Does this work? That would a step change in the relayer capabilities.

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to do some rework for this api. We can implement all TODOs related to PostRelayerListenHandler in separate PR.

@akhilkumarpilli
Copy link
Contributor

Can you also fix the alerts from lgtm-com?

I tried to fix lgtm-com alerts but I am unable to fix them.

@lgtm-com
Copy link

lgtm-com bot commented Feb 8, 2021

This pull request introduces 7 alerts when merging 6a08698 into 9f13a93 - view on LGTM.com

new alerts:

  • 4 for Uncontrolled data used in path expression
  • 2 for Incorrect conversion between integer types
  • 1 for Uncontrolled data used in network request

@colin-axner
Copy link
Contributor

I tried to fix lgtm-com alerts but I am unable to fix them.

The incorrect conversion can be fixed by changing the upstream offset value to int instead of uint64 or by adding a if statement before doing QueryTxs action.

The uncontrolled data path I think we can just suppress those errors (click on the hide button on lgtm to see how to suppress). The suppression won't take place until after this is merged, but we should still add it

@colin-axner colin-axner requested a review from fedekunze February 8, 2021 11:56
cmd/api.go Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Feb 11, 2021

This pull request introduces 7 alerts when merging 8ee029d into 872dc2e - view on LGTM.com

new alerts:

  • 4 for Uncontrolled data used in path expression
  • 2 for Incorrect conversion between integer types
  • 1 for Uncontrolled data used in network request

Copy link
Contributor

@colin-axner colin-axner 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 think we can merge this in so it starts getting some testing, see my MaxInt32 comment first though since it seems like a small fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants