@@ -227,6 +227,9 @@ func (e *Executor) initializeState() error {
227227 if err := batch .SetHeight (state .LastBlockHeight ); err != nil {
228228 return fmt .Errorf ("failed to set store height: %w" , err )
229229 }
230+ if err := batch .UpdateState (state ); err != nil {
231+ return fmt .Errorf ("failed to update state: %w" , err )
232+ }
230233 if err := batch .Commit (); err != nil {
231234 return fmt .Errorf ("failed to commit batch: %w" , err )
232235 }
@@ -236,7 +239,8 @@ func (e *Executor) initializeState() error {
236239
237240 // Sync execution layer with store on startup
238241 execReplayer := common .NewReplayer (e .store , e .exec , e .genesis , e .logger )
239- if err := execReplayer .SyncToHeight (e .ctx , state .LastBlockHeight ); err != nil {
242+ syncTargetHeight := state .LastBlockHeight
243+ if err := execReplayer .SyncToHeight (e .ctx , syncTargetHeight ); err != nil {
240244 e .sendCriticalError (fmt .Errorf ("failed to sync execution layer: %w" , err ))
241245 return fmt .Errorf ("failed to sync execution layer: %w" , err )
242246 }
@@ -281,7 +285,7 @@ func (e *Executor) executionLoop() {
281285 }
282286 txsAvailable := false
283287
284- for {
288+ for e . ctx . Err () == nil {
285289 select {
286290 case <- e .ctx .Done ():
287291 return
@@ -316,6 +320,10 @@ func (e *Executor) executionLoop() {
316320
317321// ProduceBlock creates, validates, and stores a new block.
318322func (e * Executor ) ProduceBlock (ctx context.Context ) error {
323+ if ctx .Err () != nil {
324+ return ctx .Err ()
325+ }
326+
319327 start := time .Now ()
320328 defer func () {
321329 if e .metrics .OperationDuration ["block_production" ] != nil {
@@ -582,7 +590,7 @@ func (e *Executor) CreateBlock(ctx context.Context, height uint64, batchData *Ba
582590 }
583591
584592 for i , tx := range batchData .Transactions {
585- data .Txs [i ] = types . Tx ( tx )
593+ data .Txs [i ] = tx
586594 }
587595
588596 // Set data hash
0 commit comments