Skip to content

Commit

Permalink
merge with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
biandratti committed Nov 24, 2020
2 parents 144adb8 + b5cb34b commit 711cc91
Show file tree
Hide file tree
Showing 46 changed files with 581 additions and 209 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Expand Up @@ -10,7 +10,7 @@ val mantisDev = sys.props.get("mantisDev").contains("true") || sys.env.get("MANT

val commonSettings = Seq(
name := "mantis",
version := "3.0",
version := "3.1.0",
scalaVersion := "2.12.12",
// Scalanet snapshots are published to Sonatype after each build.
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
Expand Down
6 changes: 3 additions & 3 deletions src/it/scala/io/iohk/ethereum/sync/util/CommonFakePeer.scala
Expand Up @@ -6,9 +6,9 @@ import java.util.concurrent.atomic.AtomicReference
import akka.actor.{ActorRef, ActorSystem}
import akka.testkit.TestProbe
import akka.util.{ByteString, Timeout}
import io.iohk.ethereum.blockchain.sync.regular.BlockBroadcasterActor
import io.iohk.ethereum.blockchain.sync.regular.{BlockBroadcast, BlockBroadcasterActor}
import io.iohk.ethereum.blockchain.sync.regular.BlockBroadcasterActor.BroadcastBlock
import io.iohk.ethereum.blockchain.sync.{BlockBroadcast, BlockchainHostActor, TestSyncConfig}
import io.iohk.ethereum.blockchain.sync.{BlockchainHostActor, TestSyncConfig}
import io.iohk.ethereum.db.components.{RocksDbDataSourceComponent, Storages}
import io.iohk.ethereum.db.dataSource.{RocksDbConfig, RocksDbDataSource}
import io.iohk.ethereum.db.storage.pruning.{ArchivePruning, PruningMode}
Expand All @@ -20,7 +20,7 @@ import io.iohk.ethereum.mpt.MerklePatriciaTrie
import io.iohk.ethereum.network.EtcPeerManagerActor.PeerInfo
import io.iohk.ethereum.network.PeerManagerActor.{FastSyncHostConfiguration, PeerConfiguration}
import io.iohk.ethereum.network.discovery.{DiscoveryConfig, Node}
import io.iohk.ethereum.network.discovery.PeerDiscoveryManager.{DiscoveredNodesInfo}
import io.iohk.ethereum.network.discovery.PeerDiscoveryManager.DiscoveredNodesInfo
import io.iohk.ethereum.network.handshaker.{EtcHandshaker, EtcHandshakerConfiguration, Handshaker}
import io.iohk.ethereum.network.p2p.EthereumMessageDecoder
import io.iohk.ethereum.network.p2p.messages.CommonMessages.NewBlock
Expand Down
Expand Up @@ -3,8 +3,9 @@ package io.iohk.ethereum.sync.util
import akka.util.ByteString
import cats.effect.Resource
import io.iohk.ethereum.Mocks.MockValidatorsAlwaysSucceed
import io.iohk.ethereum.blockchain.sync.{FastSync, SyncProtocol}
import io.iohk.ethereum.blockchain.sync.FastSync.SyncState
import io.iohk.ethereum.blockchain.sync.SyncProtocol
import io.iohk.ethereum.blockchain.sync.fast.FastSync
import io.iohk.ethereum.blockchain.sync.fast.FastSync.SyncState
import io.iohk.ethereum.crypto.kec256
import io.iohk.ethereum.domain.Address
import io.iohk.ethereum.mpt.{HashNode, MptNode, MptTraversals}
Expand Down
Expand Up @@ -63,6 +63,8 @@ object RegularSyncItSpecUtils {
"pending-transactions-manager"
)

lazy val validators = buildEthashConsensus.validators

lazy val regularSync = system.actorOf(
RegularSync.props(
peersClient,
Expand All @@ -71,6 +73,7 @@ object RegularSyncItSpecUtils {
ledger,
bl,
blockchainConfig, // FIXME: remove in ETCM-280
validators.blockValidator,
testSyncConfig,
ommersPool,
pendingTransactionsManager,
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/application.conf
Expand Up @@ -170,7 +170,7 @@ mantis {
# Choosing https requires creating a certificate and setting up 'certificate-keystore-path' and
# 'certificate-password-file'
# See: https://github.com/input-output-hk/mantis/wiki/Creating-self-signed-certificate-for-using-JSON-RPC-with-HTTPS
mode = "https"
mode = "http"

# Whether to enable JSON-RPC HTTP(S) endpoint
enabled = true
Expand Down Expand Up @@ -296,7 +296,9 @@ mantis {

test {include "chains/test-chain.conf"}

testnet-internal {include "chains/testnet-internal-chain.conf"}
testnet-internal-nomad {include "chains/testnet-internal-nomad-chain.conf"}

testnet-internal-gac {include "chains/testnet-internal-gac-chain.conf"}
}

sync {
Expand Down
Expand Up @@ -108,7 +108,7 @@

# Custom genesis JSON file path
# null value indicates using default genesis definition that matches the main network
custom-genesis-file = "chains/testnet-internal-genesis.json"
custom-genesis-file = "chains/testnet-internal-gac-genesis.json"

# Monetary policy parameters
# Doc: https://github.com/ethereumproject/ECIPs/blob/master/ECIPs/ECIP-1017.md
Expand Down
Expand Up @@ -10,7 +10,7 @@
"coinbase": "0x0000000000000000000000000000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
"d7a681378321f472adffb9fdded2712f677e0ba9": {"balance":
"45238430908a621cfe0e5491528dedfe82058b8e": {"balance":
"1606938044258990275541962092341162602522202993782792835301376"}
}
}
153 changes: 153 additions & 0 deletions src/main/resources/chains/testnet-internal-nomad-chain.conf
@@ -0,0 +1,153 @@
{
# Ethereum network identifier:
# 1 - mainnet, 3 - ropsten, 7 - mordor
network-id = 42

# Possibility to set Proof of Work target time for testing purposes.
# null means that the standard difficulty calculation rules are used
pow-target-time = 30 seconds

# Frontier block number
frontier-block-number = "0"

# Homestead fork block number
# Doc: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2.md
homestead-block-number = "0"

# EIP-106 fork block number
# Doc: https://github.com/ethereum/EIPs/issues/106
eip106-block-number = "1000000000000000000"

# EIP-150 fork block number
# Doc: https://github.com/ethereum/EIPs/issues/150
eip150-block-number = "0"

# EIP-155 fork block number
# Doc: https://github.com/ethereum/eips/issues/155
# 3 000 000 following lead of existing clients implementation to maintain compatibility
# https://github.com/paritytech/parity/blob/b50fb71dd1d29dfde2a6c7e1830447cf30896c31/ethcore/res/ethereum/classic.json#L15
eip155-block-number = "0"

# EIP-160 fork block number
# Doc: https://github.com/ethereum/EIPs/issues/160
eip160-block-number = "0"

# EIP-161 fork block number (ETH Only)
# Doc: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-161.md
eip161-block-number = "1000000000000000000"

# EIP-170 max code size (Enabled from Atlantis fork block number)
# Doc: https://github.com/ethereum/EIPs/issues/170
# null value indicates there's no max code size for the contract code
# TODO improve this configuration format as currently it is not obvious that this is enabled only from some block number
max-code-size = "24576"

# Difficulty bomb pause block number
# Doc: https://github.com/ethereumproject/ECIPs/blob/master/ECIPs/ECIP-1010.md
difficulty-bomb-pause-block-number = "0"

# Difficulty bomb continuation block number
# Doc: https://github.com/ethereumproject/ECIPs/blob/master/ECIPs/ECIP-1010.md
difficulty-bomb-continue-block-number = "0"

# Difficulty bomb defusion block number
# Doc: https://github.com/ethereumproject/ECIPs/blob/master/ECIPs/ECIP-1041.md
difficulty-bomb-removal-block-number = "0"

# Byzantium fork block number (ETH only)
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-609.md
byzantium-block-number = "1000000000000000000"

# Atlantis fork block number (ETC only)
# https://ecips.ethereumclassic.org/ECIPs/ecip-1054
atlantis-block-number = "0"

# Agharta fork block number (ETC only)
# https://ecips.ethereumclassic.org/ECIPs/ecip-1056
agharta-block-number = "0"

# Phoenix fork block number (ETC only)
# https://ecips.ethereumclassic.org/ECIPs/ecip-1088
phoenix-block-number = "0"

# Constantinople fork block number (ETH only)
# https://github.com/ethereum/pm/issues/53
constantinople-block-number = "1000000000000000000"

# Petersburg fork block number (ETH only)
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1716.md
petersburg-block-number = "1000000000000000000"

# Istanbul fork block number (ETH only)
# https://eips.ethereum.org/EIPS/eip-1679
istanbul-block-number = "1000000000000000000"

# Proto-treasury fork block number (ETC only, but deactivated for now)
# https://ecips.ethereumclassic.org/ECIPs/ecip-1098
treasury-address = "0011223344556677889900112233445566778899"
ecip1098-block-number = "0"

# Checkpointing fork block number
# https://ecips.ethereumclassic.org/ECIPs/ecip-1097
# Has to be equal or greater than ecip1098-block-number
ecip1097-block-number = "0"

# Epoch calibration block number
# https://ecips.ethereumclassic.org/ECIPs/ecip-1099
ecip1099-block-number = "1000000000000000000"

# DAO fork configuration (Ethereum HF/Classic split)
# https://blog.ethereum.org/2016/07/20/hard-fork-completed/
dao = null

# Starting nonce of an empty account. Some networks (like Morden) use different values.
account-start-nonce = "0"

# The ID of the accepted chain
chain-id = "0x2A"

# Custom genesis JSON file path
# null value indicates using default genesis definition that matches the main network
custom-genesis-file = "chains/testnet-internal-nomad-genesis.json"

# Monetary policy parameters
# Doc: https://github.com/ethereumproject/ECIPs/blob/master/ECIPs/ECIP-1017.md
monetary-policy {
# Block reward in the first era
first-era-block-reward = "5000000000000000000"

# Reduced block reward after Byzantium fork
first-era-reduced-block-reward = "3000000000000000000"

# Reduced block reward after Constantinople fork
first-era-constantinople-reduced-block-reward = "2000000000000000000"

# Monetary policy era duration in number of blocks
era-duration = 5000000

# Rate at which rewards get reduced in successive eras.
# Value in range [0.0, 1.0]
reward-reduction-rate = 0.2
}

# if 2 competing blocktree branches are equal in terms of total difficulty and this is set to true, then gas
# consumed in those branches will be used to resolve the tie
# this is currently only used in ETS blockchain tests
gas-tie-breaker = false

# if true, account storage will use Ethereum-specific format for storing keys/value in MPT (32 byte)
# if false, generic storage for arbitrary length integers will be used
eth-compatible-storage = true

# Set of initial nodes
bootstrap-nodes = [
"enode://ff86741b7b35087b2b53f44a612b233336490d5fae10b1434619b7714fe2d5346c71427a5e126cd27b9422a4d4376c1534ef66e88c5e62d6441d2541f63de0cf@mantis-4.mantis.ws:9004",
"enode://f92aa66337ab1993cc7269d4295d296aefe6199b34e900eac08c514c947ec7340d46a5648ffc2da10325dbaba16bdf92aa9c0b5e51d97a7818c3f495d478ddad@mantis-1.mantis.ws:9001",
"enode://442e2bd50eece65f90dee0d5c6075da4e1b4bc62e36b261a52e7f393dae6a68241e4dbad868c7ecc14fed277ed72e99a289a811b6172f35fb18bdca0b7a5602c@mantis-3.mantis.ws:9003",
"enode://af97643f364b805d5b0e32b5356578a16afcc4fb9d1b6622998e9441eeb7795e8daf8e6b0ff3330da9879034112be56954f9269164513ece0f7394b805be3633@mantis-5.mantis.ws:9005",
"enode://d8a010f019db37dcaf2e1fb98d4fcbf1f57dbd7e2a7f065e92fbe77dca8b9120d6e79f1617e98fa6134e6af8858ac8f3735b1e70a5708eb14f228080356eb0a7@mantis-2.mantis.ws:9002"
]

# List of hex encoded public keys of Checkpoint Authorities
checkpoint-public-keys = []
}
29 changes: 29 additions & 0 deletions src/main/resources/chains/testnet-internal-nomad-genesis.json
@@ -0,0 +1,29 @@
{
"extraData": "0x00",
"nonce": "0x0000000000000042",
"gasLimit": "0x2fefd8",
"_commentAboutDifficulty": "Set to 1000000",
"difficulty": "0xF4240",
"ommersHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"_commentAboutTimestamp": "Set to 11/05/2020 @ 12:00am (UTC)",
"timestamp": "0x5FA34080",
"coinbase": "0x0000000000000000000000000000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
"075b073eaa848fc14de2fd9c2a18d97a4783d84c": {
"balance": "1606938044258990275541962092341162602522202993782792835301376"
},
"18f496690eb3fabb794a653be8097af5331c07b1": {
"balance": "1606938044258990275541962092341162602522202993782792835301376"
},
"1ff7fc39f7f4dc79c5867b9514d0e42607741384": {
"balance": "1606938044258990275541962092341162602522202993782792835301376"
},
"75b0f1c605223de2a013bf7f26d4cd93c63a5eb8": {
"balance": "1606938044258990275541962092341162602522202993782792835301376"
},
"7e3166074d45c3311908315da1af5f5a965b7ece": {
"balance": "1606938044258990275541962092341162602522202993782792835301376"
}
}
}
@@ -1,6 +1,7 @@
package io.iohk.ethereum.blockchain.sync

import akka.actor.{Actor, ActorLogging, ActorRef, PoisonPill, Props, Scheduler}
import io.iohk.ethereum.blockchain.sync.fast.FastSync
import io.iohk.ethereum.blockchain.sync.regular.RegularSync
import io.iohk.ethereum.consensus.blocks.CheckpointBlockGenerator
import io.iohk.ethereum.consensus.validators.Validators
Expand Down Expand Up @@ -102,6 +103,7 @@ class SyncController(
ledger,
blockchain,
blockchainConfig,
validators.blockValidator,
syncConfig,
ommersPool,
pendingTransactionsManager,
Expand Down
@@ -1,18 +1,18 @@
package io.iohk.ethereum.blockchain.sync
package io.iohk.ethereum.blockchain.sync.fast

import akka.util.ByteString
import cats.data.NonEmptyList
import io.iohk.ethereum.blockchain.sync.SyncStateScheduler.SyncResponse
import io.iohk.ethereum.blockchain.sync.SyncStateSchedulerActor.{
import io.iohk.ethereum.blockchain.sync.fast.SyncStateScheduler.SyncResponse
import io.iohk.ethereum.blockchain.sync.fast.SyncStateSchedulerActor.{
NoUsefulDataInResponse,
PeerRequest,
ResponseProcessingResult,
UnrequestedResponse,
UsefulData
}
import io.iohk.ethereum.crypto.kec256
import io.iohk.ethereum.network.{Peer, PeerId}
import io.iohk.ethereum.network.p2p.messages.PV63.NodeData
import io.iohk.ethereum.network.{Peer, PeerId}

import scala.annotation.tailrec

Expand Down
@@ -1,14 +1,16 @@
package io.iohk.ethereum.blockchain.sync
package io.iohk.ethereum.blockchain.sync.fast

import java.time.Instant

import akka.actor._
import akka.util.ByteString
import cats.data.NonEmptyList
import io.iohk.ethereum.blockchain.sync.FastSyncReceiptsValidator.ReceiptsValidationResult
import io.iohk.ethereum.blockchain.sync.PeerRequestHandler.ResponseReceived
import io.iohk.ethereum.blockchain.sync.SyncBlocksValidator.BlockBodyValidationResult
import io.iohk.ethereum.blockchain.sync.SyncProtocol.Status.Progress
import io.iohk.ethereum.blockchain.sync.SyncStateSchedulerActor.{
import io.iohk.ethereum.blockchain.sync._
import io.iohk.ethereum.blockchain.sync.fast.ReceiptsValidator.ReceiptsValidationResult
import io.iohk.ethereum.blockchain.sync.fast.SyncBlocksValidator.BlockBodyValidationResult
import io.iohk.ethereum.blockchain.sync.fast.SyncStateSchedulerActor.{
RestartRequested,
StartSyncingTo,
StateSyncFinished,
Expand All @@ -25,6 +27,7 @@ import io.iohk.ethereum.network.p2p.messages.PV63._
import io.iohk.ethereum.utils.ByteStringUtils
import io.iohk.ethereum.utils.Config.SyncConfig
import org.bouncycastle.util.encoders.Hex

import scala.annotation.tailrec
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
Expand All @@ -44,7 +47,7 @@ class FastSync(
with ActorLogging
with PeerListSupport
with BlacklistSupport
with FastSyncReceiptsValidator
with ReceiptsValidator
with SyncBlocksValidator {

import FastSync._
Expand Down Expand Up @@ -122,7 +125,7 @@ class FastSync(
private var requestedBlockBodies: Map[ActorRef, Seq[ByteString]] = Map.empty
private var requestedReceipts: Map[ActorRef, Seq[ByteString]] = Map.empty

private val syncStateStorageActor = context.actorOf(Props[FastSyncStateStorageActor], "state-storage")
private val syncStateStorageActor = context.actorOf(Props[StateStorageActor], "state-storage")

syncStateStorageActor ! fastSyncStateStorage

Expand Down Expand Up @@ -626,7 +629,7 @@ class FastSync(
}

def processSyncing(): Unit = {
FastSyncMetrics.measure(syncState)
SyncMetrics.measure(syncState)
if (fullySynced) {
finish()
} else {
Expand Down
@@ -1,7 +1,7 @@
package io.iohk.ethereum.blockchain.sync
package io.iohk.ethereum.blockchain.sync.fast

import com.google.common.hash.{BloomFilter, Funnel}
import io.iohk.ethereum.blockchain.sync.LoadableBloomFilter.BloomFilterLoadingResult
import io.iohk.ethereum.blockchain.sync.fast.LoadableBloomFilter.BloomFilterLoadingResult
import io.iohk.ethereum.db.dataSource.RocksDbDataSource.IterationError
import monix.eval.Task
import monix.reactive.{Consumer, Observable}
Expand Down

0 comments on commit 711cc91

Please sign in to comment.