Skip to content

ETCM-986 Remove method storeEvmCode from Blockchain #1037

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

Merged
merged 1 commit into from
Jul 7, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ class BlockchainMock(genesisHash: ByteString) extends Blockchain {

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

override def storeEvmCode(hash: ByteString, evmCode: ByteString): DataSourceBatchUpdate = ???

override def storeChainWeight(blockhash: ByteString, chainWeight: ChainWeight): DataSourceBatchUpdate = ???

override def saveNode(nodeHash: NodeHash, nodeEncoded: NodeEncoded, blockNumber: BigInt): Unit = ???
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@ class SyncStateScheduler(
nodes.foreach { case (hash, (data, reqType)) =>
bloomFilter.put(hash)
reqType match {
case _: CodeRequest =>
blockchain.storeEvmCode(hash, data).commit()
case _: NodeRequest =>
blockchain.saveNode(hash, data.toArray, targetBlockNumber)
case _: CodeRequest => evmCodeStorage.put(hash, data).commit()
case _: NodeRequest => blockchain.saveNode(hash, data.toArray, targetBlockNumber)
}
}
newState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object Storages {

override val nodeStorage: NodeStorage = new NodeStorage(dataSource)

override val cachedNodeStorage: CachedNodeStorage = new CachedNodeStorage(nodeStorage, caches.nodeCache)
val cachedNodeStorage: CachedNodeStorage = new CachedNodeStorage(nodeStorage, caches.nodeCache)

override val fastSyncStateStorage: FastSyncStateStorage = new FastSyncStateStorage(dataSource)

Expand Down
8 changes: 0 additions & 8 deletions src/main/scala/io/iohk/ethereum/domain/Blockchain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ trait Blockchain {

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

def storeEvmCode(hash: ByteString, evmCode: ByteString): DataSourceBatchUpdate

def storeChainWeight(blockhash: ByteString, weight: ChainWeight): DataSourceBatchUpdate

def saveBestKnownBlocks(bestBlockNumber: BigInt, latestCheckpointNumber: Option[BigInt] = None): Unit
Expand All @@ -137,7 +135,6 @@ class BlockchainImpl(
protected val blockBodiesStorage: BlockBodiesStorage,
protected val blockNumberMappingStorage: BlockNumberMappingStorage,
protected val receiptStorage: ReceiptStorage,
protected val evmCodeStorage: EvmCodeStorage,
protected val chainWeightStorage: ChainWeightStorage,
protected val transactionMappingStorage: TransactionMappingStorage,
protected val appStateStorage: AppStateStorage,
Expand Down Expand Up @@ -305,9 +302,6 @@ class BlockchainImpl(
override def storeReceipts(blockHash: ByteString, receipts: Seq[Receipt]): DataSourceBatchUpdate =
receiptStorage.put(blockHash, receipts)

override def storeEvmCode(hash: ByteString, evmCode: ByteString): DataSourceBatchUpdate =
evmCodeStorage.put(hash, evmCode)

override def saveBestKnownBlocks(bestBlockNumber: BigInt, latestCheckpointNumber: Option[BigInt] = None): Unit =
latestCheckpointNumber match {
case Some(number) =>
Expand Down Expand Up @@ -463,7 +457,6 @@ trait BlockchainStorages {
val chainWeightStorage: ChainWeightStorage
val transactionMappingStorage: TransactionMappingStorage
val appStateStorage: AppStateStorage
val cachedNodeStorage: CachedNodeStorage
val stateStorage: StateStorage
}

Expand All @@ -474,7 +467,6 @@ object BlockchainImpl {
blockBodiesStorage = storages.blockBodiesStorage,
blockNumberMappingStorage = storages.blockNumberMappingStorage,
receiptStorage = storages.receiptStorage,
evmCodeStorage = storages.evmCodeStorage,
chainWeightStorage = storages.chainWeightStorage,
transactionMappingStorage = storages.transactionMappingStorage,
appStateStorage = storages.appStateStorage,
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/io/iohk/ethereum/jsonrpc/TestService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.iohk.ethereum.consensus.ConsensusConfig
import io.iohk.ethereum.consensus.blocks._
import io.iohk.ethereum.crypto
import io.iohk.ethereum.crypto.kec256
import io.iohk.ethereum.db.storage.EvmCodeStorage
import io.iohk.ethereum.db.storage.StateStorage
import io.iohk.ethereum.db.storage.TransactionMappingStorage
import io.iohk.ethereum.domain
Expand Down Expand Up @@ -133,6 +134,7 @@ class TestService(
blockchain: BlockchainImpl,
blockchainReader: BlockchainReader,
stateStorage: StateStorage,
evmCodeStorage: EvmCodeStorage,
pendingTransactionsManager: ActorRef,
consensusConfig: ConsensusConfig,
testModeComponentsProvider: TestModeComponentsProvider,
Expand Down Expand Up @@ -243,7 +245,7 @@ class TestService(
private def storeGenesisAccountCodes(accounts: Map[String, GenesisAccount]): Unit =
accounts
.collect { case (_, GenesisAccount(_, _, Some(code), _, _)) => code }
.foreach(code => blockchain.storeEvmCode(kec256(code), code).commit())
.foreach(code => evmCodeStorage.put(kec256(code), code).commit())

private def storeGenesisAccountStorageData(accounts: Map[String, GenesisAccount]): Unit = {
val emptyStorage = domain.EthereumUInt256Mpt.storageMpt(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import scala.annotation.tailrec
import io.iohk.ethereum.db.storage.EvmCodeStorage
import io.iohk.ethereum.domain._
import io.iohk.ethereum.ledger.BlockExecutionError.MissingParentError
import io.iohk.ethereum.ledger.BlockResult
import io.iohk.ethereum.mpt.MerklePatriciaTrie.MPTException
import io.iohk.ethereum.utils.BlockchainConfig
import io.iohk.ethereum.utils.DaoForkConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ trait TestServiceBuilder {
blockchain,
blockchainReader,
storagesInstance.storages.stateStorage,
storagesInstance.storages.evmCodeStorage,
pendingTransactionsManager,
consensusConfig,
testModeComponentsProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ trait TestBlockchainBuilder extends BlockchainBuilder {
blockBodiesStorage = storages.blockBodiesStorage,
blockNumberMappingStorage = storages.blockNumberMappingStorage,
receiptStorage = storages.receiptStorage,
evmCodeStorage = storages.evmCodeStorage,
chainWeightStorage = storages.chainWeightStorage,
transactionMappingStorage = storages.transactionMappingStorage,
appStateStorage = storages.appStateStorage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class BlockchainHostActorSpec extends AnyFlatSpec with Matchers {
val fakeEvmCode = ByteString(Hex.decode("ffddaaffddaaffddaaffddaaffddaa"))
val evmCodeHash: ByteString = ByteString(crypto.kec256(fakeEvmCode.toArray[Byte]))

blockchain.storeEvmCode(evmCodeHash, fakeEvmCode).commit()
storagesInstance.storages.evmCodeStorage.put(evmCodeHash, fakeEvmCode).commit()

//when
blockchainHost ! MessageFromPeer(GetNodeData(Seq(evmCodeHash)), peerId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ class BlockchainSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyCh
storagesInstance.storages.nodeStorage
storagesInstance.storages.pruningMode
val appStateStorage = storagesInstance.storages.appStateStorage
val cachedNodeStorage = storagesInstance.storages.cachedNodeStorage
val stateStorage = stubStateStorage
}
override val blockchainReaderWithStubPersisting = BlockchainReader(blockchainStoragesWithStubPersisting)
Expand Down