Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(index): add lotus shed commands to prune all indexes #12393

19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

# UNRELEASED

- https://github.com/filecoin-project/lotus/pull/12203: Fix slice modification bug in ETH Tx Events Bloom Filter
- https://github.com/filecoin-project/lotus/pull/12221: Fix a nil reference panic in the ETH Trace API
- https://github.com/filecoin-project/lotus/pull/12112: Moved consts from build/ to build/buildconstants/ for ligher curio deps.
- https://github.com/filecoin-project/lotus/pull/12237: Upgrade to go-f3 `v0.0.4`.
- https://github.com/filecoin-project/lotus/pull/12251: Dropping support from ProveCommitSector1 method from lotus-miner
- https://github.com/filecoin-project/lotus/pull/12276: chore: deps: Update GST, Filecoin-FFI and Actors to final versions NV23
- https://github.com/filecoin-project/lotus/pull/12278: chore: Set Mainnet upgrade epoch for NV23.
- https://github.com/filecoin-project/lotus/pull/12269 Fix `logIndex` ordering in `EthGetTransactionReceipt` by using the EventIndex to fetch logs
- https://github.com/filecoin-project/lotus/pull/12270: Feat expose `settle-deal` command for lotus miner to settle deals manually
- https://github.com/filecoin-project/lotus/pull/12285 Set up OpenTelemetry metrics reporting to prometheus
- https://github.com/filecoin-project/lotus/pull/12279 Upgrade to go-f3 v0.0.5
- https://github.com/filecoin-project/lotus/pull/12295 Upgrade to go-f3 v0.0.6
- https://github.com/filecoin-project/lotus/pull/12292: feat: p2p: allow overriding bootstrap nodes with environmemnt variable
- https://github.com/filecoin-project/lotus/pull/12319: feat: `lotus send CLI`: allow sending to ETH addresses
- https://github.com/filecoin-project/lotus/pull/12332: fix: ETH RPC: receipts: use correct txtype in receipts
- https://github.com/filecoin-project/lotus/pull/12335: fix: lotus-shed: store processed tipset after backfilling events
- https://github.com/filecoin-project/lotus/pull/12341: fix: miner: Fix DDO pledge math
- https://github.com/filecoin-project/lotus/pull/12393: feat(index): add lotus shed commands to prune all indexes

## ☢️ Upgrade Warnings ☢️

## New features
Expand Down
19 changes: 10 additions & 9 deletions chain/ethhashlookup/eth_transaction_hash_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ const (
type EthTxHashLookup struct {
db *sql.DB

stmtInsertTxHash *sql.Stmt
stmtGetCidFromHash *sql.Stmt
stmtGetHashFromCid *sql.Stmt
stmtDeleteOlderThan *sql.Stmt
stmtInsertTxHash *sql.Stmt
stmtGetCidFromHash *sql.Stmt
stmtGetHashFromCid *sql.Stmt
}

func NewTransactionHashLookup(ctx context.Context, path string) (*EthTxHashLookup, error) {
Expand Down Expand Up @@ -78,10 +77,6 @@ func (ei *EthTxHashLookup) initStatements() (err error) {
if err != nil {
return xerrors.Errorf("prepare stmtGetHashFromCid: %w", err)
}
ei.stmtDeleteOlderThan, err = ei.db.Prepare(deleteOlderThan)
if err != nil {
return xerrors.Errorf("prepare stmtDeleteOlderThan: %w", err)
}
return nil
}

Expand Down Expand Up @@ -133,10 +128,16 @@ func (ei *EthTxHashLookup) DeleteEntriesOlderThan(days int) (int64, error) {
return 0, xerrors.New("db closed")
}

res, err := ei.stmtDeleteOlderThan.Exec("-" + strconv.Itoa(days) + " day")
return DeleteEntriesOlderThan(ei.db, days)
}

// DeleteEntriesOlderThan deletes entries older than the given number of epochs from now.
func DeleteEntriesOlderThan(db *sql.DB, days int) (int64, error) {
res, err := db.Exec(deleteOlderThan, "-"+strconv.Itoa(days)+" day")
if err != nil {
return 0, err
}

return res.RowsAffected()
}

Expand Down
Loading