Skip to content

Commit

Permalink
Merge pull request #427 from adabox-aio/master
Browse files Browse the repository at this point in the history
[Koios] minFeeRefScriptCostPerByte is missing in Koios backend #425
  • Loading branch information
satran004 authored Sep 7, 2024
2 parents be53e6b + 638191c commit 8b5b9a8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import rest.koios.client.backend.api.epoch.model.EpochParams;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -178,6 +179,42 @@ private Result<ProtocolParams> convertToProtocolParams(EpochParams epochParams)
if (epochParams.getCoinsPerUtxoSize() != null) {
protocolParams.setCoinsPerUtxoSize(epochParams.getCoinsPerUtxoSize());
}
if (epochParams.getDvtPPNetworkGroup() != null) {
protocolParams.setDvtPPNetworkGroup(epochParams.getDvtPPNetworkGroup());
}
if (epochParams.getDvtPPEconomicGroup() != null) {
protocolParams.setDvtPPEconomicGroup(epochParams.getDvtPPEconomicGroup());
}
if (epochParams.getDvtPPTechnicalGroup() != null) {
protocolParams.setDvtPPTechnicalGroup(epochParams.getDvtPPTechnicalGroup());
}
if (epochParams.getDvtPPGovGroup() != null) {
protocolParams.setDvtPPGovGroup(epochParams.getDvtPPGovGroup());
}
if (epochParams.getDvtTreasuryWithdrawal() != null) {
protocolParams.setDvtTreasuryWithdrawal(epochParams.getDvtTreasuryWithdrawal());
}
if (epochParams.getCommitteeMinSize() != null) {
protocolParams.setCommitteeMinSize(epochParams.getCommitteeMinSize());
}
if (epochParams.getCommitteeMaxTermLength() != null) {
protocolParams.setCommitteeMaxTermLength(epochParams.getCommitteeMaxTermLength());
}
if (epochParams.getGovActionLifetime() != null) {
protocolParams.setGovActionLifetime(epochParams.getGovActionLifetime());
}
if (epochParams.getGovActionDeposit() != null) {
protocolParams.setGovActionDeposit(new BigInteger(epochParams.getGovActionDeposit()));
}
if (epochParams.getDrepDeposit() != null) {
protocolParams.setDrepDeposit(new BigInteger(epochParams.getDrepDeposit()));
}
if (epochParams.getDrepActivity() != null) {
protocolParams.setDrepActivity(epochParams.getDrepActivity());
}
if (epochParams.getMinFeeRefScriptCostPerByte() != null) {
protocolParams.setMinFeeRefScriptCostPerByte(epochParams.getMinFeeRefScriptCostPerByte());
}
return Result.success("OK").withValue(protocolParams).code(200);
}

Expand All @@ -197,6 +234,8 @@ private Map<String, Map<String, Long>> convertToCostModels(JsonNode costModelsJs
Map<String, Long> plutusV1CostModelsMap = new HashMap<>();
final AtomicInteger plutusV2IndexHolder = new AtomicInteger();
Map<String, Long> plutusV2CostModelsMap = new HashMap<>();
final AtomicInteger plutusV3IndexHolder = new AtomicInteger();
Map<String, Long> plutusV3CostModelsMap = new HashMap<>();
result.forEach((key, value) -> {
if (key.equals("PlutusV1")) {
value.forEach(aLong -> {
Expand All @@ -211,6 +250,13 @@ private Map<String, Map<String, Long>> convertToCostModels(JsonNode costModelsJs
});
res.put(key, plutusV2CostModelsMap);
}
// else if (key.equals("PlutusV3")) {
// value.forEach(aLong -> {
// final int index = plutusV3IndexHolder.getAndIncrement();
// plutusV3CostModelsMap.put(PlutusOps.getOperations(3).get(index), aLong);
// });
// res.put(key, plutusV3CostModelsMap);
// } TODO Uncomment after adding V3_OPS
});
} catch (JsonProcessingException ignored) {}
return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void testGetProtocolParameters() throws ApiException {
System.out.println(JsonUtil.getPrettyJson(protocolParams));

assertThat(protocolParams, notNullValue());
assertThat(protocolParams.getMinUtxo(), is("34482"));
assertThat(protocolParams.getMinUtxo(), is("0"));
assertThat(protocolParams.getPoolDeposit(), is("500000000"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
import java.util.stream.Collectors;

public class PlutusOps {
private static ObjectMapper objectMapper = new ObjectMapper();

private static final ObjectMapper objectMapper = new ObjectMapper();
private static List<String> V1_OPS;
private static List<String> V2_OPS;

private static String PLUTUS_V1_COSTS = "{\n" +
private static final String PLUTUS_V1_COSTS = "{\n" +
" \"addInteger-cpu-arguments-intercept\": 205665,\n" +
" \"addInteger-cpu-arguments-slope\": 812,\n" +
" \"addInteger-memory-arguments-intercept\": 1,\n" +
Expand Down Expand Up @@ -183,7 +184,7 @@ public class PlutusOps {
" \"verifyEd25519Signature-memory-arguments\": 10\n" +
" }";

private static String PLUTUS_V2_COSTS = " {\n" +
private static final String PLUTUS_V2_COSTS = " {\n" +
" \"addInteger-cpu-arguments-intercept\": 205665,\n" +
" \"addInteger-cpu-arguments-slope\": 812,\n" +
" \"addInteger-memory-arguments-intercept\": 1,\n" +
Expand Down

0 comments on commit 8b5b9a8

Please sign in to comment.