Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare fast state transition for forks #2303

Merged
merged 1 commit into from
Mar 31, 2021
Merged

Conversation

wemeetagain
Copy link
Member

Motivation

We want our "fast" state transition to be multi-fork aware. To that end, there should be fork-aware utilities and a fork-aware state transition function. These files should also be organized in a fork-agnostic location.

Description

  • Move phase0.fast top-level state transition function (fastStateTransition), fast utils (cached beacon state, etc), and signature set utils to a top-level fast/ directory.
  • Add stubbed switch/case(s) in fastStateTransition for other-fork logic (eg: switching out processSlots, processBlocks and upgrading the BeaconState)
  • Re-export top-level fast/ exports as fast namespace.
  • Minimal renaming/importing in lodestar and spec-test-runner packages

A followup PR can update the chain/regen/etc to use allForks.BeaconState rather than phase0.BeaconState (which will remove a lot of the explicit castings to CachedBeaconState<allForks.BeaconState>

@codeclimate
Copy link

codeclimate bot commented Mar 30, 2021

Code Climate has analyzed commit 8c35022 and detected 10 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 10

View more on Code Climate.

// verify signature
if (verifyProposer) {
if (!verifyProposerSignature(postState, signedBlock)) {
throw new Error("Invalid block signature");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add block slot/root here

Copy link
Contributor

@dapplion dapplion Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use detailed typed LodestarErrors in the state transition function too? To be tackled in new PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These errors (this and below) are untouched from before. I'll make an issue to revisit state transition errors for a future PR!

// verify state root
if (verifyStateRoot) {
if (!config.types.Root.equals(block.stateRoot, postState.tree.root)) {
throw new Error("Invalid state root");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add block stateRoot, and the expected stateRoot here

} from "../../../util";
import {FAR_FUTURE_EPOCH} from "../../../constants";
} from "../../util";
import {FAR_FUTURE_EPOCH} from "../../constants";
import {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The statusProcessEpoch function below seems to be better to put into phase0 folder, it's fine for now through

@wemeetagain wemeetagain merged commit a7bd5fb into master Mar 31, 2021
@wemeetagain wemeetagain deleted the cayman/move-fast branch March 31, 2021 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants