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

Add EIP-1344 Chain ID #1803

Merged
merged 2 commits into from
Aug 23, 2019
Merged

Add EIP-1344 Chain ID #1803

merged 2 commits into from
Aug 23, 2019

Conversation

fubuloubu
Copy link
Contributor

@fubuloubu fubuloubu commented Jul 27, 2019

What was wrong?

Fixes #1817

How was it fixed?

Added a new ChainContext class, which allows the chain configuration (and other external parameters) to inform the VM class of that outside data. Routed the Chain ID configuration parameter through this new class.

Cute Animal Picture

cute penguin

@fubuloubu fubuloubu force-pushed the eip1344-chain-id branch 2 times, most recently from c61ad37 to acaf9a0 Compare July 31, 2019 18:58
@fubuloubu
Copy link
Contributor Author

@pipermerriam got it working, just missing test cases, and the updated test suite which includes EIP-1344 tests (which is WIP IIRC) How do you feel about this approach?

@fubuloubu fubuloubu force-pushed the eip1344-chain-id branch 2 times, most recently from 5e4442f to accf6ad Compare July 31, 2019 22:22
Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

Brian, I just landed #1805 which is going to cause you a merge conflict. Let me know if you need help sorting it out.

One thing you'll need to do is create a ChainContextAPI class in the eth.abc module and use that in all the places you have type hints. Note that the BaseVM no longer exists and you'll want migrate your changes over to eth.abc.VirtualMachineAPI

@fubuloubu
Copy link
Contributor Author

fubuloubu commented Aug 1, 2019

Refactored and it works just fine. Not sure if a failure was expected, but MyPy made it really easy work.

@carver
Copy link
Contributor

carver commented Aug 21, 2019

from gitter:

I got started a little bit with Chain ID, I think it's just waiting on state tests

Rather than wait on state tests to merge, can you add some local tests, like #1829 does?

Then we can get it merged up, and add in the state tests as they come in. Don't forget to add a release note to mention that the EIP is added to Istanbul (there's also an example of that in #1829).

@fubuloubu
Copy link
Contributor Author

@carver I added a simple test and release notes for the feature. Any further suggestions to get this merged? Also, any suggestions on what to clean up with the commit history, if necessary?

@fubuloubu fubuloubu changed the title WIP: Add EIP-1344 Chain ID Add EIP-1344 Chain ID Aug 22, 2019

if chain_id is None:
chain_id = 0 # Default value (invalid for public networks)
validate_uint256(chain_id)
Copy link
Contributor Author

@fubuloubu fubuloubu Aug 22, 2019

Choose a reason for hiding this comment

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

Note: Should be uint64, which is the suggested maximum due to the mathematical configuration of EIP-155 (a hack made UINT256_MAX/2 - 36 the maximum number that could be used for the chain ID field)

fubuloubu and others added 2 commits August 23, 2019 12:36
refactor: Add ChainContext to hold/retreive chain_id

bug: Forgot to add ChainContext to Chain.get_vm()

bug: Modified test cases that initialize VM class

bug: Forget to add chain ID to class vars

refactor: Made ChainContext and immutable object

- also added docstrings and some additional validation

bug: Handle optional chain id config

refactor: Removed unused Base objects

refactor: Using ChainContextAPI ABC now

test: Added test for Chain ID

doc: Added release note
@carver
Copy link
Contributor

carver commented Aug 23, 2019

In the interest of time, I just added a few little tweaks (and handled the rebase). If anything looks off to you, let me know, and we can do a follow-up.

@carver carver merged commit b87fbe0 into ethereum:master Aug 23, 2019
@fubuloubu
Copy link
Contributor Author

The tweaks look good!

@fubuloubu fubuloubu deleted the eip1344-chain-id branch August 23, 2019 20:13
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.

EIP-1344 ChainID opcode
3 participants