Commit Graph

12090 Commits

Author SHA1 Message Date
TomZ 16168bc541 slight fixes in logging 2020-05-05 10:56:57 +02:00
TomZ bf76c5ab36 Write all bytes after command to zero.
Instead of just a single trailing zero, write all bytes of the
command-section. This is required by the protocol.
2020-05-05 10:54:26 +02:00
TomZ c2dd23d89b Merge branch '2020.03' 2020-05-03 21:02:50 +02:00
TomZ 3f16f6224a Fix the threading model in the P2PNet
This allows deletion of peers also from other threads than their own
assigned ones.
2020-05-03 21:02:45 +02:00
TomZ b51d15e3c5 Add some more comments and sanity checks 2020-05-03 19:52:44 +02:00
TomZ 2298df4935 Make peer shutdown safer.
This avoids a race condition on remove/delete of peer where
the connection manager decides to delete a peer while in its own thread
the peer is processing a package.
This moves deletion of the peer to its own strand.
2020-04-27 15:47:15 +02:00
TomZ 43ea10d9ef Prioritize the actually maintained seed 2020-04-27 11:39:57 +02:00
TomZ 164b2b4f18 Also disconnect peers that failed the version msg
When during parsing of the version message an error was found,
we should still disconnect it after 30 seconds when it doesn't
recover.
2020-04-27 11:38:53 +02:00
TomZ 6e10b8d435 P2PNet: Fixes and some new methods 2020-04-26 16:20:45 +02:00
TomZ 488fc14ece Merge branch '2020.03' 2020-04-24 10:52:39 +02:00
TomZ 2f7f7cec4c Nicely initialize the variable every loop 2020.03.2 2020-04-24 10:41:55 +02:00
TomZ d71cc4b84b [CMake] rename 'find' files to the package name
Resolve inconsistencies
2020-04-22 17:58:42 +02:00
TomZ 25ffc84f80 Introduce new lib p2p
We reuse the NetworkManager lower level code in order to connect
to the Bitcoin P2P network.
This implements the basics for anyone wanting to be a player on
this network.
2020-04-20 21:49:03 +02:00
TomZ 37d8209d64 use constexpr 2020-04-17 17:32:16 +02:00
TomZ 2870f42ad3 Split PartialMerkleTree out into its own header.
Additionally:
- add loading to it from a P2PParser
- move code from header to cpp file
2020-04-17 17:31:46 +02:00
TomZ e5ee37fd87 Fix larger messages in LegacyP2P mode.
Splitting up the bigger message in chunks is not supported on the legacy
p2p network, so don't attempt.
2020-04-16 17:12:57 +02:00
TomZ 4506e3d639 Start new streaming classes for the p2p protocol
And implemnt saving in the bloom filter for test
2020-04-16 17:12:57 +02:00
TomZ daabb551eb master is not a release 2020-04-13 18:36:02 +02:00
TomZ dc95dae34a new version 2020.03.1 2020-04-13 18:35:32 +02:00
TomZ 01bc6a4d71 fix url to online help 2020-04-13 18:15:54 +02:00
TomZ 63021917ed Fixlet in secp256k1/CMakeLists.txt 2020-04-13 15:57:42 +02:00
TomZ 3f08053db3 Fix compile
In case the BENCHMARK feature is enabled (by removing the comment in the
private header) this would fail to compile due to a refactor some time
ago.
2020-04-13 15:57:42 +02:00
TomZ 2aa462f8bb Replace SigOps with SigChecks
This is part of the protocol upgrade for 2020-05-15, and in general it
seems to go the direction of "we did this before, lets do this again".

The spec is clear enough, but there is still a lack of questioning and
testing. The problem this attempts to fix has been neutered for years[1].

The spec states:
> The essential idea of SigChecks is to perform counting solely in the
> spending transaction, and count actual executed signature check
> operations.

This, however nobel and logical, ignores that the
check-for-being-too-costly just pulled in a UTXO lookup and the loading
of the output script from the historical chain.
The goal that we protect against CPU over-use may be reached, but the
price is a total system slowdown. You can have multiple CPUs, but the
bus to permanent storage has one, max 2 parallel pipes.

To ensure theHub stays the number one scalable node, I didn't blindly
follow the spec, while making sure that the Hub is correctly going to
follow/reject consensus violations of newly mined blocks.

As a result the implementation in Flowee the Hub:

* does not check sigcheck-counts on historical blocks (more than 1000
  blocks in the past).

  This may increase the risk of chain-splits ever so slightly, but the cost
  of disk-IO would be too high.

* No longer stores the value in the mempool, nor uses it for the
  CPU-miner.

* Ties the sigcheck-limits to the user-set block-size-accept-limit.

  This is contrary to the spec which mistakenly thinks that BCH has a
  max block-size in the consensus rules. The effect is the same, though.

* The per-intput standardness suggestion is not implemented because
  standardness checks don't currently fetch the previous outputs and
  that would be too expensive to add.

* Standardness rules for the whole transaction are moved to the
  mempool-acceptance logic instead. The cost would be too great
  otherwise, similar to the previous point.
  Again, the effect is the same as likely intented.

---
1) since the intro of the CachingTransactionSignatureChecker
2020-04-13 15:57:42 +02:00
TomZ 0386f38cc1 Inline CScriptCheck
It was only called twice, and in very close proximity. The class didn't
add anything.
This improves readability and with the new state its easier to write
too.
2020-04-13 13:44:18 +02:00
TomZ 916cb9b5d7 Start sigCheck implementation; actually count them.
Update Script::State to add a sigCheckCount counter.
2020-04-12 18:08:51 +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 1882bed839 remove dead code 2020-04-11 17:05:39 +02:00
TomZ 337598a8bb Remove unused files 2020-04-11 17:04:14 +02:00
TomZ fd7a75bc2f Make sure this builds also without build.h 2020-04-10 21:13:12 +02:00
TomZ 5383f86c7c Remove automake detection 2020-04-10 20:39:00 +02:00
TomZ 9195ad96e1 Add May Protocol Upgrade activation code 2020-04-10 17:28:02 +02:00
TomZ 414bee9e9f Implementation of OP_REVERSEBYTES
Previously named OP_REVERSE, then OP_BSWAP, then OP_ENDIAN_REVERSE.
2020-04-10 15:17:18 +02:00
TomZ 4733554817 Make bloom class more modern
This follows the coding style (method naming) better and it adds
an insert method which uses a Streaming::ConstBuffer argument.
2020-04-10 12:21:49 +02:00
TomZ d9a248e484 protobuf is actually not a requirement
protobuf is only needed if you build the GUI (hub-qt), which is
not compiled by default.
2020-04-10 12:08:32 +02:00
TomZ fcdb52d5aa Make leveldb build with cmake
As this now means we completely use cmake, remove some legacy
stuff as well.
2020-04-08 22:48:29 +02:00
TomZ e8028035a1 make univalue build using cmake 2020-04-08 22:48:29 +02:00
TomZ 1144f013a4 Build secp256k1 with cmake 2020-04-08 22:48:29 +02:00
TomZ f215e89765 Import the new code-of-conduct
This is imported from
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
because why re-invent the wheel.
2020-04-07 22:25:07 +02:00
TomZ 14bd55defb Extend warning message for configure 2020-04-07 22:24:37 +02:00
TomZ ba76c35a7d Move merkle to flowee_utils libs
Merkle-block and merkle-tree classes and methods are pretty much stand-
alone and can be moved with no efforts.

Also move the relevent unit test to qtestlib.
2020-04-01 22:53:07 +02:00
TomZ 9276a45faf Move bloom filters to flowee_utils lib
Also move its unit test from the boost to qtestlib
2020-04-01 22:24:26 +02:00
TomZ 655d9fecb9 Port a log-line. 2020-04-01 20:24:08 +02:00
TomZ 436535647f Add several new features to networkmanager
Allow user to shutdown a connection, making it instantly invalid.
Allow user to register a callback for errors.
And fix pinging to be disabled on legacyP2P style connections.
2020-04-01 20:24:04 +02:00
TomZ 24e557f566 Stop double applying of offset.
We already removed the bytes in Message::header()
2020-04-01 20:22:55 +02:00
TomZ 40cad6112c Pass by reference 2020-04-01 20:22:55 +02:00
TomZ 655179e660 Add EndPoint::from() from a byte-array
This is used on the p2p layer and this allows simple
integration.
2020-04-01 20:22:55 +02:00
TomZ 0c15e877a2 Move arith_uint256 from server to utils lib 2020-04-01 20:22:55 +02:00
TomZ 22e2f3ca7c Make p2p version message mandatory
This was always the intention, but the satoshi code was stupid and buggy.
First, the 'version has been seen' flag was set even if there was a parsing
error in it.
Second, ignoring messages (up to 100) until a version message was seen
makes no sense. Just disconnect instantly.
2020-03-29 12:55:12 +02:00
TomZ 54a07cbdfc Add new log group for future component 2020-03-29 12:55:12 +02:00
TomZ 7b1b742036 Remove workaround for old boost version
The API changes in boost between 1.66 and later was the need
for the boost_compat.h header file.
Its been a long time since Flowee started demanding 1.67 minimum
for boost, making this compat obsolete.
2020-03-29 12:55:12 +02:00