BirthdayResearch / jellyfishsdk

DeFiChain Jellyfish SDK & Ecosystem for building modern lite DeFi Applications at scale.
https://jellyfishsdk.com
MIT License
104 stars 36 forks source link

PoolSwap `toOpCodes` failed to read #494

Closed canonbrother closed 3 years ago

canonbrother commented 3 years ago

What happened:

Too many decimals read from buffer. Will lose precision with more than 8 decimals

      554 |         const fraction = readBigNumberUInt64(buffer)
      555 |         if (fraction.gt(new BigNumber('99999999'))) {
    > 556 |           throw new Error('Too many decimals read from buffer. Will lose precision with more than 8 decimals')
          |                 ^
      557 |         }
      558 |         setter(integer.plus(fraction.dividedBy(ONE_HUNDRED_MILLION)))
      559 |       },

What you expected to happen:

Previously code is working, guessing the issue was caused by recent update #469

How to reproduce it (as minimally and precisely as possible):

https://mainnet.defichain.io/#/DFI/mainnet/tx/700473ec7ca4f6bec261e75342f91825f3c2cf60df1bf1f335b53a2bcd95b994 6a4c4f446654787317a9140806eb42b6d5bb69726909fb6da34a9152afdf048701c7b3240d0000000017a9140806eb42b6d5bb69726909fb6da34a9152afdf048700ffffffffffffff7fffffffffffffff7f

Anything else we need to know?:

defichain-bot commented 3 years ago

@canonbrother: Thanks for opening an issue, it is currently awaiting triage.

The triage/accepted label can be added by foundation members by writing /triage accepted in a comment.

Details I am a bot created to help the [DeFiCh](https://github.com/DeFiCh) developers manage community feedback and contributions. You can check out my [manifest file](https://github.com/DeFiCh/jellyfish/blob/main/.github/governance.yml) to understand my behavior and what I can do. If you want to use this for your project, you can check out the [DeFiCh/oss-governance-bot](https://github.com/DeFiCh/oss-governance-bot) repository.
defichain-bot commented 3 years ago

@canonbrother: There are no 'area' labels on this issue. Adding an appropriate label will greatly expedite the process for us. You can add as many area as you see fit. If you are unsure what to do you can ignore this!

You can add area labels by leaving a /area comment.

Details I am a bot created to help the [DeFiCh](https://github.com/DeFiCh) developers manage community feedback and contributions. You can check out my [manifest file](https://github.com/DeFiCh/jellyfish/blob/main/.github/governance.yml) to understand my behavior and what I can do. If you want to use this for your project, you can check out the [DeFiCh/oss-governance-bot](https://github.com/DeFiCh/oss-governance-bot) repository.
fuxingloh commented 3 years ago

https://github.com/DeFiCh/jellyfish/pull/457#discussion_r669266324

Damn it, I never thought about this. Looks like we need to handle it. Is ffffffffffffff7fffffffffffffff7f the only anomaly allowed? e.g. is ffffffffffffff7fffffffffffffff7e allowed?

If it's just ffffffffffffff7fffffffffffffff7f we can just handle that special constant

/triage accepted /priority urgent-now /assign @canonbrother

canonbrother commented 3 years ago

#457 (comment)

Damn it, I never thought about this. Looks like we need to handle it. Is ffffffffffffff7fffffffffffffff7f the only anomaly allowed? e.g. is ffffffffffffff7fffffffffffffff7e allowed?

If it's just ffffffffffffff7fffffffffffffff7f we can just handle that special constant

/triage accepted /priority urgent-now /assign @canonbrother

 is ffffffffffffff7fffffffffffffff7e allowed?

should not allow (we have maximum 99999999 checker on fraction) and should not be possible too

its caused by null maxPrice, just need to add a special handling for its default max int64 value will do https://github.com/DeFiCh/ain/blob/aed00d09075094a3a0cedebde5248c006216ba09/src/masternodes/rpc_poolpair.cpp#L115-L123