Skip to content

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

Merged
thanethomson merged 3 commits intov0.34.xfrom
mergify/bp/v0.34.x/pr-9650
Nov 7, 2022
Merged

rpc: Add caching support (backport #9650)#9666
thanethomson merged 3 commits intov0.34.xfrom
mergify/bp/v0.34.x/pr-9650

Conversation

@mergify
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.34.x/pr-9650
Your branch is up to date with 'origin/v0.34.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:   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

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   CHANGELOG_PENDING.md
	both modified:   light/proxy/routes.go
	both modified:   rpc/core/routes.go
	both modified:   rpc/openapi/openapi.yaml
	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

@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
@thanethomson
Copy link
Contributor

@Mergifyio rebase

* 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
#	light/proxy/routes.go
#	rpc/core/routes.go
#	rpc/openapi/openapi.yaml
#	test/fuzz/tests/rpc_jsonrpc_server_test.go
@mergify
Copy link
Contributor Author

mergify bot commented Nov 5, 2022

rebase

✅ Branch has been successfully rebased

@liamsi liamsi force-pushed the mergify/bp/v0.34.x/pr-9650 branch from 16fd872 to 01dbe4d Compare November 5, 2022 12:54
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
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 thanethomson merged commit 7917485 into v0.34.x Nov 7, 2022
@thanethomson thanethomson deleted the mergify/bp/v0.34.x/pr-9650 branch November 7, 2022 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done/Merged

Development

Successfully merging this pull request may close these issues.

2 participants