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

Migrate from ttmath to stint #24

Merged
merged 9 commits into from
May 7, 2018
Merged

Conversation

mratsim
Copy link
Contributor

@mratsim mratsim commented May 6, 2018

No description provided.

Copy link
Contributor

@yglukhov yglukhov left a comment

Choose a reason for hiding this comment

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

Very exciting! A couple of minor comments, and LGTM.

@@ -5,33 +5,36 @@
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import ttmath, constants, strformat, strutils, sequtils, endians, macros, utils / padding, rlp
import stint, constants, strformat, strutils, sequtils, endians, macros, utils / padding, rlp

# some methods based on py-evm utils/numeric

# TODO improve

proc intToBigEndian*(value: UInt256): Bytes =
Copy link
Contributor

Choose a reason for hiding this comment

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

These procs seem to know too much about stint internal structure. Can we just move them to stint lib?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I will move them this week, for now I just focused on porting 1-to-1 and just exposing Stint internal but tested functionality (like countLeadingZeroBits) and avoid introducing new procs/tests/reviews in Stint.

@@ -21,7 +21,7 @@ type

# TODO: The Int256 value is stored as array[32, byte], and we bitcast it
# back and forth. This is a hacky workaround for the problem that clang
# doesn't let you store ttmath types inside nim variant types (unions). Things
# doesn't let you store stint types inside nim variant types (unions). Things
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this is no longer the case, so we can just revert this hack completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, it seems like only vint is used externally here: https://github.com/status-im/nimbus/blob/master/src/runner.nim#L86

Will remove that hack as well.

@mratsim mratsim requested a review from cheatfate May 7, 2018 08:35
Copy link
Contributor

@coffeepots coffeepots left a comment

Choose a reason for hiding this comment

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

Great stuff. Nice to see that some of the hacky stuff required for ttmath will disappear! Having a pure Nim implementation is a great step forward for Nimbus.

@mratsim mratsim merged commit 2d34f14 into master May 7, 2018
@mratsim mratsim deleted the Migrate-from-ttmath-to-stint branch May 11, 2018 16:23
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.

3 participants