vm: properly manage gasConsumed overflow - #4306
Conversation
|
@roman-khimov, it's my best attempt if we don't want to convert |
afe316c to
832a543
Compare
|
|
| return v.AddPicoGas(gas * ExecFeeFactorMultiplier) | ||
| picoGas := gas * ExecFeeFactorMultiplier | ||
| if picoGas < 0 { // пу-пу-пу... | ||
| // To match C# behaviour, we still need to add this GAS to vm.gasConsumed (C# VM use *big.Int for gasConsumed calculations). |
There was a problem hiding this comment.
Try uint256.Int with benchmarks we have, maybe it's OK to use it here.
6c259a9 to
f908ec3
Compare
AnnaShaleva
left a comment
There was a problem hiding this comment.
@roman-khimov Which exactly benchmarks do you want to check? Also, I'm afraid this change may affect the coefficients of #4087.
| gasConsumed *uint256.Int | ||
| // gasLimit is the maximum amount of gas that can be consumed by the | ||
| // execution in picoGAS units. | ||
| gasLimit int64 |
There was a problem hiding this comment.
@roman-khimov C# node uses bigint got gasLimit as far. I think we're OK with gasLimit being int64. Neither RPC nor real tx fees won't let gas limit become larger than maxInt64 / ExecFeeFactorMultiplier (or even maxInt64 / ExecFeeFactorMultiplier / 1000 after #4043).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4306 +/- ##
==========================================
- Coverage 83.51% 83.49% -0.03%
==========================================
Files 359 359
Lines 44210 44228 +18
==========================================
+ Hits 36921 36926 +5
- Misses 5472 5478 +6
- Partials 1817 1824 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Anything running some scripts (BenchScript*), I don't expect anything noticeable here. |
roman-khimov
left a comment
There was a problem hiding this comment.
Looks much cleaner, if there are no regressions performance-wise I'd prefer this.
`request` arguments unwrapping should happen before method processing: https://github.com/neo-project/neo/blob/a09eeaecc458d3a604e2f586cc02047996bedfe5/src/Neo/SmartContract/Native/OracleContract.cs#L222 Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
No functional changes. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Avoid possible int64 overflows, ref. #4299. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Close #4299. Comparing to master: ``` goos: linux goarch: amd64 pkg: github.com/nspcc-dev/neo-go/pkg/vm cpu: AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ ScriptFibonacci-16 214.0µ ± 1% 206.6µ ± 1% -3.45% (n=100) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ ScriptFibonacci-16 114.0Ki ± 0% 114.0Ki ± 0% ~ (p=1.000 n=100) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ ScriptFibonacci-16 3.170k ± 0% 3.170k ± 0% ~ (p=1.000 n=100) ¹ ¹ all samples are equal ``` Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
f908ec3 to
a848893
Compare
|
Last commit vs master: |
Close #4299.