hiero-ledger / hiero-ledger/hiero-consensus-node
Cost-Answer-Query cost differs from query by 1 tinybar
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
### Description
I received a report from a user that sometimes (< 1% of the time) when running queries, they get a cost-answer-query for one amount, but when they perform the query, it costs 1 tinybar more. It could be that this happens due to changes in the exchange rate, although it seems unlikely that an exchange rate change would have an impact of only 1 tinybar, but maybe that is it (since in this case the delta is from 23 to 24 hbars, and that difference only constitutes a 4% change, it is conceivable. It may also be a rounding bug in the code. This test was executed against testnet.
### Steps to reproduce
Hard to verify without performance testing. See if this can be verified on a performance network.
### Additional context
``` 10/2/2023 9:00:19 PM RX:(04) { "transactionGetReceipt": { "header": { }, "receipt": { "status": "MODIFYING_IMMUTABLE_CONTRACT", "exchangeRate": { "currentRate": { "hbarEquiv": 30000, "centEquiv": 148698, "expirationTime": { "seconds": "1696280400" } }, "nextRate": { "hbarEquiv": 30000, "centEquiv": 150287, "expirationTime": { "seconds": "1696284000" } } } } } }
10/2/2023 9:00:19 PM QX ASK → { "contractGetInfo": { "header": { "payment": { }, "responseType": "COST_ANSWER" }, "contractID": { "contractNum": "3725323" } } }
10/2/2023 9:00:19 PM RX:(00) { "contractGetInfo": { "header": { "responseType": "COST_ANSWER", "cost": "23" } } }
10/2/2023 9:00:19 PM QX PYMT { "transactionID": { "transactionValidStart": { "seconds": "1696280357", "nanos": 186344800 }, "accountID": { "accountNum": "1031" } }, "nodeAccountID": { "accountNum": "6" }, "transactionFee": "6000000000", "transactionValidDuration": { "seconds": "120" }, "cryptoTransfer": { "transfers": { "accountAmounts": [ { "accountID": { "accountNum": "1031" }, "amount": "-23" }, { "accountID": { "accountNum": "6" }, "amount": "23" } ] } } }
10/2/2023 9:00:19 PM ├─ SIG → { "sigPair": [ { "ed25519": "BrGVgZ1PahwU/Dq125OFlEJU/oir8u2jefFNhbDkUgcetJRr9YKhEc5UOiRbrUQFixwywbnZMoY1P4iEHLE6Bw==" } ] }
10/2/2023 9:00:19 PM └─ QRY → { "contractGetInfo": { "header": { "payment": { "signedTransactionBytes": "CjcKEgoLCKXe7KgGEODK7VgSAxiHCBICGAYYgPiCrRYiAgh4chMKEQoHCgMYhwgQLQoGCgIYBhAuEkQKQhpABrGVgZ1PahwU/Dq125OFlEJU/oir8u2jefFNhbDkUgcetJRr9YKhEc5UOiRbrUQFixwywbnZMoY1P4iEHLE6Bw==" } }, "contractID": { "contractNum": "3725323" } } }
10/2/2023 9:00:19 PM RX:(00) { "contractGetInfo": { "header": { "nodeTransactionPrecheckCode": "INSUFFICIENT_TX_FEE", "cost": "24" } } }
```
### Hedera network
testnet
### Version
v0.41
### Operating system
None
Contributor guide
Research direction
Start with the contractGetInfo COST_ANSWER and the subsequent transaction precheck shown in the report, then reproduce the discrepancy on a performance network or testnet around an exchange-rate transition. Trace how the estimated cost of 23 and the rejected transaction cost of 24 are calculated; done means identifying the rounding or rate cause and ensuring the estimate matches the charged fee, with regression coverage if the relevant tests are found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100