Skip to content

Commit edc2ac4

Browse files
authored
forward-port: config(nodebuilder/header): bumps go-header, removes trustingPeriod (#4529)
1 parent 9c5c25c commit edc2ac4

File tree

8 files changed

+10
-77
lines changed

8 files changed

+10
-77
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/benbjohnson/clock v1.3.5
1313
github.com/celestiaorg/celestia-app/v6 v6.0.0-arabica
1414
github.com/celestiaorg/go-fraud v0.2.3
15-
github.com/celestiaorg/go-header v0.7.0
15+
github.com/celestiaorg/go-header v0.7.1
1616
github.com/celestiaorg/go-libp2p-messenger v0.2.2
1717
github.com/celestiaorg/go-square/merkle v0.0.0-20240117232118-fd78256df076
1818
github.com/celestiaorg/go-square/v2 v2.3.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,8 @@ github.com/celestiaorg/go-datastore v0.0.0-20250801131506-48a63ae531e4 h1:udw77B
809809
github.com/celestiaorg/go-datastore v0.0.0-20250801131506-48a63ae531e4/go.mod h1:W+pI1NsUsz3tcsAACMtfC+IZdnQTnC/7VfPoJBQuts0=
810810
github.com/celestiaorg/go-fraud v0.2.3 h1:vsGmd5HtGL92q/pvjN0cpDsXn7hGJSbVZwOJl+dNX8E=
811811
github.com/celestiaorg/go-fraud v0.2.3/go.mod h1:h2Or0jHka/TDlQ3XsJV6OibIiwm49UiGVEu2jHKzybA=
812-
github.com/celestiaorg/go-header v0.7.0 h1:bxRCjk6pabCk1J5HLT7ogQXkxcwS32E7KiIkcq+1igI=
813-
github.com/celestiaorg/go-header v0.7.0/go.mod h1:eX9iTSPthVEAlEDLux40ZT/olXPGhpxHd+mEzJeDhd0=
812+
github.com/celestiaorg/go-header v0.7.1 h1:XG0fQykSjKsCtWl9sY5jZXG12D4Xe59bjklWZ2sWip0=
813+
github.com/celestiaorg/go-header v0.7.1/go.mod h1:eX9iTSPthVEAlEDLux40ZT/olXPGhpxHd+mEzJeDhd0=
814814
github.com/celestiaorg/go-libp2p-messenger v0.2.2 h1:osoUfqjss7vWTIZrrDSy953RjQz+ps/vBFE7bychLEc=
815815
github.com/celestiaorg/go-libp2p-messenger v0.2.2/go.mod h1:oTCRV5TfdO7V/k6nkx7QjQzGrWuJbupv+0o1cgnY2i4=
816816
github.com/celestiaorg/go-square/merkle v0.0.0-20240117232118-fd78256df076 h1:PYInrsYzrDIsZW9Yb86OTi2aEKuPcpgJt6Mc0Jlc/yg=

nodebuilder/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestConfigWriteRead(t *testing.T) {
3030
var out Config
3131
err = out.Decode(buf)
3232
require.NoError(t, err)
33-
assert.EqualValues(t, in, &out)
33+
assert.EqualExportedValues(t, in, &out)
3434
})
3535
}
3636
}

nodebuilder/header/config.go

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func DefaultConfig(tp node.Type) Config {
4343
Server: p2p_exchange.DefaultServerParameters(),
4444
Client: p2p_exchange.DefaultClientParameters(),
4545
}
46-
cfg.Syncer.TrustingPeriod = trustingPeriod
4746

4847
switch tp {
4948
case node.Full, node.Bridge:
@@ -85,20 +84,6 @@ func (cfg *Config) trustedPeers(bpeers p2p.Bootstrappers) (infos []peer.AddrInfo
8584

8685
// Validate performs basic validation of the config.
8786
func (cfg *Config) Validate(tp node.Type) error {
88-
err := cfg.Store.Validate()
89-
if err != nil {
90-
return fmt.Errorf("module/header: misconfiguration of store: %w", err)
91-
}
92-
93-
err = cfg.Server.Validate()
94-
if err != nil {
95-
return fmt.Errorf("module/header: misconfiguration of p2p exchange server: %w", err)
96-
}
97-
98-
if cfg.Syncer.TrustingPeriod != trustingPeriod {
99-
return fmt.Errorf("module/header: Syncer.TrustingPeriod must be %s", trustingPeriod)
100-
}
101-
10287
switch tp {
10388
case node.Full, node.Bridge:
10489
if cfg.Syncer.SyncFromHash != "" || cfg.Syncer.SyncFromHeight != 0 || cfg.Syncer.PruningWindow != 0 {
@@ -108,27 +93,14 @@ func (cfg *Config) Validate(tp node.Type) error {
10893
)
10994
}
11095
case node.Light:
111-
err = cfg.Syncer.Validate()
112-
if err != nil {
113-
return fmt.Errorf("module/header: misconfiguration of syncer: %w", err)
114-
}
115-
11696
if cfg.Syncer.PruningWindow < availability.StorageWindow {
11797
// TODO(@Wondertan): Technically, a LN may break this restriction by setting SyncFromHeight/Hash to a header
11898
// that is closer to Head than StorageWindow. Consider putting efforts into catching this too.
11999
return fmt.Errorf("module/header: Syncer.PruningWindow must not be less then sampling storage window (%s)",
120100
availability.StorageWindow)
121101
}
122-
}
123-
124-
// we do not create a client for bridge nodes
125-
if tp == node.Bridge {
126-
return nil
127-
}
128-
129-
err = cfg.Client.Validate()
130-
if err != nil {
131-
return fmt.Errorf("module/header: misconfiguration of p2p exchange client: %w", err)
102+
default:
103+
panic("invalid node type")
132104
}
133105

134106
return nil

nodebuilder/header/constructors.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,13 @@ func newSyncer[H libhead.Header[H]](
8686
if genesis == "" {
8787
// set by height if hash is not available
8888
cfg.Syncer.SyncFromHeight = 1
89-
90-
// TODO(@Wondertan): Hack until https://github.com/celestiaorg/go-header/issues/335 is fixed
91-
// Only relevant for tests anyway
92-
cfg.Syncer.PruningWindow = 100
9389
}
9490
}
9591

9692
opts := []sync.Option{
9793
sync.WithParams(cfg.Syncer),
9894
sync.WithBlockTime(modp2p.BlockTime),
95+
sync.WithTrustingPeriod(trustingPeriod),
9996
}
10097
if MetricsEnabled {
10198
opts = append(opts, sync.WithMetrics())

nodebuilder/header/module_test.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ import (
66

77
"github.com/ipfs/go-datastore"
88
"github.com/libp2p/go-libp2p"
9-
pubsub "github.com/libp2p/go-libp2p-pubsub"
109
"github.com/libp2p/go-libp2p/p2p/net/conngater"
1110
"github.com/stretchr/testify/require"
1211
"go.uber.org/fx"
1312
"go.uber.org/fx/fxtest"
1413

15-
"github.com/celestiaorg/go-fraud"
1614
libhead "github.com/celestiaorg/go-header"
1715
"github.com/celestiaorg/go-header/p2p"
1816
"github.com/celestiaorg/go-header/store"
19-
"github.com/celestiaorg/go-header/sync"
2017

2118
"github.com/celestiaorg/celestia-node/header"
2219
"github.com/celestiaorg/celestia-node/libs/pidstore"
@@ -56,39 +53,6 @@ func TestConstructModule_StoreParams(t *testing.T) {
5653
require.Equal(t, headerStore.Params.WriteBatchSize, cfg.Store.WriteBatchSize)
5754
}
5855

59-
// TestConstructModule_SyncerParams ensures that all passed via functional options
60-
// params are set in syncer correctly.
61-
func TestConstructModule_SyncerParams(t *testing.T) {
62-
cfg := DefaultConfig(node.Light)
63-
cfg.TrustedPeers = []string{"/ip4/1.2.3.4/tcp/12345/p2p/12D3KooWNaJ1y1Yio3fFJEXCZyd1Cat3jmrPdgkYCrHfKD3Ce21p"}
64-
var syncer *sync.Syncer[*header.ExtendedHeader]
65-
app := fxtest.New(t,
66-
fx.Supply(node.Light),
67-
fx.Supply(modp2p.Private),
68-
fx.Supply(modp2p.Bootstrappers{}),
69-
fx.Provide(context.Background),
70-
fx.Provide(libp2p.New),
71-
fx.Provide(func(b datastore.Batching) (*conngater.BasicConnectionGater, error) {
72-
return conngater.NewBasicConnectionGater(b)
73-
}),
74-
fx.Provide(func() *pubsub.PubSub {
75-
return nil
76-
}),
77-
fx.Provide(func() datastore.Batching {
78-
return datastore.NewMapDatastore()
79-
}),
80-
fx.Provide(func() fraud.Service[*header.ExtendedHeader] {
81-
return nil
82-
}),
83-
ConstructModule[*header.ExtendedHeader](node.Light, &cfg),
84-
fx.Invoke(func(s *sync.Syncer[*header.ExtendedHeader]) {
85-
syncer = s
86-
}),
87-
)
88-
require.Equal(t, cfg.Syncer.TrustingPeriod, syncer.Params.TrustingPeriod)
89-
require.NoError(t, app.Err())
90-
}
91-
9256
// TestConstructModule_ExchangeParams ensures that all passed via functional options
9357
// params are set in store correctly.
9458
func TestConstructModule_ExchangeParams(t *testing.T) {

nodebuilder/tests/tastora/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ require (
7878
github.com/bytedance/sonic v1.13.1 // indirect
7979
github.com/bytedance/sonic/loader v0.2.4 // indirect
8080
github.com/celestiaorg/go-fraud v0.2.3 // indirect
81-
github.com/celestiaorg/go-header v0.7.0 // indirect
81+
github.com/celestiaorg/go-header v0.7.1 // indirect
8282
github.com/celestiaorg/go-libp2p-messenger v0.2.2 // indirect
8383
github.com/celestiaorg/go-square/merkle v0.0.0-20240117232118-fd78256df076 // indirect
8484
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect

nodebuilder/tests/tastora/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,8 @@ github.com/celestiaorg/go-datastore v0.0.0-20250801131506-48a63ae531e4 h1:udw77B
803803
github.com/celestiaorg/go-datastore v0.0.0-20250801131506-48a63ae531e4/go.mod h1:W+pI1NsUsz3tcsAACMtfC+IZdnQTnC/7VfPoJBQuts0=
804804
github.com/celestiaorg/go-fraud v0.2.3 h1:vsGmd5HtGL92q/pvjN0cpDsXn7hGJSbVZwOJl+dNX8E=
805805
github.com/celestiaorg/go-fraud v0.2.3/go.mod h1:h2Or0jHka/TDlQ3XsJV6OibIiwm49UiGVEu2jHKzybA=
806-
github.com/celestiaorg/go-header v0.7.0 h1:bxRCjk6pabCk1J5HLT7ogQXkxcwS32E7KiIkcq+1igI=
807-
github.com/celestiaorg/go-header v0.7.0/go.mod h1:eX9iTSPthVEAlEDLux40ZT/olXPGhpxHd+mEzJeDhd0=
806+
github.com/celestiaorg/go-header v0.7.1 h1:XG0fQykSjKsCtWl9sY5jZXG12D4Xe59bjklWZ2sWip0=
807+
github.com/celestiaorg/go-header v0.7.1/go.mod h1:eX9iTSPthVEAlEDLux40ZT/olXPGhpxHd+mEzJeDhd0=
808808
github.com/celestiaorg/go-libp2p-messenger v0.2.2 h1:osoUfqjss7vWTIZrrDSy953RjQz+ps/vBFE7bychLEc=
809809
github.com/celestiaorg/go-libp2p-messenger v0.2.2/go.mod h1:oTCRV5TfdO7V/k6nkx7QjQzGrWuJbupv+0o1cgnY2i4=
810810
github.com/celestiaorg/go-square/merkle v0.0.0-20240117232118-fd78256df076 h1:PYInrsYzrDIsZW9Yb86OTi2aEKuPcpgJt6Mc0Jlc/yg=

0 commit comments

Comments
 (0)