Skip to content

Commit

Permalink
Add isUnderMaintenance flag
Browse files Browse the repository at this point in the history
closes: #459
  • Loading branch information
minxylynx committed Dec 10, 2022
1 parent 83d4e15 commit 27fbb52
Show file tree
Hide file tree
Showing 31 changed files with 454 additions and 237 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Now caching FT/NFT counts per address #448
* This is done on the fly, asynchronously
* The Account detail API pulls from the cached values
* Add `isUnderMaintenance` flag #459
* Allows the service to function properly without having to hit the node; ideal for when the node is upgrading

### Data
* Migration 1.86 - Add `process_queue`, `account_token_counts` #448
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ services:
- EXPLORER_UTILITY_TOKEN_DEFAULT_GAS_PRICE=1905
- EXPLORER_UTILITY_TOKEN_BASE_DECIMAL_PLACES=9
- EXPLORER_VOTING_POWER_PADDING=1000000
- EXPLORER_IS_UNDER_MAINTENANCE=false
depends_on:
- explorer-postgres
links:
Expand Down
2 changes: 0 additions & 2 deletions service/src/main/kotlin/io/provenance/explorer/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfigurat
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.ComponentScan
import org.springframework.scheduling.annotation.EnableScheduling
import org.springframework.web.servlet.config.annotation.EnableWebMvc
import springfox.documentation.swagger2.annotations.EnableSwagger2
import java.util.TimeZone

@ComponentScan(basePackages = ["io.provenance.explorer" ])
@EnableAutoConfiguration(exclude = [HibernateJpaAutoConfiguration::class])
@EnableConfigurationProperties(value = [ExplorerProperties::class])
@EnableScheduling
@EnableWebMvc
@EnableSwagger2
class Application
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.provenance.explorer.config

import io.provenance.explorer.config.interceptor.JwtInterceptor
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Configuration
import org.springframework.scheduling.annotation.EnableScheduling
import org.springframework.web.servlet.config.annotation.InterceptorRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

Expand All @@ -19,3 +21,8 @@ class AppConfig : WebMvcConfigurer {
)
}
}

@Configuration
@EnableScheduling
@ConditionalOnProperty(name = ["is-under-maintenance"], prefix = "explorer", havingValue = "false")
class SchedulerConfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class ExplorerProperties(
val swaggerUrl: String,
val swaggerProtocol: String,
val pricingUrl: String,
val feeBugRangeOneEleven: List<Int> // [0] is the beginning of the range, [1] is the end of the range, inclusive
val feeBugRangeOneEleven: List<Int>, // [0] is the beginning of the range, [1] is the end of the range, inclusive
val isUnderMaintenance: Boolean
) {

fun initialHistoricalDays() = initialHistoricalDayCount.toInt()
Expand All @@ -47,6 +48,7 @@ class ExplorerProperties(
var PROV_ACC_PREFIX = Bech32.PROVENANCE_TESTNET_ACCOUNT_PREFIX
var PROV_VAL_OPER_PREFIX = Bech32.PROVENANCE_TESTNET_VALIDATOR_ACCOUNT_PREFIX
var PROV_VAL_CONS_PREFIX = Bech32.PROVENANCE_TESTNET_CONSENSUS_ACCOUNT_PREFIX
var UNDER_MAINTENANCE = false
}

@Value("\${explorer.utility-token}")
Expand Down Expand Up @@ -82,4 +84,9 @@ class ExplorerProperties(
PROV_VAL_CONS_PREFIX = Bech32.PROVENANCE_TESTNET_CONSENSUS_ACCOUNT_PREFIX
}
}

@Value("\${explorer.is-under-maintenance}")
fun setUnderMaintenance(isUnderMaintenance: Boolean) {
UNDER_MAINTENANCE = isUnderMaintenance
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class ValidatorsCacheRecord(id: EntityID<Int>) : CacheEntity<Int>(id) {
.map { it[BlockCacheTable.height] }
.toSet()
}

fun getLatestByHeight() = transaction {
ValidatorsCacheRecord.all().orderBy(Pair(ValidatorsCacheTable.id, SortOrder.DESC)).first().validators
}

fun getAtHeight(height: Long) = transaction { ValidatorsCacheRecord.findById(height.toInt())!!.validators }
}

var height by ValidatorsCacheTable.height
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ fun List<CoinStr>.diff(newList: List<CoinStr>) =
}

fun BigDecimal.roundWhole() = this.setScale(0, RoundingMode.HALF_EVEN)

fun defaultCoin(denom: String) = coin {
this.denom = denom
this.amount = "0"
}
Original file line number Diff line number Diff line change
@@ -1,71 +1,72 @@
package io.provenance.explorer.domain.models.explorer

import com.fasterxml.jackson.databind.JsonNode
import io.provenance.explorer.JSON_NODE_FACTORY

data class Params(
val cosmos: CosmosParams,
val prov: ProvParams,
val cosmos: CosmosParams = CosmosParams(),
val prov: ProvParams = ProvParams(),
)

data class CosmosParams(
val auth: JsonNode,
val bank: JsonNode,
val dist: DistParams,
val gov: GovParams,
val mint: MintParams,
val slashing: SlashingParams,
val staking: JsonNode,
val ibc: IBCParams,
val wasm: JsonNode
val auth: JsonNode = JSON_NODE_FACTORY.objectNode(),
val bank: JsonNode = JSON_NODE_FACTORY.objectNode(),
val dist: DistParams = DistParams(),
val gov: GovParams = GovParams(),
val mint: MintParams = MintParams(),
val slashing: SlashingParams = SlashingParams(),
val staking: JsonNode = JSON_NODE_FACTORY.objectNode(),
val ibc: IBCParams = IBCParams(),
val wasm: JsonNode = JSON_NODE_FACTORY.objectNode()
)

data class DistParams(
val community_tax: String,
val base_proposer_reward: String,
val bonus_proposer_reward: String,
val withdraw_addr_enabled: Boolean,
val community_tax: String = "",
val base_proposer_reward: String = "",
val bonus_proposer_reward: String = "",
val withdraw_addr_enabled: Boolean = false,
)

data class GovParams(
val voting: JsonNode,
val tallying: TallyingParams,
val deposit: JsonNode,
val voting: JsonNode = JSON_NODE_FACTORY.objectNode(),
val tallying: TallyingParams = TallyingParams(),
val deposit: JsonNode = JSON_NODE_FACTORY.objectNode(),
)

data class TallyingParams(
val quorum: String,
val threshold: String,
val veto_threshold: String
val quorum: String = "",
val threshold: String = "",
val veto_threshold: String = ""
)

data class MintParams(
val mint_denom: String,
val inflation_rate_change: String,
val inflation_max: String,
val inflation_min: String,
val goal_bonded: String,
val blocks_per_year: Long,
val mint_denom: String = "",
val inflation_rate_change: String = "",
val inflation_max: String = "",
val inflation_min: String = "",
val goal_bonded: String = "",
val blocks_per_year: Long = 0L,
)

data class SlashingParams(
val signed_blocks_window: Long,
val min_signed_per_window: String,
val downtime_jail_duration: String,
val slash_fraction_double_sign: String,
val slash_fraction_downtime: String,
val signed_blocks_window: Long = 0L,
val min_signed_per_window: String = "",
val downtime_jail_duration: String = "",
val slash_fraction_double_sign: String = "",
val slash_fraction_downtime: String = "",
)

data class IBCParams(
val transfer: JsonNode,
val client: JsonNode,
val icaController: JsonNode?,
val icaHost: JsonNode
val transfer: JsonNode = JSON_NODE_FACTORY.objectNode(),
val client: JsonNode = JSON_NODE_FACTORY.objectNode(),
val icaController: JsonNode = JSON_NODE_FACTORY.objectNode(),
val icaHost: JsonNode = JSON_NODE_FACTORY.objectNode()
)

data class ProvParams(
val attribute: JsonNode,
val marker: JsonNode,
val metadata: JsonNode,
val name: JsonNode,
val msgFees: JsonNode
val attribute: JsonNode = JSON_NODE_FACTORY.objectNode(),
val marker: JsonNode = JSON_NODE_FACTORY.objectNode(),
val metadata: JsonNode = JSON_NODE_FACTORY.objectNode(),
val name: JsonNode = JSON_NODE_FACTORY.objectNode(),
val msgFees: JsonNode = JSON_NODE_FACTORY.objectNode()
)
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ fun getPagination(offset: Int, limit: Int) =
this.countTotal = true
}

fun getPaginationNoCount(offset: Int, limit: Int) =
pageRequest {
this.offset = offset.toLong()
this.limit = limit.toLong()
}

//endregion

//region Marker Extensions
Expand Down
Loading

0 comments on commit 27fbb52

Please sign in to comment.