-
Notifications
You must be signed in to change notification settings - Fork 75
[ETCM-964] Fix preimage cache to make vmArithmeticTest pass #1029
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,15 +63,7 @@ class BlockExecution( | |
parentHeader <- blockchainReader | ||
.getBlockHeaderByHash(block.header.parentHash) | ||
.toRight(MissingParentError) // Should not never occur because validated earlier | ||
initialWorld = InMemoryWorldStateProxy( | ||
evmCodeStorage = evmCodeStorage, | ||
blockchain.getBackingMptStorage(block.header.number), | ||
(number: BigInt) => blockchainReader.getBlockHeaderByNumber(number).map(_.hash), | ||
accountStartNonce = blockchainConfig.accountStartNonce, | ||
stateRootHash = parentHeader.stateRoot, | ||
noEmptyAccounts = EvmConfig.forBlock(parentHeader.number, blockchainConfig).noEmptyAccounts, | ||
ethCompatibleStorage = blockchainConfig.ethCompatibleStorage | ||
) | ||
initialWorld = buildInitialWorld(block, parentHeader) | ||
execResult <- executeBlockTransactions(block, initialWorld) | ||
worldToPersist <- Either | ||
.catchOnly[MPTException](blockPreparator.payBlockReward(block, execResult.worldState)) | ||
|
@@ -81,6 +73,18 @@ class BlockExecution( | |
} yield execResult.copy(worldState = worldPersisted) | ||
} | ||
|
||
protected def buildInitialWorld(block: Block, parentHeader: BlockHeader): InMemoryWorldStateProxy = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok this is weird. apparently this simple change causes this error :
The class is mentioned in the scaladoc, and replacing it with a full name with the namespace solves the problem. But I don't really understand how this change causes a problem. |
||
InMemoryWorldStateProxy( | ||
evmCodeStorage = evmCodeStorage, | ||
blockchain.getBackingMptStorage(block.header.number), | ||
(number: BigInt) => blockchainReader.getBlockHeaderByNumber(number).map(_.hash), | ||
accountStartNonce = blockchainConfig.accountStartNonce, | ||
stateRootHash = parentHeader.stateRoot, | ||
noEmptyAccounts = EvmConfig.forBlock(parentHeader.number, blockchainConfig).noEmptyAccounts, | ||
ethCompatibleStorage = blockchainConfig.ethCompatibleStorage | ||
) | ||
} | ||
|
||
/** This function runs transactions | ||
* | ||
* @param block the block with transactions to run | ||
|
@@ -144,7 +148,8 @@ class BlockExecution( | |
* @param blocks blocks to be executed | ||
* @param parentChainWeight parent weight | ||
* | ||
* @return a list of blocks in incremental order that were correctly executed and an optional [[BlockExecutionError]] | ||
* @return a list of blocks in incremental order that were correctly executed and an optional | ||
* [[io.iohk.ethereum.ledger.BlockExecutionError]] | ||
*/ | ||
def executeAndValidateBlocks( | ||
blocks: List[Block], | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
src/main/scala/io/iohk/ethereum/testmode/TestBlockchainBuilder.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/scala/io/iohk/ethereum/testmode/TestModeBlockExecution.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.iohk.ethereum.testmode | ||
|
||
import akka.util.ByteString | ||
import io.iohk.ethereum.crypto | ||
import io.iohk.ethereum.db.storage.EvmCodeStorage | ||
import io.iohk.ethereum.domain.{Block, BlockHeader, BlockchainImpl, BlockchainReader, UInt256} | ||
import io.iohk.ethereum.ledger.{BlockExecution, BlockPreparator, BlockValidation, InMemoryWorldStateProxy} | ||
import io.iohk.ethereum.utils.BlockchainConfig | ||
import io.iohk.ethereum.vm.EvmConfig | ||
|
||
class TestModeBlockExecution( | ||
blockchain: BlockchainImpl, | ||
blockchainReader: BlockchainReader, | ||
evmCodeStorage: EvmCodeStorage, | ||
blockchainConfig: BlockchainConfig, | ||
blockPreparator: BlockPreparator, | ||
blockValidation: BlockValidation, | ||
saveStoragePreimage: (UInt256) => Unit | ||
) extends BlockExecution( | ||
blockchain, | ||
blockchainReader, | ||
evmCodeStorage, | ||
blockchainConfig, | ||
blockPreparator, | ||
blockValidation | ||
) { | ||
|
||
override protected def buildInitialWorld(block: Block, parentHeader: BlockHeader): InMemoryWorldStateProxy = | ||
TestModeWorldStateProxy( | ||
evmCodeStorage = evmCodeStorage, | ||
nodesKeyValueStorage = blockchain.getBackingMptStorage(block.header.number), | ||
getBlockHashByNumber = (number: BigInt) => blockchainReader.getBlockHeaderByNumber(number).map(_.hash), | ||
accountStartNonce = blockchainConfig.accountStartNonce, | ||
stateRootHash = parentHeader.stateRoot, | ||
noEmptyAccounts = EvmConfig.forBlock(parentHeader.number, blockchainConfig).noEmptyAccounts, | ||
ethCompatibleStorage = blockchainConfig.ethCompatibleStorage, | ||
saveStoragePreimage = saveStoragePreimage | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this
preimageCache
is used to store only storage data. If that's the case it would make sense to make this obvious from the type definition by usingAnyVal
wrappers forByteString
andUInt256
like sayStorageHash
,StorageKey