Skip to content

Commit

Permalink
pruen active set from ballot blob
Browse files Browse the repository at this point in the history
  • Loading branch information
countvonzero committed Sep 19, 2023
1 parent 27c3dd7 commit b9ecc3b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions sql/ballots/util/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"

"github.com/spacemeshos/go-spacemesh/codec"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/log"
"github.com/spacemeshos/go-spacemesh/sql"
Expand Down Expand Up @@ -42,11 +43,10 @@ func ExtractActiveSet(db sql.Executor) error {
} else if err == nil {
unique++
}
// TODO: prune ballot active set after migration 4 is released
//b.ActiveSet = nil
//if err := ballots.UpdateBlob(db, b.ID(), codec.MustEncode(b)); err != nil {
// return fmt.Errorf("update ballot %s: %w", b.ID().String(), err)
//}
b.ActiveSet = nil
if err := ballots.UpdateBlob(db, b.ID(), codec.MustEncode(b)); err != nil {
return fmt.Errorf("update ballot %s: %w", b.ID().String(), err)
}

Check warning on line 49 in sql/ballots/util/extract.go

View check run for this annotation

Codecov / codecov/patch

sql/ballots/util/extract.go#L48-L49

Added lines #L48 - L49 were not covered by tests
extracted++
}
}
Expand Down
4 changes: 1 addition & 3 deletions sql/ballots/util/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ func TestExtractActiveSet(t *testing.T) {
for _, b := range blts {
got, err := ballots.Get(db, b.ID())
require.NoError(t, err)
if b.Layer%3 != 2 {
require.NotEmpty(t, got.ActiveSet)
}
require.Nil(t, got.ActiveSet)
}
for i, h := range hashes {
got, err := activesets.Get(db, h)
Expand Down
2 changes: 1 addition & 1 deletion sql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func Open(uri string, opts ...Opt) (*Database, error) {
if err != nil {
return nil, err
}
if before <= 3 && after == 4 && config.v4Migration != nil {
if before <= 4 && after == 5 && config.v4Migration != nil {
// v4 migration (active set extraction) needs the 3rd migration to execute first
if err := config.v4Migration(db); err != nil {
return nil, err
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions sql/migrations/0005_next.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- empty migration file to facilitate pruning active set from ballot blobs
2 changes: 1 addition & 1 deletion sql/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func TestMigrationsAppliedOnce(t *testing.T) {
return true
})
require.NoError(t, err)
require.Equal(t, version, 4)
require.Equal(t, version, 5)
}

0 comments on commit b9ecc3b

Please sign in to comment.