Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-2903] Implement EIP-1344 ChainID Opcode #1690

Merged
merged 5 commits into from
Jul 15, 2019

Conversation

shemnon
Copy link
Contributor

@shemnon shemnon commented Jul 14, 2019

PR description

Add the ChainID Opcode

@shemnon
Copy link
Contributor Author

shemnon commented Jul 15, 2019

Force push was a revert, EIP1108 was accidentally pushed on this branch.

@@ -285,12 +286,13 @@ private MainnetProtocolSpecs() {}
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason) {
checkArgument(chainId.isPresent(), "Istanbul requires the use of chainId");
Copy link
Contributor

Choose a reason for hiding this comment

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

If you trace back to where the chainId is set, it looks like it's only ever missing in test cases. Might be worth going through and making the chainId argument a plain unwrapped BigInteger, in which case we wouldn't need this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FixedDifficultyProtocolSchedule uses it too. It's at least a 4 file change, larger than this PR, so that level of change would deserve its own PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's no requirement that a chain has a chainId - it may be omitted from the genesis config. This is a slightly interesting hole in the ChainID opcode spec. Doesn't apply to any public chain but there may be chains out there it does affect. So maybe ChainID opcode should return 0 when there is no chain ID?

}

@Test
public void shouldReturnChanId() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public void shouldReturnChanId() {
public void shouldReturnChainId() {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

public void shouldReturnChanId() {
final ArgumentCaptor<Bytes32> arg = ArgumentCaptor.forClass(Bytes32.class);
operation.execute(messageFrame);
Mockito.verify(messageFrame).pushStackItem(arg.capture());
Copy link
Contributor

Choose a reason for hiding this comment

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

You should probably also verify that pushStackItem is only called once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@shemnon shemnon merged commit 5d8808f into PegaSysEng:master Jul 15, 2019
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.

3 participants