From 3a10c31d78b099a514d853b97818361e7179bec5 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Thu, 14 Nov 2024 11:36:32 +0100 Subject: [PATCH 1/2] fix(core): change fill block mode (#3936) --- core/exchange_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/exchange_test.go b/core/exchange_test.go index c0b925b51d..072493d4f3 100644 --- a/core/exchange_test.go +++ b/core/exchange_test.go @@ -135,7 +135,7 @@ func fillBlocks( default: } - _, err := cctx.FillBlock(16, cfg.Genesis.Accounts()[0].Name, flags.BroadcastBlock) + _, err := cctx.FillBlock(16, cfg.Genesis.Accounts()[0].Name, flags.BroadcastAsync) require.NoError(t, err) } } From 14cd8d66136aaa743c55f9d97b6c72851f2288b0 Mon Sep 17 00:00:00 2001 From: Hlib Kanunnikov Date: Thu, 14 Nov 2024 11:56:02 +0100 Subject: [PATCH 2/2] hotfix(core): don't hold on Data (#3926) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `Data` field of `core.ResultSignedBlock` was retained even after we constructed the respective header and moved on. This was due to the header consisting of pointers pointing to fields of `core.ResultSignedBlock`, retaining the whole structure, including the `Data` field. A BN, by default, has a header store cache of size 4096; thus, holding on `Data` with 8 MB blocks took around 32GiB of RAM. Initially, we believed that the issue was with JSON unmarshalling. However, we were wrong about this being the whole story, as while profiles did confirm that the allocations did originate there, the allocated data wasn't cleaned up. Kudos to @rach-id for helping us figuring this out! This is a hotfix and is meant to be replaced with a better solution described on TODO. Also, the origin of this bug is yet to be confirmed by @rach-id by testing RAM usage with disabled header cache. --- 🎱mb certified --- core/exchange.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/exchange.go b/core/exchange.go index 3f55bbf990..bcf29842e3 100644 --- a/core/exchange.go +++ b/core/exchange.go @@ -6,6 +6,7 @@ import ( "fmt" "time" + "github.com/tendermint/tendermint/types" "golang.org/x/sync/errgroup" libhead "github.com/celestiaorg/go-header" @@ -177,7 +178,11 @@ func (ce *Exchange) getExtendedHeaderByHeight(ctx context.Context, height *int64 if err != nil { return nil, fmt.Errorf("extending block data for height %d: %w", b.Header.Height, err) } - // create extended header + + // TODO(@Wondertan): This is a hack to deref Data, allowing GC to pick it up. + // The better footgun-less solution is to change core.ResultSignedBlock fields to be pointers instead of values. + b.Data = types.Data{} + eh, err := ce.construct(&b.Header, &b.Commit, &b.ValidatorSet, eds) if err != nil { panic(fmt.Errorf("constructing extended header for height %d: %w", b.Header.Height, err))