From ac0ff50052a6097cb4d8b24befa9970ad27dd873 Mon Sep 17 00:00:00 2001 From: tmohay Date: Thu, 31 Jan 2019 14:26:55 +1100 Subject: [PATCH 1/3] Create wrapper types for Ibft Signed messages As future IBFT message will require only subsets of the data to be signed, the message structures need to be modified such taht the signed-data aspects can be a component of the message (Rather than the whole message). THis chnage starts this process by having a "flat" message which allows clients to query the required round, and author of the message. --- .../ibft/support/RoundSpecificPeers.java | 14 +++-- .../consensus/ibft/support/ValidatorPeer.java | 15 ++++-- .../consensus/ibft/tests/GossipTest.java | 5 +- .../pantheon/consensus/ibft/IbftGossip.java | 18 ++++--- .../ibft/messagedata/CommitMessageData.java | 10 ++-- .../ibft/messagedata/NewRoundMessageData.java | 11 ++-- .../ibft/messagedata/PrepareMessageData.java | 11 ++-- .../ibft/messagedata/ProposalMessageData.java | 10 ++-- .../messagedata/RoundChangeMessageData.java | 8 +-- .../ibft/messagewrappers/Commit.java | 23 ++++++++ .../ibft/messagewrappers/IbftMessage.java | 52 +++++++++++++++++++ .../ibft/messagewrappers/NewRound.java | 23 ++++++++ .../ibft/messagewrappers/Prepare.java | 23 ++++++++ .../ibft/messagewrappers/Proposal.java | 23 ++++++++ .../ibft/messagewrappers/RoundChange.java | 23 ++++++++ .../ibft/network/IbftMessageTransmitter.java | 41 ++++++++------- .../consensus/ibft/payload/Authored.java | 20 +++++++ .../consensus/ibft/payload/Payload.java | 5 +- .../consensus/ibft/payload/RoundSpecific.java | 20 +++++++ .../consensus/ibft/payload/SignedData.java | 9 ++-- .../ibft/statemachine/IbftController.java | 20 +++---- .../consensus/ibft/IbftGossipTest.java | 10 ++-- .../pantheon/consensus/ibft/TestHelpers.java | 51 +++++++++--------- .../ibft/messagedata/CommitMessageTest.java | 5 +- .../ibft/messagedata/NewRoundMessageTest.java | 5 +- .../ibft/messagedata/PrepareMessageTest.java | 5 +- .../ibft/messagedata/ProposalMessageTest.java | 5 +- .../messagedata/RoundChangeMessageTest.java | 5 +- .../ibft/statemachine/IbftControllerTest.java | 15 ++++-- 29 files changed, 351 insertions(+), 134 deletions(-) create mode 100644 consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Commit.java create mode 100644 consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/IbftMessage.java create mode 100644 consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/NewRound.java create mode 100644 consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Prepare.java create mode 100644 consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Proposal.java create mode 100644 consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/RoundChange.java create mode 100644 consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/Authored.java create mode 100644 consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundSpecific.java 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 14d2884f0d..e68f0a9104 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 @@ -195,19 +195,23 @@ private void verifyMessage( switch (expectedPayload.getMessageType()) { case IbftV2.PROPOSAL: - actualSignedPayload = ProposalMessageData.fromMessageData(actual).decode(); + actualSignedPayload = + ProposalMessageData.fromMessageData(actual).decode().getSignedPayload(); break; case IbftV2.PREPARE: - actualSignedPayload = PrepareMessageData.fromMessageData(actual).decode(); + actualSignedPayload = + PrepareMessageData.fromMessageData(actual).decode().getSignedPayload(); break; case IbftV2.COMMIT: - actualSignedPayload = CommitMessageData.fromMessageData(actual).decode(); + actualSignedPayload = CommitMessageData.fromMessageData(actual).decode().getSignedPayload(); break; case IbftV2.NEW_ROUND: - actualSignedPayload = NewRoundMessageData.fromMessageData(actual).decode(); + actualSignedPayload = + NewRoundMessageData.fromMessageData(actual).decode().getSignedPayload(); break; case IbftV2.ROUND_CHANGE: - actualSignedPayload = RoundChangeMessageData.fromMessageData(actual).decode(); + actualSignedPayload = + RoundChangeMessageData.fromMessageData(actual).decode().getSignedPayload(); break; default: fail("Illegal IBFTV2 message type."); 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 8d79d2d974..a6df12d456 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 @@ -20,6 +20,11 @@ import tech.pegasys.pantheon.consensus.ibft.messagedata.PrepareMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.ProposalMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.RoundChangeMessageData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; +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.payload.CommitPayload; import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; @@ -82,7 +87,7 @@ public SignedData injectProposal( final SignedData payload = messageFactory.createSignedProposalPayload(rId, block); - injectMessage(ProposalMessageData.create(payload)); + injectMessage(ProposalMessageData.create(new Proposal(payload))); return payload; } @@ -90,7 +95,7 @@ public SignedData injectPrepare( final ConsensusRoundIdentifier rId, final Hash digest) { final SignedData payload = messageFactory.createSignedPreparePayload(rId, digest); - injectMessage(PrepareMessageData.create(payload)); + injectMessage(PrepareMessageData.create(new Prepare(payload))); return payload; } @@ -109,7 +114,7 @@ public SignedData injectCommit( final ConsensusRoundIdentifier rId, final Hash digest, final Signature commitSeal) { final SignedData payload = messageFactory.createSignedCommitPayload(rId, digest, commitSeal); - injectMessage(CommitMessageData.create(payload)); + injectMessage(CommitMessageData.create(new Commit(payload))); return payload; } @@ -120,7 +125,7 @@ public SignedData injectNewRound( final SignedData payload = messageFactory.createSignedNewRoundPayload(rId, roundChangeCertificate, proposalPayload); - injectMessage(NewRoundMessageData.create(payload)); + injectMessage(NewRoundMessageData.create(new NewRound(payload))); return payload; } @@ -128,7 +133,7 @@ public SignedData injectRoundChange( final ConsensusRoundIdentifier rId, final Optional preparedCertificate) { final SignedData payload = messageFactory.createSignedRoundChangePayload(rId, preparedCertificate); - injectMessage(RoundChangeMessageData.create(payload)); + injectMessage(RoundChangeMessageData.create(new RoundChange(payload))); return payload; } diff --git a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java index 21ccb4a1e5..112f20e6aa 100644 --- a/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java +++ b/consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java @@ -19,6 +19,7 @@ import tech.pegasys.pantheon.consensus.ibft.IbftHelpers; import tech.pegasys.pantheon.consensus.ibft.ibftevent.NewChainHead; import tech.pegasys.pantheon.consensus.ibft.messagedata.ProposalMessageData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Proposal; import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; @@ -124,7 +125,7 @@ public void messageWithUnknownValidatorIsNotGossiped() { final SignedData unknownProposal = unknownMsgFactory.createSignedProposalPayload(roundId, block); - sender.injectMessage(ProposalMessageData.create(unknownProposal)); + sender.injectMessage(ProposalMessageData.create(new Proposal(unknownProposal))); peers.verifyNoMessagesReceived(); } @@ -135,7 +136,7 @@ public void messageIsNotGossipedToSenderOrCreator() { final SignedData proposalFromPeer = peerMsgFactory.createSignedProposalPayload(roundId, block); - sender.injectMessage(ProposalMessageData.create(proposalFromPeer)); + sender.injectMessage(ProposalMessageData.create(new Proposal(proposalFromPeer))); peers.verifyMessagesReceivedNonPropsingExcluding(msgCreator, proposalFromPeer); peers.verifyNoMessagesReceivedProposer(); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftGossip.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftGossip.java index 7dd6e84151..f4cd32d934 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftGossip.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/IbftGossip.java @@ -19,7 +19,7 @@ import tech.pegasys.pantheon.consensus.ibft.messagedata.ProposalMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.RoundChangeMessageData; import tech.pegasys.pantheon.consensus.ibft.network.ValidatorMulticaster; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; +import tech.pegasys.pantheon.consensus.ibft.payload.Authored; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.p2p.api.Message; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; @@ -50,29 +50,31 @@ public IbftGossip(final ValidatorMulticaster multicaster) { @Override public void send(final Message message) { final MessageData messageData = message.getData(); - final SignedData signedData; + final Authored decodedMessage; switch (messageData.getCode()) { case IbftV2.PROPOSAL: - signedData = ProposalMessageData.fromMessageData(messageData).decode(); + decodedMessage = ProposalMessageData.fromMessageData(messageData).decode(); break; case IbftV2.PREPARE: - signedData = PrepareMessageData.fromMessageData(messageData).decode(); + decodedMessage = PrepareMessageData.fromMessageData(messageData).decode(); break; case IbftV2.COMMIT: - signedData = CommitMessageData.fromMessageData(messageData).decode(); + decodedMessage = CommitMessageData.fromMessageData(messageData).decode(); break; case IbftV2.ROUND_CHANGE: - signedData = RoundChangeMessageData.fromMessageData(messageData).decode(); + decodedMessage = RoundChangeMessageData.fromMessageData(messageData).decode(); break; case IbftV2.NEW_ROUND: - signedData = NewRoundMessageData.fromMessageData(messageData).decode(); + decodedMessage = + NewRoundMessageData.fromMessageData(messageData).decode().getSignedPayload(); break; default: throw new IllegalArgumentException( "Received message does not conform to any recognised IBFT message structure."); } final List
excludeAddressesList = - Lists.newArrayList(message.getConnection().getPeer().getAddress(), signedData.getAuthor()); + Lists.newArrayList( + message.getConnection().getPeer().getAddress(), decodedMessage.getAuthor()); multicaster.send(messageData, excludeAddressesList); } diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/CommitMessageData.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/CommitMessageData.java index b6e52fbfa6..a3bc7f2bec 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/CommitMessageData.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/CommitMessageData.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.consensus.ibft.messagedata; -import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.ethereum.rlp.RLP; @@ -31,13 +31,13 @@ public static CommitMessageData fromMessageData(final MessageData messageData) { messageData, MESSAGE_CODE, CommitMessageData.class, CommitMessageData::new); } - public SignedData decode() { - return SignedData.readSignedCommitPayloadFrom(RLP.input(data)); + public Commit decode() { + return new Commit(SignedData.readSignedCommitPayloadFrom(RLP.input(data))); } - public static CommitMessageData create(final SignedData signedPayload) { + public static CommitMessageData create(final Commit commit) { - return new CommitMessageData(signedPayload.encode()); + return new CommitMessageData(commit.encode()); } @Override diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/NewRoundMessageData.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/NewRoundMessageData.java index 79289873f2..2e05bcf51e 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/NewRoundMessageData.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/NewRoundMessageData.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.consensus.ibft.messagedata; -import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.NewRound; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.ethereum.rlp.RLP; @@ -31,13 +31,12 @@ public static NewRoundMessageData fromMessageData(final MessageData messageData) messageData, MESSAGE_CODE, NewRoundMessageData.class, NewRoundMessageData::new); } - public SignedData decode() { - return SignedData.readSignedNewRoundPayloadFrom(RLP.input(data)); + public NewRound decode() { + return new NewRound(SignedData.readSignedNewRoundPayloadFrom(RLP.input(data))); } - public static NewRoundMessageData create(final SignedData signedPayload) { - - return new NewRoundMessageData(signedPayload.encode()); + public static NewRoundMessageData create(final NewRound newRound) { + return new NewRoundMessageData(newRound.encode()); } @Override diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/PrepareMessageData.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/PrepareMessageData.java index 4ab92ec797..4e03687722 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/PrepareMessageData.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/PrepareMessageData.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.consensus.ibft.messagedata; -import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Prepare; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.ethereum.rlp.RLP; @@ -31,13 +31,12 @@ public static PrepareMessageData fromMessageData(final MessageData messageData) messageData, MESSAGE_CODE, PrepareMessageData.class, PrepareMessageData::new); } - public SignedData decode() { - return SignedData.readSignedPreparePayloadFrom(RLP.input(data)); + public Prepare decode() { + return new Prepare(SignedData.readSignedPreparePayloadFrom(RLP.input(data))); } - public static PrepareMessageData create(final SignedData signedPayload) { - - return new PrepareMessageData(signedPayload.encode()); + public static PrepareMessageData create(final Prepare preapare) { + return new PrepareMessageData(preapare.encode()); } @Override diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/ProposalMessageData.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/ProposalMessageData.java index e836da7a9a..a857cc1a78 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/ProposalMessageData.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/ProposalMessageData.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.consensus.ibft.messagedata; -import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Proposal; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.ethereum.rlp.RLP; @@ -31,13 +31,13 @@ public static ProposalMessageData fromMessageData(final MessageData messageData) messageData, MESSAGE_CODE, ProposalMessageData.class, ProposalMessageData::new); } - public SignedData decode() { - return SignedData.readSignedProposalPayloadFrom(RLP.input(data)); + public Proposal decode() { + return new Proposal(SignedData.readSignedProposalPayloadFrom(RLP.input(data))); } - public static ProposalMessageData create(final SignedData signedPayload) { + public static ProposalMessageData create(final Proposal proposal) { - return new ProposalMessageData(signedPayload.encode()); + return new ProposalMessageData(proposal.encode()); } @Override diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/RoundChangeMessageData.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/RoundChangeMessageData.java index ebbb0cf66a..9c74831062 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/RoundChangeMessageData.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagedata/RoundChangeMessageData.java @@ -12,7 +12,7 @@ */ package tech.pegasys.pantheon.consensus.ibft.messagedata; -import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.RoundChange; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.ethereum.rlp.RLP; @@ -31,11 +31,11 @@ public static RoundChangeMessageData fromMessageData(final MessageData messageDa messageData, MESSAGE_CODE, RoundChangeMessageData.class, RoundChangeMessageData::new); } - public SignedData decode() { - return SignedData.readSignedRoundChangePayloadFrom(RLP.input(data)); + public RoundChange decode() { + return new RoundChange(SignedData.readSignedRoundChangePayloadFrom(RLP.input(data))); } - public static RoundChangeMessageData create(final SignedData signedPayload) { + public static RoundChangeMessageData create(final RoundChange signedPayload) { return new RoundChangeMessageData(signedPayload.encode()); } diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Commit.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Commit.java new file mode 100644 index 0000000000..3e99da9179 --- /dev/null +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Commit.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.consensus.ibft.messagewrappers; + +import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; +import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; + +public class Commit extends IbftMessage { + + public Commit(final SignedData payload) { + super(payload); + } +} diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/IbftMessage.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/IbftMessage.java new file mode 100644 index 0000000000..28e3830ecb --- /dev/null +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/IbftMessage.java @@ -0,0 +1,52 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.consensus.ibft.messagewrappers; + +import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; +import tech.pegasys.pantheon.consensus.ibft.payload.Authored; +import tech.pegasys.pantheon.consensus.ibft.payload.Payload; +import tech.pegasys.pantheon.consensus.ibft.payload.RoundSpecific; +import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; +import tech.pegasys.pantheon.ethereum.core.Address; +import tech.pegasys.pantheon.util.bytes.BytesValue; + +public class IbftMessage

implements Authored, RoundSpecific { + + private final SignedData

payload; + + public IbftMessage(final SignedData

payload) { + this.payload = payload; + } + + @Override + public Address getAuthor() { + return payload.getAuthor(); + } + + @Override + public ConsensusRoundIdentifier getRoundIdentifier() { + return payload.getPayload().getRoundIdentifier(); + } + + public BytesValue encode() { + return payload.encode(); + } + + public SignedData

getSignedPayload() { + return payload; + } + + public int getMessageType() { + return payload.getPayload().getMessageType(); + } +} diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/NewRound.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/NewRound.java new file mode 100644 index 0000000000..dbf38febc3 --- /dev/null +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/NewRound.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.consensus.ibft.messagewrappers; + +import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; +import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; + +public class NewRound extends IbftMessage { + + public NewRound(final SignedData payload) { + super(payload); + } +} diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Prepare.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Prepare.java new file mode 100644 index 0000000000..0587322a87 --- /dev/null +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Prepare.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.consensus.ibft.messagewrappers; + +import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; +import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; + +public class Prepare extends IbftMessage { + + public Prepare(final SignedData payload) { + super(payload); + } +} diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Proposal.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Proposal.java new file mode 100644 index 0000000000..db9568d2ea --- /dev/null +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/Proposal.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.consensus.ibft.messagewrappers; + +import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; +import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; + +public class Proposal extends IbftMessage { + + public Proposal(final SignedData payload) { + super(payload); + } +} diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/RoundChange.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/RoundChange.java new file mode 100644 index 0000000000..dbc7f37f8c --- /dev/null +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/messagewrappers/RoundChange.java @@ -0,0 +1,23 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.consensus.ibft.messagewrappers; + +import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; +import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; + +public class RoundChange extends IbftMessage { + + public RoundChange(final SignedData payload) { + super(payload); + } +} 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 55cc1cec68..ffbaf50c48 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 @@ -18,14 +18,15 @@ import tech.pegasys.pantheon.consensus.ibft.messagedata.PrepareMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.ProposalMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.RoundChangeMessageData; -import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; +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.payload.MessageFactory; -import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; import tech.pegasys.pantheon.consensus.ibft.payload.PreparedCertificate; import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; 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.crypto.SECP256K1.Signature; import tech.pegasys.pantheon.ethereum.core.Block; @@ -45,19 +46,19 @@ public IbftMessageTransmitter( } public void multicastProposal(final ConsensusRoundIdentifier roundIdentifier, final Block block) { - final SignedData signedPayload = - messageFactory.createSignedProposalPayload(roundIdentifier, block); + final Proposal data = + new Proposal(messageFactory.createSignedProposalPayload(roundIdentifier, block)); - final ProposalMessageData message = ProposalMessageData.create(signedPayload); + final ProposalMessageData message = ProposalMessageData.create(data); multicaster.send(message); } public void multicastPrepare(final ConsensusRoundIdentifier roundIdentifier, final Hash digest) { - final SignedData signedPayload = - messageFactory.createSignedPreparePayload(roundIdentifier, digest); + final Prepare data = + new Prepare(messageFactory.createSignedPreparePayload(roundIdentifier, digest)); - final PrepareMessageData message = PrepareMessageData.create(signedPayload); + final PrepareMessageData message = PrepareMessageData.create(data); multicaster.send(message); } @@ -66,10 +67,10 @@ public void multicastCommit( final ConsensusRoundIdentifier roundIdentifier, final Hash digest, final Signature commitSeal) { - final SignedData signedPayload = - messageFactory.createSignedCommitPayload(roundIdentifier, digest, commitSeal); + final Commit data = + new Commit(messageFactory.createSignedCommitPayload(roundIdentifier, digest, commitSeal)); - final CommitMessageData message = CommitMessageData.create(signedPayload); + final CommitMessageData message = CommitMessageData.create(data); multicaster.send(message); } @@ -78,10 +79,11 @@ public void multicastRoundChange( final ConsensusRoundIdentifier roundIdentifier, final Optional preparedCertificate) { - final SignedData signedPayload = - messageFactory.createSignedRoundChangePayload(roundIdentifier, preparedCertificate); + final RoundChange data = + new RoundChange( + messageFactory.createSignedRoundChangePayload(roundIdentifier, preparedCertificate)); - final RoundChangeMessageData message = RoundChangeMessageData.create(signedPayload); + final RoundChangeMessageData message = RoundChangeMessageData.create(data); multicaster.send(message); } @@ -91,9 +93,10 @@ public void multicastNewRound( final RoundChangeCertificate roundChangeCertificate, final SignedData proposalPayload) { - final SignedData signedPayload = - messageFactory.createSignedNewRoundPayload( - roundIdentifier, roundChangeCertificate, proposalPayload); + final NewRound signedPayload = + new NewRound( + messageFactory.createSignedNewRoundPayload( + roundIdentifier, roundChangeCertificate, proposalPayload)); final NewRoundMessageData message = NewRoundMessageData.create(signedPayload); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/Authored.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/Authored.java new file mode 100644 index 0000000000..f57eb59b47 --- /dev/null +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/Authored.java @@ -0,0 +1,20 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.consensus.ibft.payload; + +import tech.pegasys.pantheon.ethereum.core.Address; + +public interface Authored { + + Address getAuthor(); +} diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/Payload.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/Payload.java index 32b6278b64..14bc63b62c 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/Payload.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/Payload.java @@ -12,19 +12,16 @@ */ package tech.pegasys.pantheon.consensus.ibft.payload; -import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; import tech.pegasys.pantheon.ethereum.core.Hash; import tech.pegasys.pantheon.ethereum.rlp.BytesValueRLPOutput; import tech.pegasys.pantheon.ethereum.rlp.RLPInput; import tech.pegasys.pantheon.ethereum.rlp.RLPOutput; import tech.pegasys.pantheon.util.bytes.BytesValue; -public interface Payload { +public interface Payload extends RoundSpecific { void writeTo(final RLPOutput rlpOutput); - ConsensusRoundIdentifier getRoundIdentifier(); - default BytesValue encoded() { BytesValueRLPOutput rlpOutput = new BytesValueRLPOutput(); writeTo(rlpOutput); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundSpecific.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundSpecific.java new file mode 100644 index 0000000000..16ce20bca3 --- /dev/null +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundSpecific.java @@ -0,0 +1,20 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package tech.pegasys.pantheon.consensus.ibft.payload; + +import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; + +public interface RoundSpecific { + + ConsensusRoundIdentifier getRoundIdentifier(); +} diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/SignedData.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/SignedData.java index 7cebde129b..fd89f8c1bf 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/SignedData.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/SignedData.java @@ -23,7 +23,7 @@ import java.util.Objects; import java.util.StringJoiner; -public class SignedData { +public class SignedData implements Authored { private final Address sender; private final Signature signature; private final M unsignedPayload; @@ -34,14 +34,11 @@ public SignedData(final M unsignedPayload, final Address sender, final Signature this.signature = signature; } + @Override public Address getAuthor() { return sender; } - public Signature getSignature() { - return signature; - } - public M getPayload() { return unsignedPayload; } @@ -50,7 +47,7 @@ public void writeTo(final RLPOutput output) { output.startList(); unsignedPayload.writeTo(output); - output.writeBytesValue(getSignature().encodedBytes()); + output.writeBytesValue(signature.encodedBytes()); output.endList(); } diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftController.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftController.java index aac8b09767..c673ee81e4 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftController.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftController.java @@ -27,6 +27,8 @@ import tech.pegasys.pantheon.consensus.ibft.messagedata.PrepareMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.ProposalMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.RoundChangeMessageData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.IbftMessage; +import tech.pegasys.pantheon.consensus.ibft.payload.Authored; import tech.pegasys.pantheon.consensus.ibft.payload.Payload; import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; import tech.pegasys.pantheon.ethereum.chain.Blockchain; @@ -132,15 +134,15 @@ private void handleMessage(final Message message) { private

void consumeMessage( final Message message, - final SignedData

signedPayload, + final IbftMessage

ibftMessage, final Consumer> handleMessage) { LOG.debug( "Received IBFT message messageType={} payload={}", - signedPayload.getPayload().getMessageType(), - signedPayload); - if (processMessage(signedPayload, message)) { + ibftMessage.getMessageType(), + ibftMessage); + if (processMessage(ibftMessage, message)) { gossiper.send(message); - handleMessage.accept(signedPayload); + handleMessage.accept(ibftMessage.getSignedPayload()); } } @@ -203,8 +205,8 @@ private void startNewHeightManager(final BlockHeader parentHeader) { futureMessages.remove(newChainHeight); } - private boolean processMessage(final SignedData msg, final Message rawMsg) { - final ConsensusRoundIdentifier msgRoundIdentifier = msg.getPayload().getRoundIdentifier(); + private boolean processMessage(final IbftMessage msg, final Message rawMsg) { + final ConsensusRoundIdentifier msgRoundIdentifier = msg.getRoundIdentifier(); if (isMsgForCurrentHeight(msgRoundIdentifier)) { return isMsgFromKnownValidator(msg) && ibftFinalState.isLocalNodeValidator(); } else if (isMsgForFutureChainHeight(msgRoundIdentifier)) { @@ -212,14 +214,14 @@ private boolean processMessage(final SignedData msg, final Me } else { LOG.debug( "IBFT message discarded as it is from a previous block height messageType={} chainHeight={} eventHeight={}", - msg.getPayload().getMessageType(), + msg.getMessageType(), currentHeightManager.getChainHeight(), msgRoundIdentifier.getSequenceNumber()); } return false; } - private boolean isMsgFromKnownValidator(final SignedData msg) { + private boolean isMsgFromKnownValidator(final Authored msg) { return ibftFinalState.getValidators().contains(msg.getAuthor()); } diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftGossipTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftGossipTest.java index 892f6d2d2b..425488c0b7 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftGossipTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/IbftGossipTest.java @@ -18,10 +18,9 @@ import tech.pegasys.pantheon.consensus.ibft.messagedata.NewRoundMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.ProposalMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.RoundChangeMessageData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.IbftMessage; import tech.pegasys.pantheon.consensus.ibft.network.MockPeerFactory; import tech.pegasys.pantheon.consensus.ibft.network.ValidatorMulticaster; -import tech.pegasys.pantheon.consensus.ibft.payload.Payload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.AddressHelpers; @@ -51,11 +50,10 @@ public void setup() { peerConnection = MockPeerFactory.create(senderAddress); } - private

void assertRebroadcastToAllExceptSignerAndSender( - final Function> createPayload, - final Function, MessageData> createMessageData) { + private

> void assertRebroadcastToAllExceptSignerAndSender( + final Function createPayload, final Function createMessageData) { final KeyPair keypair = KeyPair.generate(); - final SignedData

payload = createPayload.apply(keypair); + final P payload = createPayload.apply(keypair); final MessageData messageData = createMessageData.apply(payload); final Message message = new DefaultMessage(peerConnection, messageData); diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/TestHelpers.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/TestHelpers.java index 46154bc5e0..c3b22d1e6e 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/TestHelpers.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/TestHelpers.java @@ -15,14 +15,13 @@ import static com.google.common.collect.Lists.newArrayList; import static java.util.Collections.singletonList; -import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; +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.payload.MessageFactory; -import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; -import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; 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.crypto.SECP256K1.KeyPair; import tech.pegasys.pantheon.crypto.SECP256K1.Signature; import tech.pegasys.pantheon.ethereum.core.Address; @@ -62,52 +61,56 @@ public static Block createProposalBlock(final List

validators, final in return new BlockDataGenerator().block(blockOptions); } - public static SignedData createSignedProposalPayload(final KeyPair signerKeys) { + public static Proposal createSignedProposalPayload(final KeyPair signerKeys) { return createSignedProposalPayloadWithRound(signerKeys, 0xFEDCBA98); } - public static SignedData createSignedProposalPayloadWithRound( + public static Proposal createSignedProposalPayloadWithRound( final KeyPair signerKeys, final int round) { final MessageFactory messageFactory = new MessageFactory(signerKeys); final ConsensusRoundIdentifier roundIdentifier = new ConsensusRoundIdentifier(0x1234567890ABCDEFL, round); final Block block = TestHelpers.createProposalBlock(singletonList(AddressHelpers.ofValue(1)), 0); - return messageFactory.createSignedProposalPayload(roundIdentifier, block); + return new Proposal(messageFactory.createSignedProposalPayload(roundIdentifier, block)); } - public static SignedData createSignedPreparePayload(final KeyPair signerKeys) { + public static Prepare createSignedPreparePayload(final KeyPair signerKeys) { final MessageFactory messageFactory = new MessageFactory(signerKeys); final ConsensusRoundIdentifier roundIdentifier = new ConsensusRoundIdentifier(0x1234567890ABCDEFL, 0xFEDCBA98); - return messageFactory.createSignedPreparePayload( - roundIdentifier, Hash.fromHexStringLenient("0")); + return new Prepare( + messageFactory.createSignedPreparePayload(roundIdentifier, Hash.fromHexStringLenient("0"))); } - public static SignedData createSignedCommitPayload(final KeyPair signerKeys) { + public static Commit createSignedCommitPayload(final KeyPair signerKeys) { final MessageFactory messageFactory = new MessageFactory(signerKeys); final ConsensusRoundIdentifier roundIdentifier = new ConsensusRoundIdentifier(0x1234567890ABCDEFL, 0xFEDCBA98); - return messageFactory.createSignedCommitPayload( - roundIdentifier, - Hash.fromHexStringLenient("0"), - Signature.create(BigInteger.ONE, BigInteger.TEN, (byte) 0)); + return new Commit( + messageFactory.createSignedCommitPayload( + roundIdentifier, + Hash.fromHexStringLenient("0"), + Signature.create(BigInteger.ONE, BigInteger.TEN, (byte) 0))); } - public static SignedData createSignedRoundChangePayload( - final KeyPair signerKeys) { + public static RoundChange createSignedRoundChangePayload(final KeyPair signerKeys) { final MessageFactory messageFactory = new MessageFactory(signerKeys); final ConsensusRoundIdentifier roundIdentifier = new ConsensusRoundIdentifier(0x1234567890ABCDEFL, 0xFEDCBA98); - return messageFactory.createSignedRoundChangePayload(roundIdentifier, Optional.empty()); + return new RoundChange( + messageFactory.createSignedRoundChangePayload(roundIdentifier, Optional.empty())); } - public static SignedData createSignedNewRoundPayload(final KeyPair signerKeys) { + public static NewRound createSignedNewRoundPayload(final KeyPair signerKeys) { final MessageFactory messageFactory = new MessageFactory(signerKeys); final ConsensusRoundIdentifier roundIdentifier = new ConsensusRoundIdentifier(0x1234567890ABCDEFL, 0xFEDCBA98); - final SignedData proposalPayload = createSignedProposalPayload(signerKeys); - return messageFactory.createSignedNewRoundPayload( - roundIdentifier, new RoundChangeCertificate(newArrayList()), proposalPayload); + final Proposal proposalPayload = createSignedProposalPayload(signerKeys); + return new NewRound( + messageFactory.createSignedNewRoundPayload( + roundIdentifier, + new RoundChangeCertificate(newArrayList()), + proposalPayload.getSignedPayload())); } } diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/CommitMessageTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/CommitMessageTest.java index 43d6f65f4d..64d881e243 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/CommitMessageTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/CommitMessageTest.java @@ -17,8 +17,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -29,7 +28,7 @@ @RunWith(MockitoJUnitRunner.class) public class CommitMessageTest { - @Mock private SignedData commitPayload; + @Mock private Commit commitPayload; @Mock private BytesValue messageBytes; @Mock private MessageData messageData; @Mock private CommitMessageData commitMessage; diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/NewRoundMessageTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/NewRoundMessageTest.java index 73f52769ad..7d2d1c47d9 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/NewRoundMessageTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/NewRoundMessageTest.java @@ -17,8 +17,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.NewRound; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -29,7 +28,7 @@ @RunWith(MockitoJUnitRunner.class) public class NewRoundMessageTest { - @Mock private SignedData newRoundPayload; + @Mock private NewRound newRoundPayload; @Mock private BytesValue messageBytes; @Mock private MessageData messageData; @Mock private NewRoundMessageData newRoundMessage; diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/PrepareMessageTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/PrepareMessageTest.java index 1d5364ea63..5ecb0ef175 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/PrepareMessageTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/PrepareMessageTest.java @@ -17,8 +17,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Prepare; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -29,7 +28,7 @@ @RunWith(MockitoJUnitRunner.class) public class PrepareMessageTest { - @Mock private SignedData preparePayload; + @Mock private Prepare preparePayload; @Mock private BytesValue messageBytes; @Mock private MessageData messageData; @Mock private PrepareMessageData prepareMessage; diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/ProposalMessageTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/ProposalMessageTest.java index ecd9f7e1bd..75f66e98f6 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/ProposalMessageTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/ProposalMessageTest.java @@ -17,8 +17,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Proposal; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -29,7 +28,7 @@ @RunWith(MockitoJUnitRunner.class) public class ProposalMessageTest { - @Mock private SignedData proposalMessageData; + @Mock private Proposal proposalMessageData; @Mock private BytesValue messageBytes; @Mock private MessageData messageData; @Mock private ProposalMessageData proposalMessage; diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/RoundChangeMessageTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/RoundChangeMessageTest.java index de4aa00a9d..67e9b74bc5 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/RoundChangeMessageTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/messagedata/RoundChangeMessageTest.java @@ -17,8 +17,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.RoundChange; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -29,7 +28,7 @@ @RunWith(MockitoJUnitRunner.class) public class RoundChangeMessageTest { - @Mock private SignedData roundChangePayload; + @Mock private RoundChange roundChangePayload; @Mock private BytesValue messageBytes; @Mock private MessageData messageData; @Mock private RoundChangeMessageData roundChangeMessage; diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java index 4353285962..9d03303aa4 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java @@ -34,6 +34,11 @@ import tech.pegasys.pantheon.consensus.ibft.messagedata.PrepareMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.ProposalMessageData; import tech.pegasys.pantheon.consensus.ibft.messagedata.RoundChangeMessageData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; +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.payload.CommitPayload; import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; @@ -456,7 +461,7 @@ private void setupProposal( when(signedProposal.getAuthor()).thenReturn(validator); when(proposalPayload.getRoundIdentifier()).thenReturn(roundIdentifier); when(proposalMessageData.getCode()).thenReturn(IbftV2.PROPOSAL); - when(proposalMessageData.decode()).thenReturn(signedProposal); + when(proposalMessageData.decode()).thenReturn(new Proposal(signedProposal)); proposalMessage = new DefaultMessage(null, proposalMessageData); } @@ -466,7 +471,7 @@ private void setupPrepare( when(signedPrepare.getAuthor()).thenReturn(validator); when(preparePayload.getRoundIdentifier()).thenReturn(roundIdentifier); when(prepareMessageData.getCode()).thenReturn(IbftV2.PREPARE); - when(prepareMessageData.decode()).thenReturn(signedPrepare); + when(prepareMessageData.decode()).thenReturn(new Prepare(signedPrepare)); prepareMessage = new DefaultMessage(null, prepareMessageData); } @@ -476,7 +481,7 @@ private void setupCommit( when(signedCommit.getAuthor()).thenReturn(validator); when(commitPayload.getRoundIdentifier()).thenReturn(roundIdentifier); when(commitMessageData.getCode()).thenReturn(IbftV2.COMMIT); - when(commitMessageData.decode()).thenReturn(signedCommit); + when(commitMessageData.decode()).thenReturn(new Commit(signedCommit)); commitMessage = new DefaultMessage(null, commitMessageData); } @@ -486,7 +491,7 @@ private void setupNewRound( when(signedNewRound.getAuthor()).thenReturn(validator); when(newRoundPayload.getRoundIdentifier()).thenReturn(roundIdentifier); when(newRoundMessageData.getCode()).thenReturn(IbftV2.NEW_ROUND); - when(newRoundMessageData.decode()).thenReturn(signedNewRound); + when(newRoundMessageData.decode()).thenReturn(new NewRound(signedNewRound)); newRoundMessage = new DefaultMessage(null, newRoundMessageData); } @@ -496,7 +501,7 @@ private void setupRoundChange( when(signedRoundChange.getAuthor()).thenReturn(validator); when(roundChangePayload.getRoundIdentifier()).thenReturn(roundIdentifier); when(roundChangeMessageData.getCode()).thenReturn(IbftV2.ROUND_CHANGE); - when(roundChangeMessageData.decode()).thenReturn(signedRoundChange); + when(roundChangeMessageData.decode()).thenReturn(new RoundChange(signedRoundChange)); roundChangeMessage = new DefaultMessage(null, roundChangeMessageData); } } From f9b3ca73749fb24fd1aa263926158d2fd32c1d0b Mon Sep 17 00:00:00 2001 From: tmohay Date: Thu, 31 Jan 2019 21:15:44 +1100 Subject: [PATCH 2/3] Updated IbftHeightManager to new msgtypes --- .../ibft/statemachine/BlockHeightManager.java | 25 +++-- .../statemachine/IbftBlockHeightManager.java | 77 +++++++-------- .../ibft/statemachine/IbftController.java | 12 +-- .../statemachine/NoOpBlockHeightManager.java | 21 ++-- .../IbftBlockHeightManagerTest.java | 95 ++++++++++--------- .../ibft/statemachine/IbftControllerTest.java | 76 +++++++-------- 6 files changed, 152 insertions(+), 154 deletions(-) diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/BlockHeightManager.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/BlockHeightManager.java index 5177693ece..b2fa2129c1 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/BlockHeightManager.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/BlockHeightManager.java @@ -14,31 +14,30 @@ import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; import tech.pegasys.pantheon.consensus.ibft.ibftevent.RoundExpiry; -import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; -import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; +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.ethereum.core.BlockHeader; public interface BlockHeightManager { void start(); - void handleBlockTimerExpiry(ConsensusRoundIdentifier roundIdentifier); + void handleBlockTimerExpiry(final ConsensusRoundIdentifier roundIdentifier); - void roundExpired(RoundExpiry expire); + void roundExpired(final RoundExpiry expire); - void handleProposalPayload(SignedData signedPayload); + void handleProposalPayload(final Proposal proposal); - void handlePreparePayload(SignedData signedPayload); + void handlePreparePayload(final Prepare prepare); - void handleCommitPayload(SignedData payload); + void handleCommitPayload(final Commit commit); - void handleRoundChangePayload(SignedData signedPayload); + void handleRoundChangePayload(final RoundChange roundChange); - void handleNewRoundPayload(SignedData signedPayload); + void handleNewRoundPayload(final NewRound newRound); long getChainHeight(); 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 10716e5bf1..2586df2b31 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 @@ -20,16 +20,17 @@ import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; import tech.pegasys.pantheon.consensus.ibft.RoundTimer; import tech.pegasys.pantheon.consensus.ibft.ibftevent.RoundExpiry; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.IbftMessage; +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.network.IbftMessageTransmitter; -import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; -import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; import tech.pegasys.pantheon.consensus.ibft.payload.Payload; -import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; import tech.pegasys.pantheon.consensus.ibft.payload.PreparedCertificate; -import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; 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.validation.MessageValidatorFactory; import tech.pegasys.pantheon.consensus.ibft.validation.NewRoundMessageValidator; @@ -143,9 +144,10 @@ public void roundExpired(final RoundExpiry expire) { startNewRound(currentRound.getRoundIdentifier().getRoundNumber() + 1); - final SignedData localRoundChange = - messageFactory.createSignedRoundChangePayload( - currentRound.getRoundIdentifier(), latestPreparedCertificate); + final RoundChange localRoundChange = + new RoundChange( + messageFactory.createSignedRoundChangePayload( + currentRound.getRoundIdentifier(), latestPreparedCertificate)); transmitter.multicastRoundChange(currentRound.getRoundIdentifier(), latestPreparedCertificate); // Its possible the locally created RoundChange triggers the transmission of a NewRound @@ -154,55 +156,56 @@ public void roundExpired(final RoundExpiry expire) { } @Override - public void handleProposalPayload(final SignedData signedPayload) { + public void handleProposalPayload(final Proposal proposal) { LOG.debug("Received a Proposal Payload."); actionOrBufferMessage( - signedPayload, currentRound::handleProposalMessage, RoundState::setProposedBlock); + proposal, currentRound::handleProposalMessage, RoundState::setProposedBlock); } @Override - public void handlePreparePayload(final SignedData signedPayload) { + public void handlePreparePayload(final Prepare prepare) { LOG.debug("Received a Prepare Payload."); actionOrBufferMessage( - signedPayload, currentRound::handlePrepareMessage, RoundState::addPrepareMessage); + prepare, currentRound::handlePrepareMessage, RoundState::addPrepareMessage); } @Override - public void handleCommitPayload(final SignedData payload) { + public void handleCommitPayload(final Commit commit) { LOG.debug("Received a Commit Payload."); - actionOrBufferMessage(payload, currentRound::handleCommitMessage, RoundState::addCommitMessage); + actionOrBufferMessage(commit, currentRound::handleCommitMessage, RoundState::addCommitMessage); } - private void actionOrBufferMessage( - final SignedData msgData, - final Consumer> inRoundHandler, - final BiConsumer> buffer) { - final Payload payload = msgData.getPayload(); - final MessageAge messageAge = determineAgeOfPayload(payload); + private

> void actionOrBufferMessage( + final M ibftMessage, + final Consumer> inRoundHandler, + final BiConsumer> buffer) { + final MessageAge messageAge = + determineAgeOfPayload(ibftMessage.getRoundIdentifier().getRoundNumber()); if (messageAge == CURRENT_ROUND) { - inRoundHandler.accept(msgData); + inRoundHandler.accept(ibftMessage.getSignedPayload()); } else if (messageAge == FUTURE_ROUND) { - final ConsensusRoundIdentifier msgRoundId = payload.getRoundIdentifier(); + final ConsensusRoundIdentifier msgRoundId = ibftMessage.getRoundIdentifier(); final RoundState roundstate = futureRoundStateBuffer.computeIfAbsent( msgRoundId.getRoundNumber(), k -> roundStateCreator.apply(msgRoundId)); - buffer.accept(roundstate, msgData); + buffer.accept(roundstate, ibftMessage.getSignedPayload()); } } @Override - public void handleRoundChangePayload(final SignedData signedPayload) { - final ConsensusRoundIdentifier targetRound = signedPayload.getPayload().getRoundIdentifier(); + public void handleRoundChangePayload(final RoundChange message) { + final ConsensusRoundIdentifier targetRound = message.getRoundIdentifier(); LOG.info("Received a RoundChange Payload for {}", targetRound.toString()); - final MessageAge messageAge = determineAgeOfPayload(signedPayload.getPayload()); + final MessageAge messageAge = + determineAgeOfPayload(message.getRoundIdentifier().getRoundNumber()); if (messageAge == PRIOR_ROUND) { LOG.debug("Received RoundChange Payload for a prior round. targetRound={}", targetRound); return; } final Optional result = - roundChangeManager.appendRoundChangeMessage(signedPayload); + roundChangeManager.appendRoundChangeMessage(message.getSignedPayload()); if (result.isPresent()) { if (messageAge == FUTURE_ROUND) { startNewRound(targetRound.getRoundNumber()); @@ -230,21 +233,22 @@ private void startNewRound(final int roundNumber) { } @Override - public void handleNewRoundPayload(final SignedData signedPayload) { - final NewRoundPayload payload = signedPayload.getPayload(); - final MessageAge messageAge = determineAgeOfPayload(payload); + public void handleNewRoundPayload(final NewRound newRound) { + // final NewRoundPayload payload = newRound.getSignedPayload().getPayload(); + final MessageAge messageAge = + determineAgeOfPayload(newRound.getRoundIdentifier().getRoundNumber()); if (messageAge == PRIOR_ROUND) { - LOG.info("Received NewRound Payload for a prior round={}", payload.getRoundIdentifier()); + LOG.info("Received NewRound Payload for a prior round={}", newRound.getRoundIdentifier()); return; } - LOG.info("Received NewRound Payload for {}", payload.getRoundIdentifier()); + LOG.info("Received NewRound Payload for {}", newRound.getRoundIdentifier()); - if (newRoundMessageValidator.validateNewRoundMessage(signedPayload)) { + if (newRoundMessageValidator.validateNewRoundMessage(newRound.getSignedPayload())) { if (messageAge == FUTURE_ROUND) { - startNewRound(payload.getRoundIdentifier().getRoundNumber()); + startNewRound(newRound.getRoundIdentifier().getRoundNumber()); } - currentRound.handleProposalFromNewRound(signedPayload); + currentRound.handleProposalFromNewRound(newRound.getSignedPayload()); } } @@ -258,8 +262,7 @@ public BlockHeader getParentBlockHeader() { return parentHeader; } - private MessageAge determineAgeOfPayload(final Payload payload) { - final int messageRoundNumber = payload.getRoundIdentifier().getRoundNumber(); + private MessageAge determineAgeOfPayload(final int messageRoundNumber) { final int currentRoundNumber = currentRound.getRoundIdentifier().getRoundNumber(); if (messageRoundNumber > currentRoundNumber) { return FUTURE_ROUND; diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftController.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftController.java index c673ee81e4..dc4a828541 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftController.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftController.java @@ -29,8 +29,6 @@ import tech.pegasys.pantheon.consensus.ibft.messagedata.RoundChangeMessageData; import tech.pegasys.pantheon.consensus.ibft.messagewrappers.IbftMessage; import tech.pegasys.pantheon.consensus.ibft.payload.Authored; -import tech.pegasys.pantheon.consensus.ibft.payload.Payload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; import tech.pegasys.pantheon.ethereum.chain.Blockchain; import tech.pegasys.pantheon.ethereum.core.BlockHeader; import tech.pegasys.pantheon.ethereum.p2p.api.Message; @@ -132,17 +130,15 @@ private void handleMessage(final Message message) { } } - private

void consumeMessage( - final Message message, - final IbftMessage

ibftMessage, - final Consumer> handleMessage) { + private

> void consumeMessage( + final Message message, final P ibftMessage, final Consumer

handleMessage) { LOG.debug( "Received IBFT message messageType={} payload={}", ibftMessage.getMessageType(), ibftMessage); if (processMessage(ibftMessage, message)) { gossiper.send(message); - handleMessage.accept(ibftMessage.getSignedPayload()); + handleMessage.accept(ibftMessage); } } @@ -205,7 +201,7 @@ private void startNewHeightManager(final BlockHeader parentHeader) { futureMessages.remove(newChainHeight); } - private boolean processMessage(final IbftMessage msg, final Message rawMsg) { + private boolean processMessage(final IbftMessage msg, final Message rawMsg) { final ConsensusRoundIdentifier msgRoundIdentifier = msg.getRoundIdentifier(); if (isMsgForCurrentHeight(msgRoundIdentifier)) { return isMsgFromKnownValidator(msg) && ibftFinalState.isLocalNodeValidator(); diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/NoOpBlockHeightManager.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/NoOpBlockHeightManager.java index 502c5d5af0..e49f0e84f2 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/NoOpBlockHeightManager.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/NoOpBlockHeightManager.java @@ -14,12 +14,11 @@ import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; import tech.pegasys.pantheon.consensus.ibft.ibftevent.RoundExpiry; -import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; -import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; +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.ethereum.core.BlockHeader; public class NoOpBlockHeightManager implements BlockHeightManager { @@ -40,19 +39,19 @@ public void handleBlockTimerExpiry(final ConsensusRoundIdentifier roundIdentifie public void roundExpired(final RoundExpiry expire) {} @Override - public void handleProposalPayload(final SignedData signedPayload) {} + public void handleProposalPayload(final Proposal proposal) {} @Override - public void handlePreparePayload(final SignedData signedPayload) {} + public void handlePreparePayload(final Prepare prepare) {} @Override - public void handleCommitPayload(final SignedData payload) {} + public void handleCommitPayload(final Commit commit) {} @Override - public void handleRoundChangePayload(final SignedData signedPayload) {} + public void handleRoundChangePayload(final RoundChange roundChange) {} @Override - public void handleNewRoundPayload(final SignedData signedPayload) {} + public void handleNewRoundPayload(final NewRound newRound) {} @Override public long getChainHeight() { 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 b44c7e3fef..954b17703c 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 @@ -34,15 +34,14 @@ import tech.pegasys.pantheon.consensus.ibft.RoundTimer; import tech.pegasys.pantheon.consensus.ibft.blockcreation.IbftBlockCreator; import tech.pegasys.pantheon.consensus.ibft.ibftevent.RoundExpiry; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Commit; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.NewRound; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.Prepare; +import tech.pegasys.pantheon.consensus.ibft.messagewrappers.RoundChange; import tech.pegasys.pantheon.consensus.ibft.network.IbftMessageTransmitter; -import tech.pegasys.pantheon.consensus.ibft.payload.CommitPayload; import tech.pegasys.pantheon.consensus.ibft.payload.MessageFactory; -import tech.pegasys.pantheon.consensus.ibft.payload.NewRoundPayload; -import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; import tech.pegasys.pantheon.consensus.ibft.payload.PreparedCertificate; 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.validation.MessageValidator; import tech.pegasys.pantheon.consensus.ibft.validation.MessageValidatorFactory; import tech.pegasys.pantheon.consensus.ibft.validation.NewRoundMessageValidator; @@ -217,10 +216,12 @@ public void onBlockTimerExpiryProposalMessageIsTransmitted() { @Test public void onRoundChangeReceptionRoundChangeManagerIsInvokedAndNewRoundStarted() { final ConsensusRoundIdentifier futureRoundIdentifier = createFrom(roundIdentifier, 0, +2); - final SignedData roundChangePayload = - messageFactory.createSignedRoundChangePayload(futureRoundIdentifier, Optional.empty()); + final RoundChange roundChange = + new RoundChange( + messageFactory.createSignedRoundChangePayload(futureRoundIdentifier, Optional.empty())); when(roundChangeManager.appendRoundChangeMessage(any())) - .thenReturn(Optional.of(new RoundChangeCertificate(singletonList(roundChangePayload)))); + .thenReturn( + Optional.of(new RoundChangeCertificate(singletonList(roundChange.getSignedPayload())))); when(finalState.isLocalNodeProposerForRound(any())).thenReturn(false); final IbftBlockHeightManager manager = @@ -234,9 +235,9 @@ public void onRoundChangeReceptionRoundChangeManagerIsInvokedAndNewRoundStarted( manager.start(); verify(roundFactory).createNewRound(any(), eq(0)); - manager.handleRoundChangePayload(roundChangePayload); + manager.handleRoundChangePayload(roundChange); - verify(roundChangeManager, times(1)).appendRoundChangeMessage(roundChangePayload); + verify(roundChangeManager, times(1)).appendRoundChangeMessage(roundChange.getSignedPayload()); verify(roundFactory, times(1)) .createNewRound(any(), eq(futureRoundIdentifier.getRoundNumber())); } @@ -261,10 +262,11 @@ public void onRoundTimerExpiryANewRoundIsCreatedWithAnIncrementedRoundNumber() { @Test public void whenSufficientRoundChangesAreReceivedANewRoundMessageIsTransmitted() { final ConsensusRoundIdentifier futureRoundIdentifier = createFrom(roundIdentifier, 0, +2); - final SignedData roundChangePayload = - messageFactory.createSignedRoundChangePayload(futureRoundIdentifier, Optional.empty()); + final RoundChange roundChange = + new RoundChange( + messageFactory.createSignedRoundChangePayload(futureRoundIdentifier, Optional.empty())); final RoundChangeCertificate roundChangCert = - new RoundChangeCertificate(singletonList(roundChangePayload)); + new RoundChangeCertificate(singletonList(roundChange.getSignedPayload())); when(roundChangeManager.appendRoundChangeMessage(any())) .thenReturn(Optional.of(roundChangCert)); @@ -280,7 +282,7 @@ public void whenSufficientRoundChangesAreReceivedANewRoundMessageIsTransmitted() messageValidatorFactory); manager.start(); - manager.handleRoundChangePayload(roundChangePayload); + manager.handleRoundChangePayload(roundChange); verify(messageTransmitter, times(1)) .multicastNewRound(eq(futureRoundIdentifier), eq(roundChangCert), any()); @@ -300,27 +302,30 @@ public void messagesForFutureRoundsAreBufferedAndUsedToPreloadNewRoundWhenItIsSt messageValidatorFactory); manager.start(); - final SignedData preparePayload = - validatorMessageFactory - .get(0) - .createSignedPreparePayload(futureRoundIdentifier, Hash.fromHexStringLenient("0")); - final SignedData commitPayload = - validatorMessageFactory - .get(1) - .createSignedCommitPayload( - futureRoundIdentifier, - Hash.fromHexStringLenient("0"), - Signature.create(BigInteger.ONE, BigInteger.ONE, (byte) 1)); - - manager.handlePreparePayload(preparePayload); - manager.handleCommitPayload(commitPayload); + final Prepare prepare = + new Prepare( + validatorMessageFactory + .get(0) + .createSignedPreparePayload(futureRoundIdentifier, Hash.fromHexStringLenient("0"))); + final Commit commit = + new Commit( + validatorMessageFactory + .get(1) + .createSignedCommitPayload( + futureRoundIdentifier, + Hash.fromHexStringLenient("0"), + Signature.create(BigInteger.ONE, BigInteger.ONE, (byte) 1))); + + manager.handlePreparePayload(prepare); + manager.handleCommitPayload(commit); // Force a new round to be started at new round number. - final SignedData newRound = - messageFactory.createSignedNewRoundPayload( - futureRoundIdentifier, - new RoundChangeCertificate(Collections.emptyList()), - messageFactory.createSignedProposalPayload(futureRoundIdentifier, createdBlock)); + final NewRound newRound = + new NewRound( + messageFactory.createSignedNewRoundPayload( + futureRoundIdentifier, + new RoundChangeCertificate(Collections.emptyList()), + messageFactory.createSignedProposalPayload(futureRoundIdentifier, createdBlock))); manager.handleNewRoundPayload(newRound); @@ -342,16 +347,18 @@ public void preparedCertificateIncludedInRoundChangeMessageOnRoundTimeoutExpired manager.start(); manager.handleBlockTimerExpiry(roundIdentifier); // Trigger a Proposal creation. - final SignedData preparePayload = - validatorMessageFactory - .get(0) - .createSignedPreparePayload(roundIdentifier, Hash.fromHexStringLenient("0")); - final SignedData secondPreparePayload = - validatorMessageFactory - .get(1) - .createSignedPreparePayload(roundIdentifier, Hash.fromHexStringLenient("0")); - manager.handlePreparePayload(preparePayload); - manager.handlePreparePayload(secondPreparePayload); + final Prepare firstPrepare = + new Prepare( + validatorMessageFactory + .get(0) + .createSignedPreparePayload(roundIdentifier, Hash.fromHexStringLenient("0"))); + final Prepare secondPrepare = + new Prepare( + validatorMessageFactory + .get(1) + .createSignedPreparePayload(roundIdentifier, Hash.fromHexStringLenient("0"))); + manager.handlePreparePayload(firstPrepare); + manager.handlePreparePayload(secondPrepare); manager.roundExpired(new RoundExpiry(roundIdentifier)); @@ -364,6 +371,6 @@ public void preparedCertificateIncludedInRoundChangeMessageOnRoundTimeoutExpired assertThat(preparedCert).isNotEmpty(); assertThat(preparedCert.get().getPreparePayloads()) - .containsOnly(preparePayload, secondPreparePayload); + .containsOnly(firstPrepare.getSignedPayload(), secondPrepare.getSignedPayload()); } } diff --git a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java index 9d03303aa4..276b70f787 100644 --- a/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java +++ b/consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/statemachine/IbftControllerTest.java @@ -44,7 +44,6 @@ import tech.pegasys.pantheon.consensus.ibft.payload.PreparePayload; import tech.pegasys.pantheon.consensus.ibft.payload.ProposalPayload; import tech.pegasys.pantheon.consensus.ibft.payload.RoundChangePayload; -import tech.pegasys.pantheon.consensus.ibft.payload.SignedData; import tech.pegasys.pantheon.ethereum.chain.Blockchain; import tech.pegasys.pantheon.ethereum.core.Address; import tech.pegasys.pantheon.ethereum.core.BlockHeader; @@ -73,27 +72,27 @@ public class IbftControllerTest { @Mock private BlockHeader nextBlock; @Mock private BlockHeightManager blockHeightManager; - @Mock private SignedData signedProposal; + @Mock private Proposal proposal; private Message proposalMessage; @Mock private ProposalMessageData proposalMessageData; @Mock private ProposalPayload proposalPayload; - @Mock private SignedData signedPrepare; + @Mock private Prepare prepare; private Message prepareMessage; @Mock private PrepareMessageData prepareMessageData; @Mock private PreparePayload preparePayload; - @Mock private SignedData signedCommit; + @Mock private Commit commit; private Message commitMessage; @Mock private CommitMessageData commitMessageData; @Mock private CommitPayload commitPayload; - @Mock private SignedData signedNewRound; + @Mock private NewRound newRound; private Message newRoundMessage; @Mock private NewRoundMessageData newRoundMessageData; @Mock private NewRoundPayload newRoundPayload; - @Mock private SignedData signedRoundChange; + @Mock private RoundChange roundChange; private Message roundChangeMessage; @Mock private RoundChangeMessageData roundChangeMessageData; @Mock private RoundChangePayload roundChangePayload; @@ -154,14 +153,14 @@ public void startsNewBlockHeightManagerAndReplaysFutureMessages() { verify(blockHeightManagerFactory).create(chainHeadBlockHeader); verify(blockHeightManager, atLeastOnce()).getChainHeight(); verify(blockHeightManager).start(); - verify(blockHeightManager, never()).handleProposalPayload(signedProposal); - verify(blockHeightManager).handlePreparePayload(signedPrepare); + verify(blockHeightManager, never()).handleProposalPayload(proposal); + verify(blockHeightManager).handlePreparePayload(prepare); verify(ibftGossip).send(prepareMessage); - verify(blockHeightManager).handleCommitPayload(signedCommit); + verify(blockHeightManager).handleCommitPayload(commit); verify(ibftGossip).send(commitMessage); - verify(blockHeightManager).handleRoundChangePayload(signedRoundChange); + verify(blockHeightManager).handleRoundChangePayload(roundChange); verify(ibftGossip).send(roundChangeMessage); - verify(blockHeightManager, never()).handleNewRoundPayload(signedNewRound); + verify(blockHeightManager, never()).handleNewRoundPayload(newRound); } @Test @@ -185,15 +184,15 @@ public void createsNewBlockHeightManagerAndReplaysFutureMessagesOnNewChainHeadEv verify(blockHeightManagerFactory).create(nextBlock); verify(blockHeightManager, atLeastOnce()).getChainHeight(); verify(blockHeightManager, times(2)).start(); // once at beginning, and again on newChainHead. - verify(blockHeightManager).handleProposalPayload(signedProposal); + verify(blockHeightManager).handleProposalPayload(proposal); verify(ibftGossip).send(proposalMessage); - verify(blockHeightManager).handlePreparePayload(signedPrepare); + verify(blockHeightManager).handlePreparePayload(prepare); verify(ibftGossip).send(prepareMessage); - verify(blockHeightManager).handleCommitPayload(signedCommit); + verify(blockHeightManager).handleCommitPayload(commit); verify(ibftGossip).send(commitMessage); - verify(blockHeightManager).handleRoundChangePayload(signedRoundChange); + verify(blockHeightManager).handleRoundChangePayload(roundChange); verify(ibftGossip).send(roundChangeMessage); - verify(blockHeightManager).handleNewRoundPayload(signedNewRound); + verify(blockHeightManager).handleNewRoundPayload(newRound); verify(ibftGossip).send(newRoundMessage); } @@ -243,7 +242,7 @@ public void proposalForCurrentHeightIsPassedToBlockHeightManager() { ibftController.handleMessageEvent(new IbftReceivedMessageEvent(proposalMessage)); assertThat(futureMessages).isEmpty(); - verify(blockHeightManager).handleProposalPayload(signedProposal); + verify(blockHeightManager).handleProposalPayload(proposal); verify(ibftGossip).send(proposalMessage); verify(blockHeightManager, atLeastOnce()).getChainHeight(); verify(blockHeightManager).start(); @@ -257,7 +256,7 @@ public void prepareForCurrentHeightIsPassedToBlockHeightManager() { ibftController.handleMessageEvent(new IbftReceivedMessageEvent(prepareMessage)); assertThat(futureMessages).isEmpty(); - verify(blockHeightManager).handlePreparePayload(signedPrepare); + verify(blockHeightManager).handlePreparePayload(prepare); verify(ibftGossip).send(prepareMessage); verify(blockHeightManager, atLeastOnce()).getChainHeight(); verify(blockHeightManager).start(); @@ -271,7 +270,7 @@ public void commitForCurrentHeightIsPassedToBlockHeightManager() { ibftController.handleMessageEvent(new IbftReceivedMessageEvent(commitMessage)); assertThat(futureMessages).isEmpty(); - verify(blockHeightManager).handleCommitPayload(signedCommit); + verify(blockHeightManager).handleCommitPayload(commit); verify(ibftGossip).send(commitMessage); verify(blockHeightManager, atLeastOnce()).getChainHeight(); verify(blockHeightManager).start(); @@ -286,7 +285,7 @@ public void newRoundForCurrentHeightIsPassedToBlockHeightManager() { ibftController.handleMessageEvent(new IbftReceivedMessageEvent(newRoundMessage)); assertThat(futureMessages).isEmpty(); - verify(blockHeightManager).handleNewRoundPayload(signedNewRound); + verify(blockHeightManager).handleNewRoundPayload(newRound); verify(ibftGossip).send(newRoundMessage); verify(blockHeightManager, atLeastOnce()).getChainHeight(); verify(blockHeightManager).start(); @@ -301,7 +300,7 @@ public void roundChangeForCurrentHeightIsPassedToBlockHeightManager() { ibftController.handleMessageEvent(new IbftReceivedMessageEvent(roundChangeMessage)); assertThat(futureMessages).isEmpty(); - verify(blockHeightManager).handleRoundChangePayload(signedRoundChange); + verify(blockHeightManager).handleRoundChangePayload(roundChange); verify(ibftGossip).send(roundChangeMessage); verify(blockHeightManager, atLeastOnce()).getChainHeight(); verify(blockHeightManager).start(); @@ -457,51 +456,46 @@ private void verifyHasFutureMessages( private void setupProposal( final ConsensusRoundIdentifier roundIdentifier, final Address validator) { - when(signedProposal.getPayload()).thenReturn(proposalPayload); - when(signedProposal.getAuthor()).thenReturn(validator); - when(proposalPayload.getRoundIdentifier()).thenReturn(roundIdentifier); + when(proposal.getAuthor()).thenReturn(validator); + when(proposal.getRoundIdentifier()).thenReturn(roundIdentifier); when(proposalMessageData.getCode()).thenReturn(IbftV2.PROPOSAL); - when(proposalMessageData.decode()).thenReturn(new Proposal(signedProposal)); + when(proposalMessageData.decode()).thenReturn(proposal); proposalMessage = new DefaultMessage(null, proposalMessageData); } private void setupPrepare( final ConsensusRoundIdentifier roundIdentifier, final Address validator) { - when(signedPrepare.getPayload()).thenReturn(preparePayload); - when(signedPrepare.getAuthor()).thenReturn(validator); - when(preparePayload.getRoundIdentifier()).thenReturn(roundIdentifier); + when(prepare.getAuthor()).thenReturn(validator); + when(prepare.getRoundIdentifier()).thenReturn(roundIdentifier); when(prepareMessageData.getCode()).thenReturn(IbftV2.PREPARE); - when(prepareMessageData.decode()).thenReturn(new Prepare(signedPrepare)); + when(prepareMessageData.decode()).thenReturn(prepare); prepareMessage = new DefaultMessage(null, prepareMessageData); } private void setupCommit( final ConsensusRoundIdentifier roundIdentifier, final Address validator) { - when(signedCommit.getPayload()).thenReturn(commitPayload); - when(signedCommit.getAuthor()).thenReturn(validator); - when(commitPayload.getRoundIdentifier()).thenReturn(roundIdentifier); + when(commit.getAuthor()).thenReturn(validator); + when(commit.getRoundIdentifier()).thenReturn(roundIdentifier); when(commitMessageData.getCode()).thenReturn(IbftV2.COMMIT); - when(commitMessageData.decode()).thenReturn(new Commit(signedCommit)); + when(commitMessageData.decode()).thenReturn(commit); commitMessage = new DefaultMessage(null, commitMessageData); } private void setupNewRound( final ConsensusRoundIdentifier roundIdentifier, final Address validator) { - when(signedNewRound.getPayload()).thenReturn(newRoundPayload); - when(signedNewRound.getAuthor()).thenReturn(validator); - when(newRoundPayload.getRoundIdentifier()).thenReturn(roundIdentifier); + when(newRound.getAuthor()).thenReturn(validator); + when(newRound.getRoundIdentifier()).thenReturn(roundIdentifier); when(newRoundMessageData.getCode()).thenReturn(IbftV2.NEW_ROUND); - when(newRoundMessageData.decode()).thenReturn(new NewRound(signedNewRound)); + when(newRoundMessageData.decode()).thenReturn(newRound); newRoundMessage = new DefaultMessage(null, newRoundMessageData); } private void setupRoundChange( final ConsensusRoundIdentifier roundIdentifier, final Address validator) { - when(signedRoundChange.getPayload()).thenReturn(roundChangePayload); - when(signedRoundChange.getAuthor()).thenReturn(validator); - when(roundChangePayload.getRoundIdentifier()).thenReturn(roundIdentifier); + when(roundChange.getAuthor()).thenReturn(validator); + when(roundChange.getRoundIdentifier()).thenReturn(roundIdentifier); when(roundChangeMessageData.getCode()).thenReturn(IbftV2.ROUND_CHANGE); - when(roundChangeMessageData.decode()).thenReturn(new RoundChange(signedRoundChange)); + when(roundChangeMessageData.decode()).thenReturn(roundChange); roundChangeMessage = new DefaultMessage(null, roundChangeMessageData); } } From 3fdf76880762d2fe480c53ff6f1fe38e28f2412f Mon Sep 17 00:00:00 2001 From: tmohay Date: Fri, 1 Feb 2019 14:27:57 +1100 Subject: [PATCH 3/3] Removed final from interface --- .../ibft/statemachine/BlockHeightManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/BlockHeightManager.java b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/BlockHeightManager.java index b2fa2129c1..018b0d5979 100644 --- a/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/BlockHeightManager.java +++ b/consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/BlockHeightManager.java @@ -25,19 +25,19 @@ public interface BlockHeightManager { void start(); - void handleBlockTimerExpiry(final ConsensusRoundIdentifier roundIdentifier); + void handleBlockTimerExpiry(ConsensusRoundIdentifier roundIdentifier); - void roundExpired(final RoundExpiry expire); + void roundExpired(RoundExpiry expire); - void handleProposalPayload(final Proposal proposal); + void handleProposalPayload(Proposal proposal); - void handlePreparePayload(final Prepare prepare); + void handlePreparePayload(Prepare prepare); - void handleCommitPayload(final Commit commit); + void handleCommitPayload(Commit commit); - void handleRoundChangePayload(final RoundChange roundChange); + void handleRoundChangePayload(RoundChange roundChange); - void handleNewRoundPayload(final NewRound newRound); + void handleNewRoundPayload(NewRound newRound); long getChainHeight();