Skip to content

Commit e631789

Browse files
author
Aurélien Richez
authored
[ETCM-943] partially split reading part of Blockchain (#1022)
* move getBlockHeaderByHash to BlockchainReader * move getBlockBodyByHash into BlockchainReader * Move getHashByBlockNumber, getBlockHeaderByNumber, getBlockByNumber to BlockchainReader * move getMptNodeByHash to BlockchainReader * move getReceiptsByHash to BlockchainReader and remove Blockchain from BlockchainHostActor dependencies * remove Blockchain dependency where it is not needed anymore
1 parent 67d7870 commit e631789

File tree

98 files changed

+873
-518
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+873
-518
lines changed

src/it/scala/io/iohk/ethereum/ledger/BlockImporterItSpec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class BlockImporterItSpec
6262
val emptyWorld = InMemoryWorldStateProxy(
6363
storagesInstance.storages.evmCodeStorage,
6464
blockchain.getBackingMptStorage(-1),
65-
(number: BigInt) => blockchain.getBlockHeaderByNumber(number).map(_.hash),
65+
(number: BigInt) => blockchainReader.getBlockHeaderByNumber(number).map(_.hash),
6666
blockchainConfig.accountStartNonce,
6767
ByteString(MerklePatriciaTrie.EmptyRootHash),
6868
noEmptyAccounts = false,
@@ -85,6 +85,7 @@ class BlockImporterItSpec
8585
override private[ledger] lazy val blockExecution =
8686
new BlockExecution(
8787
blockchain,
88+
blockchainReader,
8889
storagesInstance.storages.evmCodeStorage,
8990
blockchainConfig,
9091
consensus.blockPreparator,

src/it/scala/io/iohk/ethereum/sync/RegularSyncItSpec.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class RegularSyncItSpec extends FreeSpecBase with Matchers with BeforeAndAfterAl
127127
_ <- peer2.importBlocksUntil(30)(IdentityUpdate)
128128
_ <- peer1.startRegularSync()
129129
_ <- peer2.startRegularSync()
130-
_ <- peer2.addCheckpointedBlock(peer2.bl.getBlockByNumber(25).get)
130+
_ <- peer2.addCheckpointedBlock(peer2.blockchainReader.getBlockByNumber(25).get)
131131
_ <- peer2.waitForRegularSyncLoadLastBlock(length)
132132
_ <- peer1.connectToPeers(Set(peer2.node))
133133
_ <- peer1.waitForRegularSyncLoadLastBlock(length)
@@ -188,7 +188,10 @@ class RegularSyncItSpec extends FreeSpecBase with Matchers with BeforeAndAfterAl
188188
peer2.bl.getBestBlock().get.hash
189189
)
190190
)
191-
(peer1.bl.getBlockByNumber(blockNumer + 1), peer2.bl.getBlockByNumber(blockNumer + 1)) match {
191+
(
192+
peer1.blockchainReader.getBlockByNumber(blockNumer + 1),
193+
peer2.blockchainReader.getBlockByNumber(blockNumer + 1)
194+
) match {
192195
case (Some(blockP1), Some(blockP2)) =>
193196
assert(peer1.bl.getChainWeightByHash(blockP1.hash) == peer2.bl.getChainWeightByHash(blockP2.hash))
194197
case (_, _) => fail("invalid difficulty validation")

src/it/scala/io/iohk/ethereum/sync/util/CommonFakePeer.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import io.iohk.ethereum.db.components.{RocksDbDataSourceComponent, Storages}
1414
import io.iohk.ethereum.db.dataSource.{RocksDbConfig, RocksDbDataSource}
1515
import io.iohk.ethereum.db.storage.pruning.{ArchivePruning, PruningMode}
1616
import io.iohk.ethereum.db.storage.{AppStateStorage, Namespaces}
17-
import io.iohk.ethereum.domain.{Block, Blockchain, BlockchainImpl, ChainWeight, UInt256}
17+
import io.iohk.ethereum.domain.{Block, Blockchain, BlockchainImpl, BlockchainReader, ChainWeight, UInt256}
1818
import io.iohk.ethereum.security.SecureRandomBuilder
1919
import io.iohk.ethereum.ledger.InMemoryWorldStateProxy
2020
import io.iohk.ethereum.mpt.MerklePatriciaTrie
@@ -115,7 +115,8 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
115115
)
116116
)
117117

118-
val bl = BlockchainImpl(storagesInstance.storages)
118+
val blockchainReader = BlockchainReader(storagesInstance.storages)
119+
val bl = BlockchainImpl(storagesInstance.storages, blockchainReader)
119120
val evmCodeStorage = storagesInstance.storages.evmCodeStorage
120121

121122
val genesis = Block(
@@ -168,7 +169,8 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
168169
override val forkResolverOpt: Option[ForkResolver] = None
169170
override val nodeStatusHolder: AtomicReference[NodeStatus] = nh
170171
override val peerConfiguration: PeerConfiguration = peerConf
171-
override val blockchain: Blockchain = bl
172+
override val blockchain: Blockchain = CommonFakePeer.this.bl
173+
override val blockchainReader: BlockchainReader = CommonFakePeer.this.blockchainReader
172174
override val appStateStorage: AppStateStorage = storagesInstance.storages.appStateStorage
173175
override val capabilities: List[Capability] = blockchainConfig.capabilities
174176
}
@@ -205,7 +207,8 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
205207

206208
val blockchainHost: ActorRef =
207209
system.actorOf(
208-
BlockchainHostActor.props(bl, storagesInstance.storages.evmCodeStorage, peerConf, peerEventBus, etcPeerManager),
210+
BlockchainHostActor
211+
.props(blockchainReader, storagesInstance.storages.evmCodeStorage, peerConf, peerEventBus, etcPeerManager),
209212
"blockchain-host"
210213
)
211214

@@ -244,7 +247,7 @@ abstract class CommonFakePeer(peerName: String, fakePeerCustomConfig: FakePeerCu
244247
InMemoryWorldStateProxy(
245248
storagesInstance.storages.evmCodeStorage,
246249
bl.getBackingMptStorage(block.number),
247-
(number: BigInt) => bl.getBlockHeaderByNumber(number).map(_.hash),
250+
(number: BigInt) => blockchainReader.getBlockHeaderByNumber(number).map(_.hash),
248251
blockchainConfig.accountStartNonce,
249252
block.header.stateRoot,
250253
noEmptyAccounts = EvmConfig.forBlock(block.number, blockchainConfig).noEmptyAccounts,

src/it/scala/io/iohk/ethereum/sync/util/FastSyncItSpecUtils.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ object FastSyncItSpecUtils {
2929
storagesInstance.storages.fastSyncStateStorage,
3030
storagesInstance.storages.appStateStorage,
3131
bl,
32+
blockchainReader,
3233
storagesInstance.storages.evmCodeStorage,
3334
storagesInstance.storages.nodeStorage,
3435
validators,

src/it/scala/io/iohk/ethereum/sync/util/RegularSyncItSpecUtils.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ object RegularSyncItSpecUtils {
6565
vm,
6666
storagesInstance.storages.evmCodeStorage,
6767
bl,
68+
blockchainReader,
6869
blockchainConfig,
6970
fullConfig,
7071
ValidatorsExecutorAlwaysSucceed,
@@ -83,14 +84,15 @@ object RegularSyncItSpecUtils {
8384
lazy val ledger: Ledger =
8485
new LedgerImpl(
8586
bl,
87+
blockchainReader,
8688
storagesInstance.storages.evmCodeStorage,
8789
blockchainConfig,
8890
syncConfig,
8991
buildEthashConsensus(),
9092
Scheduler.global
9193
)
9294

93-
lazy val ommersPool: ActorRef = system.actorOf(OmmersPool.props(bl, 1), "ommers-pool")
95+
lazy val ommersPool: ActorRef = system.actorOf(OmmersPool.props(blockchainReader, 1), "ommers-pool")
9496

9597
lazy val pendingTransactionsManager: ActorRef = system.actorOf(
9698
PendingTransactionsManager.props(TxPoolConfig(config), peerManager, etcPeerManager, peerEventBus),
@@ -156,7 +158,9 @@ object RegularSyncItSpecUtils {
156158
)(updateWorldForBlock: (BigInt, InMemoryWorldStateProxy) => InMemoryWorldStateProxy): Task[Unit] = {
157159
Task(blockNumber match {
158160
case Some(bNumber) =>
159-
bl.getBlockByNumber(bNumber).getOrElse(throw new RuntimeException(s"block by number: $bNumber doesn't exist"))
161+
blockchainReader
162+
.getBlockByNumber(bNumber)
163+
.getOrElse(throw new RuntimeException(s"block by number: $bNumber doesn't exist"))
160164
case None => bl.getBestBlock().get
161165
}).flatMap { block =>
162166
Task {
@@ -215,7 +219,7 @@ object RegularSyncItSpecUtils {
215219
InMemoryWorldStateProxy(
216220
storagesInstance.storages.evmCodeStorage,
217221
bl.getBackingMptStorage(block.number),
218-
(number: BigInt) => bl.getBlockHeaderByNumber(number).map(_.hash),
222+
(number: BigInt) => blockchainReader.getBlockHeaderByNumber(number).map(_.hash),
219223
UInt256.Zero,
220224
ByteString(MerklePatriciaTrie.EmptyRootHash),
221225
noEmptyAccounts = false,

src/it/scala/io/iohk/ethereum/txExecTest/ContractTest.scala

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.iohk.ethereum.txExecTest
22

3-
import io.iohk.ethereum.domain.{BlockchainImpl, Receipt}
3+
import io.iohk.ethereum.domain.{BlockchainImpl, BlockchainReader, Receipt}
44
import io.iohk.ethereum.ledger.{BlockExecution, BlockQueue, BlockValidation}
55
import io.iohk.ethereum.txExecTest.util.FixtureProvider
66
import io.iohk.ethereum.utils.Config
@@ -16,19 +16,18 @@ class ContractTest extends AnyFlatSpec with Matchers {
1616
val fixtures: FixtureProvider.Fixture = FixtureProvider.loadFixtures("/txExecTest/purchaseContract")
1717
lazy val testBlockchainStorages = FixtureProvider.prepareStorages(2, fixtures)
1818

19-
override lazy val blockchain = BlockchainImpl(testBlockchainStorages)
20-
2119
//block only with ether transfers
22-
val blockValidation = new BlockValidation(consensus, blockchain, BlockQueue(blockchain, syncConfig))
23-
val blockExecution = new BlockExecution(
24-
blockchain,
25-
testBlockchainStorages.evmCodeStorage,
26-
blockchainConfig,
27-
consensus.blockPreparator,
28-
blockValidation
29-
)
30-
31-
// transfer ether
20+
val blockValidation =
21+
new BlockValidation(consensus, blockchainReader, BlockQueue(blockchain, syncConfig))
22+
val blockExecution =
23+
new BlockExecution(
24+
blockchain,
25+
blockchainReader,
26+
testBlockchainStorages.evmCodeStorage,
27+
blockchainConfig,
28+
consensus.blockPreparator,
29+
blockValidation
30+
)
3231
blockExecution.executeAndValidateBlock(fixtures.blockByNumber(1)) shouldBe noErrors
3332

3433
// deploy contract

src/it/scala/io/iohk/ethereum/txExecTest/ECIP1017Test.scala

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.iohk.ethereum.txExecTest
22

3-
import io.iohk.ethereum.domain.{Address, Receipt, UInt256}
3+
import io.iohk.ethereum.domain.{Address, BlockchainImpl, BlockchainReader, Receipt, UInt256}
44
import io.iohk.ethereum.ledger.{BlockExecution, BlockQueue, BlockValidation}
55
import io.iohk.ethereum.txExecTest.util.FixtureProvider
66
import io.iohk.ethereum.utils.{BlockchainConfig, ForkBlockNumbers, MonetaryPolicyConfig}
@@ -68,14 +68,20 @@ class ECIP1017Test extends AnyFlatSpec with Matchers {
6868
protected val testBlockchainStorages = FixtureProvider.prepareStorages(endBlock, fixtures)
6969

7070
(startBlock to endBlock) foreach { blockToExecute =>
71-
val blockValidation = new BlockValidation(consensus, blockchain, BlockQueue(blockchain, syncConfig))
72-
val blockExecution = new BlockExecution(
73-
blockchain,
74-
testBlockchainStorages.evmCodeStorage,
75-
blockchainConfig,
76-
consensus.blockPreparator,
77-
blockValidation
78-
)
71+
val storages = FixtureProvider.prepareStorages(blockToExecute - 1, fixtures)
72+
val blockchainReader = BlockchainReader(storages)
73+
val blockchain = BlockchainImpl(storages, blockchainReader)
74+
val blockValidation =
75+
new BlockValidation(consensus, blockchainReader, BlockQueue(blockchain, syncConfig))
76+
val blockExecution =
77+
new BlockExecution(
78+
blockchain,
79+
blockchainReader,
80+
testBlockchainStorages.evmCodeStorage,
81+
blockchainConfig,
82+
consensus.blockPreparator,
83+
blockValidation
84+
)
7985
blockExecution.executeAndValidateBlock(fixtures.blockByNumber(blockToExecute)) shouldBe noErrors
8086
}
8187
}

src/it/scala/io/iohk/ethereum/txExecTest/ForksTest.scala

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.iohk.ethereum.txExecTest
22

3-
import io.iohk.ethereum.domain.{Address, Receipt, UInt256}
3+
import java.util.concurrent.Executors
4+
import io.iohk.ethereum.domain.{Address, BlockchainImpl, BlockchainReader, Receipt, UInt256}
45
import io.iohk.ethereum.ledger.{BlockExecution, BlockQueue, BlockValidation}
56
import io.iohk.ethereum.txExecTest.util.FixtureProvider
67
import io.iohk.ethereum.utils.{BlockchainConfig, ForkBlockNumbers, MonetaryPolicyConfig}
@@ -60,14 +61,20 @@ class ForksTest extends AnyFlatSpec with Matchers {
6061
protected val testBlockchainStorages = FixtureProvider.prepareStorages(endBlock, fixtures)
6162

6263
(startBlock to endBlock) foreach { blockToExecute =>
63-
val blockValidation = new BlockValidation(consensus, blockchain, BlockQueue(blockchain, syncConfig))
64-
val blockExecution = new BlockExecution(
65-
blockchain,
66-
testBlockchainStorages.evmCodeStorage,
67-
blockchainConfig,
68-
consensus.blockPreparator,
69-
blockValidation
70-
)
64+
val storages = FixtureProvider.prepareStorages(blockToExecute - 1, fixtures)
65+
val blockchainReader = BlockchainReader(storages)
66+
val blockchain = BlockchainImpl(storages, blockchainReader)
67+
val blockValidation =
68+
new BlockValidation(consensus, blockchainReader, BlockQueue(blockchain, syncConfig))
69+
val blockExecution =
70+
new BlockExecution(
71+
blockchain,
72+
blockchainReader,
73+
testBlockchainStorages.evmCodeStorage,
74+
blockchainConfig,
75+
consensus.blockPreparator,
76+
blockValidation
77+
)
7178
blockExecution.executeAndValidateBlock(fixtures.blockByNumber(blockToExecute)) shouldBe noErrors
7279
}
7380
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package io.iohk.ethereum.txExecTest
22

33
import io.iohk.ethereum.blockchain.sync.EphemBlockchainTestSetup
4-
import io.iohk.ethereum.domain.{BlockchainImpl, BlockchainStorages}
4+
import io.iohk.ethereum.domain.{BlockchainImpl, BlockchainReader, BlockchainStorages}
55
import io.iohk.ethereum.ledger.Ledger.VMImpl
66

77
trait ScenarioSetup extends EphemBlockchainTestSetup {
88
protected val testBlockchainStorages: BlockchainStorages
9-
override lazy val blockchain: BlockchainImpl = BlockchainImpl(testBlockchainStorages)
9+
10+
override lazy val blockchainReader: BlockchainReader = BlockchainReader(testBlockchainStorages)
11+
override lazy val blockchain: BlockchainImpl = BlockchainImpl(testBlockchainStorages, blockchainReader)
1012
override lazy val vm: VMImpl = new VMImpl
1113
}

src/it/scala/io/iohk/ethereum/txExecTest/util/DumpChainApp.scala

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,37 @@ import com.typesafe.config.ConfigFactory
88
import io.iohk.ethereum.blockchain.sync.CacheBasedBlacklist
99
import io.iohk.ethereum.db.components.Storages.PruningModeComponent
1010
import io.iohk.ethereum.db.components.{RocksDbDataSourceComponent, Storages}
11-
import io.iohk.ethereum.db.dataSource.{DataSourceBatchUpdate, RocksDbDataSource}
11+
import io.iohk.ethereum.db.dataSource.{DataSourceBatchUpdate}
1212
import io.iohk.ethereum.db.storage.NodeStorage.{NodeEncoded, NodeHash}
13-
import io.iohk.ethereum.db.storage.TransactionMappingStorage.TransactionLocation
1413
import io.iohk.ethereum.db.storage.pruning.{ArchivePruning, PruningMode}
1514
import io.iohk.ethereum.db.storage.{AppStateStorage, MptStorage, StateStorage}
1615
import io.iohk.ethereum.domain.BlockHeader.HeaderExtraFields.HefEmpty
1716
import io.iohk.ethereum.domain.{Blockchain, UInt256, _}
18-
import io.iohk.ethereum.jsonrpc.ProofService.{EmptyStorageValueProof, StorageProof, StorageProofKey, StorageValueProof}
17+
import io.iohk.ethereum.jsonrpc.ProofService.{EmptyStorageValueProof, StorageProof, StorageProofKey}
1918
import io.iohk.ethereum.ledger.{InMemoryWorldStateProxy, InMemoryWorldStateProxyStorage}
2019
import io.iohk.ethereum.mpt.MptNode
2120
import io.iohk.ethereum.network.EtcPeerManagerActor.PeerInfo
2221
import io.iohk.ethereum.network.PeerManagerActor.PeerConfiguration
2322
import io.iohk.ethereum.network.PeerStatisticsActor
2423
import io.iohk.ethereum.network.discovery.DiscoveryConfig
2524
import io.iohk.ethereum.network.handshaker.{EtcHandshaker, EtcHandshakerConfiguration, Handshaker}
26-
import io.iohk.ethereum.network.p2p.EthereumMessageDecoder
2725
import io.iohk.ethereum.network.p2p.messages.Capability
2826
import io.iohk.ethereum.network.rlpx.RLPxConnectionHandler.RLPxConfiguration
2927
import io.iohk.ethereum.network.{ForkResolver, PeerEventBusActor, PeerManagerActor}
3028
import io.iohk.ethereum.nodebuilder.{AuthHandshakerBuilder, NodeKeyBuilder}
3129
import io.iohk.ethereum.security.SecureRandomBuilder
3230
import io.iohk.ethereum.utils.{Config, NodeStatus, ServerStatus}
33-
import monix.reactive.Observable
3431
import org.bouncycastle.util.encoders.Hex
32+
import org.scalamock.scalatest.MockFactory
3533

3634
import scala.concurrent.duration._
3735

38-
object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder with AuthHandshakerBuilder {
36+
object DumpChainApp
37+
extends App
38+
with NodeKeyBuilder
39+
with SecureRandomBuilder
40+
with AuthHandshakerBuilder
41+
with MockFactory {
3942
val conf = ConfigFactory.load("txExecTest/chainDump.conf")
4043
val node = conf.getString("node")
4144
val genesisHash = ByteString(Hex.decode(conf.getString("genesisHash")))
@@ -78,6 +81,8 @@ object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder wit
7881
val storagesInstance = new RocksDbDataSourceComponent with PruningConfig with Storages.DefaultStorages
7982

8083
val blockchain: Blockchain = new BlockchainMock(genesisHash)
84+
val blockchainReader = mock[BlockchainReader]
85+
(blockchainReader.getHashByBlockNumber _).expects(*).returning(Some(genesisHash))
8186

8287
val nodeStatus =
8388
NodeStatus(key = nodeKey, serverStatus = ServerStatus.NotListening, discoveryStatus = ServerStatus.NotListening)
@@ -92,6 +97,7 @@ object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder wit
9297
override val nodeStatusHolder: AtomicReference[NodeStatus] = DumpChainApp.nodeStatusHolder
9398
override val peerConfiguration: PeerConfiguration = peerConfig
9499
override val blockchain: Blockchain = DumpChainApp.blockchain
100+
override val blockchainReader: BlockchainReader = DumpChainApp.blockchainReader
95101
override val appStateStorage: AppStateStorage = storagesInstance.storages.appStateStorage
96102
override val capabilities: List[Capability] = blockchainConfig.capabilities
97103
}
@@ -156,14 +162,6 @@ class BlockchainMock(genesisHash: ByteString) extends Blockchain {
156162
ethCompatibleStorage: Boolean
157163
): StorageProof = EmptyStorageValueProof(StorageProofKey(position))
158164

159-
override protected def getHashByBlockNumber(number: BigInt): Option[ByteString] = Some(genesisHash)
160-
161-
override def getBlockHeaderByHash(hash: ByteString): Option[BlockHeader] = Some(new FakeHeader())
162-
163-
override def getBlockBodyByHash(hash: ByteString): Option[BlockBody] = ???
164-
165-
override def getMptNodeByHash(hash: ByteString): Option[MptNode] = ???
166-
167165
override def storeBlockHeader(blockHeader: BlockHeader): DataSourceBatchUpdate = ???
168166

169167
override def storeBlockBody(blockHash: ByteString, blockBody: BlockBody): DataSourceBatchUpdate = ???
@@ -180,8 +178,6 @@ class BlockchainMock(genesisHash: ByteString) extends Blockchain {
180178

181179
override def getChainWeightByHash(blockhash: ByteString): Option[ChainWeight] = ???
182180

183-
override def getReceiptsByHash(blockhash: ByteString): Option[Seq[Receipt]] = ???
184-
185181
def getAccount(address: Address, blockNumber: BigInt): Option[Account] = ???
186182

187183
override def getAccountStorageAt(rootHash: ByteString, position: BigInt, ethCompatibleStorage: Boolean): ByteString =
@@ -202,6 +198,12 @@ class BlockchainMock(genesisHash: ByteString) extends Blockchain {
202198

203199
override def getLatestCheckpointBlockNumber(): BigInt = ???
204200

201+
override def isInChain(hash: NodeHash): Boolean = ???
202+
203+
override def genesisHeader: BlockHeader = ???
204+
205+
override def genesisBlock: Block = ???
206+
205207
override def getBackingMptStorage(blockNumber: BigInt): MptStorage = ???
206208

207209
override def getReadOnlyMptStorage(): MptStorage = ???

src/main/scala/io/iohk/ethereum/blockchain/data/GenesisDataLoader.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ import org.bouncycastle.util.encoders.Hex
2323
import scala.io.Source
2424
import scala.util.{Failure, Success, Try}
2525

26-
class GenesisDataLoader(blockchain: Blockchain, stateStorage: StateStorage, blockchainConfig: BlockchainConfig)
27-
extends Logger {
26+
class GenesisDataLoader(
27+
blockchain: Blockchain,
28+
blockchainReader: BlockchainReader,
29+
stateStorage: StateStorage,
30+
blockchainConfig: BlockchainConfig
31+
) extends Logger {
2832

2933
private val bloomLength = 512
3034
private val hashLength = 64
@@ -99,7 +103,7 @@ class GenesisDataLoader(blockchain: Blockchain, stateStorage: StateStorage, bloc
99103

100104
log.debug(s"Prepared genesis header: $header")
101105

102-
blockchain.getBlockHeaderByNumber(0) match {
106+
blockchainReader.getBlockHeaderByNumber(0) match {
103107
case Some(existingGenesisHeader) if existingGenesisHeader.hash == header.hash =>
104108
log.debug("Genesis data already in the database")
105109
Success(())

0 commit comments

Comments
 (0)