Skip to content

chore: remove dead SkipRelaySigning global#2246

Merged
nimrod-teich merged 1 commit into
mainfrom
cleanup/remove-dead-skip-relay-signing
Mar 23, 2026
Merged

chore: remove dead SkipRelaySigning global#2246
nimrod-teich merged 1 commit into
mainfrom
cleanup/remove-dead-skip-relay-signing

Conversation

@nimrod-teich

@nimrod-teich nimrod-teich commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

User description

Summary

The smart-router never calls ConstructRelayRequest, SignRelayResponse, or VerifyRelayReply — it talks directly to RPC nodes, not through the Lava relay protocol. The SkipRelaySigning global, auto-enable logic, and CLI flags on both smart-router and provider were dead code.

Changes

  • Remove SkipRelaySigning global variable and all skip checks in ConstructRelayRequest, SignRelayResponse, VerifyRelayReply
  • Remove SkipRelaySigningFlag constant
  • Remove --skip-relay-signing CLI flag from both smart-router and provider
  • Remove smart-router auto-enable block (18 lines of dead startup logic)
  • Remove placeholder address logic in provider's ExtractConsumerAddress
  • Remove provider address skip in verifyRelayRequestMetaData
  • Remove 4 test functions that only tested the skip behavior
  • Fix TestConsumerProviderStatic integration test to use real provider addresses instead of "BANANA" + skip-signing hack

Test plan

  • go build ./protocol/... compiles cleanly
  • go test ./protocol/lavaprotocol/ passes
  • go test ./protocol/rpcprovider/ passes
  • No remaining references to SkipRelaySigning

🤖 Generated with Claude Code


Generated description

Below is a concise technical summary of the changes proposed in this PR:
Remove the SkipRelaySigning mechanism from lavaprotocol so constructors, signers, and verifiers always handle cryptographic material and providers always enforce metadata expectations. Update the RPC provider/smart-router CLI surfaces and integration test to assume real provider addresses, eliminating the placeholder address and auto-flag logic.

TopicDetails
Relay Signing Flow Simplify lavaprotocol relay signing by always generating and verifying signatures, removing SkipRelaySigning checks and CLI flags, and ensuring providers rely on real addresses.
Modified files (9)
  • protocol/common/cobra_common.go
  • protocol/lavaprotocol/request_builder.go
  • protocol/lavaprotocol/response_builder.go
  • protocol/lavaprotocol/response_builder_test.go
  • protocol/lavaprotocol/reuqest_builder_test.go
  • protocol/rpcprovider/rpcprovider.go
  • protocol/rpcprovider/rpcprovider_server.go
  • protocol/rpcprovider/rpcprovider_server_test.go
  • protocol/rpcsmartrouter/rpcsmartrouter.go
Latest Contributors(2)
UserCommitDate
nimrod.teich@gmail.comfix-make-relay-retry-l...March 01, 2026
anna@magmadevs.comfeat-provideroptimizer...February 22, 2026
Integration Test Update the static consumer/provider integration test to use real provider addresses instead of placeholder values so the normal verification path is exercised.
Modified files (1)
  • protocol/integration/protocol_test.go
Latest Contributors(2)
UserCommitDate
NadavLevifeat-smart-router-impl...March 11, 2026
anna@magmadevs.comfeat-provideroptimizer...February 22, 2026
This pull request is reviewed by Baz. Review like a pro on (Baz).

The smart-router never calls ConstructRelayRequest, SignRelayResponse,
or VerifyRelayReply — it talks directly to RPC nodes, not through the
Lava relay protocol. The SkipRelaySigning flag, auto-enable logic, and
CLI flags on both smart-router and provider were dead code.

Remove the global, all skip checks, the flag constant, and associated
tests. Fix the integration test to use real provider addresses instead
of relying on skip-signing to bypass address mismatch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Remove dead SkipRelaySigning global and related dead code
🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Remove dead SkipRelaySigning global variable and all skip checks
• Remove --skip-relay-signing CLI flags from smart-router and provider
• Remove smart-router auto-enable startup logic (18 lines)
• Remove 4 test functions testing only skip behavior
• Fix integration test to use real provider addresses instead of placeholder
Diagram
flowchart LR
  A["SkipRelaySigning Global"] -->|removed| B["Request Builder"]
  A -->|removed| C["Response Builder"]
  A -->|removed| D["Provider Server"]
  A -->|removed| E["Smart Router"]
  B -->|skip checks removed| F["ConstructRelayRequest"]
  C -->|skip checks removed| G["SignRelayResponse"]
  C -->|skip checks removed| H["VerifyRelayReply"]
  D -->|placeholder logic removed| I["ExtractConsumerAddress"]
  E -->|auto-enable removed| J["Smart Router Init"]
  K["Integration Test"] -->|fixed| L["Real Provider Addresses"]
Loading

Grey Divider

File Changes

1. protocol/common/cobra_common.go ⚙️ Configuration changes +0/-1

Remove SkipRelaySigningFlag constant definition

protocol/common/cobra_common.go


2. protocol/lavaprotocol/request_builder.go 🐞 Bug fix +0/-9

Remove SkipRelaySigning global and skip logic

protocol/lavaprotocol/request_builder.go


3. protocol/lavaprotocol/response_builder.go 🐞 Bug fix +0/-10

Remove skip signing checks from response functions

protocol/lavaprotocol/response_builder.go


View more (7)
4. protocol/lavaprotocol/response_builder_test.go 🧪 Tests +0/-186

Remove 3 test functions for skip signing behavior

protocol/lavaprotocol/response_builder_test.go


5. protocol/lavaprotocol/reuqest_builder_test.go 🧪 Tests +0/-52

Remove test for skip signing in request construction

protocol/lavaprotocol/reuqest_builder_test.go


6. protocol/rpcprovider/rpcprovider.go ⚙️ Configuration changes +0/-2

Remove skip-relay-signing CLI flag from provider

protocol/rpcprovider/rpcprovider.go


7. protocol/rpcprovider/rpcprovider_server.go 🐞 Bug fix +1/-13

Remove placeholder address logic and skip checks

protocol/rpcprovider/rpcprovider_server.go


8. protocol/rpcprovider/rpcprovider_server_test.go 🧪 Tests +0/-16

Remove skip signing test and placeholder address logic

protocol/rpcprovider/rpcprovider_server_test.go


9. protocol/rpcsmartrouter/rpcsmartrouter.go 🐞 Bug fix +0/-20

Remove auto-enable logic and CLI flag from smart-router

protocol/rpcsmartrouter/rpcsmartrouter.go


10. protocol/integration/protocol_test.go 🧪 Tests +1/-10

Fix integration test to use real provider addresses

protocol/integration/protocol_test.go


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Mar 22, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 📐 Spec deviations (0)

Grey Divider


Remediation recommended

1. Nil privKey not guarded 🐞 Bug ⛯ Reliability
Description
ConstructRelayRequest now always calls sigs.Sign(privKey, ...) and no longer has a bypass path,
but it does not validate privKey is non-nil, which can cause a panic or hard-to-diagnose failure
if a caller passes a nil key.
Code

protocol/lavaprotocol/request_builder.go[R129-136]

func ConstructRelayRequest(ctx context.Context, privKey *btcec.PrivateKey, lavaChainID, chainID string, relayRequestData *pairingtypes.RelayPrivateData, providerPublicAddress string, consumerSession *lavasession.SingleConsumerSession, epoch int64, reportedProviders []*pairingtypes.ReportedProvider) (*pairingtypes.RelayRequest, error) {
	relayRequest := &pairingtypes.RelayRequest{
		RelayData:    relayRequestData,
		RelaySession: ConstructRelaySession(lavaChainID, relayRequestData, chainID, providerPublicAddress, consumerSession, epoch, reportedProviders),
	}
-	// Skip signing when configured (e.g., smart router mode) to save CPU/memory
-	if SkipRelaySigning {
-		return relayRequest, nil
-	}
	sig, err := sigs.Sign(privKey, *relayRequest.RelaySession)
	if err != nil {
		return nil, err
Evidence
In the current implementation, the function accepts privKey *btcec.PrivateKey and immediately
signs with it. There is no nil-check before calling sigs.Sign, so a nil key (e.g., from a miswired
consumer/server setup or a future test helper) can crash or error at runtime instead of returning a
clear validation error.

protocol/lavaprotocol/request_builder.go[129-139]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`ConstructRelayRequest` unconditionally signs the relay session using `privKey`, but does not validate that the pointer is non-nil. This can lead to panics or unclear errors if `privKey` is nil.

### Issue Context
Relay signing is now mandatory (skip path removed), so input validation should be stricter and failures should be explicit.

### Fix Focus Areas
- protocol/lavaprotocol/request_builder.go[129-139]

### Suggested change
Add a guard at the top of `ConstructRelayRequest`:
- if `privKey == nil`, return a formatted error (ideally including the request GUID/context) before calling `sigs.Sign`.

This makes failures deterministic and easier to debug without changing normal behavior.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment thread protocol/lavaprotocol/request_builder.go
Comment thread protocol/rpcprovider/rpcprovider.go
@codecov

codecov Bot commented Mar 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
protocol/rpcprovider/rpcprovider_server.go 0.00% 1 Missing ⚠️
Flag Coverage Δ
consensus 8.71% <ø> (ø)
protocol 33.19% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
protocol/common/cobra_common.go 0.00% <ø> (ø)
protocol/lavaprotocol/request_builder.go 56.52% <ø> (-0.93%) ⬇️
protocol/lavaprotocol/response_builder.go 22.00% <ø> (-20.60%) ⬇️
protocol/rpcprovider/rpcprovider.go 8.35% <ø> (-0.13%) ⬇️
protocol/rpcsmartrouter/rpcsmartrouter.go 2.98% <ø> (+0.04%) ⬆️
protocol/rpcprovider/rpcprovider_server.go 9.55% <0.00%> (-0.28%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
7 files   ±0   0 ❌ ±0 

Results for commit 2fccb98. ± Comparison against base commit 50e9a40.

@nimrod-teich nimrod-teich changed the title cleanup: remove dead SkipRelaySigning global chore: remove dead SkipRelaySigning global Mar 22, 2026
@nimrod-teich nimrod-teich merged commit 4df6e90 into main Mar 23, 2026
30 of 33 checks passed
@nimrod-teich nimrod-teich deleted the cleanup/remove-dead-skip-relay-signing branch March 23, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants