Rename ibftrevised to ibft2 (#722)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Jason Frame 6 years ago committed by GitHub
parent 83c392d764
commit bdb5e8367f
  1. 2
      acceptance-tests/src/test/resources/ibft/ibft.json
  2. 8
      config/src/main/java/tech/pegasys/pantheon/config/GenesisConfigOptions.java
  3. 24
      config/src/main/java/tech/pegasys/pantheon/config/JsonGenesisConfigOptions.java
  4. 8
      config/src/test-support/java/tech/pegasys/pantheon/config/StubGenesisConfigOptions.java
  5. 14
      config/src/test/java/tech/pegasys/pantheon/config/GenesisConfigOptionsTest.java
  6. 2
      config/src/test/java/tech/pegasys/pantheon/config/IbftConfigOptionsTest.java
  7. 2
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftProtocolSchedule.java
  8. 2
      consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftProtocolSchedule.java
  9. 3
      pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftLegacyPantheonController.java
  10. 3
      pantheon/src/main/java/tech/pegasys/pantheon/controller/IbftPantheonController.java
  11. 4
      pantheon/src/main/java/tech/pegasys/pantheon/controller/PantheonController.java

@ -7,7 +7,7 @@
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 1035301,
"revisedibft": {
"ibft2": {
"blockperiodseconds": 1,
"epochlength": 30000,
"requesttimeoutseconds": 5

@ -19,17 +19,17 @@ public interface GenesisConfigOptions {
boolean isEthHash();
boolean isIbft();
boolean isIbftLegacy();
boolean isRevisedIbft();
boolean isIbft2();
boolean isClique();
IbftConfigOptions getIbftConfigOptions();
IbftConfigOptions getIbftLegacyConfigOptions();
CliqueConfigOptions getCliqueConfigOptions();
IbftConfigOptions getRevisedIbftConfigOptions();
IbftConfigOptions getIbft2ConfigOptions();
EthashConfigOptions getEthashConfigOptions();

@ -20,8 +20,8 @@ import io.vertx.core.json.JsonObject;
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;
@ -35,8 +35,8 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
}
@Override
public boolean isIbft() {
return configRoot.containsKey(IBFT_CONFIG_KEY);
public boolean isIbftLegacy() {
return configRoot.containsKey(IBFT_LEGACY_CONFIG_KEY);
}
@Override
@ -45,21 +45,21 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
}
@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;
}

@ -32,7 +32,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
}
@Override
public boolean isIbft() {
public boolean isIbftLegacy() {
return false;
}
@ -42,12 +42,12 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
}
@Override
public boolean isRevisedIbft() {
public boolean isIbft2() {
return false;
}
@Override
public IbftConfigOptions getIbftConfigOptions() {
public IbftConfigOptions getIbftLegacyConfigOptions() {
return IbftConfigOptions.DEFAULT;
}
@ -57,7 +57,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions {
}
@Override
public IbftConfigOptions getRevisedIbftConfigOptions() {
public IbftConfigOptions getIbft2ConfigOptions() {
return IbftConfigOptions.DEFAULT;
}

@ -37,17 +37,17 @@ public class GenesisConfigOptionsTest {
}
@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
@ -130,7 +130,7 @@ public class GenesisConfigOptionsTest {
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();
}

@ -84,6 +84,6 @@ public class IbftConfigOptionsTest {
return GenesisConfigFile.fromConfig(
new JsonObject(singletonMap("config", singletonMap("ibft", ibftConfigOptions))))
.getConfigOptions()
.getIbftConfigOptions();
.getIbftLegacyConfigOptions();
}
}

@ -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);

@ -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);

@ -121,7 +121,8 @@ public class IbftLegacyPantheonController implements PantheonController<IbftCont
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 =

@ -143,8 +143,7 @@ public class IbftPantheonController implements PantheonController<IbftContext> {
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();

@ -63,7 +63,7 @@ public interface PantheonController<C> extends Closeable {
nodeKeys,
metricsSystem,
privacyParameters);
} else if (configOptions.isRevisedIbft()) {
} else if (configOptions.isIbft2()) {
return IbftPantheonController.init(
storageProvider,
genesisConfigFile,
@ -72,7 +72,7 @@ public interface PantheonController<C> extends Closeable {
networkId,
nodeKeys,
metricsSystem);
} else if (configOptions.isIbft()) {
} else if (configOptions.isIbftLegacy()) {
return IbftLegacyPantheonController.init(
storageProvider,
genesisConfigFile,

Loading…
Cancel
Save