Merge branch 'dev' into danger

This commit is contained in:
Duke
2023-10-13 09:27:38 -04:00
41 changed files with 731 additions and 192 deletions

View File

@@ -50,11 +50,14 @@ namespace randomx {
template struct AlignedAllocator<CacheLineSize>;
void* LargePageAllocator::allocMemory(size_t count) {
return allocLargePagesMemory(count);
void *mem = allocLargePagesMemory(count);
if (mem == nullptr)
throw std::bad_alloc();
return mem;
}
void LargePageAllocator::freeMemory(void* ptr, size_t count) {
freePagedMemory(ptr, count);
};
}
}

View File

@@ -337,19 +337,19 @@ FORCE_INLINE int rx_vec_i128_w(rx_vec_i128 a) {
return _a.i32[3];
}
FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int _I3, int _I2, int _I1, int _I0) {
return (rx_vec_i128)((__m128li){_I0,_I1,_I2,_I3});
FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int i3, int i2, int i1, int i0) {
return (rx_vec_i128)((__m128li){i0,i1,i2,i3});
};
FORCE_INLINE rx_vec_i128 rx_xor_vec_i128(rx_vec_i128 _A, rx_vec_i128 _B) {
return (rx_vec_i128)vec_xor(_A,_B);
FORCE_INLINE rx_vec_i128 rx_xor_vec_i128(rx_vec_i128 a, rx_vec_i128 b) {
return (rx_vec_i128)vec_xor(a,b);
}
FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const *_P) {
FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const *p) {
#if defined(NATIVE_LITTLE_ENDIAN)
return *_P;
return *p;
#else
uint32_t* ptr = (uint32_t*)_P;
uint32_t* ptr = (uint32_t*)p;
vec_u c;
c.u32[0] = load32(ptr + 0);
c.u32[1] = load32(ptr + 1);
@@ -359,13 +359,13 @@ FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const *_P) {
#endif
}
FORCE_INLINE void rx_store_vec_i128(rx_vec_i128 *_P, rx_vec_i128 _B) {
FORCE_INLINE void rx_store_vec_i128(rx_vec_i128 *p, rx_vec_i128 b) {
#if defined(NATIVE_LITTLE_ENDIAN)
*_P = _B;
*p = b;
#else
uint32_t* ptr = (uint32_t*)_P;
uint32_t* ptr = (uint32_t*)p;
vec_u B;
B.i = _B;
B.i = b;
store32(ptr + 0, B.u32[0]);
store32(ptr + 1, B.u32[1]);
store32(ptr + 2, B.u32[2]);
@@ -487,12 +487,12 @@ FORCE_INLINE int rx_vec_i128_w(rx_vec_i128 a) {
return vgetq_lane_s32(vreinterpretq_s32_u8(a), 3);
}
FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int _I3, int _I2, int _I1, int _I0) {
FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int i3, int i2, int i1, int i0) {
int32_t data[4];
data[0] = _I0;
data[1] = _I1;
data[2] = _I2;
data[3] = _I3;
data[0] = i0;
data[1] = i1;
data[2] = i2;
data[3] = i3;
return vreinterpretq_u8_s32(vld1q_s32(data));
};
@@ -662,29 +662,29 @@ FORCE_INLINE int rx_vec_i128_w(rx_vec_i128 a) {
return a.u32[3];
}
FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int _I3, int _I2, int _I1, int _I0) {
FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int i3, int i2, int i1, int i0) {
rx_vec_i128 v;
v.u32[0] = _I0;
v.u32[1] = _I1;
v.u32[2] = _I2;
v.u32[3] = _I3;
v.u32[0] = i0;
v.u32[1] = i1;
v.u32[2] = i2;
v.u32[3] = i3;
return v;
};
FORCE_INLINE rx_vec_i128 rx_xor_vec_i128(rx_vec_i128 _A, rx_vec_i128 _B) {
FORCE_INLINE rx_vec_i128 rx_xor_vec_i128(rx_vec_i128 a, rx_vec_i128 b) {
rx_vec_i128 c;
c.u32[0] = _A.u32[0] ^ _B.u32[0];
c.u32[1] = _A.u32[1] ^ _B.u32[1];
c.u32[2] = _A.u32[2] ^ _B.u32[2];
c.u32[3] = _A.u32[3] ^ _B.u32[3];
c.u32[0] = a.u32[0] ^ b.u32[0];
c.u32[1] = a.u32[1] ^ b.u32[1];
c.u32[2] = a.u32[2] ^ b.u32[2];
c.u32[3] = a.u32[3] ^ b.u32[3];
return c;
}
FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const*_P) {
FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const* p) {
#if defined(NATIVE_LITTLE_ENDIAN)
return *_P;
return *p;
#else
uint32_t* ptr = (uint32_t*)_P;
uint32_t* ptr = (uint32_t*)p;
rx_vec_i128 c;
c.u32[0] = load32(ptr + 0);
c.u32[1] = load32(ptr + 1);
@@ -694,15 +694,15 @@ FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const*_P) {
#endif
}
FORCE_INLINE void rx_store_vec_i128(rx_vec_i128 *_P, rx_vec_i128 _B) {
FORCE_INLINE void rx_store_vec_i128(rx_vec_i128 *p, rx_vec_i128 b) {
#if defined(NATIVE_LITTLE_ENDIAN)
*_P = _B;
*p = b;
#else
uint32_t* ptr = (uint32_t*)_P;
store32(ptr + 0, _B.u32[0]);
store32(ptr + 1, _B.u32[1]);
store32(ptr + 2, _B.u32[2]);
store32(ptr + 3, _B.u32[3]);
uint32_t* ptr = (uint32_t*)p;
store32(ptr + 0, b.u32[0]);
store32(ptr + 1, b.u32[1]);
store32(ptr + 2, b.u32[2]);
store32(ptr + 3, b.u32[3]);
#endif
}

View File

@@ -93,6 +93,8 @@ JitCompilerA64::JitCompilerA64()
, literalPos(ImulRcpLiteralsEnd)
, num32bitLiterals(0)
{
if (code == nullptr)
throw std::runtime_error("allocMemoryPages");
memset(reg_changed_offset, 0, sizeof(reg_changed_offset));
memcpy(code, (void*) randomx_program_aarch64, CodeSize);

View File

@@ -225,6 +225,8 @@ namespace randomx {
JitCompilerX86::JitCompilerX86() {
code = (uint8_t*)allocMemoryPages(CodeSize);
if (code == nullptr)
throw std::runtime_error("allocMemoryPages");
memcpy(code, codePrologue, prologueSize);
memcpy(code + epilogueOffset, codeEpilogue, epilogueSize);
}

View File

@@ -113,6 +113,10 @@ extern "C" {
cache = nullptr;
}
}
if (cache && cache->memory == nullptr) {
randomx_release_cache(cache);
cache = nullptr;
}
return cache;
}
@@ -130,9 +134,7 @@ extern "C" {
void randomx_release_cache(randomx_cache* cache) {
assert(cache != nullptr);
if (cache->memory != nullptr) {
cache->dealloc(cache);
}
cache->dealloc(cache);
delete cache;
}
@@ -162,6 +164,10 @@ extern "C" {
dataset = nullptr;
}
}
if (dataset && dataset->memory == nullptr) {
randomx_release_dataset(dataset);
dataset = nullptr;
}
return dataset;
}

View File

@@ -32,6 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cstdint>
constexpr char hexmap[] = "0123456789abcdef";
inline void outputHex(std::ostream& os, const char* data, int length) {

View File

@@ -1,53 +0,0 @@
// Copyright (c) 2016-2023 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#ifndef CC_MARMARA_H
#define CC_MARMARA_H
/*
#include "CCinclude.h"
#include "../hush_cJSON.h"
#define MARMARA_GROUPSIZE 60
#define MARMARA_MINLOCK (1440 * 3 * 30)
#define MARMARA_MAXLOCK (1440 * 24 * 30)
#define MARMARA_VINS 16
#define EVAL_MARMARA 0xef
extern uint8_t ASSETCHAINS_MARMARA;
uint64_t hush_block_prg(uint32_t nHeight);
int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid);
int32_t MarmaraGetbatontxid(std::vector<uint256> &creditloop,uint256 &batontxid,uint256 txid);
UniValue MarmaraCreditloop(uint256 txid);
UniValue MarmaraSettlement(uint64_t txfee,uint256 batontxid);
UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height);
UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...]
UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid,bool automaticflag);
UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid);
UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency);
bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);
// CCcustom
UniValue MarmaraInfo();
*/
#endif

View File

@@ -30,7 +30,6 @@
#include "CCOracles.h"
#include "CCPrices.h"
#include "CCPegs.h"
#include "CCMarmara.h"
#include "CCPayments.h"
#include "CCGateways.h"
#include "CCtokens.h"
@@ -192,17 +191,6 @@ uint8_t PegsCCpriv[32] = { 0x52, 0x56, 0x4c, 0x78, 0x87, 0xf7, 0xa2, 0x39, 0xb0,
#undef FUNCNAME
#undef EVALCODE
// Marmara
#define FUNCNAME IsMarmaraInput
#define EVALCODE EVAL_MARMARA
const char *MarmaraCCaddr = "RGLSRDnUqTB43bYtRtNVgmwSSd1sun2te8";
const char *MarmaraNormaladdr = "RMN25Tn8NNzcyQDiQNuMp8UmwLMFd9thYc";
char MarmaraCChexstr[67] = { "03afc5be570d0ff419425cfcc580cc762ab82baad88c148f5b028d7db7bfeee61d" };
uint8_t MarmaraCCpriv[32] = { 0x7c, 0x0b, 0x54, 0x9b, 0x65, 0xd4, 0x89, 0x57, 0xdf, 0x05, 0xfe, 0xa2, 0x62, 0x41, 0xa9, 0x09, 0x0f, 0x2a, 0x6b, 0x11, 0x2c, 0xbe, 0xbd, 0x06, 0x31, 0x8d, 0xc0, 0xb9, 0x96, 0x76, 0x3f, 0x24 };
#include "CCcustom.inc"
#undef FUNCNAME
#undef EVALCODE
// Payments
#define FUNCNAME IsPaymentsInput
#define EVALCODE EVAL_PAYMENTS

View File

@@ -1547,9 +1547,171 @@ void *chainparams_commandline() {
(1249000, uint256S("0x00000001170d6ae54d494bd2dbf29c5ab7f560f51874987d7dbe129d549c097f"))
(1250000, uint256S("0x000000033226eef40d094c8aa88d03bbc9146856c52248760e28c45426787352"))
(1251000, uint256S("0x0000000281c7f7ef75ac6539791e26b9744cccd59414b04ddc4697bcd3595209"))
,(int64_t) 1675926362, // time of last checkpointed block
(int64_t) 2022392, // total txs
(double) 1371 // txs in the last day before block 1251770
// Generated at 1688095440 via hush3 util/checkpoints.pl by fekt
(1252000, uint256S("0x00000002a23866c4bc24b6d14b8039eb38530936fd7ba230cd41bbffe457c0eb"))
(1253000, uint256S("0x000000021fb79ebfda0aa2dde15ef1fc669003911bc771d1700f8b6785d86aa9"))
(1254000, uint256S("0x000000020083112cbd6ac00fff2dbbd4c72e3c1d2636138cd42a63b7fc0af798"))
(1255000, uint256S("0x00000000247e68c0c4bd2cffedf9dff84dc67e49f9c90b6df073d4c6e913856a"))
(1256000, uint256S("0x00000002556455ce2059602aa43b7dc0ed5014bc157e78e9283bc2610946720e"))
(1257000, uint256S("0x00000003119deacf7b787311ef767abb173594d22979797a58a2ad01b7bda0a5"))
(1258000, uint256S("0x000000024edab00216ccb7ef39dd16b782e14179f90aace0d812b33ecbefdde0"))
(1259000, uint256S("0x00000003016ee9e404906afe5542afa1b614be768187d8a9f9c7ebf598d76695"))
(1260000, uint256S("0x00000000b7fc90789fca4e53b5966707642d1d9ffcccc99c28fd194135d08618"))
(1261000, uint256S("0x00000001e43bbacba953a662435791e7f4bc1c3fada97d8a279c8b26598fecc7"))
(1262000, uint256S("0x00000002993a7913e93d68bf44bd0f5c0102a7ab196ed6ee4ae9ea790b197854"))
(1263000, uint256S("0x000000016bf7677b49e8df24d03c3ba6ab060356c72501de94938ad2e7be946c"))
(1264000, uint256S("0x00000002c616eed07db9e4695ac9cee6989e42a76c6f61a4e0ebe0bb5abf692f"))
(1265000, uint256S("0x000000024d31a0ef0a466f573bb7c0e0970fc52e895c3b01d95b5b38e81322ca"))
(1266000, uint256S("0x000000011e54e3519dd6ea6af0443e309c8e226e2ccd775b28cc4f12f08c0d39"))
(1267000, uint256S("0x0000000393da90dc30fde8005d7f2d2318f8785e2a32bc865bf8383f7c8ffea8"))
(1268000, uint256S("0x000000027f04b7efb776bd8420de4cc0228561aa773d59cb0b2e9f6025389322"))
(1269000, uint256S("0x000000061807ebcde0469dd2c3b3bf682864b593da8bc8c64d354108961a6514"))
(1270000, uint256S("0x00000000041c198471a04f305344aeae7650140175c97d62765861d6416a4ed1"))
(1271000, uint256S("0x00000001f0e911e3ce304f9785f4c43ae7087eca9c4cadc677c4f49659b121dc"))
(1272000, uint256S("0x000000035098a7b17ae7be1c6decf88dbca85562137c8d2200bd84cb59148788"))
(1273000, uint256S("0x00000005d5d27e58ecb84658d2c3f2d8c87bae08ee0d81c6d4cdfc347ec13ec9"))
(1274000, uint256S("0x00000001623cd2acb0005393f2378a2d1ed5603511ee806b1e04f4e677b7531b"))
(1275000, uint256S("0x0000000140a568b0870d2c6853fe3fdcd94193652ef61ba9d430989e9a521a77"))
(1276000, uint256S("0x000000046e660edfdbae93511bb48f335df7523bae3cd5bfcb77cd81525585bb"))
(1277000, uint256S("0x000000022c296e5406126bbd6040316b2706c489c58d2b7593e1ec1637d31432"))
(1278000, uint256S("0x000000012b5d649609b503398d7af1fa7e14e9e58bd8e6746d6f44bbeb311270"))
(1279000, uint256S("0x000000039deede9e29ba8c7178df43374e83d6691556103a337c58822f2501fc"))
(1280000, uint256S("0x0000000172d327c94631b30e851ada193ad0d4b05a659db7e92cdaf4a5859841"))
(1281000, uint256S("0x00000002cf093cdd98e566534b7b5aaa91ee125e71283d654a75b878f08ba015"))
(1282000, uint256S("0x0000000306c146a88cd6a2cce453ac72d632a9bebf49abf27c684b4957f8380a"))
(1283000, uint256S("0x00000004738db155d0d8b5d95abd4484962c16a40eab2047b5b20fa4c5df890e"))
(1284000, uint256S("0x00000001bba05b8445a32d3856a1e4dbe9f65a96c39ca92c654ac01e675b1076"))
(1285000, uint256S("0x00000002fbc4853d6183b848e5ad32637478358521e87a7c1febfde93c4dcaa8"))
(1286000, uint256S("0x00000002fd09e8f12b1ade668a238b4badda452869f770c20bf3edd0c9a2b984"))
(1287000, uint256S("0x0000000568e3a41c8ac6e4d5ed59630a1aeff0b957494388a4c939f206ecac0c"))
(1288000, uint256S("0x000000024cf90a1150d224e167503dd79d2261de0e5e7a7e35b04949c95b8fd6"))
(1289000, uint256S("0x00000004ecdab6f1bf5f2cfd924afefb167160a49d5aa9a2b4790b4fce190427"))
(1290000, uint256S("0x0000000305db71205f1c622693cc55fee7c3b7c26400e13e82b3855a13c40df7"))
(1291000, uint256S("0x000000032d1115be00930015cb1f6fe824349bd4ff367ec675c4c92d7b268904"))
(1292000, uint256S("0x00000000a0fa63c1264eadb0fd86f1f420c74c2b5593604897c6ebe4aa4691b5"))
(1293000, uint256S("0x00000002bfd681e56afbb24664cd056812d1347bab971b44ff957a7ecd4a54ce"))
(1294000, uint256S("0x00000000ba8ac906a4fea8b779d6272e2648a30a488c4c390f1c761fbf53e76d"))
(1295000, uint256S("0x00000000859df3b6859bdd415b8d1b1fb8c396a279c8ddd6b1f39d41cec89579"))
(1296000, uint256S("0x000000008e62f687dc9899200671a9c595e1626e29477080ab052be584349ba5"))
(1297000, uint256S("0x00000003e9d6c1cce45b1d76a775f3d6e6ebbd5caa62427ae015e954e1f14d05"))
(1298000, uint256S("0x00000000fa5a495e60cfe2c8de8d8e52c2bb1ddf335a891f69be2c7eae901dcc"))
(1299000, uint256S("0x0000000326ff88c4546f65313522fe9466b33e96af50e6a6db09dfe59193bc63"))
(1300000, uint256S("0x00000003f498d56accc70c7257bfd708a22128dda0a038499f0c984f3e9ba2c0"))
(1301000, uint256S("0x00000001313da1129ba7de5f415d211ea1e3f51ae9d910abb2624aeae15b4a56"))
(1302000, uint256S("0x000000034cdf6686f4350dcc4f1f0887bb128746afd7cc3aeba5bf8b000c636f"))
(1303000, uint256S("0x00000003dffb121ae41569ca13d851f3c45668e8ee351680c2db1871f251eb3e"))
(1304000, uint256S("0x00000000c5bb42d8bfe94087c5d129fafe2677e62edadfaa7415b8a7bb4277ff"))
(1305000, uint256S("0x0000000046e1db3cc0047a85b815b745c4a0f4af4244b79d90a57cfafdf85699"))
(1306000, uint256S("0x00000004418d213a0ecced05de5b1fcaca70fe272d37773377e02c1873d27068"))
(1307000, uint256S("0x00000001cce1afda2c61046fd571edf01bdcc5a09260fcc7727caca8e3eb6ed6"))
(1308000, uint256S("0x00000000a453c4fd6f537776b730e5b8ae4d238c2f9215ed4f6e709b8aa177ac"))
(1309000, uint256S("0x000000009c9d7cb8f66d9ccdb7ce77a3c36c8d7df74e21326ef86000627091d4"))
(1310000, uint256S("0x00000000cd97fe334d3be6f3fda419589ebf643bffab3194d5cdeb7d324d123c"))
(1311000, uint256S("0x00000004fd9a887ae0db3333544e3027fe79f59fbdf8116ca516650e165bcd52"))
(1312000, uint256S("0x0000000349b8956bf4cf1b9566580e7362dfdd512ac5f7ef6a300ce2c0cf343e"))
(1313000, uint256S("0x000000030a692fe283bdbc7e1e11f8827da5a1e7b4aa3cca3c089803af547025"))
(1314000, uint256S("0x000000034e3ff90ae3436af4d7e1caec9604c5d347bded5fc6e0b05f3d0902f8"))
(1315000, uint256S("0x000000011044536fe0741ffb747e3b0f0cf826b3103d50b41f392772ed55607c"))
(1316000, uint256S("0x000000022ca70a448e4f6693aafeb5f0eac948064188933a01cd15db835e1bc3"))
(1317000, uint256S("0x00000005b8f471f902a540463c5a8ce962a34da30157bb4c094bbfee85b3ad36"))
(1318000, uint256S("0x000000020bada11214b8cf7784286aa4e5120c14b5b5e47516f619e6411badc0"))
(1319000, uint256S("0x00000001642ce9e76b5ebe167b03fdd00d0e6d595abb09ee9bd6c033f947f2db"))
(1320000, uint256S("0x00000000995d4bafd5b3e9bcc709cf0623090008aa34c9ee6b44c815ad08bc48"))
(1321000, uint256S("0x00000001bd0fff7aff0e313d8b458568a65a395d037b6d2999328798c441d8d3"))
(1322000, uint256S("0x000000015cd85c1fc0fc6877cb6c9ff4d9ab99bc7ece23d96c468c549ee3e368"))
(1323000, uint256S("0x000000033cdd6bc9051d956dc774e7c8066ae6f2272f2cbd23a5cb34a6f21947"))
(1324000, uint256S("0x00000001feaf5da15ade7a2a7f039ef95f506dfa7c8d7a3077dc6b77106a4aa9"))
(1325000, uint256S("0x00000002ed58d3afaa3044dde92a4af3908c154895651c46b8ad24bdcd702021"))
(1326000, uint256S("0x0000000377de030a756db011af1cf8d6ea1cabec0ad4957055de3435ee1102bf"))
(1327000, uint256S("0x00000002b68d85dc8783068c6878f128c048aa85dae10c5e0495768e76b153a8"))
(1328000, uint256S("0x000000022c5ea4c4f470006d99898a1de5d783967dfc4f0759835f60a0f376d9"))
(1329000, uint256S("0x0000000448c2f62ad26c51c3481b702615acf71f40631dc384e081e579993bf2"))
(1330000, uint256S("0x000000004bfdeafb2dcdbb7b0a214c62fc4f03583f3f6f27bbe2dd78c083bc6a"))
(1331000, uint256S("0x0000000008f29e6bfeedea18387ec2df4f1518f03de03073bd402d3d84daa40d"))
(1332000, uint256S("0x00000003b6b0fdb24bcd5b132ab25d97ce116d4fce4edc70037848340f9cd6a0"))
(1333000, uint256S("0x0000000540eb80533c3ad5fb11028ef74e41cf66afeeb49d38c8e91e1b9be071"))
(1334000, uint256S("0x000000024e829222c6b338723ea69a1aaf8ca426db6f1dc5ed6a508aa4eba324"))
(1335000, uint256S("0x00000001c34ef432a6d7c5b537e4157bcdc6a2f4c3d30d25cb9bb47ff395b5a6"))
(1336000, uint256S("0x000000011cda647d4405fbcffc35ce161a057911bc551290848a56a832835c14"))
(1337000, uint256S("0x0000000297dddb61d28cd456b11c6683f5c040ea1d798462cba45ff4d9acb7aa"))
(1338000, uint256S("0x000000031a44d98fee4c721d7cf692b5c6d49c72b9e514a9eea8d7a3a980cb42"))
(1339000, uint256S("0x000000016a3b0d888eaaf488fe99202db0cadabcace4f5606e13a8021e208beb"))
(1340000, uint256S("0x0000000296642fe481256d81da12afbbfc867a6e56f7e88ee575376171a2eb2b"))
(1341000, uint256S("0x000000047f7f7df7d25d0f93873e81f317b4c59970021ff99097b90662b34886"))
(1342000, uint256S("0x00000003dee60bf850c721422ead96876a6479c0e249252cd7a0819756f214f0"))
(1343000, uint256S("0x0000000479b89d6106880dd554c9f0839893680f6aaf1d17bdd353b5ff3b690d"))
(1344000, uint256S("0x000000043e08866b7b3a2fb729934e38ed68a7158aae743dbd67e915cbbe25fa"))
(1345000, uint256S("0x000000010d28f703987f82d284a6ab34eeb9c6cdf528cfd8ea9467377b48f978"))
(1346000, uint256S("0x000000047577df762e1b9d1d36efd124d7c587e8a1b04992d012b48e1da03d1c"))
(1347000, uint256S("0x000000050e60e964649507f0abaa9041969bc292e762179cc48e370d1e85109f"))
(1348000, uint256S("0x0000000458aac55b9a6a7610abf79769ccbd21bccabe262d49313b637f360b7d"))
(1349000, uint256S("0x00000001b36d5248c6632d6f353376991a3d7ce4b6730cd777042e8eef4c2050"))
(1350000, uint256S("0x0000000040bdf5b1900a2d20f6fb7824f7f0ad2117a357ac212388bbe5238f40"))
(1351000, uint256S("0x00000004a5e89800bd3e433dc1c3f36370b14523a219ccc513e9451c6354bb86"))
(1352000, uint256S("0x000000025bda557523475832f119f8d5ebdd02f131c0004f529b0e6b16343a8e"))
(1353000, uint256S("0x000000012e20cd31e7f6eda7d0e1d1777fde4a312a4c2ce6948d629e10b196ab"))
(1354000, uint256S("0x0000000247ea366ee0719df82303d8e74aec615b2c006bb1b7d37c1d42366785"))
(1355000, uint256S("0x0000000038f84260adf0773fa051af3467e0e4bf17adf73c4a9f8cc0ae0eb52f"))
(1356000, uint256S("0x00000001b109fae9d09d98e829e273037a6209d29347485ffdee066f8f32d070"))
(1357000, uint256S("0x00000002c9047e284ad3699ee0ccd158c141ad281fe7c78bcb8cae0012e2a7a5"))
(1358000, uint256S("0x000000046e5f2a9d1b043840165ba292042ca4a6927f9451d8eb379e9f6b479f"))
(1359000, uint256S("0x00000001fe154c692d9a7255fa9657023d213d3a2b0c6025bc2942452ff0bfa7"))
(1360000, uint256S("0x00000002e0a212bc285eef4232f6805f95ef054582a43fd4b926ed23e75ec378"))
(1361000, uint256S("0x0000000170ffed44b6503976cf15289556ec5ac785c63f371990dc1dcd01c0c1"))
(1362000, uint256S("0x00000004b0a51f49dc942a4dac1c8cb7ebc3b5dc70c27488b950033543de9188"))
(1363000, uint256S("0x00000002d39b32395989ff7065d238a9e6ca9643dde76f2c4fa090da64a9dfb0"))
(1364000, uint256S("0x00000003fe2c6dafe4f7c45c2a07307864a85c649738a68fa9736990385aa1b6"))
(1365000, uint256S("0x000000006a96f8887cb0b261ff9c0947ec9a35e388354a088012e0f3587a915d"))
(1366000, uint256S("0x00000000b19f6e3ea6282cad35d25bd45f4a90799ca30de76ebfaa58360102b3"))
(1367000, uint256S("0x00000005a4c7746ba3aa321bf6d0d939b65053fd7b8993541c4382d81b1df164"))
(1368000, uint256S("0x00000005a2f3fac3d68493253cc28762ed0e7d8be207b72e9b3eba49b1301661"))
(1369000, uint256S("0x00000001d963d93ec5f029920cd5ca0f8bfca9c85ce99f84585062d2c08edca3"))
(1370000, uint256S("0x000000033c971fbcf50d26531667597acd4abf989473c10a7ecd23cd4546dc05"))
(1371000, uint256S("0x00000002a277717fd9f5b05370e9c610662ffdb6f5489e96b96bc587dc22dc70"))
(1372000, uint256S("0x00000001ef0f457f58b3523ec79d6ec265928ba5aaec6a5ee282242334883e15"))
(1373000, uint256S("0x000000005911ed4432d3077e7254e35767ca8b00a674a1b047fd0dcc12bb1e6f"))
(1374000, uint256S("0x0000000538363b8b3a25dce0a88990b96dff9787c2ec8189b70b13222008adfc"))
(1375000, uint256S("0x000000021d15ac7123e2dc7ae2de2f045165911151b898063768eca1c27e31fa"))
(1376000, uint256S("0x000000047928c3ff4ca5dec8dd99087df4770abd50469ce2bd3328346858373f"))
(1377000, uint256S("0x0000000271c0b5532f810a9ffb563d09bf74b959fb1939c741dc140ec1874d09"))
(1378000, uint256S("0x0000000048678a71baf3fdb3c5f905a78a75b6ffb02018b186693e87d8172eb4"))
(1379000, uint256S("0x00000003460b8c58481e205f842eb3fda43f313a87a303f64a8f971268fba367"))
(1380000, uint256S("0x000000023a6ce85edc04e5af620930477bea1aaf31ee262678968976717d176e"))
(1381000, uint256S("0x0000000436b6c757c06b32648e510c4249b88928921f4d0bc39371600d0d0824"))
(1382000, uint256S("0x00000001c7fd7b29c040c9c56d641ca219800d234e1eb8c640d86663de6cb335"))
(1383000, uint256S("0x00000002b9cb3b2aca628572ae964b334efc22acc8ed50500d76e834cecb264f"))
(1384000, uint256S("0x0000000550b1b189873d81707719eb1be9e2492f3897f59cf39aad447d12fe7d"))
(1385000, uint256S("0x00000002c778e98b2871165ee43f441496ed6c50e6cd97bccc82448498ca3a2b"))
(1386000, uint256S("0x000000037b6d4f8ed38297729f65b7dda39a0e297d0dff2b7ab11c31b784b5ce"))
(1387000, uint256S("0x00000002aa3edc372bb3030959ee6eda0fc188b0837d8409c073553124e31ca3"))
(1388000, uint256S("0x00000004c2ad445251b1faf327fcc6d4364d941e8b95377588d764845ce98e14"))
(1389000, uint256S("0x00000003730f20a59c6c6bfb8ee168145113eab1db437a1683c782ad59a593cc"))
(1390000, uint256S("0x00000001f4f78ddb8d92d00fea207be21bed937c632a70681a522f2b21257f30"))
(1391000, uint256S("0x0000000252c913ab26a7d67b1ef969399edc40c0cb89c564a90bca7478511d06"))
(1392000, uint256S("0x00000001a4fd677cd1510d2253223d62f3c1adc493ce88178663698aaae85ad4"))
(1393000, uint256S("0x0000000326c759d56837a8ded29af2f0628c89ea018f45f44ccc27539cda123c"))
(1394000, uint256S("0x00000006e8c60ec3bf6dbe664da6b86e29c0a6220706617b8bc024f313f600e5"))
(1395000, uint256S("0x00000001a089c52a4740433d3395e9faedca3d80bba38a5c1d51bfa5d61a82a7"))
(1396000, uint256S("0x00000009cb3a07fbfb926a75481ab04db3d1a108c73782272e184a66d55e5de9"))
(1397000, uint256S("0x00000004aa55ca33c9e6fc43f9ddd0b0f32cade6a3c0dc120c7faf60d72903ff"))
(1398000, uint256S("0x00000006091fd1a0d34b6dd29c590ba69569f910b96bcbc8434758c177f04022"))
(1399000, uint256S("0x00000003c85038020294c7c58ea8a4bec845cf6494bdf63222b31f4748fea77a"))
(1400000, uint256S("0x00000008d0941b9a5b394d19cff188a665cb8a57b89de8ad06f58fd08c6fcb8e"))
(1401000, uint256S("0x000000013a5e8cd206aad4b6b1c256e567def77a371254f2b33096f315f401f9"))
(1402000, uint256S("0x000000016587d0e9753056f74305dc05d818904248512bdc87dadc624e0be6dc"))
(1403000, uint256S("0x000000015575532cb246eb7c065b955921104a246d4fef43f14009bf2da0d9eb"))
(1404000, uint256S("0x000000055c93b66f7be3213b21f2f77eaf5e76c43060125d6cb3a91ca5ba8bd3"))
(1405000, uint256S("0x00000003df2e2b33cbeeb78d320e273880df4d6deb0e661b576052ddcaccb11c"))
(1406000, uint256S("0x00000003a9e7a1b897857b1df59931eae36855a66e39c4fe872c68440b8a77b6"))
(1407000, uint256S("0x000000007f74d842e9a2923f32a0d64bdf3bfdf9bd742bcd689a8647b487de60"))
(1408000, uint256S("0x000000004a021a23c0c31f2fcd82d757e20f2d7257880dec999061546c0309c9"))
(1409000, uint256S("0x0000000078be552c979aaf660ef8b2d6a7f3d6878975f49f6d24c0c4d70fbe07"))
(1410000, uint256S("0x000000071ffa758ba71f243c8b4106cdabaaa5ec0df9247af03f5dc9221b58b2"))
(1411000, uint256S("0x00000007be4b7695ad2a5ef100899a22efad8b142ecbc8b93d5f8d553f9286d4"))
,(int64_t) 1688026050, // time of last checkpointed block
(int64_t) 0, // total txs
(double) 2304 // txs in the last day before block 1411911
};
// END HUSH mainnet checkpoint data

View File

@@ -17,6 +17,7 @@ static const uint8_t chainparams_seed_main[] = {
0x01,0x04,0x57,0xfb,0x4c,0x21,0x00,0x00, // 87.251.76.33
0x01,0x04,0x89,0x4a,0x04,0xc6,0x00,0x00, // 137.74.4.198
0x01,0x04,0x95,0x1c,0x66,0xdb,0x00,0x00, // 149.28.102.219
0x01,0x04,0x9b,0x8a,0xe4,0x44,0x00,0x00, // 155.138.228.68
0x01,0x04,0x6b,0xae,0x46,0xfb,0x00,0x00, // 107.174.70.251
0x04,0x20,0xef,0xad,0x0c,0x95,0x3e,0x61,0xee,0x69,0x57,0x67,0xdb,0x4f,0xb7,0x8d,0xc2,0x35,0x1c,0x6b,0x96,0xf4,0x1f,0x7a,0xb4,0x06,0x09,0x3a,0x64,0x33,0xf4,0x0b,0x2c,0x94,0x00,0x00, // 56wqzfj6mhxgsv3h3nh3pdocguogxfxud55libqjhjsdh5alfsko2iqd.onion
0x04,0x20,0x3d,0x24,0x7a,0xec,0xfe,0x60,0x6e,0x3d,0x3d,0xf3,0x4f,0x35,0x12,0x29,0xdb,0x48,0x89,0x71,0x19,0xb9,0xee,0x6a,0xfd,0xb2,0x02,0xa7,0x99,0x89,0xbb,0x69,0x39,0xdb,0x00,0x00, // hushv3h6mbxd2pptj42reko3jcexcgnz5zvp3mqcu6myto3jhhn4yzyd.onion

View File

@@ -30,7 +30,7 @@
// Must be kept in sync with configure.ac , ugh!
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 9
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_REVISION 4
#define CLIENT_VERSION_BUILD 50
//! Set to true for release, false for prerelease or test build

View File

@@ -29,6 +29,8 @@ static const unsigned char REJECT_MALFORMED = 0x01;
static const unsigned char REJECT_INVALID = 0x10;
static const unsigned char REJECT_OBSOLETE = 0x11;
static const unsigned char REJECT_DUPLICATE = 0x12;
static const unsigned char REJECT_DUPLICATE_OUTPUT_PROOF = 0x13;
static const unsigned char REJECT_DUPLICATE_SPEND_PROOF = 0x14;
static const unsigned char REJECT_NONSTANDARD = 0x40;
static const unsigned char REJECT_DUST = 0x41;
static const unsigned char REJECT_INSUFFICIENTFEE = 0x42;

View File

@@ -1791,13 +1791,13 @@ int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
int32_t hush_scpublic(uint32_t tiptime)
{
// HUSH does not support public blockchains, go use something else if you want no privacy
// HUSH does not support surveillance coins, go use something else if you want no privacy
return 0;
}
int64_t hush_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,int32_t nHeight,CBlock *pblock)
int64_t hush_newcoins(int64_t *zfundsp,int32_t nHeight,CBlock *pblock)
{
CTxDestination address; int32_t i,j,m,n,vout; uint8_t *script; uint256 txid,hashBlock; int64_t zfunds=0,vinsum=0,voutsum=0,sproutfunds=0;
CTxDestination address; int32_t i,j,m,n,vout; uint8_t *script; uint256 txid,hashBlock; int64_t zfunds=0,vinsum=0,voutsum=0;
n = pblock->vtx.size();
for (i=0; i<n; i++)
{
@@ -1837,19 +1837,16 @@ int64_t hush_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,int32_t nHeight,CBl
zfunds -= tx.valueBalance;
}
*zfundsp = zfunds;
*sproutfundsp = sproutfunds;
if ( SMART_CHAIN_SYMBOL[0] == 0 && (voutsum-vinsum) == 100003*SATOSHIDEN ) // 15 times
return(3 * SATOSHIDEN);
//if ( voutsum-vinsum+zfunds > 100000*SATOSHIDEN || voutsum-vinsum+zfunds < 0 )
//. fprintf(stderr,"ht.%d vins %.8f, vouts %.8f -> %.8f zfunds %.8f\n",nHeight,dstr(vinsum),dstr(voutsum),dstr(voutsum)-dstr(vinsum),dstr(zfunds));
return(voutsum - vinsum);
}
int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height)
int64_t hush_coinsupply(int64_t *zfundsp,int32_t height)
{
CBlockIndex *pindex; CBlock block; int64_t zfunds=0,sproutfunds=0,supply = 0;
CBlockIndex *pindex; CBlock block; int64_t zfunds=0,supply = 0;
//fprintf(stderr,"coinsupply %d\n",height);
*zfundsp = *sproutfundsp = 0;
*zfundsp = 0;
if ( (pindex= hush_chainactive(height)) != 0 )
{
while ( pindex != 0 && pindex->GetHeight() > 0 )
@@ -1857,7 +1854,7 @@ int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height)
if ( pindex->newcoins == 0 && pindex->zfunds == 0 )
{
if ( hush_blockload(block,pindex) == 0 ) {
pindex->newcoins = hush_newcoins(&pindex->zfunds,&pindex->sproutfunds,pindex->GetHeight(),&block);
pindex->newcoins = hush_newcoins(&pindex->zfunds,pindex->GetHeight(),&block);
} else {
fprintf(stderr,"error loading block.%d\n",pindex->GetHeight());
return(0);
@@ -1865,13 +1862,11 @@ int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height)
}
supply += pindex->newcoins;
zfunds += pindex->zfunds;
sproutfunds += pindex->sproutfunds;
//printf("start ht.%d new %.8f -> supply %.8f zfunds %.8f -> %.8f\n",pindex->GetHeight(),dstr(pindex->newcoins),dstr(supply),dstr(pindex->zfunds),dstr(zfunds));
pindex = pindex->pprev;
}
}
*zfundsp = zfunds;
*sproutfundsp = sproutfunds;
return(supply);
}

View File

@@ -1751,7 +1751,31 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
{
return error("AcceptToMemoryPool: CheckTransaction failed");
}
// Reject duplicate output proofs in a single ztx in mempool
// Migrate this to CheckTransaction() to make it a consensus requirement
{
set<libzcash::GrothProof> vSaplingOutputProof;
BOOST_FOREACH(const OutputDescription& output, tx.vShieldedOutput)
{
if (vSaplingOutputProof.count(output.zkproof))
return state.Invalid(error("AcceptToMemoryPool: duplicate output proof"),REJECT_DUPLICATE_OUTPUT_PROOF, "bad-txns-duplicate-output-proof");
vSaplingOutputProof.insert(output.zkproof);
}
}
// Reject duplicate spend proofs in a single ztx in mempool
// Migrate this to CheckTransaction() to make it a consensus requirement
{
set<libzcash::GrothProof> vSaplingSpendProof;
BOOST_FOREACH(const SpendDescription& spend, tx.vShieldedSpend)
{
if (vSaplingSpendProof.count(spend.zkproof))
return state.Invalid(error("AcceptToMemoryPool: duplicate spend proof"),REJECT_DUPLICATE_SPEND_PROOF, "bad-txns-duplicate-spend-proof");
vSaplingSpendProof.insert(spend.zkproof);
}
}
// DoS level set to 10 to be more forgiving.
// Check transaction contextually against the set of consensus rules which apply in the next block to be mined.
if (!ContextualCheckTransaction(0,0,0,tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel))
@@ -1863,8 +1887,6 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
view.GetBestBlock();
nValueIn = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime);
if ( 0 && interest != 0 )
fprintf(stderr,"add interest %.8f\n",(double)interest/COIN);
// we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool
view.SetBackend(dummy);
}

View File

@@ -280,11 +280,16 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
vecPriority.reserve(mempool.mapTx.size() + 1);
//fprintf(stderr,"%s: going to add txs from mempool\n", __func__);
// now add transactions from the mem pool
// now add transactions from the mempool
int32_t Notarizations = 0; uint64_t txvalue;
uint32_t large_zins = 0; // number of ztxs with large number of inputs in block
uint32_t large_zouts = 0; // number of ztxs with large number of outputs in block
const uint32_t LARGE_ZINS_MAX = 1; // max ztxs with large zins per block
const uint32_t LARGE_ZOUTS_MAX = 1; // max ztxs with large zouts per block
const uint32_t LARGE_ZINS_THRESHOLD = 50; // min number of zins to be considered large
const uint32_t LARGE_ZOUTS_THRESHOLD = 10; // min number of zouts to be considered large
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
mi != mempool.mapTx.end(); ++mi)
{
mi != mempool.mapTx.end(); ++mi) {
const CTransaction& tx = mi->GetTx();
int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST)
@@ -467,6 +472,18 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
// fprintf(stderr,"%s: compared first tx from priority queue\n", __func__);
vecPriority.pop_back();
if(tx.vShieldedSpend.size() >= LARGE_ZINS_THRESHOLD && large_zins >= LARGE_ZINS_MAX) {
LogPrintf("%s: skipping ztx %s with %d zins because there are already %d ztxs with large zins\n",
__func__, tx.GetHash().ToString().c_str(), tx.vShieldedSpend.size(), LARGE_ZINS_MAX);
continue;
}
if(tx.vShieldedOutput.size() >= LARGE_ZOUTS_THRESHOLD && large_zouts >= LARGE_ZOUTS_MAX) {
LogPrintf("%s: skipping ztx %s with %d zouts because there are already %d ztxs with large zouts\n",
__func__, tx.GetHash().ToString().c_str(), tx.vShieldedOutput.size(), LARGE_ZOUTS_MAX);
continue;
}
// Size limits
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
// fprintf(stderr,"%s: nTxSize = %u\n", __func__, nTxSize);
@@ -577,6 +594,18 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
nBlockSigOps += nTxSigOps;
nFees += nTxFees;
if(tx.vShieldedOutput.size() >= LARGE_ZOUTS_THRESHOLD) {
large_zouts++;
LogPrintf("%s: txid=%s has large zouts=%d (%d large zouts in block)\n", __func__, tx.GetHash().ToString().c_str(),
tx.vShieldedOutput.size(), large_zouts );
}
if(tx.vShieldedSpend.size() >= LARGE_ZINS_THRESHOLD) {
large_zins++;
LogPrintf("%s: txid=%s has large zins=%d (%d large zins in block)\n", __func__, tx.GetHash().ToString().c_str(),
tx.vShieldedSpend.size(), large_zins );
}
if (fPrintPriority)
{
LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString());
@@ -1075,14 +1104,14 @@ void static RandomXMiner()
randomx_dataset *randomxDataset = randomx_alloc_dataset(flags);
rxdebug("%s: created dataset\n");
auto datasetItemCount = randomx_dataset_item_count();
rxdebug("%s: dataset items=%lu\n", datasetItemCount);
if( randomxDataset == nullptr) {
LogPrintf("%s: allocating randomx dataset failed!\n", __func__);
return;
}
auto datasetItemCount = randomx_dataset_item_count();
rxdebug("%s: dataset items=%lu\n", datasetItemCount);
char randomxHash[RANDOMX_HASH_SIZE];
rxdebug("%s: created randomxHash of size %d\n", RANDOMX_HASH_SIZE);
char randomxKey[82]; // randomx spec says keysize of >60 bytes is implementation-specific
@@ -1096,6 +1125,7 @@ void static RandomXMiner()
int randomxInterval = GetArg("-ac_randomx_interval",1024);
// This lag is 80 mins for 75s blocktime and 64 mins for 60s (default) blocktime for HSCs
int randomxBlockLag = GetArg("-ac_randomx_lag", 64);
randomx_vm *myVM = nullptr;
try {
// fprintf(stderr,"RandomXMiner: mining %s with randomx\n",SMART_CHAIN_SYMBOL);
@@ -1172,7 +1202,7 @@ void static RandomXMiner()
// randomx_init_dataset(randomxDataset, randomxCache, 0, datasetItemCount);
rxdebug("%s: dataset initialized\n");
randomx_vm *myVM = randomx_create_vm(flags, nullptr, randomxDataset);
myVM = randomx_create_vm(flags, nullptr, randomxDataset);
if(myVM == NULL) {
LogPrintf("RandomXMiner: Cannot create RandomX VM, aborting!\n");
return;
@@ -1398,19 +1428,35 @@ void static RandomXMiner()
} catch (const boost::thread_interrupted&) {
miningTimer.stop();
c.disconnect();
randomx_destroy_vm(myVM);
LogPrintf("%s: destroyed vm via thread interrupt\n", __func__);
randomx_release_dataset(randomxDataset);
rxdebug("%s: released dataset via thread interrupt\n");
randomx_release_cache(randomxCache);
rxdebug("%s: released cache via thread interrupt\n");
LogPrintf("HushRandomXMiner terminated\n");
throw;
} catch (const std::runtime_error &e) {
miningTimer.stop();
c.disconnect();
fprintf(stderr,"RandomXMiner: runtime error: %s\n", e.what());
randomx_destroy_vm(myVM);
LogPrintf("%s: destroyed vm because of error\n", __func__);
randomx_release_dataset(randomxDataset);
rxdebug("%s: released dataset because of error\n");
randomx_release_cache(randomxCache);
rxdebug("%s: released cache because of error\n");
return;
}
randomx_release_dataset(randomxDataset);
rxdebug("%s: released dataset\n");
rxdebug("%s: released dataset in normal exit\n");
randomx_release_cache(randomxCache);
rxdebug("%s: released cache\n");
rxdebug("%s: released cache in normal exit\n");
miningTimer.stop();
c.disconnect();
}

View File

@@ -324,7 +324,6 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
result.push_back(Pair("blocktype", "mined"));
UniValue valuePools(UniValue::VARR);
valuePools.push_back(ValuePoolDesc("sprout", blockindex->nChainSproutValue, blockindex->nSproutValue));
valuePools.push_back(ValuePoolDesc("sapling", blockindex->nChainSaplingValue, blockindex->nSaplingValue));
result.push_back(Pair("valuePools", valuePools));
@@ -1310,14 +1309,10 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& my
obj.push_back(Pair("chainwork", chainActive.LastTip()->chainPower.chainWork.GetHex()));
obj.push_back(Pair("pruned", fPruneMode));
//SproutMerkleTree tree;
//pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), tree);
//obj.push_back(Pair("commitments", static_cast<uint64_t>(tree.size())));
obj.push_back(Pair("commitments", 0));
CBlockIndex* tip = chainActive.LastTip();
UniValue valuePools(UniValue::VARR);
valuePools.push_back(ValuePoolDesc("sprout", tip->nChainSproutValue, boost::none));
valuePools.push_back(ValuePoolDesc("sapling", tip->nChainSaplingValue, boost::none));
obj.push_back(Pair("valuePools", valuePools));

View File

@@ -65,7 +65,7 @@ int32_t hush_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
extern int32_t HUSH_LASTMINED,HUSH_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC;
extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
uint32_t hush_segid32(char *coinaddr);
int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height);
int64_t hush_coinsupply(int64_t *zfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp);
uint64_t hush_notarypayamount(int32_t nHeight, int64_t notarycount);
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
@@ -416,7 +416,7 @@ public:
UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
int32_t height = 0; int32_t currentHeight; int64_t blocks_per_year,zf1,zf3,zf12,sf1,sf3,sf12,sproutfunds,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ);
int32_t height = 0; int32_t currentHeight; int64_t blocks_per_year,zf1,zf3,zf12,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ);
if (fHelp || params.size() > 1)
throw runtime_error("coinsupply <height>\n"
"\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n"
@@ -429,7 +429,6 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk)
" \"height\" : 420, (integer) The height of this coin supply data\n"
" \"supply\" : \"555.0\", (float) The transparent coin supply\n"
" \"zfunds\" : \"0.55555\", (float) The shielded coin supply (in zaddrs)\n"
" \"sprout\" : \"0.000\", (float) The sprout coin supply (in zcaddrs)\n"
" \"total\" : \"555.55555\", (float) The total coin supply, i.e. sum of supply + zfunds\n"
"}\n"
"\nExamples:\n"
@@ -442,23 +441,22 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk)
currentHeight = chainActive.Height();
if (height >= 0 && height <= currentHeight) {
if ( (supply= hush_coinsupply(&zfunds,&sproutfunds,height)) > 0 )
if ( (supply= hush_coinsupply(&zfunds,height)) > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("coin", SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL));
result.push_back(Pair("height", (int)height));
result.push_back(Pair("supply", ValueFromAmount(supply)));
result.push_back(Pair("zfunds", ValueFromAmount(zfunds)));
result.push_back(Pair("sprout", ValueFromAmount(sproutfunds)));
result.push_back(Pair("total", ValueFromAmount(zfunds + supply)));
if ( ASSETCHAINS_BLOCKTIME > 0 )
{
blocks_per_year = 24*3600*365 / ASSETCHAINS_BLOCKTIME;
if ( height > blocks_per_year )
{
supply1 = hush_coinsupply(&zf1,&sf1,height - blocks_per_year/12);
supply3 = hush_coinsupply(&zf3,&sf3,height - blocks_per_year/4);
supply12 = hush_coinsupply(&zf12,&sf12,height - blocks_per_year);
supply1 = hush_coinsupply(&zf1,height - blocks_per_year/12);
supply3 = hush_coinsupply(&zf3,height - blocks_per_year/4);
supply12 = hush_coinsupply(&zf12,height - blocks_per_year);
if ( supply1 != 0 && supply3 != 0 && supply12 != 0 )
{
result.push_back(Pair("lastmonth", ValueFromAmount(supply1+zf1)));

View File

@@ -832,7 +832,8 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params
pcmd->name != "getnotarysendmany" && pcmd->name != "geterablockheights" &&
pcmd->name != "getaddressesbyaccount" && pcmd->name != "listaddresses" && pcmd->name != "z_exportwallet" &&
pcmd->name != "notaries" && pcmd->name != "signmessage" && pcmd->name != "decoderawtransaction" &&
pcmd->name != "dumpprivkey" && pcmd->name != "getpeerinfo" && pcmd->name != "getnetworkinfo" ) {
pcmd->name != "dumpprivkey" && pcmd->name != "getpeerinfo" && pcmd->name != "getnetworkinfo" &&
pcmd->name != "abortrescan") {
throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
}
}

View File

@@ -15,6 +15,7 @@
#include <sstream>
#include <string>
#include <vector>
#include <cstdint>
[[nodiscard]] inline std::string TrimString(const std::string& str, const std::string& pattern = " \f\n\r\t\v")
{

View File

@@ -515,14 +515,15 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
auto addResult = boost::apply_visitor(
AddSpendingKeyToWallet(pwalletMain, Params().GetConsensus(), nTime, hdKeypath, seedFpStr, true), spendingkey);
if (addResult == KeyAlreadyExists){
LogPrint("zrpc", "Skipping import of zaddr (key already present)\n");
LogPrintf("%s: Skipping import of zaddr (key already present)\n", __func__);
} else if (addResult == KeyNotAdded) {
// Something went wrong
fGood = false;
LogPrintf("%s: Skipping import of zaddr (something went wrong)\n", __func__);
}
continue;
} else {
LogPrint("zrpc", "Importing detected an error: invalid spending key. Trying as a transparent key...\n");
LogPrintf("%s: Importing detected an error: invalid spending key. Trying as a transparent key...\n",__func__);
// Not a valid spending key, so carry on and see if it's a Hush transparent address
}
}

View File

@@ -3636,6 +3636,224 @@ UniValue z_listsentbyaddress(const UniValue& params, bool fHelp,const CPubKey&)
return ret;
}
UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"z_getstats\n"
"\nReturns statistics about ztxs in block height or block height range\n"
"\nArguments:\n"
"1. \"height\" (number, required) The block height\n"
"1. \"end_height\" (number, optional) The ending block height\n"
"\nResult:\n"
"\njson\n"
"\nExamples:\n"
+ HelpExampleCli("z_getstats 123", "456")
+ HelpExampleRpc("z_getstats 123", "456")
);
LOCK2(cs_main, pwalletMain->cs_wallet);
std::string strHeight = params[0].get_str();
int nHeight = -1;
try {
nHeight = std::stoi(strHeight);
} catch (const std::exception &e) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter");
}
if (nHeight < 0 || nHeight > chainActive.Height()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
}
auto strHash = chainActive[nHeight]->GetBlockHash().GetHex();
uint256 hash(uint256S(strHash));
if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlock block;
CBlockIndex* pblockindex = mapBlockIndex[hash];
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
if(!ReadBlockFromDisk(block, pblockindex,1))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
int total_ztxs = 0, total_zins = 0, total_zouts = 0;
int total_ztxs_10_or_more_zins = 0, total_ztxs_10_or_more_zouts = 0;
int total_ztxs_25_or_more_zins = 0, total_ztxs_25_or_more_zouts = 0;
int total_ztxs_50_or_more_zins = 0, total_ztxs_50_or_more_zouts = 0;
int total_ztxs_100_or_more_zins = 0, total_ztxs_100_or_more_zouts = 0;
int largest_zins = 0, largest_zouts = 0;
std::string largest_zins_txid = "", largest_zouts_txid = "";
UniValue ret(UniValue::VOBJ);
ret.pushKV("start_height", nHeight);
// given a single block height, we calculate stats for that height
if (params.size() == 1) {
BOOST_FOREACH(const CTransaction&tx, block.vtx)
{
int num_zins, num_zouts = 0;
// ignore coinbase txs which have no zins or zouts
if(!tx.IsCoinBase()) {
num_zouts = tx.vShieldedOutput.size();
num_zins = tx.vShieldedSpend.size();
// tx must have some zins and zouts to count towards our stats,
// which ignores shielding coinbase txs, which have only transparent inputs.
// This mostly will only count "z2z" txs but also counts (z,t)=>z and z=>(z,t)
// which are possible but unlikely, since RPCs cannot currently create (z,t)=>z txs
// and z=>(z,t) are disallowed when ac_private=1
if(num_zins > 0 && num_zouts > 0) {
total_ztxs++;
total_zins += num_zins;
total_zouts += num_zouts;
if (num_zins > largest_zins) {
largest_zins = num_zins;
largest_zins_txid = tx.GetHash().ToString();
}
if (num_zouts > largest_zouts) {
largest_zouts = num_zouts;
largest_zouts_txid = tx.GetHash().ToString();
}
if (num_zins >= 10) {
total_ztxs_10_or_more_zins++;
if (num_zins >= 25) {
total_ztxs_25_or_more_zins++;
if (num_zins >= 50) {
total_ztxs_50_or_more_zins++;
if (num_zins >= 100) {
total_ztxs_100_or_more_zins++;
}
}
}
}
if (num_zouts >= 10) {
total_ztxs_10_or_more_zouts++;
if (num_zouts >= 25) {
total_ztxs_25_or_more_zouts++;
if (num_zouts >= 50) {
total_ztxs_50_or_more_zouts++;
if (num_zouts >= 100) {
total_ztxs_100_or_more_zouts++;
}
}
}
}
}
}
}
} else {
// given two blocks, we calculate stats for that range
std::string strHeight2 = params[1].get_str();
int nHeight2 = -1;
try {
nHeight2 = std::stoi(strHeight2);
} catch (const std::exception &e) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid ending block height parameter");
}
if (nHeight2 <= nHeight) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Ending block height must be larger than starting height");
}
if (nHeight2 < 0 || nHeight2 > chainActive.Height()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Ending block height out of range");
}
ret.pushKV("end_height", nHeight2);
// get the stats for every block in the range
for(int currentHeight = nHeight; currentHeight <= nHeight2; currentHeight++) {
auto strHash = chainActive[currentHeight]->GetBlockHash().GetHex();
uint256 hash(uint256S(strHash));
if (mapBlockIndex.count(hash) == 0)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlock block;
CBlockIndex* pblockindex = mapBlockIndex[hash];
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
if(!ReadBlockFromDisk(block, pblockindex,1))
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
BOOST_FOREACH(const CTransaction&tx, block.vtx)
{
int num_zins, num_zouts = 0;
// ignore coinbase txs which have no zins or zouts
if(!tx.IsCoinBase()) {
num_zouts = tx.vShieldedOutput.size();
num_zins = tx.vShieldedSpend.size();
if(num_zins > 0 && num_zouts > 0) {
total_ztxs++;
total_zins += num_zins;
total_zouts += num_zouts;
}
if (num_zins > largest_zins) {
largest_zins = num_zins;
largest_zins_txid = tx.GetHash().ToString();
}
if (num_zouts > largest_zouts) {
largest_zouts = num_zouts;
largest_zouts_txid = tx.GetHash().ToString();
}
if (num_zins >= 10) {
total_ztxs_10_or_more_zins++;
if (num_zins >= 25) {
total_ztxs_25_or_more_zins++;
if (num_zins >= 50) {
total_ztxs_50_or_more_zins++;
if (num_zins >= 100) {
total_ztxs_100_or_more_zins++;
}
}
}
}
if (num_zouts >= 10) {
total_ztxs_10_or_more_zouts++;
if (num_zouts >= 25) {
total_ztxs_25_or_more_zouts++;
if (num_zouts >= 50) {
total_ztxs_50_or_more_zouts++;
if (num_zouts >= 100) {
total_ztxs_100_or_more_zouts++;
}
}
}
}
}
}
}
}
double avg_zins = total_ztxs > 0 ? (double) total_zins / total_ztxs : 0.0;
double avg_zouts = total_ztxs > 0 ? (double) total_zouts / total_ztxs : 0.0;
ret.pushKV("total_ztxs", total_ztxs);
ret.pushKV("total_zins", total_zins);
ret.pushKV("total_zouts", total_zouts);
ret.pushKV("total_ztxs_10_or_more_zins", total_ztxs_10_or_more_zins);
ret.pushKV("total_ztxs_25_or_more_zins", total_ztxs_25_or_more_zins);
ret.pushKV("total_ztxs_50_or_more_zins", total_ztxs_50_or_more_zins);
ret.pushKV("total_ztxs_100_or_more_zins", total_ztxs_100_or_more_zins);
ret.pushKV("total_ztxs_10_or_more_zouts", total_ztxs_10_or_more_zouts);
ret.pushKV("total_ztxs_25_or_more_zouts", total_ztxs_25_or_more_zouts);
ret.pushKV("total_ztxs_50_or_more_zouts", total_ztxs_50_or_more_zouts);
ret.pushKV("total_ztxs_100_or_more_zouts", total_ztxs_100_or_more_zouts);
ret.pushKV("avg_zins", avg_zins);
ret.pushKV("avg_zouts", avg_zouts);
ret.pushKV("largest_zins", largest_zins);
ret.pushKV("largest_zins_txid", largest_zins_txid);
ret.pushKV("largest_zouts", largest_zouts);
ret.pushKV("largest_zouts_txid", largest_zouts_txid);
return ret;
}
UniValue z_anonsetblockdelta(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if (!EnsureWalletIsAvailable(fHelp))
@@ -8489,6 +8707,7 @@ static const CRPCCommand commands[] =
{ "wallet", "z_listunspent", &z_listunspent, false },
{ "wallet", "z_getbalance", &z_getbalance, false },
{ "wallet", "z_getbalances", &z_getbalances, false },
{ "wallet", "z_getstats", &z_getstats, true },
{ "wallet", "z_anonsettxdelta", &z_anonsettxdelta, true },
{ "wallet", "z_anonsetblockdelta", &z_anonsetblockdelta, true },
{ "wallet", "z_gettotalbalance", &z_gettotalbalance, false },