Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ allprojects {
}

repositories {
mavenLocal()
jcenter()
maven { url "https://jitpack.io" }
}

task allDependencies(type: DependencyReportTask) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import org.apache.logging.log4j.Logger;
import org.ethereum.beacon.chain.storage.BeaconChainStorage;
import org.ethereum.beacon.chain.storage.BeaconTupleStorage;
import org.ethereum.beacon.consensus.BeaconChainSpec;
import org.ethereum.beacon.consensus.BeaconStateEx;
import org.ethereum.beacon.consensus.BlockTransition;
import org.ethereum.beacon.consensus.BeaconChainSpec;
import org.ethereum.beacon.consensus.transition.EmptySlotTransition;
import org.ethereum.beacon.consensus.verifier.BeaconBlockVerifier;
import org.ethereum.beacon.consensus.verifier.BeaconStateVerifier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.ethereum.beacon.chain;

import java.util.Collections;
import java.util.stream.IntStream;
import org.ethereum.beacon.chain.MutableBeaconChain.ImportResult;
import org.ethereum.beacon.chain.storage.BeaconChainStorage;
import org.ethereum.beacon.chain.storage.impl.SSZBeaconChainStorageFactory;
Expand Down Expand Up @@ -32,9 +34,6 @@
import tech.pegasys.artemis.ethereum.core.Hash32;
import tech.pegasys.artemis.util.uint.UInt64;

import java.util.Collections;
import java.util.stream.IntStream;

public class DefaultBeaconChainTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.ethereum.beacon.chain.storage.util.StorageUtils;
import org.ethereum.beacon.consensus.BeaconChainSpec;
import org.ethereum.beacon.consensus.BeaconStateEx;
import org.ethereum.beacon.consensus.ChainStart;
import org.ethereum.beacon.consensus.StateTransitions;
import org.ethereum.beacon.consensus.TestUtils;
import org.ethereum.beacon.consensus.transition.EmptySlotTransition;
Expand All @@ -30,7 +31,6 @@
import org.ethereum.beacon.core.types.Time;
import org.ethereum.beacon.crypto.BLS381.KeyPair;
import org.ethereum.beacon.db.InMemoryDatabase;
import org.ethereum.beacon.consensus.ChainStart;
import org.ethereum.beacon.schedulers.Schedulers;
import org.javatuples.Pair;
import org.reactivestreams.Publisher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import io.prometheus.client.Counter;
import io.prometheus.client.Gauge;
import io.prometheus.client.exporter.HTTPServer;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.ethereum.beacon.chain.observer.ObservableBeaconState;
import org.ethereum.beacon.consensus.BeaconChainSpec;
import org.ethereum.beacon.consensus.BeaconStateEx;
Expand All @@ -12,11 +16,6 @@
import org.ethereum.beacon.core.types.SlotNumber;
import tech.pegasys.artemis.util.collections.Bitlist;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Implements (some) metrics from Beacon chain metrics specs.
* @See <a href="https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.ethereum.beacon.start.common;

import org.ethereum.beacon.core.types.Time;
import org.ethereum.beacon.db.Database;
import org.ethereum.beacon.db.InMemoryDatabase;
import tech.pegasys.artemis.ethereum.core.Hash32;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.ethereum.beacon.core.types.Time;
import org.ethereum.beacon.db.Database;
import org.ethereum.beacon.db.InMemoryDatabase;
import tech.pegasys.artemis.ethereum.core.Hash32;

/**
* DB Manager which incapsulates logic to create or remove/clean DB. This is probably an
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ethereum.beacon.start.common;

import java.util.List;
import org.ethereum.beacon.bench.BenchmarkController;
import org.ethereum.beacon.bench.BenchmarkController.BenchmarkRoutine;
import org.ethereum.beacon.chain.DefaultBeaconChain;
Expand All @@ -11,6 +12,7 @@
import org.ethereum.beacon.chain.observer.ObservableStateProcessorImpl;
import org.ethereum.beacon.chain.storage.BeaconChainStorage;
import org.ethereum.beacon.chain.storage.BeaconChainStorageFactory;
import org.ethereum.beacon.chain.storage.util.StorageUtils;
import org.ethereum.beacon.consensus.BeaconChainSpec;
import org.ethereum.beacon.consensus.BeaconStateEx;
import org.ethereum.beacon.consensus.ChainStart;
Expand All @@ -29,7 +31,6 @@
import org.ethereum.beacon.db.InMemoryDatabase;
import org.ethereum.beacon.pow.DepositContract;
import org.ethereum.beacon.schedulers.Schedulers;
import org.ethereum.beacon.chain.storage.util.StorageUtils;
import org.ethereum.beacon.util.stats.MeasurementsCollector;
import org.ethereum.beacon.validator.BeaconChainProposer;
import org.ethereum.beacon.validator.attester.BeaconChainAttesterImpl;
Expand All @@ -41,8 +42,6 @@
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;

public class Launcher {
private final BeaconChainSpec spec;
private final DepositContract depositContract;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package org.ethereum.beacon.start.common;

import static org.ethereum.beacon.chain.observer.ObservableStateProcessorImpl.DEFAULT_EMPTY_SLOT_TRANSITIONS_LIMIT;

import java.time.Duration;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.ethereum.beacon.chain.DefaultBeaconChain;
import org.ethereum.beacon.chain.MutableBeaconChain;
import org.ethereum.beacon.chain.ProposedBlockProcessor;
Expand Down Expand Up @@ -33,28 +40,23 @@
import org.ethereum.beacon.validator.local.MultiValidatorService;
import org.ethereum.beacon.validator.proposer.BeaconChainProposerImpl;
import org.ethereum.beacon.wire.Feedback;
import org.ethereum.beacon.wire.MessageSerializer;
import org.ethereum.beacon.wire.SimplePeerManagerImpl;
import org.ethereum.beacon.wire.PeerManager;
import org.ethereum.beacon.wire.WireApiSub;
import org.ethereum.beacon.wire.WireApiSync;
import org.ethereum.beacon.wire.WireApiSyncServer;
import org.ethereum.beacon.wire.message.SSZMessageSerializer;
import org.ethereum.beacon.wire.net.ConnectionManager;
import org.ethereum.beacon.wire.impl.libp2p.Libp2pLauncher;
import org.ethereum.beacon.wire.sync.BeaconBlockTree;
import org.ethereum.beacon.wire.sync.SyncManagerImpl;
import org.ethereum.beacon.wire.sync.SyncQueue;
import org.ethereum.beacon.wire.sync.SyncQueueImpl;
import reactor.core.publisher.DirectProcessor;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import tech.pegasys.artemis.util.bytes.Bytes4;
import tech.pegasys.artemis.util.uint.UInt64;

import java.time.Duration;
import java.util.List;

import static org.ethereum.beacon.chain.observer.ObservableStateProcessorImpl.DEFAULT_EMPTY_SLOT_TRANSITIONS_LIMIT;

public class NodeLauncher {
private static final Logger logger = LogManager.getLogger(NodeLauncher.class);

private final BeaconChainSpec spec;
private final DepositContract depositContract;
Expand All @@ -80,12 +82,13 @@ public class NodeLauncher {

private byte networkId = 1;
private UInt64 chainId = UInt64.valueOf(1);
private Bytes4 fork = Bytes4.ZERO;
private boolean startSyncManager = false;

private WireApiSub wireApiSub;
private WireApiSync wireApiSyncRemote;
private final ConnectionManager<?> connectionManager;
private SimplePeerManagerImpl peerManager;
private final Libp2pLauncher networkLauncher;
private PeerManager peerManager;
private BeaconBlockTree blockTree;
private SyncQueue syncQueue;
private SyncManagerImpl syncManager;
Expand All @@ -95,7 +98,7 @@ public NodeLauncher(
BeaconChainSpec spec,
DepositContract depositContract,
List<BLS381Credentials> validatorCred,
ConnectionManager<?> connectionManager,
Libp2pLauncher networkLauncher,
Database db,
BeaconChainStorage beaconChainStorage,
Schedulers schedulers,
Expand All @@ -104,7 +107,7 @@ public NodeLauncher(
this.spec = spec;
this.depositContract = depositContract;
this.validatorCred = validatorCred;
this.connectionManager = connectionManager;
this.networkLauncher = networkLauncher;
this.db = db;
this.beaconChainStorage = beaconChainStorage;
this.schedulers = schedulers;
Expand Down Expand Up @@ -167,19 +170,20 @@ void chainStarted(ChainStart chainStartEvent) {
.withExternalVarResolver(new SpecConstantsResolver(spec.getConstants()))
.withExtraObjectCreator(SpecConstants.class, spec.getConstants())
.buildSerializer();
MessageSerializer messageSerializer = new SSZMessageSerializer(ssz);
syncServer = new WireApiSyncServer(beaconChainStorage);

peerManager = new SimplePeerManagerImpl(
networkId,
chainId,
connectionManager.channelsStream(),
ssz,
spec,
messageSerializer,
schedulers,
syncServer,
beaconChain.getBlockStatesStream());
networkLauncher.setSpec(spec);
networkLauncher.setSszSerializer(ssz);
networkLauncher.setSchedulers(schedulers);
networkLauncher.setWireApiSyncServer(syncServer);
networkLauncher.setHeadStream(beaconChain.getBlockStatesStream());
networkLauncher.setFork(fork);

networkLauncher.init();
peerManager = networkLauncher.getPeerManager();

Flux.from(peerManager.connectedPeerStream()).subscribe(ch -> Metrics.peerAdded());
Flux.from(peerManager.disconnectedPeerStream()).subscribe(ch -> Metrics.peerRemoved());

wireApiSub = peerManager.getWireApiSub();
wireApiSyncRemote = peerManager.getWireApiSync();
Expand Down Expand Up @@ -240,9 +244,11 @@ void chainStarted(ChainStart chainStartEvent) {
syncManager.start();
}

// Flux.from(wireApiSub.inboundBlocksStream())
// .publishOn(schedulers.reactorEvents())
// .subscribe(beaconChain::insert);
try {
networkLauncher.start().get(5, TimeUnit.SECONDS);
} catch (Exception e) {
logger.error("Problem with starting network", e);
}
}

public void stop() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package org.ethereum.beacon.start.common.util;

import com.google.common.primitives.Bytes;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.ethereum.beacon.crypto.BLS381;
import org.ethereum.beacon.crypto.Hashes;
import org.ethereum.beacon.crypto.bls.bc.BCParameters;
import tech.pegasys.artemis.util.bytes.Bytes32;
import tech.pegasys.artemis.util.bytes.BytesValue;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
* Key pair generation utilities for simulation purposes.
*/
Expand Down
Loading