-
Notifications
You must be signed in to change notification settings - Fork 9
[WIP] Rewrite in typescript, add more methods #8
Conversation
I'll just take notice and leave commenting/discussion to @axic and others who are deeper involved. |
Re-wrote the lib in typescript:
However I don't have a strong opinion about any of them and will gladly change. I'd appreciate if someone (maybe @axic) could have a look and see if it's generally ok so I can implement the remaining methods, add documentation and more tests. |
Googled a bit and came along this EIP from @axic and follow up/related work, will leave here for reference: ethereum/EIPs#159 What is actually the current default behavior on overflow for the VM? @s1na Generally I think these two method types with the plain + mod method should be a good and flexible to choose from solution? Another thing: do you have any link for better diff comparison? |
Thanks for the link, will go through it. Yeah so far I've come to the conclusion that we need both of these behaviours, each in some parts of the code. Having operations overflow by default seems safer and wherever wrapping is safe, the ops with explicit Might be easier to directly compare the whole branch against index.js. |
Thanks! 😀 Is this branch now ready for review or is there still something missing? |
On second thought that wasn't a very helpful comment 😆 Maybe I should break it into multiple PRs? I still have to update the readme too. |
😀😛 If it's not too much work then it might be worth it - yes - since this is really heavy and broad changing stuff touching the fundamentals of the VM. We do lots of heavier changes atm (which is a good thing IMO) but should also not totally overrush and do some extra paths here and there where it valuably adds to transition reliability (what a sentence 😛). |
This PR overrides overrides clone to return a
FixedBN
instance (with same width) on operations (e.g. add).As an example I also overrode
add
to apply modulo when overflow occurs (as per #6). I'm not sure if this is preferable or throwing on overflow?This also means that
FixedBN
should override most of theBN
methods to either check bounds or do modulo, which is not ideal. Are there any better ideas?Pinging @holgerd77 for comments.