-
Notifications
You must be signed in to change notification settings - Fork 790
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
Common: Return BigInt for param() functionality #1846
Comments
I vaguely remember that we have some values which are of type |
Ah, you are right, just found So it seems this is just for big numbers, so this would indeed even some additional argument to go BigInt here. 🙂 |
I've started work on this and have a question. I don't think returning |
another option would be to throw if it isn't found. it might be safer, and encourage ensuring only valid parameters are accessed. i imagine it would be more difficult to debug certain situations if a param was being returned as zero rather than alerting that it wasn't found. |
Possibly and I'll try it out locally and see what side affects it has. It seems like it could cause a much bigger set of needed rewrites to implement try/catch logic across the monorepo since this code is used in lots of places on the assumption it's returning either null or a number already. Will do some more looking. |
yeah, well if null is handled like that then maybe that achieves the desired affect, but i see your point about null getting coerced to zero. i think handling null is easier than handling a thrown error though. i would think the code could be guarded (e.g. a common if eip enabled check) before accessing params that are only available after an upgrade. |
Here's a good example of what I'm talking about. The test expects the data fee returned to be zero but two layers down in the call stack, you have this call that expects a return value or 0 (not an error if the specific parameter doesn't exist). It's easy enough to fix this particular instance but I just don't have a sense for if throwing an error really the right solution here. If this example and however many others like it were already working with null being coerced to zero, should we intentionally change the behavior of something to require a |
Yeah, I would agree to think that throwing here is overblown. Can't we just return Returning |
Update: just some additional thought: I guess It might also help on these situations to add an explicit value Just as some thought, this might also help to get to an overall consistent solution. |
* Common: Return BigInt for param() functionality Fixes #1846 * Change param getters to throw on non-existent value * Fixes * switch return to bigint or undefined * Switch param getters to return undefined and fix common tests * tx: changes to accomodate param getters * More changes * More adjustments * Fix NaN bug in opcode fee builder * Hack to fix EIP-2537 edge case * client: fix test syntax * lint * Return 0 when param doesn't exist * Spelling, dedup param usage * Update `paramByEip` to allow undefined * Hardcode EIP-2537 gas discount array * uncomment test
* Common: Return BigInt for param() functionality Fixes #1846 * Change param getters to throw on non-existent value * Fixes * switch return to bigint or undefined * Switch param getters to return undefined and fix common tests * tx: changes to accomodate param getters * More changes * More adjustments * Fix NaN bug in opcode fee builder * Hack to fix EIP-2537 edge case * client: fix test syntax * lint * Return 0 when param doesn't exist * Spelling, dedup param usage * Update `paramByEip` to allow undefined * Hardcode EIP-2537 gas discount array * uncomment test
Closed by #1854 |
* Common: Return BigInt for param() functionality Fixes #1846 * Change param getters to throw on non-existent value * Fixes * switch return to bigint or undefined * Switch param getters to return undefined and fix common tests * tx: changes to accomodate param getters * More changes * More adjustments * Fix NaN bug in opcode fee builder * Hack to fix EIP-2537 edge case * client: fix test syntax * lint * Return 0 when param doesn't exist * Spelling, dedup param usage * Update `paramByEip` to allow undefined * Hardcode EIP-2537 gas discount array * uncomment test
* Common: Return BigInt for param() functionality Fixes #1846 * Change param getters to throw on non-existent value * Fixes * switch return to bigint or undefined * Switch param getters to return undefined and fix common tests * tx: changes to accomodate param getters * More changes * More adjustments * Fix NaN bug in opcode fee builder * Hack to fix EIP-2537 edge case * client: fix test syntax * lint * Return 0 when param doesn't exist * Spelling, dedup param usage * Update `paramByEip` to allow undefined * Hardcode EIP-2537 gas discount array * uncomment test
* Common: Return BigInt for param() functionality Fixes #1846 * Change param getters to throw on non-existent value * Fixes * switch return to bigint or undefined * Switch param getters to return undefined and fix common tests * tx: changes to accomodate param getters * More changes * More adjustments * Fix NaN bug in opcode fee builder * Hack to fix EIP-2537 edge case * client: fix test syntax * lint * Return 0 when param doesn't exist * Spelling, dedup param usage * Update `paramByEip` to allow undefined * Hardcode EIP-2537 gas discount array * uncomment test
* Common: Return BigInt for param() functionality Fixes #1846 * Change param getters to throw on non-existent value * Fixes * switch return to bigint or undefined * Switch param getters to return undefined and fix common tests * tx: changes to accomodate param getters * More changes * More adjustments * Fix NaN bug in opcode fee builder * Hack to fix EIP-2537 edge case * client: fix test syntax * lint * Return 0 when param doesn't exist * Spelling, dedup param usage * Update `paramByEip` to allow undefined * Hardcode EIP-2537 gas discount array * uncomment test
* Common: Return BigInt for param() functionality Fixes #1846 * Change param getters to throw on non-existent value * Fixes * switch return to bigint or undefined * Switch param getters to return undefined and fix common tests * tx: changes to accomodate param getters * More changes * More adjustments * Fix NaN bug in opcode fee builder * Hack to fix EIP-2537 edge case * client: fix test syntax * lint * Return 0 when param doesn't exist * Spelling, dedup param usage * Update `paramByEip` to allow undefined * Hardcode EIP-2537 gas discount array * uncomment test
There are four param-retrieving functions in Common:
param()
paramByEIP()
paramByHardfork()
paramByBlock()
These functions currently return a
number
if available, otherwisenull
(needs confirmation). When doing a search on usages of the functions it turns out that on 80%+ of the occurrences, the value is used in a BigInt context and therefore transformed to BigInt with aBigInt()
constructor. In many of the remaining 20% cases there is an indirect need of a BigInt result (e.g. at the end of some calculation).It would therefore make a lot of sense to directly return a BigInt on these function calls.
In addition all these functions have an
any
return type. This is highly suboptimal and the functions should be properly typed along with this transition work.The text was updated successfully, but these errors were encountered: