Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement BitArray and replace trie.Key #2322

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5ecccae
this works
weiihann Dec 13, 2024
642c33f
one failed but im getting closer
weiihann Dec 13, 2024
24dcc95
this works
weiihann Dec 13, 2024
ef07cbb
add bytes benchmark
weiihann Dec 13, 2024
6f2581a
looks gud
weiihann Dec 13, 2024
e41896f
add Rsh test
weiihann Dec 14, 2024
721dac6
add Truncate
weiihann Dec 14, 2024
bd14e29
add CommonMSBs
weiihann Dec 15, 2024
c81ee79
minor comments
weiihann Dec 15, 2024
de18dd1
add UnmarshalBinary
weiihann Dec 15, 2024
0ef08f3
more bitArray public
weiihann Dec 15, 2024
55ace8e
add IsBitSet
weiihann Dec 15, 2024
b3f4adb
fix lint and comments
weiihann Dec 15, 2024
b3276df
Felt return value
weiihann Dec 16, 2024
518d436
add felt tests
weiihann Dec 17, 2024
2b4703b
use const for 0xFF...FF
weiihann Dec 17, 2024
00d20fa
add MSBs
weiihann Dec 17, 2024
9957235
add MSBs() and rename Truncate to LSBs
weiihann Dec 17, 2024
5ee384f
all tests passed
weiihann Dec 17, 2024
d32f008
improve comments
weiihann Dec 18, 2024
f949f68
fix lint
weiihann Dec 18, 2024
be7e437
minor chore
weiihann Dec 18, 2024
e709fa6
improvements
weiihann Dec 19, 2024
fff6d57
ensure unused bits are zero when setting bitarray
weiihann Dec 20, 2024
c79e157
update comment
weiihann Dec 20, 2024
109b5aa
Add LSBsAtPos()
weiihann Dec 26, 2024
a39833c
Add BitSet()
weiihann Dec 26, 2024
806b9f6
Add BitSetAtMSB()
weiihann Dec 27, 2024
2286c57
add IsEmpty()
weiihann Dec 27, 2024
3b87acf
Add Lsh, Or, Append
weiihann Dec 27, 2024
c6e0d9e
fix rebase
weiihann Dec 27, 2024
7cc77ef
Add BitSetFromMSB()
weiihann Dec 30, 2024
29fa141
Reverse methods between LSBs and MSBs
weiihann Dec 30, 2024
8850c73
Revert "Reverse methods between LSBs and MSBs"
weiihann Dec 30, 2024
f210ee8
add direction
weiihann Dec 30, 2024
0097243
fix tests
weiihann Dec 30, 2024
1d2cd97
add more tests
weiihann Dec 30, 2024
8e2a0dd
use IsBitSetFromMSB
weiihann Dec 30, 2024
0fbdd08
use IsBitSetFromMSB
weiihann Dec 30, 2024
8113516
Replace LSBsFromMSB to LSBs
weiihann Dec 30, 2024
fbe305f
change IsBitSetFromMSB to IsBitSet
weiihann Dec 30, 2024
1786113
minor chore
weiihann Dec 30, 2024
9320908
add SetBit()
weiihann Dec 31, 2024
dc18471
rename methods
weiihann Dec 31, 2024
40efc2f
Add Cmp()
weiihann Jan 7, 2025
abe7aa5
remove truncateToLength from Bytes()
weiihann Jan 17, 2025
a2e17a5
optimize LSBsFromLSB()
weiihann Jan 17, 2025
a2f87f6
error check for UnmarshalBinary
weiihann Jan 17, 2025
3263cc5
minor chore
weiihann Jan 17, 2025
1d2540d
Bytes() return fixed array
weiihann Jan 17, 2025
e824231
remove n == 0 switch case
weiihann Jan 17, 2025
aeb4e48
chore on Append()
weiihann Jan 17, 2025
bf7e8e8
Minor change on LSH
weiihann Jan 17, 2025
a1c5d11
deal with different length in SetBytes
weiihann Jan 17, 2025
9affc99
Revert "Minor change on LSH"
weiihann Jan 17, 2025
d19db25
fix LSH bug
weiihann Jan 17, 2025
8779b04
fix UnmarshalBinary bug
weiihann Jan 17, 2025
7c4aeb3
fix bug, add tests for SetBytes
weiihann Jan 17, 2025
46de9ca
add AppendBit()
weiihann Jan 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ func (s *State) globalTrie(bucket db.Bucket, newTrie trie.NewTrieFunc) (*trie.Tr

// fetch root key
rootKeyDBKey := dbPrefix
var rootKey *trie.Key
var rootKey *trie.BitArray // TODO: use value instead of pointer
err := s.txn.Get(rootKeyDBKey, func(val []byte) error {
rootKey = new(trie.Key)
rootKey = new(trie.BitArray)
return rootKey.UnmarshalBinary(val)
})

Expand Down Expand Up @@ -169,7 +169,7 @@ func (s *State) globalTrie(bucket db.Bucket, newTrie trie.NewTrieFunc) (*trie.Tr

if resultingRootKey != nil {
var rootKeyBytes bytes.Buffer
_, marshalErr := resultingRootKey.WriteTo(&rootKeyBytes)
_, marshalErr := resultingRootKey.Write(&rootKeyBytes)
if marshalErr != nil {
return marshalErr
}
Expand Down
Loading
Loading