This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ibft notifies EthPeer when remote node has a better block (#849)
There is a failure mode of IBFT whereby a validator fails to import a block, and also fails to receive the NewBlock message from its peers. This means said validator is unable to participate in subsequent rounds, and may cause the network to halt. To overcome this issue, if an IBFT validator receives messages from a future height, it will update the "BestEstimatedHeight" of the corresponding EthPeer object, such that the Synchroniser will (eventually) download the requisite blocks - thus allowing the IBFT network to continue to operate.
- Loading branch information
Showing
13 changed files
with
282 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...on-test/java/tech/pegasys/pantheon/consensus/ibft/support/StubbedSynchronizerUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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.support; | ||
|
||
import static java.util.function.Function.identity; | ||
|
||
import tech.pegasys.pantheon.consensus.ibft.SynchronizerUpdater; | ||
import tech.pegasys.pantheon.ethereum.p2p.api.PeerConnection; | ||
|
||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
public class StubbedSynchronizerUpdater implements SynchronizerUpdater { | ||
|
||
private Map<PeerConnection, ValidatorPeer> validatorNodes = new HashMap<>(); | ||
|
||
@Override | ||
public void updatePeerChainState( | ||
final long knownBlockNumber, final PeerConnection peerConnection) { | ||
validatorNodes.get(peerConnection).updateEstimatedChainHeight(knownBlockNumber); | ||
} | ||
|
||
public void addNetworkPeers(final Collection<ValidatorPeer> nodes) { | ||
validatorNodes.putAll( | ||
nodes.stream().collect(Collectors.toMap(ValidatorPeer::getPeerConnection, identity()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...ensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/EthSynchronizerUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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; | ||
|
||
import static org.apache.logging.log4j.LogManager.getLogger; | ||
|
||
import tech.pegasys.pantheon.ethereum.eth.manager.EthPeer; | ||
import tech.pegasys.pantheon.ethereum.eth.manager.EthPeers; | ||
import tech.pegasys.pantheon.ethereum.p2p.api.PeerConnection; | ||
|
||
import org.apache.logging.log4j.Logger; | ||
|
||
public class EthSynchronizerUpdater implements SynchronizerUpdater { | ||
|
||
private static final Logger LOG = getLogger(); | ||
private final EthPeers ethPeers; | ||
|
||
public EthSynchronizerUpdater(final EthPeers ethPeers) { | ||
this.ethPeers = ethPeers; | ||
} | ||
|
||
@Override | ||
public void updatePeerChainState( | ||
final long knownBlockNumber, final PeerConnection peerConnection) { | ||
final EthPeer ethPeer = ethPeers.peer(peerConnection); | ||
if (ethPeer == null) { | ||
LOG.debug("Received message from a peer with no corresponding EthPeer."); | ||
return; | ||
} | ||
ethPeer.chainState().updateHeightEstimate(knownBlockNumber); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/SynchronizerUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
import tech.pegasys.pantheon.ethereum.p2p.api.PeerConnection; | ||
|
||
public interface SynchronizerUpdater { | ||
|
||
void updatePeerChainState(long knownBlockNumber, PeerConnection peerConnection); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.