-
Notifications
You must be signed in to change notification settings - Fork 791
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
[WIP] convert difficulty param to hex string #1258
Conversation
thanks for the PR! looks good, i left some notes i hope they are helpful |
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
c48db7e
to
48405bc
Compare
3c30264
to
5f59124
Compare
hey @ghorbanian, i'm sorry to lead you astray but I learned that These things used to be true:
So I think it was overreaching to work on If you'd like to refocus scope back on just solving this at the |
8de05a3
to
4301902
Compare
I made the changes in the |
great, thanks, I will try to review today! |
/** | ||
* Helper functions | ||
*/ | ||
export * from './helpers' |
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 still not sure if we want to add this file to the exported methods, although it would be a nice catch-all for future helper methods. @holgerd77 any thoughts?
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.
Also given this some thought.
I think we should definitely not just open up a whole new helper category here on the sideline, we've Util relatively well structured now and to introduce some "fall-back" category for things we are not sure doesn't seem like a very good idea to me.
Generally with this implementation from above we run into this problem we've discussed in the chat 1-2 weeks ago (@ghorbanian sorry, this was in our internal chat, so you just couldn't follow-up on this) that with allowing both hex-prefixed strings (being seen as hex-byte-representations) and non-hex-strings (being assumed to be numbers) there is no chance to differentiate if people want non-hex strings to be integers or (this actually happens a lot in practice) just have forgotten the 0x
hex prefix but the input is actually a hex-byte-representation string.
This is really dangerous. With the regex implementation from above one is already catching a lot of stuff but just not all, and this would "break" respectively get ambiguous on strings like "1102" or the like. And it's just no win if things go wrong every 20th time or so (this is even a lot harder to debug than failures triggered every time).
I think we should at least not allow these kind of things officially in the util library when we just did the iteration of getting a lot stricter on type checking along with the v7 releases https://github.com/ethereumjs/ethereumjs-util/releases/tag/v7.0.0 for safety reasons.
Two things I can imagine here.
- I think the functionality would fit a lot more naturally in the Util method suite as an
intToBuffer
method as a counter part tobufferToInt
(in thebytes
package) we already have. But this method should then really only allow integer input of various forms (integer
itself,integer
string, something else?). If we then want to make an additional exception for the RPC use case we should add this as custom code to thefrom-rpc
methods inBlock
itself (if (hasSomeHexPrefix) use toBuffer(), else use intToBuffer)
). This might be an exception worth to make in this use case since RPC responses should be relatively well defined I guess. On the Util integration side I am still not 100% sure if this aligns well with e.g. the more generaltoBuffer
method, we likely don't want to end up with 7 different flavors of these Buffer conversion methods. - We generally hang this lower and just add this to an internal helper function in a new
util.ts
file in theBlock
library which we should then exclude from documentation in thetypedoc.js
file.
Atm I have a slight preference for 2., but not totally sure.
WDYGT? 🤔
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.
Option 2 sounds like it would come with much less ambiguity. The function can keep the name integerToHex
. We can think about making the helper function externally available if the need arises in the future. Any thoughts, @ryanio?
looks like ci is failing with:
so since you know the transaction is a legacy one, you could cast it as e.g. come to think of it, a good follow-up PR might be to add 1559 support to |
Yea, I'd be glad to look into 1559 support next week. Thank you so much @ryanio! Would have been hard to get started without your help. |
Any idea why I would be getting the following error every time I run tests locally from root with
I did some digging and I think it only fails locally. I just force push with |
hm no need to worry about that, maybe you are using a terminal without color support |
Minimum viable example of approach to implement
toHex
helper function to solve issue #726 . Attempting to build and run test throws aTS2305
error. The compiler does not recognize the newly created helper function that is to be committed as a part of this PR.