Commit Graph

14829 Commits

Author SHA1 Message Date
Bernhard M. Wiedemann 45113ebe57 Make tests pass after 2020
also test that 64 bit integers are properly handled
2021-02-17 03:06:02 +00:00
Pieter Wuille 46060d5c8b Support SipHash with arbitrary byte writes 2021-02-16 18:00:22 -07:00
Patrick Strateman 14d03ba7b7 Avoid recalculating vchKeyedNetGroup in eviction logic.
Lazy calculate vchKeyedNetGroup in CNode::GetKeyedNetGroup.
2021-02-16 18:00:19 -07:00
Cory Fields 686cdafa02 net: Drop CNodeRef for AttemptToEvictConnection
Locking for each operation here is unnecessary, and solves the wrong problem.
Additionally, it introduces a problem when cs_vNodes is held in an owning
class, to which invididual CNodeRefs won't have access.

These should be weak pointers anyway, once vNodes contain shared pointers.

Rather than using a refcounting class, use a 3-step process instead.

1. Lock vNodes long enough to snapshot the fields necessary for comparing
2. Unlock and do the comparison
3. Re-lock and mark the resulting node for disconnection if it still exists

Zcash: add nVersion to NodeEvictionCandidate
2021-02-16 17:50:00 -07:00
Gregory Maxwell c1600cd259 Return early in IsBanned.
I am not aware of any reason that we'd try to stop a ban-list timing
 side-channel and the prior code wouldn't be enough if we were.
2021-02-16 18:08:57 +00:00
Cory Fields 9eb0aec437 net: move CBanDB and CAddrDB out of net.h/cpp
This will eventually solve a circular dependency
2021-02-16 18:08:57 +00:00
Pieter Wuille 918a7ddc01 Add extra message to avoid a long 'Loading banlist' 2021-02-16 18:02:25 +00:00
Cory Fields 2e8cdc8687 net: No need to export DumpBanlist 2021-02-16 18:02:25 +00:00
Cory Fields 0349f30828 net: make Ban/Unban/ClearBan functionality consistent
- Ban/Unban/ClearBan call uiInterface.BannedListChanged() as necessary
- Ban/Unban/ClearBan sync to disk if the operation is user-invoked
- Mark node for disconnection automatically when banning
- Lock cs_vNodes while setting disconnected
- Don't spin in a tight loop while setting disconnected
2021-02-16 18:02:25 +00:00
Kaz Wesley 8586da99fe fix race that could fail to persist a ban
DumpBanList currently does this:
  - with lock: take a copy of the banmap
  - perform I/O (write out the banmap)
  - with lock: mark the banmap non-dirty
If a new ban is added during the I/O operation, it may never be persisted to
disk.

Reorder operations so that the data to be persisted cannot be older than the
time at which the banmap was marked non-dirty.
2021-02-16 18:02:25 +00:00
EthanHeilman 71f39f4160 Fix de-serialization bug where AddrMan is corrupted after exception
* CAddrDB modified so that when de-serialization code throws an exception Addrman is reset to a clean state
* CAddrDB modified to make unit tests possible
* Regression test created to ensure bug is fixed
* StartNode modifed to clear adrman if CAddrDB::Read returns an error code.
2021-02-16 18:02:25 +00:00
kirkalx 92b93a87c8 peers.dat, banlist.dat recreated when missing 2021-02-16 18:02:25 +00:00
Philip Kaufmann d729f55bea banlist (bugfix): allow CNode::SweepBanned() to run on interval
- allows CNode::SweepBanned() to run, even if !CNode::BannedSetIsDirty(),
  because if nBanUntil is over we want the ban to be disabled for these
  nodes
2021-02-16 18:02:25 +00:00
Philip Kaufmann bbbf4dd3a8 banlist: add more banlist infos to log / add GUI signal
- to match the peers.dat handling also supply a debug.log entry for how
  many entries were loaded from banlist.dat and how long it took
- add a GUI init message for loading the banlist (same as with peers.dat)

- move the same message for peers.dat upwards in the code, to be able to
  reuse the timing variable nStart and also just log, if our read from
  peers.dat didn't fail
2021-02-16 18:02:25 +00:00
Philip Kaufmann 0205c70e0d banlist: better handling of banlist in StartNode()
- only start working on/with banlist data, if reading in the banlist from
  disk didn't fail
- as CNode::setBannedIsDirty is false (default) when reading fails, we
  don't need to explicitly set it to false to prevent writing
  banlist.dat in that case either
2021-02-16 18:02:25 +00:00
Philip Kaufmann e49ad06dd5 banlist: update set dirty to be more fine grained
- move the SetBannedSetDirty(false) call from DumpData() into DumpBanlist()
- ensure we only set false, if the write succeeded
2021-02-16 18:02:25 +00:00
Jonas Schnelli 68066648a9 [QA] fix netbase tests because of new CSubNet::ToString() output 2021-02-16 18:02:25 +00:00
Wladimir J. van der Laan 48ffe79511 net: Fix CIDR notation in ToString()
Only use CIDR notation if the netmask can be represented as such.
2021-02-16 18:02:25 +00:00
Jonas Schnelli f8bf7b146c net: use CIDR notation in CSubNet::ToString() 2021-02-16 18:02:25 +00:00
Jonas Schnelli f3466977d8 [Qt] banlist, UI optimizing and better signal handling
Zcash: non-QT parts only (whitespace)
2021-02-16 18:02:25 +00:00
Jonas Schnelli 3909d0b455 [Qt] add ui signal for banlist changes
Zcash: non-QT part only (the signal itself)
2021-02-16 18:02:25 +00:00
Jonas Schnelli a1f8683066 Adding CSubNet constructor over a single CNetAddr 2021-02-16 18:02:24 +00:00
Jonas Schnelli edef9aa895 use CBanEntry as object container for banned nodes
- added a reason enum for a ban
- added creation time for a ban

Using CBanEntry as container will keep banlist.dat extenable.
2021-02-16 18:02:24 +00:00
Jonas Schnelli 046740585e CAddrDB/CBanDB: change filesize variables from int to uint64_t 2021-02-16 18:02:24 +00:00
Jonas Schnelli fa9fcfea60 banlist.dat: store banlist on disk 2021-02-16 18:02:24 +00:00
Jack Grigg fa1a57867b zcash_script: Add API to verify scripts with precomputed tx data
Closes zcash/zcash#4876.
2021-02-15 23:37:55 +00:00
Homu c81adc3718 Auto merge of #4979 - nuttycom:upstream_siphash, r=str4d
Backport of bitcoin/bitcoin#8020

Cherry-picked from bitcoin/bitcoin#8020

- cherry-pick bitcoin/bitcoin@a68ec21f7e
  - conflict with bitcoin/bitcoin@957e5d2
- cherry-pick bitcoin/bitcoin@8cc9cfe160
- cherry-pick bitcoin/bitcoin@382c871d28
  - replace CCoinsKeyHasher with SaltedTxidHasher
- cherry-pick bitcoin/bitcoin@0b1295b066
  - self-conflict with previously-applied bitcoin/bitcoin@b8a657936 (zcash/zcash#3180)
2021-02-15 21:40:18 +00:00
Pieter Wuille cfc4ca1817 Use SipHash-2-4 for address relay selection
Zcash: conflicts resolved against 957e5d216f
2021-02-11 11:10:42 -07:00
Pieter Wuille 407532d840 Switch CTxMempool::mapTx to use a hash index for txids 2021-02-11 11:10:42 -07:00
Pieter Wuille ec4196d8cf Use SipHash-2-4 for CCoinsCache index
This is ~1.7x slower than the Lookup3-of-Xor-with-salt construct we were
using before, but it is a primitive designed for exactly this.

Zcash: Propagate CCoinsKeyHasher -> SaltedTxidHasher changes to where
we've used CCoinsKeyHasher outside of its original scope.
2021-02-11 11:10:42 -07:00
Pieter Wuille f3b2cdb32b Add SipHash-2-4 primitives to hash 2021-02-11 11:10:42 -07:00
BtcDrak fa8d2a45bb Remove bad chain alert partition check
As per meeting 2016-03-31
https://bitcoincore.org/en/meetings/2016/03/31/#bad-chain-alerts

The partition checker was producing huge number of false-positives
and was disabled in 0.12.1 on the understanding it would either be
fixed in 0.13 or removed entirely from master if not.

(cherry picked from commit ab8be98fdb25b678a8cd7e89adf06d1b1f6bdd62)
2021-02-02 09:25:35 -07:00
Jack Grigg 340add223a test: Convert Bech32 test vectors into known-answer test vectors
This enables other projects to confirm independently that their encoding
or decoding functions are consistent, instead of merely that they are
round-trip correct.
2021-02-02 15:54:25 +00:00
Homu a960e896dd Auto merge of #4966 - str4d:zcash-script-lib, r=nuttycom
Replace libzcashconsensus with libzcash_script

We inherited `libzcashconsensus` from upstream (we just renamed it before launch to avoid conflicts). However, it has become increasingly inaccurately named; it only covers (Zcash's subset of) the Bitcoin scripting system, and not the myriad of other consensus changes (in particular, the shielded pools).

This PR reworks the library to instead be focused on transparent script verification:
- The script verification APIs are altered to take `amount` and `consensusBranchId` fields.
- Equihash code is removed (the canonical Equihash validator is now the `equihash` Rust crate).
- The library is renamed to `libzcash_script`.

The API changes are backwards-incompatible, but the library rename prevents any issues. Also, `libzcashconsensus` was in fact broken and not compiling for several years and no one complained, suggesting that it was not actually being relied on within the ecosystem. By contrast, this focused library already has a consumer: the `zebrad` full node.

Closes zcash/zcash#4879.
2021-01-28 19:34:09 +00:00
Homu 090e284f57 Auto merge of #4964 - str4d:univalue-update, r=nuttycom
Update UniValue subtree

This brings us up-to-date with upstream Bitcoin's version of the library.

Includes a commit cherry-picked from bitcoin/bitcoin#12193.
2021-01-28 18:06:37 +00:00
Homu cc5574b819 Auto merge of #4963 - defuse:fix-updatecheck-token, r=nuttycom
Move the github API token out of updatecheck.py into an untracked file.
2021-01-28 16:38:34 +00:00
Homu b9504dbb3f Auto merge of #4967 - LarryRuane:upstream-lockfixes, r=nuttycom
cherry-pick upstream locking fixes

Cherry-pick https://github.com/bitcoin/bitcoin/pull/9225
2021-01-28 14:13:34 +00:00
Homu dc94d76053 Auto merge of #4968 - str4d:design-book, r=str4d
Set up an mdbook in which we can document zcashd's architecture design

I've explained various parts of zcashd's node architecture enough times
now that it really should be written down!
2021-01-28 03:31:06 +00:00
Jack Grigg fecde3de1f Link to zips.z.cash for protocol spec 2021-01-27 17:46:03 +00:00
Jack Grigg aec304d7a0 Show README as root of zcashd book 2021-01-27 17:45:45 +00:00
Jack Grigg 9cee5686bb Actions: Add a workflow to deploy the zcashd book 2021-01-27 17:20:30 +00:00
Jack Grigg 8cfbabd6ed Set up an mdbook in which we can document zcashd's architecture design
I've explained various parts of zcashd's node architecture enough times
now that it really should be written down!
2021-01-27 17:16:34 +00:00
Matt Corallo 8982265456 Fix unlocked access to vNodes.size() 2021-01-26 11:39:45 -07:00
Matt Corallo 6da9ecda03 Remove double brackets in addrman 2021-01-26 10:48:18 -07:00
Matt Corallo 5123af41d6 Fix AddrMan locking 2021-01-26 10:40:50 -07:00
Matt Corallo e78376b4fe Make fImporting an std::atomic 2021-01-26 10:39:37 -07:00
Matt Corallo e286250ce4 Make fDisconnect an std::atomic 2021-01-26 10:23:32 -07:00
Jack Grigg 90232f65ae Rename libzcashconsensus.la -> libzcash_script.la 2021-01-25 22:20:25 +00:00
Jack Grigg ea8065917e Rename zcashconsensus_* -> zcash_script_* in APIs 2021-01-25 22:20:25 +00:00
Jack Grigg c5e7b84e9b Rename src/script/zcashconsensus.* -> src/script/zcash_script.* 2021-01-25 22:20:25 +00:00