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

Add History Retention Window of 7 days #139

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/soroban-rpc/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Config struct {
CoreRequestTimeout time.Duration
DefaultEventsLimit uint
EventLedgerRetentionWindow uint32
LedgerRetentionWindow uint32
FriendbotURL string
HistoryArchiveURLs []string
HistoryArchiveUserAgent string
Expand Down
9 changes: 9 additions & 0 deletions cmd/soroban-rpc/internal/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ func (cfg *Config) options() ConfigOptions {
ConfigKey: &cfg.CheckpointFrequency,
DefaultValue: uint32(64),
},
{
Name: "ledger-retention-window",
psheth9 marked this conversation as resolved.
Show resolved Hide resolved
Usage: fmt.Sprintf("configures the ledger retention window expressed in number of ledgers," +
" the default value is 120960 which corresponds to about 7 days of history"),
ConfigKey: &cfg.LedgerRetentionWindow,
DefaultValue: uint32(120960),
Validate: positive,
},

{
Name: "event-retention-window",
Usage: fmt.Sprintf("configures the event retention window expressed in number of ledgers,"+
Expand Down
11 changes: 3 additions & 8 deletions cmd/soroban-rpc/internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/db"
"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/events"
"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/ingest"
"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/ledgerbucketwindow"
"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/preflight"
"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/transactions"
"github.com/stellar/soroban-rpc/cmd/soroban-rpc/internal/util"
Expand Down Expand Up @@ -236,15 +235,11 @@ func MustNew(cfg *config.Config) *Daemon {
onIngestionRetry := func(err error, dur time.Duration) {
logger.WithError(err).Error("could not run ingestion. Retrying")
}
maxRetentionWindow := cfg.EventLedgerRetentionWindow
if cfg.TransactionLedgerRetentionWindow > maxRetentionWindow {
maxRetentionWindow = cfg.TransactionLedgerRetentionWindow
} else if cfg.EventLedgerRetentionWindow == 0 && cfg.TransactionLedgerRetentionWindow > ledgerbucketwindow.DefaultEventLedgerRetentionWindow {
maxRetentionWindow = ledgerbucketwindow.DefaultEventLedgerRetentionWindow
}
psheth9 marked this conversation as resolved.
Show resolved Hide resolved
ledgerRetentionWindow := cfg.LedgerRetentionWindow

ingestService := ingest.NewService(ingest.Config{
Logger: logger,
DB: db.NewReadWriter(dbConn, maxLedgerEntryWriteBatchSize, maxRetentionWindow),
DB: db.NewReadWriter(dbConn, maxLedgerEntryWriteBatchSize, ledgerRetentionWindow),
EventStore: eventStore,
TransactionStore: transactionStore,
NetworkPassPhrase: cfg.NetworkPassphrase,
Expand Down
Loading