Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
303 stars 191 forks source link

feat(rpc): support set http proxy from env #9587

Open Halimao opened 5 days ago

Halimao commented 5 days ago

Description

This PR supports setting HTTP proxy through environment variables like GLOBAL_AGENT_HTTP_PROXY.

Motivation

When I ran the following commands,

alias inter="yarn run --silent agops inter"
export AGORIC_NET=main
inter --help

Always give me errors:

(Error#1)
Error#1: cannot get network config (main): request to https://main.agoric.net/network-config failed, reason: read ECONNRESET

  at file:///home/xxx/Agoric/agoric-sdk/packages/agoric-cli/src/lib/rpc.js:43:11
  at async file:///xxx/Agoric/agoric-sdk/packages/agoric-cli/src/lib/rpc.js:52:23

I know this is due to a network problem, my network has a lot of limits, but we can use an HTTP proxy to fix the issue.

Documentation Considerations

If this PR is ok with you, we can add a doc to tell users how to set the HTTP proxy if they are facing a network issue like me

Testing Considerations

There are test cases that ensure old functions work well.

This PR only affects when an env var like GLOBAL_AGENT_HTTP_PROXY is set. After I set the GLOBAL_AGENT_HTTP_PROXY value, now it works for me:

Usage: bin-agops.js inter [options] [command]

Inter Protocol commands for liquidation bidding etc.

Options:
  --home <dir>                      agd CosmosSDK application home directory
  --fees <amount>                   set fees for transaction broadcast (e.g. 5000ubld)
  --keyring-backend <os|file|test>  keyring's backend (os|file|test) (default "os")
  -h, --help                        display help for command

Commands:
  auction                           auction commands
  bid                               auction bidding commands
  vbank                             vbank asset commands
  help [command]                    display help for command