Skip to content

Commit

Permalink
Main PR for Eunos: 1.7.x (#336)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
7 people authored May 24, 2021
1 parent 456f2e0 commit 060a469
Show file tree
Hide file tree
Showing 138 changed files with 12,031 additions and 3,701 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,6 @@ dist/

# spv
!src/spv/Makefile

# VSCode extension LocalHistory
.history
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ AX_BOOST_CHRONO
dnl Boost 1.56 through 1.62 allow using std::atomic instead of its own atomic
dnl counter implementations. In 1.63 and later the std::atomic approach is default.
m4_pattern_allow(DBOOST_AC_USE_STD_ATOMIC) dnl otherwise it's treated like a macro
BOOST_CPPFLAGS="-DBOOST_SP_USE_STD_ATOMIC -DBOOST_AC_USE_STD_ATOMIC $BOOST_CPPFLAGS"
BOOST_CPPFLAGS="-DBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS -DBOOST_MPL_LIMIT_LIST_SIZE=50 -DBOOST_SP_USE_STD_ATOMIC -DBOOST_AC_USE_STD_ATOMIC $BOOST_CPPFLAGS"

if test x$use_reduce_exports = xyes; then
AC_MSG_CHECKING([for working boost reduced exports])
Expand Down
2 changes: 1 addition & 1 deletion contrib/dockerfiles/arm-linux-gnueabihf.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LABEL org.defichain.arch=${TARGET}

RUN apt update && apt dist-upgrade -y

# Setup Defichain build dependencies. Refer to depends/README.md and doc/build-unix.md
# Setup DeFiChain build dependencies. Refer to depends/README.md and doc/build-unix.md
# from the source root for info on the builder setup

RUN apt install -y software-properties-common build-essential libtool autotools-dev automake \
Expand Down
2 changes: 1 addition & 1 deletion contrib/dockerfiles/x86_64-apple-darwin11.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LABEL org.defichain.arch=${TARGET}

RUN apt update && apt dist-upgrade -y

# Setup Defichain build dependencies. Refer to depends/README.md and doc/build-unix.md
# Setup DeFiChain build dependencies. Refer to depends/README.md and doc/build-unix.md
# from the source root for info on the builder setup

RUN apt install -y software-properties-common build-essential libtool autotools-dev automake \
Expand Down
6 changes: 3 additions & 3 deletions contrib/dockerfiles/x86_64-pc-linux-gnu.dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
ARG TARGET=x86_64-pc-linux-gnu

# -----------
FROM ubuntu:16.04 as builder-base
FROM ubuntu:18.04 as builder-base
ARG TARGET
LABEL org.defichain.name="defichain-builder-base"
LABEL org.defichain.arch=${TARGET}

RUN apt update && apt dist-upgrade -y

# Setup Defichain build dependencies. Refer to depends/README.md and doc/build-unix.md
# Setup DeFiChain build dependencies. Refer to depends/README.md and doc/build-unix.md
# from the source root for info on the builder setup

RUN apt-get install -y apt-transport-https
Expand Down Expand Up @@ -56,7 +56,7 @@ RUN mkdir /app && make prefix=/ DESTDIR=/app install && cp /work/README.md /app/

# -----------
### Actual image that contains defi binaries
FROM ubuntu:16.04
FROM ubuntu:18.04
ARG TARGET
LABEL org.defichain.name="defichain"
LABEL org.defichain.arch=${TARGET}
Expand Down
2 changes: 1 addition & 1 deletion contrib/dockerfiles/x86_64-w64-mingw32.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LABEL org.defichain.arch=${TARGET}

RUN apt update && apt dist-upgrade -y

# Setup Defichain build dependencies. Refer to depends/README.md and doc/build-unix.md
# Setup DeFiChain build dependencies. Refer to depends/README.md and doc/build-unix.md
# from the source root for info on the builder setup

RUN apt install -y software-properties-common build-essential libtool autotools-dev automake \
Expand Down
5 changes: 5 additions & 0 deletions contrib/testgen/gen_burn_addr.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def print_usage():
print('python3 ' + sys.argv[0] + ' AddressStartString')
print('Mainnet address start with string from 8F ~ 8d')
print('Testnet address start with string from 73 ~ 7R')
print('Regtest address start with string from mf ~ n4')
print('The address start string cannot contain these characters: 0OIl')
print('For example:')
print(' python3 gen_burn_addr.py 8addressForBurn')
Expand All @@ -131,6 +132,9 @@ def check_start_range(fst2):
if fst2 >= '8F' and fst2 <= '8d':
return True

if fst2 >= 'mf' and fst2 <= 'n4':
return True

return False

if __name__ == '__main__':
Expand Down Expand Up @@ -170,6 +174,7 @@ def check_start_range(fst2):
print('Address start is not correct!')
print('Mainnet address start with string from 8F ~ 8d')
print('Testnet address start with string from 73 ~ 7R')
print('Regtest address start with string from mf ~ n4')
sys.exit(0)

anotherString = startString + "X" * (34 - len(startString))
Expand Down
2 changes: 1 addition & 1 deletion doc/setup-masternodes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# How to run a Defichain masternode
# How to run a DeFiChain masternode

## Introduction

Expand Down
16 changes: 11 additions & 5 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ DEFI_CORE_H = \
init.h \
interfaces/chain.h \
interfaces/handler.h \
interfaces/node.h \
key.h \
key_io.h \
dbwrapper.h \
Expand All @@ -158,19 +157,21 @@ DEFI_CORE_H = \
masternodes/communityaccounttypes.h \
masternodes/criminals.h \
masternodes/factory.h \
masternodes/govvariables/icx_takerfee_per_btc.h \
masternodes/govvariables/lp_daily_dfi_reward.h \
masternodes/govvariables/lp_splits.h \
masternodes/gv.h \
masternodes/icxorder.h \
masternodes/incentivefunding.h \
masternodes/masternodes.h \
masternodes/mn_checks.h \
masternodes/mn_rpc.h \
masternodes/res.h \
masternodes/rewardhistoryold.h \
masternodes/tokens.h \
masternodes/poolpairs.h \
masternodes/undo.h \
masternodes/undos.h \
masternodes/oracles.h \
memusage.h \
merkleblock.h \
miner.h \
Expand Down Expand Up @@ -360,24 +361,29 @@ libdefi_server_a_SOURCES = \
index/blockfilterindex.cpp \
index/txindex.cpp \
interfaces/chain.cpp \
interfaces/node.cpp \
init.cpp \
dbwrapper.cpp \
masternodes/accounts.cpp \
masternodes/accountshistory.cpp \
masternodes/anchors.cpp \
masternodes/criminals.cpp \
masternodes/oracles.cpp \
masternodes/govvariables/icx_takerfee_per_btc.cpp \
masternodes/govvariables/lp_daily_dfi_reward.cpp \
masternodes/govvariables/lp_splits.cpp \
masternodes/gv.cpp \
masternodes/icxorder.cpp \
masternodes/incentivefunding.cpp \
masternodes/masternodes.cpp \
masternodes/mn_checks.cpp \
masternodes/mn_rpc.cpp \
masternodes/rpc_masternodes.cpp \
masternodes/rpc_accounts.cpp \
masternodes/rpc_tokens.cpp \
masternodes/rpc_customtx.cpp \
masternodes/rpc_masternodes.cpp \
masternodes/rpc_icxorderbook.cpp \
masternodes/rpc_oracles.cpp \
masternodes/rpc_poolpair.cpp \
masternodes/rpc_tokens.cpp \
masternodes/tokens.cpp \
masternodes/poolpairs.cpp \
masternodes/undos.cpp \
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ DEFI_TESTS =\
test/multisig_tests.cpp \
test/net_tests.cpp \
test/netbase_tests.cpp \
test/mn_blocktime_tests.cpp \
test/oracles_tests.cpp \
test/pmt_tests.cpp \
test/policyestimator_tests.cpp \
test/pow_tests.cpp \
Expand Down
12 changes: 4 additions & 8 deletions src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct DCT_ID {

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(v);
READWRITE(VARINT(v));
}
};

Expand Down Expand Up @@ -110,11 +110,7 @@ struct CTokenAmount { // simple std::pair is less informative
CAmount nValue;

std::string ToString() const {
const bool sign = nValue < 0;
const int64_t n_abs = (sign ? -nValue : nValue);
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);
}

Res Add(CAmount amount) {
Expand All @@ -125,7 +121,7 @@ struct CTokenAmount { // simple std::pair is less informative
// add
auto sumRes = SafeAdd(this->nValue, amount);
if (!sumRes.ok) {
return sumRes.res();
return std::move(sumRes);
}
this->nValue = *sumRes.val;
return Res::Ok();
Expand Down Expand Up @@ -162,7 +158,7 @@ struct CTokenAmount { // simple std::pair is less informative

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(VARINT(nTokenId.v));
READWRITE(nTokenId);
READWRITE(nValue);
}

Expand Down
2 changes: 1 addition & 1 deletion src/bench/duplicate_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void DuplicateInputs(benchmark::State& state)
LOCK(cs_main);
CBlockIndex* pindexPrev = ::ChainActive().Tip();
assert(pindexPrev != nullptr);
block.nBits = pos::GetNextWorkRequired(pindexPrev, &block, chainparams.GetConsensus().pos);
block.nBits = pos::GetNextWorkRequired(pindexPrev, &block, chainparams.GetConsensus());
// block.nNonce = 0;
auto nHeight = pindexPrev->nHeight + 1;

Expand Down
Loading

0 comments on commit 060a469

Please sign in to comment.