No staking code, thank you very much

This commit is contained in:
Duke Leto
2019-12-11 16:35:47 -05:00
parent 1fa3de387c
commit ed52da4a8d
6 changed files with 3 additions and 215 deletions

View File

@@ -1,7 +1,7 @@
#include "cc/eval.h"
#include "crosschain.h"
#include "notarisationdb.h"
#include "notaries_staked.h"
int GetSymbolAuthority(const char* symbol)
{

View File

@@ -16,7 +16,7 @@
#ifndef H_KOMODO_H
#define H_KOMODO_H
#include "komodo_defs.h"
#include "notaries_staked.h"
#ifdef _WIN32
#define printf(...)

View File

@@ -17,7 +17,7 @@
#include "komodo_defs.h"
#include "komodo_cJSON.h"
#include "notaries_staked.h"
#define KOMODO_MAINNET_START 178999
#define KOMODO_NOTARIES_HEIGHT1 814000

View File

@@ -1,136 +0,0 @@
#include "notaries_staked.h"
#include "crosschain.h"
#include "cc/CCinclude.h"
#include <cstring>
extern char NOTARYADDRS[64][64];
extern std::string NOTARY_ADDRESS,NOTARY_PUBKEY;
extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY;
extern pthread_mutex_t staked_mutex;
extern uint8_t NOTARY_PUBKEY33[33];
int8_t is_STAKED(const char *chain_name)
{
static int8_t STAKED,doneinit;
if ( chain_name[0] == 0 )
return(0);
if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0)
return(STAKED);
else STAKED = 0;
if ( (strcmp(chain_name, "LABS") == 0) )
STAKED = 1; // These chains are allowed coin emissions.
else if ( (strncmp(chain_name, "LABS", 4) == 0) )
STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed.
else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) )
STAKED = 3; // These chains have no speical rules at all.
else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) )
STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important.
else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) )
STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed.
doneinit = 1;
return(STAKED);
};
int32_t STAKED_era(int timestamp)
{
int8_t era = 0;
if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0])
return(1);
for (int32_t i = 1; i < NUM_STAKED_ERAS; i++)
{
if (timestamp <= STAKED_NOTARIES_TIMESTAMP[i] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[i-1] + STAKED_ERA_GAP))
return(i+1);
}
// if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP.
return(0);
};
int8_t StakedNotaryID(std::string &notaryname, char *Raddress) {
if ( STAKED_ERA != 0 )
{
for (int8_t i = 0; i < num_notaries_STAKED[STAKED_ERA-1]; i++) {
if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) {
notaryname.assign(notaries_STAKED[STAKED_ERA-1][i][0]);
return(i);
}
}
}
return(-1);
}
int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) {
int i; int8_t retval = 0;
static uint8_t staked_pubkeys[NUM_STAKED_ERAS][64][33],didinit[NUM_STAKED_ERAS];
static char ChainName[65];
if ( ChainName[0] == 0 )
{
if ( ASSETCHAINS_SYMBOL[0] == 0 )
strcpy(ChainName,"KMD");
else
strcpy(ChainName,ASSETCHAINS_SYMBOL);
}
if ( era == 0 )
{
// era is zero so we need to null out the pubkeys.
memset(pubkeys,0,64 * 33);
printf("%s is a STAKED chain and is in an ERA GAP.\n",ChainName);
return(64);
}
else
{
if ( didinit[era-1] == 0 )
{
for (i=0; i<num_notaries_STAKED[era-1]; i++) {
decode_hex(staked_pubkeys[era-1][i],33,(char *)notaries_STAKED[era-1][i][1]);
}
didinit[era-1] = 1;
printf("%s is a STAKED chain in era %i \n",ChainName,era);
}
memcpy(pubkeys,staked_pubkeys[era-1],num_notaries_STAKED[era-1] * 33);
retval = num_notaries_STAKED[era-1];
}
return(retval);
}
void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries) {
static int didinit;
if ( didinit == 0 ) {
pthread_mutex_init(&staked_mutex,NULL);
didinit = 1;
}
if ( pubkeys[0][0] == 0 )
{
// null pubkeys, era 0.
pthread_mutex_lock(&staked_mutex);
memset(NOTARYADDRS,0,sizeof(NOTARYADDRS));
pthread_mutex_unlock(&staked_mutex);
}
else
{
// staked era is set.
pthread_mutex_lock(&staked_mutex);
for (int i = 0; i<numNotaries; i++)
{
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)pubkeys[i]);
if ( memcmp(NOTARY_PUBKEY33,pubkeys[i],33) == 0 )
{
NOTARY_ADDRESS.assign(NOTARYADDRS[i]);
IS_STAKED_NOTARY = i;
}
}
pthread_mutex_unlock(&staked_mutex);
}
}
CrosschainAuthority Choose_auth_STAKED(int32_t chosen_era) {
CrosschainAuthority auth;
auth.requiredSigs = (num_notaries_STAKED[chosen_era-1] / 5);
auth.size = num_notaries_STAKED[chosen_era-1];
for (int n=0; n<auth.size; n++)
for (size_t i=0; i<33; i++)
sscanf(notaries_STAKED[chosen_era-1][n][1]+(i*2), "%2hhx", auth.notaries[n]+i);
return auth;
};

View File

@@ -1,75 +0,0 @@
#ifndef NOTARIES_STAKED
#define NOTARIES_STAKED
#include "crosschain.h"
#include "cc/CCinclude.h"
static const int32_t iguanaPort = 9333;
static const int8_t BTCminsigs = 13;
static const int8_t overrideMinSigs = 7;
static const char *iguanaSeeds[8][1] =
{
{"94.23.1.95"},
{"103.6.12.112"},
{"18.224.176.46"},
{"45.76.120.247"},
{"185.62.57.32"},
{"149.28.253.160"},
{"68.183.226.124"},
{"149.28.246.230"},
};
static const int STAKED_ERA_GAP = 777;
static const int NUM_STAKED_ERAS = 4;
static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1604244444, 1604244444, 1604244444, 1604244444};
static const int32_t num_notaries_STAKED[NUM_STAKED_ERAS] = { 22, 1, 1, 1 };
// Era array of pubkeys.
static const char *notaries_STAKED[NUM_STAKED_ERAS][64][2] =
{
{
{"blackjok3r", "035fc678bf796ad52f69e1f5759be54ec671c559a22adf27eed067e0ddf1531574" }, // RTcYRJ6WopYkUqcmksyjxoV1CueYyqxFuk right
{"Alright", "02b718c60a035f77b7103a507d36aed942b4f655b8d13bce6f28b8eac523944278" }, //RG77F4mQpP1K1q2CDSc2vZSJvKUZgF8R26
{"webworker01", "031d1fb39ae4dca28965c3abdbd21faa0f685f6d7b87a60561afa7c448343fef6d" }, //RGsQiArk5sTmjXZV9UzGMW5njyvtSnsTN8 right
{"CrisF", "03745656c8991c4597828aad2820760c43c00ff2e3b381fef3b5c040f32a7b3a34" }, // RNhYJAaPHJCVXGWNVEJeP3TfepEPdhjrRr right
{"smk762", "02381616fbc02d3f0398c912fe7b7daf2f3f29e55dc35287f686b15686d8135a9f" }, // RSchwBApVquaG6mXH31bQ6P83kMN4Hound right
{"jorian", "0343eec31037d7b909efd968a5b5e7af60321bf7e464da28f815f0fb23ee7aadd7" }, // RJorianBXNwfNDYPxtNYJJ6vX7Z3VdTR25 right
{"TonyL", "021a559101e355c907d9c553671044d619769a6e71d624f68bfec7d0afa6bd6a96" }, // RHq3JsvLxU45Z8ufYS6RsDpSG4wi6ucDev
{"CHMEX", "03ed125d1beb118d12ff0a052bdb0cee32591386d718309b2924f2c36b4e7388e6" }, // RF4HiVeuYpaznRPs7fkRAKKYqT5tuxQQTL right
{"metaphilibert", "0344182c376f054e3755d712361672138660bda8005abb64067eb5aa98bdb40d10" }, // RG28QSnYFADBg1dAVkH1uPGYS6F8ioEUM2 right
{"gt", "02312dcecb6e4a32927a075972d3c009f3c68635d8100562cc1813ea66751b9fde" }, // RCg4tzKWQ7i3wrZEU8bvCbCQ4xRJnHnyoo right
{"CMaurice", "026c6d094523e810641b89f2d7f0ddd8f0b59d97c32e1fa97f0e3e0ac119c26ae4" }, // RSjayeSuYUE1E22rBjnqoexobaRjbAZ2Yb right
{"Bar_F1sh_Rel", "0395f2d9dd9ccb78caf74bff49b6d959afb95af746462e1b35f4a167d8e82b3666" }, // RBbLxJagCA9QHDazQvfnDZe874V1K4Gu8t
{"zatJUM", "030fff499b6dc0215344b28a0b6b4becdfb00cd34cd1b36b983ec14f47965fd4bc" }, // RSoEDLBasth7anxS8gbkg6KgeGiz8rhqv1 right
{"dwy", "03669457b2934d98b5761121dd01b243aed336479625b293be9f8c43a6ae7aaeff" }, // RKhZMqRF361FSGFAzstP5AhozekPjoVh5q
{"gcharang", "021569dd350d99e685a739c5b36bd01f217efb4f448a6f9a56da80c5edf6ce20ee" }, // RE8SsNwhYoygXJSvw9DuQbJicDc28dwR78 right
{"computergenie", "027313dabde94fb72f823231d0a1c59fc7baa2e5b3bb2af97ca7d70aae116026b9" }, // RLabsCGxTRqJcJvz6foKuXAB61puJ2x8yt right
{"daemonfox", "0383484bdc745b2b953c85b5a0c496a1f27bc42ae971f15779ed1532421b3dd943" }, //
{"SHossain", "02791f5c215b8a19c143a98e3371ff03b5613df9ac430c4a331ca55fed5761c800" }, // RKdLoHkyeorXmMtj91B1AAnAGiwsdt9MdF
{"Nabob", "03ee91c20b6d26e3604022f42df6bb8de6f669da4591f93b568778cba13d9e9ddf" }, // RRwCLPZDzpHEFJnLev4phy51e2stHRUAaU
{"mylo", "03f6b7fcaf0b8b8ec432d0de839a76598b78418dadd50c8e5594c0e557d914ec09" }, // RXN4hoZkhUkkrnef9nTUDw3E3vVALAD8Kx
{"PHBA2061", "039fc98c764bc85aed97d690d7942a4fd1190b2fa4f5f4c5c8e0957fac5c6ede00" }, // RPHba2o61hcpX4ds91oj3sKJ8aDXv6QdQf right
{"Exile13", "0247b2120a39faf83678b5de6883e039180ff42925bcb298d32f3792cd59001aae" }, // RTDJ3CDZ6ANbeDKab8nqTVrGw7ViAKLeDV right
},
{
{"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x
},
{
{"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x
},
{
{"blackjok3r", "021914947402d936a89fbdd1b12be49eb894a1568e5e17bb18c8a6cffbd3dc106e" }, // RTVti13NP4eeeZaCCmQxc2bnPdHxCJFP9x
}
};
int8_t is_STAKED(const char *chain_name);
int32_t STAKED_era(int timestamp);
int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era);
int8_t StakedNotaryID(std::string &notaryname, char *Raddress);
void UpdateNotaryAddrs(uint8_t pubkeys[64][33],int8_t numNotaries);
CrosschainAuthority Choose_auth_STAKED(int32_t chosen_era);
#endif

View File

@@ -38,7 +38,6 @@
#include "zcbenchmarks.h"
#include "script/interpreter.h"
#include "zcash/zip32.h"
#include "notaries_staked.h"
#include "utiltime.h"
#include "asyncrpcoperation.h"