Skip to content

Commit

Permalink
Merge pull request #1570 from novasamatech/rc/8.1.1
Browse files Browse the repository at this point in the history
Rc/8.1.1
  • Loading branch information
antonijzelinskij authored Jul 9, 2024
2 parents e2a3f1b + 8627583 commit c67c217
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
ext {
// App version
versionName = '8.1.0'
versionCode = 141
versionName = '8.1.1'
versionCode = 142

applicationId = "io.novafoundation.nova"
releaseApplicationSuffix = "market"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ fun Chain.Additional?.isGenericLedgerAppSupported(): Boolean {
return this?.supportLedgerGenericApp ?: false
}

fun Chain.Additional?.shouldDisableMetadataHashCheck(): Boolean {
return this?.disabledCheckMetadataHash ?: false
}

fun Chain.Additional?.isMigrationLedgerAppSupported(): Boolean {
return isGenericLedgerAppSupported()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.novafoundation.nova.common.utils.encodedIncludedInExtrinsic
import io.novafoundation.nova.common.utils.encodedIncludedInSignature
import io.novafoundation.nova.common.utils.hasSignedExtension
import io.novafoundation.nova.metadata_shortener.MetadataShortener
import io.novafoundation.nova.runtime.ext.shouldDisableMetadataHashCheck
import io.novafoundation.nova.runtime.ext.utilityAsset
import io.novafoundation.nova.runtime.multiNetwork.ChainRegistry
import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain
Expand Down Expand Up @@ -44,8 +45,9 @@ internal class RealMetadataShortenerService(
private val cache = MetadataProofCache()
override suspend fun isCheckMetadataHashAvailable(chainId: ChainId): Boolean {
val runtime = chainRegistry.getRuntime(chainId)
val chain = chainRegistry.getChain(chainId)

return runtime.metadata.shouldCalculateMetadataHash()
return shouldCalculateMetadataHash(runtime.metadata, chain)
}

override suspend fun generateExtrinsicProof(payloadExtrinsic: SignerPayloadExtrinsic): ByteArray {
Expand Down Expand Up @@ -81,7 +83,7 @@ internal class RealMetadataShortenerService(

return cache.getOrCompute(chainId, expectedSpecVersion = runtimeVersion.specVersion) {
val runtimeMetadata = chainRegistry.getRuntime(chainId).metadata
val shouldIncludeHash = runtimeMetadata.shouldCalculateMetadataHash()
val shouldIncludeHash = shouldCalculateMetadataHash(runtimeMetadata, chain)

if (shouldIncludeHash) {
generateMetadataProofOrDisabled(chain, runtimeVersion)
Expand Down Expand Up @@ -166,10 +168,11 @@ internal class RealMetadataShortenerService(
}
}

private fun RuntimeMetadata.shouldCalculateMetadataHash(): Boolean {
val atLeastMinimumVersion = metadataVersion >= MINIMUM_METADATA_VERSION_TO_CALCULATE_HASH
val hasSignedExtension = extrinsic.hasSignedExtension(DefaultSignedExtensions.CHECK_METADATA_HASH)
private fun shouldCalculateMetadataHash(runtimeMetadata: RuntimeMetadata, chain: Chain): Boolean {
val canBeEnabled = chain.additional.shouldDisableMetadataHashCheck().not()
val atLeastMinimumVersion = runtimeMetadata.metadataVersion >= MINIMUM_METADATA_VERSION_TO_CALCULATE_HASH
val hasSignedExtension = runtimeMetadata.extrinsic.hasSignedExtension(DefaultSignedExtensions.CHECK_METADATA_HASH)

return atLeastMinimumVersion && hasSignedExtension
return canBeEnabled && atLeastMinimumVersion && hasSignedExtension
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private const val MAX_ELECTING_VOTES = "stakingMaxElectingVoters"
private const val FEE_VIA_RUNTIME_CALL = "feeViaRuntimeCall"
private const val SUPPORT_GENERIC_LEDGER_APP = "supportsGenericLedgerApp"
private const val IDENTITY_CHAIN = "identityChain"
private const val DISABLED_CHECK_METADATA_HASH = "disabledCheckMetadataHash"

fun mapRemoteChainToLocal(
chainRemote: ChainRemote,
Expand All @@ -60,7 +61,8 @@ fun mapRemoteChainToLocal(
stakingMaxElectingVoters = it[MAX_ELECTING_VOTES].asGsonParsedIntOrNull(),
feeViaRuntimeCall = it[FEE_VIA_RUNTIME_CALL] as? Boolean,
supportLedgerGenericApp = it[SUPPORT_GENERIC_LEDGER_APP] as? Boolean,
identityChain = it[IDENTITY_CHAIN] as? ChainId
identityChain = it[IDENTITY_CHAIN] as? ChainId,
disabledCheckMetadataHash = it[DISABLED_CHECK_METADATA_HASH] as? Boolean
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ data class Chain(
val stakingMaxElectingVoters: Int?,
val feeViaRuntimeCall: Boolean?,
val supportLedgerGenericApp: Boolean?,
val identityChain: ChainId?
val identityChain: ChainId?,
val disabledCheckMetadataHash: Boolean?
)

data class Types(
Expand Down

0 comments on commit c67c217

Please sign in to comment.