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

NC-2147 Implement Petersburg hardfork #601

Merged
merged 9 commits into from
Jan 24, 2019
Merged

Conversation

shemnon
Copy link
Contributor

@shemnon shemnon commented Jan 18, 2019

PR description

  • create a new fork definition
  • make it Constantinople without EIP-1283
  • update tests where appropriate

Fixed Issue(s)

NC-2147

* create a new fork definition
* make it constantinople without EIP-1283
* update tests where appropriate
@shemnon shemnon added the work in progress Work on this pull request is ongoing label Jan 18, 2019
ajsutton
ajsutton previously approved these changes Jan 18, 2019
Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

While we'll likely change the milestone name from Petersburg to something agreed upon with geth, I think it may be worth merging this - it's technically good and will guarantee that our next release has the newly scheduled block number. What name is used for it has no impact on how it behaves.

@@ -42,6 +42,7 @@
@Setup
public void prepare() throws Exception {
operationBenchmarkHelper = OperationBenchmarkHelper.create();
// ?? do we create another benchmark ??
Copy link
Contributor

Choose a reason for hiding this comment

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

No, I think the Constantinople benchmark is all we need here as the operation of block hash is unaffected (technically we could use a much earlier milestone) and the gas calculator isn't what we're trying to benchmark anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that I added a PetersburgGasCalculator I moved it over to that one, just to keep current.

public void petersburg() {
milestone("Petersburg");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Since the transaction tests haven't been updated for "Petersburg" we shouldn't add this. I doubt there will be additional transaction tests added since they're just about parsing transactions, not about executing them and that's unaffected.

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

@@ -193,6 +193,12 @@ private MainnetProtocolSpecs() {}
.name("Constantinople");
}

public static ProtocolSpecBuilder<Void> petersburgDefinition(final int chainId) {
return constantinopleDefinition(chainId)
.gasCalculator(TangerineWhistleGasCalculator::new)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need a new GasCalculator ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good spot - we will because Constantinople gas calculator also provides the gas cost for EXTCODEHASH and CREATE2 which aren't available in tangerine whistle. It should omit the calculateStorageCost and calculateStorageRefundAmount overrides that are in ConstantinopleGasCalculator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New gas calculator added. I extended Constantinople and copied the code from Frontier since that was the last time that particular method was updated.

@ajsutton ajsutton dismissed their stale review January 18, 2019 21:38

Missed the gas calculator detail, so just to avoid any risk of it slipping through retracting approval.

* Add PetersbergGasCalculator
@ajsutton
Copy link
Contributor

We'll want to stay compatible with Geth's genesis config. The PR for Geth is ethereum/go-ethereum#18486 and I think it's using 'constantinopleFixBlock" as the genesis config option but it's not entirely clear - "PetersburgBlock" is used a lot through the code as well.

The other detail is that if "constantinopleFixBlock" is omitted, it defaults to the same block as "constantinopleBlock". This makes a lot of sense for MainNet but feels slightly weird and unexpected. But if we don't do the same it could be a major source of confusion in the future because it's a subtle but very important difference in genesis config meaning.

shemnon and others added 4 commits January 22, 2019 16:41
* Add rinkeby Constantinople block
* Petersburg -> ConstantinopleFix
* add Ropsten constantinopleFix block
* run reference tests
* remove ConstantinopleFix from TransactionTestCases (there are no tests)
@shemnon shemnon removed the work in progress Work on this pull request is ongoing label Jan 23, 2019
@shemnon
Copy link
Contributor Author

shemnon commented Jan 23, 2019

Ready for another review.

  • Petersburg became ConstantinopleFix
  • Fork ordering verified (had to fix Clique Tests)
  • Ref Tests pass at the same rate as before

Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

LGTM.

shemnon and others added 3 commits January 23, 2019 20:30
# Conflicts:
#	ethereum/core/src/test-support/java/tech/pegasys/pantheon/ethereum/core/ExecutionContextTestFixture.java
@shemnon shemnon merged commit 08d0848 into PegaSysEng:master Jan 24, 2019
@shemnon shemnon deleted the petersburg branch January 24, 2019 06:16
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