Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Add flag for malfeasant scan
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed May 2, 2024
1 parent 7a33d28 commit ee6202e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 0 additions & 8 deletions activation/verify_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ func CheckPrevATXs(ctx context.Context, logger *zap.Logger, db sql.Executor) err
return fmt.Errorf("add malfeasance proof: %w", err)
}

// h.cdb.CacheMalfeasanceProof(atx.SmesherID, proof)
// h.tortoise.OnMalfeasance(atx.SmesherID)

// if err = h.publisher.Publish(ctx, pubsub.MalfeasanceProof, encodedProof); err != nil {
// h.log.With().Error("failed to broadcast malfeasance proof", log.Err(err))
// return false
// }

count++
}
logger.Info("created malfeasance proofs", zap.Int("count", count))
Expand Down
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func AddFlags(flagSet *pflag.FlagSet, cfg *config.Config) (configPath *string) {
flagSet.DurationVar(&cfg.DatabasePruneInterval, "db-prune-interval",
cfg.DatabasePruneInterval, "configure interval for database pruning")

flagSet.BoolVar(&cfg.ScanMalfeasantATXs, "scan-malfeasant-atxs", cfg.ScanMalfeasantATXs,
"scan for malfeasant ATXs")

flagSet.BoolVar(&cfg.NoMainOverride, "no-main-override",
cfg.NoMainOverride, "force 'nomain' builds to run on the mainnet")

Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ type BaseConfig struct {

PruneActivesetsFrom types.EpochID `mapstructure:"prune-activesets-from"`

// ScanMalfeasantATXs is a flag to enable scanning for malfeasant ATXs.
ScanMalfeasantATXs bool `mapstructure:"scan-malfeasant-atxs"`

NetworkHRP string `mapstructure:"network-hrp"`

// MinerGoodAtxsPercent is a threshold to decide if tortoise activeset should be
Expand Down
3 changes: 2 additions & 1 deletion config/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func MainnetConfig() Config {
DatabaseConnections: 16,
DatabasePruneInterval: 30 * time.Minute,
DatabaseVacuumState: 15,
PruneActivesetsFrom: 12, // starting from epoch 13 activesets below 12 will be pruned
PruneActivesetsFrom: 12, // starting from epoch 13 activesets below 12 will be pruned
ScanMalfeasantATXs: false, // opt-in
NetworkHRP: "sm",

LayerDuration: 5 * time.Minute,
Expand Down
13 changes: 7 additions & 6 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1892,13 +1892,14 @@ func (app *App) setupDBs(ctx context.Context, lg log.Log) error {
datastore.WithConfig(app.Config.Cache),
)

// TODO(mafa): add command line flag to trigger this instead of always running it
app.log.With().Info("checking DB for malicious ATXs")
start = time.Now()
if err := activation.CheckPrevATXs(ctx, app.log.Zap(), app.db); err != nil {
return fmt.Errorf("malicious ATX check: %w", err)
if app.Config.ScanMalfeasantATXs {
app.log.With().Info("checking DB for malicious ATXs")
start = time.Now()
if err := activation.CheckPrevATXs(ctx, app.log.Zap(), app.db); err != nil {
return fmt.Errorf("malicious ATX check: %w", err)
}
app.log.With().Info("malicious ATX check completed", log.Duration("duration", time.Since(start)))
}
app.log.With().Info("malicious ATX check completed", log.Duration("duration", time.Since(start)))

migrations, err = sql.LocalMigrations()
if err != nil {
Expand Down

0 comments on commit ee6202e

Please sign in to comment.