Using the Beacon node as a Blockchain API
The beacon chain is the coordinator of the Ethereum 2.0 network. It is responsible for creating new blocks, ensuring their validity, and both rewarding and penalizing participating validators for their actions. This responsibility gives the beacon node full visibility of actions performed on the blockchain, and as such, can be used as a retrospective API in order to query chain information. Whilst this could be considered analogous to log analysis, unlike in log analysis, previous states that have not had full data stored locally for review can be requested, then fetched retrospectively and queried.
By default, the Prysm beacon node saves the state of the chain locally in a database every 32 slots. For clarity, a slot is every 12 seconds and 32 slots make an epoch. Hence the beacon node, by default, saves the state on a per epoch basis. Should more detailed information on historical slots be required, these can be requested retrospectively. However, there will be a time delay whilst the data is requested and retrieved.
Aditional storage will be required
In addition to having to download the slot/epoch data there will be an increased local storage requirement, potentially by a multiple of 32 should all data be requested.
The default setting will store one state per epoch, each being ~ 1Mb (or more) of data, setting the beacon node to capture all slots per epoch will increase the storage requirements to ~ 32Mb (or more) per epoch.
Whilst the default setting is sufficient for regular beacon chain functionality, it is not optimized for users who query the API multiple times per slot or require historical data not available within the currently saved state. In order to avoid the delays outlined above when retrieving data, the beacon node can be configured to save the state for each slot. This will significantly improve performance for users creating multiple requests of local beacon nodes.
Beacon chain API information
Full details of the Ethereum 2.0 API are available here:
The Prysm documenation portal [Ethereum 2.0 public API] (https://docs.prylabs.network/docs/how-prysm-works/prysm-public-api)
The Prysm github [ethereumapis page] (https://github.com/prysmaticlabs/ethereumapis/blob/master/eth/v1alpha1/beacon_chain.proto#L36)
Command line/Configuration file usage:
Setting the beacon node to save the state for each slot can be done both on the command line and through the configuration file as outlined below.
Using Linux/MacOS based systems
Using Windows based systems
Using the Configuration file:
If you are running Prysm and specifying command line flags via a configuration file such as /home/beacon/config.yaml on Linux or MacOS or c:\prysm\beacon\config.yaml on Windows, you can add the following to that file: