* Check docs spelling * Add config * Fix docs spelling * Lint docs format * docs(flamegraph): remove note about script that was removed * sort wordlist * Set sort algo * Fix CI pipeline * hope to fix CI ordering * Disable wordlist sort check * docs(CONTRIBUTING): remove merge conflict marker and add codeblock types * refactor: change to pyspelling.yml for local runs * docs: make spell-checking wordlist case insensitive * fix: sort .wordlist.txt * refactor: alphabetize script order * fix: add docs/reference to gitignore * docs: add codeblocks to pyspelling ignore and clear all errors * docs: ignore possessive endings in spellcheck * docs: clear spelling errors in package readmes * docs: pyspelling fix generated cli.md * feat(workflows): lint generated docs * feat(workflows): add word sort to docs-check * test: unsort wordlist * fix: sort wordlist * refactor(workflow): remove unused comments --------- Co-authored-by: matthewkeil <me@matthewkeil.com> Co-authored-by: Cayman <caymannava@gmail.com>
12 KiB
Contribution Guidelines
Thanks for your interest in contributing to Lodestar. It's people like you that push the Ethereum ecosystem forward.
Prerequisites
Getting Started
- ⚙️ Run
yarnto install dependencies. - ⚙️ Run
yarn buildto build lib from source. - 📦 A
lodestarbinary will be bundled in./packages/cli/bin. - 💻 Run
./lodestar --helpto get a list of available commands and arguments.
Tests
To run tests:
- 🧪 Run
yarn test:unitfor unit tests. - 🧪 Run
yarn test:e2efor end-to-end tests. - 🧪 Run
yarn test:specfor spec tests. - 🧪 Run
yarn testto run all tests. - 🧪 Run
yarn check-typesto check TypeScript types. - 🧪 Run
yarn lintto run the linter (ESLint).
Contributing to tests:
- Test must not depend on external live resources, such that running tests for a commit must be deterministic:
- Do not pull data from external APIs like execution JSON RPC (instead run a local node).
- Do not pull unpinned versions from DockerHub (use deterministic tag) or Github (checkout commit not branch).
- Carefully design tests that depend on timing sensitive events like p2p network e2e tests. Consider that Github runners are significantly less powerful than your development environment.
Debugging Spec Tests
- To fix errors always focus on passing all minimal tests first without running mainnet tests.
- Spec tests often compare full expected vs actual states in JSON format. To better understand the diff it's convenient to use mocha's option
--inline-diffs. - A single logical error can cause many spec tests to fail. To focus on a single test at a time you can use mocha's option
--bailto stop at the first failed test - To then run only that failed test you can run against a specific file as use mocha's option
--grepto run only one case
LODESTAR_PRESET=minimal ../../node_modules/.bin/mocha --config .mocharc.spec.yml test/spec/phase0/sanity.test.ts --inline-diffs --bail --grep "attestation"
Docker
The docker-compose file requires that a .env file be present in this directory. The default.env file provides a template and can be copied .env:
cp default.env .env
Beacon node only
docker-compose up -d
Beacon node and validator
First, you must have keystores and their secrets available locally at ./keystores and your password.txt in ./secrets
docker-compose -f docker-compose.yml -f docker-compose.validator.yml up -d
Dockerized metrics + local beacon node
Run a local beacon with --metrics enabled. Then start Prometheus + Grafana with all dashboards in ./dashboards automatically loaded running:
./docker/docker-compose.local_dev.sh
First Time Contributor?
Unsure where to begin contributing to Lodestar? Here are some ideas!
- ✏️ See any typos? See any verbiage that should be changed or updated? Go for it! Github makes it easy to make contributions right from the browser.
- 🔎 Look through our outstanding unassigned issues. (Hint: look for issues labeled
meta-good-first-issueormeta-help-wanted!) - 💬 Join our Discord chat!
Reporting A Bug?
- 🗒️ Create a new issue! Select the type of issue that best fits, and please fill out as much of the information as you can.
Contribution Process
- Make sure you're familiar with our contribution guidelines (this document)!
- Create your own fork of this repository.
- Make your changes in your local fork.
- If you've made a code change, make sure to lint and test your changes (
yarn lintandyarn test:unit). - Make an open pull request when you're ready for it to be reviewed. We review PRs on a regular basis. See Pull request etiquette for more information.
- You may be asked to sign a Contributor License Agreement (CLA). We make it relatively painless with CLA-bot.
Github Style Guide
Branch Naming
If you are contributing from this repository prefix the branch name with your Github username (i.e. myusername/short-description)
Pull Request Naming
Pull request titles must be:
- Adhering to the conventional commits spec
- Short and descriptive summary
- Written in imperative present tense
- Not end with a period
For example:
- feat: add lodestar prover for execution api
- fix: ignore known block in publish blinded block flow
- refactor(reqresp)!: support byte based handlers
Pull Request Etiquette
- Pull requests should remain as drafts when they are not ready for review by maintainers. Open pull requests signal to the maintainers that it's ready for review.
- If your pull request is no longer applicable or validated to fix an issue, close your pull request.
- If your pull request is fixable and needs additional changes or commits within a short period of time, switch your pull request into a draft until it's ready.
- Otherwise, close your pull request and create a new issue instead.
Lodestar Monorepo
We're currently experimenting with hosting the majority of lodestar packages and support packages in this repository as a monorepo. We're using Lerna to manage the packages. See packages/ for a list of packages hosted in this repository.
Style Guide
- Lodestar has migrated to using ES modules.
- Many module class constructors have the following signature:
(options, dependencies)- e.g.:
public constructor(opts: IExampleOptions, {db, logger}: IExampleModules)
- e.g.:
- Modules should be designed to "do one thing and do it well!"
- Consider the interface of a module -- events included, and make sure it is coherent
- Make sure your code is properly linted
- use an IDE that will show linter errors/warnings
- run
yarn lintfrom the command line - common rules:
- Functions and variables should be
camelCase, classes should bePascalCase, constants should beUPPERCASE_WITH_UNDERSCORES. - Use
"instead of' - All functions should have types declared for all parameters and return value
- You shouldn't be using TypeScript type
any - Private class properties should not be prefixed with a
_- e.g.:
private dirty;, notprivate _dirty;
- e.g.:
- Functions and variables should be
- Make sure that your code is properly type checked:
- use an IDE that will show type errors
- run
yarn check-typesfrom the command line
- Make sure that the tests are still passing:
- run
yarn test:unitfrom the command line
- run
- Commenting: If your code does something that is not obvious or deviates from standards, leave a comment for other developers to explain your logic and reasoning.
- Use
//commenting format unless it's a comment you want people to see in their IDE. - Use
/** **/commenting format for documenting a function/variable.
- Use
- Code white space can be helpful for reading complex code, please add some.
- For unit tests, we forbid import stubbing when other approaches are feasible.
Tests style guide
Test must not depend on external live resources, such that running tests for a commit must be deterministic:
- Do not pull data from external APIs like execution JSON RPC (instead run a local node).
- Do not pull unpinned versions from dockerhub (use deterministic tag) or Github (checkout commit not branch).
- Carefully design tests that depend on timing sensitive events like p2p network e2e tests. Consider that Github runners are significantly less powerful than your development environment.
Add assertion messages where possible to ease fixing tests if they fail. If an assertion message is called from multiple times with the same stack trace, you MUST include an assertion message. For example, if an assertion is inside a for loop add some metadata to be able to locate the error source:
for (const blockResult of blocksResult) {
expect(blockResult.status).equals("processed", `wrong block ${blockResult.id} result status`);
}
Logging policy
Logging Levels
Contributors must choose the log level carefully to ensure a consistent experience for every type of user:
error: Critical issues that prevent the application from functioning correctly or cause significant disruption to users. Examples include failed network connections, crashes, or data corruption.warn: Situations that may lead to critical issues if not addressed but do not prevent the application from functioning. Examples include configuration issues, deprecated features, or temporary network disruptions.info: General sporadic informational about the node's state. Examples include initialization messages, infrequent periodic status updates, or high-level progress reports.debug: Detailed diagnostic information that can help developers or users troubleshoot specific issues. Examples include individual request logs for every REST API, networking interactions, or internal components status changes. Alias toverbose.
Logging guidelines
- Avoid excessive logging. Log messages should be clear and concise, providing enough information to understand the context and severity of the issue.
- Do not log sensitive data, such as private keys, user credentials, or personal information.
- Do not log arbitrary data from the network as ASCII or UTF8 at levels higher or equal to
info. - Use clear and concise language. Prefer to log variables in JSON format
log.debug("Action", {slot})instead of formatting the text yourselflog.debug('slot=${slot}'). - Include only relevant context in log messages, sufficient to debug the issue or action it refers to.
Contributing to Grafana dashboards
To edit or extend an existing Grafana dashboard with minimal diff:
- Grab the
.jsondashboard file from current unstable - Import file to Grafana via the web UI at
/dashboard/import. Give it some temporal name relevant to your work (i.e. the branch name) - Visually edit the dashboard
- Once done make sure to leave the exact same visual aspect as before: same refresh interval, collapsed rows, etc.
- Save the dashboard (CTRL + S)
- Run download script, see below on how to use it
- Check git diff of updated dashboards, commit, push and open your PR
Using Download Script
Create a file .secrets.env with envs
GRAFANA_API_KEY=$token
GRAFANA_URL=https://yourgrafanaapi.io
Run script to download dashboards to ./dashboards folder
node scripts/download_dashboards.mjs
Label Guide
Issues and pull requests are subject to the following labeling guidelines.
- PRs may have a status label to indicate deviation from the normal process such as
status-blockedorstatus-do-not-merge - Issues and PRs will be tagged with a
scopeandprioto indicate type and priority for triage. - All other labels allow for further evaluation and organization.
Label descriptions can be found below.
status.* Issues and Pull Request Status
Status labels apply to issues and pull requests which deviate from normal processes.
scope.* Scope Indicator
Scope is comparable to Module labels but less strict with the definition of components. It applies to both, issues and pull requests.
prio.* Prioritization Indicator
A simple indicator of issue prioritization. It mainly applies to issues.
spec.* Ethereum Consensus Spec Version Target
Issues that target a specific version of the Ethereum consensus spec, shall be tagged accordingly.
Community
Come chat with us on Discord and join our public weekly planning meetings!