-
Notifications
You must be signed in to change notification settings - Fork 0
fix: inconsistent block number #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…or price fetching
…to fix/inconsistent-block-number
…tching token decimals
…d property for configuration validation
…inconsistent-block-number
There was a problem hiding this 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_numberandhl_block_numberfields toOracleSettingswith 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.
| count = await self._rpc( | ||
| getattr(contract.functions, count_function)().call, | ||
| block_identifier=self.block_number, | ||
| ) |
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
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)
| getattr(contract.functions, item_function)(index).call, | ||
| block_identifier=self.block_number, |
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
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)
| 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) |
| w3.eth.get_balance, | ||
| checksum_subvault_address, | ||
| block_identifier=self.block_number, |
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
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)
| 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) |
There was a problem hiding this 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
Closes #53
Added block number and hl_block_number parameters to keep consistency across rpc calls