Skip to content

Conversation

@matias-gonz
Copy link
Member

Closes #53

Added block number and hl_block_number parameters to keep consistency across rpc calls

Base automatically changed from fix/eth-tests to master October 30, 2025 13:16
Copilot AI review requested due to automatic review settings October 30, 2025 13:17
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 fixes inconsistent block number usage across RPC calls by adding block_number and hl_block_number parameters to ensure all blockchain queries use the same block reference.

Key changes:

  • Added block_number and hl_block_number fields to OracleSettings with corresponding required property accessors
  • Updated all RPC calls throughout the codebase to use explicit block numbers instead of "latest"
  • Added CLI options to specify block numbers, with automatic fallback to latest block if not provided

Reviewed Changes

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

Show a summary per file
File Description
src/tq_oracle/settings.py Added block_number and hl_block_number fields with required property accessors
src/tq_oracle/main.py Added CLI options for block numbers and logic to fetch latest block if not specified
src/tq_oracle/processors/oracle_helper.py Updated getPricesD18 call to use block_number instead of "latest"
src/tq_oracle/adapters/price_adapters/chainlink.py Updated latestRoundData and decimals calls to use block_number
src/tq_oracle/adapters/price_adapters/cow_swap.py Updated token decimals call to use block_number
src/tq_oracle/adapters/check_adapters/timeout_check.py Updated all oracle contract calls to use block_number
src/tq_oracle/adapters/asset_adapters/idle_balances.py Updated balance and contract list fetching to use block_number/hl_block_number
tests/adapters/price_adapters/test_eth.py Removed wsteth-related test fixtures and integration tests
tests/* (multiple test files) Added block_number parameter to test config fixtures

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

Comment on lines +195 to +198
count = await self._rpc(
getattr(contract.functions, count_function)().call,
block_identifier=self.block_number,
)
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

The block_identifier parameter is being passed to _rpc method, but it should be passed to the .call() method instead. The current implementation passes it as a keyword argument to _rpc, which likely doesn't accept this parameter. Change to: getattr(contract.functions, count_function)().call(block_identifier=self.block_number)

Copilot uses AI. Check for mistakes.
Comment on lines +203 to +204
getattr(contract.functions, item_function)(index).call,
block_identifier=self.block_number,
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

The block_identifier parameter is being passed to _rpc method, but it should be passed to the .call() method instead. The current implementation passes it as a keyword argument to _rpc, which likely doesn't accept this parameter. Change to: getattr(contract.functions, item_function)(index).call(block_identifier=self.block_number)

Suggested change
getattr(contract.functions, item_function)(index).call,
block_identifier=self.block_number,
lambda: getattr(contract.functions, item_function)(index).call(block_identifier=self.block_number)

Copilot uses AI. Check for mistakes.
Comment on lines +247 to +249
w3.eth.get_balance,
checksum_subvault_address,
block_identifier=self.block_number,
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

The block_identifier parameter is being passed to _rpc method, but it should be passed to get_balance as the second positional argument or keyword argument. The current implementation incorrectly passes it to _rpc. Change to: w3.eth.get_balance(checksum_subvault_address, block_identifier=self.block_number)

Suggested change
w3.eth.get_balance,
checksum_subvault_address,
block_identifier=self.block_number,
lambda: w3.eth.get_balance(checksum_subvault_address, block_identifier=self.block_number)

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@timbrinded timbrinded left a comment

Choose a reason for hiding this comment

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

Looks good. Don't merge yet because I'd like to manually test this

@timbrinded timbrinded merged commit 0cc19dc into master Oct 31, 2025
6 checks passed
@timbrinded timbrinded deleted the fix/inconsistent-block-number branch October 31, 2025 12:07
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.

Onchain calls may be made on different blocks, resulting in data inconsistencies.

3 participants