Skip to content

Commit

Permalink
Merge pull request #622 from KomodoPlatform/patch-s8-prepare
Browse files Browse the repository at this point in the history
S8 preps
  • Loading branch information
ca333 authored Aug 19, 2024
2 parents 1ca3fe8 + e75479e commit 18596cc
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/komodo_mac_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

macos-build:
name: MacOS Build
runs-on: macos-latest
runs-on: macos-latest-large

steps:
- uses: actions/checkout@v4
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, 0)
define(_CLIENT_VERSION_MINOR, 8)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_REVISION, 3)
define(_CLIENT_VERSION_BUILD, 0)
define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50)))
define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1)))
Expand Down
5 changes: 3 additions & 2 deletions depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $(package)_version=1_72_0
$(package)_download_path=https://github.com/KomodoPlatform/boost/releases/download/boost-1.72.0-kmd
$(package)_sha256_hash=59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722
$(package)_file_name=$(package)_$($(package)_version).tar.bz2
$(package)_patches=fix-Solaris.patch ignore_wnonnull_gcc_11.patch
$(package)_patches=fix-Solaris.patch ignore_wnonnull_gcc_11.patch range_enums_clang_16.patch

define $(package)_set_vars
$(package)_config_opts_release=variant=release
Expand All @@ -30,7 +30,8 @@ endef
define $(package)_preprocess_cmds
echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : <cxxflags>\"$($(package)_cxxflags) $($(package)_cppflags)\" <linkflags>\"$($(package)_ldflags)\" <archiver>\"$(boost_archiver_$(host_os))\" <striper>\"$(host_STRIP)\" <ranlib>\"$(host_RANLIB)\" <rc>\"$(host_WINDRES)\" : ;" > user-config.jam&& \
patch -p1 < $($(package)_patch_dir)/fix-Solaris.patch &&\
patch -p2 < $($(package)_patch_dir)/ignore_wnonnull_gcc_11.patch
patch -p2 < $($(package)_patch_dir)/ignore_wnonnull_gcc_11.patch &&\
patch -p2 < $($(package)_patch_dir)/range_enums_clang_16.patch
endef

define $(package)_config_cmds
Expand Down
75 changes: 75 additions & 0 deletions depends/patches/boost/range_enums_clang_16.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
diff --git a/include/boost/numeric/conversion/detail/int_float_mixture.hpp b/include/boost/numeric/conversion/detail/int_float_mixture.hpp
index 464e527..7690d07 100644
--- a/include/boost/numeric/conversion/detail/int_float_mixture.hpp
+++ b/include/boost/numeric/conversion/detail/int_float_mixture.hpp
@@ -16,15 +16,15 @@
#include "boost/numeric/conversion/int_float_mixture_enum.hpp"
#include "boost/numeric/conversion/detail/meta.hpp"

-#include "boost/mpl/integral_c.hpp"
+#include "boost/type_traits/integral_constant.hpp"

namespace boost { namespace numeric { namespace convdetail
{
// Integral Constants for 'IntFloatMixture'
- typedef mpl::integral_c<int_float_mixture_enum, integral_to_integral> int2int_c ;
- typedef mpl::integral_c<int_float_mixture_enum, integral_to_float> int2float_c ;
- typedef mpl::integral_c<int_float_mixture_enum, float_to_integral> float2int_c ;
- typedef mpl::integral_c<int_float_mixture_enum, float_to_float> float2float_c ;
+ typedef boost::integral_constant<int_float_mixture_enum, integral_to_integral> int2int_c ;
+ typedef boost::integral_constant<int_float_mixture_enum, integral_to_float> int2float_c ;
+ typedef boost::integral_constant<int_float_mixture_enum, float_to_integral> float2int_c ;
+ typedef boost::integral_constant<int_float_mixture_enum, float_to_float> float2float_c ;

// Metafunction:
//
diff --git a/include/boost/numeric/conversion/detail/sign_mixture.hpp b/include/boost/numeric/conversion/detail/sign_mixture.hpp
index c7f9e42..fde1584 100644
--- a/include/boost/numeric/conversion/detail/sign_mixture.hpp
+++ b/include/boost/numeric/conversion/detail/sign_mixture.hpp
@@ -16,15 +16,15 @@
#include "boost/numeric/conversion/sign_mixture_enum.hpp"
#include "boost/numeric/conversion/detail/meta.hpp"

-#include "boost/mpl/integral_c.hpp"
+#include "boost/type_traits/integral_constant.hpp"

namespace boost { namespace numeric { namespace convdetail
{
// Integral Constants for 'SignMixture'
- typedef mpl::integral_c<sign_mixture_enum, unsigned_to_unsigned> unsig2unsig_c ;
- typedef mpl::integral_c<sign_mixture_enum, signed_to_signed> sig2sig_c ;
- typedef mpl::integral_c<sign_mixture_enum, signed_to_unsigned> sig2unsig_c ;
- typedef mpl::integral_c<sign_mixture_enum, unsigned_to_signed> unsig2sig_c ;
+ typedef boost::integral_constant<sign_mixture_enum, unsigned_to_unsigned> unsig2unsig_c ;
+ typedef boost::integral_constant<sign_mixture_enum, signed_to_signed> sig2sig_c ;
+ typedef boost::integral_constant<sign_mixture_enum, signed_to_unsigned> sig2unsig_c ;
+ typedef boost::integral_constant<sign_mixture_enum, unsigned_to_signed> unsig2sig_c ;

// Metafunction:
//
diff --git a/include/boost/numeric/conversion/detail/udt_builtin_mixture.hpp b/include/boost/numeric/conversion/detail/udt_builtin_mixture.hpp
index 36dbc49..a39d29f 100644
--- a/include/boost/numeric/conversion/detail/udt_builtin_mixture.hpp
+++ b/include/boost/numeric/conversion/detail/udt_builtin_mixture.hpp
@@ -15,15 +15,15 @@
#include "boost/numeric/conversion/udt_builtin_mixture_enum.hpp"
#include "boost/numeric/conversion/detail/meta.hpp"

-#include "boost/mpl/integral_c.hpp"
+#include "boost/type_traits/integral_constant.hpp"

namespace boost { namespace numeric { namespace convdetail
{
// Integral Constants for 'UdtMixture'
- typedef mpl::integral_c<udt_builtin_mixture_enum, builtin_to_builtin> builtin2builtin_c ;
- typedef mpl::integral_c<udt_builtin_mixture_enum, builtin_to_udt> builtin2udt_c ;
- typedef mpl::integral_c<udt_builtin_mixture_enum, udt_to_builtin> udt2builtin_c ;
- typedef mpl::integral_c<udt_builtin_mixture_enum, udt_to_udt> udt2udt_c ;
+ typedef boost::integral_constant<udt_builtin_mixture_enum, builtin_to_builtin> builtin2builtin_c ;
+ typedef boost::integral_constant<udt_builtin_mixture_enum, builtin_to_udt> builtin2udt_c ;
+ typedef boost::integral_constant<udt_builtin_mixture_enum, udt_to_builtin> udt2builtin_c ;
+ typedef boost::integral_constant<udt_builtin_mixture_enum, udt_to_udt> udt2udt_c ;

// Metafunction:
//
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
//! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 8
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_BUILD 0

//! Set to true for release, false for prerelease or test build
Expand Down
2 changes: 1 addition & 1 deletion src/deprecation.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// * Shut down WEEKS_UNTIL_DEPRECATION weeks' worth of blocks after the estimated release block height.
// * A warning is shown during the DEPRECATION_WARN_LIMIT worth of blocks prior to shut down.
static const int WEEKS_UNTIL_DEPRECATION = 52;
static const int DEPRECATION_HEIGHT = 4320000; //TODO: use [last_season_array_item - 1] + 650.000 for automagic update
static const int DEPRECATION_HEIGHT = 4820333; //TODO: use [last_season_array_item - 1] + 650.000 for automagic update
static const int APPROX_RELEASE_HEIGHT = DEPRECATION_HEIGHT - (WEEKS_UNTIL_DEPRECATION * 7 * 24 * 60);

// Number of blocks before deprecation to warn users
Expand Down
35 changes: 34 additions & 1 deletion src/komodo_bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,40 @@ int32_t komodo_checkPOW(int64_t stakeTxValue, int32_t slowflag,CBlock *pblock,in
}
}

//fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed);
/*
KIP0003 partial (for S8) consensus rule implementation. If it's an easy-mined
block (i.e., produced by a notary), the coinbase should have at only two
vouts. The first vout should be equal to the block reward (BR), and the second
should reflect a burned fee. Even if the fee in the block is zero, a 0-value
OP_RETURN second vout should exist to indicate that the block producer supports
KIP0003. We will not calculate fees for each transaction here for simplicity.
We will just check that the coinbase's first vout amount pays exactly the block
reward or less. This will mean that fees are burned anyway. Before the beginning
of S9, this rule should be removed, and a common rule (for both easy-mined and
regular blocks) for KIP0003 with nFees burned amount check should be placed in
ConnectBlock.
*/

if (chainName.isKMD() && height > nKIP0003Activation && possible != 0 && failed != 0 && notaryid != -1)
{
// it's a P2PK block with hash > bnTarget and mined by notary with index notaryid
const CBlock &blk = *pblock;
const CAmount blockReward = GetBlockSubsidy(height, Params().GetConsensus());

bool fKIP0003Checked = blk.vtx.size() > 1 &&
blk.vtx[0].vout.size() == 2 &&
blk.vtx[0].vout[0].nValue <= blockReward &&
blk.vtx[0].vout[1].scriptPubKey.IsOpReturn();

LogPrintf("KIP0003 check for NN: ht.%d, hash.%s - %s\n",
height, blk.GetHash().ToString(),
fKIP0003Checked ? "PASSED!" : "FAILED!");

// Uncomment the following line if you need to return -1 on failure
// if (!fKIP0003Checked) return -1;
}

//fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed);
if ( failed != 0 && possible == 0 && notaryid < 0 )
return(-1);
else return(0);
Expand Down
8 changes: 1 addition & 7 deletions src/komodo_gateway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block)
}
if ( chainName.isKMD() )
{
if ( overflow != 0 || total > COIN/10 )
if ( overflow != 0 )
{
if ( height >= activation )
{
Expand All @@ -186,12 +186,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block)
return(-1);
}
}
else if ( block.nBits == KOMODO_MINDIFF_NBITS && total > 0 ) // to deal with fee stealing
{
fprintf(stderr,"notary mined ht.%d with extra %.8f\n",height,dstr(total));
if ( height > KOMODO_NOTARIES_HEIGHT1 )
return(-1);
}
if ( strangeout != 0 || notmatched != 0 )
{
if ( 0 && strcmp(NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 )
Expand Down
115 changes: 115 additions & 0 deletions src/komodo_hardfork.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <cassert>
#include <cstring>
#include "komodo_hardfork.h"

const uint32_t nStakedDecemberHardforkTimestamp = 1576840000; //December 2019 hardfork 12/20/2019 @ 11:06am (UTC)
Expand All @@ -15,6 +17,11 @@ const int32_t nS6HardforkHeight = 2963330; // dPoW Season 6, Fri Jun 24 2022
const uint32_t nS7Timestamp = 1688132253; // dPoW Season 7, Fri Jun 30 2023 13:37:33 GMT+0000
const int32_t nS7HardforkHeight = 3484958; // dPoW Season 7, Fri Jun 30 2023

const uint32_t nS8Timestamp = 1728049053; // dPoW Season 8, Fri Oct 4 2024 13:37:33 GMT+0000
const int32_t nS8HardforkHeight = 4125988; // dPoW Season 8, Fri Oct 4 2024 (est. via https://github.com/KomodoPlatform/NotaryNodes/blob/master/utils/estimate_hf_block.py)

const int32_t nKIP0003Activation = nS8HardforkHeight;

// Era array of pubkeys. Add extra seasons to bottom as requried, after adding appropriate info above.
const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] =
{
Expand Down Expand Up @@ -550,5 +557,113 @@ const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] =
{"dragonhound_EU", "0286d7af8583e18127bd1f45730916b4f48ae3e0c90181b2745174b91b76c6e28b"},
{"dragonhound_NA", "0306476ea5fb67aec667172a9bb30646dbff195b84c30ac958175af9b475987802"},
{"dragonhound_DEV", "02f9a7b49282885cd03969f1f5478287497bc8edfceee9eac676053c107c5fcdaf"}
},
{
// Season 8
{"alright_DEV", "028548847b3bbccff37c9b47bc4154183304902773d514b792ec2adc91e600e3b9"}, // 0
{"alien_AR", "03a40091ce1e7aa9863d9ad0c27f67b7d18bb47612438570ce344cd1782937c575"},
{"alien_EU", "03bb749e337b9074465fa28e757b5aa92cb1f0fea1a39589bca91a602834d443cd"},
{"alien_NA", "03bea1ac333b95c8669ec091907ea8713cae26f74b9e886e13593400e21c4d30a8"},
{"alien_SH", "03911a60395801082194b6834244fa78a3c30ff3e888667498e157b4aa80b0a65f"},
{"alienx_EU", "026afe5b112d1b39e0edafd5e051e261a676104460581f3673f26ceff7f1e6c56c"},
{"alienx_NA", "02f0b3ef87629509441b1ae95f28108f258a81910e483b90e0496205e24e7069b8"},
{"artist_SH", "023f9632eb3dc7fd1cfd700bb58de2da51bfa5898838586f49afdd145bddac16b6"},
{"batman_EU", "0358441eca9d8d24cd756fb3308fd7c9d60fe2b5af702ce5c9c1429cbea7a4c284"},
{"blackice_AR", "02bbc5518d27918d77c46b4e3ad0b9df936df520646527ab4c2f206544a2b03967"},
{"blackice_EU", "02340bf4749a392865b0ddaf37e652195e740c7538aeac87f7a51b8bf2dcdc24ac"}, // 10
{"blackice_NA", "035baa12331ad6c284d5f1b76527c1d6c5eb15a74b9ba369e5d46aefcc9c120938"},
{"blackice_SH", "02c275d12560b2c8238b8a10a8fc8da891784eb7b2ff5d3310ebcb666e47579571"},
{"blackice2_AR", "03d224790d17b881db560759cc9cc73fe5c865136a88af471ea156b7eb6d88ce32"},
{"ca333_EU", "030a18ffa85e2928ed37b2e30dbeb9bfb30b21fb15c5c4bcbd61d26b945e398e2b"},
{"chmex_AR", "036c856ea778ea105b93c0be187004d4e51161eda32888aa307b8f72d490884005"},
{"chmex_EU", "025b7209ba37df8d9695a23ea706ea2594863ab09055ca6bf485855937f3321d1d"},
{"chmex_NA", "030c2528c29d5328243c910277e3d74aa77c9b4e145308007d2b11550731591dbe"},
{"chmex_SH", "02698305eb3c27a2c724efd2152f9250739355116f201656c34b83aac2d3aebd19"},
{"chmexvet_SH", "02d27ed1cddfbaff9e47865e7df0165457e8f075f70bbea8c0498598ccf494555d"},
{"cipi_AR", "033ae024cdb748e083406a2e20037017a1292079ad6a8161ae5b43f398724fea74"}, // 20
{"cipi_EU", "03d6e1f3a693b5d69049791005d7cb64c259a1ad85833f5a9c545d4fee29905009"},
{"cipi_NA", "036cc1d7476e4260601927be0fc8b748ae68d8fec8f5c498f71569a01bd92046c5"},
{"cipi2_NA", "0306531923dbd4517d15e932668b64cbf95cc6c4293e46c8b5825c6543e0f06b15"},
{"colmapol_EU", "020c63078b5f5d27183de6f2bbae9bfe3fc57e017faf89b7d566bb947a92a2e40d"},
{"dimxy_AR", "02689d0b77b1e8e8c93a102d8b689fd08179164d70e2dd585543c3896a0916e6a1"},
{"dragonhound_AR", "030a72f1a15f67624aea55743c5b777bdd55362596add77b544ee2e582bdebf0c7"},
{"dragonhound_EU", "0286d7af8583e18127bd1f45730916b4f48ae3e0c90181b2745174b91b76c6e28b"},
{"dragonhound_NA", "0306476ea5fb67aec667172a9bb30646dbff195b84c30ac958175af9b475987802"},
{"dragonhound_SH", "02fe8e5a64979bc8e55b24e121182d2f1948e00a050c77407edbfc9cc8c012d679"},
{"fediakash_AR", "027dfe5403f8870fb0e1b94a2b4204373b31ea73179ba500a88dd56d22855cd03b"}, // 30
{"fediakash_NA", "024b31751c90dd9bd31e9a419be54d6f6cb7f4a85ea475359852ab645124010290"},
{"francois_SH", "02fdbb8fdfa4b859e1a21c30824f8c04e15c8886b1e1cab5d9d0bd89c353eb9710"},
{"gcharang_AR", "030de3d833ba049da08231ca6b622c77c7f96b26269963291d9604706bb94031a5"},
{"gcharang_SH", "02cb445948bf0d89f8d61102e12a5ee6e98be61ac7c2cb9ba435219ea9db967117"},
{"gcharang2_SH", "02567b688c180212df97b65273e70512f5f1f5edd20eb5fb85c7efa2a510e363d7"},
{"kmdude_SH", "02116774b25226d0b99f70a24f55c5ce17a7af6d3522071369c233157ecb27b82a"},
{"marmarachain_AR", "0335ab9e59d602df5580b964b6451d02cd9cc243ddf01b065db84375488df9f53c"},
{"marmarachain_EU", "0234e40800500370d43979586ee2cec2e777a0368d10c682e78bca30fd1630c18d"},
{"mcrypt_NA", "03ccaa74304165e0d66968c3f714942a130d67f02db1c2f910a75dfc15c0d3d58f"},
{"naezith_EU", "038f61a0418deafdb9fa8809a5df0956943f423364022cab578c3fcb158f3dfc55"}, // 40
{"naezith_NA", "033d9e2e3e51627b4cf9fec2ddbaadfd76a50965d423a2741e5b0db6ab13a057af"},
{"onur-ozkan_EU", "03c159a0733fb3d15d0b6e7eb67568343c10891eb6f1e8ab0ae6fbe9e33af17bc0"},
{"onur-ozkan_NA", "02be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373da"},
{"pbca26_NA", "024034ed324e69316d6f6d554168b56828e40334f99d7adfe4ef9248c49d433e12"},
{"ptyx_SH", "02ac5e2bc7bd5372395eab76c56951f699af617cd4e1fa2926eb7318e9caecd531"},
{"shamardy_SH", "026d378de09ba51d8f56be52bc8d02f5e20bae843406e23686047b76c72412a7b3"},
{"smdmitry_AR", "022a2a45979a6631a25e4c96469423de720a2f4c849548957c35a35c91041ee7ac"},
{"smdmitry2_AR", "026e33b213be94fa7c05c781cb1d2fb381e4c4ef6aad40d6a67f0a8ad573d92efe"},
{"smdmitry_EU", "02eb3aad81778f8d6f7e5295c44ca224e5c812f5e43fc1e9ce4ebafc23324183c9"},
{"smdmitry_NA", "020580cbdfc051bdac9e5d05fe9a6b6a15885fbd3989c6662001f2399c6e0d7e4c"}, // 50
{"smdmitry_SH", "02d01cd6b87cbf5a9795c06968f0d169168c1be0d82cfeb79958b11ae2c30316c1"},
{"strob_SH", "025ceac4256cef83ca4b110f837a71d70a5a977ecfdf807335e00bc78b560d451a"},
{"gcharang_DEV", "033b82b5791c65477dd11095cf33332013df6d2bcb7aa06a6dae5f7b22b6959b0b"},
{"dimxy_DEV", "039a01cd626d5efbe7fd05a59d8e5fced53bacac589192278f9b00ad31654b6956"},
{"ca333_DEV", "03cf925a2d7d697448c3ac6fff9aff349b80d773b4ce7de22c9ef7e2c8c002bec6"},
{"qa_DEV", "036f42e1888378068c3a17a53665b0a9db21465571d63ca02eb8d5681afa709074"},
{"core_DEV", "03955c7999538cee313bf196a7df59db208c651f6a5a1b0eed94732ba753b4f3f4"},
{"security_DEV", "022450f4f32435372b43dc2b9d5b690114fbe5e5dcbe0c02ab8164698f1a9eda6e"},
{"tonyl_AR", "0277bbdf6403d1ebaac5a715a9120118e74be0d3bed71a2c8cf5542fb6ca7d2dd7"},
{"van_EU", "03af7f8c82f20671ca1978116353839d3e501523e379bfb52b1e05d7816bb5812f"}, // 60
{"who-biz_AR", "03057d4c00c4e18f72faa4234aada9ad17ecd4bd9455c548edef16b94befa1a087"},
{"who-biz_NA", "03170d900f6d6a13002255b708f7bd27e55b5c05d1ddbaf8c25a1fc287d9f804ed"},
{"dragonhound_DEV", "02f9a7b49282885cd03969f1f5478287497bc8edfceee9eac676053c107c5fcdaf"}
}
};

class NotaryChecker {
public:
NotaryChecker() {
checkSeasons();
checkNotaries();
}

private:
void checkSeasons() const {
for (size_t i = 0; i < NUM_KMD_SEASONS; ++i) {
assert(KMD_SEASON_TIMESTAMPS[i] != 0 && "KMD_SEASON_TIMESTAMPS is invalid");
assert(KMD_SEASON_HEIGHTS[i] != 0 && "KMD_SEASON_HEIGHTS is invalid");
}
}

void checkNotaries() const {
for (int season = 0; season < NUM_KMD_SEASONS; ++season) {
for (int notary = 0; notary < NUM_KMD_NOTARIES; ++notary) {
const char* name = notaries_elected[season][notary][0];
const char* pubkey = notaries_elected[season][notary][1];
assert(name != nullptr && "Notary name is null");
assert(pubkey != nullptr && "Notary pubkey is null");
assert(isValidPubkey(pubkey) && "Notary pubkey is invalid");
}
}
}

bool isValidPubkey(const char* str) const {
if (strlen(str) != 66) return false;
if (str[0] != '0' || (str[1] != '2' && str[1] != '3')) return false;
for (int i = 2; i < 66; ++i) {
if (!((str[i] >= '0' && str[i] <= '9') || (str[i] >= 'a' && str[i] <= 'f') || (str[i] >= 'A' && str[i] <= 'F'))) {
return false;
}
}
return true;
}
};

NotaryChecker notaryChecker;
Loading

0 comments on commit 18596cc

Please sign in to comment.