Skip to content

Commit c538465

Browse files
author
Leonor Boga
authored
ETCM-986 Remove method storeEvmCode from Blockchain class and use EvmCodestorage direclty (#1037)
1 parent 6b0ce37 commit c538465

File tree

10 files changed

+8
-20
lines changed

10 files changed

+8
-20
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ class BlockchainMock(genesisHash: ByteString) extends Blockchain {
191191

192192
override def storeReceipts(blockHash: ByteString, receipts: Seq[Receipt]): DataSourceBatchUpdate = ???
193193

194-
override def storeEvmCode(hash: ByteString, evmCode: ByteString): DataSourceBatchUpdate = ???
195-
196194
override def storeChainWeight(blockhash: ByteString, chainWeight: ChainWeight): DataSourceBatchUpdate = ???
197195

198196
override def saveNode(nodeHash: NodeHash, nodeEncoded: NodeEncoded, blockNumber: BigInt): Unit = ???

src/main/scala/io/iohk/ethereum/blockchain/sync/fast/SyncStateScheduler.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,8 @@ class SyncStateScheduler(
132132
nodes.foreach { case (hash, (data, reqType)) =>
133133
bloomFilter.put(hash)
134134
reqType match {
135-
case _: CodeRequest =>
136-
blockchain.storeEvmCode(hash, data).commit()
137-
case _: NodeRequest =>
138-
blockchain.saveNode(hash, data.toArray, targetBlockNumber)
135+
case _: CodeRequest => evmCodeStorage.put(hash, data).commit()
136+
case _: NodeRequest => blockchain.saveNode(hash, data.toArray, targetBlockNumber)
139137
}
140138
}
141139
newState

src/main/scala/io/iohk/ethereum/db/components/Storages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Storages {
3131

3232
override val nodeStorage: NodeStorage = new NodeStorage(dataSource)
3333

34-
override val cachedNodeStorage: CachedNodeStorage = new CachedNodeStorage(nodeStorage, caches.nodeCache)
34+
val cachedNodeStorage: CachedNodeStorage = new CachedNodeStorage(nodeStorage, caches.nodeCache)
3535

3636
override val fastSyncStateStorage: FastSyncStateStorage = new FastSyncStateStorage(dataSource)
3737

src/main/scala/io/iohk/ethereum/domain/Blockchain.scala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ trait Blockchain {
111111

112112
def storeReceipts(blockHash: ByteString, receipts: Seq[Receipt]): DataSourceBatchUpdate
113113

114-
def storeEvmCode(hash: ByteString, evmCode: ByteString): DataSourceBatchUpdate
115-
116114
def storeChainWeight(blockhash: ByteString, weight: ChainWeight): DataSourceBatchUpdate
117115

118116
def saveBestKnownBlocks(bestBlockNumber: BigInt, latestCheckpointNumber: Option[BigInt] = None): Unit
@@ -137,7 +135,6 @@ class BlockchainImpl(
137135
protected val blockBodiesStorage: BlockBodiesStorage,
138136
protected val blockNumberMappingStorage: BlockNumberMappingStorage,
139137
protected val receiptStorage: ReceiptStorage,
140-
protected val evmCodeStorage: EvmCodeStorage,
141138
protected val chainWeightStorage: ChainWeightStorage,
142139
protected val transactionMappingStorage: TransactionMappingStorage,
143140
protected val appStateStorage: AppStateStorage,
@@ -305,9 +302,6 @@ class BlockchainImpl(
305302
override def storeReceipts(blockHash: ByteString, receipts: Seq[Receipt]): DataSourceBatchUpdate =
306303
receiptStorage.put(blockHash, receipts)
307304

308-
override def storeEvmCode(hash: ByteString, evmCode: ByteString): DataSourceBatchUpdate =
309-
evmCodeStorage.put(hash, evmCode)
310-
311305
override def saveBestKnownBlocks(bestBlockNumber: BigInt, latestCheckpointNumber: Option[BigInt] = None): Unit =
312306
latestCheckpointNumber match {
313307
case Some(number) =>
@@ -463,7 +457,6 @@ trait BlockchainStorages {
463457
val chainWeightStorage: ChainWeightStorage
464458
val transactionMappingStorage: TransactionMappingStorage
465459
val appStateStorage: AppStateStorage
466-
val cachedNodeStorage: CachedNodeStorage
467460
val stateStorage: StateStorage
468461
}
469462

@@ -474,7 +467,6 @@ object BlockchainImpl {
474467
blockBodiesStorage = storages.blockBodiesStorage,
475468
blockNumberMappingStorage = storages.blockNumberMappingStorage,
476469
receiptStorage = storages.receiptStorage,
477-
evmCodeStorage = storages.evmCodeStorage,
478470
chainWeightStorage = storages.chainWeightStorage,
479471
transactionMappingStorage = storages.transactionMappingStorage,
480472
appStateStorage = storages.appStateStorage,

src/main/scala/io/iohk/ethereum/jsonrpc/TestService.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import io.iohk.ethereum.consensus.ConsensusConfig
2121
import io.iohk.ethereum.consensus.blocks._
2222
import io.iohk.ethereum.crypto
2323
import io.iohk.ethereum.crypto.kec256
24+
import io.iohk.ethereum.db.storage.EvmCodeStorage
2425
import io.iohk.ethereum.db.storage.StateStorage
2526
import io.iohk.ethereum.db.storage.TransactionMappingStorage
2627
import io.iohk.ethereum.domain
@@ -133,6 +134,7 @@ class TestService(
133134
blockchain: BlockchainImpl,
134135
blockchainReader: BlockchainReader,
135136
stateStorage: StateStorage,
137+
evmCodeStorage: EvmCodeStorage,
136138
pendingTransactionsManager: ActorRef,
137139
consensusConfig: ConsensusConfig,
138140
testModeComponentsProvider: TestModeComponentsProvider,
@@ -243,7 +245,7 @@ class TestService(
243245
private def storeGenesisAccountCodes(accounts: Map[String, GenesisAccount]): Unit =
244246
accounts
245247
.collect { case (_, GenesisAccount(_, _, Some(code), _, _)) => code }
246-
.foreach(code => blockchain.storeEvmCode(kec256(code), code).commit())
248+
.foreach(code => evmCodeStorage.put(kec256(code), code).commit())
247249

248250
private def storeGenesisAccountStorageData(accounts: Map[String, GenesisAccount]): Unit = {
249251
val emptyStorage = domain.EthereumUInt256Mpt.storageMpt(

src/main/scala/io/iohk/ethereum/ledger/BlockExecution.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import scala.annotation.tailrec
77
import io.iohk.ethereum.db.storage.EvmCodeStorage
88
import io.iohk.ethereum.domain._
99
import io.iohk.ethereum.ledger.BlockExecutionError.MissingParentError
10-
import io.iohk.ethereum.ledger.BlockResult
1110
import io.iohk.ethereum.mpt.MerklePatriciaTrie.MPTException
1211
import io.iohk.ethereum.utils.BlockchainConfig
1312
import io.iohk.ethereum.utils.DaoForkConfig

src/main/scala/io/iohk/ethereum/nodebuilder/NodeBuilder.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ trait TestServiceBuilder {
441441
blockchain,
442442
blockchainReader,
443443
storagesInstance.storages.stateStorage,
444+
storagesInstance.storages.evmCodeStorage,
444445
pendingTransactionsManager,
445446
consensusConfig,
446447
testModeComponentsProvider,

src/main/scala/io/iohk/ethereum/testmode/TestBlockchainBuilder.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ trait TestBlockchainBuilder extends BlockchainBuilder {
1414
blockBodiesStorage = storages.blockBodiesStorage,
1515
blockNumberMappingStorage = storages.blockNumberMappingStorage,
1616
receiptStorage = storages.receiptStorage,
17-
evmCodeStorage = storages.evmCodeStorage,
1817
chainWeightStorage = storages.chainWeightStorage,
1918
transactionMappingStorage = storages.transactionMappingStorage,
2019
appStateStorage = storages.appStateStorage,

src/test/scala/io/iohk/ethereum/blockchain/sync/BlockchainHostActorSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class BlockchainHostActorSpec extends AnyFlatSpec with Matchers {
245245
val fakeEvmCode = ByteString(Hex.decode("ffddaaffddaaffddaaffddaaffddaa"))
246246
val evmCodeHash: ByteString = ByteString(crypto.kec256(fakeEvmCode.toArray[Byte]))
247247

248-
blockchain.storeEvmCode(evmCodeHash, fakeEvmCode).commit()
248+
storagesInstance.storages.evmCodeStorage.put(evmCodeHash, fakeEvmCode).commit()
249249

250250
//when
251251
blockchainHost ! MessageFromPeer(GetNodeData(Seq(evmCodeHash)), peerId)

src/test/scala/io/iohk/ethereum/domain/BlockchainSpec.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ class BlockchainSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyCh
298298
storagesInstance.storages.nodeStorage
299299
storagesInstance.storages.pruningMode
300300
val appStateStorage = storagesInstance.storages.appStateStorage
301-
val cachedNodeStorage = storagesInstance.storages.cachedNodeStorage
302301
val stateStorage = stubStateStorage
303302
}
304303
override val blockchainReaderWithStubPersisting = BlockchainReader(blockchainStoragesWithStubPersisting)

0 commit comments

Comments
 (0)