Skip to content

Commit

Permalink
Backport 6279: Use ATXData during tortoise init (#6281)
Browse files Browse the repository at this point in the history
* Use ATXData during tortoise init (#6279)

## Motivation

Instead of reading information about malicious identities from the DB during tortoise init use atx data.

* Update Changelog
  • Loading branch information
fasmat authored Aug 22, 2024
1 parent 172f4cf commit d87adec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 8 additions & 0 deletions atxsdata/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"sync"
"sync/atomic"

"golang.org/x/exp/maps"

"github.com/spacemeshos/go-spacemesh/common/types"
)

Expand Down Expand Up @@ -147,6 +149,12 @@ func (d *Data) SetMalicious(node types.NodeID) {
d.malicious[node] = struct{}{}
}

func (d *Data) MaliciousIdentities() []types.NodeID {
d.mu.RLock()
defer d.mu.RUnlock()
return maps.Keys(d.malicious)
}

// Get returns atx data.
// SAFETY: The returned pointer MUST NOT be modified.
func (d *Data) Get(epoch types.EpochID, atx types.ATXID) *ATX {
Expand Down
7 changes: 1 addition & 6 deletions tortoise/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/spacemeshos/go-spacemesh/sql/beacons"
"github.com/spacemeshos/go-spacemesh/sql/blocks"
"github.com/spacemeshos/go-spacemesh/sql/certificates"
"github.com/spacemeshos/go-spacemesh/sql/identities"
"github.com/spacemeshos/go-spacemesh/sql/layers"
)

Expand Down Expand Up @@ -60,11 +59,7 @@ func Recover(
}
}

malicious, err := identities.GetMalicious(db)
if err != nil {
return nil, fmt.Errorf("recover malicious %w", err)
}
for _, id := range malicious {
for _, id := range atxdata.MaliciousIdentities() {
trtl.OnMalfeasance(id)
}

Expand Down

0 comments on commit d87adec

Please sign in to comment.