Skip to content
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

Merged
merged 2 commits into from
Jan 11, 2023
Merged

Fix applog values #2865

merged 2 commits into from
Jan 11, 2023

Conversation

roman-khimov
Copy link
Member

This fixes #2864, but unfortunately it requires DB resynchronization. But if we're resynchronizing anyway, then we can make some additional adjustments as well.

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.
@codecov
Copy link

codecov bot commented Jan 10, 2023

Codecov Report

Merging #2865 (584675e) into master (5ad1fcd) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            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     
Impacted Files Coverage Δ
pkg/core/blockchain.go 78.61% <100.00%> (+0.03%) ⬆️
pkg/core/state/tokens.go 82.35% <100.00%> (-0.30%) ⬇️
pkg/encoding/bigint/bigint.go 97.89% <100.00%> (+0.39%) ⬆️
pkg/services/rpcsrv/server.go 77.24% <100.00%> (-0.03%) ⬇️
pkg/network/payload/mptdata.go 81.25% <0.00%> (-18.75%) ⬇️
pkg/network/message.go 94.02% <0.00%> (-3.74%) ⬇️
pkg/core/transaction/transaction.go 85.18% <0.00%> (-1.49%) ⬇️
pkg/services/oracle/request.go 63.18% <0.00%> (+5.00%) ⬆️
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱

@ixje
Copy link
Contributor

ixje commented Jan 11, 2023

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.

@ixje
Copy link
Contributor

ixje commented Jan 11, 2023

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

@roman-khimov
Copy link
Member Author

roman-khimov commented Jan 11, 2023

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.

@roman-khimov roman-khimov merged commit e037249 into master Jan 11, 2023
@roman-khimov roman-khimov deleted the fix-applog-values branch January 11, 2023 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

transfer value notification difference in applicationlog response
3 participants