From b8cd46b920481b449696415b44400b389e75f4da Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Mon, 6 Oct 2025 18:32:18 -0500 Subject: [PATCH] fix: remove global prover state from size calculation --- hypergraph/hypergraph.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/hypergraph/hypergraph.go b/hypergraph/hypergraph.go index 886dc47..51d22df 100644 --- a/hypergraph/hypergraph.go +++ b/hypergraph/hypergraph.go @@ -174,7 +174,29 @@ func (hg *HypergraphCRDT) GetSize( hg.mu.RLock() defer hg.mu.RUnlock() if shardKey == nil { - return hg.size + sk := tries.ShardKey{ + L1: [3]byte{0, 0, 0}, + L2: [32]byte{ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + }, + } + vas := hg.getVertexAddsSet(sk) + has := hg.getHyperedgeAddsSet(sk) + vrs := hg.getVertexRemovesSet(sk) + hrs := hg.getHyperedgeRemovesSet(sk) + size := new(big.Int).Set(hg.size) + size = size.Sub( + size, + new(big.Int).Add( + new(big.Int).Add(vas.GetSize(), has.GetSize()), + new(big.Int).Add(vrs.GetSize(), hrs.GetSize()), + ), + ) + + return size } vas := hg.getVertexAddsSet(*shardKey)