Skip to content

Commit

Permalink
Add merge transition/finalization banners
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed May 10, 2022
1 parent 15d8ae2 commit 16d4fae
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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/
\##>.____,...,____,<####@ \##>.____,...,____,<####@
""' ""'
_______ ______ ______ ______ __ __
/ \ / \ / \ / \ / | / |
$$$$$$$ | ______ ______ ______ /$$$$$$ | ______ /$$$$$$ | /$$$$$$ |_$$ |_ ______ $$ | __ ______
$$ |__$$ |/ \ / \ / \ $$ |_ $$/ / \ $$ |_ $$/ $$ \__$$// $$ | / \ $$ | / | / \
$$ $$//$$$$$$ |/$$$$$$ |/$$$$$$ |$$ | /$$$$$$ |$$ | $$ \$$$$$$/ $$$$$$ |$$ |_/$$/ /$$$$$$ |
$$$$$$$/ $$ | $$/ $$ | $$ |$$ | $$ |$$$$/ $$ | $$ |$$$$/ $$$$$$ | $$ | __ / $$ |$$ $$< $$ $$ |
$$ | $$ | $$ \__$$ |$$ \__$$ |$$ | $$ \__$$ |$$ | / \__$$ | $$ |/ |/$$$$$$$ |$$$$$$ \ $$$$$$$$/
$$ | $$ | $$ $$/ $$ $$/ $$ | $$ $$/ $$ | $$ $$/ $$ $$/ $$ $$ |$$ | $$ |$$ |
$$/ $$/ $$$$$$/ $$$$$$/ $$/ $$$$$$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/
______ __ __ __ __
/ \ / | / | / | / |
/$$$$$$ | _______ _$$ |_ $$/ __ __ ______ _$$ |_ ______ ____$$ |
$$ |__$$ | / |/ $$ | / |/ \ / |/ \ / $$ | / \ / $$ |
$$ $$ |/$$$$$$$/ $$$$$$/ $$ |$$ \ /$$/ $$$$$$ |$$$$$$/ /$$$$$$ |/$$$$$$$ |
$$$$$$$$ |$$ | $$ | __ $$ | $$ /$$/ / $$ | $$ | __ $$ $$ |$$ | $$ |
$$ | $$ |$$ \_____ $$ |/ |$$ | $$ $$/ /$$$$$$$ | $$ |/ |$$$$$$$$/ $$ \__$$ |
$$ | $$ |$$ | $$ $$/ $$ | $$$/ $$ $$ | $$ $$/ $$ |$$ $$ |
$$/ $$/ $$$$$$$/ $$$$/ $$/ $/ $$$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ `;
26 changes: 22 additions & 4 deletions packages/lodestar/src/chain/blocks/verifyBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,14 +44,13 @@ export async function verifyBlock(
): Promise<FullyVerifiedBlock> {
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,
};
}

Expand Down Expand Up @@ -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) &&
Expand Down Expand Up @@ -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,
});
}

0 comments on commit 16d4fae

Please sign in to comment.