Skip to content

Commit bf28b94

Browse files
committed
Fix descriptions
1 parent 217aceb commit bf28b94

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

src/it/scala/io/iohk/ethereum/ledger/BlockImporterItSpec.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class BlockImporterItSpec extends MockFactory with TestSetupWithVmAndValidators
129129
blockchain.getBestBlock().get shouldEqual oldBlock4
130130
}
131131

132-
it should "return a correct new best block after reorganising longer chain to a shorter one" in {
132+
it should "return a correct new best block after reorganising longer chain to a shorter one if its weight is bigger" in {
133133

134134
//returning discarded initial chain
135135
blockchain.save(oldBlock2, Nil, oldWeight2, saveAsBestBlock = true)
@@ -145,8 +145,8 @@ class BlockImporterItSpec extends MockFactory with TestSetupWithVmAndValidators
145145

146146
it should "switch to a branch with a checkpoint" in {
147147

148-
val chackpoint = ObjectGenerators.fakeCheckpointGen(3, 3).sample.get
149-
val oldBlock5WithCheckpoint: Block = checkpointBlockGenerator.generate(oldBlock4, chackpoint)
148+
val checkpoint = ObjectGenerators.fakeCheckpointGen(3, 3).sample.get
149+
val oldBlock5WithCheckpoint: Block = checkpointBlockGenerator.generate(oldBlock4, checkpoint)
150150
blockchain.save(oldBlock5WithCheckpoint, Nil, oldWeight4, saveAsBestBlock = true)
151151

152152
val newBranch = List(newBlock2, newBlock3)
@@ -158,10 +158,10 @@ class BlockImporterItSpec extends MockFactory with TestSetupWithVmAndValidators
158158
blockchain.getLatestCheckpointBlockNumber() shouldEqual oldBlock5WithCheckpoint.header.number
159159
}
160160

161-
it should "return a correct checkpointed block after reorganising longer chain to a shorter one and back" in {
161+
it should "switch to a branch with a newer checkpoint" in {
162162

163-
val chackpoint = ObjectGenerators.fakeCheckpointGen(3, 3).sample.get
164-
val newBlock4WithCheckpoint: Block = checkpointBlockGenerator.generate(newBlock3, chackpoint)
163+
val checkpoint = ObjectGenerators.fakeCheckpointGen(3, 3).sample.get
164+
val newBlock4WithCheckpoint: Block = checkpointBlockGenerator.generate(newBlock3, checkpoint)
165165
blockchain.save(newBlock4WithCheckpoint, Nil, newWeight3, saveAsBestBlock = true)
166166

167167
val newBranch = List(newBlock4WithCheckpoint)
@@ -173,7 +173,7 @@ class BlockImporterItSpec extends MockFactory with TestSetupWithVmAndValidators
173173
blockchain.getLatestCheckpointBlockNumber() shouldEqual newBlock4WithCheckpoint.header.number
174174
}
175175

176-
it should "return a correct checkpointed block after receiving a new chackpoint from morpho" in {
176+
it should "return a correct checkpointed block after receiving a request for generating a new checkpoint" in {
177177

178178
val parent = blockchain.getBestBlock().get
179179
val newBlock5: Block = getBlock(genesisBlock.number + 5, difficulty = 104, parent = parent.header.hash)

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ 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
9+
import cats.implicits._
1210

1311
class BlockExecution(
1412
blockchain: BlockchainImpl,
@@ -62,9 +60,8 @@ class BlockExecution(
6260
.getBlockHeaderByHash(block.header.parentHash)
6361
.toRight(MissingParentError) // Should not never occur because validated earlier
6462
execResult <- executeBlockTransactions(block, parent)
65-
worldToPersist <- Try {
66-
blockPreparator.payBlockReward(block, execResult.worldState)
67-
}.toEither.left.map(BlockExecutionError.MPTError(_))
63+
worldToPersist <- Either.catchOnly[Throwable](blockPreparator.payBlockReward(block, execResult.worldState))
64+
.leftMap(BlockExecutionError.MPTError.apply)
6865
// State root hash needs to be up-to-date for validateBlockAfterExecution
6966
worldPersisted = InMemoryWorldStateProxy.persistState(worldToPersist)
7067
} yield execResult.copy(worldState = worldPersisted)
@@ -174,21 +171,21 @@ sealed trait BlockExecutionError {
174171

175172
sealed trait BlockExecutionSuccess
176173

177-
case object BlockExecutionSuccess extends BlockExecutionSuccess
174+
final case object BlockExecutionSuccess extends BlockExecutionSuccess
178175

179176
object BlockExecutionError {
180-
case class ValidationBeforeExecError(reason: Any) extends BlockExecutionError
177+
final case class ValidationBeforeExecError(reason: Any) extends BlockExecutionError
181178

182-
case class StateBeforeFailure(worldState: InMemoryWorldStateProxy, acumGas: BigInt, acumReceipts: Seq[Receipt])
179+
final case class StateBeforeFailure(worldState: InMemoryWorldStateProxy, acumGas: BigInt, acumReceipts: Seq[Receipt])
183180

184-
case class TxsExecutionError(stx: SignedTransaction, stateBeforeError: StateBeforeFailure, reason: String)
181+
final case class TxsExecutionError(stx: SignedTransaction, stateBeforeError: StateBeforeFailure, reason: String)
185182
extends BlockExecutionError
186183

187-
case class ValidationAfterExecError(reason: String) extends BlockExecutionError
184+
final case class ValidationAfterExecError(reason: String) extends BlockExecutionError
188185

189-
case object MissingParentError extends BlockExecutionError {
186+
final case object MissingParentError extends BlockExecutionError {
190187
override val reason: Any = "Cannot find parent"
191188
}
192189

193-
case class MPTError(reason: Throwable) extends BlockExecutionError
190+
final case class MPTError(reason: Throwable) extends BlockExecutionError
194191
}

0 commit comments

Comments
 (0)