Commit Graph

18 Commits

Author SHA1 Message Date
tomFlowee 7b0949031f Rename CHashWriter::GetHash to finalizeHash()
as the expected behavior of 'get*' is a const method, it is harmful to
name a method such when it actually alters the state of the method such
that subsequent calls will produce a different result.
2021-01-20 22:51:48 +01:00
tomFlowee 235df9c5f0 Add loading of DSProof from a constbuffer. 2021-01-20 21:35:20 +01:00
TomZ 54329bf9e4 Add new DSP test to check for stupid usage :) 2020-09-30 10:27:51 +02:00
TomZ 14a938d54c Add speed test
To make sure that a pair of really large transactions being used
to create a DSP doesn't cause a blocking thread, this runs a
benchmark on a pair of transactions with 300 inputs each, causing
45k comparisons to be made.
On my laptop this results in 0.6 msecs for this creation of the DSP.
2020-09-29 20:35:41 +02:00
TomZ fdaa6e4a81 Import some improvements from Calin.
* API docs
* Fix possible race condition in addOrphan()
* Reject proofs that violate simple constraints
* clear up possible confusing API (first/double spender getters).
2020-09-29 17:33:20 +02:00
TomZ 337b34ea8e Update error message
We seem to be having a LOT of p2sh double spends on mainnet today,
which caused confusion with people reading the logs.
This clarifies that the current version only supports p2pkh and we
need more research to support others too.
2020-08-10 10:13:02 +02:00
TomZ b51d15e3c5 Add some more comments and sanity checks 2020-05-03 19:52:44 +02:00
TomZ 2f7f7cec4c Nicely initialize the variable every loop 2020-04-24 10:41:55 +02:00
TomZ e101591f1a Refactor ScriptEval/ScriptVerify calls
Feeling cute, may update this API later.

namespace Script {
struct State {
    State() = default;
    State(uint32_t flags) : flags(flags) {}
    uint32_t flags = SCRIPT_VERIFY_NONE; // validation flags
    ScriptError error = SCRIPT_ERR_OK;

    const char* errorString() const;
};

bool eval(std::vector<std::vector<unsigned char> > &stack, const CScript
    &script, const BaseSignatureChecker checker, Script::State &state);
bool verify(const CScript& scriptSig, const CScript& scriptPubKey, const
    BaseSignatureChecker& checker, Script::State &state);
bool checkTransactionSignatureEncoding(const std::vector<unsigned char>
    &vchSig, State &state);
}

More of the same.
2020-04-12 18:08:09 +02:00
TomZ 4bea1f55c4 use QElapsedTimer 2020-01-30 15:29:03 +01:00
TomZ 6e6f43a0d4 Remember peerID in DSP-orphanage
So when we adopt one proof, and it turns out to be faulty, we can
punish the peer.
2020-01-12 18:06:23 +01:00
TomZ 071629852a Treat DSP orphans with dignity
This improves the double spend proof orphans code.
Also add a DSProof log-category and lots of log lines to make
looking at a debug build much more fun.
2020-01-12 17:41:53 +01:00
TomZ d6a2488b5c Cleanup some DSP issues
remove the need for 'flags' as this code block doesn't use the
current flags at all.

Also validate proofs that were restored from orphan cache.
2020-01-12 17:10:29 +01:00
TomZ 2b68d149de Cleanups 2020-01-05 16:47:49 +01:00
TomZ 71f0dcf942 Fixlets
Add 'override' keyword on various places.
Make test output a more readable should it fail.
2019-10-10 19:20:04 +02:00
TomZ 922d8b1f16 Fixlets in types 2019-10-05 16:08:37 +02:00
TomZ 9107d7d3b9 Change member from CScript to ConstBuffer
The Tx::Output struct can do better by keeping the ConstBuffer as
converting to CScript is cheap, the other way around is not.
2019-10-05 16:08:37 +02:00
TomZ 19bbfe4ce0 Add the concept of DoubleSpendProofs
The DSP is owned by the DoubleSpendProofStorage, which in turn
is owned by the mempool.
Each mempool-entry can refer to one proof.
2019-09-02 23:33:12 +02:00