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 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f8313f7
this works
weiihann Dec 13, 2024
47e9590
one failed but im getting closer
weiihann Dec 13, 2024
cae88a9
this works
weiihann Dec 13, 2024
8018d71
add bytes benchmark
weiihann Dec 13, 2024
989b2b1
looks gud
weiihann Dec 13, 2024
905f003
add Rsh test
weiihann Dec 14, 2024
323370c
add Truncate
weiihann Dec 14, 2024
37c8c5e
add CommonMSBs
weiihann Dec 15, 2024
31b6884
minor comments
weiihann Dec 15, 2024
93ade0c
add UnmarshalBinary
weiihann Dec 15, 2024
987ad47
more bitArray public
weiihann Dec 15, 2024
031aa35
add IsBitSet
weiihann Dec 15, 2024
c23817f
fix lint and comments
weiihann Dec 15, 2024
df6a513
Felt return value
weiihann Dec 16, 2024
ec1703c
add felt tests
weiihann Dec 17, 2024
c00326c
use const for 0xFF...FF
weiihann Dec 17, 2024
1a23f0d
add MSBs
weiihann Dec 17, 2024
fad615d
add MSBs() and rename Truncate to LSBs
weiihann Dec 17, 2024
38da2f1
all tests passed
weiihann Dec 17, 2024
9f5f581
improve comments
weiihann Dec 18, 2024
dd8b290
fix lint
weiihann Dec 18, 2024
f322653
minor chore
weiihann Dec 18, 2024
979f949
improvements
weiihann Dec 19, 2024
ed8b0ea
ensure unused bits are zero when setting bitarray
weiihann Dec 20, 2024
131f640
update comment
weiihann Dec 20, 2024
bdca4e1
Add LSBsAtPos()
weiihann Dec 26, 2024
b53c949
Add BitSet()
weiihann Dec 26, 2024
144914d
Add BitSetAtMSB()
weiihann Dec 27, 2024
05dc052
add IsEmpty()
weiihann Dec 27, 2024
83d88f1
Add Lsh, Or, Append
weiihann Dec 27, 2024
28905b3
fix rebase
weiihann Dec 27, 2024
f05d2d1
Add BitSetFromMSB()
weiihann Dec 30, 2024
8393471
Reverse methods between LSBs and MSBs
weiihann Dec 30, 2024
ef68aeb
Revert "Reverse methods between LSBs and MSBs"
weiihann Dec 30, 2024
07bef4b
add direction
weiihann Dec 30, 2024
743c581
fix tests
weiihann Dec 30, 2024
c5de9df
add more tests
weiihann Dec 30, 2024
fdd8ff3
use IsBitSetFromMSB
weiihann Dec 30, 2024
da85dd2
use IsBitSetFromMSB
weiihann Dec 30, 2024
d6d456d
Replace LSBsFromMSB to LSBs
weiihann Dec 30, 2024
e39ef57
change IsBitSetFromMSB to IsBitSet
weiihann Dec 30, 2024
7f479c1
minor chore
weiihann Dec 30, 2024
c6c0e85
add SetBit()
weiihann Dec 31, 2024
c6c8183
rename methods
weiihann Dec 31, 2024
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
9 changes: 5 additions & 4 deletions core/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ 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)
return rootKey.UnmarshalBinary(val)
rootKey = new(trie.BitArray)
rootKey.UnmarshalBinary(val)
return nil
})

// if some error other than "not found"
Expand All @@ -169,7 +170,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