Skip to content

Commit bc48950

Browse files
committed
renaming as per feedback
1 parent cd105cb commit bc48950

File tree

8 files changed

+12
-42
lines changed

8 files changed

+12
-42
lines changed

block/node.go renamed to block/components.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ type broadcaster[T any] interface {
115115
WriteToStoreAndBroadcast(ctx context.Context, payload T) error
116116
}
117117

118-
// NewSyncNode creates components for a non-aggregator full node that can only sync blocks.
118+
// NewSyncComponents creates components for a non-aggregator full node that can only sync blocks.
119119
// Non-aggregator full nodes can sync from P2P and DA but cannot produce blocks or submit to DA.
120120
// They have more sync capabilities than light nodes but no block production. No signer required.
121-
func NewSyncNode(
121+
func NewSyncComponents(
122122
config config.Config,
123123
genesis genesis.Genesis,
124124
store store.Store,
@@ -176,10 +176,10 @@ func NewSyncNode(
176176
}, nil
177177
}
178178

179-
// NewAggregatorNode creates components for an aggregator full node that can produce and sync blocks.
179+
// NewAggregatorComponents creates components for an aggregator full node that can produce and sync blocks.
180180
// Aggregator nodes have full capabilities - they can produce blocks, sync from P2P and DA,
181181
// and submit headers/data to DA. Requires a signer for block production and DA submission.
182-
func NewAggregatorNode(
182+
func NewAggregatorComponents(
183183
config config.Config,
184184
genesis genesis.Genesis,
185185
store store.Store,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestBlockComponents_StartStop_Lifecycle(t *testing.T) {
7979
assert.Contains(t, err.Error(), "context")
8080
}
8181

82-
func TestNewSyncNode_Creation(t *testing.T) {
82+
func TestNewSyncComponents_Creation(t *testing.T) {
8383
ds := sync.MutexWrap(datastore.NewMapDatastore())
8484
memStore := store.New(ds)
8585

@@ -96,7 +96,7 @@ func TestNewSyncNode_Creation(t *testing.T) {
9696

9797
// Just test that the constructor doesn't panic - don't start the components
9898
// to avoid P2P store dependencies
99-
components, err := NewSyncNode(
99+
components, err := NewSyncComponents(
100100
cfg,
101101
gen,
102102
memStore,
@@ -118,7 +118,7 @@ func TestNewSyncNode_Creation(t *testing.T) {
118118
assert.Nil(t, components.Executor) // Sync nodes don't have executors
119119
}
120120

121-
func TestNewAggregatorNode_Creation(t *testing.T) {
121+
func TestNewAggregatorComponents_Creation(t *testing.T) {
122122
ds := sync.MutexWrap(datastore.NewMapDatastore())
123123
memStore := store.New(ds)
124124

@@ -140,7 +140,7 @@ func TestNewAggregatorNode_Creation(t *testing.T) {
140140
mockSigner, err := noop.NewNoopSigner(priv)
141141
require.NoError(t, err)
142142

143-
components, err := NewAggregatorNode(
143+
components, err := NewAggregatorComponents(
144144
cfg,
145145
gen,
146146
memStore,
@@ -211,7 +211,7 @@ func TestExecutor_RealExecutionClientFailure_StopsNode(t *testing.T) {
211211
Return(nil, uint64(0), criticalError).Maybe()
212212

213213
// Create aggregator node
214-
components, err := NewAggregatorNode(
214+
components, err := NewAggregatorComponents(
215215
cfg,
216216
gen,
217217
memStore,

node/full.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ type FullNode struct {
6868

6969
// newFullNode creates a new Rollkit full node.
7070
func newFullNode(
71-
ctx context.Context,
7271
nodeConfig config.Config,
7372
p2pClient *p2p.Client,
7473
signer signer.Signer,
@@ -100,7 +99,7 @@ func newFullNode(
10099

101100
var blockComponents *block.BlockComponents
102101
if nodeConfig.Node.Aggregator {
103-
blockComponents, err = block.NewAggregatorNode(
102+
blockComponents, err = block.NewAggregatorComponents(
104103
nodeConfig,
105104
genesis,
106105
rktStore,
@@ -115,7 +114,7 @@ func newFullNode(
115114
nodeOpts.BlockOptions,
116115
)
117116
} else {
118-
blockComponents, err = block.NewSyncNode(
117+
blockComponents, err = block.NewSyncComponents(
119118
nodeConfig,
120119
genesis,
121120
rktStore,

node/helpers.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ func getNodeHeightFromStore(node Node) (uint64, error) {
8383
return 0, errors.New("not a full node or block components not initialized")
8484
}
8585

86-
//nolint:unused
87-
func safeClose(ch chan struct{}) {
88-
select {
89-
case <-ch:
90-
default:
91-
close(ch)
92-
}
93-
}
94-
9586
// waitForAtLeastNBlocks waits for the node to have at least n blocks
9687
func waitForAtLeastNBlocks(node Node, n uint64, source Source) error {
9788
return Retry(300, 100*time.Millisecond, func() error {

node/helpers_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,12 @@ func newTestNode(
106106
ds datastore.Batching,
107107
stopDAHeightTicker func(),
108108
) (*FullNode, func()) {
109-
ctx, cancel := context.WithCancel(context.Background())
110-
111109
// Generate genesis and keys
112110
genesis, genesisValidatorKey, _ := types.GetGenesisWithPrivkey("test-chain")
113111
remoteSigner, err := remote_signer.NewNoopSigner(genesisValidatorKey)
114112
require.NoError(t, err)
115113

116114
node, err := NewNode(
117-
ctx,
118115
config,
119116
executor,
120117
sequencer,
@@ -130,7 +127,6 @@ func newTestNode(
130127
require.NoError(t, err)
131128

132129
cleanup := func() {
133-
cancel()
134130
if stopDAHeightTicker != nil {
135131
stopDAHeightTicker()
136132
}
@@ -164,8 +160,6 @@ func createNodesWithCleanup(t *testing.T, num int, config evconfig.Config) ([]*F
164160

165161
nodes := make([]*FullNode, num)
166162
cleanups := make([]func(), num)
167-
// Create a cancellable context instead of using background context
168-
aggCtx, aggCancel := context.WithCancel(context.Background())
169163

170164
// Generate genesis and keys
171165
genesis, genesisValidatorKey, _ := types.GetGenesisWithPrivkey("test-chain")
@@ -179,7 +173,6 @@ func createNodesWithCleanup(t *testing.T, num int, config evconfig.Config) ([]*F
179173
require.NoError(err)
180174

181175
aggNode, err := NewNode(
182-
aggCtx,
183176
config,
184177
executor,
185178
sequencer,
@@ -196,8 +189,6 @@ func createNodesWithCleanup(t *testing.T, num int, config evconfig.Config) ([]*F
196189

197190
// Update cleanup to cancel the context instead of calling Stop
198191
cleanup := func() {
199-
// Cancel the context to stop the node
200-
aggCancel()
201192
stopDAHeightTicker()
202193
}
203194

@@ -209,15 +200,13 @@ func createNodesWithCleanup(t *testing.T, num int, config evconfig.Config) ([]*F
209200
peersList = append(peersList, aggPeerAddress)
210201
}
211202
for i := 1; i < num; i++ {
212-
ctx, cancel := context.WithCancel(context.Background())
213203
if aggPeers != "none" {
214204
config.P2P.Peers = strings.Join(peersList, ",")
215205
}
216206
config.P2P.ListenAddress = fmt.Sprintf("/ip4/127.0.0.1/tcp/%d", 40001+i)
217207
config.RPC.Address = fmt.Sprintf("127.0.0.1:%d", 8001+i)
218208
executor, sequencer, _, p2pClient, _, nodeP2PKey, stopDAHeightTicker := createTestComponents(t, config)
219209
node, err := NewNode(
220-
ctx,
221210
config,
222211
executor,
223212
sequencer,
@@ -233,8 +222,6 @@ func createNodesWithCleanup(t *testing.T, num int, config evconfig.Config) ([]*F
233222
require.NoError(err)
234223
// Update cleanup to cancel the context instead of calling Stop
235224
cleanup := func() {
236-
// Cancel the context to stop the node
237-
cancel()
238225
stopDAHeightTicker()
239226
}
240227
nodes[i], cleanups[i] = node.(*FullNode), cleanup

node/node.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package node
22

33
import (
4-
"context"
5-
64
ds "github.com/ipfs/go-datastore"
75
"github.com/rs/zerolog"
86

@@ -32,7 +30,6 @@ type NodeOptions struct {
3230
// This is the entry point for composing a node, when compiling a node, you need to provide an executor
3331
// Example executors can be found in apps/
3432
func NewNode(
35-
ctx context.Context,
3633
conf config.Config,
3734
exec coreexecutor.Executor,
3835
sequencer coresequencer.Sequencer,
@@ -54,7 +51,6 @@ func NewNode(
5451
}
5552

5653
return newFullNode(
57-
ctx,
5854
conf,
5955
p2pClient,
6056
signer,

node/single_sequencer_integration_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build integration
2-
31
package node
42

53
import (
@@ -263,7 +261,7 @@ func TestStateRecovery(t *testing.T) {
263261
// Verify state persistence
264262
recoveredHeight, err := getNodeHeight(node, Store)
265263
require.NoError(err)
266-
require.GreaterOrEqual(recoveredHeight, originalHeight)
264+
require.GreaterOrEqual(recoveredHeight, originalHeight, "recovered height should be greater than or equal to original height")
267265
}
268266

269267
// TestMaxPendingHeadersAndData verifies that the sequencer will stop producing blocks when the maximum number of pending headers or data is reached.

pkg/cmd/run_node.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func StartNode(
115115

116116
// Create and start the node
117117
rollnode, err := node.NewNode(
118-
ctx,
119118
nodeConfig,
120119
executor,
121120
sequencer,

0 commit comments

Comments
 (0)