Skip to content

Commit 9c61f18

Browse files
authored
feat: High availabilty via RAFT (#2987)
* Add high availabiliy via raft * Prefent duplicate peers * Go mod tidy * Minor updates * Fix test * Leadership fix (cherry picked from commit c44cd77e665f6d5d463295c6ed61c59a56d88db3) * Fix test * Remove sleep * Increase buffer size for raft msgs * Review feedback * Add replace to go.mod * Fix merge conflicts * Linter fix * Minor test update * Remove store.Sync * Merge * Add last submitted da heights to raft * Make test compile again * Complete merge * Fix integration test * Review feedback and linting * Convert raft state into proto type * Fix import and e2e tests * Cufigurable leader_lease_timeout * Log raft state height when passing leadership * Recover with raft state * Ensure block hash in state check * x * More safety features, including db.sync * Ensure safe restart * x * Resolve conflicts * Fix test setup * Fix dummyDA * Review feedback * Add grace period for test * Add raft doc * Available ports for e2e tests * Review feedback * Fix integration test
1 parent 62c9339 commit 9c61f18

83 files changed

Lines changed: 4975 additions & 503 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.mockery.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ packages:
2323
dir: ./test/mocks
2424
pkgname: mocks
2525
filename: p2p.go
26+
github.com/evstack/ev-node/pkg/raft:
27+
interfaces:
28+
sourceNode:
29+
config:
30+
dir: ./pkg/raft
31+
pkgname: raft
32+
filename: node_mock.go
2633
github.com/evstack/ev-node/pkg/store:
2734
interfaces:
2835
Store:

RELEASE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ Packages must be released in the following order:
9797

9898
These packages only depend on `core` and can be released in parallel after `core`:
9999

100-
2. **github.com/evstack/ev-node** - Path: `./` (root)
101-
3. **github.com/evstack/ev-node/execution/evm** - Path: `./execution/evm`
100+
1. **github.com/evstack/ev-node** - Path: `./` (root)
101+
2. **github.com/evstack/ev-node/execution/evm** - Path: `./execution/evm`
102102

103103
#### Phase 3: Application Packages
104104

apps/evm/cmd/run.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
da "github.com/evstack/ev-node/pkg/da/types"
2626
"github.com/evstack/ev-node/pkg/genesis"
2727
genesispkg "github.com/evstack/ev-node/pkg/genesis"
28-
"github.com/evstack/ev-node/pkg/p2p"
2928
"github.com/evstack/ev-node/pkg/p2p/key"
3029
"github.com/evstack/ev-node/pkg/sequencers/based"
3130
"github.com/evstack/ev-node/pkg/sequencers/single"
@@ -99,11 +98,6 @@ var RunCmd = &cobra.Command{
9998
return err
10099
}
101100

102-
p2pClient, err := p2p.NewClient(nodeConfig.P2P, nodeKey.PrivKey, datastore, genesis.ChainID, logger, nil)
103-
if err != nil {
104-
return err
105-
}
106-
107101
// Start force inclusion API server if address is provided
108102
forceInclusionAddr, err := cmd.Flags().GetString(flagForceInclusionServer)
109103
if err != nil {
@@ -142,7 +136,7 @@ var RunCmd = &cobra.Command{
142136
}()
143137
}
144138

145-
return rollcmd.StartNode(logger, cmd, executor, sequencer, p2pClient, datastore, nodeConfig, genesis, node.NodeOptions{})
139+
return rollcmd.StartNode(logger, cmd, executor, sequencer, nodeKey, datastore, nodeConfig, genesis, node.NodeOptions{})
146140
},
147141
}
148142

apps/evm/go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ require (
2525
github.com/Microsoft/go-winio v0.6.2 // indirect
2626
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6 // indirect
2727
github.com/StackExchange/wmi v1.2.1 // indirect
28+
github.com/armon/go-metrics v0.4.1 // indirect
2829
github.com/benbjohnson/clock v1.3.5 // indirect
2930
github.com/beorn7/perks v1.0.1 // indirect
3031
github.com/bits-and-blooms/bitset v1.20.0 // indirect
32+
github.com/boltdb/bolt v1.3.1 // indirect
3133
github.com/celestiaorg/go-libp2p-messenger v0.2.2 // indirect
3234
github.com/celestiaorg/go-square/merkle v0.0.0-20240627094109-7d01436067a3 // indirect
3335
github.com/celestiaorg/go-square/v3 v3.0.2 // indirect
@@ -47,6 +49,7 @@ require (
4749
github.com/emicklei/dot v1.6.2 // indirect
4850
github.com/ethereum/c-kzg-4844/v2 v2.1.5 // indirect
4951
github.com/ethereum/go-verkle v0.2.2 // indirect
52+
github.com/fatih/color v1.16.0 // indirect
5053
github.com/ferranbt/fastssz v0.1.4 // indirect
5154
github.com/filecoin-project/go-clock v0.1.0 // indirect
5255
github.com/filecoin-project/go-jsonrpc v0.10.0 // indirect
@@ -69,8 +72,15 @@ require (
6972
github.com/google/uuid v1.6.0 // indirect
7073
github.com/gorilla/websocket v1.5.3 // indirect
7174
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
75+
github.com/hashicorp/go-hclog v1.6.2 // indirect
76+
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
77+
github.com/hashicorp/go-metrics v0.5.4 // indirect
78+
github.com/hashicorp/go-msgpack v0.5.5 // indirect
79+
github.com/hashicorp/go-msgpack/v2 v2.1.2 // indirect
7280
github.com/hashicorp/golang-lru v1.0.2 // indirect
7381
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
82+
github.com/hashicorp/raft v1.7.3 // indirect
83+
github.com/hashicorp/raft-boltdb v0.0.0-20251103221153-05f9dd7a5148 // indirect
7484
github.com/holiman/uint256 v1.3.2 // indirect
7585
github.com/huin/goupnp v1.3.0 // indirect
7686
github.com/inconshreveable/mousetrap v1.1.0 // indirect

apps/evm/go.sum

Lines changed: 117 additions & 0 deletions
Large diffs are not rendered by default.

apps/grpc/cmd/run.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
da "github.com/evstack/ev-node/pkg/da/types"
2121
"github.com/evstack/ev-node/pkg/genesis"
2222
rollgenesis "github.com/evstack/ev-node/pkg/genesis"
23-
"github.com/evstack/ev-node/pkg/p2p"
2423
"github.com/evstack/ev-node/pkg/p2p/key"
2524
"github.com/evstack/ev-node/pkg/sequencers/based"
2625
"github.com/evstack/ev-node/pkg/sequencers/single"
@@ -87,14 +86,8 @@ The execution client must implement the Evolve execution gRPC interface.`,
8786
return err
8887
}
8988

90-
// Create P2P client
91-
p2pClient, err := p2p.NewClient(nodeConfig.P2P, nodeKey.PrivKey, datastore, genesis.ChainID, logger, nil)
92-
if err != nil {
93-
return err
94-
}
95-
9689
// Start the node
97-
return rollcmd.StartNode(logger, cmd, executor, sequencer, p2pClient, datastore, nodeConfig, genesis, node.NodeOptions{})
90+
return rollcmd.StartNode(logger, cmd, executor, sequencer, nodeKey, datastore, nodeConfig, genesis, node.NodeOptions{})
9891
},
9992
}
10093

apps/grpc/go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ require (
1919
require (
2020
connectrpc.com/connect v1.19.1 // indirect
2121
connectrpc.com/grpcreflect v1.3.0 // indirect
22+
github.com/armon/go-metrics v0.4.1 // indirect
2223
github.com/benbjohnson/clock v1.3.5 // indirect
2324
github.com/beorn7/perks v1.0.1 // indirect
25+
github.com/boltdb/bolt v1.3.1 // indirect
2426
github.com/celestiaorg/go-header v0.8.1 // indirect
2527
github.com/celestiaorg/go-libp2p-messenger v0.2.2 // indirect
2628
github.com/celestiaorg/go-square/merkle v0.0.0-20240627094109-7d01436067a3 // indirect
@@ -34,6 +36,7 @@ require (
3436
github.com/dgraph-io/badger/v4 v4.5.1 // indirect
3537
github.com/dgraph-io/ristretto/v2 v2.1.0 // indirect
3638
github.com/dustin/go-humanize v1.0.1 // indirect
39+
github.com/fatih/color v1.15.0 // indirect
3740
github.com/filecoin-project/go-clock v0.1.0 // indirect
3841
github.com/filecoin-project/go-jsonrpc v0.10.0 // indirect
3942
github.com/flynn/noise v1.1.0 // indirect
@@ -50,8 +53,15 @@ require (
5053
github.com/google/uuid v1.6.0 // indirect
5154
github.com/gorilla/websocket v1.5.3 // indirect
5255
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
56+
github.com/hashicorp/go-hclog v1.6.2 // indirect
57+
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
58+
github.com/hashicorp/go-metrics v0.5.4 // indirect
59+
github.com/hashicorp/go-msgpack v0.5.5 // indirect
60+
github.com/hashicorp/go-msgpack/v2 v2.1.2 // indirect
5361
github.com/hashicorp/golang-lru v1.0.2 // indirect
5462
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
63+
github.com/hashicorp/raft v1.7.3 // indirect
64+
github.com/hashicorp/raft-boltdb v0.0.0-20251103221153-05f9dd7a5148 // indirect
5565
github.com/huin/goupnp v1.3.0 // indirect
5666
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5767
github.com/ipfs/boxo v0.35.2 // indirect

0 commit comments

Comments
 (0)