mirror of https://github.com/hyperledger/besu
IBFT ensure non-validator does not partake in consensus (#627)
Nodes which are not validators in a network should not inject IBFT messages to the consensus round, and should not gossip received messages. I.e. all events should ensure that they are only handled if the node is a validator at the current height. Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>pull/2/head
parent
a1ef038865
commit
cde9425cfb
@ -0,0 +1,46 @@ |
|||||||
|
/* |
||||||
|
* 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.statemachine; |
||||||
|
|
||||||
|
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.ethereum.core.BlockHeader; |
||||||
|
|
||||||
|
public interface BlockHeightManager { |
||||||
|
|
||||||
|
void start(); |
||||||
|
|
||||||
|
void handleBlockTimerExpiry(ConsensusRoundIdentifier roundIdentifier); |
||||||
|
|
||||||
|
void roundExpired(RoundExpiry expire); |
||||||
|
|
||||||
|
void handleProposalPayload(SignedData<ProposalPayload> signedPayload); |
||||||
|
|
||||||
|
void handlePreparePayload(SignedData<PreparePayload> signedPayload); |
||||||
|
|
||||||
|
void handleCommitPayload(SignedData<CommitPayload> payload); |
||||||
|
|
||||||
|
void handleRoundChangePayload(SignedData<RoundChangePayload> signedPayload); |
||||||
|
|
||||||
|
void handleNewRoundPayload(SignedData<NewRoundPayload> signedPayload); |
||||||
|
|
||||||
|
long getChainHeight(); |
||||||
|
|
||||||
|
BlockHeader getParentBlockHeader(); |
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
/* |
||||||
|
* 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.statemachine; |
||||||
|
|
||||||
|
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.ethereum.core.BlockHeader; |
||||||
|
|
||||||
|
public class NoOpBlockHeightManager implements BlockHeightManager { |
||||||
|
|
||||||
|
private final BlockHeader parentHeader; |
||||||
|
|
||||||
|
public NoOpBlockHeightManager(final BlockHeader parentHeader) { |
||||||
|
this.parentHeader = parentHeader; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void start() {} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void handleBlockTimerExpiry(final ConsensusRoundIdentifier roundIdentifier) {} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void roundExpired(final RoundExpiry expire) {} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void handleProposalPayload(final SignedData<ProposalPayload> signedPayload) {} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void handlePreparePayload(final SignedData<PreparePayload> signedPayload) {} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void handleCommitPayload(final SignedData<CommitPayload> payload) {} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void handleRoundChangePayload(final SignedData<RoundChangePayload> signedPayload) {} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void handleNewRoundPayload(final SignedData<NewRoundPayload> signedPayload) {} |
||||||
|
|
||||||
|
@Override |
||||||
|
public long getChainHeight() { |
||||||
|
return parentHeader.getNumber() + 1; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BlockHeader getParentBlockHeader() { |
||||||
|
return parentHeader; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue