Parity

Parity dev 節點無法通過 web3 py 發送交易

  • July 11, 2018

我正在通過 docker 使用具有以下設置的奇偶校驗開發節點:

docker run -d -p 8545:8545 parity/parity --config dev --jsonrpc-interface all --jsonrpc-apis all --jsonrpc-cors "*"

當我嘗試檢索餘額或創建使用者帳戶時,它執行良好。但是,當我嘗試發送事務時,會出現 ReadTimeout 異常:

   w3.eth.sendTransaction({'to': w3.eth.accounts[1], 'from': w3.eth.coinbase, 'value': 3 * 10**9})
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/eth.py", line 268, in sendTransaction
   [transaction],
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/manager.py", line 107, in request_blocking
   response = self._make_request(method, params)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/manager.py", line 90, in _make_request
   return request_func(method, params)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/middleware/gas_price_strategy.py", line 18, in middleware
   return make_request(method, params)
 File "cytoolz/functoolz.pyx", line 232, in cytoolz.functoolz.curry.__call__
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/middleware/formatting.py", line 48, in apply_formatters
   response = make_request(method, formatted_params)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/middleware/attrdict.py", line 18, in middleware
   response = make_request(method, params)
 File "cytoolz/functoolz.pyx", line 232, in cytoolz.functoolz.curry.__call__
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/middleware/formatting.py", line 48, in apply_formatters
   response = make_request(method, formatted_params)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/middleware/normalize_errors.py", line 9, in middleware
   result = make_request(method, params)
 File "cytoolz/functoolz.pyx", line 232, in cytoolz.functoolz.curry.__call__
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/middleware/formatting.py", line 48, in apply_formatters
   response = make_request(method, formatted_params)
 File "cytoolz/functoolz.pyx", line 232, in cytoolz.functoolz.curry.__call__
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/middleware/formatting.py", line 48, in apply_formatters
   response = make_request(method, formatted_params)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/middleware/exception_retry_request.py", line 87, in middleware
   return make_request(method, params)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/providers/rpc.py", line 68, in make_request
   **self.get_request_kwargs()
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/web3/utils/request.py", line 26, in make_post_request
   response = session.post(endpoint_uri, data=data, *args, **kwargs)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/requests/sessions.py", line 555, in post
   return self.request('POST', url, data=data, json=json, **kwargs)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
   resp = self.send(prep, **send_kwargs)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
   r = adapter.send(request, **kwargs)
 File "/Users/p/anaconda/envs/py36/lib/python3.6/site-packages/requests/adapters.py", line 521, in send
   raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='localhost', port=8111): Read timed out. (read timeout=10)

我已經測試了相同的web3.py程式碼可以很好地與兩者ganachegeth --dev.

更新: web3.js掛起類似的請求

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
var BN = web3.utils.BN;

web3.eth.getAccounts(async (err, acc) => {
   let startingBalance = web3.utils.toBN(await web3.eth.getBalance(acc[0]))
   console.log(startingBalance.toString());
   let result = await web3.eth.sendTransaction({
       from: acc[0],
       to: acc[1],
       value: 1000000
   })
   console.log(result);
});

在這種情況下,奇偶校驗節點處於掛起狀態,因為基礎賬戶尚未解鎖。

引用自:https://ethereum.stackexchange.com/questions/53095