Skip to content

Commit

Permalink
stateTransition is not async
Browse files Browse the repository at this point in the history
  • Loading branch information
dgcoffman committed Nov 17, 2022
1 parent 2942065 commit 013d173
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-node/src/api/impl/beacon/state/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async function getFinalizedState(

// process blocks up to the requested slot
for await (const block of db.blockArchive.valuesStream({gt: state.slot, lte: slot})) {
state = await stateTransition(state, block, undefined, {
state = stateTransition(state, block, undefined, {
verifyStateRoot: false,
verifyProposer: false,
verifySignatures: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function verifyBlocksStateTransitionOnly(
// STFN - per_slot_processing() + per_block_processing()
// NOTE: `regen.getPreState()` should have dialed forward the state already caching checkpoint states
const useBlsBatchVerify = !opts?.disableBlsBatchVerify;
const postState = await stateTransition(
const postState = stateTransition(
preState,
block,
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function computeNewStateRoot(
// Set signature to zero to re-use stateTransition() function which requires the SignedBeaconBlock type
const blockEmptySig = {message: block, signature: ZERO_HASH} as allForks.FullOrBlindedSignedBeaconBlock;

const postState = await stateTransition(
const postState = stateTransition(
state,
blockEmptySig,
undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/regen/regen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class StateRegenerator implements IStateRegenerator {
try {
// Only advances state trusting block's signture and hashes.
// We are only running the state transition to get a specific state's data.
state = await stateTransition(
state = stateTransition(
state,
block,
undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/state-transition/src/stateTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ export type StateTransitionOpts = EpochProcessOpts & {
/**
* Implementation Note: follows the optimizations in protolambda's eth2fastspec (https://github.com/protolambda/eth2fastspec)
*/
export async function stateTransition(
export function stateTransition(
state: CachedBeaconStateAllForks,
signedBlock: allForks.FullOrBlindedSignedBeaconBlock,
blobsSidecar?: BlobsSidecar,
options?: StateTransitionOpts,
metrics?: IBeaconStateTransitionMetrics | null
): Promise<CachedBeaconStateAllForks> {
): CachedBeaconStateAllForks {
const {verifyStateRoot = true, verifyProposer = true, verifySignatures = true, verifyBlobs = true} = options || {};

const block = signedBlock.message;
Expand Down

0 comments on commit 013d173

Please sign in to comment.