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

Support for Ethereum Recovery Proposals #1004

Closed
wants to merge 13 commits into from

Conversation

phiferd
Copy link

@phiferd phiferd commented Feb 2, 2018

This PR contains the proposed reference implementation for supporting Ethereum Recovery Proposals (ERPs). There are a number of places where I'm unclear about the right approach, so your guidance is appreciated.

Please see the associated EIP issue for details: ethereum/EIPs#866

TL;DR the proposed ERP process provides a standard mechanism to support irregular state changes in uncontentious recovery cases where ownership is clear and supported by strong evidence. It can support ethereum/EIPs#156, as well as other issues.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 57.033% when pulling 82c335d on Musiconomi:erp-support into 12acb7b on ethereum:develop.

/**
* Created by Dan Phifer, 2018-02-01.
*/
public class ErpConfig extends FrontierConfig /* TODO: Is FrontierConfig correct? */ {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess ErpConfig should extend ByzantiumConfig. This assumption is based on further 6_000_000 block number used in the context. Check ByzantiumConfig implementation for details

public class ErpConfig extends FrontierConfig /* TODO: Is FrontierConfig correct? */ {

private final long EXTRA_DATA_AFFECTS_BLOCKS_NUMBER = 10;
public static final Logger logger = LoggerFactory.getLogger("config");
Copy link
Contributor

Choose a reason for hiding this comment

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

Use general logger instead of config

try {
initErpConfig();
} catch (IOException e) {
// TODO: not sure what to do here.
Copy link
Contributor

Choose a reason for hiding this comment

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

throwing RuntimeException should be enough here

*/
@Override
public byte[] getExtraData(byte[] minerExtraData, long blockNumber) {
// TODO: is EXTRA_DATA_AFFECTS_BLOCKS_NUMBER needed?
Copy link
Contributor

Choose a reason for hiding this comment

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

You may use this code if blockNumber belongs to one of the first 10 blocks, otherwise call to parent.getExtraData. Did I get you?

Copy link
Author

Choose a reason for hiding this comment

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

I think so. I saw in the DaoHFConfig that the extra data was applied not just at the target block, but for an a total of 10 blocks. I wasn't sure why that was done or if the same logic would be needed in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose it was done to check if miners accept the fork. Adding data in ten blocks in a row is more confident than just one

throw new RuntimeException("Failed to load state change object for " + erpMetadata.getId(), e);
}

// TODO: Is this the right way to apply changes in batch?
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it's implemented in the right way

throw e;
}
finally {
track.close();
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 have to do this, just omit

Copy link
Author

Choose a reason for hiding this comment

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

I was thinking it would actually be better to leave it. The startTracking method on the Repository interface returns another Repository; it makes no promise about the implementation. Whether the close method is a no-op or not is an implementation detail of the returned class, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, let's keep it there



//////////////////////////////////////////////
// TODO: These methods we included in DaoHFConfig, so I have included them here as well.
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't have to implement them since they are implemented by parent class

@@ -32,5 +32,6 @@ public MainNetConfig() {
add(2_463_000, new Eip150HFConfig(new DaoHFConfig()));
add(2_675_000, new Eip160HFConfig(new DaoHFConfig()));
add(4_370_000, new ByzantiumConfig(new DaoHFConfig()));
add(6_000_000, new ErpConfig());
Copy link
Contributor

Choose a reason for hiding this comment

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

Take a look at JsonNetConfig you might want to handle ErpConfig there too

public void applyStateChanges(StateChangeObject sco, Repository repo) throws ErpExecutionException {
try {
for (StateChangeAction action : sco.actions) {
applyStateChangeAction(action, repo);
Copy link
Contributor

Choose a reason for hiding this comment

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

Applying code could be a part of StateChangeAction. It would be more readable then

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I will change to a custom deserializer, which will remove the RawStateChangeObject and will allow me to have separate action classes for each action type. so the interface will be action.applyStateChange(repo)

import java.util.LinkedList;
import java.util.List;

public class ErpLoader {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it could be simplified somehow. For example, there is no need for extra-classes like RawStateChangeObject

@mkalinin
Copy link
Contributor

Since this PR is for review purposes will close it for now

@mkalinin mkalinin closed this Jun 14, 2018
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.

3 participants