From 16d4faedf0d20ac19852bfafce9bc4a93d7a7935 Mon Sep 17 00:00:00 2001 From: harkamal Date: Mon, 2 May 2022 11:45:27 +0530 Subject: [PATCH 1/2] Add merge transition/finalization banners --- .../utils/pandaMergeTransitionBanner.ts | 36 +++++++++++++++++++ .../lodestar/src/chain/blocks/verifyBlock.ts | 26 +++++++++++--- 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 packages/lodestar/src/chain/blocks/utils/pandaMergeTransitionBanner.ts diff --git a/packages/lodestar/src/chain/blocks/utils/pandaMergeTransitionBanner.ts b/packages/lodestar/src/chain/blocks/utils/pandaMergeTransitionBanner.ts new file mode 100644 index 000000000000..d0a0134013cc --- /dev/null +++ b/packages/lodestar/src/chain/blocks/utils/pandaMergeTransitionBanner.ts @@ -0,0 +1,36 @@ +/* eslint-disable no-useless-escape */ +export const POS_PANDA_MERGE_TRANSITION_BANNER = ` + _,..._,m, |, _,..._,m, |, + ,/' '""; | |, /' '""; | |, + / ". ". + ,'mmmMMMMmm. \ -|-_" 'mmmMMMMmm. \ -|-_" + _/-"^^^^^"""%#%mm, ; | _ o /-"^^^^^"""%#%mm, ; | _ o + ,m,_,' "###) ;, m,_,' "###) ;, + (###% \#/ ;##mm. (###% \#/ ;##mm. + ^#/__ ___ ; (######) #/__ ___ ; (######) + ; //.\\ //.\\ ; \####/ //.\\ //.\\ ; \####/ + _; (#\"// \\"/#) ; ,/ _; (#\"// \\"/#) ; ,/ + @##\ \##/ = "=" ,;mm/ @##\ \##/ = "=" ,;mm/ + \##>.____,...,____,<####@ \##>.____,...,____,<####@ + ""' ""' + _______ ______ ______ ______ __ __ +/ \ / \ / \ / \ / | / | +$$$$$$$ | ______ ______ ______ /$$$$$$ | ______ /$$$$$$ | /$$$$$$ |_$$ |_ ______ $$ | __ ______ +$$ |__$$ |/ \ / \ / \ $$ |_ $$/ / \ $$ |_ $$/ $$ \__$$// $$ | / \ $$ | / | / \ +$$ $$//$$$$$$ |/$$$$$$ |/$$$$$$ |$$ | /$$$$$$ |$$ | $$ \$$$$$$/ $$$$$$ |$$ |_/$$/ /$$$$$$ | +$$$$$$$/ $$ | $$/ $$ | $$ |$$ | $$ |$$$$/ $$ | $$ |$$$$/ $$$$$$ | $$ | __ / $$ |$$ $$< $$ $$ | +$$ | $$ | $$ \__$$ |$$ \__$$ |$$ | $$ \__$$ |$$ | / \__$$ | $$ |/ |/$$$$$$$ |$$$$$$ \ $$$$$$$$/ +$$ | $$ | $$ $$/ $$ $$/ $$ | $$ $$/ $$ | $$ $$/ $$ $$/ $$ $$ |$$ | $$ |$$ | +$$/ $$/ $$$$$$/ $$$$$$/ $$/ $$$$$$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ + + + + ______ __ __ __ __ + / \ / | / | / | / | +/$$$$$$ | _______ _$$ |_ $$/ __ __ ______ _$$ |_ ______ ____$$ | +$$ |__$$ | / |/ $$ | / |/ \ / |/ \ / $$ | / \ / $$ | +$$ $$ |/$$$$$$$/ $$$$$$/ $$ |$$ \ /$$/ $$$$$$ |$$$$$$/ /$$$$$$ |/$$$$$$$ | +$$$$$$$$ |$$ | $$ | __ $$ | $$ /$$/ / $$ | $$ | __ $$ $$ |$$ | $$ | +$$ | $$ |$$ \_____ $$ |/ |$$ | $$ $$/ /$$$$$$$ | $$ |/ |$$$$$$$$/ $$ \__$$ | +$$ | $$ |$$ | $$ $$/ $$ | $$$/ $$ $$ | $$ $$/ $$ |$$ $$ | +$$/ $$/ $$$$$$$/ $$$$/ $$/ $/ $$$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ `; diff --git a/packages/lodestar/src/chain/blocks/verifyBlock.ts b/packages/lodestar/src/chain/blocks/verifyBlock.ts index 302bde6c98c0..3f230402eafd 100644 --- a/packages/lodestar/src/chain/blocks/verifyBlock.ts +++ b/packages/lodestar/src/chain/blocks/verifyBlock.ts @@ -19,6 +19,7 @@ import {FullyVerifiedBlock, PartiallyVerifiedBlock} from "./types"; import {ExecutePayloadStatus} from "../../executionEngine/interface"; import {byteArrayEquals} from "../../util/bytes"; import {IEth1ForBlockProduction} from "../../eth1"; +import {POS_PANDA_MERGE_TRANSITION_BANNER} from "./utils/pandaMergeTransitionBanner"; export type VerifyBlockModules = { bls: IBlsVerifier; @@ -43,14 +44,13 @@ export async function verifyBlock( ): Promise { const parentBlock = verifyBlockSanityChecks(chain, partiallyVerifiedBlock); - const {postState, executionStatus} = await verifyBlockStateTransition(chain, partiallyVerifiedBlock, opts); + const processedBlockData = await verifyBlockStateTransition(chain, partiallyVerifiedBlock, opts); return { block: partiallyVerifiedBlock.block, - postState, parentBlock, skipImportingAttestations: partiallyVerifiedBlock.skipImportingAttestations, - executionStatus, + ...processedBlockData, }; } @@ -151,7 +151,6 @@ export async function verifyBlockStateTransition( chain.metrics ); - // TODO: Review mergeBlock conditions /** Not null if execution is enabled */ const executionPayloadEnabled = bellatrix.isBellatrixStateType(postState) && @@ -317,5 +316,24 @@ export async function verifyBlockStateTransition( }); } + // All checks have passed, if this is a merge transition block we can log + if (isMergeTransitionBlock) { + logOnPowBlock(chain, block); + } + return {postState, executionStatus}; } + +function logOnPowBlock(chain: VerifyBlockModules, block: allForks.SignedBeaconBlock): void { + const mergeBlock = block.message as bellatrix.BeaconBlock; + const mergeBlockHash = toHexString(chain.config.getForkTypes(mergeBlock.slot).BeaconBlock.hashTreeRoot(mergeBlock)); + const mergeExecutionHash = toHexString(mergeBlock.body.executionPayload.blockHash); + const mergePowHash = toHexString(mergeBlock.body.executionPayload.parentHash); + chain.logger.info(POS_PANDA_MERGE_TRANSITION_BANNER); + chain.logger.info("Execution transitioning from PoW to PoS!!!"); + chain.logger.info("Importing block referencing terminal PoW block", { + blockHash: mergeBlockHash, + executionHash: mergeExecutionHash, + powHash: mergePowHash, + }); +} From 794483a3ecaeb3ae3442df22fb69164b244851cc Mon Sep 17 00:00:00 2001 From: harkamal Date: Thu, 12 May 2022 13:03:47 +0530 Subject: [PATCH 2/2] fix signatures --- packages/lodestar/src/chain/blocks/verifyBlock.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/lodestar/src/chain/blocks/verifyBlock.ts b/packages/lodestar/src/chain/blocks/verifyBlock.ts index 3f230402eafd..e9cfd08cda40 100644 --- a/packages/lodestar/src/chain/blocks/verifyBlock.ts +++ b/packages/lodestar/src/chain/blocks/verifyBlock.ts @@ -44,13 +44,14 @@ export async function verifyBlock( ): Promise { const parentBlock = verifyBlockSanityChecks(chain, partiallyVerifiedBlock); - const processedBlockData = await verifyBlockStateTransition(chain, partiallyVerifiedBlock, opts); + const {postState, executionStatus} = await verifyBlockStateTransition(chain, partiallyVerifiedBlock, opts); return { block: partiallyVerifiedBlock.block, + postState, parentBlock, skipImportingAttestations: partiallyVerifiedBlock.skipImportingAttestations, - ...processedBlockData, + executionStatus, }; } @@ -318,14 +319,14 @@ export async function verifyBlockStateTransition( // All checks have passed, if this is a merge transition block we can log if (isMergeTransitionBlock) { - logOnPowBlock(chain, block); + logOnPowBlock(chain, block as bellatrix.SignedBeaconBlock); } return {postState, executionStatus}; } -function logOnPowBlock(chain: VerifyBlockModules, block: allForks.SignedBeaconBlock): void { - const mergeBlock = block.message as bellatrix.BeaconBlock; +function logOnPowBlock(chain: VerifyBlockModules, block: bellatrix.SignedBeaconBlock): void { + const mergeBlock = block.message; const mergeBlockHash = toHexString(chain.config.getForkTypes(mergeBlock.slot).BeaconBlock.hashTreeRoot(mergeBlock)); const mergeExecutionHash = toHexString(mergeBlock.body.executionPayload.blockHash); const mergePowHash = toHexString(mergeBlock.body.executionPayload.parentHash);