Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8ec7550
Testing sub assets
Aug 2, 2018
4f72e4b
Add subassets rpc, fix ownership asset database problem
Aug 3, 2018
af84a7f
Remove spam logs
Aug 3, 2018
8f61c10
Remove spam logs
Aug 3, 2018
8293f6f
Fix large asset transactions failing asset check and asset serialization
Aug 7, 2018
9fd33da
Switching to DGW at a specific block.
cfox Aug 7, 2018
b760682
Under fix to CHANNEL namespace
Aug 7, 2018
b35bd9b
h
Aug 7, 2018
9fd7e54
Merge pull request #197 from RavenProject/under-channel-namespace-fix
blondfrogs Aug 8, 2018
31eb2b5
Merge pull request #195 from RavenProject/cfox-rip9v2
blondfrogs Aug 8, 2018
d8027a2
Update regex to disallow improper asset names
Aug 8, 2018
ee999c5
Add back $ to regex expression
Aug 8, 2018
82c11a6
Add -fPIC as default on Linux builds to avoid build errors. Add addi…
Aug 3, 2018
b8aad20
Merge pull request #199 from RavenProject/revert-fpic
blondfrogs Aug 8, 2018
38b322d
Set reissuable to true by default, update typos
Aug 8, 2018
9883ee2
Quick bug fix for creating new asset with ! in it. Fix typo
Aug 8, 2018
45b0346
Remove commented out code
Aug 8, 2018
ed0ea50
Merge pull request #196 from RavenProject/sub_asset_2
blondfrogs Aug 8, 2018
b3a6fa2
Fixed/ Edited a few things
UsertJonPizza Aug 6, 2018
19a96f6
Fixed typo
UsertJonPizza Aug 6, 2018
7b62d97
Merge pull request #201 from RavenProject/typo_fixes
blondfrogs Aug 8, 2018
f95a36c
Testnetv4 and some block timing for DGW (#200)
cfox Aug 8, 2018
c344555
Add sub assets to func test (#202)
blondfrogs Aug 8, 2018
59a393f
One command
Aug 9, 2018
c94460a
Fixes a test case.
cfox Aug 9, 2018
7b69824
Merge pull request #204 from RavenProject/tron-issuesubasset-to-issue
TronBlack Aug 9, 2018
25be212
Updated version to 2.0.3
cfox Aug 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 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, 2)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_REVISION, 3)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
Expand Down Expand Up @@ -446,6 +446,8 @@ case $host in
*linux*)
TARGET_OS=linux
LEVELDB_TARGET_FLAGS="-DOS_LINUX"
CXXFLAGS="$TEMP_CXXFLAGS -fPIC"
CPPFLAGS="$CPPFLAGS -fPIC"
;;
*freebsd*)
LEVELDB_TARGET_FLAGS="-DOS_FREEBSD"
Expand Down
7 changes: 1 addition & 6 deletions src/assets/assetdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,7 @@ bool CAssetsDB::LoadAssets()

bool CAssetsDB::AssetDir(std::vector<CNewAsset>& assets, const std::string filter, const size_t count, const long start)
{
// flush everything to db
LOCK(cs_main);
bool flushed = pcoinsTip->Flush();
assert(flushed);
bool assetFlushed = passets->Flush(false, true);
assert(assetFlushed);
FlushStateToDisk();

std::unique_ptr<CDBIterator> pcursor(NewIterator());
pcursor->Seek(std::make_pair(ASSET_FLAG, std::string()));
Expand Down
535 changes: 387 additions & 148 deletions src/assets/assets.cpp

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions src/assets/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,6 @@ struct CAssetOutputEntry;
// 50000 * 82 Bytes == 4.1 Mb
#define MAX_CACHE_ASSETS_SIZE 50000

enum AssetType
{
ROOT,
OWNER,
SUB,
UNIQUE,
CHANNEL,
VOTE,
INVALID
};

class CAssets {
public:
std::map<std::string, std::set<COutPoint> > mapMyUnspentAssets; // Asset Name -> COutPoint
Expand Down Expand Up @@ -309,10 +298,13 @@ CAmount GetIssueAssetBurnAmount();
CAmount GetReissueAssetBurnAmount();
CAmount GetIssueSubAssetBurnAmount();
CAmount GetIssueUniqueAssetBurnAmount();
CAmount GetBurnAmount(const AssetType type);
std::string GetBurnAddress(const AssetType type);

bool IsAssetNameValid(const std::string& name);
bool IsAssetNameValid(const std::string& name, AssetType& assetType);
bool IsAssetNameAnOwner(const std::string& name);
std::string GetParentName(const std::string& name); // Gets the parent name of a subasset TEST/TESTSUB would return TEST

bool IsAssetNameSizeValid(const std::string& name);

Expand All @@ -323,18 +315,22 @@ bool OwnerFromTransaction(const CTransaction& tx, std::string& ownerName, std::s
bool ReissueAssetFromTransaction(const CTransaction& tx, CReissueAsset& reissue, std::string& strAddress);

bool TransferAssetFromScript(const CScript& scriptPubKey, CAssetTransfer& assetTransfer, std::string& strAddress);
bool AssetFromScript(const CScript& scriptPubKey, CNewAsset& assetTransfer, std::string& strAddress);
bool AssetFromScript(const CScript& scriptPubKey, CNewAsset& asset, std::string& strAddress);
bool OwnerAssetFromScript(const CScript& scriptPubKey, std::string& assetName, std::string& strAddress);
bool ReissueAssetFromScript(const CScript& scriptPubKey, CReissueAsset& reissue, std::string& strAddress);

bool CheckIssueBurnTx(const CTxOut& txOut);
bool CheckIssueBurnTx(const CTxOut& txOut, const AssetType& type);
bool CheckReissueBurnTx(const CTxOut& txOut);

bool CheckIssueDataTx(const CTxOut& txOut);
bool CheckOwnerDataTx(const CTxOut& txOut);
bool CheckReissueDataTx(const CTxOut& txOut);
bool CheckTransferOwnerTx(const CTxOut& txOut);

bool IsScriptNewAsset(const CScript& scriptPubKey, int& nStartingIndex);
bool IsScriptOwnerAsset(const CScript& scriptPubKey, int& nStartingIndex);
bool IsScriptReissueAsset(const CScript& scriptPubKey, int& nStartingIndex);
bool IsScriptTransferAsset(const CScript& scriptPubKey, int& nStartingIndex);
bool IsScriptNewAsset(const CScript& scriptPubKey);
bool IsScriptOwnerAsset(const CScript& scriptPubKey);
bool IsScriptReissueAsset(const CScript& scriptPubKey);
Expand All @@ -360,6 +356,8 @@ bool GetMyAssetBalance(CAssetsCache& cache, const std::string& assetName, CAmoun
bool GetMyAssetBalances(CAssetsCache& cache, const std::vector<std::string>& assetNames, std::map<std::string, CAmount>& balances);
bool GetMyAssetBalances(CAssetsCache& cache, std::map<std::string, CAmount>& balances);

bool VerifyAssetOwner(const std::string& asset_name, std::set<COutPoint>& myOwnerOutPoints, std::pair<int, std::string>& error);

std::string DecodeIPFS(std::string encoded);
std::string EncodeIPFS(std::string decoded);

Expand Down
13 changes: 13 additions & 0 deletions src/assets/assettypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@

class CAssetsCache;


enum AssetType
{
ROOT,
OWNER,
SUB,
UNIQUE,
MSGCHANNEL,
VOTE,
INVALID,
REISSUE
};

class CNewAsset {
public:
std::string strName; // MAX 31 Bytes
Expand Down
1 change: 1 addition & 0 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* current network-adjusted time before the block will be accepted.
*/
static const int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60;
static const int64_t MAX_FUTURE_BLOCK_TIME_DGW = MAX_FUTURE_BLOCK_TIME / 10;

/**
* Timestamp window used as a grace period by code that compares external
Expand Down
85 changes: 77 additions & 8 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,15 @@ class CMainParams : public CChainParams {

//Global Burn Address
strGlobalBurnAddress = "RXBurnXXXXXXXXXXXXXXXXXXXXXXWUo9FV";

// DGW Activation
nDGWActivationBlock = 338778;
/** RVN End **/
}
};

/**
* Testnet (v3)
* Testnet (v4)
*/
class CTestNetParams : public CChainParams {
public:
Expand All @@ -247,8 +250,8 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].bit = 5;
consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nStartTime = 1532476800; // July 25, 2018 UTC
consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nTimeout = 1564012800; // July 25, 2019 UTC
consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nStartTime = 1533924000; // GMT: Friday, August 10, 2018 6:00:00 PM
consensus.vDeployments[Consensus::DEPLOYMENT_ASSETS].nTimeout = 1536516000; // GMT: Sunday, September 9, 2018 6:00:00 PM


// The best chain should have at least this much work.
Expand All @@ -262,14 +265,74 @@ class CTestNetParams : public CChainParams {
pchMessageStart[1] = 0x56;
pchMessageStart[2] = 0x4E;
pchMessageStart[3] = 0x54;
nDefaultPort = 18767;
nDefaultPort = 18768;
nPruneAfterHeight = 1000;

genesis = CreateGenesisBlock(1517350340, 4791361, 0x1e00ffff, 4, 5000 * COIN);
// This is used inorder to mine the genesis block. Once found, we can use the nonce and block hash found to create a valid genesis block
// /////////////////////////////////////////////////////////////////


// arith_uint256 test;
// bool fNegative;
// bool fOverflow;
// test.SetCompact(0x1e00ffff, &fNegative, &fOverflow);
// std::cout << "Test threshold: " << test.GetHex() << "\n\n";
//
// int genesisNonce = 0;
// uint256 TempHashHolding = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");
// uint256 BestBlockHash = uint256S("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// for (int i=0;i<40000000;i++) {
// genesis = CreateGenesisBlock(1533751200, i, 0x1e00ffff, 2, 5000 * COIN);
// //genesis.hashPrevBlock = TempHashHolding;
// consensus.hashGenesisBlock = genesis.GetHash();
//
// arith_uint256 BestBlockHashArith = UintToArith256(BestBlockHash);
// if (UintToArith256(consensus.hashGenesisBlock) < BestBlockHashArith) {
// BestBlockHash = consensus.hashGenesisBlock;
// std::cout << BestBlockHash.GetHex() << " Nonce: " << i << "\n";
// std::cout << " PrevBlockHash: " << genesis.hashPrevBlock.GetHex() << "\n";
// }
//
// TempHashHolding = consensus.hashGenesisBlock;
//
// if (BestBlockHashArith < test) {
// genesisNonce = i - 1;
// break;
// }
// //std::cout << consensus.hashGenesisBlock.GetHex() << "\n";
// }
// std::cout << "\n";
// std::cout << "\n";
// std::cout << "\n";
//
// std::cout << "hashGenesisBlock to 0x" << BestBlockHash.GetHex() << std::endl;
// std::cout << "Genesis Nonce to " << genesisNonce << std::endl;
// std::cout << "Genesis Merkle " << genesis.hashMerkleRoot.GetHex() << std::endl;
//
// std::cout << "\n";
// std::cout << "\n";
// int totalHits = 0;
// double totalTime = 0.0;
//
// for(int x = 0; x < 16; x++) {
// totalHits += algoHashHits[x];
// totalTime += algoHashTotal[x];
// std::cout << "hash algo " << x << " hits " << algoHashHits[x] << " total " << algoHashTotal[x] << " avg " << algoHashTotal[x]/algoHashHits[x] << std::endl;
// }
//
// std::cout << "Totals: hash algo " << " hits " << totalHits << " total " << totalTime << " avg " << totalTime/totalHits << std::endl;
//
// genesis.hashPrevBlock = TempHashHolding;
//
// return;

// /////////////////////////////////////////////////////////////////

genesis = CreateGenesisBlock(1533751200, 555705, 0x1e00ffff, 2, 5000 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();

//Test MerkleRoot and GenesisBlock
assert(consensus.hashGenesisBlock == uint256S("0x000000055c6b201ac99ed634953f92bd52239f5b26e090ce3caab6ec81bec921"));
assert(consensus.hashGenesisBlock == uint256S("0x0000006ebc14cb6777bedda407702dfbc6b273f1af956bcfd6f4f98a2eb14433"));
assert(genesis.hashMerkleRoot == uint256S("0x28ff00a867739a352523808d301f504bc4547699398d70faf2266a8bae5f3516"));

vFixedSeeds.clear();
Expand Down Expand Up @@ -319,6 +382,9 @@ class CTestNetParams : public CChainParams {

// Global Burn Address
strGlobalBurnAddress = "n1BurnXXXXXXXXXXXXXXXXXXXXXXU1qejP";

// DGW Activation
nDGWActivationBlock = 1440;
/** RVN End **/
}
};
Expand Down Expand Up @@ -377,7 +443,7 @@ class CRegTestParams : public CChainParams {
// uint256 TempHashHolding = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");
// uint256 BestBlockHash = uint256S("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// for (int i=0;i<40000000;i++) {
// genesis = CreateGenesisBlock(1524179366, i, 0x207fffff, 4, 5000 * COIN);
// genesis = CreateGenesisBlock(1533751200, i, 0x207fffff, 2, 5000 * COIN);
// //genesis.hashPrevBlock = TempHashHolding;
// consensus.hashGenesisBlock = genesis.GetHash();
//
Expand Down Expand Up @@ -420,7 +486,7 @@ class CRegTestParams : public CChainParams {
// genesis.hashPrevBlock = TempHashHolding;
//
// return;
//

// /////////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -470,6 +536,9 @@ class CRegTestParams : public CChainParams {

// Global Burn Address
strGlobalBurnAddress = "n1BurnXXXXXXXXXXXXXXXXXXXXXXU1qejP";

// DGW Activation
nDGWActivationBlock = 200;
/** RVN End **/
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class CChainParams
const std::string& IssueSubAssetBurnAddress() const { return strIssueSubAssetBurnAddress; }
const std::string& IssueUniqueAssetBurnAddress() const { return strIssueUniqueAssetBurnAddress; }
const std::string& GlobalBurnAddress() const { return strGlobalBurnAddress; }

unsigned int DGWActivationBlock() const { return nDGWActivationBlock; }
/** RVN End **/

protected:
Expand Down Expand Up @@ -136,6 +138,8 @@ class CChainParams

// Global Burn Address
std::string strGlobalBurnAddress;

unsigned int nDGWActivationBlock;
/** RVN End **/
};

Expand Down
2 changes: 1 addition & 1 deletion src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CBaseTestNetParams : public CBaseChainParams
CBaseTestNetParams()
{
nRPCPort = 18766;
strDataDir = "testnet3";
strDataDir = "testnet4";
}
};

Expand Down
6 changes: 4 additions & 2 deletions src/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight, bool
bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout, CAssetsCache* assetsCache) {

CCoinsMap::iterator it = FetchCoin(outpoint);
if (it == cacheCoins.end()) return false;
if (it == cacheCoins.end())
return false;
cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();

/** RVN START */
Expand All @@ -216,8 +217,9 @@ bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout, CAsset
/** RVN START */
if (AreAssetsDeployed()) {
if (assetsCache) {
if (!assetsCache->TrySpendCoin(outpoint, tempCoin.out))
if (!assetsCache->TrySpendCoin(outpoint, tempCoin.out)) {
return error("%s : Failed to try and spend the asset. COutPoint : %s", __func__, outpoint.ToString());
}
}
}
/** RVN END */
Expand Down
2 changes: 1 addition & 1 deletion src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Coin
}

bool IsAsset() const {
return out.scriptPubKey.IsTransferAsset() || out.scriptPubKey.IsNewAsset() || out.scriptPubKey.IsOwnerAsset() || out.scriptPubKey.IsReissueAsset();
return out.scriptPubKey.IsAssetScript();
}

size_t DynamicMemoryUsage() const {
Expand Down
5 changes: 3 additions & 2 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, CAssetsCa
return state.DoS(100, false, REJECT_INVALID, "bad-txns-txouttotal-toolarge");

/** RVN START */
if (!AreAssetsDeployed() && txout.scriptPubKey.IsAsset() && !fReindex)
if (!AreAssetsDeployed() && txout.scriptPubKey.IsAssetScript() && !fReindex)
return state.DoS(100, false, REJECT_INVALID, "bad-txns-is-asset-and-asset-not-active");

// Check for transfers that don't meet the assets units only if the assetCache is not null
Expand Down Expand Up @@ -388,8 +388,9 @@ bool Consensus::CheckTxAssets(const CTransaction& tx, CValidationState& state, c
}

// Check the input values and the output values
if (totalOutputs.size() != totalInputs.size())
if (totalOutputs.size() != totalInputs.size()) {
return state.DoS(100, false, REJECT_INVALID, "bad-tx-asset-inputs-size-does-not-match-outputs-size");
}

for (const auto& outValue : totalOutputs) {
if (!totalInputs.count(outValue.first))
Expand Down
Loading