Skip to content

Commit 3951589

Browse files
committed
diag: Log adaptor message routing on both sides.
The adaptor setup phase flows silently through the server (AuthManager only logs handling failures, not successes) and through the client runJob loop (which logs only when a handler takes >=250ms). That makes it hard to diagnose a stuck swap: a participant that never receives the relayed AdaptorLocked looks identical to one where the inbound handler is blocked inside the cgo XMR wallet. Add four log lines, all at INFO, to distinguish those cases on the next simnet run: - client handleAdaptorMsg: log route + matchID on entry, and route + matchID + dispatch elapsed time + err on exit. - server AdaptorCoordinators.Handle: log the inbound route + matchID + phase before c.Handle, and the resulting phase + err after. - server dex.adaptorRouter: log each outbound relay (route, matchID, role, user, err). No behavior change. Test rig Core{} in TestHandleAdaptorMsg now sets log: tLogger so handleAdaptorMsg doesn't nil-deref the logger. Revert (or downgrade to Tracef) once the simnet swap is green.
1 parent 8e7ba7f commit 3951589

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

client/core/adaptorswap_bridge.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,16 @@ func handleAdaptorMsg(c *Core, _ *dexConnection, msg *msgjson.Message) error {
493493
if err != nil {
494494
return fmt.Errorf("decode %s: %w", msg.Route, err)
495495
}
496-
if err := c.adaptorMgr.Handle(msg.Route, matchID, payload); err != nil {
496+
// Diagnostic: make the inbound adaptor route + dispatch outcome
497+
// visible in the log so stuck handlers (e.g. a blocked XMR send)
498+
// can be distinguished from dropped messages. Matched by the
499+
// dispatch-complete log below.
500+
c.log.Infof("adaptor msg inbound route=%s match=%s", msg.Route, matchID)
501+
start := time.Now()
502+
err = c.adaptorMgr.Handle(msg.Route, matchID, payload)
503+
c.log.Infof("adaptor msg dispatch route=%s match=%s elapsed=%s err=%v",
504+
msg.Route, matchID, time.Since(start), err)
505+
if err != nil {
497506
if IsInformational(err) {
498507
return nil
499508
}

client/core/adaptorswap_bridge_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestHandleAdaptorMsg(t *testing.T) {
153153
mgr := NewAdaptorSwapManager(&AdaptorSwapManagerConfig{
154154
BTC: &bridgeFakeBTC{}, XMR: &bridgeFakeXMR{}, Send: sender,
155155
})
156-
c := &Core{adaptorMgr: mgr}
156+
c := &Core{adaptorMgr: mgr, log: tLogger}
157157

158158
matchID := order.MatchID{0xAB}
159159
if _, err := mgr.StartSwap(&adaptorswap.Config{

server/dex/dex.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,13 @@ func NewDEX(ctx context.Context, cfg *DexConf) (*DEX, error) {
10381038
if err != nil {
10391039
return fmt.Errorf("adaptor router: NewNotification: %w", err)
10401040
}
1041-
return authMgr.Send(user, msg)
1041+
// Diagnostic: log each outbound relay so operators can see
1042+
// whether a Send failed (user offline, link broken) versus
1043+
// the participant's handler dropping a delivered message.
1044+
sendErr := authMgr.Send(user, msg)
1045+
log.Infof("adaptor router relayed route=%s match=%s to role=%s (user=%s): err=%v",
1046+
route, matchID, role, user, sendErr)
1047+
return sendErr
10421048
})
10431049
adaptorCoords = swap.NewAdaptorCoordinators(adaptor.Config{
10441050
Router: adaptorRouter,

server/swap/adaptor_bridge.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,16 @@ func (cc *AdaptorCoordinators) Handle(route string, matchID order.MatchID, paylo
105105
if err != nil {
106106
return err
107107
}
108-
return c.Handle(evt)
108+
// Diagnostic: make inbound adaptor events visible in the server log
109+
// and report whether the coordinator accepted them. Lets the
110+
// operator tell "message never arrived" apart from "coordinator
111+
// rejected it".
112+
log.Infof("adaptor coordinator inbound route=%s match=%s phase=%s",
113+
route, matchID, c.Phase())
114+
err = c.Handle(evt)
115+
log.Infof("adaptor coordinator dispatched route=%s match=%s phase=%s err=%v",
116+
route, matchID, c.Phase(), err)
117+
return err
109118
}
110119

111120
// Dispatch feeds a non-message event (chain observation, timeout)

0 commit comments

Comments
 (0)