From d6b9f0e118d458cf24be731b08da94596c0f7b7e Mon Sep 17 00:00:00 2001 From: Satya Date: Thu, 27 Jun 2024 10:57:06 +0800 Subject: [PATCH 1/5] chore: Update genesis file for conway era (8.12.0) --- .../localcluster/config/GenesisConfig.java | 2 +- .../genesis-templates/conway-genesis.json | 242 ++++++++++++++++- .../conway-genesis.json.conway | 246 +++++++++++++++++- 3 files changed, 481 insertions(+), 9 deletions(-) diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java index cb43a1b..de55d93 100644 --- a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java @@ -41,7 +41,7 @@ public class GenesisConfig { private BigInteger minUTxOValue = BigInteger.valueOf(1000000); private int nOpt = 100; private BigInteger poolDeposit = BigInteger.valueOf(500000000); - private int protocolMajorVer = 8; + private int protocolMajorVer = 10; private int protocolMinorVer = 0; private float monetaryExpansionRate = 0.003f; private float treasuryGrowthRate = 0.20f; diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json index 9f69c5f..8ca9cfd 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json @@ -24,15 +24,251 @@ "govActionDeposit": {{govActionDeposit}}, "dRepDeposit": {{dRepDeposit}}, "dRepActivity": {{dRepActivity}}, + "minFeeRefScriptCostPerByte": 44, + "plutusV3CostModel": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35190005, + 10, + 57996947, + 18975, + 10, + 39121781, + 32260, + 10, + 23000, + 100, + 23000, + 100, + 832808, + 18, + 3209094, + 6, + 331451, + 1, + 65990684, + 23097, + 18, + 114242, + 18, + 94393407, + 87060, + 18, + 16420089, + 18, + 2145798, + 36, + 3795345, + 12, + 889023, + 1, + 204237282, + 23271, + 36, + 129165, + 36, + 189977790, + 85902, + 36, + 33012864, + 36, + 388443360, + 1, + 401885761, + 72, + 2331379, + 72, + 1927926, + 82523, + 4, + 117366, + 10475, + 4, + 1292075, + 24469, + 74, + 0, + 1, + 936157, + 49601, + 237, + 0, + 1 + ], "constitution": { "anchor": { - "url": "", - "dataHash": "0000000000000000000000000000000000000000000000000000000000000000" + "url": "https://devkit.yaci.xyz/constitution.txt", + "dataHash": "f89cc2469ce31c3dfda2f3e0b56c5c8b4ee4f0e5f66c30a3f12a95298b01179e" } }, "committee": { "members": { }, - "quorum": 0 + "threshold": 0 } } diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json.conway b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json.conway index ff349fe..3066d6c 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json.conway +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json.conway @@ -4,7 +4,7 @@ "committeeNoConfidence": {{pvtCommitteeNoConfidence}}, "hardForkInitiation": {{pvtHardForkInitiation}}, "motionNoConfidence": {{pvtMotionNoConfidence}}, - "ppSecurityGroup": {{pvtPPSecurityGroup}}, + "ppSecurityGroup": {{pvtPPSecurityGroup}} }, "dRepVotingThresholds": { "motionNoConfidence": {{dvtMotionNoConfidence}}, @@ -16,7 +16,7 @@ "ppEconomicGroup": {{dvtPPEconomicGroup}}, "ppTechnicalGroup": {{dvtPPTechnicalGroup}}, "ppGovGroup": {{dvtPPGovGroup}}, - "treasuryWithdrawal": {{dvtTreasuryWithdrawal}}, + "treasuryWithdrawal": {{dvtTreasuryWithdrawal}} }, "committeeMinSize": {{committeeMinSize}}, "committeeMaxTermLength": {{committeeMaxTermLength}}, @@ -24,15 +24,251 @@ "govActionDeposit": {{govActionDeposit}}, "dRepDeposit": {{dRepDeposit}}, "dRepActivity": {{dRepActivity}}, + "minFeeRefScriptCostPerByte": 44, + "plutusV3CostModel": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35190005, + 10, + 57996947, + 18975, + 10, + 39121781, + 32260, + 10, + 23000, + 100, + 23000, + 100, + 832808, + 18, + 3209094, + 6, + 331451, + 1, + 65990684, + 23097, + 18, + 114242, + 18, + 94393407, + 87060, + 18, + 16420089, + 18, + 2145798, + 36, + 3795345, + 12, + 889023, + 1, + 204237282, + 23271, + 36, + 129165, + 36, + 189977790, + 85902, + 36, + 33012864, + 36, + 388443360, + 1, + 401885761, + 72, + 2331379, + 72, + 1927926, + 82523, + 4, + 117366, + 10475, + 4, + 1292075, + 24469, + 74, + 0, + 1, + 936157, + 49601, + 237, + 0, + 1 + ], "constitution": { "anchor": { - "url": "", - "dataHash": "0000000000000000000000000000000000000000000000000000000000000000" + "url": "https://devkit.yaci.xyz/constitution.txt", + "dataHash": "f89cc2469ce31c3dfda2f3e0b56c5c8b4ee4f0e5f66c30a3f12a95298b01179e" } }, "committee": { "members": { }, - "quorum": 0 + "threshold": 0 } } From bb4b9861d7e74a54ce85601a845b83b878d2a509 Mon Sep 17 00:00:00 2001 From: Satya Date: Fri, 28 Jun 2024 23:57:01 +0800 Subject: [PATCH 2/5] chore: Conway specific properties in genesis file --- .../commands/localcluster/ClusterService.java | 4 +- .../localcluster/config/GenesisConfig.java | 34 +++ .../genesis-templates/conway-genesis.json | 15 +- .../conway-genesis.json.conway | 274 ------------------ .../devnet/genesis-templates/spec/conway.json | 240 ++++++++++++++- 5 files changed, 284 insertions(+), 283 deletions(-) delete mode 100644 applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json.conway diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/ClusterService.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/ClusterService.java index 28e16bf..3dea7a9 100644 --- a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/ClusterService.java +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/ClusterService.java @@ -285,8 +285,8 @@ private void updateGenesis(Path clusterFolder, String clusterName, ClusterInfo c } else if (era == Era.Conway) { srcByronGenesisFile = clusterFolder.resolve("genesis-templates").resolve("byron-genesis.json"); srcShelleyGenesisFile = clusterFolder.resolve("genesis-templates").resolve("shelley-genesis.json"); - srcAlonzoGenesisFile = clusterFolder.resolve("genesis-templates").resolve("alonzo-genesis.json.conway"); - srcConwayGenesisFile = clusterFolder.resolve("genesis-templates").resolve("conway-genesis.json.conway"); + srcAlonzoGenesisFile = clusterFolder.resolve("genesis-templates").resolve("alonzo-genesis.json"); + srcConwayGenesisFile = clusterFolder.resolve("genesis-templates").resolve("conway-genesis.json"); } Path destByronGenesisFile = clusterFolder.resolve("node").resolve("genesis").resolve("byron-genesis.json"); diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java index de55d93..6a101c0 100644 --- a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java @@ -94,6 +94,14 @@ public class GenesisConfig { private BigInteger govActionDeposit = BigInteger.valueOf(1000000000); private BigInteger dRepDeposit = BigInteger.valueOf(2000000); private int dRepActivity = 20; + private BigDecimal minFeeRefScriptCostPerByte = BigDecimal.valueOf(44); + + private String constitutionUrl = "https://devkit.yaci.xyz/constitution.json"; + private String constitutionDataHash = "f89cc2469ce31c3dfda2f3e0b56c5c8b4ee4f0e5f66c30a3f12a95298b01179e"; + private String constitutionScript; + + private List ccMembers = new ArrayList<>(); + private float ccThreshold = 0f; private boolean disableFaucet = false; private boolean disableShelleyInitialFunds = false; @@ -310,6 +318,16 @@ public Map getConfigMap() { map.put("govActionDeposit", govActionDeposit); map.put("dRepDeposit", dRepDeposit); map.put("dRepActivity", dRepActivity); + map.put("minFeeRefScriptCostPerByte", minFeeRefScriptCostPerByte); + map.put("constitutionUrl", constitutionUrl); + map.put("constitutionDataHash", constitutionDataHash); + if (constitutionScript != null) + map.put("constitutionScript", constitutionScript); + + if (ccMembers != null && ccMembers.size() > 0) + ccMembers.getLast().setLast(true); + map.put("ccMembers", ccMembers); + map.put("ccThreshold", ccThreshold); map.put("initialFunds", initialFundsList); @@ -387,6 +405,12 @@ public GenesisConfig copy() { genesisConfig.setGovActionDeposit(govActionDeposit); genesisConfig.setDRepDeposit(dRepDeposit); genesisConfig.setDRepActivity(dRepActivity); + genesisConfig.setMinFeeRefScriptCostPerByte(minFeeRefScriptCostPerByte); + genesisConfig.setConstitutionUrl(constitutionUrl); + genesisConfig.setConstitutionDataHash(constitutionDataHash); + genesisConfig.setConstitutionScript(constitutionScript); + genesisConfig.setCcMembers(ccMembers); + genesisConfig.setCcThreshold(ccThreshold); genesisConfig.setFaucets(faucets); genesisConfig.setInitialFunds(initialFunds); @@ -443,4 +467,14 @@ public record GenesisDeleg(String delegator, String delegate, String vrf, boolea public record NonAvvmBalances(String address, String balance, boolean last) {} public record InitialAddress(String address, BigInteger balance, boolean staked, boolean last) {} + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class CCMember { + String hash; + int term; + boolean last; + } } diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json index 8ca9cfd..7cdcb45 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json @@ -24,7 +24,7 @@ "govActionDeposit": {{govActionDeposit}}, "dRepDeposit": {{dRepDeposit}}, "dRepActivity": {{dRepActivity}}, - "minFeeRefScriptCostPerByte": 44, + "minFeeRefScriptCostPerByte": {{minFeeRefScriptCostPerByte}}, "plutusV3CostModel": [ 205665, 812, @@ -262,13 +262,18 @@ ], "constitution": { "anchor": { - "url": "https://devkit.yaci.xyz/constitution.txt", - "dataHash": "f89cc2469ce31c3dfda2f3e0b56c5c8b4ee4f0e5f66c30a3f12a95298b01179e" - } + "url": "{{constitutionUrl}}", + "dataHash": "{{constitutionDataHash}}" + }{{#constitutionScript}}, + "script": "{{.}}" + {{/constitutionScript}} }, "committee": { "members": { + {{#ccMembers}} + "{{hash}}": {{term}}{{^last}},{{/last}} + {{/ccMembers}} }, - "threshold": 0 + "threshold": {{ccThreshold}} } } diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json.conway b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json.conway deleted file mode 100644 index 3066d6c..0000000 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/conway-genesis.json.conway +++ /dev/null @@ -1,274 +0,0 @@ -{ - "poolVotingThresholds": { - "committeeNormal": {{pvtCommitteeNormal}}, - "committeeNoConfidence": {{pvtCommitteeNoConfidence}}, - "hardForkInitiation": {{pvtHardForkInitiation}}, - "motionNoConfidence": {{pvtMotionNoConfidence}}, - "ppSecurityGroup": {{pvtPPSecurityGroup}} - }, - "dRepVotingThresholds": { - "motionNoConfidence": {{dvtMotionNoConfidence}}, - "committeeNormal": {{dvtCommitteeNormal}}, - "committeeNoConfidence": {{dvtCommitteeNoConfidence}}, - "updateToConstitution": {{dvtUpdateToConstitution}}, - "hardForkInitiation": {{dvtHardForkInitiation}}, - "ppNetworkGroup": {{dvtPPNetworkGroup}}, - "ppEconomicGroup": {{dvtPPEconomicGroup}}, - "ppTechnicalGroup": {{dvtPPTechnicalGroup}}, - "ppGovGroup": {{dvtPPGovGroup}}, - "treasuryWithdrawal": {{dvtTreasuryWithdrawal}} - }, - "committeeMinSize": {{committeeMinSize}}, - "committeeMaxTermLength": {{committeeMaxTermLength}}, - "govActionLifetime": {{govActionLifetime}}, - "govActionDeposit": {{govActionDeposit}}, - "dRepDeposit": {{dRepDeposit}}, - "dRepActivity": {{dRepActivity}}, - "minFeeRefScriptCostPerByte": 44, - "plutusV3CostModel": [ - 205665, - 812, - 1, - 1, - 1000, - 571, - 0, - 1, - 1000, - 24177, - 4, - 1, - 1000, - 32, - 117366, - 10475, - 4, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 23000, - 100, - 100, - 100, - 23000, - 100, - 19537, - 32, - 175354, - 32, - 46417, - 4, - 221973, - 511, - 0, - 1, - 89141, - 32, - 497525, - 14068, - 4, - 2, - 196500, - 453240, - 220, - 0, - 1, - 1, - 1000, - 28662, - 4, - 2, - 245000, - 216773, - 62, - 1, - 1060367, - 12586, - 1, - 208512, - 421, - 1, - 187000, - 1000, - 52998, - 1, - 80436, - 32, - 43249, - 32, - 1000, - 32, - 80556, - 1, - 57667, - 4, - 1000, - 10, - 197145, - 156, - 1, - 197145, - 156, - 1, - 204924, - 473, - 1, - 208896, - 511, - 1, - 52467, - 32, - 64832, - 32, - 65493, - 32, - 22558, - 32, - 16563, - 32, - 76511, - 32, - 196500, - 453240, - 220, - 0, - 1, - 1, - 69522, - 11687, - 0, - 1, - 60091, - 32, - 196500, - 453240, - 220, - 0, - 1, - 1, - 196500, - 453240, - 220, - 0, - 1, - 1, - 1159724, - 392670, - 0, - 2, - 806990, - 30482, - 4, - 1927926, - 82523, - 4, - 265318, - 0, - 4, - 0, - 85931, - 32, - 205665, - 812, - 1, - 1, - 41182, - 32, - 212342, - 32, - 31220, - 32, - 32696, - 32, - 43357, - 32, - 32247, - 32, - 38314, - 32, - 35190005, - 10, - 57996947, - 18975, - 10, - 39121781, - 32260, - 10, - 23000, - 100, - 23000, - 100, - 832808, - 18, - 3209094, - 6, - 331451, - 1, - 65990684, - 23097, - 18, - 114242, - 18, - 94393407, - 87060, - 18, - 16420089, - 18, - 2145798, - 36, - 3795345, - 12, - 889023, - 1, - 204237282, - 23271, - 36, - 129165, - 36, - 189977790, - 85902, - 36, - 33012864, - 36, - 388443360, - 1, - 401885761, - 72, - 2331379, - 72, - 1927926, - 82523, - 4, - 117366, - 10475, - 4, - 1292075, - 24469, - 74, - 0, - 1, - 936157, - 49601, - 237, - 0, - 1 - ], - "constitution": { - "anchor": { - "url": "https://devkit.yaci.xyz/constitution.txt", - "dataHash": "f89cc2469ce31c3dfda2f3e0b56c5c8b4ee4f0e5f66c30a3f12a95298b01179e" - } - }, - "committee": { - "members": { - }, - "threshold": 0 - } -} diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/spec/conway.json b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/spec/conway.json index 5f1de84..7b1a85c 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/spec/conway.json +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-templates/spec/conway.json @@ -24,6 +24,7 @@ "govActionDeposit": 1000000000, "dRepDeposit": 2000000, "dRepActivity": 20, + "minFeeRefScriptCostPerByte": 44, "constitution": { "anchor": { "url": "", @@ -33,6 +34,241 @@ "committee": { "members": { }, - "quorum": 0 - } + "threshold": 0 + }, + "plutusV3CostModel": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35190005, + 10, + 57996947, + 18975, + 10, + 39121781, + 32260, + 10, + 23000, + 100, + 23000, + 100, + 832808, + 18, + 3209094, + 6, + 331451, + 1, + 65990684, + 23097, + 18, + 114242, + 18, + 94393407, + 87060, + 18, + 16420089, + 18, + 2145798, + 36, + 3795345, + 12, + 889023, + 1, + 204237282, + 23271, + 36, + 129165, + 36, + 189977790, + 85902, + 36, + 33012864, + 36, + 388443360, + 1, + 401885761, + 72, + 2331379, + 72, + 1927926, + 82523, + 4, + 117366, + 10475, + 4, + 1292075, + 24469, + 74, + 0, + 1, + 936157, + 49601, + 237, + 0, + 1 + ] } From 536e1d5faa09efe1962fc48dbc29c163f071d1c2 Mon Sep 17 00:00:00 2001 From: Satya Date: Fri, 28 Jun 2024 23:58:43 +0800 Subject: [PATCH 3/5] fix: Process error message was not shown --- .../peer/PoolKeyGeneratorService.java | 99 +++++++++++-------- .../localcluster/privnet/PrivNetService.java | 69 ++++++++----- .../localcluster/socat/SocatService.java | 7 ++ .../cardano/yacicli/util/ProcessUtil.java | 52 ++++++++++ .../templates/devnet/gen-pool-cert.sh | 4 + .../templates/devnet/gen-pool-keys.sh | 4 + .../genesis-create-template.sh | 4 + .../localcluster/templates/devnet/kupo.sh | 4 + .../localcluster/templates/devnet/ogmios.sh | 4 + .../templates/devnet/pool-registration.sh | 4 + .../localcluster/templates/devnet/socat.sh | 4 + .../templates/devnet/submit-api.sh | 4 + 12 files changed, 193 insertions(+), 66 deletions(-) create mode 100644 applications/cli/src/main/java/com/bloxbean/cardano/yacicli/util/ProcessUtil.java diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/peer/PoolKeyGeneratorService.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/peer/PoolKeyGeneratorService.java index a2a1390..e7acfd7 100644 --- a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/peer/PoolKeyGeneratorService.java +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/peer/PoolKeyGeneratorService.java @@ -6,7 +6,7 @@ import com.bloxbean.cardano.yaci.core.util.HexUtil; import com.bloxbean.cardano.yacicli.commands.localcluster.ClusterConfig; import com.bloxbean.cardano.yacicli.commands.localcluster.ClusterInfo; -import com.bloxbean.cardano.yacicli.util.ProcessStream; +import com.bloxbean.cardano.yacicli.util.ProcessUtil; import com.bloxbean.cardano.yacicli.util.TemplateEngine; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -22,8 +22,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; import java.util.function.Consumer; import static com.bloxbean.cardano.yacicli.util.ConsoleWriter.*; @@ -54,13 +52,13 @@ public void updatePoolGenScript(Path destPath, ClusterInfo clusterInfo) throws I } @SneakyThrows - public void generatePoolKeys(String nodeName, boolean overwrite, Consumer writer) { + public boolean generatePoolKeys(String nodeName, boolean overwrite, Consumer writer) { Path clusterPoolKeysFolder = clusterConfig.getPoolKeysFolder(nodeName); if (clusterPoolKeysFolder.toFile().exists() && !overwrite) { writer.accept(warn("Found existing pool keys for this node. Existing keys will be used." + "Please use --overwrite-pool-keys option to overwrite pool keys")); - return; + return true; } if (!clusterPoolKeysFolder.toFile().exists()) { @@ -70,23 +68,30 @@ public void generatePoolKeys(String nodeName, boolean overwrite, Consumer { - if (line != null && !line.isEmpty()) - writer.accept(successLabel("Pool Keys", line)); - }); - Future future = Executors.newSingleThreadExecutor().submit(processStream); - future.get(); + + return ProcessUtil.executeAndFinish(builder, "Pool Keys", writer); +// ProcessBuilder builder = new ProcessBuilder(); +// builder.command("sh", genKeyFile); +// +// builder.directory(clusterPoolKeysFolder.toFile()); +// Process process = builder.start(); +// +// ProcessStream processStream = +// new ProcessStream(process.getInputStream(), line -> { +// if (line != null && !line.isEmpty()) +// writer.accept(successLabel("Pool Keys", line)); +// }); +// Future future = Executors.newSingleThreadExecutor().submit(processStream); +// future.get(); } catch (Exception e) { log.info(e.getMessage(), e); } + return false; //Generate Cold Keys and a Cold Counter @@ -119,7 +124,7 @@ public void generateOperationalCert(String adminUrl, String nodeName, Consumer writer) throws IOException { + public boolean generateOperationalCert(String nodeName, int kesPeriod, Consumer writer) throws IOException { Path clusterPoolKeysFolder = clusterConfig.getPoolKeysFolder(nodeName); if (!clusterPoolKeysFolder.toFile().exists()) { @@ -127,29 +132,34 @@ public void generateOperationalCert(String nodeName, int kesPeriod, Consumer { -// //TODO -- Add logs - if (line != null && !line.isEmpty()) - writer.accept(info(line)); - }); - Future future = Executors.newSingleThreadExecutor().submit(processStream); - future.get(); + + return ProcessUtil.executeAndFinish(builder, "Operational Certificate", writer); +// Process process = builder.start(); +// +// ProcessStream processStream = +// new ProcessStream(process.getInputStream(), line -> { +//// //TODO -- Add logs +// if (line != null && !line.isEmpty()) +// writer.accept(info(line)); +// }); +// Future future = Executors.newSingleThreadExecutor().submit(processStream); +// future.get(); } catch (Exception e) { log.info(e.getMessage(), e); } + + return false; } @SneakyThrows - public void registerPool(String nodeName, PoolConfig poolConfig, Consumer writer) { + public boolean registerPool(String nodeName, PoolConfig poolConfig, Consumer writer) { Path clusterPoolKeysFolder = clusterConfig.getPoolKeysFolder(nodeName); try { @@ -162,26 +172,29 @@ public void registerPool(String nodeName, PoolConfig poolConfig, Consumer { -// //TODO -- Add logs - if (line != null && !line.isEmpty()) - writer.accept(successLabel("Pool Registration", line)); - }); - ProcessStream errorProcessStream = - new ProcessStream(process.getErrorStream(), line -> { -// //TODO -- Add logs - writer.accept(error(line)); - }); - Future future = Executors.newSingleThreadExecutor().submit(processStream, errorProcessStream); - future.get(); + return ProcessUtil.executeAndFinish(builder, "Pool Registration", writer); + +// ProcessStream processStream = +// new ProcessStream(process.getInputStream(), line -> { +//// //TODO -- Add logs +// if (line != null && !line.isEmpty()) +// writer.accept(successLabel("Pool Registration", line)); +// }); +// ProcessStream errorProcessStream = +// new ProcessStream(process.getErrorStream(), line -> { +//// //TODO -- Add logs +// writer.accept(error(line)); +// }); +// Future future = Executors.newSingleThreadExecutor().submit(processStream, errorProcessStream); +// future.get(); } catch (Exception e) { log.info(e.getMessage(), e); } + + return false; } @SneakyThrows diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/privnet/PrivNetService.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/privnet/PrivNetService.java index 621cdab..d515b1d 100644 --- a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/privnet/PrivNetService.java +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/privnet/PrivNetService.java @@ -10,7 +10,7 @@ import com.bloxbean.cardano.yacicli.commands.localcluster.peer.PoolKeyGeneratorService; import com.bloxbean.cardano.yacicli.commands.localcluster.profiles.GenesisProfile; import com.bloxbean.cardano.yacicli.util.AdvancedTemplateEngine; -import com.bloxbean.cardano.yacicli.util.ProcessStream; +import com.bloxbean.cardano.yacicli.util.ProcessUtil; import com.bloxbean.cardano.yacicli.util.TemplateEngine; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -23,8 +23,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.*; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -52,8 +50,10 @@ public class PrivNetService { public void setupNewKeysAndDefaultPool(Path clusterPath, String clusterName, ClusterInfo clusterInfo, GenesisConfig genesisConfig, Double activeCoeff, Consumer writer) throws IOException { updateGenesisScript(clusterPath, clusterName, clusterInfo, clusterInfo.getSlotLength(), activeCoeff, clusterInfo.getEpochLength(), writer); - runGenesisScript(clusterPath, clusterName, true, writer); - writer.accept(success("New genesis keys generated successfully")); + boolean status = runGenesisScript(clusterPath, clusterName, true, writer); + if (status) { + writer.accept(success("New genesis keys generated successfully")); + } updateByronAndShelleyDelegationKeys(clusterPath, clusterName, clusterInfo, writer); @@ -91,13 +91,13 @@ private void updateGenesisScript(Path destPath, String clusterName, ClusterInfo } } - public void runGenesisScript(Path clusterPah, String clusterName, boolean overwrite, Consumer writer) { + public boolean runGenesisScript(Path clusterPah, String clusterName, boolean overwrite, Consumer writer) { try { Path genCreateScript = clusterPah.resolve("genesis-scripts").resolve("genesis-create.sh"); if (!genCreateScript.toFile().exists()) { writer.accept(error("Genesis script file not found : %s", genCreateScript.toFile().getAbsolutePath())); - return; + return false; } Path clusterGenesisKeysFolder = clusterConfig.getGenesisKeysFolder(clusterName); @@ -105,7 +105,7 @@ public void runGenesisScript(Path clusterPah, String clusterName, boolean overwr if (clusterGenesisKeysFolder.toFile().exists() && !overwrite) { writer.accept(warn("Found existing genesis keys for this node. Existing keys will be used." + "Please use --overwrite-genesis-keys option to overwrite genesis keys")); - return; + return true; } FileUtils.deleteDirectory(clusterGenesisKeysFolder.toFile()); @@ -120,24 +120,47 @@ public void runGenesisScript(Path clusterPah, String clusterName, boolean overwr builder.command("sh", genCreateScriptFile); builder.directory(genCreateScript.getParent().toFile()); - Process process = builder.start(); - - ProcessStream processStream = - new ProcessStream(process.getInputStream(), line -> { - if (line != null && !line.isEmpty()) - writer.accept(successLabel("Genesis Keys", line)); - }); - - ProcessStream errorProcessStream = - new ProcessStream(process.getErrorStream(), line -> { - if (line != null && !line.isEmpty()) - writer.accept(error("Genesis Keys", line)); - }); - Future future = Executors.newSingleThreadExecutor().submit(processStream, errorProcessStream); - future.get(); + + return ProcessUtil.executeAndFinish(builder, "Genesis Keys", writer); +// String genCreateScriptFile = genCreateScript.toFile().getAbsolutePath(); +// +// ProcessBuilder builder = new ProcessBuilder(); +// builder.command("sh", genCreateScriptFile); +// +// builder.directory(genCreateScript.getParent().toFile()); +// Process process = builder.start(); +// +// ExecutorService executor = Executors.newSingleThreadExecutor(); +// ProcessStream processStream = +// new ProcessStream(process.getInputStream(), line -> { +// if (line != null && !line.isEmpty()) +// writer.accept(successLabel("Genesis Keys", line)); +// }); +// +// ProcessStream errorProcessStream = +// new ProcessStream(process.getErrorStream(), line -> { +// if (line != null && !line.isEmpty()) +// writer.accept(error("Genesis Keys %s", line)); +// }); +// +// Future inputFuture = executor.submit(processStream); +// Future errorFuture = executor.submit(errorProcessStream); +// +// inputFuture.get(); +// errorFuture.get(); +// +// // Wait for process to complete +// int exitCode = process.waitFor(); +// System.out.println("Process exited with code: " + exitCode); +//// Future future = executor.submit(processStream, errorProcessStream); +//// future.get(); +// +// executor.shutdown(); } catch (Exception e) { log.info(e.getMessage(), e); } + + return false; } private void updateByronAndShelleyDelegationKeys(Path destPath, String clusterName, ClusterInfo clusterInfo, Consumer writer) throws IOException { diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/socat/SocatService.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/socat/SocatService.java index 39211af..d07e08b 100644 --- a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/socat/SocatService.java +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/socat/SocatService.java @@ -39,6 +39,9 @@ public class SocatService { @Value("${socat.enabled:true}") private boolean enableSocat; + @Value("${is.docker:false}") + private boolean isDocker; + @Autowired TemplateEngine templateEngine; @@ -50,6 +53,10 @@ public void handleClusterStarted(ClusterStarted clusterStarted) { if (!enableSocat) return; + if (!isDocker) { + return; + } + if (!clusterStarted.getClusterName().equals("default")) { writeLn("Socat is only supported for 'default' cluster"); return; diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/util/ProcessUtil.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/util/ProcessUtil.java new file mode 100644 index 0000000..75d2777 --- /dev/null +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/util/ProcessUtil.java @@ -0,0 +1,52 @@ +package com.bloxbean.cardano.yacicli.util; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.function.Consumer; + +import static com.bloxbean.cardano.yacicli.util.ConsoleWriter.error; +import static com.bloxbean.cardano.yacicli.util.ConsoleWriter.successLabel; + +public class ProcessUtil { + + public static boolean executeAndFinish(ProcessBuilder processBuilder, String scriptPurpose, Consumer writer) { + ExecutorService executor = Executors.newCachedThreadPool(); + try { + Process process = processBuilder.start(); + + ProcessStream processStream = + new ProcessStream(process.getInputStream(), line -> { + if (line != null && !line.isEmpty()) + writer.accept(successLabel(scriptPurpose, " %s", line)); + }); + + ProcessStream errorProcessStream = + new ProcessStream(process.getErrorStream(), line -> { + if (line != null && !line.isEmpty()) + writer.accept(error(scriptPurpose + " %s", line)); + }); + + Future inputFuture = executor.submit(processStream); + Future errorFuture = executor.submit(errorProcessStream); + + inputFuture.get(); + errorFuture.get(); + + // Wait for process to complete + int exitCode = process.waitFor(); + + if (exitCode == 0) + return true; + else + return false; + } catch (Exception e) { + e.printStackTrace(); + } finally { + executor.shutdown(); + } + + return false; + } + +} diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/gen-pool-cert.sh b/applications/cli/src/main/resources/localcluster/templates/devnet/gen-pool-cert.sh index d0cf8e3..1588502 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/gen-pool-cert.sh +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/gen-pool-cert.sh @@ -1,3 +1,7 @@ +#!/bin/bash + +set -e + #Generate Cold Keys and a Cold_counter: echo "\nGenerating pool certificate" ${BIN_FOLDER}/cardano-cli node issue-op-cert \ diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/gen-pool-keys.sh b/applications/cli/src/main/resources/localcluster/templates/devnet/gen-pool-keys.sh index 74fd468..b8fb705 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/gen-pool-keys.sh +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/gen-pool-keys.sh @@ -1,3 +1,7 @@ +#!/bin/bash + +set -e + #Generate Pool owner payment and Stake Keys echo "\nGenerating payment and stake keys for pool" ${BIN_FOLDER}/cardano-cli address key-gen \ diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-scripts/genesis-create-template.sh b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-scripts/genesis-create-template.sh index 283cea2..ae68713 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-scripts/genesis-create-template.sh +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/genesis-scripts/genesis-create-template.sh @@ -1,3 +1,7 @@ +#!/bin/bash + +set -e + {{BIN_FOLDER}}/cardano-cli genesis create-cardano \ --genesis-dir {{genesisKeysHome}} \ --gen-genesis-keys {{nGenesisKeys}} \ diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/kupo.sh b/applications/cli/src/main/resources/localcluster/templates/devnet/kupo.sh index 5394f87..37d1102 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/kupo.sh +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/kupo.sh @@ -1,3 +1,7 @@ +#!/bin/bash + +set -e + ${KUPO_BIN} \ --ogmios-host 0.0.0.0 \ --ogmios-port ${OGMIOS_PORT} \ diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/ogmios.sh b/applications/cli/src/main/resources/localcluster/templates/devnet/ogmios.sh index 5e9260a..780252f 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/ogmios.sh +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/ogmios.sh @@ -1 +1,5 @@ +#!/bin/bash + +set -e + ${OGMIOS_BIN} --node-socket node/node.sock --node-config node/configuration.yaml --host 0.0.0.0 --port ${OGMIOS_PORT} diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/pool-registration.sh b/applications/cli/src/main/resources/localcluster/templates/devnet/pool-registration.sh index 9b23d2a..d30cce1 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/pool-registration.sh +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/pool-registration.sh @@ -1,3 +1,7 @@ +#!/bin/bash + +set -e + #Generate pool registration certificate #Parameters: # $1 pledege: The amount of ADA that will be pledged to the pool diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/socat.sh b/applications/cli/src/main/resources/localcluster/templates/devnet/socat.sh index 1a9787e..6579004 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/socat.sh +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/socat.sh @@ -1 +1,5 @@ +#!/bin/bash + +set -e + socat TCP-LISTEN:${SOCAT_PORT},reuseaddr,fork UNIX-CONNECT:node/node.sock diff --git a/applications/cli/src/main/resources/localcluster/templates/devnet/submit-api.sh b/applications/cli/src/main/resources/localcluster/templates/devnet/submit-api.sh index aba0218..edc3bee 100644 --- a/applications/cli/src/main/resources/localcluster/templates/devnet/submit-api.sh +++ b/applications/cli/src/main/resources/localcluster/templates/devnet/submit-api.sh @@ -1 +1,5 @@ +#!/bin/bash + +set -e + ${BIN_FOLDER}/cardano-submit-api --config submit-api-config.yaml --testnet-magic ${PROTOCOL_MAGIC} --socket-path node/node.sock --port ${SUBMIT_API_PORT} --listen-address 0.0.0.0 From aef33ed87bdabce28443bbaa741328514ffc6889 Mon Sep 17 00:00:00 2001 From: Satya Date: Sat, 29 Jun 2024 14:08:57 +0800 Subject: [PATCH 4/5] fix: Set bootstrap node's era --- .../cardano/yacicli/commands/localcluster/peer/PeerService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/peer/PeerService.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/peer/PeerService.java index 5ccfed3..b0ad2af 100644 --- a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/peer/PeerService.java +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/peer/PeerService.java @@ -121,7 +121,7 @@ public boolean addPeer(String adminUrl, String nodeName, int portShift, boolean .p2pEnabled(true) .isBlockProducer(isBlockProducer) .adminNodeUrl(adminUrl) - .era(Era.Babbage) //TODO: Need to get from admin node + .era(bootstrapClusterInfo.getEra()) .build(); clusterInfo.setOgmiosPort(clusterInfo.getOgmiosPort() + portShift); From 464f8186f0a76d142b8134fed91669d88029dcb2 Mon Sep 17 00:00:00 2001 From: Satya Date: Sat, 29 Jun 2024 15:01:54 +0800 Subject: [PATCH 5/5] chore: Set min protocol version to 10 for Conway era --- .../yacicli/commands/localcluster/ClusterService.java | 6 ++++++ .../yacicli/commands/localcluster/config/GenesisConfig.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/ClusterService.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/ClusterService.java index 3dea7a9..8ccd96e 100644 --- a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/ClusterService.java +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/ClusterService.java @@ -308,6 +308,12 @@ private void updateGenesis(Path clusterFolder, String clusterName, ClusterInfo c values.put("activeSlotsCoeff", String.valueOf(activeSlotsCoeff)); values.put("epochLength", String.valueOf(epochLength)); + //Check if protocol version should be minimun 10 and it's conway era + if (era == Era.Conway && genesisConfig.getProtocolMajorVer() < 10) { + values.put("protocolMajorVer", 10); + values.put("protocolMinorVer", 0); + } + //Update Genesis files try { templateEngineHelper.replaceValues(srcByronGenesisFile, destByronGenesisFile, values); diff --git a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java index 6a101c0..8649930 100644 --- a/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java +++ b/applications/cli/src/main/java/com/bloxbean/cardano/yacicli/commands/localcluster/config/GenesisConfig.java @@ -41,7 +41,7 @@ public class GenesisConfig { private BigInteger minUTxOValue = BigInteger.valueOf(1000000); private int nOpt = 100; private BigInteger poolDeposit = BigInteger.valueOf(500000000); - private int protocolMajorVer = 10; + private int protocolMajorVer = 8; private int protocolMinorVer = 0; private float monetaryExpansionRate = 0.003f; private float treasuryGrowthRate = 0.20f;