Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Koios] minFeeRefScriptCostPerByte is missing in Koios backend #425 #427

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading