From 5c75bec9775489074041a7ad1079aff7a5c239d6 Mon Sep 17 00:00:00 2001 From: thib-wien Date: Mon, 27 Nov 2023 12:08:22 +0100 Subject: [PATCH 1/4] (BIDS-1823) Adjusts the format of numerous time durations --- cmd/misc/main.go | 2 +- db/bigtable.go | 6 ++--- db/bigtable_eth1.go | 20 +++++++------- db/bigtable_init.go | 6 ++--- db/statistics.go | 2 +- db/subscriptions.go | 4 +-- eth1data/eth1data.go | 4 +-- exporter/appsubscription_oracle.go | 2 +- exporter/eth1.go | 2 +- exporter/exporter.go | 16 ++++++------ exporter/rocketpool.go | 4 +-- exporter/ssv.go | 2 +- handlers/auth.go | 4 +-- handlers/gasnow.go | 2 +- mail/mail.go | 2 +- rpc/lighthouse.go | 2 +- services/charts_updater.go | 8 +++--- services/execution_layer.go | 4 +-- services/gitcoin_feed_updater.go | 2 +- services/historic_prices.go | 2 +- services/notifications.go | 4 +-- services/services.go | 42 +++++++++++++++--------------- services/stats.go | 2 +- utils/session.go | 3 +-- utils/utils.go | 3 +-- 25 files changed, 74 insertions(+), 76 deletions(-) diff --git a/cmd/misc/main.go b/cmd/misc/main.go index 717cdc8592..908dfccda9 100644 --- a/cmd/misc/main.go +++ b/cmd/misc/main.go @@ -336,7 +336,7 @@ func main() { ) if err != nil { logrus.Errorf("error exporting genesis-deposits: %v", err) - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) continue } } diff --git a/db/bigtable.go b/db/bigtable.go index 9c5fa62a0c..9a7ca5553c 100644 --- a/db/bigtable.go +++ b/db/bigtable.go @@ -2302,7 +2302,7 @@ func (bigtable *Bigtable) getValidatorIncomeDetailsHistoryV2(validators []uint64 startEpoch = 0 } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*180) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3) defer cancel() res := make(map[uint64]map[uint64]*itypes.ValidatorEpochIncome, len(validators)) @@ -2378,7 +2378,7 @@ func (bigtable *Bigtable) getValidatorIncomeDetailsHistoryV1(validators []uint64 startEpoch = 0 } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*180) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3) defer cancel() ranges := bigtable.getEpochRangesV1(startEpoch, endEpoch) @@ -2530,7 +2530,7 @@ func (bigtable *Bigtable) GetTotalValidatorIncomeDetailsHistory(startEpoch uint6 startEpoch = 0 } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*180) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3) defer cancel() res := make(map[uint64]*itypes.ValidatorEpochIncome, endEpoch-startEpoch+1) diff --git a/db/bigtable_eth1.go b/db/bigtable_eth1.go index a6da2d5fdf..aa97929011 100644 --- a/db/bigtable_eth1.go +++ b/db/bigtable_eth1.go @@ -451,7 +451,7 @@ func (bigtable *Bigtable) GetFullBlocksDescending(stream chan<- *types.Eth1Block }) defer tmr.Stop() - ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Second*180)) + ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Minute*3)) defer cancel() if high < low { @@ -3026,7 +3026,7 @@ func (bigtable *Bigtable) GetMetadataUpdates(prefix string, startToken string, l }) defer tmr.Stop() - ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Minute*120)) + ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Hour*2)) defer cancel() keys := make([]string, 0, limit) @@ -3062,7 +3062,7 @@ func (bigtable *Bigtable) GetMetadata(startToken string, limit int) ([]string, [ }) defer tmr.Stop() - ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Minute*120)) + ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Hour*2)) defer cancel() keys := make([]string, 0, limit) @@ -3411,7 +3411,7 @@ func (bigtable *Bigtable) GetAddressName(address []byte) (string, error) { rowKey := fmt.Sprintf("%s:%x", bigtable.chainId, address) cacheKey := bigtable.chainId + ":NAME:" + rowKey - if wanted, err := cache.TieredCache.GetStringWithLocalTimeout(cacheKey, time.Hour*24); err == nil { + if wanted, err := cache.TieredCache.GetStringWithLocalTimeout(cacheKey, utils.Day); err == nil { // logrus.Infof("retrieved name for address %x from cache", address) return wanted, nil } @@ -3495,7 +3495,7 @@ func (bigtable *Bigtable) GetContractMetadata(address []byte) (*types.ContractMe rowKey := fmt.Sprintf("%s:%x", bigtable.chainId, address) cacheKey := bigtable.chainId + ":CONTRACT:" + rowKey - if cached, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Hour*24, new(types.ContractMetadata)); err == nil { + if cached, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, utils.Day, new(types.ContractMetadata)); err == nil { ret := cached.(*types.ContractMetadata) val, err := abi.JSON(bytes.NewReader(ret.ABIJson)) ret.ABI = &val @@ -3520,7 +3520,7 @@ func (bigtable *Bigtable) GetContractMetadata(address []byte) (*types.ContractMe } else { utils.LogError(err, "Fetching contract metadata", 0, logAdditionalInfo) } - err := cache.TieredCache.Set(cacheKey, &types.ContractMetadata{}, time.Hour*24) + err := cache.TieredCache.Set(cacheKey, &types.ContractMetadata{}, utils.Day) if err != nil { utils.LogError(err, "Caching contract metadata", 0, logAdditionalInfo) } @@ -3530,14 +3530,14 @@ func (bigtable *Bigtable) GetContractMetadata(address []byte) (*types.ContractMe // No contract found, caching empty if ret == nil { - err = cache.TieredCache.Set(cacheKey, &types.ContractMetadata{}, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, &types.ContractMetadata{}, utils.Day) if err != nil { utils.LogError(err, "Caching contract metadata", 0, map[string]interface{}{"address": fmt.Sprintf("%x", address)}) } return nil, nil } - err = cache.TieredCache.Set(cacheKey, ret, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, ret, utils.Day) if err != nil { utils.LogError(err, "Caching contract metadata", 0, map[string]interface{}{"address": fmt.Sprintf("%x", address)}) } @@ -3565,7 +3565,7 @@ func (bigtable *Bigtable) GetContractMetadata(address []byte) (*types.ContractMe } } - err = cache.TieredCache.Set(cacheKey, ret, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, ret, utils.Day) return ret, err } @@ -4096,7 +4096,7 @@ func (bigtable *Bigtable) markBalanceUpdate(address []byte, token []byte, mutati mutations.Keys = append(mutations.Keys, balanceUpdateKey) mutations.Muts = append(mutations.Muts, mut) - cache.Set(balanceUpdateCacheKey, []byte{0x1}, int((time.Hour * 48).Seconds())) + cache.Set(balanceUpdateCacheKey, []byte{0x1}, int((utils.Day * 2).Seconds())) } } diff --git a/db/bigtable_init.go b/db/bigtable_init.go index e5b511d4fc..d11a496416 100644 --- a/db/bigtable_init.go +++ b/db/bigtable_init.go @@ -29,11 +29,11 @@ func InitBigtableSchema() error { DEFAULT_FAMILY_BLOCKS: gcp_bigtable.MaxVersionsGCPolicy(1), } tables["data"] = map[string]gcp_bigtable.GCPolicy{ - CONTRACT_METADATA_FAMILY: gcp_bigtable.MaxAgeGCPolicy(time.Hour * 24), + CONTRACT_METADATA_FAMILY: gcp_bigtable.MaxAgeGCPolicy(utils.Day), DEFAULT_FAMILY: nil, } tables["machine_metrics"] = map[string]gcp_bigtable.GCPolicy{ - MACHINE_METRICS_COLUMN_FAMILY: gcp_bigtable.MaxAgeGCPolicy(time.Hour * 24 * 31), + MACHINE_METRICS_COLUMN_FAMILY: gcp_bigtable.MaxAgeGCPolicy(utils.Day * 31), } tables["metadata"] = map[string]gcp_bigtable.GCPolicy{ ACCOUNT_METADATA_FAMILY: nil, @@ -44,7 +44,7 @@ func InitBigtableSchema() error { SERIES_FAMILY: gcp_bigtable.MaxVersionsGCPolicy(1), } tables["metadata_updates"] = map[string]gcp_bigtable.GCPolicy{ - METADATA_UPDATES_FAMILY_BLOCKS: gcp_bigtable.MaxAgeGCPolicy(time.Hour * 24), + METADATA_UPDATES_FAMILY_BLOCKS: gcp_bigtable.MaxAgeGCPolicy(utils.Day), DEFAULT_FAMILY: nil, } ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) diff --git a/db/statistics.go b/db/statistics.go index 64ed169f04..006234201f 100644 --- a/db/statistics.go +++ b/db/statistics.go @@ -1315,7 +1315,7 @@ func GetValidatorIncomeHistory(validatorIndices []uint64, lowerBoundDay uint64, func WriteChartSeriesForDay(day int64) error { startTs := time.Now() - ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() g, gCtx := errgroup.WithContext(ctx) diff --git a/db/subscriptions.go b/db/subscriptions.go index ce2702b5d8..f71b20b56a 100644 --- a/db/subscriptions.go +++ b/db/subscriptions.go @@ -270,7 +270,7 @@ func UpdateSubscriptionLastSent(tx *sqlx.Tx, ts uint64, epoch uint64, subID uint // CountSentMail increases the count of sent mails in the table `mails_sent` for this day. func CountSentMail(email string) error { - day := time.Now().Truncate(time.Hour * 24).Unix() + day := time.Now().Truncate(utils.Day).Unix() _, err := FrontendWriterDB.Exec(` INSERT INTO mails_sent (email, ts, cnt) VALUES ($1, TO_TIMESTAMP($2), 1) ON CONFLICT (email, ts) DO UPDATE SET cnt = mails_sent.cnt+1`, email, day) @@ -279,7 +279,7 @@ func CountSentMail(email string) error { // GetMailsSentCount returns the number of sent mails for the day of the passed time. func GetMailsSentCount(email string, t time.Time) (int, error) { - day := t.Truncate(time.Hour * 24).Unix() + day := t.Truncate(utils.Day).Unix() count := 0 err := FrontendWriterDB.Get(&count, "SELECT cnt FROM mails_sent WHERE email = $1 AND ts = TO_TIMESTAMP($2)", email, day) if err == sql.ErrNoRows { diff --git a/eth1data/eth1data.go b/eth1data/eth1data.go index d1539a60ef..73b1d23bf4 100644 --- a/eth1data/eth1data.go +++ b/eth1data/eth1data.go @@ -288,7 +288,7 @@ func GetEth1Transaction(hash common.Hash) (*types.Eth1TxData, error) { } } - err = cache.TieredCache.Set(cacheKey, txPageData, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, txPageData, utils.Day) if err != nil { return nil, fmt.Errorf("error writing data for tx to cache: %w", err) } @@ -308,7 +308,7 @@ func IsContract(ctx context.Context, address common.Address) (bool, error) { } isContract := len(code) != 0 - err = cache.TieredCache.SetBool(cacheKey, isContract, time.Hour*24) + err = cache.TieredCache.SetBool(cacheKey, isContract, utils.Day) if err != nil { return false, fmt.Errorf("error writing code data for address %v to cache: %w", address, err) } diff --git a/exporter/appsubscription_oracle.go b/exporter/appsubscription_oracle.go index bd640bb252..b298781733 100644 --- a/exporter/appsubscription_oracle.go +++ b/exporter/appsubscription_oracle.go @@ -70,7 +70,7 @@ func checkSubscriptions() { } logger.WithField("subscriptions", len(receipts)).WithField("duration", time.Since(start)).Info("subscription update completed") - time.Sleep(time.Second * 60 * 60 * 4) // 4h + time.Sleep(time.Hour * 4) } } diff --git a/exporter/eth1.go b/exporter/eth1.go index efd1b57832..ad984a6cc6 100644 --- a/exporter/eth1.go +++ b/exporter/eth1.go @@ -155,7 +155,7 @@ func eth1DepositsExporter() { continue } - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) } } diff --git a/exporter/exporter.go b/exporter/exporter.go index 125d5f5156..29cc1787f1 100644 --- a/exporter/exporter.go +++ b/exporter/exporter.go @@ -125,7 +125,7 @@ func genesisDepositsExporter(client rpc.Client) { } if latestEpoch == 0 { - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) continue } @@ -134,7 +134,7 @@ func genesisDepositsExporter(client rpc.Client) { err = db.WriterDb.Get(&genesisDepositsCount, "SELECT COUNT(*) FROM blocks_deposits WHERE block_slot=0") if err != nil { logger.Errorf("error retrieving genesis-deposits-count when exporting genesis-deposits: %v", err) - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) continue } @@ -146,14 +146,14 @@ func genesisDepositsExporter(client rpc.Client) { genesisValidators, err := client.GetValidatorState(0) if err != nil { logger.Errorf("error retrieving genesis validator data for genesis-epoch when exporting genesis-deposits: %v", err) - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) continue } tx, err := db.WriterDb.Beginx() if err != nil { logger.Errorf("error beginning db-tx when exporting genesis-deposits: %v", err) - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) continue } @@ -169,7 +169,7 @@ func genesisDepositsExporter(client rpc.Client) { if err != nil { tx.Rollback() logger.Errorf("error exporting genesis-deposits: %v", err) - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) continue } } @@ -186,7 +186,7 @@ func genesisDepositsExporter(client rpc.Client) { if err != nil { tx.Rollback() logger.Errorf("error hydrating eth1 data into genesis-deposits: %v", err) - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) continue } @@ -195,7 +195,7 @@ func genesisDepositsExporter(client rpc.Client) { if err != nil { tx.Rollback() logger.Errorf("error updating deposit count for the genesis slot: %v", err) - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) continue } @@ -203,7 +203,7 @@ func genesisDepositsExporter(client rpc.Client) { if err != nil { tx.Rollback() logger.Errorf("error committing db-tx when exporting genesis-deposits: %v", err) - time.Sleep(time.Second * 60) + time.Sleep(time.Minute) continue } diff --git a/exporter/rocketpool.go b/exporter/rocketpool.go index c0fe293fb3..1ff393e44b 100644 --- a/exporter/rocketpool.go +++ b/exporter/rocketpool.go @@ -138,7 +138,7 @@ func NewRocketpoolExporter(eth1Client *ethclient.Client, storageContractAddressH rpe.Eth1Client = eth1Client rpe.API = rp rpe.DB = db - rpe.UpdateInterval = time.Second * 60 + rpe.UpdateInterval = time.Minute rpe.MinipoolsByAddress = map[string]*RocketpoolMinipool{} rpe.NodesByAddress = map[string]*RocketpoolNode{} rpe.DAOProposalsByID = map[uint64]*RocketpoolDAOProposal{} @@ -219,7 +219,7 @@ func (rp *RocketpoolExporter) InitDAOMembers() error { } func (rp *RocketpoolExporter) Run() error { - errorInterval := time.Second * 60 + errorInterval := time.Minute t := time.NewTicker(rp.UpdateInterval) defer t.Stop() var count int64 = 0 diff --git a/exporter/ssv.go b/exporter/ssv.go index 18c25bcb7d..6eef1fe7ed 100644 --- a/exporter/ssv.go +++ b/exporter/ssv.go @@ -75,7 +75,7 @@ func exportSSV() error { } }() - qryValidatorsTicker := time.NewTicker(time.Second * 600) + qryValidatorsTicker := time.NewTicker(time.Minute * 10) defer qryValidatorsTicker.Stop() for { diff --git a/handlers/auth.go b/handlers/auth.go index d12c8a168d..00c62ff1e3 100644 --- a/handlers/auth.go +++ b/handlers/auth.go @@ -21,8 +21,8 @@ import ( ) var authSessionName = "auth" -var authResetEmailRateLimit = time.Second * 60 * 2 -var authConfirmEmailRateLimit = time.Second * 60 * 2 +var authResetEmailRateLimit = time.Minute * 2 +var authConfirmEmailRateLimit = time.Minute * 2 var authInternalServerErrorFlashMsg = "Error: Something went wrong :( Please retry later" // Register handler renders a template that allows for the creation of a new user. diff --git a/handlers/gasnow.go b/handlers/gasnow.go index 6b856ada18..51b26bc179 100644 --- a/handlers/gasnow.go +++ b/handlers/gasnow.go @@ -23,7 +23,7 @@ func GasNow(w http.ResponseWriter, r *http.Request) { data := InitPageData(w, r, "gasnow", "/gasnow", fmt.Sprintf("%v Gwei", 34), templateFiles) now := time.Now().Truncate(time.Minute) - lastWeek := time.Now().Truncate(time.Minute).Add(-time.Hour * 24 * 7) + lastWeek := time.Now().Truncate(time.Minute).Add(-utils.Week) history, err := db.BigtableClient.GetGasNowHistory(now, lastWeek) if err != nil { diff --git a/mail/mail.go b/mail/mail.go index b0a3ea0ed7..65fec7b244 100644 --- a/mail/mail.go +++ b/mail/mail.go @@ -90,7 +90,7 @@ func SendMailRateLimited(to, subject string, msg types.Email, attachment []types return err } if count >= utils.Config.Frontend.MaxMailsPerEmailPerDay { - timeLeft := now.Add(time.Hour * 24).Truncate(time.Hour * 24).Sub(now) + timeLeft := now.Add(utils.Day).Truncate(utils.Day).Sub(now) return &types.RateLimitError{TimeLeft: timeLeft} } } diff --git a/rpc/lighthouse.go b/rpc/lighthouse.go index 07b8638a22..6e51468c0f 100644 --- a/rpc/lighthouse.go +++ b/rpc/lighthouse.go @@ -1270,7 +1270,7 @@ var errNotFound = errors.New("not found 404") func (lc *LighthouseClient) get(url string) ([]byte, error) { // t0 := time.Now() // defer func() { fmt.Println(url, time.Since(t0)) }() - client := &http.Client{Timeout: time.Second * 120} + client := &http.Client{Timeout: time.Minute * 2} resp, err := client.Get(url) if err != nil { return nil, err diff --git a/services/charts_updater.go b/services/charts_updater.go index ef58c1f2aa..1e6da9127e 100644 --- a/services/charts_updater.go +++ b/services/charts_updater.go @@ -90,7 +90,7 @@ func chartsPageDataUpdater(wg *sync.WaitGroup) { // if start.Add(time.Minute * -20).After(utils.EpochToTime(latestEpoch)) { // logger.Info("skipping chartsPageDataUpdater because the explorer is syncing") - // time.Sleep(time.Second * 60) + // time.Sleep(time.Minute) // continue // } @@ -104,7 +104,7 @@ func chartsPageDataUpdater(wg *sync.WaitGroup) { logger.WithField("epoch", latestEpoch).WithField("duration", time.Since(start)).Info("chartPageData update completed") cacheKey := fmt.Sprintf("%d:frontend:chartsPageData", utils.Config.Chain.ClConfig.DepositChainID) - cache.TieredCache.Set(cacheKey, data, time.Hour*24) + cache.TieredCache.Set(cacheKey, data, utils.Day) prevEpoch = latestEpoch @@ -114,7 +114,7 @@ func chartsPageDataUpdater(wg *sync.WaitGroup) { } if latestEpoch == 0 { ReportStatus("chartsPageDataUpdater", "Running", nil) - time.Sleep(time.Second * 60 * 10) + time.Sleep(time.Minute * 10) } } } @@ -277,7 +277,7 @@ func activeValidatorsChartData() (*types.GenericChartData, error) { dailyActiveValidators := [][]float64{} for _, row := range rows { - day := float64(utils.EpochToTime(row.Epoch).Truncate(time.Hour*24).Unix() * 1000) + day := float64(utils.EpochToTime(row.Epoch).Truncate(utils.Day).Unix() * 1000) if len(dailyActiveValidators) == 0 || dailyActiveValidators[len(dailyActiveValidators)-1][0] != day { dailyActiveValidators = append(dailyActiveValidators, []float64{day, float64(row.ValidatorsCount)}) diff --git a/services/execution_layer.go b/services/execution_layer.go index d138817510..53833b4f62 100644 --- a/services/execution_layer.go +++ b/services/execution_layer.go @@ -22,7 +22,7 @@ func latestBlockUpdater(wg *sync.WaitGroup) { utils.LogError(err, "error getting most recent eth1 block", 0) } cacheKey := fmt.Sprintf("%d:frontend:%s", utils.Config.Chain.ClConfig.DepositChainID, latestBlockNumberCacheKey) - err = cache.TieredCache.SetUint64(cacheKey, recent.GetNumber(), time.Hour*24) + err = cache.TieredCache.SetUint64(cacheKey, recent.GetNumber(), utils.Day) if err != nil { utils.LogError(err, fmt.Sprintf("error caching latest block number with cache key %s", latestBlockNumberCacheKey), 0) } @@ -66,7 +66,7 @@ func headBlockRootHashUpdater(wg *sync.WaitGroup) { utils.LogError(err, "error getting blockroot hash for chain head", 0) } cacheKey := fmt.Sprintf("%d:frontend:%s", utils.Config.Chain.ClConfig.DepositChainID, latestBlockHashRootCacheKey) - err = cache.TieredCache.SetString(cacheKey, string(blockRootHash), time.Hour*24) + err = cache.TieredCache.SetString(cacheKey, string(blockRootHash), utils.Day) if err != nil { utils.LogError(err, fmt.Sprintf("error caching latest blockroot hash with cache key %s", latestBlockHashRootCacheKey), 0) } diff --git a/services/gitcoin_feed_updater.go b/services/gitcoin_feed_updater.go index 9ef1561942..eb980b8518 100644 --- a/services/gitcoin_feed_updater.go +++ b/services/gitcoin_feed_updater.go @@ -59,7 +59,7 @@ func InitGitCoinFeed() { logger.Infoln("Started GitcoinFeed service") for { updateFeed() - time.Sleep(time.Second * 120) + time.Sleep(time.Minute * 2) } }() } diff --git a/services/historic_prices.go b/services/historic_prices.go index 1beeb2c288..ae8a312164 100644 --- a/services/historic_prices.go +++ b/services/historic_prices.go @@ -112,7 +112,7 @@ func fetchHistoricPrice(ts time.Time) (*types.HistoricEthPrice, error) { if utils.Config.Chain.Name == "gnosis" { chain = "gnosis" } - resp, err := client.Get(fmt.Sprintf("https://api.coingecko.com/api/v3/coins/%s/history?date=%s", chain, ts.Truncate(time.Hour*24).Format("02-01-2006"))) + resp, err := client.Get(fmt.Sprintf("https://api.coingecko.com/api/v3/coins/%s/history?date=%s", chain, ts.Truncate(utils.Day).Format("02-01-2006"))) if err != nil { return nil, err diff --git a/services/notifications.go b/services/notifications.go index c264cb5aed..f8f4576f11 100644 --- a/services/notifications.go +++ b/services/notifications.go @@ -115,7 +115,7 @@ func notificationCollector() { if err != nil { logger.Errorf("error collection user db notifications: %v", err) ReportStatus("notification-collector", "Error", nil) - time.Sleep(time.Second * 120) + time.Sleep(time.Minute * 2) continue } @@ -139,7 +139,7 @@ func notificationCollector() { func notificationSender() { for { start := time.Now() - ctx, cancel := context.WithTimeout(context.Background(), time.Second*300) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5) conn, err := db.FrontendWriterDB.Conn(ctx) if err != nil { diff --git a/services/services.go b/services/services.go index 8280fea442..13505c2cbe 100644 --- a/services/services.go +++ b/services/services.go @@ -320,7 +320,7 @@ func relaysUpdater(wg *sync.WaitGroup) { } cacheKey := fmt.Sprintf("%d:frontend:relaysData", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.Set(cacheKey, data, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, data, utils.Day) if err != nil { logger.Errorf("error caching relaysData: %v", err) } @@ -344,7 +344,7 @@ func epochUpdater(wg *sync.WaitGroup) { logger.Errorf("error retrieving latest node epoch from the database: %v", err) } else { cacheKey := fmt.Sprintf("%d:frontend:latestNodeEpoch", utils.Config.Chain.ClConfig.DepositChainID) - err := cache.TieredCache.SetUint64(cacheKey, epochNode, time.Hour*24) + err := cache.TieredCache.SetUint64(cacheKey, epochNode, utils.Day) if err != nil { logger.Errorf("error caching latestNodeEpoch: %v", err) } @@ -357,7 +357,7 @@ func epochUpdater(wg *sync.WaitGroup) { logger.Errorf("error retrieving latest node finalized epoch from the database: %v", err) } else { cacheKey := fmt.Sprintf("%d:frontend:latestNodeFinalizedEpoch", utils.Config.Chain.ClConfig.DepositChainID) - err := cache.TieredCache.SetUint64(cacheKey, latestNodeFinalized, time.Hour*24) + err := cache.TieredCache.SetUint64(cacheKey, latestNodeFinalized, utils.Day) if err != nil { logger.Errorf("error caching latestNodeFinalized: %v", err) } @@ -370,7 +370,7 @@ func epochUpdater(wg *sync.WaitGroup) { logger.Errorf("error retrieving latest exported epoch from the database: %v", err) } else { cacheKey := fmt.Sprintf("%d:frontend:latestEpoch", utils.Config.Chain.ClConfig.DepositChainID) - err := cache.TieredCache.SetUint64(cacheKey, epoch, time.Hour*24) + err := cache.TieredCache.SetUint64(cacheKey, epoch, utils.Day) if err != nil { logger.Errorf("error caching latestEpoch: %v", err) } @@ -383,7 +383,7 @@ func epochUpdater(wg *sync.WaitGroup) { logger.Errorf("error retrieving latest exported finalized epoch from the database: %v", err) } else { cacheKey := fmt.Sprintf("%d:frontend:latestFinalized", utils.Config.Chain.ClConfig.DepositChainID) - err := cache.TieredCache.SetUint64(cacheKey, latestFinalizedEpoch, time.Hour*24) + err := cache.TieredCache.SetUint64(cacheKey, latestFinalizedEpoch, utils.Day) if err != nil { logger.Errorf("error caching latestFinalizedEpoch: %v", err) } @@ -413,7 +413,7 @@ func slotUpdater(wg *sync.WaitGroup) { } } else { cacheKey := fmt.Sprintf("%d:frontend:slot", utils.Config.Chain.ClConfig.DepositChainID) - err := cache.TieredCache.SetUint64(cacheKey, slot, time.Hour*24) + err := cache.TieredCache.SetUint64(cacheKey, slot, utils.Day) if err != nil { logger.Errorf("error caching slot: %v", err) } @@ -440,7 +440,7 @@ func poolsUpdater(wg *sync.WaitGroup) { } cacheKey := fmt.Sprintf("%d:frontend:poolsData", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.Set(cacheKey, data, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, data, utils.Day) if err != nil { logger.Errorf("error caching poolsData: %v", err) } @@ -493,7 +493,7 @@ func latestProposedSlotUpdater(wg *sync.WaitGroup) { } else { cacheKey := fmt.Sprintf("%d:frontend:latestProposedSlot", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.SetUint64(cacheKey, slot, time.Hour*24) + err = cache.TieredCache.SetUint64(cacheKey, slot, utils.Day) if err != nil { logger.Errorf("error caching latestProposedSlot: %v", err) } @@ -523,7 +523,7 @@ func indexPageDataUpdater(wg *sync.WaitGroup) { logger.WithFields(logrus.Fields{"genesis": data.Genesis, "currentEpoch": data.CurrentEpoch, "networkName": data.NetworkName, "networkStartTs": data.NetworkStartTs}).Infof("index page data update completed in %v", time.Since(start)) cacheKey := fmt.Sprintf("%d:frontend:indexPageData", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.Set(cacheKey, data, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, data, utils.Day) if err != nil { logger.Errorf("error caching indexPageData: %v", err) } @@ -548,7 +548,7 @@ func ethStoreStatisticsDataUpdater(wg *sync.WaitGroup) { } cacheKey := fmt.Sprintf("%d:frontend:ethStoreStatistics", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.Set(cacheKey, data, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, data, utils.Day) if err != nil { logger.Errorf("error caching ETH.STORE statistics data: %v", err) } @@ -572,7 +572,7 @@ func slotVizUpdater(wg *sync.WaitGroup) { logger.Errorf("error retrieving slot viz data from database: %v latest epoch: %v", err, latestEpoch) } else { cacheKey := fmt.Sprintf("%d:frontend:slotVizMetrics", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.Set(cacheKey, epochData, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, epochData, utils.Day) if err != nil { logger.Errorf("error caching slotVizMetrics: %v", err) } @@ -756,7 +756,7 @@ func getIndexPageData() (*types.IndexPageData, error) { periodDays := float64(len(points)) avgDepositPerDay := data.DepositedTotal / periodDays daysUntilThreshold := (data.DepositThreshold - data.DepositedTotal) / avgDepositPerDay - estimatedTimeToThreshold := time.Now().Add(time.Hour * 24 * time.Duration(daysUntilThreshold)) + estimatedTimeToThreshold := time.Now().Add(utils.Day * time.Duration(daysUntilThreshold)) if estimatedTimeToThreshold.After(time.Unix(data.NetworkStartTs, 0)) { data.NetworkStartTs = estimatedTimeToThreshold.Add(time.Duration(int64(utils.Config.Chain.ClConfig.GenesisDelay) * 1000 * 1000 * 1000)).Unix() } @@ -771,7 +771,7 @@ func getIndexPageData() (*types.IndexPageData, error) { data.Genesis = false } // show the transition view one hour before the first slot and until epoch 30 is reached - if now.Add(time.Hour*24).After(startSlotTime) && now.Before(genesisTransition) { + if now.Add(utils.Day).After(startSlotTime) && now.Before(genesisTransition) { data.GenesisPeriod = true } else { data.GenesisPeriod = false @@ -1024,7 +1024,7 @@ func LatestProposedSlot() uint64 { func LatestMempoolTransactions() *types.RawMempoolResponse { wanted := &types.RawMempoolResponse{} cacheKey := fmt.Sprintf("%d:frontend:mempool", utils.Config.Chain.ClConfig.DepositChainID) - if wanted, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Second*60, wanted); err == nil { + if wanted, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Minute, wanted); err == nil { return wanted.(*types.RawMempoolResponse) } else { logger.Errorf("error retrieving mempool data from cache: %v", err) @@ -1035,7 +1035,7 @@ func LatestMempoolTransactions() *types.RawMempoolResponse { func LatestBurnData() *types.BurnPageData { wanted := &types.BurnPageData{} cacheKey := fmt.Sprintf("%d:frontend:burn", utils.Config.Chain.ClConfig.DepositChainID) - if wanted, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Second*60, wanted); err == nil { + if wanted, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Minute, wanted); err == nil { return wanted.(*types.BurnPageData) } else { logger.Errorf("error retrieving burn data from cache: %v", err) @@ -1046,7 +1046,7 @@ func LatestBurnData() *types.BurnPageData { func LatestEthStoreStatistics() *types.EthStoreStatistics { wanted := &types.EthStoreStatistics{} cacheKey := fmt.Sprintf("%d:frontend:ethStoreStatistics", utils.Config.Chain.ClConfig.DepositChainID) - if wanted, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Second*60, wanted); err == nil { + if wanted, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Minute, wanted); err == nil { return wanted.(*types.EthStoreStatistics) } else { logger.Errorf("error retrieving ETH.STORE statistics data from cache: %v", err) @@ -1271,7 +1271,7 @@ func gasNowUpdater(wg *sync.WaitGroup) { } cacheKey := fmt.Sprintf("%d:frontend:gasNow", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.Set(cacheKey, data, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, data, utils.Day) if err != nil { logger.Errorf("error caching latestFinalizedEpoch: %v", err) } @@ -1479,7 +1479,7 @@ func mempoolUpdater(wg *sync.WaitGroup) { } cacheKey := fmt.Sprintf("%d:frontend:mempool", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.Set(cacheKey, mempoolTx, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, mempoolTx, utils.Day) if err != nil { logger.Errorf("error caching mempool data: %v", err) } @@ -1502,7 +1502,7 @@ func burnUpdater(wg *sync.WaitGroup) { continue } cacheKey := fmt.Sprintf("%d:frontend:burn", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.Set(cacheKey, data, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, data, utils.Day) if err != nil { logger.Errorf("error caching burn data: %v", err) } @@ -1686,7 +1686,7 @@ func latestExportedStatisticDayUpdater(wg *sync.WaitGroup) { continue } - err = cache.TieredCache.Set(cacheKey, lastDay, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, lastDay, utils.Day) if err != nil { logger.Errorf("error caching last exported statistics day: %v", err) } @@ -1696,7 +1696,7 @@ func latestExportedStatisticDayUpdater(wg *sync.WaitGroup) { logger.Info("initialized last exported statistics day updater") } ReportStatus("lastExportedStatisticDay", "Running", nil) - time.Sleep(time.Second * 120) + time.Sleep(time.Minute * 2) } } diff --git a/services/stats.go b/services/stats.go index 8da2a1684f..e0d1b44270 100644 --- a/services/stats.go +++ b/services/stats.go @@ -28,7 +28,7 @@ func statsUpdater(wg *sync.WaitGroup) { logger.WithField("epoch", latestEpoch).WithField("duration", time.Since(now)).Info("stats update completed") cacheKey := fmt.Sprintf("%d:frontend:latestStats", utils.Config.Chain.ClConfig.DepositChainID) - err = cache.TieredCache.Set(cacheKey, statResult, time.Hour*24) + err = cache.TieredCache.Set(cacheKey, statResult, utils.Day) if err != nil { logger.Errorf("error caching latestStats: %v", err) } diff --git a/utils/session.go b/utils/session.go index e875457ba9..7096940898 100644 --- a/utils/session.go +++ b/utils/session.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "net/http" - "time" "github.com/alexedwards/scs/redisstore" "github.com/alexedwards/scs/v2" @@ -94,7 +93,7 @@ func InitSessionStore(secret string) { } sessionManager := scs.New() - sessionManager.Lifetime = time.Hour * 24 * 7 + sessionManager.Lifetime = Week sessionManager.Cookie.Name = "session_id" sessionManager.Cookie.HttpOnly = true sessionManager.Cookie.Persist = true diff --git a/utils/utils.go b/utils/utils.go index d10813531a..62d6b79790 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -1427,8 +1427,7 @@ func GetTimeToNextWithdrawal(distance uint64) time.Time { } func EpochsPerDay() uint64 { - day := time.Hour * 24 - return (uint64(day.Seconds()) / Config.Chain.ClConfig.SlotsPerEpoch) / Config.Chain.ClConfig.SecondsPerSlot + return (uint64(Day.Seconds()) / Config.Chain.ClConfig.SlotsPerEpoch) / Config.Chain.ClConfig.SecondsPerSlot } func GetFirstAndLastEpochForDay(day uint64) (uint64, uint64) { From 1d9e813d6ff3eaf29884c69bb06cc8720f9f90a6 Mon Sep 17 00:00:00 2001 From: thib-wien Date: Mon, 27 Nov 2023 12:38:56 +0100 Subject: [PATCH 2/4] (BIDS-1823) Adjusts the format of numerous time durations --- handlers/api_eth1.go | 6 +++--- services/notifications.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/handlers/api_eth1.go b/handlers/api_eth1.go index d8508a87ea..79cf0f3234 100644 --- a/handlers/api_eth1.go +++ b/handlers/api_eth1.go @@ -483,9 +483,9 @@ func formatBlocksForApiResponse(blocks []*types.Eth1BlockIndexed, relaysData map func getValidatorExecutionPerformance(queryIndices []uint64) ([]types.ExecutionPerformanceResponse, error) { latestEpoch := services.LatestEpoch() - last31dTimestamp := time.Now().Add(-31 * 24 * time.Hour) - last7dTimestamp := time.Now().Add(-7 * 24 * time.Hour) - last1dTimestamp := time.Now().Add(-1 * 24 * time.Hour) + last31dTimestamp := time.Now().Add(-31 * utils.Day) + last7dTimestamp := time.Now().Add(-7 * utils.Day) + last1dTimestamp := time.Now().Add(-1 * utils.Day) monthRange := latestEpoch - 7200 if latestEpoch < 7200 { diff --git a/services/notifications.go b/services/notifications.go index f8f4576f11..87968640af 100644 --- a/services/notifications.go +++ b/services/notifications.go @@ -2776,7 +2776,7 @@ func (n *rocketpoolNotification) GetInfo(includeUrl bool) string { var inTime time.Duration syncStartEpoch, err := strconv.ParseUint(extras[1], 10, 64) if err != nil { - inTime = time.Duration(24 * time.Hour) + inTime = time.Duration(utils.Day) } else { inTime = time.Until(utils.EpochToTime(syncStartEpoch)) } From 40bd8cac004b1e726d8b84d5427a6d93c41df4a6 Mon Sep 17 00:00:00 2001 From: thib-wien Date: Mon, 27 Nov 2023 16:44:27 +0100 Subject: [PATCH 3/4] Additional changes after review --- cmd/explorer/main.go | 2 +- db/db.go | 4 +-- start | 29 ++++++++++++++++++++++ stop | 58 ++++++++++++++++++++++++++++++++++++++++++++ utils/utils.go | 6 ++--- 5 files changed, 93 insertions(+), 6 deletions(-) create mode 100755 start create mode 100755 stop diff --git a/cmd/explorer/main.go b/cmd/explorer/main.go index cfc0a96b08..611a67d974 100644 --- a/cmd/explorer/main.go +++ b/cmd/explorer/main.go @@ -620,7 +620,7 @@ func main() { utils.Config.Frontend.HttpReadTimeout = time.Second * 15 } if utils.Config.Frontend.HttpIdleTimeout == 0 { - utils.Config.Frontend.HttpIdleTimeout = time.Second * 60 + utils.Config.Frontend.HttpIdleTimeout = time.Minute } srv := &http.Server{ Addr: cfg.Frontend.Server.Host + ":" + cfg.Frontend.Server.Port, diff --git a/db/db.go b/db/db.go index 2e123f845c..334d8e57e7 100644 --- a/db/db.go +++ b/db/db.go @@ -98,7 +98,7 @@ func mustInitDB(writer *types.DatabaseConfig, reader *types.DatabaseConfig) (*sq dbTestConnection(dbConnWriter, "database") dbConnWriter.SetConnMaxIdleTime(time.Second * 30) - dbConnWriter.SetConnMaxLifetime(time.Second * 60) + dbConnWriter.SetConnMaxLifetime(time.Minute) dbConnWriter.SetMaxOpenConns(writer.MaxOpenConns) dbConnWriter.SetMaxIdleConns(writer.MaxIdleConns) @@ -114,7 +114,7 @@ func mustInitDB(writer *types.DatabaseConfig, reader *types.DatabaseConfig) (*sq dbTestConnection(dbConnReader, "read replica database") dbConnReader.SetConnMaxIdleTime(time.Second * 30) - dbConnReader.SetConnMaxLifetime(time.Second * 60) + dbConnReader.SetConnMaxLifetime(time.Minute) dbConnReader.SetMaxOpenConns(reader.MaxOpenConns) dbConnReader.SetMaxIdleConns(reader.MaxIdleConns) return dbConnWriter, dbConnReader diff --git a/start b/start new file mode 100755 index 0000000000..96d71a4b7c --- /dev/null +++ b/start @@ -0,0 +1,29 @@ +#!/bin/sh +set -v +notallmodules="indexer eth1indexer frontend-data-updater" + +./stop +cd ~/eth2-beaconchain-explorer/local-deployment/ + +set +v +echo "================================================================" +echo "Launch all modules?" +echo "'n' will launch only $notallmodules" +read -p "y/n ? " runall +echo "================================================================" +set -v + +systemctl restart docker.service +kurtosis engine restart +kurtosis clean -a + +kurtosis run --enclave my-testnet . "$(cat network-params.json)" + +bash provision-explorer-config.sh + +case $runall in + y) docker compose up -d;; + n) docker compose up -d ${notallmodules};; + *) echo "Please start Docker manually.";; +esac + diff --git a/stop b/stop new file mode 100755 index 0000000000..de728049dc --- /dev/null +++ b/stop @@ -0,0 +1,58 @@ +#!/bin/sh + +set -v +cd ~/eth2-beaconchain-explorer/local-deployment/ + +set +v +echo "===============================================================" +echo "What strength do you need?" +echo "Most of the time, 1 is enough. If Kurtosis or Docker gives you" +echo "errors that you cannot explain, try to clean at level 2. If it" +echo "doesn't solve your weird problem, try level 3." +echo "USE LEVEL 4 IN LAST RESORT ONLY. Please read the script before" +echo "trying level 4! To completely achieve level 4, you might need" +echo "to do it twice." +read -p "1/2/3/4 ? " strength +echo "===============================================================" + +# yes, I could use if statements and functions, but I prefer readability for this critical script: + +case $strength in + 4) set -v + sudo aa-remove-unknown + sudo apparmor_parser -r /etc/apparmor.d/*snap-confine* + sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap-confine* + sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/* + sudo systemctl daemon-reload + sudo systemctl enable --now apparmor.service + sudo systemctl enable --now snapd.apparmor.service + sudo snap refresh --stable chromium + sudo snap refresh --stable firefox + sudo snap refresh --stable docker + set +v + ;; +esac + +case $strength in + 4|3|2) set -v + kurtosis enclave rm -f my-testnet + sudo docker rm -f $(docker ps -qa) + sudo docker compose down + kurtosis engine stop + sudo docker network rm -f kt-my-testnet + set +v + ;; + *) set -v + docker compose down + kurtosis engine stop + set +v + ;; +esac + +case $strength in + 4|3) set -v + sudo docker system prune --volumes -a -f + set +v + ;; +esac + diff --git a/utils/utils.go b/utils/utils.go index 62d6b79790..2032b21da4 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -360,12 +360,12 @@ func EpochToTime(epoch uint64) time.Time { // TimeToDay will return a days since genesis for an timestamp func TimeToDay(timestamp uint64) uint64 { - return uint64(time.Unix(int64(timestamp), 0).Sub(time.Unix(int64(Config.Chain.GenesisTimestamp), 0)).Hours() / 24) - // return time.Unix(int64(Config.Chain.GenesisTimestamp), 0).Add(time.Hour * time.Duration(24*int(day))) + const hoursInADay = float64(Day / time.Hour) + return uint64(time.Unix(int64(timestamp), 0).Sub(time.Unix(int64(Config.Chain.GenesisTimestamp), 0)).Hours() / hoursInADay) } func DayToTime(day int64) time.Time { - return time.Unix(int64(Config.Chain.GenesisTimestamp), 0).Add(time.Hour * time.Duration(24*int(day))) + return time.Unix(int64(Config.Chain.GenesisTimestamp), 0).Add(Day * time.Duration(day)) } // TimeToEpoch will return an epoch for a given time From 4ca03ca2133f1065d062355a0755d8f8adc3f427 Mon Sep 17 00:00:00 2001 From: thib-wien Date: Mon, 27 Nov 2023 16:48:10 +0100 Subject: [PATCH 4/4] (BIDS-1823) Additional changes after review --- start | 29 ----------------------------- stop | 58 ---------------------------------------------------------- 2 files changed, 87 deletions(-) delete mode 100755 start delete mode 100755 stop diff --git a/start b/start deleted file mode 100755 index 96d71a4b7c..0000000000 --- a/start +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -set -v -notallmodules="indexer eth1indexer frontend-data-updater" - -./stop -cd ~/eth2-beaconchain-explorer/local-deployment/ - -set +v -echo "================================================================" -echo "Launch all modules?" -echo "'n' will launch only $notallmodules" -read -p "y/n ? " runall -echo "================================================================" -set -v - -systemctl restart docker.service -kurtosis engine restart -kurtosis clean -a - -kurtosis run --enclave my-testnet . "$(cat network-params.json)" - -bash provision-explorer-config.sh - -case $runall in - y) docker compose up -d;; - n) docker compose up -d ${notallmodules};; - *) echo "Please start Docker manually.";; -esac - diff --git a/stop b/stop deleted file mode 100755 index de728049dc..0000000000 --- a/stop +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh - -set -v -cd ~/eth2-beaconchain-explorer/local-deployment/ - -set +v -echo "===============================================================" -echo "What strength do you need?" -echo "Most of the time, 1 is enough. If Kurtosis or Docker gives you" -echo "errors that you cannot explain, try to clean at level 2. If it" -echo "doesn't solve your weird problem, try level 3." -echo "USE LEVEL 4 IN LAST RESORT ONLY. Please read the script before" -echo "trying level 4! To completely achieve level 4, you might need" -echo "to do it twice." -read -p "1/2/3/4 ? " strength -echo "===============================================================" - -# yes, I could use if statements and functions, but I prefer readability for this critical script: - -case $strength in - 4) set -v - sudo aa-remove-unknown - sudo apparmor_parser -r /etc/apparmor.d/*snap-confine* - sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap-confine* - sudo apparmor_parser -r /var/lib/snapd/apparmor/profiles/* - sudo systemctl daemon-reload - sudo systemctl enable --now apparmor.service - sudo systemctl enable --now snapd.apparmor.service - sudo snap refresh --stable chromium - sudo snap refresh --stable firefox - sudo snap refresh --stable docker - set +v - ;; -esac - -case $strength in - 4|3|2) set -v - kurtosis enclave rm -f my-testnet - sudo docker rm -f $(docker ps -qa) - sudo docker compose down - kurtosis engine stop - sudo docker network rm -f kt-my-testnet - set +v - ;; - *) set -v - docker compose down - kurtosis engine stop - set +v - ;; -esac - -case $strength in - 4|3) set -v - sudo docker system prune --volumes -a -f - set +v - ;; -esac -