-
Notifications
You must be signed in to change notification settings - Fork 146
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: Precision loss for gas calculation of HTS system contracts v2 #15446
fix: Precision loss for gas calculation of HTS system contracts v2 #15446
Conversation
Signed-off-by: Stanimir Stoyanov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. tyvm @stoyanov-st
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
…s-calculation # Conflicts: # hedera-node/hedera-config/src/main/java/com/hedera/node/config/data/ContractsConfig.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from hedera-base changes. Will defer to @lukelee-sl for smart contract changes
* develop: (22 commits) test: New HAPI test for TokenAirdrop transaction (#15348) test: unit test verifySyncInvalidEd25519() is not stable (#15534) chore: add `TracerBinding` interface for `TransactionExecutors`. (#15480) chore: Add missing javadocs in Consensus Service (#15299) fix: Validate `CustomFees` input arrays in `UpdateTokenCustomFeesDecoder` (#15520) feat: migrate event serialization to protobuf (#15417) fix: 15494: Improve VirtualLeafRecord serialization to bytes during flushes (#15512) docs: tss block signing proposal (#15160) fix: 15438: Eliminate busy loop in HalfDiskHashMap.endWriting() (#15439) build: cleanup settings.gradle.kts / remove build.gradle.kts (#15470) test: fix CryptographyTests (#15529) fix: recreate block hash from state (#15444) docs: Proposal Process Update - Specify post-acceptance non-material update procedure (#15447) chore: testnet event hashing (#15432) fix: 15167: Remove timeout from reconnect/rehash Iterators (#15468) chore: remove snapshot ops (#15462) feat: Add TokenUpdateNFTs as a smart contract operation v2 (#15445) feat: introduce PbjRecordHasher and RosterUtils.hash(Roster) (#15457) fix: Precision loss for gas calculation of HTS system contracts v2 (#15446) chore: correct the variable name in roster.proto (#15465) ... # Conflicts: # hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/scope/HandleHederaOperations.java
Description:
NOTE: This PR is copied from PR
Due to DCO issues we had to open this one with the exact changes and linked issues.
Original description from initial PR
Main issues are two
Those results represent 3 real and possible price schemes for hBar:
Values for fields in ExchangeRate.java
1hbar =
~$0.005
| hbarEquiv =30k
; centEquiv =16197
1hbar =
~$0.12
| hbarEquiv =30k
; centEquiv =359789
1hbar =
~$0,96
| hbarEquiv =30k
; centEquiv =2888899
Test cases for contractCalls calling system contracts using the above exchange rates.
cryptoTransferNonFungible + auto-associate ->
747724
,748112
,823803
🤯cryptoTransferNonFungible ->
43467
,43474
,44959
Conclusion, due to precision loss the higher the price for the operation & per hbar, the higher the discrepancies.
This PR aims to fix the precision loss by the following changes :
FEE_SCHEDULE_UNITS_PER_TINYCENT
, multiply numerator withFEE_SCHEDULE_UNITS_PER_TINYCENT
, thus avoid precision loss.TOKEN_INFO
, which results a change from100
fixed gas units to2607
gas units, at the current configuration, representing$0.0001
canonical price.After those improvements, we will also see changes in gas. However, they are not as big as the possible fluctuations, which also result in breaking the narrative that gas measures just computational effort.
The actual differences that will happen are documented in the issue itself - here
Related issue(s):
Fixes #10828
#6993
Notes for reviewer:
All of those changes are guarded behind a feature flags.
There is an open issue #15098 which is tracking the task for removing the deprecated logic and
isGasPrecisionLossFixEnabled
&isCanonicalViewGasEnabled
.Checklist