-
Notifications
You must be signed in to change notification settings - Fork 795
generic Provider allowing relaxed json rpc handling #2527
base: master
Are you sure you want to change the base?
Conversation
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.
I'm supportive of this feature, because this really comes up a lot in foundry, unfortunately, especially with new testnets.
having an option to allow malformed json rpc would be useful.
defer to @DaniPopes re changes/how to proceed
Since there's interest to accept this PR I'm putting in the time to do a couple of minor cleanups. E.g., the name of the typevar is now RELAXED and LooseHttp is RelaxedHttp. Note that the real thrust of this change is to allow these types to be generics so that behavior can be parameterized in general. To do this RELAXED would be a more complex type, but the bones are there. |
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.
would love to get this in cc @DaniPopes
@aathan anything else needs cleanup here?=
👋 checking in here |
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.
Needs cargo +nightly fmt
.
This is a pretty big breaking change, I think this is better implemented with a run time check that is opt-in at construction of the provider, like a relaxed(bool)
method.
May I ask what would break exactly? It's been a while since I wrote/submitted this but as I recall: (a) the ResponseVisitor didn't seem like something with external dependents of course, (c) is not a big deal in this case. This change would really be helpful in that they'd allow foundry users to connect to imperfect providers. I'd like to get this merged so if you feel strongly about it and the changes really are breaking external dependents I can refactor. |
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
|
Motivation
Sometimes you have no choice but to interact with json rpc endpoints that don't exactly adhere to the standards. Innocuous departures from the standard should be tolerable.
Solution
I'm new to Rust, so I do not claim this implementation is ideal. From what I could tell the only way to achieve this is to modify the deserializer, and in order to do this without additional runtime state variables, I implemented this via a const bool generic type parameter on Response and Provider. A pull request I am submitting to https://github.com/foundry-rs/foundry will reference this pull request.
Because I export a type name Http which is equivalent to the old type, I believe this is not a breaking change; but that depends on what level of abstraction your source is at.
PR Checklist