Giter VIP home page Giter VIP logo

zebra's Introduction

Zebra logotype


CI Docker CI OSes Continuous Delivery Coverage codecov Build docs Build lightwalletd Build Zcash Params

License

Contents

About

Zebra is the Zcash Foundation's independent, consensus-compatible implementation of a Zcash node, currently under development. It can be used to join the Zcash peer-to-peer network, which helps keeping Zcash working by validating and broadcasting transactions, and maintaining the Zcash blockchain state in a distributed manner.

Zcash is a cryptocurrency designed to preserve the user's privacy. If you just want to send and receive Zcash then you don't need to use Zebra directly. You can download a Zcash wallet application which will handle that for you.

Please join us on Discord if you'd like to find out more or get involved!

Using Zebra

You would want to run Zebra if you want to contribute to the Zcash network: the more nodes are run, the more reliable the network will be in terms of speed and resistance to denial of service attacks, for example.

Zebra aims to be faster, more secure, and more easily extensible than other Zcash implementations.

Beta Releases

Every few weeks, we release a new Zebra beta release.

Zebra's network stack is interoperable with zcashd, and Zebra implements all the features required to reach Zcash network consensus.

Currently, Zebra validates all of the Zcash consensus rules for the NU5 network upgrade.

But it may not validate any:

  • Undocumented rules derived from Bitcoin
  • Undocumented network protocol requirements

Getting Started

Building zebrad requires Rust, libclang, and a C++ compiler.

Build and Run Instructions

zebrad is still under development, so there is no supported packaging or install mechanism. To run zebrad, follow the instructions to compile zebrad for your platform:

  1. Install cargo and rustc.
    • Zebra is tested with the latest stable Rust version. Earlier versions are not supported or tested, but they might work. (Rust 1.57 and earlier are not supported, due to missing features.)
  2. Install Zebra's build dependencies:
    • libclang: the libclang, libclang-dev, llvm, or llvm-dev packages, depending on your package manager
    • clang or another C++ compiler: g++, Xcode, or MSVC
  3. Run cargo install --locked --git https://github.com/ZcashFoundation/zebra --tag v1.0.0-beta.13 zebrad
  4. Run zebrad start (see Running Zebra for more information)

For more detailed instructions, refer to the documentation.

Optional Features

For performance reasons, some debugging and monitoring features are disabled in release builds.

You can enable these features using:

cargo install --features=<name> ...

System Requirements

The recommended requirements for compiling and running zebrad are:

  • 4+ CPU cores
  • 16+ GB RAM
  • 100 GB+ available disk space for building binaries and storing cached chain state
  • 100+ Mbps network connections

We continuously test that our builds and tests pass on:

The latest GitHub Runners for:

  • macOS
  • Ubuntu

Docker:

  • Debian Bullseye

Zebra's tests can take over an hour, depending on your machine. We're working on making them faster.

zebrad might build and run fine on smaller and slower systems - we haven't tested its exact limits yet.

For more detailed requirements, refer to the documentation.

Memory Troubleshooting

If Zebra's build runs out of RAM, try setting: export CARGO_BUILD_JOBS=2

If Zebra's tests timeout or run out of RAM, try running: cargo test -- --test-threads=2

(cargo uses all the processor cores on your machine by default.)

macOS Test Troubleshooting

Some of Zebra's tests deliberately cause errors that make Zebra panic. macOS records these panics as crash reports.

If you are seeing "Crash Reporter" dialogs during Zebra tests, you can disable them using this Terminal.app command:

defaults write com.apple.CrashReporter DialogType none

Network Ports and Data Usage

By default, Zebra uses the following inbound TCP listener ports:

  • 8233 on Mainnet
  • 18233 on Testnet

Zebra needs some peers which have a round-trip latency of 2 seconds or less. If this is a problem for you, please open a ticket.

zebrad's typical mainnet network usage is:

  • Initial sync: 40 GB download (in the longer term, several hundred GB are likely to be downloaded).
  • Ongoing updates: 10 MB - 1 GB upload and download per day, depending on user-created transaction size, and peer requests

Zebra also performs an initial sync every time its internal database version changes.

For more detailed information, refer to the documentation.

Network Troubleshooting

Some of Zebra's tests download Zcash blocks, so they might be unreliable depending on your network connection. You can set ZEBRA_SKIP_NETWORK_TESTS=1 to skip the network tests.

Zebra may be unreliable on Testnet, and under less-than-perfect network conditions. See our roadmap for details.

Disk Usage

Zebra uses up to 40 GB of space for cached mainnet data, and 10 GB of space for cached testnet data.

RocksDB cleans up outdated data periodically, and when the database is closed and re-opened.

Disk Troubleshooting

Zebra's state commits changes using RocksDB database transactions.

If you forcibly terminate Zebra, or it panics, any incomplete changes will be rolled back the next time it starts.

So Zebra's state should always be valid, unless your OS or disk hardware is corrupting data.

Known Issues

There are a few bugs in Zebra that we're still working on fixing:

  • No Windows support #3801
    • We used to test with Windows Server 2019, but not anymore; see issue for details

Performance

We are working on improving Zebra performance, the following are known issues:

  • Send note commitment and history trees from the non-finalized state to the finalized state #4824
  • Speed up opening the database #4822
  • Revert note commitment and history trees when forking non-finalized chains #4794
  • Store only the first tree state in each identical series of tree states #4784

RPCs might also be slower than they used to be, we need to check:

  • Revert deserializing state transactions in rayon threads #4831

Ongoing investigations:

  • Find out which parts of CommitBlock/CommitFinalizedBlock are slow #4823
  • Mini-Epic: Stop tokio tasks running for a long time and blocking other tasks #4747
  • Investigate busiest tasks per tokio-console #4583

Future Work

Features:

  • Wallet functionality

Performance and Reliability:

  • Reliable syncing under poor network conditions
  • Additional batch verification
  • Performance tuning

Currently, the following features are out of scope:

  • Mining support
  • Optional Zcash network protocol messages
  • Consensus rules removed before Canopy activation (Zebra checkpoints on Canopy activation)

Documentation

The Zebra website contains user documentation, such as how to run or configure Zebra, set up metrics integrations, etc., as well as developer documentation, such as design documents. We also render API documentation for the external API of our crates, as well as internal documentation for private APIs.

Security

Zebra has a responsible disclosure policy, which we encourage security researchers to follow.

License

Zebra is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT.

zebra's People

Contributors

teor2345 avatar dconnolly avatar hdevalence avatar dependabot[bot] avatar oxarbitrage avatar yaahc avatar conradoplg avatar dependabot-preview[bot] avatar jvff avatar gustavovalverde avatar upbqdn avatar mpguerra avatar rex4539 avatar fanatid avatar vramana avatar str4d avatar ebfull avatar aarnott avatar gtank avatar kiminuo avatar sandakersmann avatar preston-evans98 avatar tony-iqlusion avatar luckytokidoki avatar

Watchers

 avatar

zebra's Issues

Blocks [#205641..#791962] have wrong PoW hash

For some blocks in range of [#205641..#791962] (included begin and end block) the condition:

if hash > &difficulty_threshold {
...
Err(BlockError::DifficultyFilter(
            *height,
            *hash,
            difficulty_threshold,
            network,
        ))?;
}

is true.

pow_blocks_with_wrong_diff.gz - here is the exact block numbers that violates the PoW difficulty.

invalid non-finalized block height

After sync 3024878 blocks:

Message: invalid non-finalized block height: the canopy checkpoint is mandatory, pre-canopy blocks, and the canopy activation block, must be committed to the state as finalized blocks
Location: zebra-state/src/service.rs:544

image

InvalidDifficultyThreshold?

Error

only called after inserting a block

Metadata

key value
version 1.0.0-alpha.16+968.gd1430fd
Zcash network Mainnet
state version 25
branch komodo
git commit d1430fd
commit timestamp 2022-10-06T14:19:35Z
target triple x86_64-unknown-linux-gnu
build profile debug
location zebra-state/src/service/non_finalized_state.rs:312:14

SpanTrace

SpanTrace:
   0: zebra_state::service::state
             at zebra-state/src/service.rs:609
   1: zebrad::components::sync::obtain_tips
             at zebrad/src/components/sync.rs:508
   2: zebrad::components::sync::try_to_sync
             at zebrad/src/components/sync.rs:433
   3: zebrad::components::sync::sync
             at zebrad/src/components/sync.rs:400
   4: zebrad::application::
           with �[3mzebrad�[0m�[2m=�[0m"d1430fd" �[3mnet�[0m�[2m=�[0m"Main"
             at zebrad/src/application.rs:397

Block before:

2022-10-06T23:40:16.895241Z  WARN {zebrad="d1430fd" net="Main"}:sync:try_to_sync: zebrad::components::sync: error downloading and verifying block e=Invalid { error: Block(Commit(CloneError { source: CommitBlockError(InvalidDifficultyThreshold { difficulty_threshold: CompactDifficulty(0x1d01fe5b, Some(ExpandedDifficulty("00000001fe5b0000000000000000000000000000000000000000000000000000"))), expected_difficulty: CompactDifficulty(0x1d017a62, Some(ExpandedDifficulty("000000017a620000000000000000000000000000000000000000000000000000"))) }) })), height: Height(3025602), hash: block::Hash("0000000078426135b855b0fdb62fb8bfb7d2faf801340b79cf0cf1c35b935f3c") }

Block: #3025602
0000000078426135b855b0fdb62fb8bfb7d2faf801340b79cf0cf1c35b935f3c

0000000078426135b855b0fdb62fb8bfb7d2faf801340b79cf0cf1c35b935f3c
00000001fe5b0000000000000000000000000000000000000000000000000000 - difficulty_threshold
000000017a620000000000000000000000000000000000000000000000000000 - expected_difficulty

balance overflow already checked: Constraint { value: 20001502817375916, range: 0..=20000000000000000 }

Message: balance overflow already checked: Constraint { value: 20001502817375916, range: 0..=20000000000000000 }
Location: zebra-state/src/service/finalized_state/zebra_db/transparent.rs:456

    /// Updates the current balance by adding the supplied output's value.
    pub fn receive_output(
        &mut self,
        unspent_output: &transparent::Output,
    ) -> Result<(), amount::Error> {
        self.balance = (self.balance + unspent_output.value())?;

        Ok(())
    }

Variables:

self.balance = 9997553159712924
unspent_output.value() = 10003949657662992

And value of 20001502817375916 exceeds MAX_MONEY constraints.

{start:0, end:20000000000000000, exhausted:false}

Transaction e415cbac112324003dea318b61e6789bdbd4fcaf1bb833642540408d979f08c4 in Block #164683.

Block #1711048 - body length exceeded maximum size

2022-08-10T08:12:21.273524Z  WARN {zebrad="42349c8" net="Main"}:sync:try_to_sync: zebrad::components::sync: error downloading and verifying block e=DownloadFailed { error: SharedPeerError(Serialization(Parse("body length exceeded maximum size"))), hash: block::Hash("08137de7eb4324e28587ea34f7d76bd7bc35b481846285a4187a8a8b644d41fd") }

Block #1711048 - Size (bytes) | 4193134

2022-08-10T08:25:24.683718Z  WARN {zebrad="42349c8" net="Main"}:sync:try_to_sync: zebrad::components::sync: error downloading and verifying block e=DownloadFailed { error: SharedPeerError(Serialization(Parse("body length exceeded maximum size"))), hash: block::Hash("090d802b592383d9300aaccfbe75a2e77c0430566f5c146023192b586891293f") }

Block #1710803 - Size (bytes) | 12831 ?

could not to deserialize tx

Error

zcash_script_new_precomputed_tx returned 3 (could not to deserialize tx)

Metadata

key value
version 1.0.0-alpha.16+972.g64e9d6b
Zcash network Mainnet
state version 25
branch komodo
git commit 64e9d6b
commit timestamp 2022-10-07T00:08:44Z
target triple x86_64-unknown-linux-gnu
build profile debug
location zebra-script/src/lib.rs:130:9

SpanTrace

SpanTrace:
   0: zebrad::components::sync::try_to_sync
             at zebrad/src/components/sync.rs:433
   1: zebrad::components::sync::sync
             at zebrad/src/components/sync.rs:400
   2: zebrad::application::
           with �[3mzebrad�[0m�[2m=�[0m"64e9d6b" �[3mnet�[0m�[2m=�[0m"Main"
             at zebrad/src/application.rs:397
Failed to parse transaction: value out of range
Transaction: V4 { inputs: [PrevOut { outpoint: OutPoint { hash: transaction::Hash("fdcf4737f161f33003aa09fe61dfd3c220d37eca7e08d4f107582e4ee3885b16"), index: 1 }, unlock_script: Script("483045022100e41127a63ab39ff6ee89d5aa9dfc61a9549943544b2070b774b30c88b496bbf3022074445f1438882cad402918927c41d8a8ce36697a68da554efc0a0f3ba26351d4012103ef6e99aa6ebddf4ac072643263590fa70f2231d2de15bceb1dc02a98351aeedd"), sequence: 4294967295 }, PrevOut { outpoint: OutPoint { hash: transaction::Hash("76f82515bf02b9cff1bbc2a8745ef267dbe589b6ed93b166d081bcca1e11b77a"), index: 1 }, unlock_script: Script("4830450221008b84522f65ed9af34d2544f2527f8b2a9470504f0719c1fe579820c91b48ebc4022020741a73b2444295bc38c9e556ed90ae65fa247e344872657094b27fd64508b4012103ef6e99aa6ebddf4ac072643263590fa70f2231d2de15bceb1dc02a98351aeedd"), sequence: 4294967295 }, PrevOut { outpoint: OutPoint { hash: transaction::Hash("e186d93fbc51e09294179be549ea6e5e57978202b953fa10e79f1ab0112f4e38"), index: 1 }, unlock_script: Script("483045022100838c813f5ecac57ade5ee02d1e278f78efdbd0e6efbb15f407d09e172c96d6e602201834147c4593b19f25c8c0f77e5de2a1b315391086d509e760791fc7bffef3a4012103ef6e99aa6ebddf4ac072643263590fa70f2231d2de15bceb1dc02a98351aeedd"), sequence: 4294967295 }, PrevOut { outpoint: OutPoint { hash: transaction::Hash("f901bcd0cc7eac876527a6dbf7992fd417fc9bf6418ff55ed7a4d1d2cc9f6cfd"), index: 1 }, unlock_script: Script("4830450221008d5a5f78a32b0eb84c5a90bf73dfd1aa86c9c53a6f06d7aba0bdc7b17f73f3ac02202bf4192bcd9a2517ded07416ce93d055a44ae9b478209a8c2d24a460d7cf250701210320bea4b200fc9a1b80445ddd4f21c2cfda6be7e4a3de554837486114505d1595"), sequence: 4294967295 }], outputs: [Output { value: Amount<zebra_chain::amount::NonNegative>(4142143722381184), lock_script: Script("76a914e0225f834038263c4966ea8e29a1df1372a18a7e88ac") }], lock_time: Time(2022-08-30T01:44:20Z), expiry_height: Height(0), joinsplit_data: None, sapling_shielded_data: None }

https://kmdexplorer.io/tx/ccec18534f09e284306fff642aed55227ad120da447e4cd646c905d2a8f9b614

outputs: [Output { value: Amount<zebra_chain::amount::NonNegative>(4142143722381184), lock_script: Script("76a914e0225f834038263c4966ea8e29a1df1372a18a7e88ac") }]

41421437.22381185 KMD

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.