Skip to content

Conversation

@brbrr
Copy link
Contributor

@brbrr brbrr commented Dec 4, 2025

fixes #3261

@brbrr brbrr self-assigned this Dec 4, 2025
Copilot AI review requested due to automatic review settings December 4, 2025 16:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors block fetching to separate header and transaction retrieval as part of fixing issue #3261. The change aims to optimize performance by allowing header and transaction data to be fetched independently rather than always fetching the entire block.

Key changes:

  • Added new blockTxnsByNumber helper method and TransactionsByBlockNumber blockchain reader method to fetch transactions separately
  • Refactored BlockWithTxHashes and BlockWithTxs to call blockHeaderByID and blockTxnsByNumber separately instead of blockByID
  • Updated blockStatus signature to accept block number directly instead of the full block

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
rpc/v9/helpers.go Added new blockTxnsByNumber helper to fetch transactions by block number
rpc/v9/block.go Refactored BlockWithTxHashes and BlockWithTxs to use separate header and transaction fetches; updated blockStatus to accept block number
blockchain/blockchain.go Added new TransactionsByBlockNumber method to Reader interface and implementation
mocks/mock_blockchain.go Added mock implementation for TransactionsByBlockNumber method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@brbrr brbrr changed the title Fetch block header and txns separately fix: getBlockWithTx* fetch block header and txns separately Dec 5, 2025
@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 72.60274% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.26%. Comparing base (d0c941b) to head (ef1acb0).

Files with missing lines Patch % Lines
rpc/v10/helpers.go 52.94% 6 Missing and 2 partials ⚠️
rpc/v8/helpers.go 52.94% 6 Missing and 2 partials ⚠️
rpc/v9/helpers.go 52.94% 6 Missing and 2 partials ⚠️
blockchain/blockchain.go 0.00% 4 Missing ⚠️
rpc/v10/block.go 87.87% 2 Missing and 2 partials ⚠️
rpc/v8/block.go 86.20% 2 Missing and 2 partials ⚠️
rpc/v9/block.go 86.20% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3322      +/-   ##
==========================================
+ Coverage   76.20%   76.26%   +0.05%     
==========================================
  Files         346      346              
  Lines       32713    32816     +103     
==========================================
+ Hits        24930    25027      +97     
+ Misses       5993     5987       -6     
- Partials     1790     1802      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

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.

starknet_getBlockWithTxHashes and starknet_getBlockWithTxs don't need to load receipts

2 participants