Skip to content

Commit

Permalink
[devnet] separare logging - headers download (#7551)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
  • Loading branch information
AlexeyAkhunov and Alex Sharp authored May 20, 2023
1 parent c919283 commit 2a872b4
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 43 deletions.
1 change: 1 addition & 0 deletions cmd/sentry/sentry/sentry_multi_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ func NewMultiClient(
1024*1024, /* linkLimit */
engine,
blockReader,
logger,
)
if chainConfig.TerminalTotalDifficultyPassed {
hd.SetPOSSync(true)
Expand Down
20 changes: 12 additions & 8 deletions ethdb/privateapi/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,16 @@ func makeTestDb(ctx context.Context, db kv.RwDB) {
}

func TestMockDownloadRequest(t *testing.T) {
logger := log.New()
db := memdb.NewTestDB(t)
ctx := context.Background()
require := require.New(t)

makeTestDb(ctx, db)
hd := headerdownload.NewHeaderDownload(0, 0, nil, nil)
hd := headerdownload.NewHeaderDownload(0, 0, nil, nil, logger)
hd.SetPOSSync(true)
events := shards.NewEvents()
backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, hd, false, log.New())
backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, hd, false, logger)

var err error
var reply *remote.EnginePayloadStatus
Expand Down Expand Up @@ -145,17 +146,18 @@ func TestMockDownloadRequest(t *testing.T) {
}

func TestMockValidExecution(t *testing.T) {
logger := log.New()
db := memdb.NewTestDB(t)
ctx := context.Background()
require := require.New(t)

makeTestDb(ctx, db)

hd := headerdownload.NewHeaderDownload(0, 0, nil, nil)
hd := headerdownload.NewHeaderDownload(0, 0, nil, nil, logger)
hd.SetPOSSync(true)

events := shards.NewEvents()
backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, hd, false, log.New())
backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, hd, false, logger)

var err error
var reply *remote.EnginePayloadStatus
Expand All @@ -181,17 +183,18 @@ func TestMockValidExecution(t *testing.T) {
}

func TestMockInvalidExecution(t *testing.T) {
logger := log.New()
db := memdb.NewTestDB(t)
ctx := context.Background()
require := require.New(t)

makeTestDb(ctx, db)

hd := headerdownload.NewHeaderDownload(0, 0, nil, nil)
hd := headerdownload.NewHeaderDownload(0, 0, nil, nil, logger)
hd.SetPOSSync(true)

events := shards.NewEvents()
backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, hd, false, log.New())
backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{TerminalTotalDifficulty: libcommon.Big1}, nil, hd, false, logger)

var err error
var reply *remote.EnginePayloadStatus
Expand All @@ -217,16 +220,17 @@ func TestMockInvalidExecution(t *testing.T) {
}

func TestNoTTD(t *testing.T) {
logger := log.New()
db := memdb.NewTestDB(t)
ctx := context.Background()
require := require.New(t)

makeTestDb(ctx, db)

hd := headerdownload.NewHeaderDownload(0, 0, nil, nil)
hd := headerdownload.NewHeaderDownload(0, 0, nil, nil, logger)

events := shards.NewEvents()
backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{}, nil, hd, false, log.New())
backend := NewEthBackendServer(ctx, nil, db, events, nil, &chain.Config{}, nil, hd, false, logger)

var err error

Expand Down
15 changes: 9 additions & 6 deletions p2p/discover/v5_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/ledgerwatch/erigon/p2p/discover/v5wire"
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/log/v3"
)

// This test checks that lookup works.
Expand All @@ -19,7 +20,8 @@ func TestUDPv5_lookup(t *testing.T) {
t.Skip("fix me on win please")
}
t.Parallel()
test := newUDPV5Test(t)
logger := log.New()
test := newUDPV5Test(t, logger)
t.Cleanup(test.close)

// Lookup on empty table returns no nodes.
Expand All @@ -31,7 +33,7 @@ func TestUDPv5_lookup(t *testing.T) {
for d, nn := range lookupTestnet.dists {
for i, key := range nn {
n := lookupTestnet.node(d, i)
test.getNode(key, &net.UDPAddr{IP: n.IP(), Port: n.UDP()})
test.getNode(key, &net.UDPAddr{IP: n.IP(), Port: n.UDP()}, logger)
}
}

Expand All @@ -53,7 +55,7 @@ func TestUDPv5_lookup(t *testing.T) {
recipient, key := lookupTestnet.nodeByAddr(to)
switch p := p.(type) {
case *v5wire.Ping:
test.packetInFrom(key, to, &v5wire.Pong{ReqID: p.ReqID})
test.packetInFrom(key, to, &v5wire.Pong{ReqID: p.ReqID}, logger)
case *v5wire.Findnode:
if asked[recipient.ID()] {
t.Error("Asked node", recipient.ID(), "twice")
Expand All @@ -62,7 +64,7 @@ func TestUDPv5_lookup(t *testing.T) {
nodes := lookupTestnet.neighborsAtDistances(recipient, p.Distances, 16)
t.Logf("Got FINDNODE for %v, returning %d nodes", p.Distances, len(nodes))
for _, resp := range packNodes(p.ReqID, nodes) {
test.packetInFrom(key, to, resp)
test.packetInFrom(key, to, resp, logger)
}
}
})
Expand All @@ -79,8 +81,9 @@ func TestUDPv5_lookupE2E(t *testing.T) {
t.Skip("fix me on win please")
}
t.Parallel()
logger := log.New()

bootNode := startLocalhostV5(t, Config{})
bootNode := startLocalhostV5(t, Config{}, logger)
bootNodeRec := bootNode.Self()

const N = 5
Expand All @@ -89,7 +92,7 @@ func TestUDPv5_lookupE2E(t *testing.T) {
cfg := Config{
Bootnodes: []*enode.Node{bootNodeRec},
}
node := startLocalhostV5(t, cfg)
node := startLocalhostV5(t, cfg, logger)
nodes = append(nodes, node)
}

Expand Down
8 changes: 5 additions & 3 deletions p2p/discover/v5_udp_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/ledgerwatch/erigon/p2p/discover/v5wire"
"github.com/ledgerwatch/log/v3"
)

// This test checks that calls with n replies may take up to n * respTimeout.
Expand All @@ -18,6 +19,7 @@ func TestUDPv5_callTimeoutReset(t *testing.T) {
t.Skip("fix me on win please")
}
t.Parallel()
logger := log.New()

replyTimeout := respTimeoutV5
// This must be significantly lower than replyTimeout to not get "RPC timeout" error.
Expand All @@ -32,13 +34,13 @@ func TestUDPv5_callTimeoutReset(t *testing.T) {
ctx := context.Background()
ctx = contextWithReplyTimeout(ctx, replyTimeout)

test := newUDPV5TestContext(ctx, t)
test := newUDPV5TestContext(ctx, t, logger)
t.Cleanup(test.close)

// Launch the request:
var (
distance = uint(230)
remote = test.getNode(test.remotekey, test.remoteaddr).Node()
remote = test.getNode(test.remotekey, test.remoteaddr, logger).Node()
nodes = nodesAtDistance(remote.ID(), int(distance), totalNodesResponseLimit)
done = make(chan error, 1)
)
Expand All @@ -55,7 +57,7 @@ func TestUDPv5_callTimeoutReset(t *testing.T) {
ReqID: p.ReqID,
Total: totalNodesResponseLimit,
Nodes: nodesToRecords(nodes[i : i+1]),
})
}, logger)
}
})
if err := <-done; err != nil {
Expand Down
Loading

0 comments on commit 2a872b4

Please sign in to comment.