Once men turned their thinking over to machines in the hope that this would set them free.

But that only permitted other men with machines to enslave them.

      --  Reverend Mother Gaius Helen Mohiam
This commit is contained in:
Duke Leto
2020-12-09 07:23:08 -05:00
parent 710559576c
commit 6a30b40415
30 changed files with 346 additions and 458 deletions

View File

@@ -1,3 +1,6 @@
// Copyright (c) 2016-2020 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. *
* *
@@ -13,10 +16,7 @@
* *
******************************************************************************/
/*
CCutils has low level functions that are universally useful for all contracts.
*/
// CCutils has low level functions that are universally useful for all contracts.
#include "CCinclude.h"
#include "hush_structs.h"
#include "key_io.h"
@@ -28,7 +28,7 @@
#endif // TESTMODE
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
struct hush_state *hush_stateptr(char *symbol,char *dest);
extern uint32_t KOMODO_DPOWCONFS;
extern uint32_t HUSH_DPOWCONFS;
void endiancpy(uint8_t *dest,uint8_t *src,int32_t len)
{
@@ -823,12 +823,12 @@ int64_t TotalPubkeyCCInputs(const CTransaction &tx, const CPubKey &pubkey)
bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector<uint8_t> paramsNull,const CTransaction &ctx, unsigned int nIn)
{
CTransaction createTx; uint256 assetid,assetid2,hashBlock; uint8_t funcid; int32_t height,i,n,from_mempool = 0; int64_t amount; std::vector<uint8_t> origpubkey;
height = KOMODO_CONNECTING;
if ( KOMODO_CONNECTING < 0 ) // always comes back with > 0 for final confirmation
height = HUSH_CONNECTING;
if ( HUSH_CONNECTING < 0 ) // always comes back with > 0 for final confirmation
return(true);
if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE )
return eval->Invalid("CC are disabled or not active yet");
if ( (KOMODO_CONNECTING & (1<<30)) != 0 )
if ( (HUSH_CONNECTING & (1<<30)) != 0 )
{
from_mempool = 1;
height &= ((1<<30) - 1);
@@ -836,7 +836,7 @@ bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector<uint8_t> param
if (cp->validate == NULL)
return eval->Invalid("validation not supported for eval code");
//fprintf(stderr,"KOMODO_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE);
//fprintf(stderr,"HUSH_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE);
// there is a chance CC tx is valid in mempool, but invalid when in block, so we cant filter duplicate requests. if any of the vins are spent, for example
//txid = ctx.GetHash();
//if ( txid == cp->prevtxid )
@@ -869,12 +869,12 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector<uint8_t> paramsNull,co
fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME.c_str());
return eval->Invalid("-ac_cclib name mismatches myname");
}
height = KOMODO_CONNECTING;
if ( KOMODO_CONNECTING < 0 ) // always comes back with > 0 for final confirmation
height = HUSH_CONNECTING;
if ( HUSH_CONNECTING < 0 ) // always comes back with > 0 for final confirmation
return(true);
if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE )
return eval->Invalid("CC are disabled or not active yet");
if ( (KOMODO_CONNECTING & (1<<30)) != 0 )
if ( (HUSH_CONNECTING & (1<<30)) != 0 )
{
from_mempool = 1;
height &= ((1<<30) - 1);

View File

@@ -215,8 +215,8 @@ bool Eval::ImportPayout(const std::vector<uint8_t> params, const CTransaction &i
// Check disputeTx solves momproof from vout[0]
{
NotarisationData data(0);
if (!GetNotarisationData(proof.notarisationHash, data))
NotarizationData data(0);
if (!GetNotarizationData(proof.notarisationHash, data))
return Invalid("coudnt-load-mom");
if (data.MoM != proof.branch.Exec(disputeTx.GetHash()))

View File

@@ -1,4 +1,6 @@
// Copyright © 2019-2020 The Hush Developers
// Copyright (c) 2016-2020 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. *
* *
@@ -13,10 +15,8 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#include <assert.h>
#include <cryptoconditions.h>
#include "primitives/block.h"
#include "primitives/transaction.h"
#include "script/cc.h"
@@ -27,15 +27,12 @@
#include "chain.h"
#include "core_io.h"
#include "crosschain.h"
#define FAUCET2SIZE COIN
#define EVAL_FAUCET2 EVAL_FIRSTUSER
#ifdef BUILD_ROGUE
#define EVAL_ROGUE 17
std::string MYCCLIBNAME = (char *)"rogue";
#elif BUILD_CUSTOMCC
#include "customcc.h"
@@ -446,13 +443,12 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
else return eval->Invalid("invalid evalcode");
#endif
}
numvins = tx.vin.size();
numvouts = tx.vout.size();
numvins = tx.vin.size();
numvouts = tx.vout.size();
preventCCvins = preventCCvouts = -1;
if ( numvouts < 1 )
if ( numvouts < 1 ) {
return eval->Invalid("no vouts");
else
{
} else {
for (i=0; i<numvins; i++)
{
if ( IsCCInput(tx.vin[0].scriptSig) == 0 )
@@ -462,13 +458,10 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
}
}
//fprintf(stderr,"check amounts\n");
if ( CClibExactAmounts(cp,eval,tx,1,10000) == false )
{
if ( CClibExactAmounts(cp,eval,tx,1,10000) == false ) {
fprintf(stderr,"faucetget invalid amount\n");
return false;
}
else
{
} else {
preventCCvouts = 1;
if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) != 0 )
{

View File

@@ -181,13 +181,13 @@ bool Eval::CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t t
}
// Get MoM from a notarisation tx hash (on HUSH)
bool Eval::GetNotarisationData(const uint256 notaryHash, NotarisationData &data) const
bool Eval::GetNotarizationData(const uint256 notaryHash, NotarizationData &data) const
{
CTransaction notarisationTx;
CBlockIndex block;
if (!GetTxConfirmed(notaryHash, notarisationTx, block)) return false;
if (!CheckNotaryInputs(notarisationTx, block.GetHeight(), block.nTime)) return false;
if (!ParseNotarisationOpReturn(notarisationTx, data)) return false;
if (!ParseNotarizationOpReturn(notarisationTx, data)) return false;
return true;
}
@@ -205,9 +205,9 @@ std::string Eval::GetAssetchainsSymbol() const
/*
* Notarisation data, ie, OP_RETURN payload in notarisation transactions
* Notarization data, ie, OP_RETURN payload in notarisation transactions
*/
bool ParseNotarisationOpReturn(const CTransaction &tx, NotarisationData &data)
bool ParseNotarizationOpReturn(const CTransaction &tx, NotarizationData &data)
{
if (tx.vout.size() < 2) return false;
std::vector<unsigned char> vdata;

View File

@@ -69,7 +69,7 @@ typedef uint8_t EvalCode;
class AppVM;
class NotarisationData;
class NotarizationData;
class Eval
@@ -110,7 +110,7 @@ public:
virtual bool GetSpendsConfirmed(uint256 hash, std::vector<CTransaction> &spends) const;
virtual bool GetBlock(uint256 hash, CBlockIndex& blockIdx) const;
virtual int32_t GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t timestamp) const;
virtual bool GetNotarisationData(uint256 notarisationHash, NotarisationData &data) const;
virtual bool GetNotarizationData(uint256 notarisationHash, NotarizationData &data) const;
virtual bool CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const;
virtual uint32_t GetAssetchainsCC() const;
virtual std::string GetAssetchainsSymbol() const;
@@ -160,10 +160,10 @@ extern char SMART_CHAIN_SYMBOL[65];
/*
* Data from notarisation OP_RETURN from chain being notarised
*/
class NotarisationData
class NotarizationData
{
public:
int IsBackNotarisation = 0;
int IsBackNotarization = 0;
uint256 blockHash = uint256();
uint32_t height = 0;
uint256 txHash = uint256();
@@ -174,7 +174,7 @@ public:
uint256 MoMoM = uint256();
uint32_t MoMoMDepth = 0;
NotarisationData(int IsBack=2) : IsBackNotarisation(IsBack) {
NotarizationData(int IsBack=2) : IsBackNotarization(IsBack) {
symbol[0] = '\0';
}
@@ -183,8 +183,8 @@ public:
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
bool IsBack = IsBackNotarisation;
if (2 == IsBackNotarisation) IsBack = DetectBackNotarisation(s, ser_action);
bool IsBack = IsBackNotarization;
if (2 == IsBackNotarization) IsBack = DetectBackNotarization(s, ser_action);
READWRITE(blockHash);
READWRITE(height);
@@ -219,7 +219,7 @@ public:
}
template <typename Stream>
bool DetectBackNotarisation(Stream& s, CSerActionUnserialize act)
bool DetectBackNotarization(Stream& s, CSerActionUnserialize act)
{
if (SMART_CHAIN_SYMBOL[0]) return 1;
if (s.size() >= 72) {
@@ -230,14 +230,14 @@ public:
}
template <typename Stream>
bool DetectBackNotarisation(Stream& s, CSerActionSerialize act)
bool DetectBackNotarization(Stream& s, CSerActionSerialize act)
{
return !txHash.IsNull();
}
};
bool ParseNotarisationOpReturn(const CTransaction &tx, NotarisationData &data);
bool ParseNotarizationOpReturn(const CTransaction &tx, NotarizationData &data);
/*

View File

@@ -79,8 +79,8 @@ bool Eval::ImportPayout(const std::vector<uint8_t> params, const CTransaction &i
// Check disputeTx solves momproof from vout[0]
{
NotarisationData data;
if (!GetNotarisationData(proof.notarisationHash, data))
NotarizationData data;
if (!GetNotarizationData(proof.notarisationHash, data))
return Invalid("coudnt-load-mom");
if (data.MoM != proof.Exec(disputeTx.GetHash()))