diff --git a/cmd/stellar-rpc/internal/config/main.go b/cmd/stellar-rpc/internal/config/main.go index dd6028bea..df1e7e97a 100644 --- a/cmd/stellar-rpc/internal/config/main.go +++ b/cmd/stellar-rpc/internal/config/main.go @@ -25,6 +25,10 @@ type Config struct { CaptiveCoreHTTPQueryThreadPoolSize uint16 CaptiveCoreHTTPQuerySnapshotLedgers uint16 + IngestionLoadTestFixturesPath string + IngestionLoadTestLedgersPath string + IngestionLoadTestCloseDuration time.Duration + Endpoint string AdminEndpoint string CheckpointFrequency uint32 diff --git a/cmd/stellar-rpc/internal/config/options.go b/cmd/stellar-rpc/internal/config/options.go index 09c1ac7cb..fa1759ba6 100644 --- a/cmd/stellar-rpc/internal/config/options.go +++ b/cmd/stellar-rpc/internal/config/options.go @@ -204,6 +204,22 @@ func (cfg *Config) options() Options { } }, }, + { + Name: "ingestion-load-test-fixtures-path", + Usage: "path to ledger entries file which will be used as fixtures for the ingestion load test.", + ConfigKey: &cfg.IngestionLoadTestFixturesPath, + }, + { + Name: "ingestion-load-test-ledgers-path", + Usage: "path to ledgers file which will be replayed in the ingestion load test.", + ConfigKey: &cfg.IngestionLoadTestLedgersPath, + }, + { + Name: "ingestion-load-test-close-duration", + DefaultValue: 2 * time.Second, + Usage: "the time (in seconds) it takes to close ledgers in the ingestion load test.", + ConfigKey: &cfg.IngestionLoadTestCloseDuration, + }, { Name: "history-archive-urls", Usage: "comma-separated list of stellar history archives to connect with", diff --git a/cmd/stellar-rpc/internal/daemon/daemon.go b/cmd/stellar-rpc/internal/daemon/daemon.go index 63fc8120c..2cdd0856d 100644 --- a/cmd/stellar-rpc/internal/daemon/daemon.go +++ b/cmd/stellar-rpc/internal/daemon/daemon.go @@ -21,6 +21,7 @@ import ( "github.com/stellar/go/clients/stellarcore" "github.com/stellar/go/historyarchive" "github.com/stellar/go/ingest/ledgerbackend" + "github.com/stellar/go/ingest/loadtest" "github.com/stellar/go/support/datastore" supporthttp "github.com/stellar/go/support/http" supportlog "github.com/stellar/go/support/log" @@ -291,8 +292,7 @@ func createIngestService(cfg *config.Config, logger *supportlog.Entry, daemon *D onIngestionRetry := func(err error, _ time.Duration) { logger.WithError(err).Error("could not run ingestion. Retrying") } - - return ingest.NewService(ingest.Config{ + ingestConfig := ingest.Config{ Logger: logger, DB: db.NewReadWriter( logger, @@ -309,7 +309,18 @@ func createIngestService(cfg *config.Config, logger *supportlog.Entry, daemon *D OnIngestionRetry: onIngestionRetry, Daemon: daemon, FeeWindows: feewindows, - }) + } + + if cfg.IngestionLoadTestLedgersPath != "" { + ingestConfig.LedgerBackend = loadtest.NewLedgerBackend(loadtest.LedgerBackendConfig{ + NetworkPassphrase: cfg.NetworkPassphrase, + LedgerBackend: daemon.core, + LedgersFilePath: cfg.IngestionLoadTestLedgersPath, + LedgerEntriesFilePath: cfg.IngestionLoadTestFixturesPath, + LedgerCloseDuration: cfg.IngestionLoadTestCloseDuration, + }) + } + return ingest.NewService(ingestConfig) } func createPreflightWorkerPool(cfg *config.Config, logger *supportlog.Entry, daemon *Daemon) *preflight.WorkerPool { diff --git a/go.mod b/go.mod index 868fed9d6..d69562938 100644 --- a/go.mod +++ b/go.mod @@ -48,6 +48,7 @@ require ( github.com/gorilla/handlers v1.5.2 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/pkg/xattr v0.4.9 // indirect + github.com/xdrpp/goxdr v0.1.1 // indirect ) require (