Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAN-3202][BESU-37] Implement EIP-2124 #156

Merged
merged 59 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5db0202
edits to test names (#153)
macfarla Nov 4, 2019
3ac0ef5
Moving JsonRpcMethods classes into the same package, prior to refacto…
CjHare Nov 4, 2019
a416b4e
Add --identity flag for client identification in node browsers (#150)
shemnon Nov 4, 2019
a26c73e
[PAN-3202] add basic forkId (eip-2124) creation class and related test
SteveMieskoski Nov 4, 2019
7e38ff5
[PAN-2798] Enable pruning by default for fast sync (#135)
RatanRSur Nov 4, 2019
5349e18
commenting out circles publish on the release branch so we're ready f…
joshuafernandes Nov 5, 2019
46329a2
fix style to properly conform
SteveMieskoski Nov 5, 2019
32ca662
Redesign of how JsonRpcMethods are created (#159)
CjHare Nov 5, 2019
b89494f
remove print statement from forkId
SteveMieskoski Nov 5, 2019
138d030
check protocol version and bypass at present until eth protocol with …
SteveMieskoski Nov 5, 2019
b222e1b
Merge branch 'master' into eip-2124
SteveMieskoski Nov 5, 2019
935e1ec
commit suggestion to param description
SteveMieskoski Nov 7, 2019
288f26f
Merge remote-tracking branch 'origin/eip-2124' into eip-2124
SteveMieskoski Nov 11, 2019
65e66d3
Merge branch 'master' into eip-2124
SteveMieskoski Nov 16, 2019
1882dcb
change forkId to forkIdManager, idEntry to ForkId, modify statusMessa…
SteveMieskoski Nov 17, 2019
27c42ff
include forkId in statusMessage class, move fork collection to genesi…
SteveMieskoski Nov 29, 2019
4d07927
Merge branch 'master' into eip-2124
SteveMieskoski Nov 29, 2019
fb9cde1
clean up unused imports and remove some comments related to forkId
SteveMieskoski Nov 29, 2019
cbef3e9
eip-2124 RLP encoding checks pass, store next block number as bytesValue
SteveMieskoski Nov 30, 2019
9c946a8
eip-2124 RLP encoding checks pass, store next block number as bytesVa…
SteveMieskoski Nov 30, 2019
35f012f
remove redundant methods in forkId and modify fork collection to use …
SteveMieskoski Nov 30, 2019
2de97a8
Merge pull request #1 from SteveMieskoski/eip-2364
SteveMieskoski Nov 30, 2019
2597ac9
needed to lint prior commit
SteveMieskoski Nov 30, 2019
0da2285
Merge branch 'eip-2364' into eip-2124
SteveMieskoski Nov 30, 2019
5b5cac6
correct forkId test
SteveMieskoski Nov 30, 2019
14e56ba
reduce duplication, and check getForks order
SteveMieskoski Dec 3, 2019
36cbe98
replace ArrayDeque usage with ArrayList
SteveMieskoski Dec 4, 2019
ea69e62
lint via spotlessApply
SteveMieskoski Dec 4, 2019
6ef9548
enforce exhaustiveness of fork sequence in test
RatanRSur Dec 3, 2019
b3601da
remove commented code
RatanRSur Dec 3, 2019
a1fb990
asserts
RatanRSur Dec 3, 2019
c226b3a
immutable list
RatanRSur Dec 3, 2019
1dd5486
functional style
RatanRSur Dec 3, 2019
2280d86
Math.max
RatanRSur Dec 4, 2019
1bdeb0b
add final
RatanRSur Dec 4, 2019
1130695
rename
RatanRSur Dec 4, 2019
4b7a090
cleanup fork generation
RatanRSur Dec 8, 2019
5839ecd
visible for testing
RatanRSur Dec 9, 2019
b68a84d
spotless
RatanRSur Dec 9, 2019
28d507e
add ordering to get forks test
RatanRSur Dec 9, 2019
4d4b187
remove unused methods
RatanRSur Dec 10, 2019
23e75dc
Merge pull request #2 from RatanRSur/eip-2124
SteveMieskoski Dec 12, 2019
7883f10
Merge branch 'master' into eip-2124
SteveMieskoski Dec 12, 2019
5486679
Merge branch 'master' into eip-2124
SteveMieskoski Dec 18, 2019
23d12fd
Merge branch 'master' into eip-2124
SteveMieskoski Dec 30, 2019
f72f0e4
update to use tuweni bytes
SteveMieskoski Dec 31, 2019
fcd87db
ran spotlessJava
SteveMieskoski Dec 31, 2019
4463ca4
add missing item to StatusMessage.java to fix failing test
SteveMieskoski Dec 31, 2019
f85d693
Merge branch 'master' into eip-2124
RatanRSur Jan 8, 2020
992a156
fix ci failure from forkId
SteveMieskoski Jan 8, 2020
4268b8e
re-fix ci failure from forkId
SteveMieskoski Jan 8, 2020
c93769c
fix getLatestForkId out of bounds error
SteveMieskoski Jan 8, 2020
93ce270
Merge remote-tracking branch 'upstream/master' into eip-2124
SteveMieskoski Jan 8, 2020
203ee57
Merge branch 'master' into eip-2124
SteveMieskoski Jan 8, 2020
1547427
change method used to get byte array
SteveMieskoski Jan 9, 2020
758e950
Merge remote-tracking branch 'origin/eip-2124' into eip-2124
SteveMieskoski Jan 9, 2020
b7e4c83
Merge remote-tracking branch 'upstream/master' into eip-2124
SteveMieskoski Jan 9, 2020
bfa9efe
Merge branch 'master' into eip-2124
SteveMieskoski Jan 9, 2020
fa0b5d4
Merge branch 'master' into eip-2124
RatanRSur Jan 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ protected EthProtocolManager createEthProtocolManager(
syncConfig.getComputationParallelism(),
clock,
metricsSystem,
ethereumWireProtocolConfiguration);
ethereumWireProtocolConfiguration,
gatherForks());
}

private List<PeerValidator> createPeerValidators(final ProtocolSchedule<C> protocolSchedule) {
Expand All @@ -372,4 +373,18 @@ private List<PeerValidator> createPeerValidators(final ProtocolSchedule<C> proto

protected abstract PluginServiceFactory createAdditionalPluginServices(
final Blockchain blockchain);

private List<Long> gatherForks() {
// todo: may need to check what protocol version is being used. (i.e. if less than x return null
// to disable this check)
List<Long> listb = new ArrayList<>();
Map<String, Object> values = genesisConfig.getConfigOptions(genesisConfigOverrides).asMap();
values.forEach(
(x, y) -> {
if (y instanceof Long && !x.equals("chainId")) {
listb.add((Long) y);
}
});
return listb;
RatanRSur marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ public static EthProtocol get() {
public static class EthVersion {
public static final int V62 = 62;
public static final int V63 = 63;
public static final int V64 = 64;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver {
private final AtomicBoolean stopped = new AtomicBoolean(false);

private final Hash genesisHash;
private final ForkId forkId;
private final BigInteger networkId;
private final EthPeers ethPeers;
private final EthMessages ethMessages;
Expand Down Expand Up @@ -91,6 +92,8 @@ public EthProtocolManager(
this.shutdown = new CountDownLatch(1);
genesisHash = blockchain.getBlockHashByNumber(0L).get();

forkId = ForkId.buildCollection(genesisHash);

ethPeers = new EthPeers(getSupportedProtocol(), clock, metricsSystem);
ethMessages = new EthMessages();
ethContext = new EthContext(ethPeers, ethMessages, scheduler);
Expand Down Expand Up @@ -153,6 +156,46 @@ public EthProtocolManager(
metricsSystem);
}

public EthProtocolManager(
final Blockchain blockchain,
final WorldStateArchive worldStateArchive,
final BigInteger networkId,
final List<PeerValidator> peerValidators,
final boolean fastSyncEnabled,
final int syncWorkers,
final int txWorkers,
final int computationWorkers,
final Clock clock,
final MetricsSystem metricsSystem,
final EthProtocolConfiguration ethereumWireProtocolConfiguration,
final List<Long> forks) {
this.networkId = networkId;
this.peerValidators = peerValidators;
this.scheduler = new EthScheduler(syncWorkers, txWorkers, computationWorkers, metricsSystem);
this.blockchain = blockchain;
this.fastSyncEnabled = fastSyncEnabled;

this.shutdown = new CountDownLatch(1);
genesisHash = blockchain.getBlockHashByNumber(0L).get();

// todo: check about modification of the above and related constructor
forkId = ForkId.buildCollection(genesisHash, forks, blockchain, getSupportedCapabilities());

ethPeers = new EthPeers(getSupportedProtocol(), clock, metricsSystem);
ethMessages = new EthMessages();
ethContext = new EthContext(ethPeers, ethMessages, scheduler);

this.blockBroadcaster = new BlockBroadcaster(ethContext);

// Run validators
for (final PeerValidator peerValidator : this.peerValidators) {
PeerValidatorRunner.runValidator(ethContext, peerValidator);
}

// Set up request handlers
new EthServer(blockchain, worldStateArchive, ethMessages, ethereumWireProtocolConfiguration);
}

public EthContext ethContext() {
return ethContext;
}
Expand Down Expand Up @@ -247,7 +290,7 @@ public void handleNewConnection(final PeerConnection connection) {
networkId,
blockchain.getChainHead().getTotalDifficulty(),
blockchain.getChainHeadHash(),
genesisHash);
forkId.getLatestForkId(cap.getVersion()));
try {
LOG.debug("Sending status message to {}.", peer);
peer.send(status);
Expand Down Expand Up @@ -284,7 +327,7 @@ private void handleStatusMessage(final EthPeer peer, final MessageData data) {
if (!status.networkId().equals(networkId)) {
LOG.debug("Disconnecting from peer with mismatched network id: {}", status.networkId());
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED);
} else if (!status.genesisHash().equals(genesisHash)) {
} else if (forkId.peerCheck(status.genesisHash())) {
LOG.debug(
"Disconnecting from peer with matching network id ({}), but non-matching genesis hash: {}",
networkId,
Expand Down
Loading