Giter Club home page Giter Club logo

Comments (5)

Pet3ris avatar Pet3ris commented on July 17, 2024 1

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.

fselmo avatar fselmo commented on July 17, 2024 1

@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.

fselmo avatar fselmo commented on July 17, 2024

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.

Pet3ris avatar Pet3ris commented on July 17, 2024

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.

Pet3ris avatar Pet3ris commented on July 17, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.