Giter Club home page Giter Club logo

bite-keeper's People

Contributors

dizzy avatar godsflaw avatar kentonprescott avatar livnev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bite-keeper's Issues

Cannot successfully authenticate with remote Infura RPC endpoint

Description

bite-keeper cannot successfully connect to my Infura instance in order to interact via JSON-RPC.

To the best of my knowledge, all of the settings on my Infura endpoint are the defaults (i.e., no whitelists, etc.).

After inspecting the code in bite_keeper/bite_keeper.py, I modified line 44 to use https as the prefix, rather than the (existing) http prefix.

That is, this line:

self.web3 = kwargs['web3'] if 'web3' in kwargs else Web3(HTTPProvider(endpoint_uri=f"http://{self.arguments.rpc_host}:{self.arguments.rpc_port}",

becomes this:

    elf.web3 = kwargs['web3'] if 'web3' in kwargs else Web3(HTTPProvider(endpoint_uri=f"https://{self.arguments.rpc_host}:{self.arguments.rpc_port}",
                                                                              request_kwargs={"timeout": self.arguments.rpc_timeout}))

Note: Yes, I have replaced both <eth addr> and <Infura public API key> fields with their correct values in all code snippets below.

Version and System Information

Commit: 406bf7d
System Info: Debian 10 (Buster)

$ uname --all
Linux instance-2 4.19.0-8-cloud-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64 GNU/Linux

Actual Behaviour

$ bin/bite-keeper --eth-from <eth addr> --tub-address 0x448a5065aebb8e423f0896e6c5d525c040f59af3 --rpc-host https://mainnet.infura.io/v3/<Infura public API key> --rpc-port 443 --debug
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/local/lib/python3.7/dist-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/dist-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/dist-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f6879667e80>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/dist-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/lib/python3.7/dist-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //mainnet.infura.io/v3/<Infura public API key>:443 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f6879667e80>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jmcph4/bite-keeper/bite_keeper/bite_keeper.py", line 73, in <module>
    BiteKeeper(sys.argv[1:]).main()
  File "/home/jmcph4/bite-keeper/bite_keeper/bite_keeper.py", line 48, in __init__
    self.tub = Tub(web3=self.web3, address=Address(self.arguments.tub_address))
  File "/home/jmcph4/bite-keeper/lib/pymaker/pymaker/sai.py", line 82, in __init__
    self._contract = self._get_contract(web3, self.abi, address)
  File "/home/jmcph4/bite-keeper/lib/pymaker/pymaker/__init__.py", line 157, in _get_contract
    if not is_contract_at(web3, address):
  File "/home/jmcph4/bite-keeper/lib/pymaker/pymaker/util.py", line 62, in is_contract_at
    code = web3.eth.getCode(address.address)
  File "/usr/local/lib/python3.7/dist-packages/web3/eth.py", line 198, in getCode
    [account, block_identifier],
  File "/usr/local/lib/python3.7/dist-packages/web3/manager.py", line 149, in request_blocking
    response = self._make_request(method, params)
  File "/usr/local/lib/python3.7/dist-packages/web3/manager.py", line 128, in _make_request
    return request_func(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 75, in apply_formatters
    response = make_request(method, params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/gas_price_strategy.py", line 34, in middleware
    return make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/attrdict.py", line 33, in middleware
    response = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/normalize_errors.py", line 25, in middleware
    result = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 75, in apply_formatters
    response = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/exception_retry_request.py", line 104, in middleware
    return make_request(method, params)
  File "/usr/local/lib/python3.7/dist-packages/web3/providers/rpc.py", line 83, in make_request
    **self.get_request_kwargs()
  File "/usr/local/lib/python3.7/dist-packages/web3/_utils/request.py", line 34, in make_post_request
    response = session.post(endpoint_uri, data=data, *args, **kwargs)  # type: ignore
  File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 578, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/dist-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //mainnet.infura.io/v3/<Infura public API key>:443 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f6879667e80>: Failed to establish a new connection: [Errno -2] Name or service not known'))

When trying the input without prepending https:// onto the value for --rpc-host:

$ bin/bite-keeper --eth-from <eth addr> --tub-address 0x448a5065aebb8e423f0896e6c5d525c040f59af3 --rpc-host mainnet.infura.io/v3/<Infura public API key> --rpc-port 443 --debug
    Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jmcph4/bite-keeper/bite_keeper/bite_keeper.py", line 73, in <module>
    BiteKeeper(sys.argv[1:]).main()
  File "/home/jmcph4/bite-keeper/bite_keeper/bite_keeper.py", line 48, in __init__
    self.tub = Tub(web3=self.web3, address=Address(self.arguments.tub_address))
  File "/home/jmcph4/bite-keeper/lib/pymaker/pymaker/sai.py", line 82, in __init__
    self._contract = self._get_contract(web3, self.abi, address)
  File "/home/jmcph4/bite-keeper/lib/pymaker/pymaker/__init__.py", line 157, in _get_contract
    if not is_contract_at(web3, address):
  File "/home/jmcph4/bite-keeper/lib/pymaker/pymaker/util.py", line 62, in is_contract_at
    code = web3.eth.getCode(address.address)
  File "/usr/local/lib/python3.7/dist-packages/web3/eth.py", line 198, in getCode
    [account, block_identifier],
  File "/usr/local/lib/python3.7/dist-packages/web3/manager.py", line 149, in request_blocking
    response = self._make_request(method, params)
  File "/usr/local/lib/python3.7/dist-packages/web3/manager.py", line 128, in _make_request
    return request_func(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 75, in apply_formatters
    response = make_request(method, params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/gas_price_strategy.py", line 34, in middleware
    return make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/attrdict.py", line 33, in middleware
    response = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/normalize_errors.py", line 25, in middleware
    result = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 75, in apply_formatters
    response = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/exception_retry_request.py", line 104, in middleware
    return make_request(method, params)
  File "/usr/local/lib/python3.7/dist-packages/web3/providers/rpc.py", line 83, in make_request
    **self.get_request_kwargs()
  File "/usr/local/lib/python3.7/dist-packages/web3/_utils/request.py", line 35, in make_post_request
    response.raise_for_status()
  File "/usr/local/lib/python3.7/dist-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://mainnet.infura.io/v3/<Infura public API key>:443

After modifying the code to remove the https:// prefix I had previously added, the same input produces:

$ bin/bite-keeper --eth-from <eth addr> --tub-address 0x448a5065aebb8e423f0896e6c5d525c040f59af3 --rpc-host https://mainnet.infura.io/v3/<Infura public API key> --rpc-port 443 --debug
    Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jmcph4/bite-keeper/bite_keeper/bite_keeper.py", line 73, in <module>
    BiteKeeper(sys.argv[1:]).main()
  File "/home/jmcph4/bite-keeper/bite_keeper/bite_keeper.py", line 48, in __init__
    self.tub = Tub(web3=self.web3, address=Address(self.arguments.tub_address))
  File "/home/jmcph4/bite-keeper/lib/pymaker/pymaker/sai.py", line 82, in __init__
    self._contract = self._get_contract(web3, self.abi, address)
  File "/home/jmcph4/bite-keeper/lib/pymaker/pymaker/__init__.py", line 157, in _get_contract
    if not is_contract_at(web3, address):
  File "/home/jmcph4/bite-keeper/lib/pymaker/pymaker/util.py", line 62, in is_contract_at
    code = web3.eth.getCode(address.address)
  File "/usr/local/lib/python3.7/dist-packages/web3/eth.py", line 198, in getCode
    [account, block_identifier],
  File "/usr/local/lib/python3.7/dist-packages/web3/manager.py", line 149, in request_blocking
    response = self._make_request(method, params)
  File "/usr/local/lib/python3.7/dist-packages/web3/manager.py", line 128, in _make_request
    return request_func(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 75, in apply_formatters
    response = make_request(method, params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/gas_price_strategy.py", line 34, in middleware
    return make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/attrdict.py", line 33, in middleware
    response = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/normalize_errors.py", line 25, in middleware
    result = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 75, in apply_formatters
    response = make_request(method, params)
  File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/formatting.py", line 73, in apply_formatters
    response = make_request(method, formatted_params)
  File "/usr/local/lib/python3.7/dist-packages/web3/middleware/exception_retry_request.py", line 104, in middleware
    return make_request(method, params)
  File "/usr/local/lib/python3.7/dist-packages/web3/providers/rpc.py", line 83, in make_request
    **self.get_request_kwargs()
  File "/usr/local/lib/python3.7/dist-packages/web3/_utils/request.py", line 35, in make_post_request
    response.raise_for_status()
  File "/usr/local/lib/python3.7/dist-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://mainnet.infura.io/v3/<Infura public API key>:443

Expected Behaviour

For the bite-keeper client to actually authenticate with the Infura API endpoint successfully.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.