From 5ae93061d4c550ae820ca8ef76cf5737de7a9fa2 Mon Sep 17 00:00:00 2001 From: Saulius Grigaitis Date: Tue, 2 Apr 2024 16:25:26 +0300 Subject: [PATCH] Moved Grandine book to this repo --- .gitignore | 2 + book/book.toml | 9 ++ book/src/SUMMARY.md | 14 +++ book/src/beacon_node_api.md | 21 +++++ book/src/builder_api_and_mev.md | 10 ++ book/src/checkpoint_sync.md | 8 ++ book/src/cli_options.md | 160 ++++++++++++++++++++++++++++++++ book/src/downloads.md | 16 ++++ book/src/metrics.md | 16 ++++ book/src/slashing_protection.md | 17 ++++ book/src/storage.md | 22 +++++ book/src/subcommands.md | 8 ++ book/src/support.md | 9 ++ book/src/validator_client.md | 29 ++++++ book/src/web3signer.md | 7 ++ 15 files changed, 348 insertions(+) create mode 100644 book/book.toml create mode 100644 book/src/SUMMARY.md create mode 100644 book/src/beacon_node_api.md create mode 100644 book/src/builder_api_and_mev.md create mode 100644 book/src/checkpoint_sync.md create mode 100644 book/src/cli_options.md create mode 100644 book/src/downloads.md create mode 100644 book/src/metrics.md create mode 100644 book/src/slashing_protection.md create mode 100644 book/src/storage.md create mode 100644 book/src/subcommands.md create mode 100644 book/src/support.md create mode 100644 book/src/validator_client.md create mode 100644 book/src/web3signer.md diff --git a/.gitignore b/.gitignore index 65b96adc..40719674 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ cobertura.xml /target/ +book/book +book/deploy diff --git a/book/book.toml b/book/book.toml new file mode 100644 index 00000000..7371d35f --- /dev/null +++ b/book/book.toml @@ -0,0 +1,9 @@ +[book] +authors = ["Saulius Grigaitis"] +language = "en" +multilingual = false +src = "src" +title = "Grandine" + +[output.html] +default-theme = "ayu" diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md new file mode 100644 index 00000000..35997e66 --- /dev/null +++ b/book/src/SUMMARY.md @@ -0,0 +1,14 @@ +# Summary + +- [Beacon Node API](./beacon_node_api.md) +- [Builder API and MEV](./builder_api_and_mev.md) +- [Checkpoint Sync](./checkpoint_sync.md) +- [CLI Options](./cli_options.md) +- [Downloads](./downloads.md) +- [Metrics](./metrics.md) +- [Slashing Protection](./slashing_protection.md) +- [Storage](./storage.md) +- [Subcommands](./subcommands.md) +- [Validator Client](./validator_client.md) +- [Web3Signer](./web3signer.md) +- [Support](./support.md) diff --git a/book/src/beacon_node_api.md b/book/src/beacon_node_api.md new file mode 100644 index 00000000..552c69cf --- /dev/null +++ b/book/src/beacon_node_api.md @@ -0,0 +1,21 @@ +## Beacon Node API + +Grandine supports standard [Beacon Node API](https://ethereum.github.io/beacon-APIs/). This API is extensively tested against other CL validator clients and other Beacon Node API consumers such as [Vouch](https://github.com/attestantio/vouch). API is enabled by default. An example of running Grandine Beacon Node with API enabled by default: + +``` +docker run \ + -p 9000:9000/tcp \ + -p 9000:9000/udp \ + -v $HOME/.grandine:/root/.grandine \ + -v $HOME/.grandine/jwtsecret:/root/.grandine/jwtsecret \ + sifrai/grandine:unstable grandine \ + --checkpoint-sync-url CHECKPOINT-SYNC-URL \ + --eth1-rpc-urls ETH1-RPC-URL \ + --jwt-secret JWT-SECRET-PATH +``` + +### Relevant command line options: + +* `--http-port` - sets API listen port (default: `5052`); +* `--http-address` - sets API listen address (default: `127.0.0.1`); +* `--timeout` - sets API timeout in miliseconds (default: `10000`). diff --git a/book/src/builder_api_and_mev.md b/book/src/builder_api_and_mev.md new file mode 100644 index 00000000..f8f5c01c --- /dev/null +++ b/book/src/builder_api_and_mev.md @@ -0,0 +1,10 @@ +## Builder API and MEV + +Grandine supports [Builder API](https://github.com/ethereum/builder-specs) for stakers that use MEV. Only a single builder URL can be passed to Grandine. Multiple builders can be used via relay such as [mev-boost](https://github.com/flashbots/mev-boost) or [mev-rs](https://github.com/ralexstokes/mev-rs). Grandine provides a configurable circuit breaker that disables external block building in certain conditions. + +### Relevant command line options: + +* `--builder-api-url` - external block builder URL (default: does not use any external builder); +* `--builder-disable-checks` - always specified external block builder without checking for circuit breaker conditions (default: disabled); +* `--builder-max-skipped-slots` - number of consecutive missing blocks to trigger circuit breaker condition and switch to a local execution engine for payload construction (default: `3`); +* `--builder-max-skipped-slots-per-epoch` - number of missing blocks in the last rolling epoch to trigger circuit breaker condition and switch to a local execution engine for payload construction (default: `5`). diff --git a/book/src/checkpoint_sync.md b/book/src/checkpoint_sync.md new file mode 100644 index 00000000..f281b1fb --- /dev/null +++ b/book/src/checkpoint_sync.md @@ -0,0 +1,8 @@ +## Checkpoint Sync + +Grandine supports checkpoint sync. Currently, it's the preferred way to sync the chain. By default, back-syncing is disabled, so no historical blocks are fetched and no historical states are reconstructed. This default behavior is sufficient for staking, however, for other use cases (such as historical data access via Beacon Node API) back-syncing must be enabled. + +### Relevant command line options + +* `--checkpoint-sync-url` - Beacon Node API URL to load a recent finalized checkpoint and sync from it (default: disabled) +* `--back-sync` - enables back-syncing blocks and reconstructing states (default: disabled) diff --git a/book/src/cli_options.md b/book/src/cli_options.md new file mode 100644 index 00000000..15cc92f3 --- /dev/null +++ b/book/src/cli_options.md @@ -0,0 +1,160 @@ +## CLI options + +The list of command line options: + +``` + --network + Name of the Eth2 network to connect to [default: mainnet] [possible values: mainnet, goerli, custom] + --configuration-file + Load configuration from YAML_FILE + --configuration-directory + Load configuration from directory + --verify-phase0-preset-file + Verify that Phase 0 variables in preset match YAML_FILE + --verify-altair-preset-file + Verify that Altair variables in preset match YAML_FILE + --verify-bellatrix-preset-file + Verify that Bellatrix variables in preset match YAML_FILE + --verify-capella-preset-file + Verify that Capella variables in preset match YAML_FILE + --verify-configuration-file + Verify that configuration matches YAML_FILE + --terminal-total-difficulty-override + Override TERMINAL_TOTAL_DIFFICULTY + --terminal-block-hash-override + Override TERMINAL_BLOCK_HASH + --terminal-block-hash-activation-epoch-override + Override TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH + --deposit-contract-starting-block + Start tracking deposit contract from BLOCK_NUMBER + --genesis-state-file + Load genesis state from SSZ_FILE + --max-empty-slots + [default: 32] + --checkpoint-sync-url + Beacon node API URL to load recent finalized checkpoint and sync from it [default: None] + --force-checkpoint-sync + Force checkpoint sync. Requires --checkpoint-sync-url [default: disabled] + --eth1-rpc-urls ... + List of Eth1 RPC URLs + --data-dir + Parent directory for application data files [default: $HOME/.grandine/{network}] + --store-directory + Directory to store application data files [default: {data_dir}/beacon] + --network-dir + Directory to store application network files [default: {data_dir}/network] + --archival-epoch-interval + [default: 32] + --prune-storage + Enable prune mode where only single checkpoint state & block are stored in the DB [default: disabled] + --unfinalized-states-in-memory + Number of unfinalized states to keep in memory. Specifying this number enables unfinalized state pruning. By default all unfinalized states are kept in memory. [default: None] + --database-size + Max size of the Eth2 database [default: "274.9 GB"] + --eth1-database-size + Max size of the Eth1 database [default: "17.2 GB"] + --request-timeout + Default global request timeout for various services in milliseconds [default: 30000] + --http-address + HTTP API address [default: 127.0.0.1] + --http-port + HTTP API port [default: 5052] + --state-slot + State slot [default: None] + --disable-block-verification-pool + Disable block signature verification pool [default: enabled] + --subscribe-all-subnets + Subscribe to all subnets + --suggested-fee-recipient + Suggested value for the feeRecipient field of the new payload + --jwt-id + Optional CL unique identifier to send to EL in the JWT token claim [default: None] + --jwt-secret + Path to a file containing the hex-encoded 256 bit secret key to be used for verifying/generating JWT tokens + --jwt-version + Optional CL node type/version to send to EL in the JWT token claim [default: None] + --back-sync + Enable syncing historical data [default: disabled] + --metrics + Collect Prometheus metrics + --metrics-address + Metrics address for metrics endpoint [default: 127.0.0.1] + --metrics-port + Listen port for metrics endpoint [default: 5054] + --remote-metrics-url + Optional remote metrics URL that Grandine will periodically send metrics to + --track-liveness + Enable validator liveness tracking [default: disabled] + --max-events + Max number of events stored in a single channel for HTTP API /events api call [default: 100] + --timeout + HTTP API timeout in milliseconds [default: 10000] + --listen-address + Listen IPv4 address [default: 0.0.0.0] + --listen-address-ipv6 + Listen IPv6 address [default: None] + --libp2p-port + libp2p IPv4 port [default: 9000] + --libp2p-port-ipv6 + libp2p IPv6 port [default: 9050] + --disable-peer-scoring + Disable peer scoring + --disable-upnp + Disable NAT traversal via UPnP [default: enabled] + --discovery-port + discv5 IPv4 port [default: 9000] + --discovery-port-ipv6 + discv5 IPv6 port [default: 9050] + --enr-address + ENR IPv4 address + --enr-address-ipv6 + ENR IPv6 address + --enr-tcp-port + ENR TCP IPv4 port + --enr-tcp-port-ipv6 + ENR TCP IPv6 port + --enr-udp-port + ENR UDP IPv4 port + --enr-udp-port-ipv6 + ENR UDP IPv6 port + --boot-nodes + List of ENR boot node addresses + --libp2p-nodes + List of Multiaddr node addresses + --target-peers + Target number of network peers [default: 80] + --trusted-peers + List of trusted peers + --slashing-enabled + Enable slasher [default: disabled] + --slashing-history-limit + Number of epochs for slasher to search for violations [default: 54000] + --keystore-dir + Path to a directory containing EIP-2335 keystore files + --keystore-password-dir + Path to a directory containing passwords for keystore files + --keystore-password-file + Path to a file containing password for keystore files + --pack-extra-attestations + Pack extra singular attestations to proposed block + --builder-api-url + External block builder API URL + --builder-disable-checks + Always use specified external block builder without checking for circuit breaker conditions + --builder-max-skipped-slots + Max allowed consecutive missing blocks to trigger circuit breaker condition and switch to local execution engine for payload construction [default: 3] + --builder-max-skipped-slots-per-epoch + Max allowed missing blocks in the last rolling epoch to trigger circuit breaker condition and switch to local execution engine for payload construction [default: 5] + --web3signer-api-urls ... + List of Web3Signer API URLs + --use-validator-key-cache + Use validator key cache for faster startup + --graffiti + + --features + List of optional runtime features to enable + -h, --help + Print help + -V, --version + Print version +``` diff --git a/book/src/downloads.md b/book/src/downloads.md new file mode 100644 index 00000000..8ad2823c --- /dev/null +++ b/book/src/downloads.md @@ -0,0 +1,16 @@ +## Downloads + +### Docker + +Docker [images](https://hub.docker.com/r/sifrai/grandine/tags) is the best way to get the latest versions of Grandine. We provide multi-platform images supporting `linux/amd64` and `linux/arm64`. Available tags: + +* `latest` - latest stable version for `linux/amd64` and `linux/arm64`; +* `latest-amd64` - latest stable version for `linux/amd64`; +* `latest-arm64` - latest stable version for `linux/arm64`; +* `unstable` - latest unstable version `linux/amd64` and `linux/arm64`; +* `unstable-amd64` - latest unstable version for `linux/amd64`; +* `unstable-arm64` - latest unstable version for `linux/arm64`. + +### Binary + +The latest stable binaries are provided on [Github](https://github.com/sifraitech/grandine/tags). Unstable binary builds are not released to Github. diff --git a/book/src/metrics.md b/book/src/metrics.md new file mode 100644 index 00000000..03a508ab --- /dev/null +++ b/book/src/metrics.md @@ -0,0 +1,16 @@ +## Metrics + +### Beacon Node metrics + +Grandine provides a set of Beacon Node metrics that are suitable to be consumed by [Prometheus](https://github.com/prometheus/prometheus) and visualized via [Grafana](https://github.com/grafana/grafana) dashboards. + +### Remote Metrics + +Grandine can to push metrics to a remote endpoint every 60 seconds. This option is useful for services such as [beaconcha.in](https://kb.beaconcha.in/beaconcha.in-explorer/mobile-app-less-than-greater-than-beacon-node). + +### Relevant command line options: + +* `--metrics` - enables metrics (default: disabled); +* `--metrics-address` - address for metrics endpoint (default: `127.0.0.1`); +* `--metrics-port` - port for metrics endpoint (default: `5054`); +* `--remote-metrics-url` - remote metrics URL that Grandine will periodically send metrics to (default: disabled). diff --git a/book/src/slashing_protection.md b/book/src/slashing_protection.md new file mode 100644 index 00000000..069549bf --- /dev/null +++ b/book/src/slashing_protection.md @@ -0,0 +1,17 @@ +## Slashing Protection + +Grandine supports the [Slashing Protection Interchange Format](https://eips.ethereum.org/EIPS/eip-3076). It's a must to migrate slashing protection data if you are switching validators between clients or servers. + +Import Slashing Protection history to Grandine: + +``` +./grandine --network goerli interchange export slashing_protection.json +``` + +Export Slashing Protection history from Grandine: + +``` +./grandine --network goerli interchange export slashing_protection.json +``` + +We highly recommend waiting for a few epochs before starting validators after migration. diff --git a/book/src/storage.md b/book/src/storage.md new file mode 100644 index 00000000..ca6974ea --- /dev/null +++ b/book/src/storage.md @@ -0,0 +1,22 @@ +## Storage + +### Memory + +By default, Grandine keeps the non-finalized part of the chain in the memory using structural sharing. This approach contributes to the high performance of Grandine because full state copies are avoided. This is a perfect approach for healthy chains (such as Ethereum Mainnet) that don't experience very long non-finalization periods. In such conditions, Grandine uses only ~1GB of memory on the Mainnet. However, during long non-finalization, this approach increases memory usage. In such cases, Grandine allows limiting the number of the latest memory stored states by settings the maximum number of the latest slots that should keep states in the memory. + +### Disk + +Grandine stores finalized part of the chain in the disk using an embedded key-value database `libmdbx`. Disk storage is passive and mainly used for storing/loading checkpoints, and serving historical data via API. Historical blocks and corresponding intermediate states are stored on the disk. It's possible to set the length of the intermediate states period. A higher value for this interval means lower disk usage and slower API responses for historical data. + +Grandine allows starting the Beacon Node from an earlier stored checkpoint by using `--state-slot` option. In this case, Grandine will try to find and load from the disk the closest stored checkpoint before the specified `--state-slot`. + +### Prune Mode + +Grandine provides `--prune-storage` option for prune mode that only stores a single checkpoint state with the corresponding block. This mode also stores unfinalized blocks on Grandine shutdown. This mode is sufficient for staking. + +### Relevant command line options + +* `--archival-epoch-interval` - sets the number of epochs between stored states (default: `32`); +* `--prune-storage` - enables pruning mode that doesn't store historical states and blocks (default: disabled); +* `--state-slot` - sets the slot at which Grandine Beacon Node should start (default: latest finalized slot); +* `--unfinalized-states-in-memory` - the number of the latest slots that will store states in the memory (default: all unfinalized states stored in the memory). diff --git a/book/src/subcommands.md b/book/src/subcommands.md new file mode 100644 index 00000000..46ea75fa --- /dev/null +++ b/book/src/subcommands.md @@ -0,0 +1,8 @@ +## Subcommands + +Grandine has a few helpful subcommands: + +* `export` - Export blocks and state to ssz files within slot range for debugging (example: `grandine export --from 0 --to 5`); +* `replay` - Replay blocks within slot range (example: `grandine replay --from 0 --to 5`); +* `interchange` - Import/export slashing protection interchange file (example: `grandine interchange import file.json`); +* `help` - Print this message or the help of the given subcommand(s). diff --git a/book/src/support.md b/book/src/support.md new file mode 100644 index 00000000..42ced28c --- /dev/null +++ b/book/src/support.md @@ -0,0 +1,9 @@ +## Support + +### Discord + +It's best to reach us via [Grandine Discord](https://discord.gg/H9XCdUSyZd). Feel free to join if you have any question! + +### Commercial support + +Please [contacts us](mainto:info@grandine.io) if you are interested in commercial support for Grandine and related services. diff --git a/book/src/validator_client.md b/book/src/validator_client.md new file mode 100644 index 00000000..2d0b30ed --- /dev/null +++ b/book/src/validator_client.md @@ -0,0 +1,29 @@ +## Validator client + +The Validator Client is a built-in component that is activated if validator keys are passed to Grandine. Let's try running Grandine with a new validator enabled on the Goerli network (assuming you already have keys, secrets etc.): + +``` +docker run \ + -p 9000:9000/tcp \ + -p 9000:9000/udp \ + -v $HOME/.grandine:/root/.grandine \ + -v $HOME/.grandine/jwtsecret:/root/.grandine/jwtsecret \ + -v $HOME/.grandine/validator_keys:/root/.grandine/validator_keys \ + -v $HOME/.grandine/secrets:/root/.grandine/secrets \ + sifrai/grandine:unstable grandine \ + --eth1-rpc-urls ETH1-RPC-URL \ + --network goerli \ + --keystore-dir /root/.grandine/validator_keys \ + --keystore-password-file /root/.grandine/secrets + --jwtsecret /root/.grandine/jwtsecret +``` + +In this example, the same secret is used to secure all the keystores, this secret should be placed in `$HOME/.grandine/secrets` file. Otherwise, for every keystore file in `$HOME/.grandine/validator_keys` there should be a corresponding file in the `$HOME/.grandine/secrets` directory with the secret file named the same as the corresponding keystore file except the extension should be `.txt` instead of `.json`. + +For any sensitive keys it's a must to use a remote signer. + +### Relevant command line options: + +* `--keystore-dir` - a directory containing validator keystore files; +* `--keystore-password-file` - a file containing a single secret for all the validator keystore files (this option usable if all the keystores are secured with the same secret); +* `--keystore-password-dir` - a directory containing secrets for all the validator keystore files (this option usable if all the keystores are secured with not the same secret), for every keystore file in `--keystore-dir` there should be a corresponding file in the `--keystore-password-dir` directory with the secret file named the same as the corresponding keystore file except the extension should be `.txt` instead of `.json`. diff --git a/book/src/web3signer.md b/book/src/web3signer.md new file mode 100644 index 00000000..3e21275a --- /dev/null +++ b/book/src/web3signer.md @@ -0,0 +1,7 @@ +## Web3Signer + +Grandine has a built-in validator that supports [Web3Signer](https://github.com/ConsenSys/web3signer). This is a recommended way to use Grandine's built-in validator with sensitive keys. We also recommend using Web3signer's built-in slashing protection even though the built-in validator has slashing protection too. Grandine automatically refreshes the validators list from the given Web3Signer instances. + +### Relevant command line options + +* `--web3signer-api-urls` - comma separated list of Web3Signer urls. Web3Signer is not used if this option is not set.