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

Oracle development #287

Merged
merged 4 commits into from
Apr 21, 2021
Merged

Oracle development #287

merged 4 commits into from
Apr 21, 2021

Conversation

ShengguangXiao
Copy link
Contributor

@ShengguangXiao ShengguangXiao commented Mar 16, 2021

@ShengguangXiao ShengguangXiao requested a review from a team as a code owner March 16, 2021 03:39
@defichain-bot
Copy link
Member

@ShengguangXiao: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind fix
  • /kind chore
  • /kind docs
  • /kind refactor
  • /kind dependencies
Details

I am a bot created to help the DeFiCh developers manage community feedback and contributions. You can check out my manifest file 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 repository.

src/masternodes/mn_checks.cpp Outdated Show resolved Hide resolved
src/masternodes/mn_checks.cpp Outdated Show resolved Hide resolved
src/masternodes/mn_checks.cpp Outdated Show resolved Hide resolved
src/masternodes/mn_checks.cpp Outdated Show resolved Hide resolved
src/masternodes/mn_checks.cpp Outdated Show resolved Hide resolved
src/masternodes/mn_checks.h Outdated Show resolved Hide resolved
src/masternodes/mn_checks.h Outdated Show resolved Hide resolved
src/masternodes/oracles.cpp Outdated Show resolved Hide resolved
src/masternodes/rpc_oracles.cpp Outdated Show resolved Hide resolved
src/masternodes/rpc_oracles.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@bvbfan bvbfan left a comment

Choose a reason for hiding this comment

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

Overall is OK, rpc info is still missing, @ShengguangXiao did you tried as functinoallity?
Lint should be addressed as well.

src/masternodes/mn_checks.cpp Outdated Show resolved Hide resolved
src/masternodes/mn_checks.cpp Outdated Show resolved Hide resolved
@ShengguangXiao
Copy link
Contributor Author

Overall is OK, rpc info is still missing, @ShengguangXiao did you tried as functinoallity?
Lint should be addressed as well.

Yes, i tried functionality, it works good.

@bvbfan
Copy link
Contributor

bvbfan commented Mar 24, 2021

@monstrobishi it looks good, except getcustomtx lacks support of oracle txs.

@ShengguangXiao ShengguangXiao requested a review from a team March 24, 2021 14:15
@ShengguangXiao
Copy link
Contributor Author

@monstrobishi it looks good, except getcustomtx lacks support of oracle txs.

I already handle it. But the hardfork height should set to some height definition start with E?

@bvbfan
Copy link
Contributor

bvbfan commented Mar 24, 2021

@ShengguangXiao note that rpcInfo does nothing in these functions.

@ShengguangXiao
Copy link
Contributor Author

ShengguangXiao commented Mar 27, 2021

@bvbfan @monstrobishi @uzyn I have tested this PR, it works good. Only need to change the hard fork height definition.

@bvbfan
Copy link
Contributor

bvbfan commented Mar 31, 2021

@surangap you should add new hardfork check in few more places, take a look in old hardfork commits, then you should adjust the tests.

@bvbfan bvbfan force-pushed the oracles-actual-branch-1 branch from a7662e9 to 17b994b Compare April 6, 2021 13:39
@monstrobishi monstrobishi changed the base branch from master to 1.7.x April 14, 2021 04:33
@bvbfan bvbfan force-pushed the oracles-actual-branch-1 branch 3 times, most recently from 977afcc to 20e6d6b Compare April 20, 2021 13:36
@bvbfan bvbfan force-pushed the oracles-actual-branch-1 branch from 20e6d6b to fb5cb69 Compare April 20, 2021 13:45
const int64_t quotient = n_abs / COIN;
const int64_t remainder = n_abs % COIN;
return strprintf("%s%d.%08d@%d", sign ? "-" : "", quotient, remainder, nTokenId.v);
return strprintf("%s@%d", GetDecimaleString(nValue), nTokenId.v);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you elaborate on this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate code in GetDecimaleString

return static_cast<CustomTxType>(ch);
else
return CustomTxType::None;
inline CustomTxType CustomTxCodeToType(uint8_t ch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

will need to keep in mind this refactoring for the other PRs

Copy link
Contributor

Choose a reason for hiding this comment

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

@bvbfan do you suggest we keep this change or revert to how it was before?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should add ohty in txtypes say CRTMNnpuslrUbBaGAohty so refactor is better, i think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think so too, it's cleaner, ok approving this

@DeFiCh DeFiCh deleted a comment from bvbfan Apr 21, 2021
@monstrobishi monstrobishi merged commit 001c378 into 1.7.x Apr 21, 2021
@monstrobishi monstrobishi deleted the oracles-actual-branch-1 branch April 21, 2021 07:39
monstrobishi added a commit that referenced this pull request May 24, 2021
* Randomise winning anchor on blockhash (#314)

* Randomise winning anchor on blockhash

* Remove unused function argument

* Lazy rewards redistribution (#279)

* Split custom tx processing into parsing and applying

Signed-off-by: Anthony Fieroni <[email protected]>

* Prevent copies in serialize

Signed-off-by: Anthony Fieroni <[email protected]>

* Adopt pool tables to have historical records
Per account rewards calculation

Signed-off-by: Anthony Fieroni <[email protected]>

* Do not redistribute rewards per block

Signed-off-by: Anthony Fieroni <[email protected]>

* Fix lint circular dependency

Signed-off-by: Anthony Fieroni <[email protected]>

* Introduce db version check at runtime

Signed-off-by: Anthony Fieroni <[email protected]>

* Use bidirectional storage iterators

Signed-off-by: Anthony Fieroni <[email protected]>

* Fix pool id serialization in update poolpair tx

Signed-off-by: Anthony Fieroni <[email protected]>

* Update rewards on every block as drop-in replacement

Signed-off-by: Anthony Fieroni <[email protected]>

* Split pool historical records

* Added EunosHeight

* Fork out rewards redistribution per block

Signed-off-by: Anthony Fieroni <[email protected]>

* Extend pool swap functional test to Eunos hieght

Signed-off-by: Anthony Fieroni <[email protected]>

* Minimize undo data size

Signed-off-by: Anthony Fieroni <[email protected]>

* Prune undo data prior last checkpoint

Signed-off-by: Anthony Fieroni <[email protected]>

* Prevent database fragmentation

Signed-off-by: Anthony Fieroni <[email protected]>

* Make account history own database (#323)

Signed-off-by: Anthony Fieroni <[email protected]>

Co-authored-by: surangap <[email protected]>
Co-authored-by: Ahmed Hilali <[email protected]>

* Split pool reward records (#332)

Signed-off-by: Anthony Fieroni <[email protected]>

* DFIP8 New emissions (#328)

* New emissions

* Use subsidy map

* Assign swap, futures and options to unallocated

* Show non-UTXO rewards in getblock

* Oracle development (#287)

* Oracle development

Signed-off-by: Anthony Fieroni <[email protected]>

* Fix rpc parameter not converted in defi-cli (#319)

* Update rpc_oracles.cpp

Fixed rpc documentation

* Updated devnet heights

Co-authored-by: Anthony Fieroni <[email protected]>
Co-authored-by: Ahmed Hilali <[email protected]>

* Fix compile error (#341)

* Fix build issue on GCC5

Signed-off-by: Anthony Fieroni <[email protected]>

* Fix unit test fail

* Updated branch matching for dev builds

* Updated dev build branch matching

* Feature/decodecustomtx (#340)

* Added GetBlockHash() function to retrieve the block hash given the transaction hash

* Added new RPC decodecustomtx

* Added tests for decodecustomtx RPC

* Added iswitness parameter to vRPCConvertParams in client.cpp

* Updated decodecustomtx RPC as per new requirements

* Updated decodecustomtx to use INT_MAX as default block height. Updated testing.

* Removed redundant code

* Added GetBlockHash() function to retrieve the block hash given the transaction hash

* Added new RPC decodecustomtx

* Added tests for decodecustomtx RPC

* Added iswitness parameter to vRPCConvertParams in client.cpp

* Updated decodecustomtx RPC as per new requirements

* Updated decodecustomtx to use INT_MAX as default block height. Updated testing.

* Removed redundant code

Co-authored-by: monstrobishi <[email protected]>

* Extend block merkle root by hash of account changes (#337)

Signed-off-by: Anthony Fieroni <[email protected]>

Co-authored-by: monstrobishi <[email protected]>

* spv_getfeerate. SPV wallet fee filter for HTLC. SPV reset on reindex. (#356)

* Added header functions back in to fix compile

* Refactor: RPC oracles take array instead of string (#367)

Signed-off-by: Anthony Fieroni <[email protected]>

* Track UTXO and tokens sent to burn address (#354)

* Track TX and non-TX burns. Zero foundation balances.

* Remove Qt from depends

* Remove unused variables (#372)

* lint: remove unused json (#373)

* Change difficulty adjust period (#378)

* Remove unused GUI support code (#379)

* Use block height when getting last block time for coin-age (#380)

* Added listaccounts RPC pagination test (#376)

* Added listaccounts RPC pagination test
Optimized Account iteration

* Better handle pagination in listaccounts

Signed-off-by: Anthony Fieroni <[email protected]>

Co-authored-by: Anthony Fieroni <[email protected]>

* Fix linter error

* Added hardfork heights

* Add creation fee for devnet (#388)

* Masternode creation requires authorization (#386)

Signed-off-by: Anthony Fieroni <[email protected]>

* Remove backwards compatible anchor code (#383)

* Change daily LP rewards automatically on subsidy reduction (#390)

* Minor lint fixes for 1.7.x (#392)

* Minor lint fix. Set Ubuntu 18.04 as minimum for tests and builds. (#393)

* lint: remove "dead" code

* Run lint on 1.x PRs. Ubuntu 18.04 minimum for tests and builds.

* Fix listaccount pagination after start one (#394)

Signed-off-by: Anthony Fieroni <[email protected]>

* ICX Orderbook (#335)

* Initial ICX orderbook development

* Inital development of ICX Orderbook

* Fixes and changes.

* Remove prints and small fix.

* Fix seed to hash calculation

* Optimize data structures.

* Fix searching HTLCs.

* Refactor data structures and flow, fixed PR issues

* Refactor data structures and flow, fixed PR issues

* Fix issues.

* Added incentives and fees. Fixed issue with CAmount multiply overflow. Fix tests and clean code. (#5)

* Add incentives and fees. Fix multiply overflow.

* Fix lint rpc mapping check

* Add poolpair id to governance variable for DFI/BTC price used in takerFee, minimum timeout for 2nd HTLC, added initial unit test, various fixes and code clean.

* Fix calculation of takerFee. Clean code.

* Get poolpair id from governance variable.

* Adding expiration for minimum timeout to EXT HTLC.

* Remove locking funds on makeoffer, fixes.

* Add initial test that add creation of poolpair.

* Added takerFeePerBTC gov var, adapted timeouts for htlcs, check in rpc for correct htlc timeouts, added more checks in test.

* Added key for ext htlc closed, addapted test and rpcs.

* Fill partial offer to complete order

* Test burn. Wip burn map in ConnectBlock. Tally tokens.

* ICX Set order owner on creation

* Fix regressions, reproducible crashes
Polish

Fixes: #374

Signed-off-by: Anthony Fieroni <[email protected]>

* Remove chain data from DB, refactor address storing only in order/offer, fix auth, polish and clean code.

* Add warning disclaimer

* Add creation fee for devnet

* Fixed HTLC timout check, refund partial takerFee on partial offer accept, added test case for BTC/DFI flow, added error test cases, polished code.

* Fixed expiration of offer and htlcs,  added check for open offer on submit htlc, added more test cases.

* Fix order expiration refund, add checkin rpc for htlc if order expires first, fixed and added tests.

* Fix findng poolpair and calculating DFI per BTC, adapted test,  rpc fix.

* Remove unnecessary check in GetBTCDFIPoolPair(), make BTC isDAT in error tests, change BTC blocks in DFI to 20.

* Masternode creation requires authorization (#386)

Signed-off-by: Anthony Fieroni <[email protected]>

* Polish correct offer prices in blockchain layer

Signed-off-by: Anthony Fieroni <[email protected]>

* Moving more checks from RPC to mn_checks, cleanup code

* Small fixes.

* Follow getburninfo at all steps. Set correct amounts.

* Fix lint

* Fix lint

* Fix typo.

Co-authored-by: Peter Bushnell <[email protected]>
Co-authored-by: monstrobishi <[email protected]>
Co-authored-by: Anthony Fieroni <[email protected]>

* Updated Eunos upgrade heights for mainnet and testnet (#391)

* Update chainparams.cpp (#396)

* Ignore but log merkle failures (#403)

* Start burn search from default CScript (#401)

* Skip old coinbase block post Eunos (#400)

* Close expired orders simplifications

Signed-off-by: Anthony Fieroni <[email protected]>

* Skip higher coinbase spent block post Eunos

Signed-off-by: Anthony Fieroni <[email protected]>

* Updated code to return correct lastblockcreationattempt in getmininginfo RPC (#399)

* Fixed operator ==

* Update chainparams.cpp

* Add account destruction address on testnet (#404)

* Skip merkle root check on startup (#405)

* Fix/prevent reverts (#408)

* Prevent chain revert past Eunos

Signed-off-by: Anthony Fieroni <[email protected]>

* Add consesus code to reject custom tx

Signed-off-by: Anthony Fieroni <[email protected]>

* Fix oracles rpc cli paramters (#409)

* Fix oracles rpc cli paramters

Signed-off-by: Anthony Fieroni <[email protected]>

* Update oracle input parameter validation

Signed-off-by: Anthony Fieroni <[email protected]>

* Fix masternode hash generation by adding time to custom tx (#410)

Signed-off-by: Anthony Fieroni <[email protected]>

* Set new testnet fork height. Revert merkle root checks. (#411)

* Prevent rewards calculation to shown in account history (#412)

Signed-off-by: Anthony Fieroni <[email protected]>

* Add checkpoint to testnet (#414)

* Reduce new fork height to two hours ahead (#415)

* Fix calculating owner rewards and returning takerFee on close offer. (#416)

* Increase masternode registration and resign delay (#419)

* SPV add call, fix Windows connection issue and set Eunos height. (#424)

* SPV getpeers

* SPV: Use non-blocking on Windows

* Set Eunos height on mainnet

* Use C String in peer_log to build on macOS

* Client-name capitalization fix (#425)

* Using ubuntu 18.04 to build for linux (#422)

* Increment PROTOCOL_VERSION (#426)

Co-authored-by: Peter John Bushnell <[email protected]>
Co-authored-by: Anthony Fieroni <[email protected]>
Co-authored-by: surangap <[email protected]>
Co-authored-by: Xiao Shengguang <[email protected]>
Co-authored-by: Mihailo Milenkovic <[email protected]>
Co-authored-by: U-Zyn Chua <[email protected]>
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.

4 participants