Skip to content

Commit 8f996eb

Browse files
authored
feat: add namespace cfg validation + random default (#2682)
Update the default namespace to a random string on init to avoid collisions. Validate the namespace using go-square lib, as suggested by node team. Users should always have a namespace for their chain, but having a random one, improve usability and testing while making sure users won't by mistake all publish to the same namespace.
1 parent a57f197 commit 8f996eb

33 files changed

Lines changed: 203 additions & 154 deletions

apps/evm/single/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ require (
5555
github.com/bits-and-blooms/bitset v1.20.0 // indirect
5656
github.com/buger/goterm v1.0.4 // indirect
5757
github.com/celestiaorg/go-libp2p-messenger v0.2.2 // indirect
58+
github.com/celestiaorg/go-square/v2 v2.3.3 // indirect
5859
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
5960
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
6061
github.com/cespare/xxhash/v2 v2.3.0 // indirect

apps/evm/single/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ github.com/celestiaorg/go-datastore v0.0.0-20250801131506-48a63ae531e4 h1:udw77B
106106
github.com/celestiaorg/go-datastore v0.0.0-20250801131506-48a63ae531e4/go.mod h1:W+pI1NsUsz3tcsAACMtfC+IZdnQTnC/7VfPoJBQuts0=
107107
github.com/celestiaorg/go-libp2p-messenger v0.2.2 h1:osoUfqjss7vWTIZrrDSy953RjQz+ps/vBFE7bychLEc=
108108
github.com/celestiaorg/go-libp2p-messenger v0.2.2/go.mod h1:oTCRV5TfdO7V/k6nkx7QjQzGrWuJbupv+0o1cgnY2i4=
109+
github.com/celestiaorg/go-square/v2 v2.3.3 h1:vhu6Lt39km19Q/Jk4nS3r2cuWJq6jFg+/1+iG8YGftY=
110+
github.com/celestiaorg/go-square/v2 v2.3.3/go.mod h1:vY5RRv+qRmEVjPF6dAdr0dyLwKmTTDHHffENPQw8pUA=
109111
github.com/celestiaorg/utils v0.1.0 h1:WsP3O8jF7jKRgLNFmlDCwdThwOFMFxg0MnqhkLFVxPo=
110112
github.com/celestiaorg/utils v0.1.0/go.mod h1:vQTh7MHnvpIeCQZ2/Ph+w7K1R2UerDheZbgJEJD2hSU=
111113
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=

apps/grpc/single/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require (
1818
github.com/beorn7/perks v1.0.1 // indirect
1919
github.com/celestiaorg/go-header v0.7.2 // indirect
2020
github.com/celestiaorg/go-libp2p-messenger v0.2.2 // indirect
21+
github.com/celestiaorg/go-square/v2 v2.3.3 // indirect
2122
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2223
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2324
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect

apps/grpc/single/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ github.com/celestiaorg/go-header v0.7.2 h1:Jw01iBKnodfsILzynDCU3C11xurpoBt5SI9lg
2828
github.com/celestiaorg/go-header v0.7.2/go.mod h1:eX9iTSPthVEAlEDLux40ZT/olXPGhpxHd+mEzJeDhd0=
2929
github.com/celestiaorg/go-libp2p-messenger v0.2.2 h1:osoUfqjss7vWTIZrrDSy953RjQz+ps/vBFE7bychLEc=
3030
github.com/celestiaorg/go-libp2p-messenger v0.2.2/go.mod h1:oTCRV5TfdO7V/k6nkx7QjQzGrWuJbupv+0o1cgnY2i4=
31+
github.com/celestiaorg/go-square/v2 v2.3.3 h1:vhu6Lt39km19Q/Jk4nS3r2cuWJq6jFg+/1+iG8YGftY=
32+
github.com/celestiaorg/go-square/v2 v2.3.3/go.mod h1:vY5RRv+qRmEVjPF6dAdr0dyLwKmTTDHHffENPQw8pUA=
3133
github.com/celestiaorg/utils v0.1.0 h1:WsP3O8jF7jKRgLNFmlDCwdThwOFMFxg0MnqhkLFVxPo=
3234
github.com/celestiaorg/utils v0.1.0/go.mod h1:vQTh7MHnvpIeCQZ2/Ph+w7K1R2UerDheZbgJEJD2hSU=
3335
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

apps/testapp/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ require (
2828
github.com/benbjohnson/clock v1.3.5 // indirect
2929
github.com/beorn7/perks v1.0.1 // indirect
3030
github.com/celestiaorg/go-libp2p-messenger v0.2.2 // indirect
31+
github.com/celestiaorg/go-square/v2 v2.3.3 // indirect
3132
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3233
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3334
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect

apps/testapp/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ github.com/celestiaorg/go-datastore v0.0.0-20250801131506-48a63ae531e4 h1:udw77B
2626
github.com/celestiaorg/go-datastore v0.0.0-20250801131506-48a63ae531e4/go.mod h1:W+pI1NsUsz3tcsAACMtfC+IZdnQTnC/7VfPoJBQuts0=
2727
github.com/celestiaorg/go-libp2p-messenger v0.2.2 h1:osoUfqjss7vWTIZrrDSy953RjQz+ps/vBFE7bychLEc=
2828
github.com/celestiaorg/go-libp2p-messenger v0.2.2/go.mod h1:oTCRV5TfdO7V/k6nkx7QjQzGrWuJbupv+0o1cgnY2i4=
29+
github.com/celestiaorg/go-square/v2 v2.3.3 h1:vhu6Lt39km19Q/Jk4nS3r2cuWJq6jFg+/1+iG8YGftY=
30+
github.com/celestiaorg/go-square/v2 v2.3.3/go.mod h1:vY5RRv+qRmEVjPF6dAdr0dyLwKmTTDHHffENPQw8pUA=
2931
github.com/celestiaorg/utils v0.1.0 h1:WsP3O8jF7jKRgLNFmlDCwdThwOFMFxg0MnqhkLFVxPo=
3032
github.com/celestiaorg/utils v0.1.0/go.mod h1:vQTh7MHnvpIeCQZ2/Ph+w7K1R2UerDheZbgJEJD2hSU=
3133
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

block/components_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestNewSyncComponents_Creation(t *testing.T) {
8383
ds := sync.MutexWrap(datastore.NewMapDatastore())
8484
memStore := store.New(ds)
8585

86-
cfg := config.DefaultConfig
86+
cfg := config.DefaultConfig()
8787
gen := genesis.Genesis{
8888
ChainID: "test-chain",
8989
InitialHeight: 1,
@@ -122,7 +122,7 @@ func TestNewAggregatorComponents_Creation(t *testing.T) {
122122
ds := sync.MutexWrap(datastore.NewMapDatastore())
123123
memStore := store.New(ds)
124124

125-
cfg := config.DefaultConfig
125+
cfg := config.DefaultConfig()
126126

127127
// Create a test signer first
128128
priv, _, err := crypto.GenerateEd25519Key(crand.Reader)
@@ -176,7 +176,7 @@ func TestExecutor_RealExecutionClientFailure_StopsNode(t *testing.T) {
176176
ds := sync.MutexWrap(datastore.NewMapDatastore())
177177
memStore := store.New(ds)
178178

179-
cfg := config.DefaultConfig
179+
cfg := config.DefaultConfig()
180180
cfg.Node.BlockTime.Duration = 50 * time.Millisecond // Fast for testing
181181

182182
// Create test signer

block/internal/cache/bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func benchSetupStore(b *testing.B, n int, txsPer int, chainID string) store.Stor
4646
}
4747

4848
func benchNewManager(b *testing.B, st store.Store) Manager {
49-
cfg := config.DefaultConfig
49+
cfg := config.DefaultConfig()
5050
cfg.RootDir = b.TempDir()
5151
m, err := NewManager(cfg, st, zerolog.Nop())
5252
if err != nil {

block/internal/cache/manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818

1919
// helper to make a temp config rooted at t.TempDir()
2020
func tempConfig(t *testing.T) config.Config {
21-
cfg := config.DefaultConfig
21+
cfg := config.DefaultConfig()
2222
cfg.RootDir = t.TempDir()
2323
return cfg
2424
}

block/internal/executing/executor_lazy_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ func TestLazyMode_ProduceBlockLogic(t *testing.T) {
2626
ds := sync.MutexWrap(datastore.NewMapDatastore())
2727
memStore := store.New(ds)
2828

29-
cacheManager, err := cache.NewManager(config.DefaultConfig, memStore, zerolog.Nop())
29+
cacheManager, err := cache.NewManager(config.DefaultConfig(), memStore, zerolog.Nop())
3030
require.NoError(t, err)
3131

3232
metrics := common.NopMetrics()
3333

3434
addr, _, signerWrapper := buildTestSigner(t)
3535

36-
cfg := config.DefaultConfig
36+
cfg := config.DefaultConfig()
3737
cfg.Node.BlockTime = config.DurationWrapper{Duration: 10 * time.Millisecond}
3838
cfg.Node.LazyMode = true
3939
cfg.Node.MaxPendingHeadersAndData = 1000
@@ -134,14 +134,14 @@ func TestRegularMode_ProduceBlockLogic(t *testing.T) {
134134
ds := sync.MutexWrap(datastore.NewMapDatastore())
135135
memStore := store.New(ds)
136136

137-
cacheManager, err := cache.NewManager(config.DefaultConfig, memStore, zerolog.Nop())
137+
cacheManager, err := cache.NewManager(config.DefaultConfig(), memStore, zerolog.Nop())
138138
require.NoError(t, err)
139139

140140
metrics := common.NopMetrics()
141141

142142
addr, _, signerWrapper := buildTestSigner(t)
143143

144-
cfg := config.DefaultConfig
144+
cfg := config.DefaultConfig()
145145
cfg.Node.BlockTime = config.DurationWrapper{Duration: 10 * time.Millisecond}
146146
cfg.Node.LazyMode = false // Regular mode
147147
cfg.Node.MaxPendingHeadersAndData = 1000

0 commit comments

Comments
 (0)