-
Notifications
You must be signed in to change notification settings - Fork 81
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 applog values #2865
Fix applog values #2865
Conversation
In some cases n.Add() can reuse the []Word buffer and n.Sub() reallocate it away. If that happens, we're out of luck with 0.99.0+ versions (since 3945e81). I'm not sure why it does that, bit width doesn't change in most of the cases and even if it does, we still have enough of it in cap() to hold the old Abs() value (when we have a negative value we in fact decreate its Abs() first and increase it back afterwards). Still, that's what we have. So when we have processTokenTransfer() doing Neg/Neg in-place its value is not affected, but the original []Word bits that are reused by amount value are (they're shared initially, Amount: *amount). name old time/op new time/op delta ToPreallocatedBytes-8 65.8ns ± 2% 45.6ns ± 2% -30.73% (p=0.008 n=5+5) name old alloc/op new alloc/op delta ToPreallocatedBytes-8 0.00B 0.00B ~ (all equal) name old allocs/op new allocs/op delta ToPreallocatedBytes-8 0.00 0.00 ~ (all equal)
We have both from and to here, so technically we can either drop the neg/neg trick from the processTokenTransfer() or drop one field from the structure (the other side is a part of the key). Drop the field since this can make the DB a bit more compact. Change Amount to be a pointer along the way since that's the "native" thing for big.Int, we've used non-pointer field specifically to avoid Neg/Neg problems, but it looks like this is not necessary. This structure is only used by the RPC server and I doubt anyone uses it via the *Blockchain.
6d7e801
to
584675e
Compare
Codecov Report
@@ Coverage Diff @@
## master #2865 +/- ##
==========================================
+ Coverage 84.99% 85.05% +0.05%
==========================================
Files 329 329
Lines 42218 42228 +10
==========================================
+ Hits 35885 35915 +30
+ Misses 4875 4848 -27
- Partials 1458 1465 +7
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
😱
I can't comment on the implementation, but I can say that with this PR I no longer have issues with what I was using neo-go for. |
I have to retract my last comment. I can't yet tell where it goes wrong (my side or neo-go) but I'll investigate and let you know |
This certainly solves the issue, I've tested it with testnet dump as well, but if there are any other problems, please let us know. This fix deserves a release, so we'll be making one soon. |
This fixes #2864, but unfortunately it requires DB resynchronization. But if we're resynchronizing anyway, then we can make some additional adjustments as well.