Skip to content
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

Change hardcoded "id: 1" to random integer #42

Closed
wants to merge 1 commit into from

Conversation

dmihal
Copy link

@dmihal dmihal commented Feb 2, 2020

This library has id: 1 hardcoded when making RPC calls. Unfortunately, this causes some other RPC calls with the ID of 1 to be overriden. This is fixed by using a random integer for the RPC ID.

Copy link
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmihal thanks for suggesting this! With the request overriding you're seeing, wouldn't this still override some request, technically? Or is this leaning on the statistical improbability that this id already exists?

@ziogaschr
Copy link

ziogaschr commented Feb 18, 2020

I will try to share an ugly idea.

@whymarrh what if we drop id at all here and let the web3-provider-engine create-payload to add it?
I don't like that we don't follow the RPC spec here and we rely on another package to set it up.
The only way that this might be a solution is if this package is only used by web3-provider-engine, on the other hand, how can we know if and how this package will be used in the future?

p.s.: I just started playing with the web3-provider-engine stuff and its surroundings and this id: 1 causes me a huge issue.
p.s2: @dmihal nice catch of this bug 👍. I see @whymarrh point, but also your solution will work most of the times. Although, it might cause random failures that will be very hard to catch afterwards.


UPDATE: I just saw that the suggested solution won't work with the README example either using ethjs-provider-http. So consider it a bad idea. What if we allow a getRPCId function to be passed as an opt in the constructor?

@whymarrh
Copy link
Contributor

whymarrh commented Sep 2, 2020

We'll look to address this soon, certainly having the hardcoded id isn't good

@whymarrh
Copy link
Contributor

whymarrh commented Sep 2, 2020

There is also precedent for using a random number as the ID, as is done in src/subscribe.js:

id: createRandomId(), method, params, jsonrpc: "2.0"

I missed that context in my original comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants