New to the Prysm project and eth2? We first recommend checking out this awesome reading list here: https://eth2.info. There's a number of ways to help out the project for people of all skillsets and experience levels. If you are unsure where you may be best suited, stop by either our Discord or Gitter and a member of the team or community will be happy to answer questions and offer some direction.
Once you are a bit more familiar with the concepts behind eth2 and are ready to write some code, head over and explore Prysm's open issues on Github. We recommend looking for issues tagged with the "Good First Issue" label if it is your first contribution. If you are still unsure about how to tackle a bug or a feature, our team is always available on Discord. Sign in to your Github account, then navigate to the official Prysm repository. In the upper right hand corner of the page, click the 'Fork' button. This will create a copy of the Prysm repository on your account that can be edited for pull requests.
Setting up your environment
To develop Prysm, you'll need the following:
- A modern windows, osx, or linux operating system
- Go 1.16.x version installed, download and install here
- A code editor such as Visual Studio Code or Jetbrains' Goland IDE or your preferred one
First, create a local clone of Prysm.
Then link your local repository to your newly created fork.
Finally, ensure Go is installed and working on your machine:
Building and testing Prysm with Go
The Prysm project is a large monorepo containing all sorts of tools and services that implement the eth2 protocol. We use Go for everything we do in development, helping everyone have reproducible builds. If you want to build the whole project, you can run the following command:
This will build the project by downloading dependencies as Go modules.
Running Go tests
All code we check into our repo needs to have sufficient tests to ensure it is maintainable and works as expected. You can use Go run tests in Prysm.
If there is a particular subfolder you want to test, such as
beacon-chain/rpc/node, you can run the command:
If you want to add a new dependency to Prysm, please adhere to the guidelines found in our DEPENDENCIES.md document.
Building and testing Prysm with Bazel
The Prysm project is a large monorepo containing all sorts of tools and services that implement the eth2 protocol. We use the Bazel build system created by Google for everything we do, helping everyone have reproducible builds. If you want to build the beacon chain or validator using Bazel, you can run the commands:
Other binaries in our codebase use a similar command to build. If you want to run a particular built binary, you can use the command:
Where you can specify any amount of command line arguments you need based on the available flags of the item you're running.
In order to write code for the Prysm codebase comfortably with Bazel, we recommend using either Visual Studio Code with its Bazel plugin, or any Jetbrains IDE with the Bazel plugin (Goland is a great choice, used by most of the Prysmatic Labs team).
You can also find various other types of IDE support for Bazel in the official Bazel documentation here. Once you have your coding environment set-up, you'll be well-equipped to contribute to eth2!
Running Bazel tests
All code we check into our repo needs to have sufficient tests to ensure it is maintainable and works as expected. We use bazel to run all of our test suites in Prysm. If there is a particular subfolder you want to test, such as
beacon-chain/rpc/node, you can run the command:
For running a specific test, for example, a test called
TestNode_GetPeers inside of
beacon-chain/node/node_test.go, you can use Bazel to filter it out:
For the list of all available flags to the
bazel test command, you can see the reference documentation here.
You can also run our full, end-to-end test suite with:
Contributing to the Eth2 API
The eth2 API implemented by Prysm is maintained as a separate repository than Prysm. You can read more about how to contribute specifically to the API here.
Making your first contribution
Each time you begin a set of changes, ensure that you are working on a new branch that you have created as opposed to the
master of your local repository. By keeping your changes segregated in this branch, merging your changes into the main repository later will be much simpler for the team.
To create a local branch for
git to checkout, issue the command:
To checkout a branch you have already created:
Preparing your commit
To fetch changes to the Prysm repository since your last session:
Then synchronize your master branch:
To stage the changed files that are be committed, issue the command:
Once you are ready to make a commit, you can do so with:
–amend flag can be used as well to include previous commits that have not yet been pushed to an upstream repository.
If there are conflicts between your edits and those made by others since you started work Git will ask you to resolve them. To find out which files have conflicts, run:
Open those files, and you will see lines inserted by Git that identify the conflicts:
The code from the Prysm repository is inserted between
=== while the change you have made is inserted between
>>>>. Remove everything between
>>> and replace it with code that resolves the conflict. Repeat the process for all files listed by Git status to have conflicts.
When you are ready, use git push to move your local copy of the changes to your fork of the repository on Github.
Opening a pull request
Navigate to your fork of the repository on Github. In the upper left where the current branch is listed, change the branch to your newly created one. Open the files that you have worked on and ensure they include your changes.
Navigate to https://github.com/prysmaticlabs/prysm and click on the new pull request button. In the “base” box on the left, leave the default selection “base master”, the branch that you want your changes to be applied to. In the “compare” box on the right, select the branch containing the changes you want to apply. You will then be asked to answer a few questions about your pull request. Pull requests should have enough context about what you are working on, how you are solving a problem, and reference all necessary information for your reviewers to help.
After you complete the questionnaire, the pull request will appear in the list of pull requests at https://github.com/prysmaticlabs/prysm/pulls.
Core developers may ask questions and request that you make edits. If you set notifications at the top of the page to “not watching,” you will still be notified by email whenever someone comments on the page of a pull request you have created. If you are asked to modify your pull request, edit your local branch, push up your fixes, then leave a comment to notify the original reviewer that the pull request is ready for further review.