Skip to content

Commit f12360c

Browse files
committed
Add action status and recovery endpoints
1 parent 5e0a92e commit f12360c

File tree

10 files changed

+1001
-13
lines changed

10 files changed

+1001
-13
lines changed

.github/workflows/build&release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ jobs:
9393
env:
9494
DD_API_KEY: ${{ secrets.DD_API_KEY }}
9595
DD_SITE: ${{ secrets.DD_SITE }}
96+
RECOVERY_ADMIN_TOKEN: ${{ secrets.RECOVERY_ADMIN_TOKEN }}
9697
run: |
9798
# Ensure module metadata is up to date
9899
go mod tidy
@@ -110,7 +111,8 @@ jobs:
110111
-X github.com/LumeraProtocol/supernode/v2/supernode/cmd.BuildTime=${{ steps.vars.outputs.build_time }} \
111112
-X github.com/LumeraProtocol/supernode/v2/supernode/cmd.MinVer=${{ vars.MIN_VER }} \
112113
-X github.com/LumeraProtocol/supernode/v2/pkg/logtrace.DDAPIKey=${DD_API_KEY} \
113-
-X github.com/LumeraProtocol/supernode/v2/pkg/logtrace.DDSite=${DD_SITE}" \
114+
-X github.com/LumeraProtocol/supernode/v2/pkg/logtrace.DDSite=${DD_SITE} \
115+
-X github.com/LumeraProtocol/supernode/v2/supernode/transport/gateway.RecoveryAdminToken=${RECOVERY_ADMIN_TOKEN}" \
114116
-o release/supernode \
115117
./supernode
116118

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ LDFLAGS = -X github.com/LumeraProtocol/supernode/v2/supernode/cmd.Version=$(VERS
1919
-X github.com/LumeraProtocol/supernode/v2/supernode/cmd.BuildTime=$(BUILD_TIME) \
2020
-X github.com/LumeraProtocol/supernode/v2/supernode/cmd.MinVer=$(MIN_VER) \
2121
-X github.com/LumeraProtocol/supernode/v2/pkg/logtrace.DDAPIKey=$(DD_API_KEY) \
22-
-X github.com/LumeraProtocol/supernode/v2/pkg/logtrace.DDSite=$(DD_SITE)
22+
-X github.com/LumeraProtocol/supernode/v2/pkg/logtrace.DDSite=$(DD_SITE) \
23+
-X github.com/LumeraProtocol/supernode/v2/supernode/transport/gateway.RecoveryAdminToken=$(RECOVERY_ADMIN_TOKEN)
2324

2425
# Linker flags for sn-manager
2526
SN_MANAGER_LDFLAGS = -X main.Version=$(VERSION) \
@@ -205,4 +206,3 @@ test-sn-manager:
205206
@echo "Running sn-manager e2e tests..."
206207
@cd tests/system && ${GO} test -tags=system_test -v -run '^TestSNManager' .
207208

208-

supernode/adaptors/lumera.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
type LumeraClient interface {
1313
GetAction(ctx context.Context, actionID string) (*actiontypes.QueryGetActionResponse, error)
1414
GetTopSupernodes(ctx context.Context, blockHeight uint64) (*sntypes.QueryGetTopSuperNodesForBlockResponse, error)
15+
ListSupernodes(ctx context.Context) (*sntypes.QueryListSuperNodesResponse, error)
1516
Verify(ctx context.Context, address string, msg []byte, sig []byte) error
1617
GetActionFee(ctx context.Context, dataSizeKB string) (*actiontypes.QueryGetActionFeeResponse, error)
1718
SimulateFinalizeAction(ctx context.Context, actionID string, rqids []string) (*sdktx.SimulateResponse, error)
@@ -32,6 +33,10 @@ func (l *lumeraImpl) GetTopSupernodes(ctx context.Context, blockHeight uint64) (
3233
})
3334
}
3435

36+
func (l *lumeraImpl) ListSupernodes(ctx context.Context) (*sntypes.QueryListSuperNodesResponse, error) {
37+
return l.c.SuperNode().ListSuperNodes(ctx)
38+
}
39+
3540
func (l *lumeraImpl) Verify(ctx context.Context, address string, msg []byte, sig []byte) error {
3641
return l.c.Auth().Verify(ctx, address, msg, sig)
3742
}

supernode/cascade/download.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ const (
4040
)
4141

4242
type DownloadRequest struct {
43-
ActionID string
44-
Signature string
43+
ActionID string
44+
Signature string
45+
BypassPrivateSignature bool // recovery/admin path only; caller must enforce auth externally
4546
}
4647

4748
type DownloadResponse struct {
@@ -91,8 +92,8 @@ func (task *CascadeRegistrationTask) Download(ctx context.Context, req *Download
9192
return err
9293
}
9394

94-
// Step 4: Verify download signature for private cascades.
95-
if !metadata.Public {
95+
// Step 4: Verify download signature for private cascades unless explicitly bypassed by admin recovery.
96+
if !metadata.Public && !(req != nil && req.BypassPrivateSignature) {
9697
if req.Signature == "" {
9798
fields[logtrace.FieldError] = "missing signature for private download"
9899
return task.wrapErr(ctx, "private cascade requires a download signature", nil, fields)
@@ -102,6 +103,8 @@ func (task *CascadeRegistrationTask) Download(ctx context.Context, req *Download
102103
return task.wrapErr(ctx, "failed to verify download signature", err, fields)
103104
}
104105
logtrace.Info(ctx, "download: signature verified", fields)
106+
} else if !metadata.Public {
107+
logtrace.Warn(ctx, "download: private cascade signature bypassed (recovery/admin)", fields)
105108
} else {
106109
logtrace.Info(ctx, "download: public cascade (no signature)", fields)
107110
}

supernode/cascade/ica_verify_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ func (f *fakeCascadeLumeraClient) GetTopSupernodes(ctx context.Context, blockHei
2828
return nil, nil
2929
}
3030

31+
func (f *fakeCascadeLumeraClient) ListSupernodes(ctx context.Context) (*sntypes.QueryListSuperNodesResponse, error) {
32+
return nil, nil
33+
}
34+
3135
func (f *fakeCascadeLumeraClient) Verify(ctx context.Context, address string, msg []byte, sig []byte) error {
3236
if f.verifyFn == nil {
3337
return nil

supernode/cascade/stream_send_error_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ func (s *stubLumeraClient) GetTopSupernodes(context.Context, uint64) (*sntypes.Q
2323
panic("unexpected call")
2424
}
2525

26+
func (s *stubLumeraClient) ListSupernodes(context.Context) (*sntypes.QueryListSuperNodesResponse, error) {
27+
panic("unexpected call")
28+
}
29+
2630
func (s *stubLumeraClient) Verify(context.Context, string, []byte, []byte) error {
2731
panic("unexpected call")
2832
}

supernode/cmd/start.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,18 @@ The supernode will connect to the Lumera network and begin participating in the
185185
logtrace.Fatal(ctx, "Failed to create gRPC server", logtrace.Fields{"error": err.Error()})
186186
}
187187

188-
// Create HTTP gateway server that directly calls the supernode server
189-
// Pass chain ID for pprof configuration
190-
gatewayServer, err := gateway.NewServerWithConfig(
188+
// Create HTTP gateway server that directly calls the supernode server.
189+
// Recovery endpoints are always registered; access is token-gated at handler level.
190+
gatewayServer, err := gateway.NewServerWithConfigAndRecovery(
191191
appConfig.SupernodeConfig.Host,
192192
int(appConfig.SupernodeConfig.GatewayPort),
193193
supernodeServer,
194194
appConfig.LumeraClientConfig.ChainID,
195+
&gateway.RecoveryDeps{
196+
CascadeFactory: cService,
197+
P2PClient: p2pService,
198+
SelfSupernodeAddress: appConfig.SupernodeConfig.Identity,
199+
},
195200
)
196201
if err != nil {
197202
return fmt.Errorf("failed to create gateway server: %w", err)

0 commit comments

Comments
 (0)