@@ -18,7 +18,6 @@ import (
18
18
coresequencer "github.com/evstack/ev-node/core/sequencer"
19
19
"github.com/evstack/ev-node/pkg/config"
20
20
"github.com/evstack/ev-node/pkg/genesis"
21
- "github.com/evstack/ev-node/pkg/raft"
22
21
"github.com/evstack/ev-node/pkg/signer"
23
22
"github.com/evstack/ev-node/pkg/store"
24
23
"github.com/evstack/ev-node/types"
@@ -29,13 +28,6 @@ type broadcaster[T any] interface {
29
28
WriteToStoreAndBroadcast (ctx context.Context , payload T ) error
30
29
}
31
30
32
- // RaftNode interface for leader election and state replication
33
- type RaftNode interface {
34
- IsLeader () bool
35
- Propose (ctx context.Context , data []byte ) error
36
- GetStateMachine () interface {}
37
- }
38
-
39
31
// Executor handles block production, transaction processing, and state management
40
32
type Executor struct {
41
33
// Core components
@@ -72,9 +64,6 @@ type Executor struct {
72
64
ctx context.Context
73
65
cancel context.CancelFunc
74
66
wg sync.WaitGroup
75
-
76
- // Raft for leader election and state replication
77
- raftNode RaftNode
78
67
}
79
68
80
69
// NewExecutor creates a new block executor.
@@ -97,7 +86,6 @@ func NewExecutor(
97
86
logger zerolog.Logger ,
98
87
options common.BlockOptions ,
99
88
errorCh chan <- error ,
100
- raftNode RaftNode ,
101
89
) (* Executor , error ) {
102
90
if signer == nil {
103
91
return nil , errors .New ("signer cannot be nil" )
@@ -128,7 +116,6 @@ func NewExecutor(
128
116
txNotifyCh : make (chan struct {}, 1 ),
129
117
errorCh : errorCh ,
130
118
logger : logger .With ().Str ("component" , "executor" ).Logger (),
131
- raftNode : raftNode ,
132
119
}, nil
133
120
}
134
121
@@ -304,34 +291,6 @@ func (e *Executor) produceBlock() error {
304
291
}
305
292
}()
306
293
307
- // Check leadership if raft is enabled
308
- if e .raftNode != nil {
309
- if ! e .raftNode .IsLeader () {
310
- e .logger .Debug ().Msg ("not leader, skipping block production" )
311
- return nil
312
- }
313
-
314
- // New leader catch-up: apply latest block from raft if behind
315
- if sm := e .raftNode .GetStateMachine (); sm != nil {
316
- if blockSM , ok := sm .(* raft.BlockStateMachine ); ok {
317
- raftHeader , raftData := blockSM .GetLastBlock ()
318
- if raftHeader != nil && raftData != nil {
319
- currentState := e .GetLastState ()
320
- if raftHeader .Height () > currentState .LastBlockHeight {
321
- e .logger .Info ().
322
- Uint64 ("current_height" , currentState .LastBlockHeight ).
323
- Uint64 ("raft_height" , raftHeader .Height ()).
324
- Msg ("new leader catching up from raft" )
325
-
326
- if err := e .applyRaftBlock (raftHeader , raftData ); err != nil {
327
- return fmt .Errorf ("catch up from raft: %w" , err )
328
- }
329
- }
330
- }
331
- }
332
- }
333
- }
334
-
335
294
currentState := e .GetLastState ()
336
295
newHeight := currentState .LastBlockHeight + 1
337
296
@@ -419,21 +378,6 @@ func (e *Executor) produceBlock() error {
419
378
return fmt .Errorf ("failed to update state: %w" , err )
420
379
}
421
380
422
- // Replicate full block via raft before broadcasting to P2P
423
- // This ensures follower nodes have the full block data and can apply it
424
- if e .raftNode != nil {
425
- blockStateData , err := raft .CreateBlockStateData (header , data )
426
- if err != nil {
427
- return fmt .Errorf ("failed to create block state data: %w" , err )
428
- }
429
-
430
- if err := e .raftNode .Propose (e .ctx , blockStateData ); err != nil {
431
- return fmt .Errorf ("failed to propose block to raft: %w" , err )
432
- }
433
-
434
- e .logger .Debug ().Uint64 ("height" , newHeight ).Msg ("full block replicated via raft" )
435
- }
436
-
437
381
// broadcast header and data to P2P network
438
382
g , ctx := errgroup .WithContext (e .ctx )
439
383
g .Go (func () error { return e .headerBroadcaster .WriteToStoreAndBroadcast (ctx , header ) })
@@ -685,56 +629,6 @@ func (e *Executor) recordBlockMetrics(data *types.Data) {
685
629
e .metrics .CommittedHeight .Set (float64 (data .Metadata .Height ))
686
630
}
687
631
688
- // applyRaftBlock applies a block received via raft (for follower nodes)
689
- func (e * Executor ) applyRaftBlock (header * types.SignedHeader , data * types.Data ) error {
690
- e .logger .Info ().Uint64 ("height" , header .Height ()).Msg ("applying block from raft" )
691
-
692
- currentState := e .GetLastState ()
693
-
694
- // Skip if already processed
695
- if header .Height () <= currentState .LastBlockHeight {
696
- e .logger .Debug ().Uint64 ("height" , header .Height ()).Msg ("block already applied, skipping" )
697
- return nil
698
- }
699
-
700
- // Validate block
701
- if err := e .validateBlock (currentState , header , data ); err != nil {
702
- return fmt .Errorf ("validate block: %w" , err )
703
- }
704
-
705
- // Apply block to execution client
706
- newState , err := e .applyBlock (e .ctx , header .Header , data )
707
- if err != nil {
708
- return fmt .Errorf ("apply block: %w" , err )
709
- }
710
-
711
- // Save block data
712
- if err := e .store .SaveBlockData (e .ctx , header , data , & header .Signature ); err != nil {
713
- return fmt .Errorf ("save block data: %w" , err )
714
- }
715
-
716
- // Update store height
717
- if err := e .store .SetHeight (e .ctx , header .Height ()); err != nil {
718
- return fmt .Errorf ("set height: %w" , err )
719
- }
720
-
721
- // Update state
722
- if err := e .updateState (e .ctx , newState ); err != nil {
723
- return fmt .Errorf ("update state: %w" , err )
724
- }
725
-
726
- e .recordBlockMetrics (data )
727
-
728
- e .logger .Info ().Uint64 ("height" , header .Height ()).Int ("txs" , len (data .Txs )).Msg ("applied block from raft" )
729
-
730
- return nil
731
- }
732
-
733
- // GetRaftStateMachine returns a reference to the raft block state machine if raft is enabled
734
- func (e * Executor ) GetRaftStateMachine () interface {} {
735
- return e .raftNode
736
- }
737
-
738
632
// BatchData represents batch data from sequencer
739
633
type BatchData struct {
740
634
* coresequencer.Batch
0 commit comments