Skip to content

Commit

Permalink
Feature: update to rc20 (#384)
Browse files Browse the repository at this point in the history
* feature: rc20 wip

Signed-off-by: Timur Guskov <[email protected]>

* feature: rc20 wip

Signed-off-by: Timur Guskov <[email protected]>

* update Executor to RC20

Signed-off-by: Marin Veršić <[email protected]>

* feature: rc20 wip

Signed-off-by: Timur Guskov <[email protected]>

* fix create_nft_for_alice_smartcontract

Signed-off-by: Marin Veršić <[email protected]>

* feature: rc20 wip

Signed-off-by: Timur Guskov <[email protected]>

* feature: rc20 wip

Signed-off-by: Timur Guskov <[email protected]>

* feature: rc20 wip

Signed-off-by: Timur Guskov <[email protected]>

* feature: rc20 wip

Signed-off-by: Timur Guskov <[email protected]>

* feature: test Iroha health check

Signed-off-by: Timur Guskov <[email protected]>

* feature: client test

Signed-off-by: Timur Guskov <[email protected]>

* feature: client test

Signed-off-by: Timur Guskov <[email protected]>

* feature: client test

Signed-off-by: Timur Guskov <[email protected]>

* feature: client test

Signed-off-by: Timur Guskov <[email protected]>

* feature: remove disabled from client tests

Signed-off-by: Timur Guskov <[email protected]>

* feature: fix docker compose + genesis.json

Signed-off-by: Timur Guskov <[email protected]>

---------

Signed-off-by: Timur Guskov <[email protected]>
Signed-off-by: Marin Veršić <[email protected]>
Co-authored-by: Timur Guskov <[email protected]>
Co-authored-by: Marin Veršić <[email protected]>
  • Loading branch information
3 people authored Nov 3, 2023
1 parent 9777064 commit 50cb33b
Show file tree
Hide file tree
Showing 125 changed files with 2,214 additions and 3,229 deletions.
8 changes: 4 additions & 4 deletions docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"

services:
iroha:
image: hyperledger/iroha2:stable-2.0.0-pre-rc.19
image: hyperledger/iroha2:stable-2.0.0-pre-rc.20
environment:
TORII_P2P_ADDR: iroha:1337
TORII_API_URL: iroha:8080
Expand All @@ -24,7 +24,7 @@ services:
command: iroha --submit-genesis

iroha1:
image: hyperledger/iroha2:stable-2.0.0-pre-rc.19
image: hyperledger/iroha2:stable-2.0.0-pre-rc.20
environment:
TORII_P2P_ADDR: iroha1:1338
TORII_API_URL: iroha1:8081
Expand All @@ -46,7 +46,7 @@ services:
command: iroha

iroha2:
image: hyperledger/iroha2:stable-2.0.0-pre-rc.19
image: hyperledger/iroha2:stable-2.0.0-pre-rc.20
environment:
TORII_P2P_ADDR: iroha2:1339
TORII_API_URL: iroha2:8082
Expand All @@ -68,7 +68,7 @@ services:
command: iroha

iroha3:
image: hyperledger/iroha2:stable-2.0.0-pre-rc.19
image: hyperledger/iroha2:stable-2.0.0-pre-rc.20
environment:
TORII_P2P_ADDR: iroha3:1340
TORII_API_URL: iroha3:8083
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.net.URL
fun main(args: Array<String>): Unit = runBlocking {
val peerUrl = "http://127.0.0.1:8080"
val telemetryUrl = "http://127.0.0.1:8180"
val admin = AccountId("bob".asName(), "wonderland".asDomainId())
val admin = AccountId("wonderland".asDomainId(), "bob".asName())
val adminKeyPair = keyPairFromHex(
"7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0",
"9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ open class AdminIroha2Client(
/**
* Send metrics request
*/
suspend fun metrics(): String = client.get("${getTelemetryUrl()}$METRICS_ENDPOINT").body()
suspend fun metrics(): String = client.get("${getApiUrl()}$METRICS_ENDPOINT").body()

/**
* Send health check request
Expand All @@ -66,7 +66,7 @@ open class AdminIroha2Client(
/**
* Send status check request
*/
suspend fun status(): PeerStatus = client.get("${getTelemetryUrl()}$STATUS_ENDPOINT").body()
suspend fun status(): PeerStatus = client.get("${getApiUrl()}$STATUS_ENDPOINT").body()

/**
* Send schema request
Expand Down
38 changes: 19 additions & 19 deletions modules/block/src/main/kotlin/jp/co/soramitsu/iroha2/Genesis.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package jp.co.soramitsu.iroha2

import jp.co.soramitsu.iroha2.generated.ExecutorMode
import jp.co.soramitsu.iroha2.generated.Expression
import jp.co.soramitsu.iroha2.generated.IdentifiableBox
import jp.co.soramitsu.iroha2.generated.InstructionBox
import jp.co.soramitsu.iroha2.generated.InstructionExpr
import jp.co.soramitsu.iroha2.generated.Metadata
import jp.co.soramitsu.iroha2.generated.NewAccount
import jp.co.soramitsu.iroha2.generated.NewAssetDefinition
import jp.co.soramitsu.iroha2.generated.NewDomain
import jp.co.soramitsu.iroha2.generated.RawGenesisBlock
import jp.co.soramitsu.iroha2.generated.RegisterBox
import jp.co.soramitsu.iroha2.generated.RegisterExpr
import jp.co.soramitsu.iroha2.generated.RegistrableBox
import jp.co.soramitsu.iroha2.generated.ValidatorMode
import jp.co.soramitsu.iroha2.generated.Value
import java.nio.file.Files
import java.nio.file.Path
Expand All @@ -37,31 +37,31 @@ open class Genesis(open val block: RawGenesisBlock) {

companion object {

val validatorMode = this::class.java.classLoader.getResource("validator.wasm")
?.let { ValidatorMode.Path("validator.wasm") }
?: throw IrohaSdkException("validator.wasm not found")
val executorMode = this::class.java.classLoader.getResource("executor.wasm")
?.let { ExecutorMode.Path("executor.wasm") }
?: throw IrohaSdkException("executor.wasm not found")

/**
* Return empty genesis
*/
fun getEmpty() = Genesis(RawGenesisBlock(listOf(listOf()), validatorMode))
fun getEmpty() = Genesis(RawGenesisBlock(listOf(listOf()), executorMode))

/**
* List of genesis blocks to single block with unique instructions
*/
fun List<Genesis>.toSingle(): Genesis {
val uniqueIsi: MutableSet<InstructionBox> = mutableSetOf()
val uniqueIsi: MutableSet<InstructionExpr> = mutableSetOf()
this.forEach { genesis ->
uniqueIsi.addAll(genesis.block.transactions.flatten())
}

return Genesis(RawGenesisBlock(listOf(uniqueIsi.mergeMetadata()), validatorMode))
return Genesis(RawGenesisBlock(listOf(uniqueIsi.mergeMetadata()), executorMode))
}

private fun MutableSet<InstructionBox>.mergeMetadata(): List<InstructionBox> {
private fun MutableSet<InstructionExpr>.mergeMetadata(): List<InstructionExpr> {
val metadataMap = mutableMapOf<Any, Metadata>()

// only for InstructionBox.Register
// only for InstructionExpr.Register
this.extractIdentifiableBoxes().forEach { idBox ->
metadataMap.putMergedMetadata(idBox)
}
Expand All @@ -71,16 +71,16 @@ open class Genesis(open val block: RawGenesisBlock) {
val idBox = toReplace.first().extractIdentifiableBox()
val registrableBox = idBox?.toRegisterBox(metadata)
?: throw RuntimeException("IdentifiableBox shouldn't be null")
this.add(InstructionBox.Register(RegisterBox(registrableBox.evaluatesTo())))
this.add(InstructionExpr.Register(RegisterExpr(registrableBox.evaluatesTo())))
}

return this.sorted()
}

private fun MutableSet<InstructionBox>.sorted() = this.sortedWith(
private fun MutableSet<InstructionExpr>.sorted() = this.sortedWith(
compareByDescending { instruction ->
when (instruction) {
is InstructionBox.Register -> when (instruction.extractIdentifiableBox()) {
is InstructionExpr.Register -> when (instruction.extractIdentifiableBox()) {
is IdentifiableBox.NewDomain -> 5
is IdentifiableBox.NewAccount -> 4
is IdentifiableBox.NewAssetDefinition -> 3
Expand Down Expand Up @@ -142,15 +142,15 @@ open class Genesis(open val block: RawGenesisBlock) {
}
}

private fun MutableSet<InstructionBox>.findIsiToReplace(
private fun MutableSet<InstructionExpr>.findIsiToReplace(
metadata: Map<Any, Metadata>,
): MutableMap<Metadata, MutableList<InstructionBox.Register>> {
val isiToReplace = mutableMapOf<Metadata, MutableList<InstructionBox.Register>>()
): MutableMap<Metadata, MutableList<InstructionExpr.Register>> {
val isiToReplace = mutableMapOf<Metadata, MutableList<InstructionExpr.Register>>()

this.forEach { instruction ->
runCatching {
instruction.cast<InstructionBox.Register>()
.registerBox.`object`.expression
instruction.cast<InstructionExpr.Register>()
.registerExpr.`object`.expression
.cast<Expression.Raw>().value
.cast<Value.Identifiable>().identifiableBox
}.onSuccess { idBox ->
Expand Down
Loading

0 comments on commit 50cb33b

Please sign in to comment.