diff --git a/node/app/node.go b/node/app/node.go index 45b458d..4ef2f0a 100644 --- a/node/app/node.go +++ b/node/app/node.go @@ -42,23 +42,6 @@ func newNode( execEngines[ceremonyExecutionEngine.GetName()] = ceremonyExecutionEngine } - intrinsicFilter := append( - p2p.GetBloomFilter(application.CEREMONY_ADDRESS, 256, 3), - p2p.GetBloomFilterIndices(application.CEREMONY_ADDRESS, 65536, 24)..., - ) - logger.Info("running compaction") - - if err := clockStore.Compact( - intrinsicFilter, - ); err != nil { - if errors.Is(err, store.ErrNotFound) { - logger.Error("Missing compaction data. Skipping for now.", zap.Error(err)) - } else { - panic(err) - } - } - logger.Info("compaction complete") - return &Node{ logger, clockStore, diff --git a/node/main.go b/node/main.go index 44f5a16..7adcbfc 100644 --- a/node/main.go +++ b/node/main.go @@ -21,7 +21,10 @@ import ( "go.uber.org/zap" "google.golang.org/protobuf/proto" + "source.quilibrium.com/quilibrium/monorepo/node/execution/intrinsics/ceremony/application" + "source.quilibrium.com/quilibrium/monorepo/node/p2p" "source.quilibrium.com/quilibrium/monorepo/node/protobufs" + "source.quilibrium.com/quilibrium/monorepo/node/store" "source.quilibrium.com/quilibrium/monorepo/node/utils" "github.com/libp2p/go-libp2p/core/crypto" @@ -213,6 +216,26 @@ func main() { node.Stop() } +// Reintroduce at a later date +func RunCompaction(clockStore *store.PebbleClockStore) { + intrinsicFilter := append( + p2p.GetBloomFilter(application.CEREMONY_ADDRESS, 256, 3), + p2p.GetBloomFilterIndices(application.CEREMONY_ADDRESS, 65536, 24)..., + ) + fmt.Println("running compaction") + + if err := clockStore.Compact( + intrinsicFilter, + ); err != nil { + if errors.Is(err, store.ErrNotFound) { + fmt.Println("missing compaction data, skipping for now", zap.Error(err)) + } else { + panic(err) + } + } + fmt.Println("compaction complete") +} + func RunSelfTestIfNeeded( configDir string, nodeConfig *config.Config, diff --git a/node/store/clock.go b/node/store/clock.go index a3fb034..c1cd3f6 100644 --- a/node/store/clock.go +++ b/node/store/clock.go @@ -611,6 +611,10 @@ func (p *PebbleClockStore) GetDataClockFrame( if len(value) == (len(filter) + 42) { frameValue, frameCloser, err := p.db.Get(value) if err != nil { + if errors.Is(err, pebble.ErrNotFound) { + return nil, nil, ErrNotFound + } + return nil, nil, errors.Wrap(err, "get data clock frame") } if err := proto.Unmarshal(frameValue, frame); err != nil { @@ -762,6 +766,10 @@ func (p *PebbleClockStore) GetLatestDataClockFrame( frameNumber := binary.BigEndian.Uint64(idxValue) frame, _, err := p.GetDataClockFrame(filter, frameNumber, false) if err != nil { + if errors.Is(err, pebble.ErrNotFound) { + return nil, ErrNotFound + } + return nil, errors.Wrap(err, "get latest data clock frame") } @@ -769,6 +777,10 @@ func (p *PebbleClockStore) GetLatestDataClockFrame( if proverTrie != nil { trieData, closer, err := p.db.Get(clockProverTrieKey(filter, frameNumber)) if err != nil { + if errors.Is(err, pebble.ErrNotFound) { + return nil, ErrNotFound + } + return nil, errors.Wrap(err, "get latest data clock frame") }