Skip to content

Commit

Permalink
Merge branch 'master' into bush/snapshot-on-blk
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl committed Jul 15, 2024
2 parents 9a84497 + 5370c8c commit f90c2cd
Show file tree
Hide file tree
Showing 14 changed files with 1,050 additions and 82 deletions.
10 changes: 8 additions & 2 deletions ci/sync/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ setup_vars() {
REF_LOG_PATH="${BASE_PATH}/${BUCKET}/${REF_LOG_DIR}/${REF_LOG}"

# Commands
DEFID_CMD="${DEFID_BIN} -datadir=${DATADIR} -daemon -debug=accountchange -spv -checkpoints=0 -interrupt-block=$((STOP_BLOCK + 1))"
DEFID_CMD="${DEFID_BIN} -datadir=${DATADIR} -daemon -debug=accountchange -ethdebug=1 -spv -checkpoints=0 -interrupt-block=$((STOP_BLOCK + 1))"
DEFI_CLI_CMD="${DEFI_CLI_BIN} -datadir=${DATADIR}"
FETCH="aria2c -x16 -s16"
GREP="grep"
Expand Down Expand Up @@ -71,6 +71,8 @@ print_info() {
${DEFI_CLI_CMD} listvaults '{\"verbose\": true}' '{\"limit\":1000000}'
${DEFI_CLI_CMD} listtokens '{\"limit\":1000000}'
${DEFI_CLI_CMD} getburninfo
${DEFI_CLI_CMD} listgovs
${DEFI_CLI_CMD} logevmaccountstates
- defi.conf:
$(cat "$CONF_FILE")
Expand All @@ -91,6 +93,10 @@ get_full_log() {
$DEFI_CLI_CMD listtokens '{"limit":1000000}'
echo "-- getburninfo --"
$DEFI_CLI_CMD getburninfo
echo "-- listgovs --"
$DEFI_CLI_CMD listgovs
echo "-- logevmaccountstates --"
$DEFI_CLI_CMD logevmaccountstates
}

rollback_and_log() {
Expand All @@ -105,7 +111,7 @@ rollback_and_log() {

create_pre_sync_rollback_log() {
local DATADIR_ROLLBACK="${DATADIR}-rollback"
local DEFID_CMD="${DEFID_BIN} -datadir=${DATADIR_ROLLBACK} -daemon -debug=accountchange -spv -rpcport=9999 -port=9998 -connect=0 -checkpoints=0 -interrupt-block=$((START_BLOCK + 1))"
local DEFID_CMD="${DEFID_BIN} -datadir=${DATADIR_ROLLBACK} -daemon -debug=accountchange -ethdebug=1 -spv -rpcport=9999 -port=9998 -connect=0 -checkpoints=0 -interrupt-block=$((START_BLOCK + 1))"
local DEFI_CLI_CMD="${DEFI_CLI_BIN} -datadir=${DATADIR_ROLLBACK} -rpcport=9999"
local DEBUG_FILE="${DATADIR_ROLLBACK}/debug.log"

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 4)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
Expand Down
1 change: 1 addition & 0 deletions src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static constexpr CAmount COIN = 100000000;
static constexpr CAmount CENT = 1000000;
static constexpr int64_t WEI_IN_GWEI = 1000000000;
static constexpr int64_t CAMOUNT_TO_GWEI = 10;
static constexpr CAmount HIGH_PRECISION_SCALER = COIN * COIN; // 1,0000,0000,0000,0000

//Converts the given value to decimal format string with COIN precision.
inline std::string GetDecimalString(CAmount nValue)
Expand Down
2 changes: 0 additions & 2 deletions src/dfi/loan.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ inline auto InterestAddition = [](const CInterestAmount &a, const CInterestAmoun
return interest;
};

static const CAmount HIGH_PRECISION_SCALER = COIN * COIN; // 1,0000,0000,0000,0000

CAmount TotalInterest(const CInterestRateV3 &rate, const uint32_t height);
CInterestAmount TotalInterestCalculation(const CInterestRateV3 &rate, const uint32_t height);
CAmount CeilInterest(const base_uint<128> &value, uint32_t height);
Expand Down
34 changes: 23 additions & 11 deletions src/dfi/masternodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,17 +971,29 @@ bool CCustomCSView::CalculateOwnerRewards(const CScript &owner, uint32_t targetH
return true; // no share or target height is before a pool share' one
}
auto onLiquidity = [&]() -> CAmount { return GetBalance(owner, poolId).nValue; };
auto beginHeight = std::max(*height, balanceHeight);
CalculatePoolRewards(
poolId, onLiquidity, beginHeight, targetHeight, [&](RewardType, CTokenAmount amount, uint32_t height) {
auto res = AddBalance(owner, amount);
if (!res) {
LogPrintf("Pool rewards: can't update balance of %s: %s, height %ld\n",
owner.GetHex(),
res.msg,
targetHeight);
}
});
const auto beginHeight = std::max(*height, balanceHeight);
auto onReward = [&](RewardType, const CTokenAmount &amount, const uint32_t height) {
if (auto res = AddBalance(owner, amount); !res) {
LogPrintf(
"Pool rewards: can't update balance of %s: %s, height %ld\n", owner.GetHex(), res.msg, height);
}
};

if (beginHeight < Params().GetConsensus().DF24Height) {
// Calculate just up to the fork height
const auto targetNewHeight = targetHeight >= Params().GetConsensus().DF24Height
? Params().GetConsensus().DF24Height - 1
: targetHeight;
CalculatePoolRewards(poolId, onLiquidity, beginHeight, targetNewHeight, onReward);
}

if (targetHeight >= Params().GetConsensus().DF24Height) {
// Calculate from the fork height
const auto beginNewHeight =
beginHeight < Params().GetConsensus().DF24Height ? Params().GetConsensus().DF24Height : beginHeight;
CalculateStaticPoolRewards(onLiquidity, onReward, poolId.v, beginNewHeight, targetHeight);
}

return true;
});

Expand Down
Loading

0 comments on commit f90c2cd

Please sign in to comment.