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

rpc: Add caching support (backport #9650) #9665

Open
wants to merge 3 commits into
base: v0.37.x
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 3, 2022

This is an automatic backport of pull request #9650 done by Mergify.
Cherry-pick of 816c6ba has failed:

On branch mergify/bp/v0.37.x/pr-9650
Your branch is up to date with 'origin/v0.37.x'.

You are currently cherry-picking commit 816c6bac0.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   light/proxy/routes.go
	modified:   rpc/core/routes.go
	modified:   rpc/jsonrpc/jsonrpc_test.go
	modified:   rpc/jsonrpc/server/http_json_handler.go
	modified:   rpc/jsonrpc/server/http_json_handler_test.go
	modified:   rpc/jsonrpc/server/http_server.go
	modified:   rpc/jsonrpc/server/http_server_test.go
	modified:   rpc/jsonrpc/server/http_uri_handler.go
	modified:   rpc/jsonrpc/server/rpc_func.go
	modified:   rpc/openapi/openapi.yaml

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   CHANGELOG_PENDING.md
	deleted by us:   test/fuzz/tests/rpc_jsonrpc_server_test.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

* Set cache control in the HTTP-RPC response header

* Add a simply cache policy to the RPC routes

* add a condition to check the RPC request has default height settings

* fix cherry pick error

* update pending log

* use options struct intead of single parameter

* refacor FuncOptions to functional options

* add functional options in WebSocket RPC function

* revert doc

* replace deprecated function call

* revise functional options

* remove unuse comment

* fix revised error

* adjust cache-control settings

* Update rpc/jsonrpc/server/http_json_handler.go

Co-authored-by: Thane Thomson <connect@thanethomson.com>

* linter: Fix false positive

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* rpc: Separate cacheable and non-cacheable HTTP response writers

Allows us to roll this change out in a non-API-breaking way, since this
is an additive change.

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* rpc: Ensure consistent caching strategy

Ensure a consistent caching strategy across both JSONRPC- and URI-based
requests.

This requires a bit of a refactor of the previous caching logic, which
is complicated a little by the complex reflection-based approach taken
in the Tendermint RPC.

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* rpc: Add more tests for caching

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update CHANGELOG_PENDING

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* light: Sync routes config with RPC core

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* rpc: Update OpenAPI docs

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: jayt106 <jaytseng106@gmail.com>
Co-authored-by: jay tseng <jay.tseng@crypto.com>
Co-authored-by: JayT106 <JayT106@users.noreply.github.com>
(cherry picked from commit 816c6ba)

# Conflicts:
#	CHANGELOG_PENDING.md
#	test/fuzz/tests/rpc_jsonrpc_server_test.go
@mergify mergify bot requested a review from a team November 3, 2022 17:20
@mergify mergify bot added the conflicts label Nov 3, 2022
@thanethomson thanethomson self-assigned this Nov 3, 2022
Signed-off-by: Thane Thomson <connect@thanethomson.com>
@thanethomson thanethomson added the S:wip Work in progress (prevents stalebot from automatically closing) label Nov 5, 2022
Copy link
Contributor

@sergio-mena sergio-mena left a comment

Choose a reason for hiding this comment

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

LGTM

@thanethomson
Copy link
Contributor

@sergio-mena would you recommend holding off on merging this until v0.37.1?

@sergio-mena
Copy link
Contributor

I would say so

@faddat
Copy link
Contributor

faddat commented Nov 22, 2022

this is a big deal. Thanks team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflicts S:wip Work in progress (prevents stalebot from automatically closing)
Projects
Status: Blocked
Development

Successfully merging this pull request may close these issues.

None yet

4 participants