Skip to content

rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl#171

Merged
louisliu2048 merged 1 commit intomainfrom
devin/1772682887-rpc-optimize-trait-bounds
Mar 5, 2026
Merged

rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl#171
louisliu2048 merged 1 commit intomainfrom
devin/1772682887-rpc-optimize-trait-bounds

Conversation

@Vui-Chee
Copy link
Contributor

@Vui-Chee Vui-Chee commented Mar 5, 2026

Description

The XlayerRpcExtApiServer impl for XlayerRpcExt<T> had excessive trait bounds that were never actually used. The only method (flashblocks_enabled) calls self.backend.has_pending_flashblock(), which only requires PendingFlashBlockProvider. This PR strips the unused bounds and their corresponding imports/dependencies.

Removed trait bounds on T: EthFees, LoadFee, LoadBlock, EthApiTypes<NetworkTypes = Net>, SequencerClientProvider, Clone, and the entire T::Provider: ChainSpecProvider<...> + BlockReaderIdExt + HeaderProvider clause.

Removed unused crate dependencies: reth-chainspec, reth-storage-api.

Kept: PendingFlashBlockProvider + Send + Sync + 'static (the only bounds actually needed).

This reduces compile-time trait resolution work and shrinks the dependency graph for the xlayer-rpc crate.

Type of Change

  • Refactoring (no functional changes)

Checklist

  • My code follows the coding standards of this project
  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes

Testing

  • cargo check -p xlayer-rpc — passes
  • cargo test -p xlayer-rpc — all 4 existing tests pass

Human Review Checklist

  • Verify full workspace build: The downstream binary (bin/node/src/main.rs) instantiates XlayerRpcExt with Arc<OpEthApi<...>>. Confirm it compiles with the reduced bounds (local build hit an unrelated openssl-sys system dep issue before reaching that crate).
  • Confirm no implicit bound requirements from jsonrpsee codegen: The #[rpc] macro generates into_rpc() — verify it doesn't silently depend on any removed bounds at the call site in main.rs.

Additional Notes

Link to Devin session: https://app.devin.ai/sessions/12a9c90470fa4e81a5441eb476edce91
Requested by: @Vui-Chee

…xtApiServer impl

The XlayerRpcExtApiServer impl for XlayerRpcExt only uses
PendingFlashBlockProvider via has_pending_flashblock(), but had
excessive trait bounds including EthFees, LoadFee, LoadBlock,
EthApiTypes, SequencerClientProvider, Clone, and complex Provider
bounds that were never used.

Changes:
- Remove unused trait bounds from XlayerRpcExtApiServer impl, keeping
  only PendingFlashBlockProvider + Send + Sync + 'static
- Remove unused imports (reth_chainspec, reth_rpc_eth_api helpers,
  reth_storage_api) from xlayer_ext.rs
- Remove unused crate dependencies (reth-chainspec, reth-storage-api)
  from Cargo.toml

This improves compile times by reducing trait resolution work and
dependency graph, and makes the code clearer about actual requirements.

Co-Authored-By: vuicheesiew@gmail.com <vuicheesiew@gmail.com>
Copy link
Contributor

@JimmyShi22 JimmyShi22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@louisliu2048 louisliu2048 merged commit 5aa1698 into main Mar 5, 2026
@Vui-Chee Vui-Chee deleted the devin/1772682887-rpc-optimize-trait-bounds branch March 5, 2026 06:11
Vui-Chee added a commit that referenced this pull request Mar 9, 2026
* main:
  Feat(chainspec): adding xlayer-devnet chainspec (#167)
  chore(builder): flatten flashblocks builder, remove unnecessary trait interfaces (#172)
  rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl (#171)
  fix fmt in bin/tools/gen_genesis.rs (#170)
  fix(builder): Resolve bugs on upstream flashblocks timing scheduler (#169)
  Feat(tools): Add a tool to generate a custom genesis file based on a template and existing chain data (#159)
  feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder (#162)
  chore(builder): remove unused custom-engine-api feature flag in tests (#168)
  fix: p2p test hang due to hang on port (#165)
Vui-Chee added a commit that referenced this pull request Mar 13, 2026
* main: (25 commits)
  fix: bump quinn-proto to 0.11.14 to patch CVE-2026-31812 DoS vuln (#183)
  pre-job authorization (#193)
  fix: trigger review skill failed to ack (#192)
  feat: trigger skill review separately (#191)
  feat: add Claude skills and CLAUDE.md for AI-assisted development (#190)
  rename ext (#185)
  supply workflow for claude (#184)
  feat(builder): incremental trie cache optimization for flashblocks state root (#163)
  chore(flashblocks-rpc): migrate op-reth flashblocks into xlayer-reth (#175)
  Feat(chainspec): adding xlayer-devnet chainspec (#167)
  chore(builder): flatten flashblocks builder, remove unnecessary trait interfaces (#172)
  rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl (#171)
  fix fmt in bin/tools/gen_genesis.rs (#170)
  fix(builder): Resolve bugs on upstream flashblocks timing scheduler (#169)
  Feat(tools): Add a tool to generate a custom genesis file based on a template and existing chain data (#159)
  feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder (#162)
  chore(builder): remove unused custom-engine-api feature flag in tests (#168)
  fix: p2p test hang due to hang on port (#165)
  fix: update testcontainers to v0.27.0 to remediate CVE-2025-62518 (#164)
  chore(builder): further clean up builder crate (#161)
  ...
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.

3 participants