Skip to content
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

bug: missing parameters in get_block() method #1549

Closed
1 task done
shawakash opened this issue Jan 12, 2025 · 8 comments
Closed
1 task done

bug: missing parameters in get_block() method #1549

shawakash opened this issue Jan 12, 2025 · 8 comments
Labels
bug Something isn't working

Comments

@shawakash
Copy link

What happened

While fetching the block details from a block number using node_client.get_block() function, an error was raised saying some parameters like l1_data_gas_price and l1_da_mode is missed.
Screenshot 2025-01-12 at 6 20 27 AM

My node client is working fine as i am able to use another methods and i tried changing the sdk version from 0.24.3 to 0.24.2, still issue persisted
Screenshot 2025-01-12 at 6 38 32 AM

Stack trace

ERROR - Error getting date from block: {'l1_data_gas_price': ['Missing data for required field.'], 'l1_da_mode': ['Missing data for required field.']}

Steps to reproduce

  1. just try to fetch the get_block() function in FullNodeClient https://starknetpy.readthedocs.io/en/latest/api/full_node_client.html#starknet_py.net.full_node_client.FullNodeClient.get_block

SDK Version

0.24.3

Python version

Python 3.11.0

What operating system are you using?

Mac

Is there an existing issue for this?

  • I have searched the existing issues and verified no issue exits for this problem.
@shawakash shawakash added the bug Something isn't working label Jan 12, 2025
@shawakash
Copy link
Author

@franciszekjob any clue here ?

@franciszekjob
Copy link
Collaborator

Hi @shawakash 👋 ,
get_block returns an object which is defined as PENDING_BLOCK_HEADER in spec
It should have several fields, including l1_data_gas_price and l1_da_mode. For some reason, the response which you receive while calling node_client.get_block(...), doesn't include these fields, hence the problem during deserialization.

Which node are you using?

@shawakash
Copy link
Author

hey @franciszekjob ,
i am using the mainnet node from blastapi.io

@shawakash
Copy link
Author

only the get_date_from_block() func ?

@shawakash
Copy link
Author

async def get_date_from_block(self, block: int) -> Optional[datetime]:
        """Get date from block number"""
        try:
            block_info = await self.node_client.get_block(block_number=block)
            self._logger.info(f"Block info: {block_info}")
            return datetime.fromtimestamp(block_info.timestamp)
        except Exception as e:
            self._logger.error(f"Error getting date from block: {str(e)}")
            return None

here you go @franciszekjob

@franciszekjob
Copy link
Collaborator

franciszekjob commented Jan 12, 2025

Ok, I managed to reproduce your error. It's because you're using endpoint for RPC 0.8.0. Fore some reason, block header response lacks l1_data_gas_price and l1_da_mode 🤔 . Try with https://starknet-mainnet.public.blastapi.io/rpc/v0_7 which uses RPC 0.7.0. Should work, let me know 😄

@shawakash
Copy link
Author

thanks a lot bud, it worked
@franciszekjob saved me a lot of time to debug this

@franciszekjob
Copy link
Collaborator

@shawakash happy I could help you 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants