Browse Source

Merge branch 'duke' into dev

old_dev
Jonathan "Duke" Leto 5 years ago
parent
commit
2e24035318
  1. 3
      src/assetchains
  2. 12
      src/assetchains.json
  3. 4
      src/assetchains.old
  4. 4
      src/assetchains_stop
  5. 4
      src/bitcoind.cpp
  6. 2
      src/cc/gateways.cpp
  7. 40
      src/cc/payments.cpp
  8. 8
      src/cryptoconditions/src/cryptoconditions.c
  9. 3
      src/fiat-cli
  10. 2
      src/komodo_defs.h
  11. 2
      src/komodo_gateway.h
  12. 4
      src/komodo_nSPV_fullnode.h
  13. 4
      src/main.cpp

3
src/assetchains

@ -5,6 +5,7 @@ set -eo pipefail
source pubkey.txt
overide_args="$@"
seed_ip=`getent hosts zero.kolo.supernet.org | awk '{ print $1 }'`
komodo_binary='./komodod'
if [ -z "$delay" ]; then delay=20; fi
@ -14,6 +15,6 @@ if [ -z "$delay" ]; then delay=20; fi
gen=" -gen -genproclimit=1"
fi
./komodod $gen $args $overide_args -pubkey=$pubkey -addnode=$seed_ip &
$komodo_binary $gen $args $overide_args -pubkey=$pubkey -addnode=$seed_ip &
sleep $delay
done

12
src/assetchains.json

@ -233,14 +233,22 @@
"ac_supply": "90000000000",
"ac_reward": "100000000",
"ac_cc": "3",
"addnode": ["138.201.136.145"]
"ac_staked": "10",
"addnode": [
"138.201.136.145",
"95.217.44.58"
]
},
{
"ac_name": "MORTY",
"ac_supply": "90000000000",
"ac_reward": "100000000",
"ac_cc": "3",
"addnode": ["138.201.136.145"]
"ac_staked": "10",
"addnode": [
"138.201.136.145",
"95.217.44.58"
]
},
{
"ac_name": "KOIN",

4
src/assetchains.old

@ -46,8 +46,8 @@ echo $pubkey
./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 &
./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 &
./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=51.75.122.83 &
./komodod -pubkey=$pubkey -ac_name=RICK -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -addnode=138.201.136.145 &
./komodod -pubkey=$pubkey -ac_name=MORTY -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -addnode=138.201.136.145 &
./komodod -pubkey=$pubkey -ac_name=RICK -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -ac_staked=10 -addnode=95.217.44.58 -addnode=138.201.136.145 &
./komodod -pubkey=$pubkey -ac_name=MORTY -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -ac_staked=10 -addnode=95.217.44.58 -addnode=138.201.136.145 &
./komodod -pubkey=$pubkey -ac_name=VOTE2019 -ac_supply=123651638 -ac_public=1 -addnode=95.213.238.98 &
./komodod -pubkey=$pubkey -ac_name=KOIN -ac_supply=125000000 -addnode=3.0.32.10 &
./komodod -pubkey=$pubkey -ac_name=ZEXO -ac_supply=100000000 -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_ccenable=236 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02713bd85e054db923694b6b7a85306264edf4d6bd6d331814f2b40af444b3ebbc -ac_public=1 -addnode=80.240.17.222 &

4
src/assetchains_stop

@ -1,6 +1,8 @@
#!/bin/bash
set -eo pipefail
komodo_cli='./komodo-cli'
./listassetchains | while read chain; do
./komodo-cli --ac_name=$chain stop
$komodo_cli --ac_name=$chain stop
done

4
src/bitcoind.cpp

@ -76,14 +76,14 @@ void WaitForShutdown(boost::thread_group* threadGroup)
fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT);
StartShutdown();
}
if ( ASSETCHAINS_STAKED == 0 && ASSETCHAINS_ADAPTIVEPOW == 0 && (pindex= komodo_chainactive(1)) != 0 )
/*if ( ASSETCHAINS_STAKED == 0 && ASSETCHAINS_ADAPTIVEPOW == 0 && (pindex= komodo_chainactive(1)) != 0 )
{
if ( pindex->nTime > ADAPTIVEPOW_CHANGETO_DEFAULTON )
{
ASSETCHAINS_ADAPTIVEPOW = 1;
fprintf(stderr,"default activate adaptivepow\n");
} else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,ADAPTIVEPOW_CHANGETO_DEFAULTON);
} //else fprintf(stderr,"cant find height 1\n");
} //else fprintf(stderr,"cant find height 1\n");*/
if ( ASSETCHAINS_CBOPRET != 0 )
komodo_pricesinit();
while (!fShutdown)

2
src/cc/gateways.cpp

@ -1114,7 +1114,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui
if ( CCchange != 0 ) mtx.vout.push_back(MakeTokensCC1vout(EVAL_GATEWAYS,CCchange,gatewayspk));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysClaimOpRet('C',tokenid,bindtxid,refcoin,deposittxid,destpub,amount)));
}
return "";
return("");
}
std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin,CPubKey withdrawpub,int64_t amount)

40
src/cc/payments.cpp

@ -77,6 +77,18 @@
// start of consensus code
void mpz_set_lli( mpz_t rop, long long op )
{
mpz_import(rop, 1, 1, sizeof(op), 0, 0, &op);
}
int64_t mpz_get_si2( mpz_t op )
{
int64_t ret = 0;
mpz_export(&ret, NULL, 1, sizeof(ret), 0, 0, op);
return ret;
}
CScript EncodePaymentsTxidOpRet(int64_t allocation,std::vector<uint8_t> scriptPubKey,std::vector<uint8_t> destopret)
{
CScript opret; uint8_t evalcode = EVAL_PAYMENTS;
@ -277,7 +289,7 @@ int32_t payments_getallocations(int32_t top, int32_t bottom, const std::vector<s
//fprintf(stderr, "address: %s nValue.%li \n", CBitcoinAddress(address.second).ToString().c_str(), address.first);
scriptPubKeys.push_back(scriptPubKey);
allocations.push_back(address.first);
mpz_set_si(mpzAllocation,address.first);
mpz_set_lli(mpzAllocation,address.first);
mpz_add(mpzTotalAllocations,mpzTotalAllocations,mpzAllocation);
mpz_clear(mpzAllocation);
}
@ -316,7 +328,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
return(eval->Invalid("could not decode ccopret"));
if ( tx.vout.back().scriptPubKey.IsOpReturn() )
fHasOpret = true;
mpz_set_si(mpzCheckamount,amountReleased);
mpz_set_lli(mpzCheckamount,amountReleased);
} else return(eval->Invalid("could not decode ccopret"));
// use the createtxid to fetch the tx and all of the plans info.
@ -382,7 +394,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
//fprintf(stderr, "totalallocations.%li checkallocations.%li\n",totalallocations, checkallocations);
if ( totalallocations != checkallocations )
return(eval->Invalid("allocation missmatch"));
mpz_set_si(mpzTotalAllocations,totalallocations);
mpz_set_lli(mpzTotalAllocations,totalallocations);
}
else if ( funcid == 'S' || funcid == 'O' )
{
@ -438,16 +450,16 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
else
{
mpz_init(mpzAllocation);
mpz_set_si(mpzAllocation,allocations[n]);
mpz_set_lli(mpzAllocation,allocations[n]);
mpz_mul(mpzAllocation,mpzAllocation,mpzCheckamount);
mpz_tdiv_q(mpzAllocation,mpzAllocation,mpzTotalAllocations);
test = mpz_get_si(mpzAllocation);
test = mpz_get_si2(mpzAllocation);
mpz_clear(mpzAllocation);
}
//fprintf(stderr, "vout %i test.%li nValue.%li\n", i, test, tx.vout[i].nValue);
//fprintf(stderr, "vout.%i test.%lli vs nVlaue.%lli\n",i, (long long)test, (long long)tx.vout[i].nValue);
if ( test != tx.vout[i].nValue )
{
fprintf(stderr, "vout.%i test.%li vs nVlaue.%li\n",i, test, tx.vout[i].nValue);
fprintf(stderr, "vout.%i test.%lli vs nVlaue.%lli\n",i, (long long)test, (long long)tx.vout[i].nValue);
return(eval->Invalid("amounts do not match"));
}
if ( test < minimum )
@ -463,10 +475,10 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
{
// need to check that the next allocation was less than minimum, otherwise ppl can truncate the tx at any place not paying all elegible addresses.
mpz_init(mpzAllocation);
mpz_set_si(mpzAllocation,allocations[n+1]);
mpz_set_lli(mpzAllocation,allocations[n+1]);
mpz_mul(mpzAllocation,mpzAllocation,mpzCheckamount);
mpz_tdiv_q(mpzAllocation,mpzAllocation,mpzTotalAllocations);
int64_t test = mpz_get_si(mpzAllocation);
int64_t test = mpz_get_si2(mpzAllocation);
//fprintf(stderr, "check next vout pays under min: test.%li > minimuim.%i\n", test, minimum);
if ( test > minimum )
return(eval->Invalid("next allocation was not under minimum"));
@ -785,7 +797,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
return(result);
}
// set totalallocations to a mpz_t bignum, for amounts calculation later.
mpz_set_si(mpzTotalAllocations,totalallocations);
mpz_set_lli(mpzTotalAllocations,totalallocations);
}
else if ( funcid == 'S' || funcid == 'O' )
{
@ -852,7 +864,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
}
newamount = amount;
int64_t totalamountsent = 0;
mpz_t mpzAmount; mpz_init(mpzAmount); mpz_set_si(mpzAmount,amount);
mpz_t mpzAmount; mpz_init(mpzAmount); mpz_set_lli(mpzAmount,amount);
for (i=0; i<m; i++)
{
mpz_t mpzValue; mpz_init(mpzValue);
@ -860,11 +872,11 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
mtx.vout[i+1].nValue = amount / (top-bottom);
else
{
mpz_set_si(mpzValue,mtx.vout[i+1].nValue);
mpz_set_lli(mpzValue,mtx.vout[i+1].nValue);
mpz_mul(mpzValue,mpzValue,mpzAmount);
mpz_tdiv_q(mpzValue,mpzValue,mpzTotalAllocations);
if ( mpz_fits_slong_p(mpzValue) )
mtx.vout[i+1].nValue = mpz_get_si(mpzValue);
mtx.vout[i+1].nValue = mpz_get_si2(mpzValue);
else
{
result.push_back(Pair("result","error"));
@ -897,7 +909,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
totalamountsent += mtx.vout[i+1].nValue;
}
if ( totalamountsent < amount ) newamount = totalamountsent;
//int64_t temptst = mpz_get_si(mpzTotalAllocations);
//int64_t temptst = mpz_get_si2(mpzTotalAllocations);
//fprintf(stderr, "checkamount RPC.%li totalallocations.%li\n",totalamountsent, temptst);
mpz_clear(mpzAmount); mpz_clear(mpzTotalAllocations);
}

8
src/cryptoconditions/src/cryptoconditions.c

@ -272,10 +272,10 @@ int cc_verify(const struct CC *cond, const unsigned char *msg, size_t msgLength,
unsigned char msgHash[32];
if (doHashMsg) sha256(msg, msgLength, msgHash);
else memcpy(msgHash, msg, 32);
int32_t z;
for (z=0; z<32; z++)
fprintf(stderr,"%02x",msgHash[z]);
fprintf(stderr," msgHash msglen.%d\n",msgLength);
//int32_t z;
//for (z=0; z<32; z++)
// fprintf(stderr,"%02x",msgHash[z]);
//fprintf(stderr," msgHash msglen.%d\n",(int32_t)msgLength);
if (!cc_secp256k1VerifyTreeMsg32(cond, msgHash)) {
fprintf(stderr," cc_verify error C\n");

3
src/fiat-cli

@ -1,8 +1,9 @@
#!/bin/bash
args="$@"
komodo_cli='./komodo-cli'
./listassetchains | while read chain; do
echo $chain
./komodo-cli --ac_name=$chain $args
$komodo_cli --ac_name=$chain $args
done

2
src/komodo_defs.h

@ -20,7 +20,7 @@
#include "komodo_nk.h"
#define KOMODO_EARLYTXID_HEIGHT 100
#define ADAPTIVEPOW_CHANGETO_DEFAULTON 1572480000
//#define ADAPTIVEPOW_CHANGETO_DEFAULTON 1572480000
#define ASSETCHAINS_MINHEIGHT 128
#define ASSETCHAINS_MAX_ERAS 7
#define KOMODO_ELECTION_GAP 2000

2
src/komodo_gateway.h

@ -1420,7 +1420,7 @@ void komodo_passport_iteration()
int32_t maxseconds = 10;
FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; uint64_t RTmask = 0; //CBlockIndex *pindex;
expired = 0;
while ( KOMODO_INITDONE == 0 )
while ( 0 && KOMODO_INITDONE == 0 )
{
fprintf(stderr,"[%s] PASSPORT iteration waiting for KOMODO_INITDONE\n",ASSETCHAINS_SYMBOL);
sleep(3);

4
src/komodo_nSPV_fullnode.h

@ -620,7 +620,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
iguana_rwnum(0,&request[len-4],sizeof(filter),&filter);
}
if ( isCC != 0 )
if ( 0 && isCC != 0 )
fprintf(stderr,"utxos %s isCC.%d skipcount.%d filter.%x\n",coinaddr,isCC,skipcount,filter);
memset(&U,0,sizeof(U));
if ( (slen= NSPV_getaddressutxos(&U,coinaddr,isCC,skipcount,filter)) > 0 )
@ -660,7 +660,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
iguana_rwnum(0,&request[len-4],sizeof(filter),&filter);
}
//if ( isCC != 0 )
if ( 0 && isCC != 0 )
fprintf(stderr,"txids %s isCC.%d skipcount.%d filter.%d\n",coinaddr,isCC,skipcount,filter);
memset(&T,0,sizeof(T));
if ( (slen= NSPV_getaddresstxids(&T,coinaddr,isCC,skipcount,filter)) > 0 )

4
src/main.cpp

@ -4453,8 +4453,8 @@ static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBloc
notarizedht = komodo_notarized_height(&prevMoMheight,&notarizedhash,&txid);
if ( !fSkipdpow && pindexFork != 0 && pindexOldTip->GetHeight() > notarizedht && pindexFork->GetHeight() < notarizedht )
{
fprintf(stderr,"pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht,(int32_t)pindexOldTip->GetHeight(),notarizedht);
return state.DoS(100, error("ActivateBestChainStep(): pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht,(int32_t)pindexOldTip->GetHeight(),notarizedht),
fprintf(stderr,"pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexOldTip->GetHeight(),notarizedht,(int32_t)pindexFork->GetHeight(),notarizedht);
return state.DoS(100, error("ActivateBestChainStep(): pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexOldTip->GetHeight(),notarizedht,(int32_t)pindexFork->GetHeight(),notarizedht),
REJECT_INVALID, "past-notarized-height");
}
// - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks.

Loading…
Cancel
Save