File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 36
36
CodeOffset = uint256 .NewInt (128 )
37
37
MainStorageOffset = new (uint256.Int ).Lsh (uint256 .NewInt (256 ), 31 )
38
38
VerkleNodeWidth = uint256 .NewInt (8 )
39
- codeStorageDelta = uint256 .NewInt (0 ).Sub (HeaderStorageOffset , CodeOffset )
39
+ codeStorageDelta = uint256 .NewInt (0 ).Sub (CodeOffset , HeaderStorageOffset )
40
40
)
41
41
42
42
func GetTreeKey (address []byte , treeIndex * uint256.Int , subIndex byte ) []byte {
@@ -94,10 +94,14 @@ func GetTreeKeyStorageSlot(address []byte, storageKey *uint256.Int) []byte {
94
94
treeIndex .Add (MainStorageOffset , storageKey )
95
95
}
96
96
treeIndex .Div (treeIndex , VerkleNodeWidth )
97
- subIndexMod := new (uint256.Int ).Mod (treeIndex , VerkleNodeWidth ).Bytes ()
97
+
98
+ // calculate the sub_index, i.e. the index in the stem tree.
99
+ // Because the modulus is 256, it's the last byte of treeIndex
100
+ subIndexMod := treeIndex .Bytes ()
98
101
var subIndex byte
99
102
if len (subIndexMod ) != 0 {
100
- subIndex = subIndexMod [0 ]
103
+ // Get the last byte, as uint256.Int is big-endian
104
+ subIndex = subIndexMod [len (subIndexMod )- 1 ]
101
105
}
102
106
return GetTreeKey (address , treeIndex , subIndex )
103
107
}
You can’t perform that action at this time.
0 commit comments