diff --git a/cmd/soroban-rpc/internal/config/config.go b/cmd/soroban-rpc/internal/config/config.go index 15e69f6b..639d9e53 100644 --- a/cmd/soroban-rpc/internal/config/config.go +++ b/cmd/soroban-rpc/internal/config/config.go @@ -26,6 +26,7 @@ type Config struct { CoreRequestTimeout time.Duration DefaultEventsLimit uint EventLedgerRetentionWindow uint32 + LedgerRetentionWindow uint32 FriendbotURL string HistoryArchiveURLs []string HistoryArchiveUserAgent string diff --git a/cmd/soroban-rpc/internal/config/options.go b/cmd/soroban-rpc/internal/config/options.go index df503200..e131cb09 100644 --- a/cmd/soroban-rpc/internal/config/options.go +++ b/cmd/soroban-rpc/internal/config/options.go @@ -209,6 +209,15 @@ func (cfg *Config) options() ConfigOptions { ConfigKey: &cfg.CheckpointFrequency, DefaultValue: uint32(64), }, + { + Name: "ledger-retention-window", + Usage: fmt.Sprintf("configures the ledger retention window expressed in number of ledgers,"+ + " the default value is %d which corresponds to about 24 hours of history", ledgerbucketwindow.DefaultEventLedgerRetentionWindow), + 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,"+ diff --git a/cmd/soroban-rpc/internal/daemon/daemon.go b/cmd/soroban-rpc/internal/daemon/daemon.go index c2c224de..c28e4726 100644 --- a/cmd/soroban-rpc/internal/daemon/daemon.go +++ b/cmd/soroban-rpc/internal/daemon/daemon.go @@ -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" @@ -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 - } + 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,