@@ -4,7 +4,7 @@ import akka.util.ByteString
4
4
import cats .implicits ._
5
5
import io .iohk .ethereum .consensus .blocks .BlockGenerator
6
6
import io .iohk .ethereum .domain .{Account , Address , Block , Blockchain , UInt256 }
7
- import io .iohk .ethereum .jsonrpc .ProofService .StorageValueProof .asRlpSerializedNode
7
+ import io .iohk .ethereum .jsonrpc .ProofService .StorageProof .asRlpSerializedNode
8
8
import io .iohk .ethereum .jsonrpc .ProofService .{
9
9
GetProofRequest ,
10
10
GetProofResponse ,
@@ -34,41 +34,38 @@ object ProofService {
34
34
35
35
sealed trait StorageProof {
36
36
val key : StorageProofKey
37
- val value : BigInt
38
- val proof : Seq [ByteString ]
37
+ val value : BigInt = BigInt ( 0 )
38
+ val proof : Seq [ByteString ] = Seq .empty[ MptNode ].map(asRlpSerializedNode)
39
39
}
40
40
41
- /**
42
- * Object proving a relationship of a storage value to an account's storageHash
43
- *
44
- * @param key storage proof key
45
- * @param value the value of the storage slot in its account tree
46
- * @param proof the set of node values needed to traverse a patricia merkle tree (from root to leaf) to retrieve a value
47
- */
48
- case class StorageValueProof (
49
- key : StorageProofKey ,
50
- value : BigInt = BigInt (0 ),
51
- proof : Seq [ByteString ] = Seq .empty[MptNode ].map(asRlpSerializedNode)
52
- ) extends StorageProof
53
-
54
- object StorageValueProof {
55
- def apply (position : BigInt , value : Option [BigInt ], proof : Option [Vector [MptNode ]]): StorageValueProof =
41
+ object StorageProof {
42
+ def apply (position : BigInt , value : Option [BigInt ], proof : Option [Vector [MptNode ]]): StorageProof =
56
43
(value, proof) match {
57
44
case (Some (value), Some (proof)) =>
58
- new StorageValueProof (key = StorageProofKey (position), value = value, proof = proof.map(asRlpSerializedNode))
45
+ StorageValueProof (StorageProofKey (position), value, proof.map(asRlpSerializedNode))
59
46
case (None , Some (proof)) =>
60
- new StorageValueProof (key = StorageProofKey (position), proof = proof.map(asRlpSerializedNode))
61
- case (Some (value), None ) => new StorageValueProof (key = StorageProofKey (position), value = value)
62
- case (None , None ) => new StorageValueProof (key = StorageProofKey (position))
47
+ EmptyStorageValue ( StorageProofKey (position), proof.map(asRlpSerializedNode))
48
+ case (Some (value), None ) => EmptyStorageProof ( StorageProofKey (position), value)
49
+ case (None , None ) => EmptyStorageValueProof ( StorageProofKey (position))
63
50
}
64
51
65
- def apply (position : BigInt ): StorageValueProof =
66
- new StorageValueProof (key = StorageProofKey (position))
67
-
68
52
def asRlpSerializedNode (node : MptNode ): ByteString =
69
53
ByteString (MptTraversals .encodeNode(node))
70
54
}
71
55
56
+ /**
57
+ * Object proving a relationship of a storage value to an account's storageHash
58
+ *
59
+ * @param key storage proof key
60
+ * @param value the value of the storage slot in its account tree
61
+ * @param proof the set of node values needed to traverse a patricia merkle tree (from root to leaf) to retrieve a value
62
+ */
63
+ case class EmptyStorageValueProof (key : StorageProofKey ) extends StorageProof
64
+ case class EmptyStorageValue (key : StorageProofKey , override val proof : Seq [ByteString ]) extends StorageProof
65
+ case class EmptyStorageProof (key : StorageProofKey , override val value : BigInt ) extends StorageProof
66
+ case class StorageValueProof (key : StorageProofKey , override val value : BigInt , override val proof : Seq [ByteString ])
67
+ extends StorageProof
68
+
72
69
/** The key used to get the storage slot in its account tree */
73
70
case class StorageProofKey (v : BigInt ) extends AnyVal
74
71
0 commit comments