Skip to content

Commit

Permalink
Merge pull request #18 from marmarachain/dev
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
marmarachain committed Jun 1, 2021
2 parents 7a615aa + 26a68b7 commit 6bcae3f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 64 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/komodo_mac_ci.yml
Expand Up @@ -17,26 +17,23 @@ jobs:

- name: Install deps (macOS)
run: |
softwareupdate --install -a
brew update
brew uninstall php glib gcc gcc@8 gcc@9 python@3.9 pipx
brew upgrade
brew install gcc@8 gcc
brew install boost
brew tap discoteq/discoteq; brew install flock
brew install autoconf autogen automake
brew install gcc@8
brew install binutils
brew install protobuf
brew install coreutils
pip install --upgrade pip
pip install setuptools wheel wget
brew install wget
brew install python3
brew install gmp
- name: Build (macOS)
run: |
# flag for some CC tests transactions - so DO NOT USE THIS CI ARTIFACTS IN PRODUCTION!!!
./zcutil/build-mac-dtest.sh -j$(nproc)
export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/
./zcutil/build-mac-dtest.sh -j4
tar -czvf komodo-macos.tar.gz src/komodod src/komodo-cli
- name: Upload komodo-macos.tar.gz as artifact
uses: actions/upload-artifact@v1
with:
Expand Down Expand Up @@ -83,7 +80,7 @@ jobs:

- name: Install deps (OraclesCC)
run: |
brew install curl
brew install python3 curl
python3 -m pip install setuptools wheel
python3 -m pip install slick-bitcoinrpc pytest wget jsonschema
- name: Download komodo-macos.tar.gz
Expand All @@ -99,7 +96,6 @@ jobs:
./zcutil/fetch-params.sh
cd qa/pytest_komodo
./ci_setup.sh cc_modules/test_oracles.py
macos-test-baserpc:

name: Test (macos/BasicRPC)
Expand All @@ -111,7 +107,7 @@ jobs:

- name: Install deps (BasicRPC)
run: |
brew install curl
brew install python3 curl
python3 -m pip install setuptools wheel
python3 -m pip install slick-bitcoinrpc pytest wget jsonschema
- name: Download komodo-macos.tar.gz
Expand Down
80 changes: 41 additions & 39 deletions src/cc/marmara.cpp
Expand Up @@ -5635,48 +5635,33 @@ UniValue MarmaraPoSStat(int32_t beginHeight, int32_t endHeight)
for(int32_t h = beginHeight; h <= endHeight; h ++)
{
int8_t hsegid = komodo_segid(0, h);
if (hsegid >= 0)
{
CBlockIndex *pblockindex = chainActive[h];
CBlock block;

if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) {
error.push_back(Pair("result", "error"));
error.push_back(Pair("error", std::string("Block not available (pruned data), h=") + std::to_string(h)));
return error;
}
CBlockIndex *pblockindex = chainActive[h];
CBlock block;

if (!ReadBlockFromDisk(block, pblockindex, 1)) {
error.push_back(Pair("result", "error"));
error.push_back(Pair("error", std::string("Can't read block from disk, h=") + std::to_string(h)));
return error;
}
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) {
error.push_back(Pair("result", "error"));
error.push_back(Pair("error", std::string("Block not available (pruned data), h=") + std::to_string(h)));
return error;
}

if (!ReadBlockFromDisk(block, pblockindex, 1)) {
error.push_back(Pair("result", "error"));
error.push_back(Pair("error", std::string("Can't read block from disk, h=") + std::to_string(h)));
return error;
}
if (hsegid >= 0)
{
if (block.vtx.size() >= 2)
{
CTransaction coinbase = block.vtx[0];
CTransaction stakeTx = block.vtx.back(), vintx;
uint256 hashBlock;
vscript_t vopret;

// check vin.size and vout.size, do not do this yet for diagnosis
// if (stakeTx.vin.size() == 1 && stakeTx.vout.size() == 1 || stakeTx.vout.size() == 2 && GetOpReturnData(stakeTx.vout.back().scriptPubKey, vopret) /*opret with merkle*/)
// {
//if (myGetTransaction(stakeTx.vin[0].prevout.hash, vintx, hashBlock))
//{
//char vintxaddr[KOMODO_ADDRESS_BUFSIZE];
char staketxaddr[KOMODO_ADDRESS_BUFSIZE];
//Getscriptaddress(vintxaddr, vintx.vout[0].scriptPubKey);
Getscriptaddress(staketxaddr, stakeTx.vout[0].scriptPubKey);

//if (strcmp(vintxaddr, staketxaddr) == 0)
//{

// LOGSTREAMFN("marmara", CCLOG_DEBUG1, stream << "h=" << h << " stake txid=" << stakeTx.GetHash().GetHex() << " vout.size()=" << stakeTx.vout.size() << std::endl);

//char coinbaseaddr[KOMODO_ADDRESS_BUFSIZE];
//Getscriptaddress(coinbaseaddr, coinbase.vout[0].scriptPubKey);

std::string sStakeTxAddr = staketxaddr;
std::string staketxtype;

Expand Down Expand Up @@ -5727,25 +5712,28 @@ UniValue MarmaraPoSStat(int32_t beginHeight, int32_t endHeight)
mapStat[sStakeTxAddr + staketxtype] = std::make_tuple(sStakeTxAddr, staketxtype, segid, amount, std::get<POSSTAT_TXCOUNT>(elem) + 1);

LOGSTREAMFN("marmara", CCLOG_DEBUG1, stream << "h=" << h << " stake-txid=" << stakeTx.GetHash().GetHex() << " segid=" << segid << " address=" << staketxaddr << " type=" << staketxtype << " amount=" << stakeTx.vout[0].nValue << std::endl);

//}
//}
//}
}
else
LOGSTREAMFN("marmara", CCLOG_ERROR, stream << "not a pos block" << " h=" << h << " hsegid=" << (int)hsegid<< std::endl);
}
else {
CTransaction coinbase = block.vtx[0];
char cbaddr[KOMODO_ADDRESS_BUFSIZE];
Getscriptaddress(cbaddr, coinbase.vout[0].scriptPubKey);
TStatElem elem = mapStat[std::string(cbaddr) + "pow"];

CAmount amount = std::get<POSSTAT_COINBASEAMOUNT>(elem) + coinbase.vout[0].nValue;
mapStat[std::string(cbaddr) + "pow"] = std::make_tuple(std::string(cbaddr), "pow", 0, amount, std::get<POSSTAT_TXCOUNT>(elem) + 1);
}
}

for (const auto &eStat : mapStat)
{
UniValue elem(UniValue::VOBJ);

elem.push_back(Pair("StakeTxAddress", std::get<POSSTAT_STAKETXADDR>(eStat.second)));
elem.push_back(Pair("StakeTxType", std::get<POSSTAT_STAKETXTYPE>(eStat.second)));
elem.push_back(Pair("CoinbaseAddress", std::get<POSSTAT_STAKETXADDR>(eStat.second)));
elem.push_back(Pair("BlockType", std::get<POSSTAT_STAKETXTYPE>(eStat.second)));
elem.push_back(Pair("segid", (uint64_t)std::get<POSSTAT_SEGID>(eStat.second)));
elem.push_back(Pair("CoinbaseAmount", std::get<POSSTAT_COINBASEAMOUNT>(eStat.second)));
elem.push_back(Pair("StakeTxCount", std::get<POSSTAT_TXCOUNT>(eStat.second)));
elem.push_back(Pair("TxCount", std::get<POSSTAT_TXCOUNT>(eStat.second)));
array.push_back(elem);
}

Expand Down Expand Up @@ -6179,8 +6167,22 @@ UniValue MarmaraAmountStatDiff(int32_t beginHeight, int32_t endHeight)
{
uint256 spenttxid;
int32_t spentvin, spentheight;
bool bSpent = false;
if (CCgetspenttxid(spenttxid, spentvin, spentheight, tx.GetHash(), ivout) == 0)
{
CTransaction spenttx;
uint256 hashBlock;

if (CCgetspenttxid(spenttxid, spentvin, spentheight, tx.GetHash(), ivout) != 0 || spentheight > endHeight)
if (GetTransaction(spenttxid, spenttx, hashBlock)) {
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second) {
CBlockIndex* pindex = (*mi).second;
if (chainActive.Contains(pindex))
bSpent = true;
}
}
}
if (!bSpent || spentheight > endHeight || spentheight == 0)
addTotals(tx, ivout, false);
}

Expand Down
5 changes: 2 additions & 3 deletions src/main.cpp
Expand Up @@ -2597,11 +2597,10 @@ int IsNotInSync()
}

CBlockIndex *pbi = chainActive.Tip();
int longestchain = komodo_longestchain();

if ( !pbi ||
(pindexBestHeader == 0) ||
((pindexBestHeader->GetHeight() - 1) > pbi->GetHeight()) ||
(longestchain != 0 && longestchain > pbi->GetHeight()) )
((pindexBestHeader->GetHeight() - 1) > pbi->GetHeight()) )
{
return (pbi && pindexBestHeader && (pindexBestHeader->GetHeight() - 1) > pbi->GetHeight()) ?
pindexBestHeader->GetHeight() - pbi->GetHeight() :
Expand Down
11 changes: 7 additions & 4 deletions src/rpc/mining.cpp
Expand Up @@ -705,13 +705,16 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp, const CPubKey& myp
LOCK(cs_vNodes);
fvNodesEmpty = vNodes.empty();
}
if (Params().MiningRequiresPeers() && (IsNotInSync() || fvNodesEmpty))

if (Params().MiningRequiresPeers() && fvNodesEmpty)
{
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Cannot get a block template while no peers are connected or chain not in sync!");
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!");
}

//if (IsInitialBlockDownload())
// throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");
// currently we have checkpoints only in KMD chain, so we checking IsInitialBlockDownload only for KMD itself
if (ASSETCHAINS_SYMBOL[0] == 0 && IsInitialBlockDownload()) {
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Komodo is downloading blocks...");
}

static unsigned int nTransactionsUpdatedLast;

Expand Down
10 changes: 5 additions & 5 deletions zcutil/fetch-params.bat
Expand Up @@ -6,23 +6,23 @@ MKDIR "%APPDATA%"\ZcashParams
)
IF NOT EXIST "%APPDATA%"\ZcashParams\sprout-proving.key (
ECHO Downloading Zcash trusted setup sprout-proving.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sprout-proving.key -O "%APPDATA%"\ZcashParams\sprout-proving.key
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://komodoplatform.com/downloads/sprout-proving.key -O "%APPDATA%"\ZcashParams\sprout-proving.key
)
IF NOT EXIST "%APPDATA%"\ZcashParams\sprout-verifying.key (
ECHO Downloading Zcash trusted setup sprout-verifying.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sprout-verifying.key -O "%APPDATA%"\ZcashParams\sprout-verifying.key
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://komodoplatform.com/downloads/sprout-verifying.key -O "%APPDATA%"\ZcashParams\sprout-verifying.key
)
IF NOT EXIST "%APPDATA%"\ZcashParams\sapling-spend.params (
ECHO Downloading Zcash trusted setup sprout-proving.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sapling-spend.params -O "%APPDATA%"\ZcashParams\sapling-spend.params
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://komodoplatform.com/downloads/sapling-spend.params -O "%APPDATA%"\ZcashParams\sapling-spend.params
)
IF NOT EXIST "%APPDATA%"\ZcashParams\sapling-output.params (
ECHO Downloading Zcash trusted setup sprout-verifying.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sapling-output.params -O "%APPDATA%"\ZcashParams\sapling-output.params
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://komodoplatform.com/downloads/sapling-output.params -O "%APPDATA%"\ZcashParams\sapling-output.params
)
IF NOT EXIST "%APPDATA%"\ZcashParams\sprout-groth16.params (
ECHO Downloading Zcash trusted setup sprout-verifying.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sprout-groth16.params -O "%APPDATA%"\ZcashParams\sprout-groth16.params
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://komodoplatform.com/downloads/sprout-groth16.params -O "%APPDATA%"\ZcashParams\sprout-groth16.params
)
goto :EOF
:GET_CURRENT_DIR
Expand Down
2 changes: 1 addition & 1 deletion zcutil/fetch-params.sh
Expand Up @@ -13,7 +13,7 @@ SPROUT_VKEY_NAME='sprout-verifying.key'
SAPLING_SPEND_NAME='sapling-spend.params'
SAPLING_OUTPUT_NAME='sapling-output.params'
SAPLING_SPROUT_GROTH16_NAME='sprout-groth16.params'
SPROUT_URL="https://z.cash/downloads"
SPROUT_URL="https://komodoplatform.com/downloads"
SPROUT_IPFS="/ipfs/QmZKKx7Xup7LiAtFRhYsE1M7waXcv9ir9eCECyXAFGxhEo"

SHA256CMD="$(command -v sha256sum || echo shasum)"
Expand Down

0 comments on commit 6bcae3f

Please sign in to comment.