c2fbb40909
* begin state service * begin on the state trie idea * created beacon state structure * add in the full clone getter * return by value instead * add all setters * new state setters are being completed * arrays roots exposed * close to finishing all these headerssss * functionality complete * added in proto benchmark test * test for compatibility * add test for compat * comments fixed * add clone * add clone * remove underlying copies * make it immutable * integrate it into chainservice * revert * wrap up comments for package * address all comments and godocs * address all comments * clone the pending attestation properly * properly clone remaining items * tests pass fixed bug * begin using it instead of head state * prevent nil pointer exceptions * begin using new struct in db * integrated new type into db package * add proper nil checks * using new state in archiver * refactored much of core * editing all the precompute functions * done with most core refactor * fixed up some bugs in the clone comparisons * append current epoch atts * add missing setters * add new setters * fix other core methods * fix up transition * main service and forkchoice * fix rpc * integrated to powchain * some more changes * fix build * improve processing of deposits * fix error * prevent panic * comment * fix process att * gaz * fix up att process * resolve existing review comments * resolve another batch of gh comments * resolve broken cpt state * revise testutil to use the new state * begin updating the state transition func to pass in more compartmentalized args * finish editing transition function to return errors * block operations pretty much done with refactor * state transition fully refactored * got epoch processing completed * fix build in fork choice * fixing more of the build * fix up broken sync package * it builds nowww it buildssss * revert registry changes * Recompute on Read (#4627) * compute on read * fix up eth1 data votes * looking into slashings bug introduced in core/ * able to advance more slots * add logging * can now sync with testnet yay * remove the leaves algorithm and other merkle imports * expose initialize unsafe funcs * Update beacon-chain/db/kv/state.go * lint Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> * More Optimizations for New State (#4641) * map optimization * more optimizations * use a custom hasher * comment * block operations optimizations * Update beacon-chain/state/types.go Co-Authored-By: Raul Jordan <raul@prysmaticlabs.com> * fixed up various operations to use the validator index map access Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> * archiver tests pass * fixing cache tests * cache tests passing * edited validator tests * powchain tests passing * halfway thru sync tests * more sync test fixes * add in tests for state/ * working through rpc tests * assignments tests passed * almost done with rpc/beacon tests * resolved painful validator test * fixed up even more tests * resolve tests * fix build * reduce a randao mixes copy * fixes under //beacon-chain/blockchain/... * build //beacon-chain/core/... * fixes * Runtime Optimizations (#4648) * parallelize shuffling * clean up * lint * fix build * use callback to read from registry * fix array roots and size map * new improvements * reduce hash allocs * improved shuffling * terence's review * use different method * raul's comment * new array roots * remove clone in pre-compute * Update beacon-chain/state/types.go Co-Authored-By: Raul Jordan <raul@prysmaticlabs.com> * raul's review * lint * fix build issues * fix visibility Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> * fix visibility * build works for all * fix blockchain test * fix a few tests * fix more tests * update validator in slashing * archiver passing * fixed rpc/validator * progress on core tests * resolve broken rpc tests * blockchain tests passed * fix up some tests in core * fix message diff * remove unnecessary save * Save validator after slashing * Update validators one by one * another update * fix everything * fix more precompute tests * fix blocks tests * more elegant fix * more helper fixes * change back ? * fix test * fix skip slot * fix test * reset caches * fix testutil * raceoff fixed * passing * Retrieve cached state in the beginning * lint * Fixed tests part 1 * Fixed rest of the tests * Minor changes to avoid copying, small refactor to reduce deplicated code * Handle att req for slot 0 * New beacon state: Only populate merkle layers as needed, copy merkle layers on copy/clone. (#4689) * Only populate merkle layers as needed, copy merkle layers on copy/clone. * use custom copy * Make maps of correct size * slightly fast, doesn't wait for lock Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> * Target root can't be 0x00 * Don't use cache for current slot (may not be the right fix) * fixed up tests * Remove some copy for init sync. Not sure if it is safe enough for runtime though... testing... * Align with prev logic for process slots cachedState.Slot() < slot * Fix Initial Sync Flag (#4692) * fixes * fix up some test failures due to lack of nil checks * fix up some test failures due to lack of nil checks * fix up imports * revert some changes * imports Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> * resolving further conflicts * Better skip slot cache (#4694) * Return copy of skip slot cache state, disable skip slot cache on sync * fix * Fix pruning * copy on write method * gaz * fix tests * fix up issues with broken tests * remove extra update * remove debugging lines * gofmt Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: Nishant Das <nish1993@hotmail.com> Co-authored-by: shayzluf <thezluf@gmail.com> Co-authored-by: terence tsao <terence@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> |
||
---|---|---|
.github | ||
.well-known | ||
beacon-chain | ||
contracts | ||
docs | ||
endtoend | ||
proto | ||
scripts | ||
shared | ||
slasher | ||
third_party | ||
tools | ||
validator | ||
.bazelrc | ||
.buildkite-bazelrc | ||
.codecov.yml | ||
.dockerignore | ||
.gitattributes | ||
.gitignore | ||
.golangci.yml | ||
.travis.yml | ||
BUILD.bazel | ||
CONTRIBUTING.md | ||
interop.Dockerfile | ||
INTEROP.md | ||
LICENSE.md | ||
nogo_config.json | ||
PULL_REQUEST_TEMPLATE.md | ||
README.md | ||
renovate.json | ||
service-account.json.enc | ||
TESTNET.md | ||
VERSION | ||
WORKSPACE |
Prysm: An Ethereum 2.0 Client Written in Go
This is the core repository for Prysm, a Golang implementation of the Ethereum 2.0 client specifications developed by Prysmatic Labs.
Need assistance?
A more detailed set of installation and usage instructions as well as breakdowns of each individual component are available in the official documentation portal. If you still have questions, feel free to stop by either our Discord or Gitter and a member of the team or our community will be happy to assist you.
Come join the testnet!
Participation is now open to the public for our Ethereum 2.0 phase 0 testnet release. Visit prylabs.net for more information on the project or to sign up as a validator on the network.
Table of Contents
- Dependencies
- Installation
- Connecting to the public testnet: running a beacon node
- Staking ETH: running a validator client
- Setting up a local ETH2 development chain
- Testing Prysm
- Contributing
- License
Dependencies
Prysm can be installed either with Docker (recommended) or using our build tool, Bazel. The below instructions include sections for performing both.
For Docker installations:
- The latest release of Docker
For Bazel installations:
- The latest release of Bazel
- The latest release of
cmake
- The latest release of
git
- A modern UNIX operating system
macOS included
Installing Prysm
Build via Docker
- Ensure you are running the most recent version of Docker by issuing the command:
docker -v
- To pull the Prysm images, issue the following commands:
docker pull gcr.io/prysmaticlabs/prysm/validator:latest
docker pull gcr.io/prysmaticlabs/prysm/beacon-chain:latest
This process will also install any related dependencies.
Build via Bazel
- Open a terminal window. Ensure you are running the most recent version of Bazel by issuing the command:
bazel version
- Clone Prysm's main repository and enter the directory:
git clone https://github.com/prysmaticlabs/prysm
cd prysm
- Build both the beacon chain node and the validator client:
bazel build //beacon-chain:beacon-chain
bazel build //validator:validator
Bazel will automatically pull and install any dependencies as well, including Go and necessary compilers.
Connecting to the testnet: running a beacon node
Below are instructions for initialising a beacon node and connecting to the public testnet. To further understand the role that the beacon node plays in Prysm, see this section of the documentation.
NOTE: It is recommended to open up port 13000 on your local router to improve connectivity and receive more peers from the network. To do so, navigate to 192.168.0.1
in your browser and login if required. Follow along with the interface to modify your routers firewall settings. When this task is completed, append the parameter--p2p-host-ip=$(curl -s ident.me)
to your selected beacon startup command presented in this section to use the newly opened port.
Running via Docker
Docker on Linux/macOS:
To start your beacon node, issue the following command:
docker run -it -v $HOME/prysm:/data -p 4000:4000 -p 13000:13000 --name beacon-node \
gcr.io/prysmaticlabs/prysm/beacon-chain:latest \
--datadir=/data
The beacon node can be halted by either using Ctrl+c
or with the command:
docker stop beacon-node
To restart the beacon node, issue the following command:
docker start -ai beacon-node
To delete a corrupted container, issue the following command:
docker rm beacon-node
To recreate a deleted container and refresh the chain database, issue the start command with an additional --clear-db
parameter:
docker run -it -v $HOME/prysm:/data -p 4000:4000 -p 13000:13000 --name beacon-node \
gcr.io/prysmaticlabs/prysm/beacon-chain:latest \
--datadir=/data \
--clear-db
Docker on Windows:
-
You will need to 'share' the local drive you wish to mount to
e.g. C:
.- Enter Docker settings
right click the tray icon
- Click 'Shared Drives'
- Select a drive to share
- Click 'Apply'
- Enter Docker settings
-
You will next need to create a directory named
/prysm/
within your selected shared Drive. This folder will be used as a local data directory for Beacon Node chain data as well as account and keystore information required by the validator. Docker will not create this directory if it does not exist already. For the purposes of these instructions, it is assumed thatC:
is your prior-selected shared Drive. -
To run the beacon node, issue the following command:
docker run -it -v c:/prysm/:/data -p 4000:4000 -p 13000:13000 --name beacon-node gcr.io/prysmaticlabs/prysm/beacon-chain:latest --datadir=/data --clear-db
Running via Bazel
To start your Beacon Node with Bazel, issue the following command:
bazel run //beacon-chain -- --clear-db --datadir=$HOME/prysm
This will sync up the beacon node with the latest head block in the network.
NOTE: The beacon node must be completely synced before attempting to initialise a validator client, otherwise the validator will not be able to complete the deposit and funds will lost.
Staking ETH: Running a validator client
Once your beacon node is up, the chain will be waiting for you to deposit 3.2 Goerli ETH into a validator deposit contract in order to activate your validator discussed in the section below
. First though, you will need to create this validator and connect to this node to participate in consensus.
Each validator represents 3.2 Goerli ETH being staked in the system, and it is possible to spin up as many as you desire in order to have more stake in the network.
Activating your validator: depositing 3.2 Göerli ETH
To begin setting up a validator, follow the instructions found on prylabs.net to use the Göerli ETH faucet and make a deposit. For step-by-step assistance with the deposit page, see the Activating a Validator section of this documentation.
It will take a while for the nodes in the network to process a deposit. Once the node is active, the validator will immediately begin performing its responsibilities.
In your validator client, you will be able to frequently see your validator balance as it goes up over time. Note that, should your node ever go offline for a long period, a validator will start gradually losing its deposit until it is removed from the network entirely.
Congratulations, you are now running Ethereum 2.0 Phase 0!
Setting up a local ETH2 development chain
This section outlines the process of setting up Prysm for local testing with other Ethereum 2.0 client implementations. See the INTEROP.md file for advanced configuration options. For more background information on interoperability development, see this blog post.
Installation and dependencies
To begin setting up a local ETH2 development chain, follow the Bazel instructions found in the dependencies and installation sections respectively.
Running a local beacon node and validator client
The example below will generate a beacon genesis state and initiate Prysm with 64 validators with the genesis time set to your machines UNIX time.
Open up two terminal windows. In the first, issue the command:
bazel run //beacon-chain -- \
--custom-genesis-delay=0 \
--bootstrap-node= \
--deposit-contract $(curl https://prylabs.net/contract) \
--clear-db \
--interop-num-validators 64 \
--interop-eth1data-votes
Wait a moment for the beacon chain to start. In the other terminal, issue the command:
bazel run //validator -- --keymanager=interop --keymanageropts='{"keys":64}'
This command will kickstart the system with your 64 validators performing their duties accordingly.
Testing Prysm
To run the unit tests of our system, issue the command:
bazel test //...
To run our linter, make sure you have golangci-lint installed and then issue the command:
golangci-lint run
Contributing
Want to get involved? Check out our Contribution Guide to learn more!