Skip to content

Commit 1f5bf63

Browse files
committed
Update for changed master base (since PR #3642)
1 parent 60de41d commit 1f5bf63

File tree

14 files changed

+72
-41
lines changed

14 files changed

+72
-41
lines changed

tools/syncer/helpers/sync_ticker.nim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
{.push raises: [].}
1212

1313
import
14-
std/strutils,
15-
pkg/[chronos, chronicles, eth/common, stint, stew/interval_set],
14+
pkg/[chronos, chronicles, eth/common, stew/interval_set],
1615
../../../execution_chain/sync/beacon/worker/[blocks, headers, worker_desc]
1716

1817
logScope:

tools/syncer/replay/replay_desc.nim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ type
5656
ReplayEndUpFn* = proc() {.gcsafe, raises: [].}
5757
## Terminator control directive for runner/dispatcher
5858

59+
ReplayGetPeerFn* = GetPeerFn[BeaconCtxData,BeaconBuddyData]
60+
## Shortcut
61+
62+
ReplayGetPeersFn* = GetPeersFn[BeaconCtxData,BeaconBuddyData]
63+
## Shortcut
64+
5965
ReplayRef* = ref object of BeaconHandlersSyncRef
6066
## Overlay handlers extended by descriptor data for caching replay state
6167
ctx*: BeaconCtxRef ## Parent context
@@ -64,7 +70,7 @@ type
6470
stopQuit*: bool ## Quit after replay
6571
backup*: BeaconHandlersRef ## Can restore previous handlers
6672
reader*: ReplayReaderRef ## Input records
67-
73+
getPeerSave*: ReplayGetPeerFn ## Additionsl restore settings
6874

6975
ReplayPayloadRef* = ref object of RootRef
7076
## Decoded payload base record

tools/syncer/replay/replay_reader/reader_reclog.nim

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,14 @@ proc addX(
7777
$base.blkUnpr.value.bLeastLen
7878

7979
if base.peerCtx.isSome() and
80-
(0 < base.peerCtx.value.nHdrErrors or
81-
0 < base.peerCtx.value.nBlkErrors):
82-
q.add "nErr=(" & $base.peerCtx.value.nHdrErrors &
83-
"," & $base.peerCtx.value.nBlkErrors & ")"
80+
(0 < base.peerCtx.value.nErrors.fetch.hdr or
81+
0 < base.peerCtx.value.nErrors.fetch.bdy or
82+
0 < base.peerCtx.value.nErrors.apply.hdr or
83+
0 < base.peerCtx.value.nErrors.apply.blk):
84+
q.add "nErr=(" & $base.peerCtx.value.nErrors.fetch.hdr &
85+
"," & $base.peerCtx.value.nErrors.fetch.bdy &
86+
";" & $base.peerCtx.value.nErrors.apply.hdr &
87+
"," & $base.peerCtx.value.nErrors.apply.blk & ")"
8488

8589
if base.slowPeer.isSome():
8690
q.add "slowPeer=" & base.slowPeer.value.short()
@@ -170,6 +174,8 @@ func toStrSeq(n: int; w: ReplaySchedPeerBegin): seq[string] =
170174
var res = newSeqOfCap[string](20)
171175
res.addX(w.replayLabel, n, w.bag)
172176
res.add "peer=" & $w.bag.peerIP & ":" & $w.bag.peerPort
177+
res.add "info=" & $w.bag.rank.assessed
178+
res.add "rank=" & $w.bag.rank.ranking
173179
res
174180

175181
func toStrSeq(n: int; w: ReplaySchedPeerEnd): seq[string] =
@@ -186,8 +192,8 @@ func toStrSeq(n: int; w: ReplayFetchHeaders): seq[string] =
186192
rLen = w.bag.req.maxResults
187193
rRev = if w.bag.req.reverse: "rev" else: ""
188194
if w.bag.req.startBlock.isHash:
189-
res.add "req=" &
190-
w.bag.req.startBlock.hash.short & "[" & $rLen & "]" & rRev
195+
res.add "req=" & w.bag.req.startBlock.hash.short & "[" & $rLen & "]" & rRev
196+
res.add "bn=" & w.bag.bn.bnStr
191197
else:
192198
res.add "req=" &
193199
w.bag.req.startBlock.number.bnStr & "[" & $rLen & "]" & rRev

tools/syncer/replay/replay_runner/runner_desc.nim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ type
8484
# Instruction handling
8585
instrNumber*: uint ## Instruction counter
8686

87+
# ------------------------------------------------------------------------------
88+
# Fake scheduler `getPeer()` and `getPeers()` for replay runner
89+
# ------------------------------------------------------------------------------
90+
91+
proc replayGetPeerFn*(run: ReplayRunnerRef): ReplayGetPeerFn =
92+
result = proc(peerID: Hash): BeaconBuddyRef =
93+
run.peers.withValue(peerID,val):
94+
return val[]
95+
8796
# ------------------------------------------------------------------------------
8897
# End
8998
# ------------------------------------------------------------------------------

tools/syncer/replay/replay_runner/runner_dispatch/dispatch_headers.nim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func getBeaconError(e: ReplayWaitError): BeaconError =
5757
proc fetchHeadersHandler*(
5858
buddy: BeaconBuddyRef;
5959
req: BlockHeadersRequest;
60+
bn: BlockNumber;
6061
): Future[Result[FetchHeadersData,BeaconError]]
6162
{.async: (raises: []).} =
6263
## Replacement for `getBlockHeaders()` handler.
@@ -80,7 +81,10 @@ proc fetchHeadersHandler*(
8081
", expected=" & instr.bag.req.startBlock.toStr &
8182
# -----
8283
", reqLen=" & $req.maxResults &
83-
", expected=" & $instr.bag.req.maxResults
84+
", expected=" & $instr.bag.req.maxResults &
85+
# -----
86+
", bn=" & bn.bnStr &
87+
", expected=" & instr.bag.bn.bnStr
8488
data = instr
8589

8690
buddy.withInstr(ReplaySyncHeaders, info):

tools/syncer/replay/replay_runner/runner_dispatch/dispatch_helpers.nim

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ proc newPeerImpl(
175175
run: run,
176176
ctx: run.ctx,
177177
only: BeaconBuddyData(
178-
nRespErrors: (instr.bag.peerCtx.value.nHdrErrors,
179-
instr.bag.peerCtx.value.nBlkErrors)),
178+
nErrors: instr.bag.peerCtx.value.nErrors),
180179
peerID: instr.bag.peerCtx.value.peerID,
181180
peer: Peer(
182181
dispatcher: run.ethState.capa,
@@ -348,17 +347,17 @@ proc peerStatesDifferImpl(
348347
info info & ": peer ctrl states differ", n, serial, peer,
349348
ctrl=buddy.ctrl.state, expected=instr.bag.peerCtx.value.peerCtrl
350349

351-
if instr.bag.peerCtx.value.nHdrErrors != buddy.only.nRespErrors.hdr:
350+
if instr.bag.peerCtx.value.nErrors.fetch != buddy.nErrors.fetch:
352351
statesDiffer = true
353-
info info & ": peer header errors differ", n, serial, peer,
354-
nHdrErrors=buddy.only.nRespErrors.hdr,
355-
expected=instr.bag.peerCtx.value.nHdrErrors
352+
info info & ": peer fetch errors differ", n, serial, peer,
353+
nHdrErrors=buddy.nErrors.fetch,
354+
expected=instr.bag.peerCtx.value.nErrors
356355

357-
if instr.bag.peerCtx.value.nBlkErrors != buddy.only.nRespErrors.blk:
356+
if instr.bag.peerCtx.value.nErrors.apply != buddy.only.nErrors.apply:
358357
statesDiffer = true
359-
info info & ": peer body errors differ", n, serial, peer,
360-
nBlkErrors=buddy.only.nRespErrors.blk,
361-
expected=instr.bag.peerCtx.value.nBlkErrors
358+
info info & ": peer apply errors differ", n, serial, peer,
359+
nHdrErrors=buddy.nErrors.apply,
360+
expected=instr.bag.peerCtx.value.nErrors.apply
362361

363362
return statesDiffer
364363

tools/syncer/replay/replay_runner/runner_dispatch/dispatch_sched.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ proc schedPeerProcessImpl(
6060
# Activate peer
6161
buddy.run.nPeers.inc
6262

63-
discard await run.backup.schedPeer(buddy)
63+
discard await run.backup.schedPeer(buddy, instr.bag.rank)
6464
buddy.processFinishedClearFrame(instr, info)
6565

6666
trace info & ": end", n=run.iNum, serial=instr.bag.serial,

tools/syncer/replay/replay_setup.nim

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ proc noOpSchedDaemon(ctx: BeaconCtxRef):
6565
Future[Duration] {.async: (raises: []).} =
6666
return replayWaitMuted
6767

68-
proc noOpSchedPeer(buddy: BeaconBuddyRef):
68+
proc noOpSchedPeer(buddy: BeaconBuddyRef; rank: PeerRanking):
6969
Future[Duration] {.async: (raises: []).} =
7070
return replayWaitMuted
7171

@@ -95,20 +95,21 @@ proc replayStartCB(rpl: ReplayRunnerRef) =
9595
##
9696
# Set up redirect handlers for replay
9797
rpl.version = ReplayRunnerID
98-
# activate # use as is
99-
# suspend # use as is
98+
# activate # use as is
99+
# suspend # use as is
100100
rpl.reader = ReplayReaderRef.init(rpl.captStrm)
101101
rpl.schedDaemon = noOpSchedDaemon
102-
rpl.schedStart = noOpSchedStartFalse # `false` => don't register
102+
rpl.schedStart = noOpSchedStartFalse # `false` => don't register
103103
rpl.schedStop = noOpBuddy
104-
rpl.schedPool = noOpSchedPoolTrue # `true` => stop repeating
104+
rpl.schedPool = noOpSchedPoolTrue # `true` => stop repeating
105105
rpl.schedPeer = noOpSchedPeer
106-
rpl.getBlockHeaders = fetchHeadersHandler # from dispatcher
106+
rpl.getBlockHeaders = fetchHeadersHandler # from dispatcher
107107
rpl.syncBlockHeaders = noOpBuddy
108-
rpl.getBlockBodies = fetchBodiesHandler # from dispatcher
108+
rpl.getBlockBodies = fetchBodiesHandler # from dispatcher
109109
rpl.syncBlockBodies = noOpBuddy
110-
rpl.importBlock = importBlockHandler # from dispatcher
110+
rpl.importBlock = importBlockHandler # from dispatcher
111111
rpl.syncImportBlock = noOpBuddy
112+
rpl.ctx.getPeer = rpl.replayGetPeerFn() # normally provided by scheduler
112113

113114
rpl.initRunner()
114115

@@ -120,6 +121,7 @@ proc replayStartCB(rpl: ReplayRunnerRef) =
120121
ReplayRunnerRef(self).destroyRunner()
121122
stopInfo.onException(DontQuit):
122123
ReplayRunnerRef(self).captStrm.close()
124+
ReplayRunnerRef(self).ctx.getPeer = ReplayRunnerRef(self).getPeerSave
123125
ReplayRunnerRef(self).ctx.pool.handlers = ReplayRunnerRef(self).backup
124126

125127
# Start fake scheduler
@@ -155,6 +157,7 @@ proc replaySetup*(
155157
fakeImport: fakeImport,
156158
stopQuit: not noStopQuit,
157159
backup: ctx.pool.handlers,
160+
getPeerSave: ctx.getPeer,
158161

159162
# This is still the old descriptor which will be updated when
160163
# `startSync()` is run.

tools/syncer/syncer_test_client_replay.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import
1111
std/[cmdline, os, strutils, terminal],
1212
pkg/[chronicles, results],
13-
../../execution_chain/[config, nimbus_desc, nimbus_execution_client],
13+
../../execution_chain/[conf, nimbus_desc, nimbus_execution_client],
1414
../../execution_chain/sync/beacon,
1515
./helpers/sync_ticker,
1616
./replay/replay_setup

tools/syncer/syncer_test_client_trace.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import
1111
std/[cmdline, os, strutils, terminal],
1212
pkg/[chronicles, confutils, results],
13-
../../execution_chain/[config, nimbus_desc, nimbus_execution_client],
13+
../../execution_chain/[conf, nimbus_desc, nimbus_execution_client],
1414
../../execution_chain/sync/beacon,
1515
./helpers/sync_ticker,
1616
./trace/trace_setup

0 commit comments

Comments
 (0)