Skip to content

Commit 4ba7d45

Browse files
committed
[ETCM-533] scalafmt
1 parent 7620a47 commit 4ba7d45

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

src/main/scala/io/iohk/ethereum/jsonrpc/EthProofService.scala

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import cats.implicits._
55
import io.iohk.ethereum.consensus.blocks.BlockGenerator
66
import io.iohk.ethereum.domain.{Account, Address, Block, Blockchain, UInt256}
77
import io.iohk.ethereum.jsonrpc.ProofService.StorageValueProof.asRlpSerializedNode
8-
import io.iohk.ethereum.jsonrpc.ProofService.{GetProofRequest, GetProofResponse, ProofAccount, StorageProof, StorageProofKey, StorageValueProof}
8+
import io.iohk.ethereum.jsonrpc.ProofService.{
9+
GetProofRequest,
10+
GetProofResponse,
11+
ProofAccount,
12+
StorageProof,
13+
StorageProofKey,
14+
StorageValueProof
15+
}
916
import io.iohk.ethereum.mpt.{MptNode, MptTraversals}
1017
import monix.eval.Task
1118

@@ -30,6 +37,7 @@ object ProofService {
3037
val value: BigInt
3138
val proof: Seq[ByteString]
3239
}
40+
3341
/**
3442
* Object proving a relationship of a storage value to an account's storageHash
3543
*
@@ -40,13 +48,16 @@ object ProofService {
4048
case class StorageValueProof(
4149
key: StorageProofKey,
4250
value: BigInt = BigInt(0),
43-
proof: Seq[ByteString] = Seq.empty[MptNode].map(asRlpSerializedNode)) extends StorageProof
51+
proof: Seq[ByteString] = Seq.empty[MptNode].map(asRlpSerializedNode)
52+
) extends StorageProof
4453

4554
object StorageValueProof {
4655
def apply(position: BigInt, value: Option[BigInt], proof: Option[Vector[MptNode]]): StorageValueProof =
4756
(value, proof) match {
48-
case (Some(value), Some(proof)) => new StorageValueProof(key = StorageProofKey(position), value = value, proof = proof.map(asRlpSerializedNode))
49-
case (None, Some(proof)) => new StorageValueProof(key = StorageProofKey(position), proof = proof.map(asRlpSerializedNode))
57+
case (Some(value), Some(proof)) =>
58+
new StorageValueProof(key = StorageProofKey(position), value = value, proof = proof.map(asRlpSerializedNode))
59+
case (None, Some(proof)) =>
60+
new StorageValueProof(key = StorageProofKey(position), proof = proof.map(asRlpSerializedNode))
5061
case (Some(value), None) => new StorageValueProof(key = StorageProofKey(position), value = value)
5162
case (None, None) => new StorageValueProof(key = StorageProofKey(position))
5263
}

src/main/scala/io/iohk/ethereum/mpt/MerklePatriciaTrie.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import io.iohk.ethereum.rlp.RLPImplicits._
99
import io.iohk.ethereum.rlp.{encode => encodeRLP}
1010
import org.bouncycastle.util.encoders.Hex
1111
import io.iohk.ethereum.utils.ByteUtils.matchingLength
12-
1312
import scala.annotation.tailrec
1413

1514
object MerklePatriciaTrie {
@@ -103,7 +102,8 @@ class MerklePatriciaTrie[K, V] private (private[mpt] val rootNode: Option[MptNod
103102
def getProof(key: K): Option[Vector[MptNode]] = {
104103
pathTraverse[Vector[MptNode]](Vector.empty, mkKeyNibbles(key)) { case (acc, node) =>
105104
node match {
106-
case Some(nextNodeOnExt @ (_: BranchNode | _: ExtensionNode | _: LeafNode | _: HashNode)) => acc :+ nextNodeOnExt
105+
case Some(nextNodeOnExt @ (_: BranchNode | _: ExtensionNode | _: LeafNode | _: HashNode)) =>
106+
acc :+ nextNodeOnExt
107107
case _ => acc
108108
}
109109
}

src/test/scala/io/iohk/ethereum/domain/BlockchainSpec.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import io.iohk.ethereum.consensus.blocks.CheckpointBlockGenerator
66
import io.iohk.ethereum.db.dataSource.EphemDataSource
77
import io.iohk.ethereum.db.storage.StateStorage
88
import io.iohk.ethereum.domain.BlockHeader.HeaderExtraFields.HefPostEcip1097
9-
import io.iohk.ethereum.mpt.MerklePatriciaTrie
9+
import io.iohk.ethereum.mpt.{HashNode, MerklePatriciaTrie}
1010
import io.iohk.ethereum.{BlockHelpers, Fixtures, ObjectGenerators}
1111
import io.iohk.ethereum.ObjectGenerators._
1212
import io.iohk.ethereum.proof.MptProofVerifier
@@ -177,9 +177,11 @@ class BlockchainSpec extends AnyFlatSpec with Matchers with ScalaCheckPropertyCh
177177

178178
val wrongAddress = Address(666)
179179
val retrievedAccountProofWrong = blockchain.getAccountProof(wrongAddress, headerWithAcc.number)
180-
//the account doesn't exist, so we can't retrieve it, but we do receive a proof of non-existence with a full path of nodes that we iterated
181-
retrievedAccountProofWrong.isDefined shouldBe true
182-
retrievedAccountProofWrong.size shouldBe 1
180+
//the account doesn't exist, so we can't retrieve it, but we do receive a proof of non-existence with a full path of nodes(root node) that we iterated
181+
(retrievedAccountProofWrong.getOrElse(Vector.empty).toList match {
182+
case _ @HashNode(_) :: Nil => true
183+
case _ => false
184+
}) shouldBe true
183185
mptWithAcc.get(wrongAddress) shouldBe None
184186
}
185187

0 commit comments

Comments
 (0)