From 5a5d450e58dbf4154338ba9fa247e96f2ae5fa01 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Tue, 28 Jan 2025 11:03:49 +0100 Subject: [PATCH 1/2] fix(nodebuilder/pruner): Change archival mode warning message (#4064) --- nodebuilder/pruner/flags.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodebuilder/pruner/flags.go b/nodebuilder/pruner/flags.go index 986fb9eaf5..873bcb5da5 100644 --- a/nodebuilder/pruner/flags.go +++ b/nodebuilder/pruner/flags.go @@ -48,8 +48,8 @@ If you want to retain history beyond the sampling window, please pass the --arch // Warn the user if pruning is disabled and archival is not enabled for Full and Bridge nodes if !archivalChanged && (tp == node.Full || tp == node.Bridge) { - log.Warn(`WARNING: Pruning is disabled. -Pruning will become the default mode for all nodes. + log.Warn(`WARNING: Node is now running in ARCHIVAL mode. +PRUNING mode will become the default for all nodes. If you want to retain history beyond the sampling window, please pass the --archival flag.`) } } From 87bc6c891949c80d1a68389af45c8bae87588597 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Tue, 28 Jan 2025 11:25:14 +0100 Subject: [PATCH 2/2] feat(store): Add HasQ4ByHash method on store (#4035) --- core/exchange_test.go | 7 ++++++- core/listener_test.go | 5 +++++ store/store.go | 9 +++++++++ store/store_test.go | 28 ++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/core/exchange_test.go b/core/exchange_test.go index 54b07ec914..79df507b0f 100644 --- a/core/exchange_test.go +++ b/core/exchange_test.go @@ -146,7 +146,7 @@ func TestExchange_StoreHistoricIfArchival(t *testing.T) { headers, err := ce.GetRangeByHeight(ctx, genHeader, 30) require.NoError(t, err) - // ensure all "historic" EDSs were stored + // ensure all "historic" EDSs were stored but not the .q4 files for _, h := range headers { has, err := store.HasByHeight(ctx, h.Height()) require.NoError(t, err) @@ -159,6 +159,11 @@ func TestExchange_StoreHistoricIfArchival(t *testing.T) { has, err = store.HasByHash(ctx, h.DAH.Hash()) require.NoError(t, err) assert.True(t, has) + + // ensure .q4 file was not stored + has, err = store.HasQ4ByHash(ctx, h.DAH.Hash()) + require.NoError(t, err) + assert.False(t, has) } } diff --git a/core/listener_test.go b/core/listener_test.go index 99c6ea1a28..e8dec78360 100644 --- a/core/listener_test.go +++ b/core/listener_test.go @@ -130,6 +130,11 @@ func TestListener_DoesNotStoreHistoric(t *testing.T) { has, err := store.HasByHash(ctx, hash) require.NoError(t, err) assert.False(t, has) + + // ensure .q4 file was not stored + has, err = store.HasQ4ByHash(ctx, hash) + require.NoError(t, err) + assert.False(t, has) } } diff --git a/store/store.go b/store/store.go index 554337275e..476f6e8deb 100644 --- a/store/store.go +++ b/store/store.go @@ -432,6 +432,15 @@ func (s *Store) hasByHeight(height uint64) (bool, error) { return exists(pathODS) } +func (s *Store) HasQ4ByHash(_ context.Context, datahash share.DataHash) (bool, error) { + lock := s.stripLock.byHash(datahash) + lock.RLock() + defer lock.RUnlock() + + pathQ4File := s.hashToPath(datahash, q4FileExt) + return exists(pathQ4File) +} + func (s *Store) RemoveODSQ4(ctx context.Context, height uint64, datahash share.DataHash) error { lock := s.stripLock.byHashAndHeight(datahash, height) lock.lock() diff --git a/store/store_test.go b/store/store_test.go index 4374e01bbf..c7cefdc31b 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" libshare "github.com/celestiaorg/go-square/v2/share" @@ -268,6 +269,33 @@ func TestEDSStore(t *testing.T) { }) } + t.Run("HasQ4", func(t *testing.T) { + dir := t.TempDir() + edsStore, err := NewStore(paramsNoCache(), dir) + require.NoError(t, err) + + square, roots := randomEDS(t) + randHeight := uint64(8) + + has, err := edsStore.HasQ4ByHash(ctx, roots.Hash()) + require.NoError(t, err) + assert.False(t, has) + + err = edsStore.PutODSQ4(ctx, roots, randHeight, square) + require.NoError(t, err) + + has, err = edsStore.HasQ4ByHash(ctx, roots.Hash()) + require.NoError(t, err) + assert.True(t, has) + + err = edsStore.RemoveQ4(ctx, randHeight, roots.Hash()) + require.NoError(t, err) + + has, err = edsStore.HasQ4ByHash(ctx, roots.Hash()) + require.NoError(t, err) + assert.False(t, has) + }) + t.Run("Does not exist", func(t *testing.T) { dir := t.TempDir() edsStore, err := NewStore(paramsNoCache(), dir)