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

Rename ibftrevised to ibft2 #722

Merged
merged 10 commits into from
Feb 1, 2019
2 changes: 1 addition & 1 deletion acceptance-tests/src/test/resources/ibft/ibft.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 1035301,
"revisedibft": {
"ibft2": {
"blockperiodseconds": 1,
"epochlength": 30000,
"requesttimeoutseconds": 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ public interface GenesisConfigOptions {

boolean isEthHash();

boolean isIbft();
boolean isIbftLegacy();

boolean isRevisedIbft();
boolean isIbft2();
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 love that this is only 1 character different from isIbft

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what to do about that. The name is ibft 2. Thought perhaps could make the old version ibftLegacy in the method names?

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. renamed old ibft methods to ibftLegacy to distinguish from ibft2


boolean isClique();

IbftConfigOptions getIbftConfigOptions();
IbftConfigOptions getIbftLegacyConfigOptions();

CliqueConfigOptions getCliqueConfigOptions();

IbftConfigOptions getRevisedIbftConfigOptions();
IbftConfigOptions getIbft2ConfigOptions();
Copy link
Contributor

Choose a reason for hiding this comment

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

as above.

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. as above


EthashConfigOptions getEthashConfigOptions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
public class JsonGenesisConfigOptions implements GenesisConfigOptions {

private static final String ETHASH_CONFIG_KEY = "ethash";
private static final String IBFT_CONFIG_KEY = "ibft";
private static final String REVISED_IBFT_CONFIG_KEY = "revisedibft";
private static final String IBFT_LEGACY_CONFIG_KEY = "ibft";
private static final String IBFT2_CONFIG_KEY = "ibft2";
private static final String CLIQUE_CONFIG_KEY = "clique";
private final JsonObject configRoot;

Expand All @@ -35,8 +35,8 @@ public boolean isEthHash() {
}

@Override
public boolean isIbft() {
return configRoot.containsKey(IBFT_CONFIG_KEY);
public boolean isIbftLegacy() {
return configRoot.containsKey(IBFT_LEGACY_CONFIG_KEY);
}

@Override
Expand All @@ -45,21 +45,21 @@ public boolean isClique() {
}

@Override
public boolean isRevisedIbft() {
return configRoot.containsKey(REVISED_IBFT_CONFIG_KEY);
public boolean isIbft2() {
return configRoot.containsKey(IBFT2_CONFIG_KEY);
}

@Override
public IbftConfigOptions getIbftConfigOptions() {
return isIbft()
? new IbftConfigOptions(configRoot.getJsonObject(IBFT_CONFIG_KEY))
public IbftConfigOptions getIbftLegacyConfigOptions() {
return isIbftLegacy()
? new IbftConfigOptions(configRoot.getJsonObject(IBFT_LEGACY_CONFIG_KEY))
: IbftConfigOptions.DEFAULT;
}

@Override
public IbftConfigOptions getRevisedIbftConfigOptions() {
return isRevisedIbft()
? new IbftConfigOptions(configRoot.getJsonObject(REVISED_IBFT_CONFIG_KEY))
public IbftConfigOptions getIbft2ConfigOptions() {
return isIbft2()
? new IbftConfigOptions(configRoot.getJsonObject(IBFT2_CONFIG_KEY))
: IbftConfigOptions.DEFAULT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean isEthHash() {
}

@Override
public boolean isIbft() {
public boolean isIbftLegacy() {
return false;
}

Expand All @@ -42,12 +42,12 @@ public boolean isClique() {
}

@Override
public boolean isRevisedIbft() {
public boolean isIbft2() {
return false;
}

@Override
public IbftConfigOptions getIbftConfigOptions() {
public IbftConfigOptions getIbftLegacyConfigOptions() {
return IbftConfigOptions.DEFAULT;
}

Expand All @@ -57,7 +57,7 @@ public CliqueConfigOptions getCliqueConfigOptions() {
}

@Override
public IbftConfigOptions getRevisedIbftConfigOptions() {
public IbftConfigOptions getIbft2ConfigOptions() {
return IbftConfigOptions.DEFAULT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ public void shouldNotUseEthHashIfEthHashNotPresent() {
}

@Test
public void shouldUseIbftWhenIbftInConfig() {
public void shouldUseIbftLegacyWhenIbftInConfig() {
final GenesisConfigOptions config = fromConfigOptions(singletonMap("ibft", emptyMap()));
assertThat(config.isIbft()).isTrue();
assertThat(config.getIbftConfigOptions()).isNotSameAs(IbftConfigOptions.DEFAULT);
assertThat(config.isIbftLegacy()).isTrue();
assertThat(config.getIbftLegacyConfigOptions()).isNotSameAs(IbftConfigOptions.DEFAULT);
}

@Test
public void shouldNotUseIbftIfIbftNotPresent() {
public void shouldNotUseIbftLegacyIfIbftNotPresent() {
final GenesisConfigOptions config = fromConfigOptions(emptyMap());
assertThat(config.isIbft()).isFalse();
assertThat(config.getIbftConfigOptions()).isSameAs(IbftConfigOptions.DEFAULT);
assertThat(config.isIbftLegacy()).isFalse();
assertThat(config.getIbftLegacyConfigOptions()).isSameAs(IbftConfigOptions.DEFAULT);
}

@Test
Expand Down Expand Up @@ -130,7 +130,7 @@ public void shouldGetChainIdWhenSpecified() {
public void shouldSupportEmptyGenesisConfig() {
final GenesisConfigOptions config = GenesisConfigFile.fromConfig("{}").getConfigOptions();
assertThat(config.isEthHash()).isFalse();
assertThat(config.isIbft()).isFalse();
assertThat(config.isIbftLegacy()).isFalse();
assertThat(config.isClique()).isFalse();
assertThat(config.getHomesteadBlockNumber()).isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ private IbftConfigOptions fromConfigOptions(final Map<String, Object> ibftConfig
return GenesisConfigFile.fromConfig(
new JsonObject(singletonMap("config", singletonMap("ibft", ibftConfigOptions))))
.getConfigOptions()
.getIbftConfigOptions();
.getIbftLegacyConfigOptions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class IbftProtocolSchedule {
private static final int DEFAULT_CHAIN_ID = 1;

public static ProtocolSchedule<IbftContext> create(final GenesisConfigOptions config) {
final IbftConfigOptions ibftConfig = config.getIbftConfigOptions();
final IbftConfigOptions ibftConfig = config.getIbftLegacyConfigOptions();
final long epochLength = ibftConfig.getEpochLength();
final long blockPeriod = ibftConfig.getBlockPeriodSeconds();
final EpochManager epochManager = new EpochManager(epochLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class IbftProtocolSchedule {
private static final int DEFAULT_CHAIN_ID = 1;

public static ProtocolSchedule<IbftContext> create(final GenesisConfigOptions config) {
final IbftConfigOptions ibftConfig = config.getIbftConfigOptions();
final IbftConfigOptions ibftConfig = config.getIbftLegacyConfigOptions();
final long epochLength = ibftConfig.getEpochLength();
final long blockPeriod = ibftConfig.getBlockPeriodSeconds();
final EpochManager epochManager = new EpochManager(epochLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public static PantheonController<IbftContext> init(
final WorldStateArchive worldStateArchive = new WorldStateArchive(worldStateStorage);
genesisState.writeStateTo(worldStateArchive.getMutable(Hash.EMPTY_TRIE_HASH));

final IbftConfigOptions ibftConfig = genesisConfig.getConfigOptions().getIbftConfigOptions();
final IbftConfigOptions ibftConfig =
genesisConfig.getConfigOptions().getIbftLegacyConfigOptions();
final EpochManager epochManager = new EpochManager(ibftConfig.getEpochLength());

final VoteTally voteTally =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ public static PantheonController<IbftContext> init(
final WorldStateArchive worldStateArchive = new WorldStateArchive(worldStateStorage);
genesisState.writeStateTo(worldStateArchive.getMutable(Hash.EMPTY_TRIE_HASH));

final IbftConfigOptions ibftConfig =
genesisConfig.getConfigOptions().getRevisedIbftConfigOptions();
final IbftConfigOptions ibftConfig = genesisConfig.getConfigOptions().getIbft2ConfigOptions();
final EpochManager epochManager = new EpochManager(ibftConfig.getEpochLength());

final BlockInterface blockInterface = new IbftBlockInterface();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static PantheonController<?> fromConfig(
nodeKeys,
metricsSystem,
privacyParameters);
} else if (configOptions.isRevisedIbft()) {
} else if (configOptions.isIbft2()) {
return IbftPantheonController.init(
storageProvider,
genesisConfigFile,
Expand All @@ -72,7 +72,7 @@ static PantheonController<?> fromConfig(
networkId,
nodeKeys,
metricsSystem);
} else if (configOptions.isIbft()) {
} else if (configOptions.isIbftLegacy()) {
return IbftLegacyPantheonController.init(
storageProvider,
genesisConfigFile,
Expand Down