Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Conversation

@konradkonrad
Copy link
Contributor

A common pitfall for developers is using vanilla tester.state with contracts
that use more recent opcodes (ending up with invalid opcode errors).

The factory function latest_state, prepares the state for any developer with
the latest fork block number (as set in ethereum.config.LATEST_FORK_BLKNUMBER).

This way, legacy applications won't change their behavior, but newer users/
developers can be encouraged to just use latest_state().

@LefterisJP
Copy link
Contributor

Simple and nice. Looks good to me. Let's see if the tests pass.

@chfast
Copy link
Member

chfast commented Nov 1, 2016

@mfranciszkiewicz, can you review this?

A common pitfall for developers is using vanilla `tester.state` with contracts
that use more recent opcodes (ending up with `invalid opcode` errors).

The factory function `latest_state`, prepares the state for any developer with
the latest fork block number (as set in ethereum.config.LATEST_FORK_BLKNUMBER).

This way, legacy applications won't change their behavior, but newer users/
developers can be encouraged to just use `latest_state()`.

Since inception of this PR, this got rebased on latest develop to now point to
the ANTI_DOS_FORK.
"""
blockchain_state = state(**kwargs)

if blknum is not None:

Choose a reason for hiding this comment

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

I believe you meant if blknum is None here, otherwise blockchain_state.block.number is either LATEST_APPLIED_FORK_BLKNUM + 1 or None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:doh:
Thanks for spotting this! That was a pretty terrible LOC/error ratio 😮
Fixed and added tests!

This fixes an error with the `blknum` parameter and changes
the logic to set the state to the actual `LATEST_APPLIED_FORK_BLKNUM` (instead
of `+ 1`), since rules are applied starting from the block.

Also added tests to ensure the intended behavior.
mfranciszkiewicz added a commit to golemfactory/golem-crowdfunding that referenced this pull request Nov 2, 2016
EIP150 starting block (to be refactored after ethereum/pyethereum#411 is merged)
Tester gas limit set to 2 mil
@konradkonrad
Copy link
Contributor Author

I don't think this will ever be merged...closing it!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants