Commit Graph

25 Commits

Author SHA1 Message Date
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 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 7e01498eba Add operator== to class Tx 2020-01-04 21:08:38 +01:00
TomZ d93faff5a3 Fix C++11 compiler warning
also fix potential memory out-of-bounds write issue.
2020-01-04 14:20:22 +01:00
TomZ 9d77814cc0 cleanups and splits
The recent introduction of helper methods on pubkey.h had the
side-effect of pulling in crypto libraries.
This splits the static methods into a separate namespace and file
to avoid such cross-module dependencies.
2019-11-13 19:09:24 +01:00
TomZ f1d0a68579 Port address monitor service to use address-hash
Remove addresses of type ripe160 to be used in the API of AddresMonitor
API service. Instead use a sha256 hash of the entire output script.

This is mostly internal changes not affecting the operations much.
2019-10-20 20:17:17 +02:00
TomZ d684bb5b52 Remove dead code. 2019-10-10 19:18:47 +02:00
TomZ da199a5cf7 Port https://github.com/bitcoin/bitcoin/pull/12460
Assert CPubKey::ValidLength to the pubkey's header-relevant size

Original author: Marco Falke
2019-10-10 15:13:34 +02:00
TomZ b09fa3ab7e Minor fixups
This makes the whitespace usage more in line with the standard.

This also moves an implementation of a virtual method to the cpp file
in order to avoid dynamic linking issues down the line.
2019-10-09 19:35:14 +02:00
TomZ 4e9f66a335 Remove unused CScript::isCommitment() method. 2019-10-09 19:16:52 +02:00
TomZ bba96f3805 Remove unused member 2019-10-09 19:13:03 +02:00
TomZ 80f27ee26d Make CheckMinimalPush exposed and unit test it. 2019-10-08 14:24:22 +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 0412ae756a Simplify this code
This removes some of the experimental additions that no longer are
used and as such restores the older, simpler, design.
2019-09-04 14:12:38 +02:00
TomZ b327821236 make compile 2019-06-07 09:53:05 +02:00
TomZ 449f91f46d Move solver method to utils lib
The code that detects standard script-types is now available as a
library function, renamed to live in a namespace;
Script::solver()
2019-06-06 22:21:46 +02:00
TomZ e137a7b59f Add simple memcpy constructor to KeyId / uint160 2019-05-06 14:45:12 +02:00
TomZ b41e2795e7 Add Schnorr support 2019-04-19 17:30:59 +02:00
TomZ 86a59c067d Add support for the 'segwit recovery' 2019-04-19 17:30:56 +02:00
TomZ ef5dafe6e0 Add private header warnings 2019-04-06 12:28:34 +02:00
TomZ 70d0c55a04 Add standard accessor; dataLength 2019-03-17 22:23:52 +01:00
TomZ 557c2000f2 Move CKey to live in utils as well 2019-03-13 22:43:25 +01:00
TomZ a0f39317ea Add an accessor method: Tx::data() 2019-03-13 22:36:00 +01:00
TomZ cfe690320d Move various standalone simple classes into utils
The 'server' library has always been a catch-all and
ideally only the hub links it in (far future goal).
In line with this I move a list of files out of server
into the utils lib.
I choose 'utils' because all these are plain old data
objects that many crypto apps will find useful.

now in utils/primitives/
* CScript
* CPubKey
* CTransaction
* CBlock
* FastTransaction
* FastBlock
* CScript

streams.h is now in utils/streaming/
hash.h is now in utils/
2019-03-11 15:40:42 +01:00