From c16fa8104e31e8e9ce61a1a8b6a911cb1b42ed6d Mon Sep 17 00:00:00 2001 From: Stephan D Date: Sun, 1 Feb 2026 02:03:55 +0100 Subject: [PATCH] added logging --- api/gateway/chain/go.mod | 2 +- api/gateway/chain/go.sum | 4 ++-- api/gateway/tron/go.mod | 2 +- api/gateway/tron/go.sum | 4 ++-- .../orchestrator/plan_builder_gateways.go | 16 ++++++++++++++-- .../service/orchestrator/plan_builder_steps.go | 7 ++++++- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/api/gateway/chain/go.mod b/api/gateway/chain/go.mod index f72010dd..b234fdd4 100644 --- a/api/gateway/chain/go.mod +++ b/api/gateway/chain/go.mod @@ -22,7 +22,7 @@ require ( require ( github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260129130236-980997f64e25 // indirect + github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260131145833-e3fabd62fc61 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.24.4 // indirect github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect diff --git a/api/gateway/chain/go.sum b/api/gateway/chain/go.sum index bf8b5ecd..3bb6c62c 100644 --- a/api/gateway/chain/go.sum +++ b/api/gateway/chain/go.sum @@ -6,8 +6,8 @@ github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260129130236-980997f64e25 h1:0/qk6PCyqRadMiHQzH5Ld1TdaJn5tKcSsg8OQ+lW76I= -github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260129130236-980997f64e25/go.mod h1:ioLG6R+5bUSO1oeGSDxOV3FADARuMoytZCSX6MEMQkI= +github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260131145833-e3fabd62fc61 h1:iLc9NjmJ3AdAl5VoiRSDXzEmmW8kvHp3E2vJ2eKKc7s= +github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260131145833-e3fabd62fc61/go.mod h1:ioLG6R+5bUSO1oeGSDxOV3FADARuMoytZCSX6MEMQkI= github.com/VictoriaMetrics/fastcache v1.13.0 h1:AW4mheMR5Vd9FkAPUv+NH6Nhw+fmbTMGMsNAoA/+4G0= github.com/VictoriaMetrics/fastcache v1.13.0/go.mod h1:hHXhl4DA2fTL2HTZDJFXWgW0LNjo6B+4aj2Wmng3TjU= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/api/gateway/tron/go.mod b/api/gateway/tron/go.mod index 8016db2a..41a74af6 100644 --- a/api/gateway/tron/go.mod +++ b/api/gateway/tron/go.mod @@ -23,7 +23,7 @@ require ( require ( github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260129130236-980997f64e25 // indirect + github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260131145833-e3fabd62fc61 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.24.4 // indirect github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect diff --git a/api/gateway/tron/go.sum b/api/gateway/tron/go.sum index 560ab3b8..c63fbb03 100644 --- a/api/gateway/tron/go.sum +++ b/api/gateway/tron/go.sum @@ -6,8 +6,8 @@ github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260129130236-980997f64e25 h1:0/qk6PCyqRadMiHQzH5Ld1TdaJn5tKcSsg8OQ+lW76I= -github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260129130236-980997f64e25/go.mod h1:ioLG6R+5bUSO1oeGSDxOV3FADARuMoytZCSX6MEMQkI= +github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260131145833-e3fabd62fc61 h1:iLc9NjmJ3AdAl5VoiRSDXzEmmW8kvHp3E2vJ2eKKc7s= +github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260131145833-e3fabd62fc61/go.mod h1:ioLG6R+5bUSO1oeGSDxOV3FADARuMoytZCSX6MEMQkI= github.com/VictoriaMetrics/fastcache v1.13.0 h1:AW4mheMR5Vd9FkAPUv+NH6Nhw+fmbTMGMsNAoA/+4G0= github.com/VictoriaMetrics/fastcache v1.13.0/go.mod h1:hHXhl4DA2fTL2HTZDJFXWgW0LNjo6B+4aj2Wmng3TjU= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/api/payments/orchestrator/internal/service/orchestrator/plan_builder_gateways.go b/api/payments/orchestrator/internal/service/orchestrator/plan_builder_gateways.go index c7745bb3..6b857c88 100644 --- a/api/payments/orchestrator/internal/service/orchestrator/plan_builder_gateways.go +++ b/api/payments/orchestrator/internal/service/orchestrator/plan_builder_gateways.go @@ -9,16 +9,23 @@ import ( "github.com/shopspring/decimal" "github.com/tech/sendico/payments/orchestrator/storage/model" "github.com/tech/sendico/pkg/merrors" + "github.com/tech/sendico/pkg/mlogger" paymenttypes "github.com/tech/sendico/pkg/payments/types" + "go.uber.org/zap" ) -func ensureGatewayForAction(ctx context.Context, registry GatewayRegistry, cache map[model.Rail]*model.GatewayInstanceDescriptor, rail model.Rail, network string, amount *paymenttypes.Money, action model.RailOperation, instanceID string, dir sendDirection) (*model.GatewayInstanceDescriptor, error) { +func ensureGatewayForAction(ctx context.Context, logger mlogger.Logger, registry GatewayRegistry, cache map[model.Rail]*model.GatewayInstanceDescriptor, rail model.Rail, network string, amount *paymenttypes.Money, action model.RailOperation, instanceID string, dir sendDirection) (*model.GatewayInstanceDescriptor, error) { if registry == nil { return nil, merrors.InvalidArgument("plan builder: gateway registry is required") } if gw, ok := cache[rail]; ok && gw != nil { if instanceID == "" || strings.EqualFold(gw.InstanceID, instanceID) { if err := validateGatewayAction(gw, network, amount, action, dir); err != nil { + logger.Warn("Failed to validate gateway", zap.Error(err), + zap.String("instance_id", instanceID), zap.String("rail", string(rail)), + zap.String("network", network), zap.String("action", string(action)), + zap.String("direction", sendDirectionLabel(dir)), zap.Int("ralis_qty", len(cache)), + ) return nil, err } return gw, nil @@ -26,6 +33,11 @@ func ensureGatewayForAction(ctx context.Context, registry GatewayRegistry, cache } gw, err := selectGateway(ctx, registry, rail, network, amount, action, instanceID, dir) if err != nil { + logger.Warn("Failed to select gateway", zap.Error(err), + zap.String("instance_id", instanceID), zap.String("rail", string(rail)), + zap.String("network", network), zap.String("action", string(action)), + zap.String("direction", sendDirectionLabel(dir)), zap.Int("ralis_qty", len(cache)), + ) return nil, err } cache[rail] = gw @@ -106,7 +118,7 @@ func selectGateway(ctx context.Context, registry GatewayRegistry, rail model.Rai } if len(eligible) == 0 { if lastErr != nil { - return nil, merrors.InvalidArgument("plan builder: no eligible gateway instance found: " + lastErr.Error()) + return nil, merrors.InvalidArgument("plan builder: no eligible gateway instance found, last error: " + lastErr.Error()) } return nil, merrors.InvalidArgument("plan builder: no eligible gateway instance found") } diff --git a/api/payments/orchestrator/internal/service/orchestrator/plan_builder_steps.go b/api/payments/orchestrator/internal/service/orchestrator/plan_builder_steps.go index c05f04de..bab71b96 100644 --- a/api/payments/orchestrator/internal/service/orchestrator/plan_builder_steps.go +++ b/api/payments/orchestrator/internal/service/orchestrator/plan_builder_steps.go @@ -164,8 +164,13 @@ func (b *defaultPlanBuilder) buildPlanFromTemplate(ctx context.Context, payment checkAmount = cloneMoney(providerSettlementAmount) } } - gw, err := ensureGatewayForAction(ctx, gateways, gatewaysByRail, tpl.Rail, network, checkAmount, action, instanceID, sendDirectionForRail(tpl.Rail)) + gw, err := ensureGatewayForAction(ctx, b.logger, gateways, gatewaysByRail, tpl.Rail, network, checkAmount, action, instanceID, sendDirectionForRail(tpl.Rail)) if err != nil { + logger.Warn("Failed to ensure gateway for plan step", zap.Error(err), + zap.String("step_id", stepID), zap.String("rail", string(tpl.Rail)), + zap.String("gateway_network", network), zap.String("managed_wallet_network", managedWalletNetwork), + zap.Int("gateways_by_rail_count", len(gatewaysByRail)), + ) return nil, err } step.GatewayID = strings.TrimSpace(gw.ID)