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

474/soroban diagnostic events #4813

Merged
merged 5 commits into from
Mar 23, 2023
Merged
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
23 changes: 14 additions & 9 deletions ingest/ledgerbackend/captive_core_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ func (c *CaptiveStellarCore) roundDownToFirstReplayAfterCheckpointStart(ledger u
//
// Requires Stellar-Core v13.2.0+.
type CaptiveStellarCore struct {
archive historyarchive.ArchiveInterface
checkpointManager historyarchive.CheckpointManager
ledgerHashStore TrustedLedgerHashStore
useDB bool
archive historyarchive.ArchiveInterface
checkpointManager historyarchive.CheckpointManager
ledgerHashStore TrustedLedgerHashStore
useDB bool
enableSorobanDiagnosticEvents bool

// cancel is the CancelFunc for context which controls the lifetime of a CaptiveStellarCore instance.
// Once it is invoked CaptiveStellarCore will not be able to stream ledgers from Stellar Core or
Expand Down Expand Up @@ -136,6 +137,9 @@ type CaptiveCoreConfig struct {
// of DATABASE parameter in the captive-core-config-path or if absent, the db will default to sqlite
// and the db file will be stored at location derived from StoragePath parameter.
UseDB bool

// Enable Soroban diagnostic events in core
EnableSorobanDiagnosticEvents bool
}

// NewCaptive returns a new CaptiveStellarCore instance.
Expand Down Expand Up @@ -173,11 +177,12 @@ func NewCaptive(config CaptiveCoreConfig) (*CaptiveStellarCore, error) {
}

c := &CaptiveStellarCore{
archive: &archivePool,
ledgerHashStore: config.LedgerHashStore,
useDB: config.UseDB,
cancel: cancel,
checkpointManager: historyarchive.NewCheckpointManager(config.CheckpointFrequency),
archive: &archivePool,
ledgerHashStore: config.LedgerHashStore,
useDB: config.UseDB,
enableSorobanDiagnosticEvents: config.EnableSorobanDiagnosticEvents,
cancel: cancel,
checkpointManager: historyarchive.NewCheckpointManager(config.CheckpointFrequency),
}

c.stellarCoreRunnerFactory = func() stellarCoreRunnerInterface {
Expand Down
3 changes: 3 additions & 0 deletions ingest/ledgerbackend/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type captiveCoreTomlValues struct {
UseBucketListDB bool `toml:"EXPERIMENTAL_BUCKETLIST_DB,omitempty"`
BucketListDBPageSizeExp *uint `toml:"EXPERIMENTAL_BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT,omitempty"`
BucketListDBCutoff *uint `toml:"EXPERIMENTAL_BUCKETLIST_DB_INDEX_CUTOFF,omitempty"`
EnableSorobanDiagnosticEvents bool `toml:"ENABLE_SOROBAN_DIAGNOSTIC_EVENTS,omitempty"`
}

// QuorumSetIsConfigured returns true if there is a quorum set defined in the configuration.
Expand Down Expand Up @@ -324,6 +325,8 @@ type CaptiveCoreTomlParams struct {
UseDB bool
// the path to the core binary, used to introspect core at runtie, determine some toml capabilities
CoreBinaryPath string
// Make core emit Soroban diagnostic events
EnableSorobanDiagnosticEvents bool
}

// NewCaptiveCoreTomlFromFile constructs a new CaptiveCoreToml instance by merging configuration
Expand Down
23 changes: 12 additions & 11 deletions services/horizon/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ type Config struct {
Port uint
AdminPort uint

EnableCaptiveCoreIngestion bool
EnableIngestionFiltering bool
UsingDefaultPubnetConfig bool
CaptiveCoreBinaryPath string
RemoteCaptiveCoreURL string
CaptiveCoreConfigPath string
CaptiveCoreTomlParams ledgerbackend.CaptiveCoreTomlParams
CaptiveCoreToml *ledgerbackend.CaptiveCoreToml
CaptiveCoreStoragePath string
CaptiveCoreReuseStoragePath bool
CaptiveCoreConfigUseDB bool
EnableCaptiveCoreIngestion bool
EnableIngestionFiltering bool
UsingDefaultPubnetConfig bool
CaptiveCoreBinaryPath string
RemoteCaptiveCoreURL string
CaptiveCoreConfigPath string
CaptiveCoreTomlParams ledgerbackend.CaptiveCoreTomlParams
CaptiveCoreToml *ledgerbackend.CaptiveCoreToml
CaptiveCoreStoragePath string
CaptiveCoreReuseStoragePath bool
CaptiveCoreConfigUseDB bool
CaptiveCoreConfigEnableSorobanDiagnosticEvents bool
paulbellamy marked this conversation as resolved.
Show resolved Hide resolved

StellarCoreDatabaseURL string
StellarCoreURL string
Expand Down
18 changes: 18 additions & 0 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
CaptiveCoreConfigPathName = "captive-core-config-path"
// captive-core-use-db is the command line flag for enabling captive core runtime to use an external db url connection rather than RAM for ledger states
CaptiveCoreConfigUseDB = "captive-core-use-db"
// captive-core-enable-soroban-diagnostic-events is the command line flag for enabling soroban diagnostic events in captive core
CaptiveCoreConfigEnableSorobanDiagnosticEvents = "captive-core-enable-soroban-diagnostic-events"
paulbellamy marked this conversation as resolved.
Show resolved Hide resolved

captiveCoreMigrationHint = "If you are migrating from Horizon 1.x.y, start with the Migration Guide here: https://developers.stellar.org/docs/run-api-server/migrating/"
)
Expand Down Expand Up @@ -193,6 +195,22 @@ func Flags() (*Config, support.ConfigOptions) {
},
ConfigKey: &config.CaptiveCoreConfigUseDB,
},
&support.ConfigOption{
Name: CaptiveCoreConfigEnableSorobanDiagnosticEvents,
OptType: types.Bool,
FlagDefault: false,
Required: false,
Usage: `when enabled, Horizon ingestion will instruct the captive
core invocation to emit Soroban diagnostic events.`,
CustomSetValue: func(opt *support.ConfigOption) error {
if val := viper.GetBool(opt.Name); val {
config.CaptiveCoreConfigEnableSorobanDiagnosticEvents = val
config.CaptiveCoreTomlParams.EnableSorobanDiagnosticEvents = val
}
return nil
},
ConfigKey: &config.CaptiveCoreConfigEnableSorobanDiagnosticEvents,
},
&support.ConfigOption{
Name: "enable-captive-core-ingestion",
OptType: types.Bool,
Expand Down