From 1024bbada5d654404a97135f6b3872a8d95dc809 Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Wed, 26 Mar 2025 02:38:31 -0500 Subject: [PATCH] resolve memory issue with commit --- node/crypto/lazy_proof_tree.go | 6 +++++- node/rpc/hypergraph_sync_rpc_server_test.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/node/crypto/lazy_proof_tree.go b/node/crypto/lazy_proof_tree.go index 390f80f..0d76074 100644 --- a/node/crypto/lazy_proof_tree.go +++ b/node/crypto/lazy_proof_tree.go @@ -103,7 +103,11 @@ func (n *LazyVectorCommitmentBranchNode) Commit( if n.Commitment == nil || recalculate { vector := make([][]byte, len(n.Children)) wg := sync.WaitGroup{} - throttle := make(chan struct{}, runtime.WorkerCount(0, false)) + workers := 1 + if n.LongestBranch == 2 { + workers = runtime.WorkerCount(0, false) + } + throttle := make(chan struct{}, workers) for i, child := range n.Children { throttle <- struct{}{} wg.Add(1) diff --git a/node/rpc/hypergraph_sync_rpc_server_test.go b/node/rpc/hypergraph_sync_rpc_server_test.go index 1c37418..5d79a6d 100644 --- a/node/rpc/hypergraph_sync_rpc_server_test.go +++ b/node/rpc/hypergraph_sync_rpc_server_test.go @@ -67,6 +67,7 @@ func TestLoadHypergraphFallback(t *testing.T) { } for k, a := range clientLoad.GetVertexAdds() { assert.Equal(t, len(crypto.ConvertAllPreloadedLeaves(string(application.VertexAtomType), string(application.AddsPhaseType), k, clientHypergraphStore, a.GetTree().Root, []int{})), 100000) + fmt.Printf("%x\n", a.GetTree().Commit(true)) } fmt.Println("Should not reattempt") @@ -75,6 +76,7 @@ func TestLoadHypergraphFallback(t *testing.T) { assert.NoError(t, err) clientLoad, err = clientHypergraphStore.LoadHypergraph() assert.NoError(t, err) + t.FailNow() } func TestHypergraphSyncServer(t *testing.T) {