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

[PAN-2829] Add opcode and precompiled support for versioning #1683

Merged
merged 13 commits into from
Jul 13, 2019

Conversation

shemnon
Copy link
Contributor

@shemnon shemnon commented Jul 12, 2019

PR description

Different opcode sets and precompiled contract sets for different account versions

Add the current contract's version to the message frame.
Different opcode sets for different account versions
Different precompile sets for different account versions
Copy link
Contributor

@mbaxter mbaxter left a comment

Choose a reason for hiding this comment

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

seems good to me :D

return registry;
}

public static PrecompileContractRegistry appendPrivacy(
final PrecompileContractRegistry registry,
public static PrecompileContractRegistry istanbul(
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is unused - should you add it to ProtocolSpecBuilder or cut it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed adding it to the spec builder.


public OperationRegistry(final int numVersions) {
Preconditions.checkArgument(numVersions >= 1);
this.operations = new Operation[numVersions][NUM_OPERATIONS];
Copy link
Contributor

Choose a reason for hiding this comment

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

(Optional) You might look into guava's RangeMap, which could map a range of versions to a single operation, rather than creating distinct references for every op-version combo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is a "hotspot" I opted for native arrays, on the presumption native arrays are faster than interfaces. When we get better performance monitoring in we can see how much the impact is.

@@ -39,6 +39,7 @@
long DEFAULT_NONCE = 0L;
Wei DEFAULT_BALANCE = Wei.ZERO;
int DEFAULT_VERSION = 0;
int ISTANBUL_VERSION = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

(Optional) Not sure about storing ISTANBUL_VERSION here - it feels very mainnet-evm-specific. Looks like you could get away with just keeping this as a local variable in MainnetProtocolSpecs.

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

…switch

# Conflicts:
#	ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/mainnet/MainnetProtocolSpecs.java
#	ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/vm/MessageFrame.java
@shemnon shemnon merged commit 1328ef6 into PegaSysEng:master Jul 13, 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.

2 participants