Skip to content

Update contract.py #2846

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

Merged
merged 4 commits into from
Feb 24, 2023
Merged

Update contract.py #2846

merged 4 commits into from
Feb 24, 2023

Conversation

leafyoung
Copy link
Contributor

@leafyoung leafyoung commented Feb 24, 2023

What was wrong?

contract_function.call() returns the latest result when w3.eth.default_block has been set.

The default value "latest" for block_identifier parameter masks w3.eth.default_block even when it is set to non-None.

w3.eth.default_block is by default set to 'latest'. Changing the default value to None will not change its default behaviour.

If we do not change this, we have to add block_identifier=past_block_number to every .call(). This breaks existing codes using web3.py and it's very tedious to do so.

Related to Issue #

I found this wrong behaviour when running regression test with an earlier version of web3.py

How was it fixed?

Change the default value to None to make parse_block_identifier do the work.

Todo:

Set default block_identifier in ContractFunction.call() to None

Cute Animal Picture

phoenix.

The default parameter "latest" ignores when w3.eth.default_block is set.
* add newsfragment
@kclowes
Copy link
Collaborator

kclowes commented Feb 24, 2023

Thanks for raising this issue @leafyoung. This looks like a good change to me. I found a couple other places where we're doing the same thing, so I'll update those and push it up.

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

Thanks @leafyoung!

@kclowes kclowes merged commit 70c6c71 into ethereum:master Feb 24, 2023
@leafyoung
Copy link
Contributor Author

Thanks @kclowes

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.

2 participants