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

Reduce returned balance precision in accounting.Balance #127

Merged
merged 3 commits into from
Oct 29, 2020

Conversation

alexvanin
Copy link
Contributor

Closes #122

Before patch with Fixed16 precision in balance smart contract:

  1. Deposit 900 GAS
  2. Deposit 900 GAS
  3. neofs-cli -c config.yml accounting balance: -44.6744073709551586

After patch:

  1. Deposit 900 GAS
  2. Deposit 900 GAS
  3. neofs-cli -c config.yml accounting balance: 1800.00000000

@codecov
Copy link

codecov bot commented Oct 28, 2020

Codecov Report

Merging #127 into master will increase coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #127      +/-   ##
==========================================
+ Coverage   44.50%   44.64%   +0.13%     
==========================================
  Files          53       53              
  Lines        2548     2549       +1     
==========================================
+ Hits         1134     1138       +4     
+ Misses       1293     1291       -2     
+ Partials      121      120       -1     
Impacted Files Coverage Δ
pkg/morph/client/util.go 70.00% <100.00%> (+0.30%) ⬆️
pkg/network/muxer/muxer.go 98.96% <0.00%> (+3.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 330c4b4...e0b7b7d. Read the comment docs.

func BigIntFromStackItem(param stackitem.Item) (*big.Int, error) {
switch param.Type() {
case stackitem.IntegerT, stackitem.ByteArrayT:
i, err := param.TryInteger()
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we can do just

func BigIntFromStackItem(param stackitem.Item) (*big.Int, error) {
  return param.TryInteger()
}

This is at odds with the approach used in other functions, so it can be done separately in a complex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like a good option! Thank you, fixed.

Neo-go can return big.Int values on stack after contract execution.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
Fixed8 won't overflow int64 for values less than 92 billion
that is suitable for GAS.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
@alexvanin alexvanin merged commit d08c1c7 into nspcc-dev:master Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working neofs-storage Storage node application issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fit Fixed16 balance from sidechain in decimal response
2 participants