@@ -61,24 +61,29 @@ func (e *EngineController) onPayloadSuccess(ctx context.Context, ev PayloadSucce
6161func  (e  * EngineController ) logBlockProcessingMetrics (updateEngineFinish  time.Time , ev  PayloadSuccessEvent ) {
6262	// Protect against nil pointer dereferences 
6363	if  ev .Envelope  ==  nil  ||  ev .Envelope .ExecutionPayload  ==  nil  {
64- 		e .log .Debug ("Envelope.ExecutionPayload not found, skipping block processing metrics" )
64+ 		e .log .Info ("Envelope.ExecutionPayload not found, skipping block processing metrics" )
6565		return 
6666	}
6767
68- 	buildTime  :=  ev .InsertStarted .Sub (ev .BuildStarted )
68+ 	mgas  :=  float64 (ev .Envelope .ExecutionPayload .GasUsed ) /  1e6 
69+ 	buildTime  :=  time .Duration (0 )
6970	insertTime  :=  updateEngineFinish .Sub (ev .InsertStarted )
71+ 	totalTime  :=  insertTime 
7072
71- 	var  totalTime  time.Duration 
73+ 	// BuildStarted may be zero if sequencer already built + gossiped a block, but failed during 
74+ 	// insertion and needed a retry of the insertion. In that case we use the default values above, 
75+ 	// otherwise we calculate buildTime and totalTime below 
7276	if  ! ev .BuildStarted .IsZero () {
77+ 		buildTime  =  ev .InsertStarted .Sub (ev .BuildStarted )
7378		totalTime  =  updateEngineFinish .Sub (ev .BuildStarted )
74- 	} else  {
75- 		totalTime  =  insertTime 
7679	}
7780
7881	// Protect against divide-by-zero 
79- 	var  mgasps  float64 
82+ 	var  mgasps  float64   // Mgas/s 
8083	if  totalTime  >  0  {
81- 		mgasps  =  float64 (ev .Envelope .ExecutionPayload .GasUsed ) *  1000  /  float64 (totalTime )
84+ 		// Calculate "block-processing" Mgas/s. 
85+ 		// NOTE: "realtime" mgasps (chain throughput) is a different calculation: (GasUsed / blockPeriod) 
86+ 		mgasps  =  mgas  /  totalTime .Seconds ()
8287	}
8388
8489	e .log .Info ("Inserted new L2 unsafe block" ,
@@ -87,7 +92,7 @@ func (e *EngineController) logBlockProcessingMetrics(updateEngineFinish time.Tim
8792		"build_time" , common .PrettyDuration (buildTime ),
8893		"insert_time" , common .PrettyDuration (insertTime ),
8994		"total_time" , common .PrettyDuration (totalTime ),
90- 		"mgas" , float64 ( ev . Envelope . ExecutionPayload . GasUsed ) / 1000000 ,
95+ 		"mgas" , mgas ,
9196		"mgasps" , mgasps ,
9297	)
9398}
0 commit comments