- critbit trie bug
- proof messages performing incorrect repeat
This commit is contained in:
Cassandra Heart 2024-11-13 00:10:22 -06:00
parent 71b13c5490
commit c2b9b1d460
No known key found for this signature in database
GPG Key ID: 6352152859385958
4 changed files with 36 additions and 0 deletions

View File

@ -121,6 +121,7 @@ type DataClockConsensusEngine struct {
report *protobufs.SelfTestReport
clients []protobufs.DataIPCServiceClient
grpcRateLimiter *RateLimiter
previousFrameProven *protobufs.ClockFrame
previousTree *mt.MerkleTree
clientReconnectTest int
}

View File

@ -149,6 +149,10 @@ func (e *DataClockConsensusEngine) processFrame(
break
}
} else {
if e.previousFrameProven.FrameNumber == latestFrame.FrameNumber {
return latestFrame
}
h, err := poseidon.HashBytes(e.pubSub.GetPeerID())
if err != nil {
panic(err)
@ -232,6 +236,7 @@ func (e *DataClockConsensusEngine) processFrame(
)
return latestFrame
}
e.previousFrameProven = latestFrame
e.previousTree = proofTree
sig, err := e.pubSub.SignMessage(

View File

@ -274,6 +274,13 @@ func (t *RollingFrecencyCritbitTrie) Remove(address []byte) {
return
}
if t.Root.External != nil {
if bytes.Equal(t.Root.External.Key, address) {
t.Root = nil
}
return
}
blen := uint32(len(address))
var gp *Node
p := t.Root

View File

@ -2,6 +2,7 @@ package tries_test
import (
"crypto/rand"
"fmt"
"math/big"
"testing"
@ -52,6 +53,28 @@ func TestSerializers(t *testing.T) {
}
}
func TestCritbitReinit(t *testing.T) {
tree := &tries.RollingFrecencyCritbitTrie{}
set := [][]byte{}
for i := 0; i < 1024; i++ {
seed := make([]byte, 32)
rand.Read(seed)
set = append(set, seed)
tree.Add(seed, 14)
tree.Remove(seed)
}
for i := 0; i < 1024; i++ {
tree.Add(set[i], 14)
}
for i := 0; i < 1024; i++ {
tree.Remove(set[i])
}
near := tree.FindNearestAndApproximateNeighbors(make([]byte, 32))
for _, n := range near {
fmt.Println(n.External.Key)
}
}
func TestCritbit(t *testing.T) {
tree := &tries.RollingFrecencyCritbitTrie{}