Comments (5)
Wow thanks @fselmo - this is super cool, thanks for suggesting the work-around and adding the issue. Will give it a go!
from eth-tester.
@Pet3ris yeah... none of this is ideal. I can try to check out the py-evm
customization issue soon. Hopefully until then you can work around this a bit.
from eth-tester.
Hey @Pet3ris. This is due to an upstream set of changes in py-evm
for London that made certain values unconfigurable, block_number
being one of them. There's no reason we can't make it configurable but I don't see a great work-around that doesn't involve making this change in py-evm
. That said, for now, you could get all the default values from the genesis header and unpack them into a dictionary, edit the block_number
to your choosing while keeping all the other values the same, and set a new header with the updated parameters as follows:
>>> backend = PyEVMBackend(vm_configuration=(
... (0, LondonVM),
... ))
>>> default_header_fields = vars(backend.chain.header).items()
>>> custom_header_fields = {}
>>> for key, val in default_header_fields:
... normalized_key = key[1:] # removes starting "_" from the property
... if normalized_key == 'block_number':
... custom_header_fields['block_number'] = 12345 # set block number here
... else:
... custom_header_fields[normalized_key] = val
>>> backend.chain.header = LondonBlockHeader(**custom_header_fields)
>>> backend.chain.header.block_number
12345
>>> tester = EthereumTester(backend=backend)
This is pretty hacky but I'm hoping it will at least get you unstuck for now. I will create an issue in py-evm
to allow these values to be configurable and we can un-comment it out here in eth-tester
once those changes are in.
Let me know if this workaround helps you get unstuck. Good luck!
from eth-tester.
Alright - I was able to change the block number with this snippet but it looks like it changes the block number of the second block, not the first block.
I'm now getting the error:
Blocks must be numbered consecutively. Block number #12207202 has parent #0
which comes from here:
https://github.com/ethereum/py-evm/blob/cb6f44c3e43f3f56ff4082b10cc63ab90e6acf19/eth/vm/base.py#L608
Is there a way around this other than monkey patching out the parent check?
from eth-tester.
@fselmo no worries - unfortunate the cascading effects of the block number!
I'll try and think about what would be safe to monkey patch for now.
from eth-tester.
Related Issues (20)
- Legacy properties required and set to null instead of allowed to be excluded HOT 2
- Testing without London enabled HOT 2
- MockBackend allow default account data configuration
- feat request: set_balance method
- Problems with PyEVMBackend Berlin configuration HOT 1
- feature request: Add `set_code()` API method
- Add typing HOT 2
- Build with `py-evm` feature fails on Python3.11/MacOS HOT 2
- Have error formatting comply with the JSON-RPC error format HOT 3
- ContractLogicError from custom exception contains stringified bytes instead of hex str
- Feature request: eth_feeHistory RPC endpoint HOT 1
- Support HDPath for Mnemonic
- Surprising execution behavior when calling smart contract functions HOT 2
- Implement `eth_getStorageAt` HOT 2
- ERROR: Could not build wheels for pyethash, which is required to install pyproject.toml-based projects
- ETHEREUM TESTER
- feat: Python 3.12 support HOT 1
- eth_fee_history works incorrectly
- Support eth_createAccessList RPC implementation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eth-tester.