Skip to content

Commit 0822357

Browse files
Jaap van der PlasAnastasiiaL
authored andcommitted
catch exceptions during block reward payment (thrown by MPT implementation)
1 parent bf52f6c commit 0822357

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import io.iohk.ethereum.ledger.Ledger.BlockResult
66
import io.iohk.ethereum.utils.{BlockchainConfig, DaoForkConfig, Logger}
77
import io.iohk.ethereum.vm.EvmConfig
88
import scala.annotation.tailrec
9+
import scala.util.Try
10+
import akka.util.ByteString
11+
import io.iohk.ethereum.mpt.MerklePatriciaTrie.MissingNodeException
912

1013
class BlockExecution(
1114
blockchain: BlockchainImpl,
@@ -59,7 +62,9 @@ class BlockExecution(
5962
.getBlockHeaderByHash(block.header.parentHash)
6063
.toRight(MissingParentError) // Should not never occur because validated earlier
6164
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(_))
6368
// State root hash needs to be up-to-date for validateBlockAfterExecution
6469
worldPersisted = InMemoryWorldStateProxy.persistState(worldToPersist)
6570
} yield execResult.copy(worldState = worldPersisted)
@@ -184,4 +189,6 @@ object BlockExecutionError {
184189
case object MissingParentError extends BlockExecutionError {
185190
override val reason: Any = "Cannot find parent"
186191
}
192+
193+
case class MPTError(reason: Throwable) extends BlockExecutionError
187194
}

0 commit comments

Comments
 (0)