**Motivation**
- tracks #7048
-
[era](https://github.com/eth-clients/e2store-format-specs/blob/main/formats/era.md)
specs.
**Description**
- Adds functionality to read/write to
[e2s](613f4a9a50/docs/e2store.md (era-files))
files
```ts
import {open} from "node:fs/promises";
import {e2s} from "@lodestar/era";
const fh = await open("mainnet-xxxxxx-xxxxxxxx.era");
const entry = await e2s.readEntry(fh, 0);
entry.type == e2s.EntryType.Version
```
- Adds functionality to read/write era files
```ts
import {era} from "@lodestar/era";
import {config} from "@lodestar/config/default";
// open reader
const reader = await era.EraReader.open(config, "mainnet-xxxxx-xxxxxxxx.era");
// check number of groups
reader.groups.length === 1;
// read blocks
const slot = reader.groups[0].startSlot;
// return snappy-frame compressed, ssz-serialized block at slot or null if a skip slot
// throws if out of range
await reader.readCompressedBlock(slot);
// same, but for ssz-serialized block
await reader.readSerializedBlock(slot);
// same but for deserialized block
await reader.readBlock(slot);
// read state(s), one per group
// similar api to blocks, but with an _optional_ eraNumber param for specifying which group's state to read
await reader.readCompressedState();
await reader.readSerializedState();
await reader.readState();
// write era files
const writer = await era.EraWriter.create(config, "path/to/era");
// similar api to reader, can write compressed, serialized, or deserialized items
// first write all blocks for the era
await writer.writeBlock(block);
// ...
// then write the state
await writer.writeState(state);
// if applicable, continue writing eras of blocks and state (an era file can contain multiple eras, or "groups" as the spec states)
// when finished, must call `finish`, which will close the file handler and _rename_ the file to the spec-compliant name
await writer.finish();
```
- e2e test reads an era file, does all validation, writes an era fila,
does validation on that freshly created file
- requires the era file fixture to be downloaded (`cd packages/era/test
&& ./download_era_file.sh`)
- e2e test is skipped (`test:e2e` is not defined for the era package)
---------
Co-authored-by: Cayman <caymannava@gmail.com>
Lodestar Ethereum Consensus Implementation
Lodestar is a TypeScript implementation of the Ethereum Consensus specification developed by ChainSafe Systems.
Getting started
- ⚙️ Follow the instructions for build from source, binaries, or Docker to install Lodestar. Or use our Lodestar Quickstart scripts.
- 📚 Use Lodestar libraries in your next Ethereum Typescript project.
- 🌐 Run a beacon node on mainnet or a public testnet.
- 💻 Utilize the whole stack by starting a local testnet.
- 🗒️ View the Lodestar CLI commands and options.
- 🤓 View the Package and dependency structure.
- 📝 Prospective contributors can read the contributing section to understand how we develop and test on Lodestar.
- ✍️ If you have questions submit an issue or join us on Discord!
- 🚨 Please note our security policy.
- 🐦 Follow Lodestar on Twitter for announcements and updates!
Prerequisites
Developer Quickstart:
yarn install
yarn build
./lodestar --help
Architecture Overview
- 📦 This mono-repository contains a suite of Ethereum Consensus packages.
- ⚖️ The mono-repository is released under Apache-2.0 license. Note, that the packages contain their own licenses.
| Package | Version | License | Docs | Description |
|---|---|---|---|---|
@chainsafe/lodestar |
💻 Command-line tool for Lodestar | |||
@lodestar/api |
📋 REST Client for the Ethereum Beacon API | |||
@lodestar/beacon-node |
🚨 Beacon-chain client | |||
@lodestar/config |
🗒️ Eth Consensus types and params bundled together | |||
@lodestar/db |
💾 Read/write persistent Eth Consensus data | |||
@lodestar/flare |
💥 Command tool for triggering non-standard actions | |||
@lodestar/fork-choice |
🍴 Beacon-chain fork choice | |||
@lodestar/light-client |
🐦 Ethereum Light client | |||
@lodestar/logger |
📝 NodeJS logger for Lodestar binaries | |||
@lodestar/params |
🕸️ Eth Consensus network parameters | |||
@lodestar/prover |
✅ Ethereum Light client verifier for execution JSON-RPC calls | |||
@lodestar/reqresp |
📞 Eth Consensus Req/Resp protocol | |||
@lodestar/spec-test-util |
🧪 Test harness for Eth Consensus spec tests | |||
@lodestar/state-transition |
🔎 Eth Consensus beacon-state transition | |||
@lodestar/types |
🗒️ Eth Consensus TypeScript and SSZ types | |||
@lodestar/utils |
🧰 Miscellaneous utility functions used across Lodestar | |||
@lodestar/validator |
🏦 Validator client |
Contributors
Read our contributors document, submit an issue or talk to us on our Discord!
Meetings
Weekly contributor meetings are posted under Discussions and topics are welcomed by any participant in the relevant meeting thread. Feel free to check out our meeting notes and documents on HackMD. Post-September 2021, meeting notes can be found on the Lodestar Wiki Page.
Donations
We are a local group of Toronto open-source developers. As such, all of our open-source work is funded by grants. We all take the time out of our hectic lives to contribute to the Ethereum ecosystem. If you want to donate, you can find the ETH address under "Sponsor this project" on this repository.