-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
(node:73511) UnhandledPromiseRejectionWarning: Error: failed to meet quorum (method="call", params={"transaction":.. #1067
Comments
Just a quick parsing of these errors to help you debug it further: Error 1: Error 2: Error 3: You can read more about
Maybe you can experiment with reducing the poling interval in your subscription. |
I think it must be another part of your code base that is causing those errors. A quorum error is only caused by a FallbackProvider, but I don’t see you instantiating one, so maybe it’s embedded in one of your other libraries? |
@zemse Thank you so much, Zemse! let ethPrice;
const updateEthPrice = async () => {
const results = await kyber.methods
.getExpectedRate(
"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
addresses.tokens.dai,
1
)
.call(); //! bug possible
ethPrice = web3.utils
.toBN("1")
.mul(web3.utils.toBN(results.expectedRate))
.div(ONE_WEI);
};
await updateEthPrice();
setInterval(updateEthPrice, 15000);
await web3.eth
.subscribe("newBlockHeaders")
.on("data", async (block) => {
console.log(`New block received. Block # ${block.number}`);
// Get Execution Price of ETH/DAI on Uniswap
const dai = new Token(
ChainId.MAINNET,
"0x6B175474E89094C44Da98b954EedeAC495271d0F",
18
);
const weth = WETH[dai.chainId];
const daiWeth_Pair = await Fetcher.fetchPairData(dai, weth);
// const daiWeth_Pair = await Pair.fetchData(dai, weth); //! only for SDK2.
const amountsEth = await Promise.all([
kyber.methods
.getExpectedRate(
addresses.tokens.dai,
"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
AMOUNT_DAI_WEI
)
.call(), //! bug possible
daiWeth_Pair.getOutputAmount(new TokenAmount(dai, AMOUNT_DAI_WEI)),
]).catch(console.log);
const ethFromKyber = AMOUNT_DAI_WEI.mul(
web3.utils.toBN(amountsEth[0].expectedRate)
).div(ONE_WEI);
const ethFromUniswap = web3.utils.toBN(amountsEth[1][0].raw.toString());
const amountsDai = await Promise.all([
kyber.methods
.getExpectedRate(
"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
addresses.tokens.dai,
ethFromUniswap.toString()
)
.call(), //! bug possible
daiWeth_Pair.getOutputAmount(
new TokenAmount(weth, ethFromKyber.toString())
),
]).catch(console.log);
const daiFromKyber = ethFromUniswap
.mul(web3.utils.toBN(amountsDai[0].expectedRate))
.div(ONE_WEI);
const daiFromUniswap = web3.utils.toBN(amountsDai[1][0].raw.toString()); @ricmoo Thank you so much, Ricmoo! You're right. const {
ChainId,
Token,
TokenAmount,
WETH,
Fetcher,
Trade,
} = require("@uniswap/sdk");
{
"name": "@uniswap/sdk",
"license": "MIT",
"version": "3.0.3",
"description": "🛠 An SDK for building applications on top of Uniswap.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
],
"repository": "https://github.com/Uniswap/uniswap-sdk.git",
"keywords": [
"uniswap",
"ethereum"
],
"module": "dist/sdk.esm.js",
"scripts": {
"lint": "tsdx lint src test",
"build": "tsdx build",
"start": "tsdx watch",
"test": "tsdx test",
"prepublishOnly": "tsdx build"
},
"dependencies": {
"@uniswap/v2-core": "^1.0.0",
"big.js": "^5.2.2",
"decimal.js-light": "^2.5.0",
"jsbi": "^3.1.1",
"tiny-invariant": "^1.1.0",
"tiny-warning": "^1.0.3",
"toformat": "^2.0.0"
},
"peerDependencies": {
"@ethersproject/address": "^5.0.0-beta",
"@ethersproject/contracts": "^5.0.0-beta",
"@ethersproject/networks": "^5.0.0-beta",
"@ethersproject/providers": "^5.0.0-beta",
"@ethersproject/solidity": "^5.0.0-beta"
},
"devDependencies": {
"@ethersproject/address": "^5.0.2",
"@ethersproject/contracts": "^5.0.2",
"@ethersproject/networks": "^5.0.2",
"@ethersproject/providers": "^5.0.5",
"@ethersproject/solidity": "^5.0.2",
"@types/big.js": "^4.0.5",
"@types/jest": "^24.0.25",
"babel-plugin-transform-jsbi-to-bigint": "^1.3.1",
"tsdx": "^0.12.3"
},
"engines": {
"node": ">=10"
},
"prettier": {
"printWidth": 120,
"semi": false,
"singleQuote": true
}
} Hope it to be of any help. |
@zhengger Actually, I haven't used web3 much, I do not know more about it's API. The interval time of 15 sec is just actuallly fine for ethereum. However I guess that there could be something with your subscription part of code. Since the error 2 (#1067 (comment)) is calling await web3.eth
.subscribe("newBlockHeaders") What this probably does is constantly making calls to see if block number is incremented. So maybe you need to see how to reduce the rate of constant calling. I tried to look at web3 docs, but couldn't spot a option that does this. Web3.js has a gitter chat https://gitter.im/ethereum/web3.js there you can take help regarding web3. Other than that, I can recommend you to try plain ethers.js in your next project and use minimum dependencies instead of depending on lot of things, you would have better time fixing any error that might come up with lesser deps than more. |
Hi @zemse!
Error 2: TIMEOUT while requsting eth_blockNumber cloudfare backend. Error 3: ECONNRESET while requesting eth_call alchemy backend. So maybe it's a possible solution to adjust the frequency of requests although I don't know how to do it.. const ws = new Web3WsProvider(
"wss://mainnet.infura.io/ws/v3/" + process.env.INFURA_URL_0,
options
); |
I found the bug may be sourced from the "Fetcher" in the "@Uniswap/SDK". After replaced the default provider "Fetcher" in the with the existing websocket provider, old errors disapeard were repalced by new errors subsequently. const {ethers} = require("ethers");
const {
ChainId,
Token,
TokenAmount,
WETH,
Fetcher,
Trade,
} = require("@uniswap/sdk");
// @ts-ignore
clientConfig: {
// Useful if requests are large
maxReceivedFrameSize: 100000000, // bytes - default: 1MiB
maxReceivedMessageSize: 100000000, // bytes - default: 8MiB
// Useful to keep a connection alive
keepalive: true,
keepaliveInterval: 60000, // ms
},
// Enable auto reconnection
reconnect: {
auto: true,
delay: 1000, // ms
maxAttempts: 10,
onTimeout: false,
},
};
const ws = new Web3WsProvider(
"wss://mainnet.infura.io/ws/v3/" + process.env.INFURA_URL,
options
);
const web3 = new Web3(ws);
const daiWeth_Pair = await Fetcher.fetchPairData(
dai,
weth,
new ethers.providers.Web3Provider(ws) // to replace the default provider.
);
Here is the old code. const {
ChainId,
Token,
TokenAmount,
WETH,
Fetcher,
Trade,
} = require("@uniswap/sdk");
// @ts-ignore
clientConfig: {
// Useful if requests are large
maxReceivedFrameSize: 100000000, // bytes - default: 1MiB
maxReceivedMessageSize: 100000000, // bytes - default: 8MiB
// Useful to keep a connection alive.
keepalive: true,
keepaliveInterval: 60000, // ms
},
// Enable auto reconnection.
reconnect: {
auto: true,
delay: 1000, // ms
maxAttempts: 10,
onTimeout: false,
},
};
const ws = new Web3WsProvider(
"wss://mainnet.infura.io/ws/v3/" + process.env.INFURA_URL,
options
);
// use default provider which is omitted here.
const web3 = new Web3(ws);
const daiWeth_Pair = await Fetcher.fetchPairData(
dai,
weth
); Here are the new errors:
|
I think this issue may be stale, so I'm closing it. If not, please feel free to re-open or start a new issue/discussion. Thanks! :) |
I found a very similar issue like mine. But I cannot find the answer. So I posted a new issue here. Thanks for your help!
##841 (comment)
Part of my code below where @uniswap/sdk used ethers.js with @ethersproject_providers@5.0.9 :
Some Error information:
Error1:
Error2:
Error3:
The text was updated successfully, but these errors were encountered: