-
-
Notifications
You must be signed in to change notification settings - Fork 328
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: increase range for the random value of request id in prover #6115
Conversation
Request id is currently generated by choosing random number 0-10000. This range is too small, and in some scenarios causes duplicate ids in batch. Example: call eth_call to multicall contract, aggregating balanceOf calls of many tokens. If enough tokens are queried, then many eth_getProof requests will be submitted in a batch. for a large amount of tokens there is a large chance of request id collision, failing the check in https://github.com/ChainSafe/lodestar/blob/unstable/packages/prover/src/utils/json_rpc.ts#L84
@@ -100,6 +100,6 @@ export class ELRpc { | |||
|
|||
getRequestId(): string { | |||
// TODO: Find better way to generate random id | |||
return (Math.random() * 10000).toFixed(0); | |||
return (Math.random() * 100000000000000000).toFixed(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing this! Indeed the range of 10000 is improper for this application.
Math.random is a bad generator regardless. Why not have an incrementing counter @nazarhussain ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is better than what we had before.
Created an issue to investigate this further.
🎉 This PR is included in v1.14.0 🎉 |
…inSafe#6115) fix: increase range for the random value of request id Request id is currently generated by choosing random number 0-10000. This range is too small, and in some scenarios causes duplicate ids in batch. Example: call eth_call to multicall contract, aggregating balanceOf calls of many tokens. If enough tokens are queried, then many eth_getProof requests will be submitted in a batch. for a large amount of tokens there is a large chance of request id collision, failing the check in https://github.com/ChainSafe/lodestar/blob/unstable/packages/prover/src/utils/json_rpc.ts#L84
Request id is currently generated by choosing random number 0-10000.
This range is too small, and in some scenarios causes duplicate ids in batch.
Example:
call eth_call to multicall contract, aggregating balanceOf calls of many tokens.
If enough tokens are queried, then many eth_getProof requests will be submitted in a batch. for a large amount of tokens there is a large chance of request id collision, failing the check in https://github.com/ChainSafe/lodestar/blob/unstable/packages/prover/src/utils/json_rpc.ts#L84