Skip to content

Commit

Permalink
Implement code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirms committed Apr 4, 2023
1 parent f0ecb37 commit b2b5a5d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 33 deletions.
8 changes: 4 additions & 4 deletions services/horizon/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ type Config struct {
// IngestDisableStateVerification disables state verification
// `System.verifyState()` when set to `true`.
IngestDisableStateVerification bool
// IngestStateVerificationFrequency configures how often state verification is performed.
// If IngestStateVerificationFrequency is set to 1 state verification is run on every checkpoint,
// If IngestStateVerificationFrequency is set to 2 state verification is run on every second checkpoint,
// IngestStateVerificationCheckpointFrequency configures how often state verification is performed.
// If IngestStateVerificationCheckpointFrequency is set to 1 state verification is run on every checkpoint,
// If IngestStateVerificationCheckpointFrequency is set to 2 state verification is run on every second checkpoint,
// etc...
IngestStateVerificationFrequency uint
IngestStateVerificationCheckpointFrequency uint
// IngestStateVerificationTimeout configures a timeout on the state verification routine.
// If IngestStateVerificationTimeout is set to 0 the timeout is disabled.
IngestStateVerificationTimeout time.Duration
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ func Flags() (*Config, support.ConfigOptions) {
Usage: "ingestion system runs a verification routing to compare state in local database with history buckets, this can be disabled however it's not recommended",
},
&support.ConfigOption{
Name: "ingest-state-verification-frequency",
ConfigKey: &config.IngestStateVerificationFrequency,
Name: "ingest-state-verification-checkpoint-frequency",
ConfigKey: &config.IngestStateVerificationCheckpointFrequency,
OptType: types.Uint,
FlagDefault: uint(1),
Usage: "the frequency in units per checkpoint for how often state verification is executed. " +
Expand Down
8 changes: 4 additions & 4 deletions services/horizon/internal/ingest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ type Config struct {
ReingestRetryBackoffSeconds int

// The checkpoint frequency will be 64 unless you are using an exotic test setup.
CheckpointFrequency uint32
StateVerificationFrequency uint32
StateVerificationTimeout time.Duration
CheckpointFrequency uint32
StateVerificationCheckpointFrequency uint32
StateVerificationTimeout time.Duration

RoundingSlippageFilter int

Expand Down Expand Up @@ -310,7 +310,7 @@ func NewSystem(config Config) (System, error) {
},
runStateVerificationOnLedger: ledgerEligibleForStateVerification(
config.CheckpointFrequency,
config.StateVerificationFrequency,
config.StateVerificationCheckpointFrequency,
),
}

Expand Down
5 changes: 0 additions & 5 deletions services/horizon/internal/ingest/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ func (s *system) verifyState(verifyAgainstLatestCheckpoint bool) error {
return nil
}

if !s.runStateVerificationOnLedger(ledgerSequence) {
localLog.Info("Current ledger is not eligible for state verification. Canceling...")
return nil
}

localLog.Info("Starting state verification")

if verifyAgainstLatestCheckpoint {
Expand Down
36 changes: 18 additions & 18 deletions services/horizon/internal/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,24 @@ func initIngester(app *App) {
HistorySession: mustNewDBSession(
db.IngestSubservice, app.config.DatabaseURL, ingest.MaxDBConnections, ingest.MaxDBConnections, app.prometheusRegistry,
),
NetworkPassphrase: app.config.NetworkPassphrase,
HistoryArchiveURLs: app.config.HistoryArchiveURLs,
CheckpointFrequency: app.config.CheckpointFrequency,
StellarCoreURL: app.config.StellarCoreURL,
StellarCoreCursor: app.config.CursorName,
CaptiveCoreBinaryPath: app.config.CaptiveCoreBinaryPath,
CaptiveCoreStoragePath: app.config.CaptiveCoreStoragePath,
CaptiveCoreConfigUseDB: app.config.CaptiveCoreConfigUseDB,
CaptiveCoreToml: app.config.CaptiveCoreToml,
RemoteCaptiveCoreURL: app.config.RemoteCaptiveCoreURL,
EnableCaptiveCore: app.config.EnableCaptiveCoreIngestion,
DisableStateVerification: app.config.IngestDisableStateVerification,
StateVerificationFrequency: uint32(app.config.IngestStateVerificationFrequency),
StateVerificationTimeout: app.config.IngestStateVerificationTimeout,
EnableReapLookupTables: app.config.HistoryRetentionCount > 0,
EnableExtendedLogLedgerStats: app.config.IngestEnableExtendedLogLedgerStats,
RoundingSlippageFilter: app.config.RoundingSlippageFilter,
EnableIngestionFiltering: app.config.EnableIngestionFiltering,
NetworkPassphrase: app.config.NetworkPassphrase,
HistoryArchiveURLs: app.config.HistoryArchiveURLs,
CheckpointFrequency: app.config.CheckpointFrequency,
StellarCoreURL: app.config.StellarCoreURL,
StellarCoreCursor: app.config.CursorName,
CaptiveCoreBinaryPath: app.config.CaptiveCoreBinaryPath,
CaptiveCoreStoragePath: app.config.CaptiveCoreStoragePath,
CaptiveCoreConfigUseDB: app.config.CaptiveCoreConfigUseDB,
CaptiveCoreToml: app.config.CaptiveCoreToml,
RemoteCaptiveCoreURL: app.config.RemoteCaptiveCoreURL,
EnableCaptiveCore: app.config.EnableCaptiveCoreIngestion,
DisableStateVerification: app.config.IngestDisableStateVerification,
StateVerificationCheckpointFrequency: uint32(app.config.IngestStateVerificationCheckpointFrequency),
StateVerificationTimeout: app.config.IngestStateVerificationTimeout,
EnableReapLookupTables: app.config.HistoryRetentionCount > 0,
EnableExtendedLogLedgerStats: app.config.IngestEnableExtendedLogLedgerStats,
RoundingSlippageFilter: app.config.RoundingSlippageFilter,
EnableIngestionFiltering: app.config.EnableIngestionFiltering,
})

if err != nil {
Expand Down

0 comments on commit b2b5a5d

Please sign in to comment.