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: change default rpc config + upgrade CORS library #1118

Merged

Conversation

zivkovicmilos
Copy link
Member

Description

This PR introduces several changes to the default JSON-RPC config of the Gno node:

  • allow all (*) origin requests by default. The reasoning behind this is that local development setups that require the RPC layer will have their requests rejected by the CORS policy, and will require a custom RPC config to be specified to the node. This is more of a convenience on the side of development, as production Gno RPC setups will have a concrete RPC configuration that is more limited
  • explicitly allow OPTIONS requests (preflight requests) in the default configuration
  • change the CORS library used in the project from gnolang/cors to rs/cors. The gnolang/cors library is a fork of rs/cors, with seemingly no functionality changes. Therefore, to stay up to date with the latest fixes and upstream changes, I've updated the library gno uses to the original one, which is actively maintained by the original authors

How can I test this out?

Essentially, you can run the local node with the default RPC params, and try to do an HTTP request from a frontend application:

import { GnoJSONRPCProvider } from "@gnolang/gno-js-client";

const exampleMethod = async () => {
  // Local node as the endpoint
  const provider = new GnoJSONRPCProvider("http://127.0.0.1:26657");

  const blockNumber: number = await provider.getBlockNumber();

  console.log(blockNumber);
};

exampleMethod()
  .then(() => {
    console.log("success");
  })
  .catch((e) => {
    console.error(e);
  });

Example error:
Screenshot 2023-09-13 at 12 27 22

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@netlify
Copy link

netlify bot commented Sep 13, 2023

Deploy Preview for gno-docs failed.

Name Link
🔨 Latest commit 1498399
🔍 Latest deploy log https://app.netlify.com/sites/gno-docs/deploys/65018f06cea9a00008f94b4e

@github-actions github-actions bot added the 📦 🌐 tendermint v2 Issues or PRs tm2 related label Sep 13, 2023
Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

I'm approving this PR because it fixes a bug that is creating issues for Gnochess, and from what I can tell the library was originally forked to remove the dependency on Gin. Since then, the library author has changed the examples and wrapper directory to use their own go.mods, not affecting the main library one, which currently doesn't have any dependencies.

The change diff can be seen here: gnolang/cors@master...rs:cors:master . The changes in actual library files are minor and mostly about fixing bugs or adding new, optional functionality.

@ajnavarro
Copy link
Contributor

@zivkovicmilos @thehowl Shall we archive the fork?

@zivkovicmilos zivkovicmilos merged commit 6190894 into gnolang:master Sep 13, 2023
76 of 81 checks passed
@zivkovicmilos zivkovicmilos deleted the fix/change-default-rpc-config branch September 13, 2023 16:32
@moul moul added this to the 🌟 main.gno.land (wanted) milestone Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related
Projects
Status: Done
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants