88 ForkChoiceErrorCode ,
99 NotReorgedReason ,
1010 getSafeExecutionBlockHash ,
11- isGloasBlock ,
1211} from "@lodestar/fork-choice" ;
1312import {
1413 ForkPostAltair ,
@@ -87,7 +86,7 @@ export async function importBlock(
8786 fullyVerifiedBlock : FullyVerifiedBlock ,
8887 opts : ImportBlockOpts
8988) : Promise < void > {
90- const { blockInput, postBlockState , parentBlockSlot, executionStatus, dataAvailabilityStatus, indexedAttestations} =
89+ const { blockInput, postState , parentBlockSlot, executionStatus, dataAvailabilityStatus, indexedAttestations} =
9190 fullyVerifiedBlock ;
9291 const block = blockInput . getBlock ( ) ;
9392 const source = blockInput . getBlockSource ( ) ;
@@ -99,7 +98,7 @@ export async function importBlock(
9998 const blockEpoch = computeEpochAtSlot ( blockSlot ) ;
10099 const prevFinalizedEpoch = this . forkChoice . getFinalizedCheckpoint ( ) . epoch ;
101100 const blockDelaySec =
102- fullyVerifiedBlock . seenTimestampSec - computeTimeAtSlot ( this . config , blockSlot , postBlockState . genesisTime ) ;
101+ fullyVerifiedBlock . seenTimestampSec - computeTimeAtSlot ( this . config , blockSlot , postState . genesisTime ) ;
103102 const recvToValLatency = Date . now ( ) / 1000 - ( opts . seenTimestampSec ?? Date . now ( ) / 1000 ) ;
104103 const fork = this . config . getForkSeq ( blockSlot ) ;
105104
@@ -122,10 +121,10 @@ export async function importBlock(
122121 // 2. Import block to fork choice
123122
124123 // Should compute checkpoint balances before forkchoice.onBlock
125- this . checkpointBalancesCache . processState ( blockRootHex , postBlockState ) ;
124+ this . checkpointBalancesCache . processState ( blockRootHex , postState ) ;
126125 const blockSummary = this . forkChoice . onBlock (
127126 block . message ,
128- postBlockState ,
127+ postState ,
129128 blockDelaySec ,
130129 currentSlot ,
131130 fork >= ForkSeq . gloas ? ExecutionStatus . PayloadSeparated : executionStatus ,
@@ -134,11 +133,7 @@ export async function importBlock(
134133
135134 // This adds the state necessary to process the next block
136135 // Some block event handlers require state being in state cache so need to do this before emitting EventType.block
137- // Pre-Gloas: blockSummary.payloadStatus is always FULL, payloadPresent = true
138- // Post-Gloas: blockSummary.payloadStatus is always PENDING, so payloadPresent = false (block state only, no payload processing yet)
139- const payloadPresent = ! isGloasBlock ( blockSummary ) ;
140- // processState manages both block state and payload state variants together for memory/disk management
141- this . regen . processBlockState ( blockRootHex , postBlockState ) ;
136+ this . regen . processState ( blockRootHex , postState ) ;
142137
143138 // For Gloas blocks, create PayloadEnvelopeInput so it's available for later payload import
144139 if ( fork >= ForkSeq . gloas ) {
@@ -191,7 +186,7 @@ export async function importBlock(
191186 ( opts . importAttestations !== AttestationImportOpt . Skip && blockEpoch >= currentEpoch - FORK_CHOICE_ATT_EPOCH_LIMIT )
192187 ) {
193188 const attestations = block . message . body . attestations ;
194- const rootCache = new RootCache ( postBlockState ) ;
189+ const rootCache = new RootCache ( postState ) ;
195190 const invalidAttestationErrorsByCode = new Map < string , { error : Error ; count : number } > ( ) ;
196191
197192 const addAttestation = fork >= ForkSeq . electra ? addAttestationPostElectra : addAttestationPreElectra ;
@@ -205,7 +200,7 @@ export async function importBlock(
205200 const attDataRoot = toRootHex ( ssz . phase0 . AttestationData . hashTreeRoot ( indexedAttestation . data ) ) ;
206201 addAttestation . call (
207202 this ,
208- postBlockState ,
203+ postState ,
209204 target ,
210205 attDataRoot ,
211206 attestation as Attestation < ForkPostElectra > ,
@@ -320,7 +315,7 @@ export async function importBlock(
320315
321316 if ( newHead . blockRoot !== oldHead . blockRoot ) {
322317 // Set head state as strong reference
323- this . regen . updateHeadState ( newHead , postBlockState ) ;
318+ this . regen . updateHeadState ( newHead , postState ) ;
324319
325320 try {
326321 this . emitter . emit ( routes . events . EventType . head , {
@@ -390,10 +385,10 @@ export async function importBlock(
390385 // we want to import block asap so do this in the next event loop
391386 callInNextEventLoop ( ( ) => {
392387 try {
393- if ( isStatePostAltair ( postBlockState ) ) {
388+ if ( isStatePostAltair ( postState ) ) {
394389 this . lightClientServer ?. onImportBlockHead (
395390 block . message as BeaconBlock < ForkPostAltair > ,
396- postBlockState ,
391+ postState ,
397392 parentBlockSlot
398393 ) ;
399394 }
@@ -415,11 +410,11 @@ export async function importBlock(
415410 // and the block is weak and can potentially be reorged out.
416411 let shouldOverrideFcu = false ;
417412
418- if ( blockSlot >= currentSlot && isStatePostBellatrix ( postBlockState ) && postBlockState . isExecutionStateType ) {
413+ if ( blockSlot >= currentSlot && isStatePostBellatrix ( postState ) && postState . isExecutionStateType ) {
419414 let notOverrideFcuReason = NotReorgedReason . Unknown ;
420415 const proposalSlot = blockSlot + 1 ;
421416 try {
422- const proposerIndex = postBlockState . getBeaconProposer ( proposalSlot ) ;
417+ const proposerIndex = postState . getBeaconProposer ( proposalSlot ) ;
423418 const feeRecipient = this . beaconProposerCache . get ( proposerIndex ) ;
424419
425420 if ( feeRecipient ) {
@@ -499,22 +494,22 @@ export async function importBlock(
499494 }
500495 }
501496
502- if ( ! postBlockState . isStateValidatorsNodesPopulated ( ) ) {
503- this . logger . verbose ( "After importBlock caching postState without SSZ cache" , { slot : postBlockState . slot } ) ;
497+ if ( ! postState . isStateValidatorsNodesPopulated ( ) ) {
498+ this . logger . verbose ( "After importBlock caching postState without SSZ cache" , { slot : postState . slot } ) ;
504499 }
505500
506501 // Cache shufflings when crossing an epoch boundary
507502 const parentEpoch = computeEpochAtSlot ( parentBlockSlot ) ;
508503 if ( parentEpoch < blockEpoch ) {
509- this . shufflingCache . processState ( postBlockState ) ;
504+ this . shufflingCache . processState ( postState ) ;
510505 this . logger . verbose ( "Processed shuffling for next epoch" , { parentEpoch, blockEpoch, slot : blockSlot } ) ;
511506 }
512507
513508 if ( blockSlot % SLOTS_PER_EPOCH === 0 ) {
514509 // Cache state to preserve epoch transition work
515- const checkpointState = postBlockState ;
510+ const checkpointState = postState ;
516511 const cp = getCheckpointFromState ( checkpointState ) ;
517- this . regen . addCheckpointState ( cp , checkpointState , payloadPresent ) ;
512+ this . regen . addCheckpointState ( cp , checkpointState ) ;
518513 // consumers should not mutate state ever
519514 this . emitter . emit ( ChainEvent . checkpoint , cp , checkpointState ) ;
520515
@@ -602,11 +597,11 @@ export async function importBlock(
602597 this . metrics ?. parentBlockDistance . observe ( blockSlot - parentBlockSlot ) ;
603598 this . metrics ?. proposerBalanceDeltaAny . observe ( fullyVerifiedBlock . proposerBalanceDelta ) ;
604599 this . validatorMonitor ?. registerImportedBlock ( block . message , fullyVerifiedBlock ) ;
605- if ( isStatePostAltair ( fullyVerifiedBlock . postBlockState ) ) {
600+ if ( isStatePostAltair ( fullyVerifiedBlock . postState ) ) {
606601 this . validatorMonitor ?. registerSyncAggregateInBlock (
607602 blockEpoch ,
608603 ( block as altair . SignedBeaconBlock ) . message . body . syncAggregate ,
609- fullyVerifiedBlock . postBlockState . currentSyncCommitteeIndexed . validatorIndices
604+ fullyVerifiedBlock . postState . currentSyncCommitteeIndexed . validatorIndices
610605 ) ;
611606 }
612607
0 commit comments