@@ -6,6 +6,9 @@ import io.iohk.ethereum.ledger.Ledger.BlockResult
6
6
import io .iohk .ethereum .utils .{BlockchainConfig , DaoForkConfig , Logger }
7
7
import io .iohk .ethereum .vm .EvmConfig
8
8
import scala .annotation .tailrec
9
+ import scala .util .Try
10
+ import akka .util .ByteString
11
+ import io .iohk .ethereum .mpt .MerklePatriciaTrie .MissingNodeException
9
12
10
13
class BlockExecution (
11
14
blockchain : BlockchainImpl ,
@@ -59,7 +62,9 @@ class BlockExecution(
59
62
.getBlockHeaderByHash(block.header.parentHash)
60
63
.toRight(MissingParentError ) // Should not never occur because validated earlier
61
64
execResult <- executeBlockTransactions(block, parent)
62
- worldToPersist = blockPreparator.payBlockReward(block, execResult.worldState)
65
+ worldToPersist <- Try {
66
+ blockPreparator.payBlockReward(block, execResult.worldState)
67
+ }.toEither.left.map(BlockExecutionError .MPTError (_))
63
68
// State root hash needs to be up-to-date for validateBlockAfterExecution
64
69
worldPersisted = InMemoryWorldStateProxy .persistState(worldToPersist)
65
70
} yield execResult.copy(worldState = worldPersisted)
@@ -184,4 +189,6 @@ object BlockExecutionError {
184
189
case object MissingParentError extends BlockExecutionError {
185
190
override val reason : Any = " Cannot find parent"
186
191
}
192
+
193
+ case class MPTError (reason : Throwable ) extends BlockExecutionError
187
194
}
0 commit comments