@@ -6,12 +6,6 @@ import (
6
6
"github.com/ethereum/go-ethereum/rlp"
7
7
)
8
8
9
- func PrepareBranchNode (branch1 , branch2 , extNode1 , extNode2 , extListRlpBytes []byte , extValues [][]byte , key , driftedInd byte ,
10
- isBranchSPlaceholder , isBranchCPlaceholder , isExtension bool ) Node {
11
- return prepareBranchNode (branch1 , branch2 , extNode1 , extNode2 , extListRlpBytes , extValues , key , driftedInd ,
12
- isBranchSPlaceholder , isBranchCPlaceholder , isExtension )
13
- }
14
-
15
9
// isBranch takes GetProof element and returns whether the element is a branch.
16
10
func isBranch (proofEl []byte ) bool {
17
11
elems , _ , err := rlp .SplitList (proofEl )
@@ -25,23 +19,6 @@ func isBranch(proofEl []byte) bool {
25
19
return c == 17
26
20
}
27
21
28
- func isTxLeaf (proofEl []byte ) bool {
29
- elems , _ , err := rlp .SplitList (proofEl )
30
- check (err )
31
- c , err1 := rlp .CountValues (elems )
32
- check (err1 )
33
- // 2: hashed node
34
- // 9: for tx (Nonce, Gas, GasPrice, Value, To, Data, r, s, v)
35
- // ext node is also 2
36
- return (c == 9 || c == 2 ) && ! isTxExt (proofEl )
37
- }
38
-
39
- func isTxExt (proofEl []byte ) bool {
40
- elems , _ , _ := rlp .SplitList (proofEl )
41
- idx := proofEl [0 ] - 225
42
- return len (proofEl ) < 50 && proofEl [0 ] < 248 && elems [idx ] == 160
43
- }
44
-
45
22
// prepareBranchWitness takes the rows that are to be filled with branch data and it takes
46
23
// a branch as returned by GetProof. There are 19 rows for a branch and prepareBranchWitness
47
24
// fills the rows from index 1 to index 16 (index 0 is init, index 17 and 18 are for extension
@@ -53,7 +30,7 @@ func prepareBranchWitness(rows [][]byte, branch []byte, branchStart int, branchR
53
30
rowInd := 1
54
31
colInd := branchNodeRLPLen - 1
55
32
56
- // TODO: if input branch is a leaf node , it'll work abnormally
33
+ // TODO: if the input is a leaf, it would throw exception
57
34
i := 0
58
35
insideInd := - 1
59
36
for {
@@ -238,8 +215,11 @@ func getDriftedPosition(leafKeyRow []byte, numberOfNibbles int) byte {
238
215
239
216
// addBranchAndPlaceholder adds to the rows a branch and its placeholder counterpart
240
217
// (used when one of the proofs have one branch more than the other).
241
- func addBranchAndPlaceholder (proof1 , proof2 [][]byte , extNibblesS , extNibblesC []byte ,
242
- extProofTx , leafRow0 , key []byte , keyIndex int , isShorterProofLastLeaf bool ,
218
+ func addBranchAndPlaceholder (
219
+ proof1 , proof2 [][]byte ,
220
+ extNibblesS , extNibblesC []byte ,
221
+ extProofTx , leafRow0 , key []byte ,
222
+ keyIndex int , isShorterProofLastLeaf bool ,
243
223
) (bool , bool , int , Node ) {
244
224
245
225
len1 := len (proof1 )
@@ -261,6 +241,7 @@ func addBranchAndPlaceholder(proof1, proof2 [][]byte, extNibblesS, extNibblesC [
261
241
var proof []byte
262
242
var extNibbles []byte
263
243
if isTxProof {
244
+ // At 16th tx, the length of proofS/C is 2 only
264
245
extNibbles = extNibblesS
265
246
proof = extProofTx
266
247
} else {
@@ -325,7 +306,7 @@ func addBranchAndPlaceholder(proof1, proof2 [][]byte, extNibblesS, extNibblesC [
325
306
}
326
307
327
308
// Note that isModifiedExtNode happens also when we have a branch instead of shortExtNode
328
- isModifiedExtNode := ( ! isBranch (longExtNode ) && ! isShorterProofLastLeaf )
309
+ isModifiedExtNode := ! isBranch (longExtNode ) && ! isShorterProofLastLeaf
329
310
330
311
// We now get the first nibble of the leaf that was turned into branch.
331
312
// This first nibble presents the position of the leaf once it moved
0 commit comments