Skip to content

Commit

Permalink
fix telemetry calls
Browse files Browse the repository at this point in the history
  • Loading branch information
kocubinski committed Jan 2, 2025
1 parent 2b30650 commit 8a59b0a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 67 deletions.
102 changes: 51 additions & 51 deletions simapp/v2/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,59 +87,59 @@ func NewSimApp[T transaction.Tx](
AppConfig(),
config,
depinject.Supply(
// ADVANCED CONFIGURATION

//
// AUTH
//
// For providing a custom function required in auth to generate custom account types
// add it below. By default the auth module uses simulation.RandomGenesisAccounts.
//
// authtypes.RandomGenesisAccountsFn(simulation.RandomGenesisAccounts),
//
// For providing a custom a base account type add it below.
// By default the auth module uses authtypes.ProtoBaseAccount().
//
// func() sdk.AccountI { return authtypes.ProtoBaseAccount() },
//
// For providing a different address codec, add it below.
// By default the auth module uses a Bech32 address codec,
// with the prefix defined in the auth module configuration.
//
// func() address.Codec { return <- custom address codec type -> }

//
// STAKING
//
// For provinding a different validator and consensus address codec, add it below.
// By default the staking module uses the bech32 prefix provided in the auth config,
// and appends "valoper" and "valcons" for validator and consensus addresses respectively.
// When providing a custom address codec in auth, custom address codecs must be provided here as well.
//
// func() runtime.ValidatorAddressCodec { return <- custom validator address codec type -> }
// func() runtime.ConsensusAddressCodec { return <- custom consensus address codec type -> }

//
// MINT
//

// For providing a custom inflation function for x/mint add here your
// custom function that implements the minttypes.InflationCalculationFn
// interface.
// ADVANCED CONFIGURATION

//
// AUTH
//
// For providing a custom function required in auth to generate custom account types
// add it below. By default the auth module uses simulation.RandomGenesisAccounts.
//
// authtypes.RandomGenesisAccountsFn(simulation.RandomGenesisAccounts),
//
// For providing a custom a base account type add it below.
// By default the auth module uses authtypes.ProtoBaseAccount().
//
// func() sdk.AccountI { return authtypes.ProtoBaseAccount() },
//
// For providing a different address codec, add it below.
// By default the auth module uses a Bech32 address codec,
// with the prefix defined in the auth module configuration.
//
// func() address.Codec { return <- custom address codec type -> }

//
// STAKING
//
// For provinding a different validator and consensus address codec, add it below.
// By default the staking module uses the bech32 prefix provided in the auth config,
// and appends "valoper" and "valcons" for validator and consensus addresses respectively.
// When providing a custom address codec in auth, custom address codecs must be provided here as well.
//
// func() runtime.ValidatorAddressCodec { return <- custom validator address codec type -> }
// func() runtime.ConsensusAddressCodec { return <- custom consensus address codec type -> }

//
// MINT
//

// For providing a custom inflation function for x/mint add here your
// custom function that implements the minttypes.InflationCalculationFn
// interface.
),
depinject.Provide(
// if you want to provide a custom public key you
// can do it from here.
// Example:
// basedepinject.ProvideCustomPubkey[Ed25519PublicKey]()
//
// You can also provide a custom public key with a custom validation function:
//
// basedepinject.ProvideCustomPubKeyAndValidationFunc(func(pub Ed25519PublicKey) error {
// if len(pub.Key) != 64 {
// return fmt.Errorf("invalid pub key size")
// }
// })
// if you want to provide a custom public key you
// can do it from here.
// Example:
// basedepinject.ProvideCustomPubkey[Ed25519PublicKey]()
//
// You can also provide a custom public key with a custom validation function:
//
// basedepinject.ProvideCustomPubKeyAndValidationFunc(func(pub Ed25519PublicKey) error {
// if len(pub.Key) != 64 {
// return fmt.Errorf("invalid pub key size")
// }
// })
),
)
)
Expand Down
2 changes: 1 addition & 1 deletion store/v2/commitment/iavlv2/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func isHighBitSet(version uint64) error {
func DefaultOptions(keepVersions int64) iavl.TreeOptions {
opts := iavl.DefaultTreeOptions()
opts.MinimumKeepVersions = keepVersions
opts.CheckpointInterval = 60
opts.CheckpointInterval = 200
opts.PruneRatio = 1
opts.HeightFilter = 1
opts.EvictionDepth = 22
Expand Down
2 changes: 1 addition & 1 deletion store/v2/root/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func DefaultStoreOptions() Options {
Interval: 100,
},
IavlConfig: &iavl.Config{
CacheSize: 1_000_000,
CacheSize: 500_000,
SkipFastStorageUpgrade: true,
},
}
Expand Down
23 changes: 9 additions & 14 deletions store/v2/root/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ func (s *Store) GetLatestVersion() (uint64, error) {

func (s *Store) Query(storeKey []byte, version uint64, key []byte, prove bool) (store.QueryResult, error) {
if s.telemetry != nil {
now := time.Now()
defer s.telemetry.MeasureSince(now, "root_store", "query")
defer s.telemetry.MeasureSince(time.Now(), "root_store", "query")

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
}

val, err := s.stateCommitment.Get(storeKey, version, key)
Expand All @@ -196,8 +195,7 @@ func (s *Store) Query(storeKey []byte, version uint64, key []byte, prove bool) (

func (s *Store) LoadLatestVersion() error {
if s.telemetry != nil {
now := time.Now()
defer s.telemetry.MeasureSince(now, "root_store", "load_latest_version")
defer s.telemetry.MeasureSince(time.Now(), "root_store", "load_latest_version")

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
}

lv, err := s.GetLatestVersion()
Expand All @@ -210,17 +208,15 @@ func (s *Store) LoadLatestVersion() error {

func (s *Store) LoadVersion(version uint64) error {
if s.telemetry != nil {
now := time.Now()
defer s.telemetry.MeasureSince(now, "root_store", "load_version")
defer s.telemetry.MeasureSince(time.Now(), "root_store", "load_version")

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
}

return s.loadVersion(version, nil, false)
}

func (s *Store) LoadVersionForOverwriting(version uint64) error {
if s.telemetry != nil {
now := time.Now()
defer s.telemetry.MeasureSince(now, "root_store", "load_version_for_overwriting")
defer s.telemetry.MeasureSince(time.Now(), "root_store", "load_version_for_overwriting")

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
}

return s.loadVersion(version, nil, true)
Expand All @@ -233,7 +229,6 @@ func (s *Store) LoadVersionAndUpgrade(version uint64, upgrades *corestore.StoreU
if upgrades == nil {
return errors.New("upgrades cannot be nil")
}

if s.telemetry != nil {
defer s.telemetry.MeasureSince(time.Now(), "root_store", "load_version_and_upgrade")
}
Expand Down Expand Up @@ -289,12 +284,12 @@ func (s *Store) loadVersion(v uint64, upgrades *corestore.StoreUpgrades, overrid
// from the SC tree. Finally, it commits the SC tree and returns the hash of
// the CommitInfo.
func (s *Store) Commit(cs *corestore.Changeset) ([]byte, error) {
now := time.Now()
defer func() {
if s.telemetry != nil {
if s.telemetry != nil {
now := time.Now()
defer func() {
s.telemetry.MeasureSince(now, "root_store", "commit")
}
}()
}()
}

if err := s.handleMigration(cs); err != nil {
return nil, err
Expand Down

0 comments on commit 8a59b0a

Please sign in to comment.