diff --git a/src/cc/CC_made_easy.md b/src/cc/CC_made_easy.md index ada471a8e..354e99ab2 100644 --- a/src/cc/CC_made_easy.md +++ b/src/cc/CC_made_easy.md @@ -25,7 +25,7 @@ Since CC contracts run native C/C++ code, it is turing complete and that means t utxo based contracts are a bit harder to start writing than for balance based contracts. However, they are much more secure as they leverage the existing bitcoin utxo system. That makes it much harder to have bugs that issue a zillion new coins from a bug, since all the CC contract operations needs to also obey the existing bitcoin utxo protocol. -This document will be heavily example based so it will utilize many of the existing reference CC contracts. After understanding this document, you should be in a good position to start creating either a new CC contract to be integrated into komodod or to make rpc based dapps directly. +This document will be heavily example based so it will utilize many of the existing reference CC contracts. After understanding this document, you should be in a good position to start creating either a new CC contract to be integrated into hushd or to make rpc based dapps directly. Chapter 0 - Bitcoin Protocol Basics There are many aspects of the bitcoin protocol that isnt needed to understand the CC contracts dependence on it. Such details will not be discussed. The primary aspect is the utxo, unspent transaction output. Just a fancy name for txid/vout, so when you sendtoaddress some coins, it creates a txid and the first output is vout.0, combine it and txid/0 is a specific utxo. @@ -152,7 +152,7 @@ Ultimately the CC contract is all about how it constrains its inputs, but before Chapter 4 - CC rpc extensions Currently, CC contracts need to be integrated at the source level. This limits who is able to create and add new CC contracts, which at first is good, but eventually will be a too strict limitation. The runtime bindings chapter will touch on how to break out of the source based limitation, but there is another key interface level, the RPC. -By convention, each CC contract adds an associated set of rpc calls to the komodo-cli. This not only simplifies the creation of the CC contract transactions, it further will allow dapps to be created just via rpc calls. That will require there being enough foundational CC contracts already in place. As we find new usecases that cannot be implemented via rpc, then a new CC contract is made that can handle that (and more) and the power of the rpc level increases. This is a long term process. +By convention, each CC contract adds an associated set of rpc calls to the hush-cli. This not only simplifies the creation of the CC contract transactions, it further will allow dapps to be created just via rpc calls. That will require there being enough foundational CC contracts already in place. As we find new usecases that cannot be implemented via rpc, then a new CC contract is made that can handle that (and more) and the power of the rpc level increases. This is a long term process. The typical rpc calls that are added address, , return the various special CC addresses, the list of CC contract instances and info about each CC contract instance. Along with an rpc that creates a CC instance and of course the calls to invoke a CC instance. @@ -228,9 +228,9 @@ faucetfund calls FaucetFund faucetget calls FaucetGet faucetinfo calls FaucetInfo -Now you might not be a programmer, but I hope you are able to understand the above sequence. user types in a cli call, komodo-cli processes it by calling the rpc function, which in turn calls the function inside faucet.cpp +Now you might not be a programmer, but I hope you are able to understand the above sequence. user types in a cli call, hush-cli processes it by calling the rpc function, which in turn calls the function inside faucet.cpp -No magic, just simple conversion of a user command line call that runs code inside the komodod. Both the faucetfund and faucetget create properly signed rawtransaction that is ready to be broadcast to the network using the standard sendrawtransaction rpc. It doesnt automatically do this to allow the GUI to have a confirmation step with all the details before doing an irrevocable CC contract transaction. +No magic, just simple conversion of a user command line call that runs code inside the hushd. Both the faucetfund and faucetget create properly signed rawtransaction that is ready to be broadcast to the network using the standard sendrawtransaction rpc. It doesnt automatically do this to allow the GUI to have a confirmation step with all the details before doing an irrevocable CC contract transaction. faucetfund allows anybody to add funds to the faucet faucetget allows anybody to get 0.1 coins from the faucet as long as they dont violate the rules. @@ -239,7 +239,7 @@ And we come to what it is all about. The rules of the faucet. Initially it was m To make it much harder to leech, it was made so each faucetget returned only 0.1 coins (down from 1.0) so it was worth 90% less. It was also made so that it had to be to a fresh address with less than 3 transactions. Finally each txid was constrained to start and end with 00! This is a cool trick to force usage of precious CPU time (20 to 60 seconds depending on system) to generate a valid txid. Like PoW mining for the txid and I expect other CC contracts to use a similar mechanism if they want to rate limit usage. -Combined, it became such a pain to get 0.1 coins, the faucet leeching problem was solved. It might not seem like too much trouble to change an address to get another 0.1 coins, but the way things are setup you need to launch the komodod -pubkey= to change the pubkey that is active for a node. That means to change the pubkey being used, the komodod needs to be restarted and this creates a lot of issues for any automation trying to do this. Combined with the PoW required, only when 0.1 coins becomes worth a significant effort will faucet leeching return. In that case, the PoW requirement can be increased and coin amount decreased, likely with a faucet2 CC contract as I dont expect many such variations to be needed. +Combined, it became such a pain to get 0.1 coins, the faucet leeching problem was solved. It might not seem like too much trouble to change an address to get another 0.1 coins, but the way things are setup you need to launch the hushd -pubkey= to change the pubkey that is active for a node. That means to change the pubkey being used, the hushd needs to be restarted and this creates a lot of issues for any automation trying to do this. Combined with the PoW required, only when 0.1 coins becomes worth a significant effort will faucet leeching return. In that case, the PoW requirement can be increased and coin amount decreased, likely with a faucet2 CC contract as I dont expect many such variations to be needed. Chapter 7 - rewards example The next CC contract in complexity is the rewards CC contract. This is designed to capture what most people like about masternodes, without anything else, ie. the rewards! @@ -653,7 +653,7 @@ Our testing cycle went a lot faster than expected as the bugs found were few and Yes, blockchains are complicated. Chapter 13 - different languages -The current codebase is integrated into the komodod codebase, which is C/C++. However, it is possible to use different languages and integrate into the C/C++ as zcash has shown by using the rust language for some parts of the zcashd. +The current codebase is integrated into the hushd codebase, which is C/C++. However, it is possible to use different languages and integrate into the C/C++ as zcash has shown by using the rust language for some parts of the zcashd. I think any language that is compiled and can create a linkable library while being able to call and be called by C/C++ functions can be used. If you are able to make such a language binding for a simple CC contract like faucet, this will be good for a 777 KMD bounty. Of course, you need to be the first to submit a properly working pull request. diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp index 343195dfe..c1b1c9028 100644 --- a/src/cc/customcc.cpp +++ b/src/cc/customcc.cpp @@ -10,7 +10,7 @@ ./makecustom ../hush-smart-chain -ac_name=CUSTOM -ac_cclib=custom -ac_cc=2 ... - The above will rebuild komodod and get it running again + The above will rebuild hushd and get it running again */ CScript custom_opret(uint8_t funcid,CPubKey pk) diff --git a/src/cc/customcc.h b/src/cc/customcc.h index c3614d2af..c88f6333d 100644 --- a/src/cc/customcc.h +++ b/src/cc/customcc.h @@ -10,7 +10,7 @@ 3. write the actual custom_func0, custom_func1 and custom_validate in customcc.cpp - 4. ./makecustom, which builds cclib.cpp with -DBUILD_CUSTOMCC and puts the libcc.so in ~/komodo/src and rebuilds komodod + 4. ./makecustom, which builds cclib.cpp with -DBUILD_CUSTOMCC and puts the libcc.so in ~/hush3/src and rebuilds hushd 5. launch your chain with -ac_cclib=customcc -ac_cc=2 diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 83b2f8097..b1fd8635d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -129,7 +129,7 @@ std::string Rogue_pname = ""; // keystrokes retry //////////////////////// start of CClib interface -//./komodod -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & +//./hushd -ac_name=ROGUE -ac_supply=1000000 -pubkey=03951a6f7967ad784453116bc55cd30c54f91ea8a5b1e9b04d6b29cfd6b395ba6c -addnode=5.9.102.210 -ac_cclib=rogue -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60001 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc > /dev/null & // cclib newgame 17 \"[3,10]\" // cclib pending 17 diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index 6edd868b2..4feda6701 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2480,7 +2480,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi) } //////////////////////// start of CClib interface -// ./komodod -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & +// ./hushd -ac_name=SUDOKU -ac_supply=1000000 -pubkey= -addnode=5.9.102.210 -gen -genproclimit=1 -ac_cclib=sudoku -ac_perc=10000000 -ac_reward=100000000 -ac_cc=60000 -ac_script=2ea22c80203d1579313abe7d8ea85f48c65ea66fc512c878c0d0e6f6d54036669de940febf8103120c008203000401cc & /* cclib "gen" 17 \"10\" 5d13c1ad80daf37215c74809a36720c2ada90bacadb2e10bf0866092ce558432 */ diff --git a/src/hushd-testnet b/src/hushd-testnet deleted file mode 100755 index 3e36b81f7..000000000 --- a/src/hushd-testnet +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# Copyright (c) 2016-2021 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 - -# set working directory to the location of this script -DIR="$( cd "$( dirname "$( readlink -f "${BASH_SOURCE[0]}" )" )" && pwd )" -cd $DIR -DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )" -cd $DIR - -# TESTING VALUES, DO NOT USE EXCEPT FOR DEVELOPMENT -NAME=HUSH3T -# this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn -SCRIPT=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac - -# Hush was and will always be: -# The First Pure Sapling Zcash Protocol chain! -SAPLING=1 - -# Chain parameters -ERAS=3 -BLOCKTIME=150 -# 6250000 - (sprout pool at block 500,000) -SUPPLY=6178674 -FOUNDERS=1 -REWARD=0,1125000000,562500000 -PERC=11111111 -HALVING=129,340000,840000 -END=128,340000,5422111 -CLIENTNAME=GoldenSandtrout -SEEDNODE=1.2.3.4 -CCLIB=hush3 - -# CryptoConditions/Custom Consensus params -FAUCET=228 -HEIR=234 -CHANNEL=235 -ORACLE=236 -GATEWAY=241 -CCENABLE=$FAUCET,$HEIR,$CHANNEL,$ORACLE,$GATEWAY - -# jl777 dishonored his village and so Duke The Elder journeys on -# with the True Extreme Privacy Cypherpunks -KMD=${KOMODOD:-./komodod} -$KMD -ac_name=$NAME \ - -ac_sapling=$SAPLING \ - -ac_reward=$REWARD \ - -ac_halving=$HALVING \ - -ac_end=$END \ - -ac_eras=$ERAS \ - -ac_blocktime=$BLOCKTIME \ - -ac_cc=2 \ - -ac_ccenable=$CCENABLE \ - -ac_founders=$FOUNDERS \ - -ac_supply=$SUPPLY \ - -ac_perc=$PERC \ - -clientname=$CLIENTNAME \ - -ac_cclib=$CCLIB \ - -ac_script=$SCRIPT "$@" diff --git a/src/main.cpp b/src/main.cpp index fe08fe6b4..42dd82efd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -727,7 +727,7 @@ CBlockTreeDB *pblocktree = NULL; #define HUSH_ZCASH #include "hush.h" -UniValue komodo_snapshot(int top) +UniValue hush_snapshot(int top) { LOCK(cs_main); int64_t total = -1; @@ -745,7 +745,7 @@ UniValue komodo_snapshot(int top) return(result); } -bool komodo_snapshot2(std::map &addressAmounts) +bool hush_snapshot2(std::map &addressAmounts) { if ( fAddressIndex && pblocktree != 0 ) { @@ -787,7 +787,7 @@ bool hush_dailysnapshot(int32_t height) if ( undo_height == lastSnapShotHeight ) return true; std::map addressAmounts; - if ( !komodo_snapshot2(addressAmounts) ) + if ( !hush_snapshot2(addressAmounts) ) return false; // undo blocks in reverse order diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 0d48071b7..91b012b13 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1287,7 +1287,7 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp, const CPubKey& my } -UniValue komodo_snapshot(int top); +UniValue hush_snapshot(int top); UniValue getsnapshot(const UniValue& params, bool fHelp, const CPubKey& mypk) { @@ -1337,7 +1337,7 @@ UniValue getsnapshot(const UniValue& params, bool fHelp, const CPubKey& mypk) + HelpExampleRpc("getsnapshot", "1000") ); } - result = komodo_snapshot(top); + result = hush_snapshot(top); if ( result.size() > 0 ) { result.push_back(Pair("end_time", (int) time(NULL))); } else { diff --git a/src/test-hush/test_addrman.cpp b/src/test-hush/test_addrman.cpp index afded7393..29d5fc319 100644 --- a/src/test-hush/test_addrman.cpp +++ b/src/test-hush/test_addrman.cpp @@ -2,16 +2,13 @@ // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html #include - #include "addrman.h" #include #include #include - #include "hash.h" #include "random.h" #include "util/asmap.h" - #include "netbase.h" #include "chainparams.h" #include "tinyformat.h" @@ -51,7 +48,7 @@ class TestCout : public std::stringstream using namespace std; -/* xxd -i est-komodo/data/asmap.raw | sed 's/unsigned char/static unsigned const char/g' */ +/* xxd -i test-hush/data/asmap.raw | sed 's/unsigned char/static unsigned const char/g' */ static unsigned const char asmap_raw[] = { 0xfb, 0x03, 0xec, 0x0f, 0xb0, 0x3f, 0xc0, 0xfe, 0x00, 0xfb, 0x03, 0xec, 0x0f, 0xb0, 0x3f, 0xc0, 0xfe, 0x00, 0xfb, 0x03, 0xec, 0x0f, 0xb0, 0xff, diff --git a/src/txdb.cpp b/src/txdb.cpp index e6b82332a..74901bdf4 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -429,23 +429,8 @@ bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &addr uint32_t hush_segid32(char *coinaddr); #define DECLARE_IGNORELIST std::map ignoredMap = { \ - {"RReUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, \ - {"RMUF3UDmzWFLSKV82iFbMaqzJpUnrWjcT4", 1}, \ - {"RA5imhVyJa7yHhggmBytWuDr923j2P1bxx", 1}, \ - {"RBM5LofZFodMeewUzoMWcxedm3L3hYRaWg", 1}, \ - {"RAdcko2d94TQUcJhtFHZZjMyWBKEVfgn4J", 1}, \ - {"RLzUaZ934k2EFCsAiVjrJqM8uU1vmMRFzk", 1}, \ - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, \ - {"RUDrX1v5toCsJMUgtvBmScKjwCB5NaR8py", 1}, \ - {"RMSZMWZXv4FhUgWhEo4R3AQXmRDJ6rsGyt", 1}, \ - {"RRvwmbkxR5YRzPGL5kMFHMe1AH33MeD8rN", 1}, \ - {"RQLQvSgpPAJNPgnpc8MrYsbBhep95nCS8L", 1}, \ - {"RK8JtBV78HdvEPvtV5ckeMPSTojZPzHUTe", 1}, \ - {"RHVs2KaCTGUMNv3cyWiG1jkEvZjigbCnD2", 1}, \ - {"RE3SVaDgdjkRPYA6TRobbthsfCmxQedVgF", 1}, \ - {"RW6S5Lw5ZCCvDyq4QV9vVy7jDHfnynr5mn", 1}, \ - {"RTkJwAYtdXXhVsS3JXBAJPnKaBfMDEswF8", 1}, \ - {"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} \ + {"RUeUxSs5hGE39ELU23DfydX8riUuzdrHAE", 1}, \ + {"R2d2gnrMpPaTSMn8vai6yiGA7mN4QGPVMY", 1} \ }; bool CBlockTreeDB::Snapshot2(std::map &addressAmounts, UniValue *ret)