Skip to content

Commit

Permalink
remove legacy peg-in/withdrawlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Nov 6, 2017
1 parent b2bbc67 commit 65ed777
Show file tree
Hide file tree
Showing 42 changed files with 178 additions and 1,793 deletions.
232 changes: 0 additions & 232 deletions qa/rpc-tests/pegging.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ endif

libelementsconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info 1:0:0 $(RELDFLAGS)
libelementsconsensus_la_LIBADD = $(LIBSECP256K1)
libelementsconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL -DBITCOIN_SCRIPT_NO_CALLRPC
libelementsconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
libelementsconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

endif
Expand Down
1 change: 0 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ BITCOIN_TESTS =\
test/hash_tests.cpp \
test/key_tests.cpp \
test/limitedmap_tests.cpp \
test/lockedutxo_tests.cpp \
test/withdrawspent_tests.cpp \
test/dbwrapper_tests.cpp \
test/main_tests.cpp \
Expand Down
4 changes: 2 additions & 2 deletions src/bench/mempool_eviction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ static void AddTx(const CTransaction& tx, const CAmount& nFee, CTxMemPool& pool)
unsigned int nHeight = 1;
bool spendsCoinbase = false;
unsigned int sigOpCost = 4;
std::set<std::pair<uint256, COutPoint> > setWithdrawsSpent;
std::set<std::pair<uint256, COutPoint> > setPeginsSpent;
LockPoints lp;
pool.addUnchecked(tx.GetHash(), CTxMemPoolEntry(
MakeTransactionRef(tx), nFee, nTime, dPriority, nHeight,
0, spendsCoinbase, sigOpCost, lp, setWithdrawsSpent));
0, spendsCoinbase, sigOpCost, lp, setPeginsSpent));
}

// Right now this is only testing eviction performance in an extremely small
Expand Down
2 changes: 1 addition & 1 deletion src/bench/verify_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void VerifyScriptBench(benchmark::State& state)
txCredit.vout[0].scriptPubKey,
&txSpend.wit.vtxinwit[0].scriptWitness,
flags,
MutableTransactionNoWithdrawsSignatureChecker(&txSpend, 0, txCredit.vout[0].nValue),
MutableTransactionSignatureChecker(&txSpend, 0, txCredit.vout[0].nValue),
&err);
assert(err == SCRIPT_ERR_OK);
assert(success);
Expand Down
68 changes: 6 additions & 62 deletions src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,10 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)

// ... and merge in other signatures:
BOOST_FOREACH(const CTransaction& txv, txVariants)
sigdata = CombineSignatures(prevPubKey, MutableTransactionNoWithdrawsSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
UpdateTransaction(mergedTx, i, sigdata);

if (!VerifyScript(txin.scriptSig, prevPubKey, (mergedTx.wit.vtxinwit.size() > i) ? &mergedTx.wit.vtxinwit[i].scriptWitness : NULL, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionNoWithdrawsSignatureChecker(&mergedTx, i, amount)))
if (!VerifyScript(txin.scriptSig, prevPubKey, (mergedTx.wit.vtxinwit.size() > i) ? &mergedTx.wit.vtxinwit[i].scriptWitness : NULL, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&mergedTx, i, amount)))
fComplete = false;
}

Expand All @@ -716,58 +716,6 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
tx = mergedTx;
}

static void MutateTxPeginSign(CMutableTransaction& tx, const std::string& flagStr)
{
if (!registers.count("peginkeys"))
throw std::runtime_error("peginkeys register variable must be set.");
UniValue keysObj = registers["peginkeys"];

if (!keysObj.isObject())
throw std::runtime_error("peginkeysObjs must be an object");
std::map<std::string,UniValue::VType> types = boost::assign::map_list_of("contract",UniValue::VSTR)("txoutproof",UniValue::VSTR)("tx",UniValue::VSTR)("nout",UniValue::VNUM);
if (!keysObj.checkObject(types))
throw std::runtime_error("peginkeysObjs internal object typecheck fail");

std::vector<unsigned char> contractData(ParseHexUV(keysObj["contract"], "contract"));
std::vector<unsigned char> txoutproofData(ParseHexUV(keysObj["txoutproof"], "txoutproof"));
std::vector<unsigned char> txData(ParseHexUV(keysObj["tx"], "tx"));
int nOut = atoi(keysObj["nout"].getValStr());

if (contractData.size() != 40)
throw std::runtime_error("contract must be 40 bytes");

CDataStream ssProof(txoutproofData,SER_NETWORK, PROTOCOL_VERSION);
Sidechain::Bitcoin::CMerkleBlock merkleBlock;
ssProof >> merkleBlock;

CDataStream ssTx(txData, SER_NETWORK, PROTOCOL_VERSION);
Sidechain::Bitcoin::CTransactionRef txBTCRef;
ssTx >> txBTCRef;
Sidechain::Bitcoin::CTransaction txBTC(*txBTCRef);

std::vector<uint256> transactionHashes;
std::vector<unsigned int> transactionIndices;
if (!CheckBitcoinProof(merkleBlock.header.GetHash(), merkleBlock.header.nBits) ||
merkleBlock.txn.ExtractMatches(transactionHashes, transactionIndices) != merkleBlock.header.hashMerkleRoot ||
transactionHashes.size() != 1 ||
transactionHashes[0] != txBTC.GetHash())
throw std::runtime_error("txoutproof is invalid or did not match tx");

if (nOut < 0 || (unsigned int) nOut >= txBTC.vout.size())
throw std::runtime_error("nout must be >= 0, < txout count");

CScript scriptSig;
scriptSig << contractData;
scriptSig.PushWithdraw(txoutproofData);
scriptSig.PushWithdraw(txData);
scriptSig << nOut;

//TODO: Verify the withdraw proof
for (unsigned int i = 0; i < tx.vin.size(); i++) {
tx.vin[i].scriptSig = scriptSig;
}
}

class Secp256k1Init
{
ECCVerifyHandle globalVerifyHandle;
Expand Down Expand Up @@ -815,17 +763,13 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
} else if (command == "blind") {
if (!ecc) { ecc.reset(new Secp256k1Init()); }
MutateTxBlind(tx, commandVal);
} else if (command == "peginsign")
MutateTxPeginSign(tx, commandVal);

else if (command == "load")
} else if (command == "load") {
RegisterLoad(commandVal);

else if (command == "set")
} else if (command == "set") {
RegisterSet(commandVal);

else
} else {
throw std::runtime_error("unknown command");
}
}

static void OutputTxJSON(const CTransaction& tx)
Expand Down
1 change: 0 additions & 1 deletion src/consensus/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ static const unsigned char REJECT_NONSTANDARD = 0x40;
static const unsigned char REJECT_DUST = 0x41;
static const unsigned char REJECT_INSUFFICIENTFEE = 0x42;
static const unsigned char REJECT_CHECKPOINT = 0x43;
static const unsigned char REJECT_SCRIPT = 0x44;

/** Capture information about block/transaction validation */
class CValidationState {
Expand Down
9 changes: 0 additions & 9 deletions src/policy/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,6 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
{
const CTxOut& prev = mapInputs.GetOutputFor(tx.vin[i]);

if (prev.scriptPubKey.IsWithdrawLock()) {
if (!tx.vin[i].scriptSig.IsWithdrawProof()) {
if (tx.vout.size() < i)
if (!tx.vout[i].nValue.IsExplicit() || tx.vout[i].nValue.GetAmount() > MAX_MONEY / 100)
return false;
}
continue;
}

// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
// keys. (remember the 520 byte limit on redeemScript size) That works
// out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627
Expand Down
Loading

0 comments on commit 65ed777

Please sign in to comment.