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

Improved output of formatNumberReadable #13277

Conversation

Ruko97
Copy link
Contributor

@Ruko97 Ruko97 commented Jul 15, 2022

Follow up to issue #9601 and pull request #13163.
Based on advice by @cameel in the conversation in issue.
Previously formatNumberReadable(57896044618658097711785492504343953926634992332820282019728792003956564819968) would equal to 0x80 * 2 ** 248, but now it equals to 2 ** 255.
Also, there was a bug in the test case test_format_number_readable_signed in test/StringUtils.cpp. formatNumberReadable(-0xffffffff) should be equal to -2 ** 32 + 1 but previously it was tested to be equal to -2 ** 32 - 1. The new version of formatNumberReadable fixes this problem.

@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch 3 times, most recently from 27947c0 to fb1aa30 Compare July 16, 2022 05:01
@matheusaaguiar matheusaaguiar self-assigned this Aug 15, 2022
Copy link
Collaborator

@matheusaaguiar matheusaaguiar left a comment

Choose a reason for hiding this comment

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

Looks good!
Just some code style adjustments and readability suggestions.

@Ruko97 Ruko97 dismissed a stale review via dc0b2b9 August 17, 2022 06:28
@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch from fb1aa30 to dc0b2b9 Compare August 17, 2022 06:28
@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch from 59926fa to 9f3a3f8 Compare August 20, 2022 09:46
@matheusaaguiar
Copy link
Collaborator

I think this is in good shape. Please, rebase.

@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch from 9f3a3f8 to ddfa9ea Compare August 28, 2022 16:58
@Ruko97
Copy link
Contributor Author

Ruko97 commented Aug 28, 2022

Pushed a rebased version right now. Please check it.

Copy link
Collaborator

@matheusaaguiar matheusaaguiar left a comment

Choose a reason for hiding this comment

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

Sorry, I had another look and found some things that were glossed over before and could be improved.

@leonardoalt
Copy link
Member

Auto please rebase onto origin/develop to get rid of the CI errors.

@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch from ddfa9ea to 9feab34 Compare September 7, 2022 13:22
@Ruko97
Copy link
Contributor Author

Ruko97 commented Sep 7, 2022

I have rebased and updated my commit based on the suggestions here. Sorry for being late.

@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch 3 times, most recently from 2bc3c96 to 2aa6706 Compare September 8, 2022 01:53
@matheusaaguiar
Copy link
Collaborator

I have rebased and updated my commit based on the suggestions here. Sorry for being late.

No need to apologize, you are not late at all. You are actually quite timely with your responses. Thanks for contributing to the project :)

Copy link
Collaborator

@matheusaaguiar matheusaaguiar left a comment

Choose a reason for hiding this comment

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

I consider it ready. But it needs another rebase on top of develop since we are having a release today.

@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch from 2aa6706 to 24fe519 Compare September 9, 2022 06:32
matheusaaguiar
matheusaaguiar previously approved these changes Sep 16, 2022
Copy link
Collaborator

@matheusaaguiar matheusaaguiar left a comment

Choose a reason for hiding this comment

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

It is going to need another rebase, but I am approving so someone else from the team can merge it later.

@Ruko97
Copy link
Contributor Author

Ruko97 commented Oct 24, 2022

The errors in CircleCI seem to be related to not being able to find fmt::format. Does CircleCI not use the fmt library?

@cameel
Copy link
Member

cameel commented Oct 24, 2022

It's there but we added it as a dependency very recently so not all of our libs link to it yet. You have to add it to target_link_libraries in libsolutil/CMakeLists.txt. See how #13473 does it.

@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch 3 times, most recently from 6623208 to 0af20fa Compare October 25, 2022 01:31
Copy link
Collaborator

@matheusaaguiar matheusaaguiar left a comment

Choose a reason for hiding this comment

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

Some adjustments and I wanted to confirm that you added the test case mentioned here.
Also, @nikola-matic are you satisfied with the current replacements of string concatenation or do you think that they are needed for the simple cases at lines 133, 203 and 218?

@nikola-matic
Copy link
Collaborator

Some adjustments and I wanted to confirm that you added the test case mentioned here. Also, @nikola-matic are you satisfied with the current replacements of string concatenation or do you think that they are needed for the simple cases at lines 133, 203 and 218?

The formatting looks good now, and no, no need for fmt::format for simple cases. Another rebase would be nice to get rid of the gp2 failure.

@Ruko97
Copy link
Contributor Author

Ruko97 commented Oct 26, 2022

Some adjustments and I wanted to confirm that you added the test case mentioned here. Also, @nikola-matic are you satisfied with the current replacements of string concatenation or do you think that they are needed for the simple cases at lines 133, 203 and 218?

Yes, I added them at lines 185, 186, 285 and 286. I added some more tests now just to make sure.

@Ruko97
Copy link
Contributor Author

Ruko97 commented Oct 26, 2022

I am also removing the std::to_string functions, and rebasing the code to the latest version.

@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch 2 times, most recently from af1079b to 0028cd2 Compare November 2, 2022 13:01
@nikola-matic
Copy link
Collaborator

@matheusaaguiar @ekpyron will this need a changelog entry?

@ekpyron
Copy link
Member

ekpyron commented Nov 2, 2022

@matheusaaguiar @ekpyron will this need a changelog entry?

I'd say, it's borderline. But strictly speaking it's user-facing, so we can just default to "yes".

@matheusaaguiar
Copy link
Collaborator

matheusaaguiar commented Nov 2, 2022

@Ruko97 , please add a Changelog entry under the Compiler Features section, describing shortly the improvement on readability of large/hex numbers. Also, the fixed bug, under section Bugfixes.

@Ruko97 Ruko97 force-pushed the formatNumberReadable_styleChange_upstream branch from 0028cd2 to 362a86e Compare November 3, 2022 12:28
Changelog.md Outdated
@@ -8,9 +8,11 @@ Compiler Features:
* Standard JSON: Add a boolean field `settings.metadata.appendCBOR` that skips CBOR metadata from getting appended at the end of the bytecode.
* Yul Optimizer: Allow replacing the previously hard-coded cleanup sequence by specifying custom steps after a colon delimiter (``:``) in the sequence string.
* Language Server: Add basic document hover support.
* SMTChecker: Improved readability for large integers that are powers of two or almost powers of two
Copy link
Collaborator

Choose a reason for hiding this comment

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

@leonardoalt is this SMT checker related?

@nikola-matic nikola-matic force-pushed the formatNumberReadable_styleChange_upstream branch 2 times, most recently from e248feb to ff19748 Compare November 4, 2022 13:11
@nikola-matic
Copy link
Collaborator

Rebased, resolved conflicts, and added periods to changelog entires. The build should now be fine, and hopefully closer to merging.

@chriseth chriseth force-pushed the formatNumberReadable_styleChange_upstream branch 5 times, most recently from ea822bd to d6542b5 Compare November 14, 2022 16:35
… and one-less-than powers of two in a more compact format
@chriseth chriseth force-pushed the formatNumberReadable_styleChange_upstream branch from d6542b5 to 3abf272 Compare November 14, 2022 16:37
Copy link
Contributor

@NunoFilipeSantos NunoFilipeSantos left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@matheusaaguiar matheusaaguiar left a comment

Choose a reason for hiding this comment

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

LGTM

@NunoFilipeSantos NunoFilipeSantos merged commit 75a74cd into ethereum:develop Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants