Commit 06214315 authored by protolambda's avatar protolambda

op-node: fix p2p peerstore instantiation

parent fdabf5d9
...@@ -7,6 +7,8 @@ import ( ...@@ -7,6 +7,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/ethereum-optimism/optimism/op-service/clock"
"github.com/ethereum-optimism/optimism/op-node/p2p/store" "github.com/ethereum-optimism/optimism/op-node/p2p/store"
libp2p "github.com/libp2p/go-libp2p" libp2p "github.com/libp2p/go-libp2p"
lconf "github.com/libp2p/go-libp2p/config" lconf "github.com/libp2p/go-libp2p/config"
...@@ -138,7 +140,7 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter) (host.Host, ...@@ -138,7 +140,7 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter) (host.Host,
return nil, fmt.Errorf("failed to open peerstore: %w", err) return nil, fmt.Errorf("failed to open peerstore: %w", err)
} }
ps, err := store.NewExtendedPeerstore(context.Background(), basePs, conf.Store) ps, err := store.NewExtendedPeerstore(context.Background(), log, clock.SystemClock, basePs, conf.Store)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to open extended peerstore: %w", err) return nil, fmt.Errorf("failed to open extended peerstore: %w", err)
} }
......
...@@ -7,6 +7,8 @@ import ( ...@@ -7,6 +7,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/ethereum-optimism/optimism/op-service/clock"
p2p "github.com/ethereum-optimism/optimism/op-node/p2p" p2p "github.com/ethereum-optimism/optimism/op-node/p2p"
p2pMocks "github.com/ethereum-optimism/optimism/op-node/p2p/mocks" p2pMocks "github.com/ethereum-optimism/optimism/op-node/p2p/mocks"
"github.com/ethereum-optimism/optimism/op-node/p2p/store" "github.com/ethereum-optimism/optimism/op-node/p2p/store"
...@@ -72,9 +74,10 @@ func (c *customPeerstoreNetwork) Close() error { ...@@ -72,9 +74,10 @@ func (c *customPeerstoreNetwork) Close() error {
// getNetHosts generates a slice of hosts using the [libp2p/go-libp2p] library. // getNetHosts generates a slice of hosts using the [libp2p/go-libp2p] library.
func getNetHosts(testSuite *PeerScoresTestSuite, ctx context.Context, n int) []host.Host { func getNetHosts(testSuite *PeerScoresTestSuite, ctx context.Context, n int) []host.Host {
var out []host.Host var out []host.Host
log := testlog.Logger(testSuite.T(), log.LvlError)
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
swarm := tswarm.GenSwarm(testSuite.T()) swarm := tswarm.GenSwarm(testSuite.T())
eps, err := store.NewExtendedPeerstore(ctx, swarm.Peerstore(), sync.MutexWrap(ds.NewMapDatastore())) eps, err := store.NewExtendedPeerstore(ctx, log, clock.SystemClock, swarm.Peerstore(), sync.MutexWrap(ds.NewMapDatastore()))
netw := &customPeerstoreNetwork{swarm, eps} netw := &customPeerstoreNetwork{swarm, eps}
require.NoError(testSuite.T(), err) require.NoError(testSuite.T(), err)
h := bhost.NewBlankHost(netw) h := bhost.NewBlankHost(netw)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment