eth2fastspec-0.0.5
توضیحات
Optimized version of eth2spec
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | eth2fastspec-0.0.5 |
| نام | eth2fastspec |
| نسخه کتابخانه | 0.0.5 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | protolambda |
| ایمیل نویسنده | proto+pip@protolambda.com |
| آدرس صفحه اصلی | https://github.com/protolambda/eth2fastspec |
| آدرس اینترنتی | https://pypi.org/project/eth2fastspec/ |
| مجوز | MIT |
# `eth2fastspec`
[](https://pypi.python.org/pypi/eth2fastspec) [](https://pypi.python.org/pypi/eth2fastspec) [](https://pypi.python.org/pypi/eth2fastspec) [](https://pypi.python.org/pypi/eth2fastspec)
Eth2fastspec is an extension to [`eth2spec`](https://pypi.org/project/eth2spec/), utilizing the same types, configuration and dependencies, but optimized for transition speed.
## Usage
A few new objects are introduced for precomputed data, speeding up the transition:
- `ShufflingEpoch`: Committee shuffling information for a single epoch
- `EpochsContext`: A collection of contextual information to re-use during an epoch, and rotating precomputed data of the next epoch into the current epoch. This includes shuffling, but also proposer information is available.
- `epochs_ctx.load_state(state)` precomputes the data for the given state.
- `sync_pubkeys()` checks the precomputed data against a state, and then adds missing pubkeys (strictly append-only however, not meant to fork this information)
- `copy()` if a fork occurs, the context will have to be copied. To avoid copying the immutable parts, the `copy()` implements a specialized copy routine.
- `rotate_epochs()` to re-use information, such as the shuffling of the next epoch, after transitioning into a new epoch, the `rotate_epochs()` is called. The transition function takes care of epoch-context data rotation.
- `FlatValidator`: A copy of the regular `Validator`, but in a simple object instead of a tree-representation. For intermediate computation the remerkleable representation slows things down, so a regular object is used instead.
- `AttesterStatus`: During the epoch transition, additional data is precomputed to avoid traversing any state a second time. Attestations are a big part of this, and each validator has an "status" to represent its precomputed participation.
- `EpochProcess`: The `AttesterStatus` (and `FlatValidator` under `status.validator`) objects and `EpochStakeSummary` are tracked in the `EpochProcess` and made available as additional context in the epoch transition.
- `prepare_epoch_process_state(epochs_ctx, state)` computes this data.
Method signatures in the spec changed to utilize precomputed data:
- `state_transition`, `process_slots`, `process_slot`, `process_epoch`, every epoch sub-process, `process_block`, every block sub-process, and `verify_block_signature` all have an additional `epochs_ctx` (`EpochsContext`) argument.
- every epoch sub-process has an additional `process` (`EpochProcess`) argument.
The argument order is generally: `epochs_ctx`, `proces`, `state`, remaining args.
```python
from eth2spec.config.config_util import prepare_config
# Example: load a config, loading it in `eth2spec` as well as `eth2fastspec`, before loading the spec modules.
prepare_config("./lighthouse", "config")
import eth2fastspec as spec
state: spec.BeaconState = ... # BeaconState.deserialize(stream, size), or some other source.
block: spec.SignedBeaconBlock = ...
epochs_ctx = spec.EpochsContext()
epochs_ctx.load_state(state)
spec.state_transition(epochs_ctx, state, block)
print(state.hash_tree_root().hex())
```
## License
MIT, see [LICENSE](./LICENSE) file.
نیازمندی
| مقدار | نام |
|---|---|
| <0.13,>=0.12.1 | eth2spec |
| >=0.1.16 | remerkleable |
| ==1.3.0 | milagro-bls-binding |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8, <4 | Python |
نحوه نصب
نصب پکیج whl eth2fastspec-0.0.5:
pip install eth2fastspec-0.0.5.whl
نصب پکیج tar.gz eth2fastspec-0.0.5:
pip install eth2fastspec-0.0.5.tar.gz