Skip to content

chore: remove dead code identified by static analysis#1571

Open
joanestebanr wants to merge 1 commit intodevelopfrom
chore/remove-dead-code
Open

chore: remove dead code identified by static analysis#1571
joanestebanr wants to merge 1 commit intodevelopfrom
chore/remove-dead-code

Conversation

@joanestebanr
Copy link
Copy Markdown
Collaborator

🔄 Changes Summary

Removes dead code identified by static analysis (whole-program call graph + manual grep validation). All removed elements had zero references in production code.

  • agglayer/tx.go (deleted): Legacy ZKP-based certificate submission types (Tx, SignedTx, ZKP) and their methods. Superseded by gRPC-based submission; never referenced anywhere in the codebase.
  • agglayer/client.go: Remove ErrAgglayerRateLimitExceeded — defined but never referenced (no errors.Is calls, no switch cases).
  • aggsender/flows/builder_flow_aggchain_prover.go: Remove l1Client aggkittypes.BaseEthereumClienter parameter from NewAggchainProverBuilderFlow — accepted but never stored on the struct or used in the constructor body. Remove config AggchainProverFlowConfig struct field — assigned in constructor but never read in any method.
  • aggsender/metrics/metrics.go: Remove SendingRetry() function and numberOfSendingRetries counter — metric registered but never incremented by any caller.

⚠️ Breaking Changes

None. All removed exports had zero usages in the codebase.

📋 Config Updates

None.

✅ Testing

  • 🤖 Automatic:
    • make test-unit
  • 🖱️ Manual:
    • go build ./... — passes clean
    • go vet ./aggsender/... ./agglayer/... ./multidownloader/... ./reorgdetector/... — no issues

🐞 Issues

  • Closes #N/A

🔗 Related PRs

None

📝 Notes

getL2StartBlock in aggsender/flows/builder_flow_aggchain_prover.go is also production-unreachable (the equivalent logic lives in aggsender/query/aggchain_fep_rollup_query.go), but it has a dedicated unit test so it was left for a follow-up cleanup.

- Delete agglayer/tx.go: legacy ZKP submission types (Tx, SignedTx, ZKP)
  superseded by gRPC, never referenced outside the file
- Remove ErrAgglayerRateLimitExceeded: defined but never used anywhere
- Remove unused l1Client parameter from NewAggchainProverBuilderFlow:
  accepted but never stored or used in the constructor body
- Remove unused config struct field from AggchainProverBuilderFlow:
  assigned in constructor but never read in any method
- Remove SendingRetry metric: counter registered but never incremented

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude bot commented Apr 8, 2026

Claude finished @joanestebanr's task in 2m 21s —— View job


🔍 Code Review Complete


🚀 What's New

This PR removes 93 lines of dead code identified through static analysis, including legacy ZKP-based certificate submission types, unused error definitions, unused function parameters, unused struct fields, and unused metrics.

🐛 Bug Fixes

None.

📋 Config Updates

None.

⚠️ Breaking Changes

None. All removed exports had zero usages in the codebase.

✅ Review Summary

This is an excellent cleanup PR. The static analysis and manual validation were thorough, and the removals are safe. All tests should pass (the vulnerability check failure is unrelated to these changes).

🟢 Detailed Findings

1. agglayer/tx.go (deleted) - Approved

  • Removed legacy types: Tx, SignedTx, ZKP
  • ✅ Verified no references to agglayer.Tx, agglayer.SignedTx, or agglayer.ZKP in codebase
  • ✅ Similar-named types found elsewhere (validator/cert_hash.go, optimistic/optimistic_sign.go) are unrelated
  • These were indeed legacy ZKP-based submission types superseded by gRPC

2. agglayer/client.go - Approved

  • Removed: ErrAgglayerRateLimitExceeded error and unused errors import
  • ✅ Verified zero references via errors.Is, errors.As, or direct usage
  • Clean removal, import cleanup correct

3. aggsender/flows/builder_flow_aggchain_prover.go - Approved

  • Removed unused parameter: l1Client aggkittypes.BaseEthereumClienter from NewAggchainProverBuilderFlow
  • Removed unused struct field: config AggchainProverFlowConfig
  • ✅ Verified parameter was never stored or used in constructor body
  • ✅ Verified config field had no references (no .config. usages)
  • ✅ All call sites updated correctly in:
    • builder_flow_factory.go:135-145
    • verifier_flow_factory.go:95-105
    • Test files

4. aggsender/metrics/metrics.go - Approved

  • Removed: SendingRetry() function and numberOfSendingRetries counter
  • ✅ Verified zero callers to SendingRetry()
  • Metric was registered but never incremented - dead code

🟡 Notes & Observations

  1. getL2StartBlock function: As mentioned in PR notes, this function at aggsender/flows/builder_flow_aggchain_prover.go:35 is also production-unreachable but has a dedicated unit test (Test_AggchainProverFlow_getL2StartBlock). Good call leaving it for follow-up cleanup.

  2. CI Status:

    • ✅ PR semantic check passed
    • ⚠️ Vulnerability check failed with 2 known vulnerabilities (unrelated to this PR):
      • google.golang.org/grpc@v1.79.1 → needs upgrade to v1.79.3 (GO-2026-4762)
      • github.com/pion/dtls/v2@v2.2.12 → no fix available (GO-2026-4479)
    • 🔄 Other checks still running (lint, unit tests, E2E tests, CodeQL)
  3. Code Quality: The PR demonstrates excellent software engineering practices:

    • Using whole-program call graph analysis
    • Manual grep validation
    • Comprehensive commit message
    • Proper test updates

🎯 Recommendation

APPROVE - This PR is safe to merge once CI passes. The changes are purely deletions of verified dead code with no functional impact.

📊 Change Statistics

  • Files changed: 8
  • Deletions: 93 lines
  • Additions: 0 lines
  • Tests updated: 3 test files

@joanestebanr joanestebanr self-assigned this Apr 8, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 8, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant