diff --git a/consensus/clique/src/main/java/tech/pegasys/pantheon/consensus/clique/CliqueBlockInterface.java b/consensus/clique/src/main/java/tech/pegasys/pantheon/consensus/clique/CliqueBlockInterface.java index ebef04d65c..db6e46607c 100644 --- a/consensus/clique/src/main/java/tech/pegasys/pantheon/consensus/clique/CliqueBlockInterface.java +++ b/consensus/clique/src/main/java/tech/pegasys/pantheon/consensus/clique/CliqueBlockInterface.java @@ -20,7 +20,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeader; import tech.pegasys.pantheon.ethereum.core.BlockHeaderBuilder; import tech.pegasys.pantheon.util.bytes.BytesValue; -import java.util.List; +import java.util.Collection; import java.util.Optional; import com.google.common.collect.ImmutableBiMap; @@ -71,7 +71,7 @@ public class CliqueBlockInterface implements BlockInterface { } @Override - public List
validatorsInBlock(final BlockHeader header) { + public Collection
validatorsInBlock(final BlockHeader header) { return CliqueExtraData.decode(header.getExtraData()).getValidators(); } diff --git a/consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/CliqueBlockInterfaceTest.java b/consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/CliqueBlockInterfaceTest.java index 46db611ba2..2aa090dc3a 100644 --- a/consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/CliqueBlockInterfaceTest.java +++ b/consensus/clique/src/test/java/tech/pegasys/pantheon/consensus/clique/CliqueBlockInterfaceTest.java @@ -27,6 +27,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeaderTestFixture; import tech.pegasys.pantheon.ethereum.core.Util; import tech.pegasys.pantheon.ethereum.mainnet.MainnetBlockHashFunction; +import java.util.Collection; import java.util.List; import java.util.Optional; @@ -123,7 +124,7 @@ public class CliqueBlockInterfaceTest { public void extractsValidatorsFromHeader() { final BlockHeader header = TestHelpers.createCliqueSignedBlockHeader(headerBuilder, proposerKeys, validatorList); - final List
extractedValidators = blockInterface.validatorsInBlock(header); + final Collection
extractedValidators = blockInterface.validatorsInBlock(header); assertThat(extractedValidators).isEqualTo(validatorList); } diff --git a/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/BlockInterface.java b/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/BlockInterface.java index d767c125b1..d2ca818dcd 100644 --- a/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/BlockInterface.java +++ b/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/BlockInterface.java @@ -15,7 +15,7 @@ package tech.pegasys.pantheon.consensus.common; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.BlockHeader; -import java.util.List; +import java.util.Collection; import java.util.Optional; public interface BlockInterface { @@ -24,5 +24,5 @@ public interface BlockInterface { Optional extractVoteFromHeader(final BlockHeader header); - List
validatorsInBlock(final BlockHeader header); + Collection
validatorsInBlock(final BlockHeader header); } diff --git a/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/VoteTally.java b/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/VoteTally.java index e250fc8a78..981a281471 100644 --- a/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/VoteTally.java +++ b/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/VoteTally.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -35,7 +34,7 @@ public class VoteTally implements ValidatorProvider { private final Map> addVotesBySubject; private final Map> removeVotesBySubject; - public VoteTally(final List
initialValidators) { + public VoteTally(final Collection
initialValidators) { this(new TreeSet<>(initialValidators), new HashMap<>(), new HashMap<>()); } diff --git a/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/VoteTallyUpdater.java b/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/VoteTallyUpdater.java index 463f04af11..7f856d8d7a 100644 --- a/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/VoteTallyUpdater.java +++ b/consensus/common/src/main/java/tech/pegasys/pantheon/consensus/common/VoteTallyUpdater.java @@ -16,7 +16,7 @@ import tech.pegasys.pantheon.ethereum.chain.Blockchain; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.BlockHeader; -import java.util.List; +import java.util.Collection; import java.util.Optional; import org.apache.logging.log4j.LogManager; @@ -49,7 +49,7 @@ public class VoteTallyUpdater { final long epochBlockNumber = epochManager.getLastEpochBlock(chainHeadBlockNumber); LOG.info("Loading validator voting state starting from block {}", epochBlockNumber); final BlockHeader epochBlock = blockchain.getBlockHeader(epochBlockNumber).get(); - final List
initialValidators = blockInterface.validatorsInBlock(epochBlock); + final Collection
initialValidators = blockInterface.validatorsInBlock(epochBlock); final VoteTally voteTally = new VoteTally(initialValidators); for (long blockNumber = epochBlockNumber + 1; blockNumber <= chainHeadBlockNumber; diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/ConsensusRoundIdentifier.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/ConsensusRoundIdentifier.java index 233b0417e5..36e520b55d 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/ConsensusRoundIdentifier.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/ConsensusRoundIdentifier.java @@ -100,7 +100,7 @@ public class ConsensusRoundIdentifier implements Comparable seals; + private final Collection seals; private final Signature proposerSeal; - private final List
validators; + private final Collection
validators; public IbftExtraData( final BytesValue vanityData, - final List seals, + final Collection seals, final Signature proposerSeal, - final List
validators) { + final Collection
validators) { checkNotNull(vanityData); checkNotNull(seals); @@ -64,9 +64,10 @@ public class IbftExtraData { final RLPInput rlpInput = new BytesValueRLPInput(rlpData, false); rlpInput.enterList(); // This accounts for the "root node" which contains IBFT data items. - final List
validators = rlpInput.readList(Address::readFrom); + final Collection
validators = rlpInput.readList(Address::readFrom); final Signature proposerSeal = parseProposerSeal(rlpInput); - final List seals = rlpInput.readList(rlp -> Signature.decode(rlp.readBytesValue())); + final Collection seals = + rlpInput.readList(rlp -> Signature.decode(rlp.readBytesValue())); rlpInput.leaveList(); return new IbftExtraData(vanityData, seals, proposerSeal, validators); @@ -97,7 +98,7 @@ public class IbftExtraData { return vanityData; } - public List getSeals() { + public Collection getSeals() { return seals; } @@ -105,7 +106,7 @@ public class IbftExtraData { return proposerSeal; } - public List
getValidators() { + public Collection
getValidators() { return validators; } } diff --git a/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftLegacyBlockInterface.java b/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftLegacyBlockInterface.java index f757c6c121..43ddc3f730 100644 --- a/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftLegacyBlockInterface.java +++ b/consensus/ibftlegacy/src/main/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftLegacyBlockInterface.java @@ -20,7 +20,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeader; import tech.pegasys.pantheon.ethereum.core.BlockHeaderBuilder; import tech.pegasys.pantheon.util.bytes.BytesValue; -import java.util.List; +import java.util.Collection; import java.util.Optional; import com.google.common.collect.ImmutableBiMap; @@ -71,7 +71,7 @@ public class IbftLegacyBlockInterface implements BlockInterface { } @Override - public List
validatorsInBlock(final BlockHeader header) { + public Collection
validatorsInBlock(final BlockHeader header) { return IbftExtraData.decode(header.getExtraData()).getValidators(); } diff --git a/consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftLegacyBlockInterfaceTest.java b/consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftLegacyBlockInterfaceTest.java index b69c30f547..194ff5ec1f 100644 --- a/consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftLegacyBlockInterfaceTest.java +++ b/consensus/ibftlegacy/src/test/java/tech/pegasys/pantheon/consensus/ibftlegacy/IbftLegacyBlockInterfaceTest.java @@ -27,6 +27,7 @@ import tech.pegasys.pantheon.ethereum.core.BlockHeaderTestFixture; import tech.pegasys.pantheon.ethereum.core.Util; import tech.pegasys.pantheon.ethereum.mainnet.MainnetBlockHashFunction; +import java.util.Collection; import java.util.List; import java.util.Optional; @@ -122,7 +123,7 @@ public class IbftLegacyBlockInterfaceTest { final BlockHeader header = TestHelpers.createIbftSignedBlockHeader(headerBuilder, proposerKeys, validatorList); - final List
extractedValidators = blockInterface.validatorsInBlock(header); + final Collection
extractedValidators = blockInterface.validatorsInBlock(header); assertThat(extractedValidators).isEqualTo(validatorList); } diff --git a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/BlockImporter.java b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/BlockImporter.java index a833ef67cc..9f291aeeb2 100644 --- a/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/BlockImporter.java +++ b/ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/BlockImporter.java @@ -27,7 +27,7 @@ import java.util.List; public interface BlockImporter { /** - * Attempts to import the given block to the specificed blockchain and world state. + * Attempts to import the given block to the specified blockchain and world state. * * @param context The context to attempt to update * @param block The block @@ -43,7 +43,7 @@ public interface BlockImporter { } /** - * Attempts to import the given block to the specificed blockchain and world state. + * Attempts to import the given block to the specified blockchain and world state. * * @param context The context to attempt to update * @param block The block diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockImporterTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockImporterTest.java index d06b86bb88..6a6a299c89 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockImporterTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/util/BlockImporterTest.java @@ -65,7 +65,8 @@ public final class BlockImporterTest { @Test public void ibftImport() throws IOException { final Path source = folder.newFile().toPath(); - final String config = Resources.toString(Resources.getResource("ibft_genesis.json"), UTF_8); + final String config = + Resources.toString(Resources.getResource("ibftlegacy_genesis.json"), UTF_8); try { Files.write( diff --git a/pantheon/src/test/resources/ibft_genesis.json b/pantheon/src/test/resources/ibftlegacy_genesis.json similarity index 100% rename from pantheon/src/test/resources/ibft_genesis.json rename to pantheon/src/test/resources/ibftlegacy_genesis.json