From c13df089c167d05c0456ad5a28d93e58af0262d9 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Mon, 30 Dec 2024 19:12:02 -0500 Subject: [PATCH 01/22] noop the current validator state refresh for now. We're switching to a regular view to avoid deadlocks that occur with realtime fetches to the website --- .../io/provenance/explorer/domain/entities/Validators.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Validators.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Validators.kt index 74255a4d..35415267 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Validators.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Validators.kt @@ -150,10 +150,11 @@ class ValidatorStateRecord(id: EntityID) : IntEntity(id) { .toList() } - fun refreshCurrentStateView() = transaction { - val query = "REFRESH MATERIALIZED VIEW current_validator_state" - this.exec(query) - } + fun refreshCurrentStateView() {} +// transaction { +// val query = "REFRESH MATERIALIZED VIEW current_validator_state" +// this.exec(query) +// } fun findAll(activeSet: Int) = transaction { val query = "SELECT * FROM get_all_validator_state(?, ?, NULL)".trimIndent() From 33e5cc2b48c447d705fa74e7d70f17aff2bfdd95 Mon Sep 17 00:00:00 2001 From: Jason D Date: Mon, 30 Dec 2024 17:12:23 -0700 Subject: [PATCH 02/22] change current_validator_state to a normal view --- .../V1_97__Update_validator_state_view.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql diff --git a/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql b/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql new file mode 100644 index 00000000..95f6eae5 --- /dev/null +++ b/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql @@ -0,0 +1,22 @@ +SELECT 'Modify `current_validator_state` view' AS comment; +DROP MATERIALIZED VIEW IF EXISTS current_validator_state; + +CREATE VIEW IF NOT EXISTS current_validator_state AS +SELECT DISTINCT ON (vs.operator_addr_id) vs.operator_addr_id, + vs.operator_address, + vs.block_height, + vs.moniker, + vs.status, + vs.jailed, + vs.token_count, + vs.json, + svc.account_address, + svc.consensus_address, + svc.consensus_pubkey, + vs.commission_rate, + vs.removed, + ai.image_url +FROM validator_state vs + JOIN staking_validator_cache svc on vs.operator_addr_id = svc.id + LEFT JOIN address_image ai ON svc.operator_address = ai.address +ORDER BY vs.operator_addr_id, vs.block_height desc; From 93c06529ebc386f32120c443b4fd40d257292423 Mon Sep 17 00:00:00 2001 From: Jason D Date: Mon, 30 Dec 2024 17:32:38 -0700 Subject: [PATCH 03/22] change current_validator_state to a normal view --- .../db/migration/V1_97__Update_validator_state_view.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql b/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql index 95f6eae5..1d743fa8 100644 --- a/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql +++ b/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql @@ -1,7 +1,7 @@ SELECT 'Modify `current_validator_state` view' AS comment; DROP MATERIALIZED VIEW IF EXISTS current_validator_state; -CREATE VIEW IF NOT EXISTS current_validator_state AS +CREATE VIEW current_validator_state AS SELECT DISTINCT ON (vs.operator_addr_id) vs.operator_addr_id, vs.operator_address, vs.block_height, From e8b89cc32c97d038ab82f530a25e40d5bf75da89 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Tue, 31 Dec 2024 09:55:49 -0500 Subject: [PATCH 04/22] - Add a table to track row counts, and apply a trigger to the tx_cache table. --- .../V1_98__Tx_cache_counter_trigger.sql | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql diff --git a/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql b/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql new file mode 100644 index 00000000..bd2d5134 --- /dev/null +++ b/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql @@ -0,0 +1,32 @@ +CREATE TABLE row_counts +( + id VARCHAR(20) NOT NULL PRIMARY KEY, + current_count BIGINT NOT NULL +); + +CREATE +OR REPLACE FUNCTION row_counts_trigger() +RETURNS TRIGGER +LANGUAGE PLPGSQL +AS +$$ +BEGIN + IF TG_OP = 'INSERT' THEN + UPDATE row_counts + SET current_count = current_count + 1 + WHERE id = 'tx_cache'; + ELSIF TG_OP = 'DELETE' THEN + UPDATE row_counts + SET current_count = current_count - 1 + WHERE id = 'tx_cache'; + END IF; + + RETURN NEW; +END; +$$; + +CREATE TRIGGER row_counts_trigger + BEFORE INSERT OR DELETE +ON tx_cache +FOR EACH ROW +EXECUTE FUNCTION row_counts_trigger(); From 84d8de8c54f8bf5f5c53d97c45225cee700b2e74 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Tue, 31 Dec 2024 10:00:21 -0500 Subject: [PATCH 05/22] create/ignore or replace to avoid conflicts if we shove this into the db sooner. --- .../V1_98__Tx_cache_counter_trigger.sql | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql b/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql index bd2d5134..9a9d49ba 100644 --- a/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql +++ b/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql @@ -1,11 +1,10 @@ -CREATE TABLE row_counts +CREATE TABLE IF NOT EXISTS row_counts ( id VARCHAR(20) NOT NULL PRIMARY KEY, current_count BIGINT NOT NULL ); -CREATE -OR REPLACE FUNCTION row_counts_trigger() +CREATE OR REPLACE FUNCTION tx_cache_row_counts_trigger() RETURNS TRIGGER LANGUAGE PLPGSQL AS @@ -25,8 +24,22 @@ BEGIN END; $$; + -- Create the trigger only if it does not already exist +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM pg_trigger + WHERE tgname = 'row_counts_trigger' + ) THEN CREATE TRIGGER row_counts_trigger BEFORE INSERT OR DELETE ON tx_cache -FOR EACH ROW -EXECUTE FUNCTION row_counts_trigger(); + FOR EACH ROW + EXECUTE FUNCTION tx_cache_row_counts_trigger(); +END IF; +END; +$$; + +INSERT INTO row_counts (id, current_count) +SELECT 'tx_cache', COUNT(*) FROM tx_cache; \ No newline at end of file From 353f500ef1f5c6973c4810fe5cfe53b92a0693d0 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Tue, 31 Dec 2024 10:57:04 -0500 Subject: [PATCH 06/22] - Ignore this one for now.. --- .../V1_98__Tx_cache_counter_trigger.sql | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql diff --git a/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql b/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql deleted file mode 100644 index 9a9d49ba..00000000 --- a/database/src/main/resources/db/migration/V1_98__Tx_cache_counter_trigger.sql +++ /dev/null @@ -1,45 +0,0 @@ -CREATE TABLE IF NOT EXISTS row_counts -( - id VARCHAR(20) NOT NULL PRIMARY KEY, - current_count BIGINT NOT NULL -); - -CREATE OR REPLACE FUNCTION tx_cache_row_counts_trigger() -RETURNS TRIGGER -LANGUAGE PLPGSQL -AS -$$ -BEGIN - IF TG_OP = 'INSERT' THEN - UPDATE row_counts - SET current_count = current_count + 1 - WHERE id = 'tx_cache'; - ELSIF TG_OP = 'DELETE' THEN - UPDATE row_counts - SET current_count = current_count - 1 - WHERE id = 'tx_cache'; - END IF; - - RETURN NEW; -END; -$$; - - -- Create the trigger only if it does not already exist -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM pg_trigger - WHERE tgname = 'row_counts_trigger' - ) THEN -CREATE TRIGGER row_counts_trigger - BEFORE INSERT OR DELETE -ON tx_cache - FOR EACH ROW - EXECUTE FUNCTION tx_cache_row_counts_trigger(); -END IF; -END; -$$; - -INSERT INTO row_counts (id, current_count) -SELECT 'tx_cache', COUNT(*) FROM tx_cache; \ No newline at end of file From 45d2aae83875d8c717ba224de4b868c7cbce2273 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Tue, 31 Dec 2024 11:28:42 -0500 Subject: [PATCH 07/22] - Add caching for recent blocks and txs --- buildSrc/src/main/kotlin/Dependencies.kt | 4 ++++ service/build.gradle.kts | 2 ++ .../provenance/explorer/config/CacheConfig.kt | 21 +++++++++++++++++++ .../explorer/web/v2/BlockController.kt | 2 ++ .../web/v2/TransactionControllerV2.kt | 14 +++++++------ 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 service/src/main/kotlin/io/provenance/explorer/config/CacheConfig.kt diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 1446ae1d..583aeb89 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,3 +1,4 @@ + object PluginIds { // please keep this sorted in sections // Kotlin const val Kotlin = "kotlin" @@ -55,6 +56,7 @@ object Versions { const val Postgres = "42.2.23" const val Protobuf = "3.21.9" const val Reflections = "0.9.12" + const val Caffeine = "2.9.2" // Testing const val Jupiter = "5.9.1" @@ -92,6 +94,7 @@ object Libraries { const val KaseChange = "net.pearx.kasechange:kasechange:${Versions.KaseChange}" const val Json = "org.json:json:${Versions.Json}" const val Reflections = "org.reflections:reflections:${Versions.Reflections}" + const val Caffeine = "com.github.ben-manes.caffeine:caffeine:${Versions.Caffeine}" // Protobuf const val GrpcNetty = "io.grpc:grpc-netty:${Versions.Grpc}" @@ -105,6 +108,7 @@ object Libraries { const val SpringBootConfigProcessor = "org.springframework.boot:spring-boot-configuration-processor:${Versions.SpringBoot}" const val SpringBootStarterValidation = "org.springframework.boot:spring-boot-starter-validation:${Versions.SpringBoot}" const val SpringBootStarterWeb = "org.springframework.boot:spring-boot-starter-web:${Versions.SpringBoot}" + const val SpringBootStarterCache = "org.springframework.boot:spring-boot-starter-cache:${Versions.SpringBoot}" const val SpringBootStarterTest = "org.springframework.boot:spring-boot-starter-test:${Versions.SpringBoot}" const val Swagger = "io.springfox:springfox-boot-starter:${Versions.Swagger}" diff --git a/service/build.gradle.kts b/service/build.gradle.kts index e53e1926..9abe1f11 100644 --- a/service/build.gradle.kts +++ b/service/build.gradle.kts @@ -28,11 +28,13 @@ dependencies { implementation(Libraries.ProtobufKotlin) implementation(Libraries.ProvenanceProto) implementation(Libraries.Reflections) + implementation(Libraries.Caffeine) implementation(Libraries.SpringBootStarterWeb) implementation(Libraries.SpringBootStarterJdbc) implementation(Libraries.SpringBootStarterActuator) implementation(Libraries.SpringBootStarterValidation) + implementation(Libraries.SpringBootStarterCache) kapt(Libraries.SpringBootConfigProcessor) implementation(Libraries.BouncyCastle) diff --git a/service/src/main/kotlin/io/provenance/explorer/config/CacheConfig.kt b/service/src/main/kotlin/io/provenance/explorer/config/CacheConfig.kt new file mode 100644 index 00000000..d86450f1 --- /dev/null +++ b/service/src/main/kotlin/io/provenance/explorer/config/CacheConfig.kt @@ -0,0 +1,21 @@ +import org.springframework.cache.CacheManager +import org.springframework.cache.annotation.EnableCaching +import org.springframework.cache.caffeine.CaffeineCacheManager +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import java.util.concurrent.TimeUnit + +@Configuration +@EnableCaching +class CacheConfig { + @Bean + fun cacheManager(): CacheManager { + val cacheManager = CaffeineCacheManager("responses") + cacheManager.setCaffeine( + com.github.benmanes.caffeine.cache.Caffeine.newBuilder() + .expireAfterWrite(30, TimeUnit.SECONDS) // Cache expires after 10 seconds + .maximumSize(100) + ) // Optional, limits the number of cached items + return cacheManager + } +} diff --git a/service/src/main/kotlin/io/provenance/explorer/web/v2/BlockController.kt b/service/src/main/kotlin/io/provenance/explorer/web/v2/BlockController.kt index 8f593d7f..f6ace5bd 100644 --- a/service/src/main/kotlin/io/provenance/explorer/web/v2/BlockController.kt +++ b/service/src/main/kotlin/io/provenance/explorer/web/v2/BlockController.kt @@ -4,6 +4,7 @@ import io.provenance.explorer.service.ExplorerService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation import io.swagger.annotations.ApiParam +import org.springframework.cache.annotation.Cacheable import org.springframework.http.MediaType import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.GetMapping @@ -34,6 +35,7 @@ class BlockController(private val explorerService: ExplorerService) { fun blockHeight(@PathVariable height: Int) = explorerService.getBlockAtHeight(height) @ApiOperation("Returns X most recent blocks") + @Cacheable(value = ["responses"], key = "{#root.methodName, #count, #page}") @GetMapping("/recent") fun recentBlocks( @ApiParam(value = "Record count between 1 and 200", defaultValue = "10", required = false) diff --git a/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt b/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt index 1509d93f..7cf98c8c 100644 --- a/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt +++ b/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt @@ -7,6 +7,7 @@ import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation import io.swagger.annotations.ApiParam import org.joda.time.DateTime +import org.springframework.cache.annotation.Cacheable import org.springframework.format.annotation.DateTimeFormat import org.springframework.http.MediaType import org.springframework.validation.annotation.Validated @@ -31,6 +32,7 @@ class TransactionControllerV2(private val transactionService: TransactionService @ApiOperation("Return the latest transactions with query params") @GetMapping("/recent") + @Cacheable(value = ["responses"], key = "{#root.methodName, #count, #page, #msgType, #txStatus, #fromDate, #toDate}") fun txsRecent( @ApiParam(defaultValue = "1", required = false) @RequestParam(defaultValue = "1") @@ -64,12 +66,12 @@ class TransactionControllerV2(private val transactionService: TransactionService @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) toDate: DateTime? ) = transactionService.getTxsByQuery( - msgType = msgType, - txStatus = txStatus, - count = count, - page = page, - fromDate = fromDate, - toDate = toDate + msgType = msgType, + txStatus = txStatus, + count = count, + page = page, + fromDate = fromDate, + toDate = toDate ) @ApiOperation("Return transaction detail by hash value") From ce761d2b2dcc72b1cef8431817d5bc796a8e84a0 Mon Sep 17 00:00:00 2001 From: arnabmitra Date: Tue, 31 Dec 2024 09:45:54 -0700 Subject: [PATCH 08/22] updating most cron jobs to run with delay of 5 mins --- .../explorer/service/async/ScheduledTaskService.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt b/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt index 4f2ed1d7..0ed4e062 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt @@ -94,7 +94,7 @@ class ScheduledTaskService( }.start() } - @Scheduled(initialDelay = 0L, fixedDelay = 5000L) + @Scheduled(initialDelay = 0L, fixedDelay = 300000L) // Every 5 minutes fun updateLatestBlockHeightJob() { val index = getBlockIndex() val startHeight = blockService.getLatestBlockHeight() @@ -211,7 +211,7 @@ class ScheduledTaskService( @Scheduled(initialDelay = 0L, fixedDelay = 5000L) fun updateSpotlight() = explorerService.createSpotlight() - @Scheduled(initialDelay = 0L, fixedDelay = 30000L) + @Scheduled(initialDelay = 0L, fixedDelay = 300000L) // Every 5 minutes fun retryBlockTxs() { logger.info("Retrying block/tx records") BlockTxRetryRecord.getRecordsToRetry().map { height -> @@ -263,7 +263,7 @@ class ScheduledTaskService( tokenService.updateAndSaveTokenHistoricalData(startDate, today) } - @Scheduled(initialDelay = 0L, fixedDelay = 300000L) // Every 5 minutes + @Scheduled(initialDelay = 0L, fixedDelay = 600000L) // Every 5 minutes fun updateTokenLatest() { val today = DateTime.now().withZone(DateTimeZone.UTC) val startDate = today.minusDays(1) @@ -349,7 +349,7 @@ class ScheduledTaskService( } } - @Scheduled(initialDelay = 5000L, fixedDelay = 5000L) + @Scheduled(initialDelay = 5000L, fixedDelay = 300000L) // Every 5 minutes fun startAccountProcess() { processAccountRecords() } From 277a22266fab8f3769a87ecd23a77b7f53a5938b Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Tue, 31 Dec 2024 13:16:14 -0500 Subject: [PATCH 09/22] - brute force logging --- .../io/provenance/explorer/domain/entities/Transactions.kt | 3 +++ .../io/provenance/explorer/service/TransactionService.kt | 1 + 2 files changed, 4 insertions(+) diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt index fa509e4c..b3bf4986 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt @@ -6,6 +6,7 @@ import cosmos.tx.v1beta1.ServiceOuterClass import io.provenance.explorer.OBJECT_MAPPER import io.provenance.explorer.VANILLA_MAPPER import io.provenance.explorer.config.ExplorerProperties +import io.provenance.explorer.domain.core.logger import io.provenance.explorer.domain.core.sql.Distinct import io.provenance.explorer.domain.core.sql.jsonb import io.provenance.explorer.domain.core.sql.toProcedureObject @@ -405,6 +406,8 @@ class TxMessageRecord(id: EntityID) : IntEntity(id) { } private fun findByQueryParams(tqp: TxQueryParams, distinctQuery: List>?) = transaction { + logger().info("Query Params: $tqp"); + var join: ColumnSet = TxMessageTable if (tqp.msgTypes.isNotEmpty()) diff --git a/service/src/main/kotlin/io/provenance/explorer/service/TransactionService.kt b/service/src/main/kotlin/io/provenance/explorer/service/TransactionService.kt index ac11f7e7..6d8c8299 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/TransactionService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/TransactionService.kt @@ -111,6 +111,7 @@ class TransactionService( ibcSrcPort: String? = null, ibcSrcChannel: String? = null ): PagedResults { + logger.info("Fetching transactions with address: $address, denom: $denom, module: $module, msgType: $msgType, txHeight: $txHeight, txStatus: $txStatus, count: $count, page: $page, fromDate: $fromDate, toDate: $toDate, nftAddr: $nftAddr, ibcChain: $ibcChain, ibcSrcPort: $ibcSrcPort, ibcSrcChannel: $ibcSrcChannel"); val msgTypes = if (msgType != null) listOf(msgType) else (module?.getValuesPlusAddtnl() ?: listOf()) val msgTypeIds = transaction { TxMessageTypeRecord.findByType(msgTypes).map { it.id.value } }.toList() val addr = transaction { address?.getAddressType(valService.getActiveSet()) } From 873564ffa16fb02f87ca5645e4c3289eacdcfa3b Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Tue, 31 Dec 2024 14:09:05 -0500 Subject: [PATCH 10/22] - noop the gov tx controller fetch for now. --- .../io/provenance/explorer/web/v2/TransactionControllerV2.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt b/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt index 7cf98c8c..96d954e2 100644 --- a/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt +++ b/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt @@ -1,7 +1,9 @@ package io.provenance.explorer.web.v2 import io.provenance.explorer.model.MsgTypeSet +import io.provenance.explorer.model.TxGov import io.provenance.explorer.model.TxStatus +import io.provenance.explorer.model.base.PagedResults import io.provenance.explorer.service.TransactionService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation @@ -342,7 +344,8 @@ class TransactionControllerV2(private val transactionService: TransactionService @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) toDate: DateTime? - ) = transactionService.getGovernanceTxs(address, msgType, txStatus, page, count, fromDate, toDate) + ) = PagedResults(0, emptyList(), 0) +// transactionService.getGovernanceTxs(address, msgType, txStatus, page, count, fromDate, toDate) @ApiOperation("Returns transactions for smart contract module with unique response type") @GetMapping("/module/smart_contract") From 2577dc32c6b3b12bd587a2df6160a26489e2427d Mon Sep 17 00:00:00 2001 From: arnabmitra Date: Tue, 31 Dec 2024 12:12:55 -0700 Subject: [PATCH 11/22] reverting scheduler changes. --- .../explorer/service/async/ScheduledTaskService.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt b/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt index 0ed4e062..514e23b7 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt @@ -94,7 +94,7 @@ class ScheduledTaskService( }.start() } - @Scheduled(initialDelay = 0L, fixedDelay = 300000L) // Every 5 minutes + @Scheduled(initialDelay = 0L, fixedDelay = 5000L) fun updateLatestBlockHeightJob() { val index = getBlockIndex() val startHeight = blockService.getLatestBlockHeight() @@ -263,7 +263,7 @@ class ScheduledTaskService( tokenService.updateAndSaveTokenHistoricalData(startDate, today) } - @Scheduled(initialDelay = 0L, fixedDelay = 600000L) // Every 5 minutes + @Scheduled(initialDelay = 0L, fixedDelay = 5000L) fun updateTokenLatest() { val today = DateTime.now().withZone(DateTimeZone.UTC) val startDate = today.minusDays(1) @@ -349,7 +349,7 @@ class ScheduledTaskService( } } - @Scheduled(initialDelay = 5000L, fixedDelay = 300000L) // Every 5 minutes + @Scheduled(initialDelay = 5000L, fixedDelay = 5000L) fun startAccountProcess() { processAccountRecords() } From 2fbc1fc6e632372842af5d1fe23e38ccd39c2ec7 Mon Sep 17 00:00:00 2001 From: arnabmitra Date: Tue, 31 Dec 2024 12:13:31 -0700 Subject: [PATCH 12/22] reverting scheduler changes. --- .../provenance/explorer/service/async/ScheduledTaskService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt b/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt index 514e23b7..460da9fa 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/async/ScheduledTaskService.kt @@ -211,7 +211,7 @@ class ScheduledTaskService( @Scheduled(initialDelay = 0L, fixedDelay = 5000L) fun updateSpotlight() = explorerService.createSpotlight() - @Scheduled(initialDelay = 0L, fixedDelay = 300000L) // Every 5 minutes + @Scheduled(initialDelay = 0L, fixedDelay = 5000L) fun retryBlockTxs() { logger.info("Retrying block/tx records") BlockTxRetryRecord.getRecordsToRetry().map { height -> From a3a642acec48982628723f2adf5e9e49f7f2ad70 Mon Sep 17 00:00:00 2001 From: Jason D Date: Tue, 31 Dec 2024 12:39:07 -0700 Subject: [PATCH 13/22] add subquery to primary tx query to prevent sorting until after distinct and joins --- .../io/provenance/explorer/domain/entities/Transactions.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt index b3bf4986..86a2aff4 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt @@ -395,6 +395,8 @@ class TxMessageRecord(id: EntityID) : IntEntity(id) { fun findByQueryForResults(txQueryParams: TxQueryParams) = transaction { val query = findByQueryParams(txQueryParams, listOf(distId) + tableColSet) + .alias("subQuery") //create a subquery to delay sorting until after the distinct + .selectAll() .orderBy(Pair(TxMessageTable.blockHeight, SortOrder.DESC)) .limit(txQueryParams.count, txQueryParams.offset.toLong()) TxMessageRecord.wrapRows(query).toSet() @@ -451,6 +453,7 @@ class TxMessageRecord(id: EntityID) : IntEntity(id) { query } + fun buildInsert(txInfo: TxData, message: Any, msgIdx: Int) = transaction { listOf( 0, From 04e3d81db6e13ef6c77b2316504359177de24a4b Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Tue, 31 Dec 2024 14:58:46 -0500 Subject: [PATCH 14/22] - Allow the tx query for validator gov proposals to run again now that we're ordering outside of the subquery --- .../io/provenance/explorer/web/v2/TransactionControllerV2.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt b/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt index 96d954e2..e43e63c8 100644 --- a/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt +++ b/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt @@ -344,8 +344,7 @@ class TransactionControllerV2(private val transactionService: TransactionService @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) toDate: DateTime? - ) = PagedResults(0, emptyList(), 0) -// transactionService.getGovernanceTxs(address, msgType, txStatus, page, count, fromDate, toDate) + ) = transactionService.getGovernanceTxs(address, msgType, txStatus, page, count, fromDate, toDate) @ApiOperation("Returns transactions for smart contract module with unique response type") @GetMapping("/module/smart_contract") From fca2f7c77fb4af181ccf69b49bfeb3cc7a207160 Mon Sep 17 00:00:00 2001 From: Jason D Date: Tue, 31 Dec 2024 13:57:57 -0700 Subject: [PATCH 15/22] tweak subquery alias to match orderBy expression --- .../io/provenance/explorer/domain/entities/Transactions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt index 86a2aff4..3b0f852e 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt @@ -395,7 +395,7 @@ class TxMessageRecord(id: EntityID) : IntEntity(id) { fun findByQueryForResults(txQueryParams: TxQueryParams) = transaction { val query = findByQueryParams(txQueryParams, listOf(distId) + tableColSet) - .alias("subQuery") //create a subquery to delay sorting until after the distinct + .alias("tx_message") //create a subquery (aliased as tx_message) to delay sorting until after the distinct .selectAll() .orderBy(Pair(TxMessageTable.blockHeight, SortOrder.DESC)) .limit(txQueryParams.count, txQueryParams.offset.toLong()) From a8a4c82b1d90254dbc9b23003690e08651c9c360 Mon Sep 17 00:00:00 2001 From: Carlton N Hanna Date: Fri, 3 Jan 2025 14:15:56 -0700 Subject: [PATCH 16/22] fix linting issues --- .../explorer/domain/entities/Transactions.kt | 5 ++--- .../explorer/service/TransactionService.kt | 2 +- .../explorer/web/v2/TransactionControllerV2.kt | 14 ++++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt index 3b0f852e..5ddc6198 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt @@ -395,7 +395,7 @@ class TxMessageRecord(id: EntityID) : IntEntity(id) { fun findByQueryForResults(txQueryParams: TxQueryParams) = transaction { val query = findByQueryParams(txQueryParams, listOf(distId) + tableColSet) - .alias("tx_message") //create a subquery (aliased as tx_message) to delay sorting until after the distinct + .alias("tx_message") // create a subquery (aliased as tx_message) to delay sorting until after the distinct .selectAll() .orderBy(Pair(TxMessageTable.blockHeight, SortOrder.DESC)) .limit(txQueryParams.count, txQueryParams.offset.toLong()) @@ -408,7 +408,7 @@ class TxMessageRecord(id: EntityID) : IntEntity(id) { } private fun findByQueryParams(tqp: TxQueryParams, distinctQuery: List>?) = transaction { - logger().info("Query Params: $tqp"); + logger().info("Query Params: $tqp") var join: ColumnSet = TxMessageTable @@ -453,7 +453,6 @@ class TxMessageRecord(id: EntityID) : IntEntity(id) { query } - fun buildInsert(txInfo: TxData, message: Any, msgIdx: Int) = transaction { listOf( 0, diff --git a/service/src/main/kotlin/io/provenance/explorer/service/TransactionService.kt b/service/src/main/kotlin/io/provenance/explorer/service/TransactionService.kt index 6d8c8299..bc76bede 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/TransactionService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/TransactionService.kt @@ -111,7 +111,7 @@ class TransactionService( ibcSrcPort: String? = null, ibcSrcChannel: String? = null ): PagedResults { - logger.info("Fetching transactions with address: $address, denom: $denom, module: $module, msgType: $msgType, txHeight: $txHeight, txStatus: $txStatus, count: $count, page: $page, fromDate: $fromDate, toDate: $toDate, nftAddr: $nftAddr, ibcChain: $ibcChain, ibcSrcPort: $ibcSrcPort, ibcSrcChannel: $ibcSrcChannel"); + logger.info("Fetching transactions with address: $address, denom: $denom, module: $module, msgType: $msgType, txHeight: $txHeight, txStatus: $txStatus, count: $count, page: $page, fromDate: $fromDate, toDate: $toDate, nftAddr: $nftAddr, ibcChain: $ibcChain, ibcSrcPort: $ibcSrcPort, ibcSrcChannel: $ibcSrcChannel") val msgTypes = if (msgType != null) listOf(msgType) else (module?.getValuesPlusAddtnl() ?: listOf()) val msgTypeIds = transaction { TxMessageTypeRecord.findByType(msgTypes).map { it.id.value } }.toList() val addr = transaction { address?.getAddressType(valService.getActiveSet()) } diff --git a/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt b/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt index e43e63c8..7f2a3c5f 100644 --- a/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt +++ b/service/src/main/kotlin/io/provenance/explorer/web/v2/TransactionControllerV2.kt @@ -1,9 +1,7 @@ package io.provenance.explorer.web.v2 import io.provenance.explorer.model.MsgTypeSet -import io.provenance.explorer.model.TxGov import io.provenance.explorer.model.TxStatus -import io.provenance.explorer.model.base.PagedResults import io.provenance.explorer.service.TransactionService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation @@ -68,12 +66,12 @@ class TransactionControllerV2(private val transactionService: TransactionService @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) toDate: DateTime? ) = transactionService.getTxsByQuery( - msgType = msgType, - txStatus = txStatus, - count = count, - page = page, - fromDate = fromDate, - toDate = toDate + msgType = msgType, + txStatus = txStatus, + count = count, + page = page, + fromDate = fromDate, + toDate = toDate ) @ApiOperation("Return transaction detail by hash value") From 87909d60f05a6c44dae9648190be6007811c3722 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Thu, 9 Jan 2025 13:13:52 -0500 Subject: [PATCH 17/22] Optimize ordering so that validators can fetch gov transactions. --- .../explorer/domain/entities/Transactions.kt | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt index 5ddc6198..3dd6d619 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt @@ -7,7 +7,7 @@ import io.provenance.explorer.OBJECT_MAPPER import io.provenance.explorer.VANILLA_MAPPER import io.provenance.explorer.config.ExplorerProperties import io.provenance.explorer.domain.core.logger -import io.provenance.explorer.domain.core.sql.Distinct +import io.provenance.explorer.domain.core.sql.DistinctOn import io.provenance.explorer.domain.core.sql.jsonb import io.provenance.explorer.domain.core.sql.toProcedureObject import io.provenance.explorer.domain.entities.FeeType.BASE_FEE_OVERAGE @@ -55,10 +55,14 @@ import org.jetbrains.exposed.sql.ColumnSet import org.jetbrains.exposed.sql.ColumnType import org.jetbrains.exposed.sql.Expression import org.jetbrains.exposed.sql.IntegerColumnType +import org.jetbrains.exposed.sql.Query import org.jetbrains.exposed.sql.SizedIterable import org.jetbrains.exposed.sql.SortOrder +import org.jetbrains.exposed.sql.SqlLogger import org.jetbrains.exposed.sql.TextColumnType +import org.jetbrains.exposed.sql.Transaction import org.jetbrains.exposed.sql.VarCharColumnType +import org.jetbrains.exposed.sql.addLogger import org.jetbrains.exposed.sql.alias import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.andWhere @@ -69,6 +73,7 @@ import org.jetbrains.exposed.sql.jodatime.DateColumnType import org.jetbrains.exposed.sql.jodatime.datetime import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll +import org.jetbrains.exposed.sql.statements.StatementContext import org.jetbrains.exposed.sql.transactions.TransactionManager import org.jetbrains.exposed.sql.transactions.transaction import org.joda.time.DateTime @@ -348,8 +353,6 @@ object TxMessageTable : IntIdTable(name = "tx_message") { class TxMessageRecord(id: EntityID) : IntEntity(id) { companion object : IntEntityClass(TxMessageTable) { - - val distId = Distinct(TxMessageTable.id, IntegerColumnType()).alias("dist") val tableColSet = TxMessageTable.columns.toMutableList() fun findByHash(hash: String) = transaction { @@ -370,7 +373,7 @@ class TxMessageRecord(id: EntityID) : IntEntity(id) { fun findByHashIdPaginated(hashId: Int, msgTypes: List, limit: Int, offset: Int) = transaction { val query = TxMessageTable .innerJoin(TxMsgTypeSubtypeTable, { TxMessageTable.id }, { TxMsgTypeSubtypeTable.txMsgId }) - .slice(listOf(distId) + tableColSet) + .slice(tableColSet) .select { TxMessageTable.txHashId eq hashId } if (msgTypes.isNotEmpty()) { query.andWhere { TxMsgTypeQueryTable.typeId inList msgTypes } @@ -394,12 +397,19 @@ class TxMessageRecord(id: EntityID) : IntEntity(id) { } fun findByQueryForResults(txQueryParams: TxQueryParams) = transaction { - val query = findByQueryParams(txQueryParams, listOf(distId) + tableColSet) - .alias("tx_message") // create a subquery (aliased as tx_message) to delay sorting until after the distinct - .selectAll() - .orderBy(Pair(TxMessageTable.blockHeight, SortOrder.DESC)) - .limit(txQueryParams.count, txQueryParams.offset.toLong()) - TxMessageRecord.wrapRows(query).toSet() + findByQueryParams(txQueryParams, tableColSet).let { + // Because of the way the db takes hints on when to materialize data for sorting, it is in our best interest + // to sort by the deepest level of the inner joins that have been executed. In this case this will yield a + // query that takes less than a second whereas ordering by the same field in the tx message table takes 18 minutes. + if ((txQueryParams.addressId != null && txQueryParams.addressType != null) || txQueryParams.address != null) + it.orderBy(Pair(TxAddressJoinTable.blockHeight, SortOrder.DESC)) + else + it.orderBy(Pair(TxMessageTable.blockHeight, SortOrder.DESC)) + }.let { + it.limit(txQueryParams.count, txQueryParams.offset.toLong()) + }.let { + TxMessageRecord.wrapRows(it).toSet() + } } fun findByQueryParamsForCount(txQueryParams: TxQueryParams) = transaction { From cf9ef6c80eb30fd86b4e95913f87cfb3b846340e Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Thu, 9 Jan 2025 13:16:48 -0500 Subject: [PATCH 18/22] removed usused imports --- .../io/provenance/explorer/domain/entities/Transactions.kt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt index 3dd6d619..ba121a7c 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Transactions.kt @@ -7,7 +7,6 @@ import io.provenance.explorer.OBJECT_MAPPER import io.provenance.explorer.VANILLA_MAPPER import io.provenance.explorer.config.ExplorerProperties import io.provenance.explorer.domain.core.logger -import io.provenance.explorer.domain.core.sql.DistinctOn import io.provenance.explorer.domain.core.sql.jsonb import io.provenance.explorer.domain.core.sql.toProcedureObject import io.provenance.explorer.domain.entities.FeeType.BASE_FEE_OVERAGE @@ -55,15 +54,10 @@ import org.jetbrains.exposed.sql.ColumnSet import org.jetbrains.exposed.sql.ColumnType import org.jetbrains.exposed.sql.Expression import org.jetbrains.exposed.sql.IntegerColumnType -import org.jetbrains.exposed.sql.Query import org.jetbrains.exposed.sql.SizedIterable import org.jetbrains.exposed.sql.SortOrder -import org.jetbrains.exposed.sql.SqlLogger import org.jetbrains.exposed.sql.TextColumnType -import org.jetbrains.exposed.sql.Transaction import org.jetbrains.exposed.sql.VarCharColumnType -import org.jetbrains.exposed.sql.addLogger -import org.jetbrains.exposed.sql.alias import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.andWhere import org.jetbrains.exposed.sql.countDistinct @@ -73,7 +67,6 @@ import org.jetbrains.exposed.sql.jodatime.DateColumnType import org.jetbrains.exposed.sql.jodatime.datetime import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll -import org.jetbrains.exposed.sql.statements.StatementContext import org.jetbrains.exposed.sql.transactions.TransactionManager import org.jetbrains.exposed.sql.transactions.transaction import org.joda.time.DateTime From 52eaaa7019652b0463ef9d642c6c6f4256c42133 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Thu, 9 Jan 2025 13:30:46 -0500 Subject: [PATCH 19/22] - Cleanup the various usages of the now defunct refresh materialized view functions. --- .../io/provenance/explorer/domain/entities/Validators.kt | 6 ------ .../io/provenance/explorer/service/ValidatorService.kt | 8 +++----- .../explorer/service/async/BlockAndTxProcessor.kt | 2 +- .../provenance/explorer/service/utility/UtilityService.kt | 2 -- .../explorer/web/v2/utility/UtilityController.kt | 4 ---- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Validators.kt b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Validators.kt index 35415267..8752573e 100644 --- a/service/src/main/kotlin/io/provenance/explorer/domain/entities/Validators.kt +++ b/service/src/main/kotlin/io/provenance/explorer/domain/entities/Validators.kt @@ -150,12 +150,6 @@ class ValidatorStateRecord(id: EntityID) : IntEntity(id) { .toList() } - fun refreshCurrentStateView() {} -// transaction { -// val query = "REFRESH MATERIALIZED VIEW current_validator_state" -// this.exec(query) -// } - fun findAll(activeSet: Int) = transaction { val query = "SELECT * FROM get_all_validator_state(?, ?, NULL)".trimIndent() val arguments = mutableListOf>( diff --git a/service/src/main/kotlin/io/provenance/explorer/service/ValidatorService.kt b/service/src/main/kotlin/io/provenance/explorer/service/ValidatorService.kt index b46657bb..81019898 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/ValidatorService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/ValidatorService.kt @@ -132,8 +132,7 @@ class ValidatorService( getImgUrl(it.description.identity) ?.let { img -> AddressImageRecord.upsert(it.operatorAddress, img) } } - }.also { ValidatorStateRecord.refreshCurrentStateView() } - .let { ValidatorStateRecord.findByOperator(getActiveSet(), address)!! } + }.let { ValidatorStateRecord.findByOperator(getActiveSet(), address)!! } } fun validateValidator(validator: String) = @@ -149,7 +148,6 @@ class ValidatorService( val votingPowerTotal = validatorSet.sumOf { it.votingPower.toBigInteger() } val slashingParams = getSlashingParams() validateStatus(addr, latestValidator, addr.operatorAddrId) - .also { if (it) ValidatorStateRecord.refreshCurrentStateView() } val stakingValidator = getStakingValidator(addr.operatorAddress) ValidatorDetails( if (latestValidator != null) { @@ -245,7 +243,7 @@ class ValidatorService( } else { false } - }.also { map -> if (map.contains(true)) ValidatorStateRecord.refreshCurrentStateView() } + } } // Updates the staking validator cache @@ -294,7 +292,7 @@ class ValidatorService( ).validatorsList getStakingValidators(status).map { v -> validateStatus(v, validatorSet.firstOrNull { it.address == v.consensusAddr }, v.operatorAddrId) - }.also { map -> if (map.contains(true)) ValidatorStateRecord.refreshCurrentStateView() } + } val stakingValidators = getStakingValidators(status, null, page.toOffset(count), count) val results = hydrateValidators(validatorSet, hr24ChangeSet, stakingValidators, height) val totalCount = getStakingValidatorsCount(status, null) diff --git a/service/src/main/kotlin/io/provenance/explorer/service/async/BlockAndTxProcessor.kt b/service/src/main/kotlin/io/provenance/explorer/service/async/BlockAndTxProcessor.kt index 165cd527..ddaf33b5 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/async/BlockAndTxProcessor.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/async/BlockAndTxProcessor.kt @@ -224,7 +224,7 @@ class BlockAndTxProcessor( TxAddressJoinType.OPERATOR.name -> validatorService.updateStakingValidators( ent.value, blockRes.block.height() - ).also { updated -> if (updated) ValidatorStateRecord.refreshCurrentStateView() } + ) } } } diff --git a/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt b/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt index 6f0bc22f..3548a923 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt @@ -127,8 +127,6 @@ class UtilityService( "( '$proto', '$module', '$type', '$category' )" } } - - fun refreshCurrentValidatorState() = ValidatorStateRecord.refreshCurrentStateView() } data class ProtoBreakout( diff --git a/service/src/main/kotlin/io/provenance/explorer/web/v2/utility/UtilityController.kt b/service/src/main/kotlin/io/provenance/explorer/web/v2/utility/UtilityController.kt index 96b48569..0cef0cbc 100644 --- a/service/src/main/kotlin/io/provenance/explorer/web/v2/utility/UtilityController.kt +++ b/service/src/main/kotlin/io/provenance/explorer/web/v2/utility/UtilityController.kt @@ -75,8 +75,4 @@ class UtilityController(private val us: UtilityService) { @ApiOperation("Parses and tries to save raw tx json, formatted as a string. Used for debugging a tx response") @PostMapping("/parse/tx_json/save") fun saveTxResponseObject(@RequestBody rawJson: String) = ResponseEntity.ok(us.saveRawTxJson(rawJson)) - - @ApiOperation("Refresh the current validator state view") - @GetMapping("/validator_refresh") - fun refreshValidatorStateView() = ResponseEntity.ok(us.refreshCurrentValidatorState()) } From 6b26c37d5aa00ce63f493e2aaf6179acf6a75089 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Thu, 9 Jan 2025 13:43:31 -0500 Subject: [PATCH 20/22] - Update changelog. --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a08c2b2c..1c2aabf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,14 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Unreleased +## Improvements +* Removed materialized view that is unnecessary and causes misdirection when debugging performance issues +* Add a caching interface for block and transaction queries that tend to be used often +* Optimize governance transaction fetching to return results in a timely fashion + +### Bug Fixes +* Resolve explorer service restarts due to database connection starvation caused by long running governance transaction queries + ## [v6.0.0](https://github.com/provenance-io/explorer-service/releases/tag/v6.0.0) - 2024-11-15 ### Features From fe2963d544d0355937ade6cc704d0b19666266d8 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Thu, 9 Jan 2025 18:37:40 -0500 Subject: [PATCH 21/22] - unused import --- .../io/provenance/explorer/service/utility/UtilityService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt b/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt index 3548a923..a8b3bd62 100644 --- a/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt +++ b/service/src/main/kotlin/io/provenance/explorer/service/utility/UtilityService.kt @@ -11,7 +11,6 @@ import io.provenance.explorer.domain.entities.TxFeeRecord import io.provenance.explorer.domain.entities.TxMessageRecord import io.provenance.explorer.domain.entities.TxMessageTypeRecord import io.provenance.explorer.domain.entities.UnknownTxType -import io.provenance.explorer.domain.entities.ValidatorStateRecord import io.provenance.explorer.domain.extensions.fromBase64 import io.provenance.explorer.domain.extensions.toObjectNode import io.provenance.explorer.domain.models.explorer.BlockProposer From 9aa8a7b23d3e58ed292beb92a32fd69c5a07aa95 Mon Sep 17 00:00:00 2001 From: Matt Conroy Date: Thu, 9 Jan 2025 18:37:51 -0500 Subject: [PATCH 22/22] - Add a config for ktlint that somewhat mimics what I'm seeing from the 0.47.1 version on version 1.5.0 this needs to be better... --- .editorconfig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..15f59f31 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,32 @@ +[*.{kt,kts}] + +ktlint_standard_filename=disabled +ktlint_standard_chain-wrapping=disabled +ktlint_standard_enum-entry-name-case=disabled +ktlint_standard_multiline-if-else=disabled +ktlint_standard_property-naming=disabled +ktlint_standard_max-line-length=disabled +ktlint_standard_value-parameter-comment=disabled +ktlint_standard_no-empty-file=disabled +ktlint_standard_function-naming=disabled + +ktlint_standard_function-signature=disabled +ktlint_standard_chain-method-continuation=disabled +ktlint_standard_multiline-expression-wrapping=disabled +ktlint_standard_trailing-comma-on-call-site=disabled +ktlint_standard_trailing-comma-on-declaration-site=disabled +ktlint_standard_class-signature=disabled +ktlint_standard_blank-line-before-declaration=disabled +ktlint_standard_no-empty-first-line-in-class-body=disabled +ktlint_standard_parameter-list-wrapping=disabled +ktlint_standard_argument-list-wrapping=disabled +ktlint_standard_function-expression-body=disabled +ktlint_standard_string-template-indent=disabled +ktlint_standard_indent=disabled +ktlint_standard_if-else-wrapping=disabled +ktlint_standard_condition-wrapping=disabled +ktlint_standard_statement-wrapping=disabled +ktlint_standard_try-catch-finally-spacing=disabled +ktlint_standard_if-else-bracing=disabled +ktlint_standard_no-blank-line-in-list=disabled +ktlint_standard_no-single-line-block-comment=disabled