diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java index 0002f7d762..8fd7611ba5 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/RoundSpecificPeers.java @@ -29,7 +29,7 @@ import tech.pegasys.pantheon.consensus.ibft.payload.Payload; import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.crypto.SECP256K1.Signature; import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; @@ -109,14 +109,13 @@ public class RoundSpecificPeers { } public List> createSignedRoundChangePayload( - final ConsensusRoundIdentifier roundId, - final TerminatedRoundArtefacts terminatedRoundArtefacts) { + final ConsensusRoundIdentifier roundId, final PreparedRoundArtefacts preparedRoundArtefacts) { return peers .stream() .map( p -> p.getMessageFactory() - .createRoundChange(roundId, Optional.of(terminatedRoundArtefacts)) + .createRoundChange(roundId, Optional.of(preparedRoundArtefacts)) .getSignedPayload()) .collect(Collectors.toList()); } diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestHelpers.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestHelpers.java index c25518108d..da6033c77a 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestHelpers.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/TestHelpers.java @@ -23,7 +23,7 @@ import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangeCertificate; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.crypto.SECP256K1; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.Signature; @@ -49,11 +49,11 @@ public class TestHelpers { return messageFactory.createCommit(roundId, block.getHash(), commitSeal).getSignedPayload(); } - public static TerminatedRoundArtefacts createValidTerminatedRoundArtefacts( + public static PreparedRoundArtefacts createValidPreparedRoundArtefacts( final TestContext context, final ConsensusRoundIdentifier preparedRound, final Block block) { final RoundSpecificPeers peers = context.roundSpecificPeers(preparedRound); - return new TerminatedRoundArtefacts( + return new PreparedRoundArtefacts( peers.getProposer().getMessageFactory().createProposal(preparedRound, block), peers .createSignedPreparePayloadOfNonProposing(preparedRound, block.getHash()) diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/ValidatorPeer.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/ValidatorPeer.java index cefa900179..96d7c2b61d 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/ValidatorPeer.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/support/ValidatorPeer.java @@ -29,7 +29,7 @@ import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangeCertificate; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.crypto.SECP256K1; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.Signature; @@ -121,8 +121,8 @@ public class ValidatorPeer { public RoundChange injectRoundChange( final ConsensusRoundIdentifier rId, - final Optional terminatedRoundArtefacts) { - final RoundChange payload = messageFactory.createRoundChange(rId, terminatedRoundArtefacts); + final Optional preparedRoundArtefacts) { + final RoundChange payload = messageFactory.createRoundChange(rId, preparedRoundArtefacts); injectMessage(RoundChangeMessageData.create(payload)); return payload; } diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/ReceivedNewRoundTest.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/ReceivedNewRoundTest.java index 10473aae16..fb64c23b6c 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/ReceivedNewRoundTest.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/ReceivedNewRoundTest.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.consensus.ibft.tests; -import static tech.pegasys.pantheon.consensus.ibft.support.TestHelpers.createValidTerminatedRoundArtefacts; +import static tech.pegasys.pantheon.consensus.ibft.support.TestHelpers.createValidPreparedRoundArtefacts; import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; @@ -22,7 +22,7 @@ import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangeCertificate; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.consensus.ibft.support.RoundSpecificPeers; import tech.pegasys.pantheon.consensus.ibft.support.TestContext; import tech.pegasys.pantheon.consensus.ibft.support.TestContextBuilder; @@ -111,11 +111,11 @@ public class ReceivedNewRoundTest { final Block reproposedBlock = context.createBlockForProposalFromChainHead(1, 15); final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1); - final TerminatedRoundArtefacts terminatedRoundArtefacts = - createValidTerminatedRoundArtefacts(context, roundId, initialBlock); + final PreparedRoundArtefacts preparedRoundArtefacts = + createValidPreparedRoundArtefacts(context, roundId, initialBlock); final List> roundChanges = - peers.createSignedRoundChangePayload(nextRoundId, terminatedRoundArtefacts); + peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtefacts); final ValidatorPeer nextProposer = context.roundSpecificPeers(nextRoundId).getProposer(); @@ -163,11 +163,11 @@ public class ReceivedNewRoundTest { final Block reproposedBlock = context.createBlockForProposalFromChainHead(1, 15); final ConsensusRoundIdentifier nextRoundId = new ConsensusRoundIdentifier(1, 1); - final TerminatedRoundArtefacts terminatedRoundArtefacts = - createValidTerminatedRoundArtefacts(context, roundId, initialBlock); + final PreparedRoundArtefacts preparedRoundArtefacts = + createValidPreparedRoundArtefacts(context, roundId, initialBlock); final List> roundChanges = - peers.createSignedRoundChangePayload(nextRoundId, terminatedRoundArtefacts); + peers.createSignedRoundChangePayload(nextRoundId, preparedRoundArtefacts); final RoundSpecificPeers nextRoles = context.roundSpecificPeers(nextRoundId); final ValidatorPeer nextProposer = nextRoles.getProposer(); diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/RoundChangeTest.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/RoundChangeTest.java index 148e8eb20d..85152a4073 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/RoundChangeTest.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/RoundChangeTest.java @@ -14,7 +14,7 @@ package tech.pegasys.pantheon.consensus.ibft.tests; import static java.util.Collections.emptyList; import static java.util.Optional.empty; -import static tech.pegasys.pantheon.consensus.ibft.support.TestHelpers.createValidTerminatedRoundArtefacts; +import static tech.pegasys.pantheon.consensus.ibft.support.TestHelpers.createValidPreparedRoundArtefacts; import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; import tech.pegasys.pantheon.consensus.ibft.IbftHelpers; @@ -27,7 +27,7 @@ import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangeCertificate; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.consensus.ibft.support.RoundSpecificPeers; import tech.pegasys.pantheon.consensus.ibft.support.TestContext; import tech.pegasys.pantheon.consensus.ibft.support.TestContextBuilder; @@ -130,7 +130,7 @@ public class RoundChangeTest { localNodeMessageFactory.createRoundChange( targetRound, Optional.of( - new TerminatedRoundArtefacts( + new PreparedRoundArtefacts( proposal, Lists.newArrayList(localPrepareMessage, p1, p2)))); context.getController().handleRoundExpiry(new RoundExpiry(roundId)); @@ -169,14 +169,14 @@ public class RoundChangeTest { public void newRoundMessageContainsBlockOnWhichPeerPrepared() { final long ARBITRARY_BLOCKTIME = 1500; - final TerminatedRoundArtefacts earlierPrepCert = - createValidTerminatedRoundArtefacts( + final PreparedRoundArtefacts earlierPrepCert = + createValidPreparedRoundArtefacts( context, new ConsensusRoundIdentifier(1, 1), context.createBlockForProposalFromChainHead(1, ARBITRARY_BLOCKTIME / 2)); - final TerminatedRoundArtefacts bestPrepCert = - createValidTerminatedRoundArtefacts( + final PreparedRoundArtefacts bestPrepCert = + createValidPreparedRoundArtefacts( context, new ConsensusRoundIdentifier(1, 2), context.createBlockForProposalFromChainHead(2, ARBITRARY_BLOCKTIME)); @@ -263,8 +263,8 @@ public class RoundChangeTest { final ConsensusRoundIdentifier targetRound = new ConsensusRoundIdentifier(1, 4); - final TerminatedRoundArtefacts prepCert = - createValidTerminatedRoundArtefacts( + final PreparedRoundArtefacts prepCert = + createValidPreparedRoundArtefacts( context, new ConsensusRoundIdentifier(1, 2), context.createBlockForProposalFromChainHead(2, ARBITRARY_BLOCKTIME)); @@ -329,14 +329,14 @@ public class RoundChangeTest { final RoundChange rc3 = peers.getNonProposing(2).injectRoundChange(targetRound, empty()); // create illegal RoundChangeMessage - final TerminatedRoundArtefacts illegalTerminatedRoundArtefacts = - new TerminatedRoundArtefacts( + final PreparedRoundArtefacts illegalPreparedRoundArtefacts = + new PreparedRoundArtefacts( peers.getNonProposing(0).getMessageFactory().createProposal(roundId, blockToPropose), emptyList()); peers .getNonProposing(2) - .injectRoundChange(targetRound, Optional.of(illegalTerminatedRoundArtefacts)); + .injectRoundChange(targetRound, Optional.of(illegalPreparedRoundArtefacts)); // Ensure no NewRound message is sent. peers.verifyNoMessagesReceived(); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/IbftMessageTransmitter.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/IbftMessageTransmitter.java index 60795f87b4..9bc6d4e6ce 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/IbftMessageTransmitter.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/network/IbftMessageTransmitter.java @@ -27,7 +27,7 @@ import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangeCertificate; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.crypto.SECP256K1.Signature; import tech.pegasys.pantheon.ethereum.core.Block; import tech.pegasys.pantheon.ethereum.core.Hash; @@ -74,10 +74,10 @@ public class IbftMessageTransmitter { public void multicastRoundChange( final ConsensusRoundIdentifier roundIdentifier, - final Optional terminatedRoundArtefacts) { + final Optional preparedRoundArtefacts) { final RoundChange data = - messageFactory.createRoundChange(roundIdentifier, terminatedRoundArtefacts); + messageFactory.createRoundChange(roundIdentifier, preparedRoundArtefacts); final RoundChangeMessageData message = RoundChangeMessageData.create(data); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/MessageFactory.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/MessageFactory.java index f9c479c7ea..d8fed15ff8 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/MessageFactory.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/MessageFactory.java @@ -18,7 +18,7 @@ import tech.pegasys.pantheon.consensus.ibft.messagewrappers.NewRound; import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Prepare; import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Proposal; import tech.pegasys.pantheon.consensus.ibft.messagewrappers.RoundChange; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.crypto.SECP256K1; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.Signature; @@ -64,12 +64,12 @@ public class MessageFactory { public RoundChange createRoundChange( final ConsensusRoundIdentifier roundIdentifier, - final Optional terminatedRoundArtefacts) { + final Optional preparedRoundArtefacts) { final RoundChangePayload payload = new RoundChangePayload( roundIdentifier, - terminatedRoundArtefacts.map(TerminatedRoundArtefacts::getPreparedCertificate)); + preparedRoundArtefacts.map(PreparedRoundArtefacts::getPreparedCertificate)); return new RoundChange(createSignedMessage(payload)); } diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManager.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManager.java index ef60892224..1f85e9d0b9 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManager.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManager.java @@ -69,7 +69,7 @@ public class IbftBlockHeightManager implements BlockHeightManager { private final Function roundStateCreator; private final IbftFinalState finalState; - private Optional latesteTerminatedRoundArtefacts = Optional.empty(); + private Optional latestPreparedRoundArtefacts = Optional.empty(); private IbftRound currentRound; @@ -133,20 +133,20 @@ public class IbftBlockHeightManager implements BlockHeightManager { LOG.info( "Round has expired, creating PreparedCertificate and notifying peers. round={}", currentRound.getRoundIdentifier()); - final Optional terminatedRoundArtefats = - currentRound.constructTerminatedRoundArtefacts(); + final Optional preparedRoundArtefacts = + currentRound.constructPreparedRoundArtefacts(); - if (terminatedRoundArtefats.isPresent()) { - latesteTerminatedRoundArtefacts = terminatedRoundArtefats; + if (preparedRoundArtefacts.isPresent()) { + latestPreparedRoundArtefacts = preparedRoundArtefacts; } startNewRound(currentRound.getRoundIdentifier().getRoundNumber() + 1); final RoundChange localRoundChange = messageFactory.createRoundChange( - currentRound.getRoundIdentifier(), latesteTerminatedRoundArtefacts); + currentRound.getRoundIdentifier(), latestPreparedRoundArtefacts); transmitter.multicastRoundChange( - currentRound.getRoundIdentifier(), latesteTerminatedRoundArtefacts); + currentRound.getRoundIdentifier(), latestPreparedRoundArtefacts); // Its possible the locally created RoundChange triggers the transmission of a NewRound // message - so it must be handled accordingly. diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRound.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRound.java index db17b99f08..5e0208be86 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRound.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRound.java @@ -165,8 +165,8 @@ public class IbftRound { peerIsCommitted(msg); } - public Optional constructTerminatedRoundArtefacts() { - return roundState.constructTerminatedRoundArtefacts(); + public Optional constructPreparedRoundArtefacts() { + return roundState.constructPreparedRoundArtefacts(); } private boolean updateStateWithProposedBlock(final Proposal msg) { diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/TerminatedRoundArtefacts.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/PreparedRoundArtefacts.java similarity index 91% rename from consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/TerminatedRoundArtefacts.java rename to consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/PreparedRoundArtefacts.java index d1e1e9d06f..8ddd1fc692 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/TerminatedRoundArtefacts.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/PreparedRoundArtefacts.java @@ -20,12 +20,12 @@ import tech.pegasys.pantheon.ethereum.core.Block; import java.util.Collection; import java.util.stream.Collectors; -public class TerminatedRoundArtefacts { +public class PreparedRoundArtefacts { private Proposal proposal; private Collection prepares; - public TerminatedRoundArtefacts(final Proposal proposal, final Collection prepares) { + public PreparedRoundArtefacts(final Proposal proposal, final Collection prepares) { this.proposal = proposal; this.prepares = prepares; } diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundState.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundState.java index 076093467a..7f9bbe25e6 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundState.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundState.java @@ -127,9 +127,9 @@ public class RoundState { .collect(Collectors.toList()); } - public Optional constructTerminatedRoundArtefacts() { + public Optional constructPreparedRoundArtefacts() { if (isPrepared()) { - return Optional.of(new TerminatedRoundArtefacts(proposalMessage.get(), prepareMessages)); + return Optional.of(new PreparedRoundArtefacts(proposalMessage.get(), prepareMessages)); } return Optional.empty(); } diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftHelpersTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftHelpersTest.java index 94564b259f..7ac8232e4f 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftHelpersTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftHelpersTest.java @@ -20,7 +20,7 @@ import static tech.pegasys.pantheon.consensus.ibft.IbftHelpers.calculateRequired import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Proposal; import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.PreparedCertificate; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.ethereum.core.Block; import tech.pegasys.pantheon.ethereum.core.Hash; @@ -93,9 +93,9 @@ public class IbftHelpersTest { final Proposal differentProposal = proposerMessageFactory.createProposal(preparedRound, proposedBlock); - final Optional latterTerminatedRoundArtefacts = + final Optional latterPreparedRoundArtefacts = Optional.of( - new TerminatedRoundArtefacts( + new PreparedRoundArtefacts( differentProposal, Lists.newArrayList( proposerMessageFactory.createPrepare(roundIdentifier, proposedBlock.getHash()), @@ -108,9 +108,9 @@ public class IbftHelpersTest { TestHelpers.createFrom(roundIdentifier, 0, -2); final Proposal earlierProposal = proposerMessageFactory.createProposal(earlierPreparedRound, proposedBlock); - final Optional earlierTerminatedRoundArtefacts = + final Optional earlierPreparedRoundArtefacts = Optional.of( - new TerminatedRoundArtefacts( + new PreparedRoundArtefacts( earlierProposal, Lists.newArrayList( proposerMessageFactory.createPrepare( @@ -122,14 +122,14 @@ public class IbftHelpersTest { IbftHelpers.findLatestPreparedCertificate( Lists.newArrayList( proposerMessageFactory - .createRoundChange(roundIdentifier, earlierTerminatedRoundArtefacts) + .createRoundChange(roundIdentifier, earlierPreparedRoundArtefacts) .getSignedPayload(), proposerMessageFactory - .createRoundChange(roundIdentifier, latterTerminatedRoundArtefacts) + .createRoundChange(roundIdentifier, latterPreparedRoundArtefacts) .getSignedPayload())); assertThat(newestCert.get()) - .isEqualTo(latterTerminatedRoundArtefacts.get().getPreparedCertificate()); + .isEqualTo(latterPreparedRoundArtefacts.get().getPreparedCertificate()); } @Test diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java index 5198ed5ded..bb8ba32e52 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java @@ -92,7 +92,7 @@ public class IbftBlockHeightManagerTest { @Mock private RoundTimer roundTimer; @Mock private NewRoundMessageValidator newRoundPayloadValidator; - @Captor private ArgumentCaptor> terminatedRoundArtefactsCaptor; + @Captor private ArgumentCaptor> preparedRoundArtefactsCaptor; private final List validatorKeys = Lists.newArrayList(); private final List
validators = Lists.newArrayList(); @@ -356,9 +356,8 @@ public class IbftBlockHeightManagerTest { final ConsensusRoundIdentifier nextRound = createFrom(roundIdentifier, 0, +1); verify(messageTransmitter, times(1)) - .multicastRoundChange(eq(nextRound), terminatedRoundArtefactsCaptor.capture()); - final Optional preparedCert = - terminatedRoundArtefactsCaptor.getValue(); + .multicastRoundChange(eq(nextRound), preparedRoundArtefactsCaptor.capture()); + final Optional preparedCert = preparedRoundArtefactsCaptor.getValue(); assertThat(preparedCert).isNotEmpty(); diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRoundTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRoundTest.java index b4062c280f..cf7736feba 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRoundTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftRoundTest.java @@ -294,7 +294,7 @@ public class IbftRoundTest { messageFactory.createRoundChange( roundIdentifier, Optional.of( - new TerminatedRoundArtefacts( + new PreparedRoundArtefacts( messageFactory.createProposal(priorRoundChange, proposedBlock), emptyList()))))); diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java index 617045500d..daffdc5210 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeManagerTest.java @@ -152,10 +152,10 @@ public class RoundChangeManagerTest { }) .collect(Collectors.toList()); - final TerminatedRoundArtefacts terminatedRoundArtects = - new TerminatedRoundArtefacts(proposal, preparePayloads); + final PreparedRoundArtefacts preparedRoundArtefacts = + new PreparedRoundArtefacts(proposal, preparePayloads); - return messageFactory.createRoundChange(round, Optional.of(terminatedRoundArtects)); + return messageFactory.createRoundChange(round, Optional.of(preparedRoundArtefacts)); } @Test diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundStateTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundStateTest.java index cae3002a84..f278770836 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundStateTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundStateTest.java @@ -71,7 +71,7 @@ public class RoundStateTest { assertThat(roundState.isPrepared()).isFalse(); assertThat(roundState.isCommitted()).isFalse(); - assertThat(roundState.constructTerminatedRoundArtefacts()).isEmpty(); + assertThat(roundState.constructPreparedRoundArtefacts()).isEmpty(); } @Test @@ -85,7 +85,7 @@ public class RoundStateTest { assertThat(roundState.setProposedBlock(proposal)).isFalse(); assertThat(roundState.isPrepared()).isFalse(); assertThat(roundState.isCommitted()).isFalse(); - assertThat(roundState.constructTerminatedRoundArtefacts()).isEmpty(); + assertThat(roundState.constructPreparedRoundArtefacts()).isEmpty(); } @Test @@ -99,10 +99,10 @@ public class RoundStateTest { assertThat(roundState.setProposedBlock(proposal)).isTrue(); assertThat(roundState.isPrepared()).isTrue(); assertThat(roundState.isCommitted()).isFalse(); - assertThat(roundState.constructTerminatedRoundArtefacts()).isNotEmpty(); + assertThat(roundState.constructPreparedRoundArtefacts()).isNotEmpty(); assertThat( roundState - .constructTerminatedRoundArtefacts() + .constructPreparedRoundArtefacts() .get() .getPreparedCertificate() .getProposalPayload()) @@ -134,7 +134,7 @@ public class RoundStateTest { roundState.addCommitMessage(commit); assertThat(roundState.isPrepared()).isTrue(); assertThat(roundState.isCommitted()).isTrue(); - assertThat(roundState.constructTerminatedRoundArtefacts()).isNotEmpty(); + assertThat(roundState.constructPreparedRoundArtefacts()).isNotEmpty(); } @Test @@ -153,19 +153,19 @@ public class RoundStateTest { roundState.addPrepareMessage(firstPrepare); assertThat(roundState.isPrepared()).isFalse(); assertThat(roundState.isCommitted()).isFalse(); - assertThat(roundState.constructTerminatedRoundArtefacts()).isEmpty(); + assertThat(roundState.constructPreparedRoundArtefacts()).isEmpty(); roundState.addPrepareMessage(secondPrepare); assertThat(roundState.isPrepared()).isFalse(); assertThat(roundState.isCommitted()).isFalse(); - assertThat(roundState.constructTerminatedRoundArtefacts()).isEmpty(); + assertThat(roundState.constructPreparedRoundArtefacts()).isEmpty(); final Proposal proposal = validatorMessageFactories.get(0).createProposal(roundIdentifier, block); assertThat(roundState.setProposedBlock(proposal)).isTrue(); assertThat(roundState.isPrepared()).isTrue(); assertThat(roundState.isCommitted()).isFalse(); - assertThat(roundState.constructTerminatedRoundArtefacts()).isNotEmpty(); + assertThat(roundState.constructPreparedRoundArtefacts()).isNotEmpty(); } @Test @@ -194,7 +194,7 @@ public class RoundStateTest { assertThat(roundState.setProposedBlock(proposal)).isTrue(); assertThat(roundState.isPrepared()).isFalse(); assertThat(roundState.isCommitted()).isFalse(); - assertThat(roundState.constructTerminatedRoundArtefacts()).isEmpty(); + assertThat(roundState.constructPreparedRoundArtefacts()).isEmpty(); } @Test diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundSignedDataValidatorTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundSignedDataValidatorTest.java index 66e5f5681e..ad98280f20 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundSignedDataValidatorTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/NewRoundSignedDataValidatorTest.java @@ -26,7 +26,7 @@ import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Proposal; import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangeCertificate; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.consensus.ibft.validation.RoundChangePayloadValidator.MessageValidatorForHeightFactory; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.ethereum.core.Address; @@ -163,8 +163,8 @@ public class NewRoundSignedDataValidatorTest { final Block prevProposedBlock = TestHelpers.createProposalBlock(validators.subList(0, 1), roundIdentifier.getRoundNumber()); - final TerminatedRoundArtefacts mismatchedRoundArtefacts = - new TerminatedRoundArtefacts( + final PreparedRoundArtefacts mismatchedRoundArtefacts = + new PreparedRoundArtefacts( proposerMessageFactory.createProposal(preparedRound, prevProposedBlock), singletonList( validatorMessageFactory.createPrepare(preparedRound, prevProposedBlock.getHash()))); @@ -207,7 +207,7 @@ public class NewRoundSignedDataValidatorTest { proposerMessageFactory.createRoundChange( roundIdentifier, Optional.of( - new TerminatedRoundArtefacts( + new PreparedRoundArtefacts( proposerMessageFactory.createProposal(prevRound, proposedBlock), Lists.newArrayList( validatorMessageFactory.createPrepare( @@ -230,9 +230,9 @@ public class NewRoundSignedDataValidatorTest { roundIdentifier.getSequenceNumber(), roundIdentifier.getRoundNumber() - 1); final Proposal latterProposal = proposerMessageFactory.createProposal(latterPrepareRound, proposedBlock); - final Optional preparedCert = + final Optional preparedCert = Optional.of( - new TerminatedRoundArtefacts( + new PreparedRoundArtefacts( latterProposal, Lists.newArrayList( validatorMessageFactory.createPrepare( @@ -247,9 +247,9 @@ public class NewRoundSignedDataValidatorTest { roundIdentifier.getSequenceNumber(), roundIdentifier.getRoundNumber() - 2); final Proposal earlierProposal = proposerMessageFactory.createProposal(earlierPreparedRound, earlierBlock); - final Optional earlierPreparedCert = + final Optional earlierPreparedCert = Optional.of( - new TerminatedRoundArtefacts( + new PreparedRoundArtefacts( earlierProposal, Lists.newArrayList( validatorMessageFactory.createPrepare( diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/RoundChangeSignedDataValidatorTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/RoundChangeSignedDataValidatorTest.java index d57a9fb511..891c5b3524 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/RoundChangeSignedDataValidatorTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/validation/RoundChangeSignedDataValidatorTest.java @@ -25,7 +25,7 @@ import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Prepare; import tech.pegasys.pantheon.consensus.ibft.messagewrappers.RoundChange; import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.PreparedCertificate; -import tech.pegasys.pantheon.consensus.ibft.statemachine.TerminatedRoundArtefacts; +import tech.pegasys.pantheon.consensus.ibft.statemachine.PreparedRoundArtefacts; import tech.pegasys.pantheon.consensus.ibft.validation.RoundChangePayloadValidator.MessageValidatorForHeightFactory; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.ethereum.core.Address; @@ -95,16 +95,14 @@ public class RoundChangeSignedDataValidatorTest { @Test public void roundChangeContainingInvalidProposalFails() { - final TerminatedRoundArtefacts terminatedRoundArtefacts = - new TerminatedRoundArtefacts( + final PreparedRoundArtefacts preparedRoundArtefacts = + new PreparedRoundArtefacts( proposerMessageFactory.createProposal(currentRound, block), Collections.emptyList()); - final PreparedCertificate prepareCertificate = - terminatedRoundArtefacts.getPreparedCertificate(); + final PreparedCertificate prepareCertificate = preparedRoundArtefacts.getPreparedCertificate(); final RoundChange msg = - proposerMessageFactory.createRoundChange( - targetRound, Optional.of(terminatedRoundArtefacts)); + proposerMessageFactory.createRoundChange(targetRound, Optional.of(preparedRoundArtefacts)); when(basicValidator.addSignedProposalPayload(any())).thenReturn(false); @@ -119,13 +117,12 @@ public class RoundChangeSignedDataValidatorTest { @Test public void roundChangeContainingValidProposalButNoPrepareMessagesFails() { - final TerminatedRoundArtefacts terminatedRoundArtefacts = - new TerminatedRoundArtefacts( + final PreparedRoundArtefacts preparedRoundArtefacts = + new PreparedRoundArtefacts( proposerMessageFactory.createProposal(currentRound, block), Collections.emptyList()); final RoundChange msg = - proposerMessageFactory.createRoundChange( - targetRound, Optional.of(terminatedRoundArtefacts)); + proposerMessageFactory.createRoundChange(targetRound, Optional.of(preparedRoundArtefacts)); when(basicValidator.addSignedProposalPayload(any())).thenReturn(true); assertThat(validator.validateRoundChange(msg.getSignedPayload())).isFalse(); @@ -134,8 +131,8 @@ public class RoundChangeSignedDataValidatorTest { @Test public void roundChangeInvalidPrepareMessageFromProposerFails() { final Prepare prepareMsg = validatorMessageFactory.createPrepare(currentRound, block.getHash()); - final TerminatedRoundArtefacts terminatedRoundArtefacts = - new TerminatedRoundArtefacts( + final PreparedRoundArtefacts preparedRoundArtefacts = + new PreparedRoundArtefacts( proposerMessageFactory.createProposal(currentRound, block), Lists.newArrayList(prepareMsg)); @@ -143,8 +140,7 @@ public class RoundChangeSignedDataValidatorTest { when(basicValidator.validatePrepareMessage(any())).thenReturn(false); final RoundChange msg = - proposerMessageFactory.createRoundChange( - targetRound, Optional.of(terminatedRoundArtefacts)); + proposerMessageFactory.createRoundChange(targetRound, Optional.of(preparedRoundArtefacts)); assertThat(validator.validateRoundChange(msg.getSignedPayload())).isFalse(); @@ -171,14 +167,13 @@ public class RoundChangeSignedDataValidatorTest { currentRound.getSequenceNumber(), currentRound.getRoundNumber() + 2); final Prepare prepareMsg = validatorMessageFactory.createPrepare(futureRound, block.getHash()); - final TerminatedRoundArtefacts terminatedRoundArtefacts = - new TerminatedRoundArtefacts( + final PreparedRoundArtefacts preparedRoundArtefacts = + new PreparedRoundArtefacts( proposerMessageFactory.createProposal(futureRound, block), Lists.newArrayList(prepareMsg)); final RoundChange msg = - proposerMessageFactory.createRoundChange( - targetRound, Optional.of(terminatedRoundArtefacts)); + proposerMessageFactory.createRoundChange(targetRound, Optional.of(preparedRoundArtefacts)); assertThat(validator.validateRoundChange(msg.getSignedPayload())).isFalse(); verify(validatorFactory, never()).createAt(any()); @@ -189,17 +184,15 @@ public class RoundChangeSignedDataValidatorTest { @Test public void roundChangeWithPastProposalForCurrentHeightIsSuccessful() { final Prepare prepareMsg = validatorMessageFactory.createPrepare(currentRound, block.getHash()); - final TerminatedRoundArtefacts terminatedRoundArtefacts = - new TerminatedRoundArtefacts( + final PreparedRoundArtefacts preparedRoundArtefacts = + new PreparedRoundArtefacts( proposerMessageFactory.createProposal(currentRound, block), Lists.newArrayList(prepareMsg)); - final PreparedCertificate prepareCertificate = - terminatedRoundArtefacts.getPreparedCertificate(); + final PreparedCertificate prepareCertificate = preparedRoundArtefacts.getPreparedCertificate(); final RoundChange msg = - proposerMessageFactory.createRoundChange( - targetRound, Optional.of(terminatedRoundArtefacts)); + proposerMessageFactory.createRoundChange(targetRound, Optional.of(preparedRoundArtefacts)); when(basicValidator.addSignedProposalPayload(prepareCertificate.getProposalPayload())) .thenReturn(true);