-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix the issue of handling decimals. #2886
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0xverin
force-pushed
the
fix-assembleAssertions-issue
branch
from
July 11, 2024 03:34
5e35292
to
06b8d65
Compare
tee-worker/litentry/core/assertion-build/src/dynamic/contracts/libraries/StringShift.sol
Outdated
Show resolved
Hide resolved
tee-worker/litentry/core/assertion-build/src/dynamic/contracts/libraries/StringShift.sol
Outdated
Show resolved
Hide resolved
0xverin
force-pushed
the
fix-assembleAssertions-issue
branch
from
July 12, 2024 07:10
9502740
to
618b859
Compare
BillyWooo
reviewed
Jul 14, 2024
tee-worker/litentry/core/assertion-build/src/dynamic/contracts/libraries/StringShift.sol
Outdated
Show resolved
Hide resolved
0xverin
force-pushed
the
fix-assembleAssertions-issue
branch
from
July 15, 2024 02:15
310090e
to
eab3ade
Compare
higherordertech
approved these changes
Jul 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
In Solidity, if division by a number results in a decimal, precision will be lost.
For example:
10001/1000=10(not 10.001)
,1/1000=0(not 0.001)
.Therefore, the previous method of range*1000 / 1000 is inaccurate and may lead to bugs:
If
range*1000
is less than 1000, we will only get 0 (ranges for BTC and ETH may always equal to 0).Solution:
Avoid mathematical operations and directly use string padding.
resolves p-877
Labels
Please apply following PR-related labels when appropriate:
C0-breaking
: if your change could break the existing client, e.g. API change, critical logic changeC1-noteworthy
: if your change is non-breaking, but is still worth noticing for the client, e.g. reference code improvementHow (Optional)
Testing Evidences
Please attach any relevant evidences if applicable