From 857788731a11191edb10a79a31fe095445e3a455 Mon Sep 17 00:00:00 2001 From: Thomas Kammerlocher Date: Tue, 17 Dec 2024 10:12:34 +0100 Subject: [PATCH] fix: fixed a mapping issue which left the protocolversion at null (#260) * fix: fixed a mapping issue which left the protocolversion at null * chore: spotless * chore: added n2c-socket to .env.dockerfile --- .../rosetta/api/block/model/domain/ProtocolParams.java | 3 ++- .../rosetta/common/mapper/ProtocolParamsMapper.java | 4 +--- .../api/construction/mapper/ConstructionMapperTest.java | 8 +++----- .../rosetta/common/mapper/ProtocolParamsMapperTest.java | 3 +-- .../mapper/ProtocolParamsToRosettaProtocolParamsTest.java | 7 ++----- docker-compose-node.yaml | 2 -- docker/dockerfiles/mithril/Dockerfile | 8 +++++++- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/ProtocolParams.java b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/ProtocolParams.java index 2c553399..c9516c02 100644 --- a/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/ProtocolParams.java +++ b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/ProtocolParams.java @@ -27,7 +27,8 @@ public class ProtocolParams { private Integer maxTxSize; //3 private BigInteger keyDeposit; //5 private BigInteger poolDeposit; //6 - private ProtocolVersion protocolVersion; //14 + private Integer protocolMajorVer; + private Integer protocolMinorVer; private BigInteger minPoolCost; //16 private BigInteger adaPerUtxoByte; //17 diff --git a/api/src/main/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapper.java b/api/src/main/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapper.java index d311e59a..e611eb80 100644 --- a/api/src/main/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapper.java +++ b/api/src/main/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapper.java @@ -11,13 +11,11 @@ @Mapper(config = BaseMapper.class) public interface ProtocolParamsMapper { - @Mapping(target = "protocolVersion.major", source = "protocolMajorVer") - @Mapping(target = "protocolVersion.minor", source = "protocolMinorVer") ProtocolParams mapProtocolParamsToEntity(ProtocolParamsEntity entity); @Mapping(target = "coinsPerUtxoSize", source = "adaPerUtxoByte") @Mapping(target = "minFeeCoefficient", source = "minFeeA") @Mapping(target = "minFeeConstant", source = "minFeeB") - @Mapping(target = "protocol", source = "protocolVersion.major") + @Mapping(target = "protocol", source = "protocolMajorVer") ProtocolParameters mapToProtocolParameters(ProtocolParams model); } diff --git a/api/src/test/java/org/cardanofoundation/rosetta/api/construction/mapper/ConstructionMapperTest.java b/api/src/test/java/org/cardanofoundation/rosetta/api/construction/mapper/ConstructionMapperTest.java index d5813db1..f07b2663 100644 --- a/api/src/test/java/org/cardanofoundation/rosetta/api/construction/mapper/ConstructionMapperTest.java +++ b/api/src/test/java/org/cardanofoundation/rosetta/api/construction/mapper/ConstructionMapperTest.java @@ -17,7 +17,6 @@ import org.junit.jupiter.api.Test; import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams; -import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams.ProtocolVersion; import org.cardanofoundation.rosetta.common.mapper.ProtocolParamsMapper; import org.cardanofoundation.rosetta.common.mapper.ProtocolParamsMapperImpl; import org.cardanofoundation.rosetta.common.model.cardano.crypto.Signatures; @@ -73,7 +72,7 @@ void mapToMetadataResponse_protocolParamsNull_test() { void mapToMetadataResponse_protocolParamsSomeFieldsNull_test() { ProtocolParams protocolParams = getProtocolParams(); protocolParams.setKeyDeposit(null); - protocolParams.setProtocolVersion(null); + protocolParams.setProtocolMajorVer(0); ConstructionMetadataResponse actual = constructionMapper.mapToMetadataResponse( protocolParams, 1L, 100L); @@ -123,7 +122,7 @@ private ProtocolParams getProtocolParams() { .maxTxSize(2) .keyDeposit(BigInteger.TWO) .poolDeposit(BigInteger.TEN) - .protocolVersion(new ProtocolVersion()) + .protocolMajorVer(0) .minPoolCost(BigInteger.ONE) .adaPerUtxoByte(BigInteger.ONE) .maxValSize(3L) @@ -163,8 +162,7 @@ private void assertProtocolParameters(ProtocolParameters actual, ProtocolParams assertThat(actual.getPoolDeposit()) .isEqualTo(Objects.toString(expected.getPoolDeposit(), null)); assertThat(actual.getProtocol()) - .isEqualTo(expected.getProtocolVersion() != null ? expected.getProtocolVersion() - .getMajor() : null); + .isEqualTo(expected.getProtocolMajorVer() != null ? expected.getProtocolMajorVer() : null); } private void assertSignature(Signatures actual, Signature expected) { diff --git a/api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapperTest.java b/api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapperTest.java index a95bf49e..27a4caa0 100644 --- a/api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapperTest.java +++ b/api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsMapperTest.java @@ -62,8 +62,7 @@ private void assertProtocolParameters(ProtocolParams into, ProtocolParamsEntity assertThat(into.getMinFeeB()).isEqualTo(param.getMinFeeB()); assertThat(into.getMinPoolCost()).isEqualTo(param.getMinPoolCost()); assertThat(into.getPoolDeposit()).isEqualTo(param.getPoolDeposit()); - assertThat(into.getProtocolVersion().getMajor()).isEqualTo(param.getProtocolMajorVer()); - assertThat(into.getProtocolVersion().getMinor()).isEqualTo(param.getProtocolMinorVer()); + assertThat(into.getProtocolMajorVer()).isEqualTo(param.getProtocolMajorVer()); assertThat(into.getMaxValSize()).isEqualTo(param.getMaxValSize()); assertThat(into.getMaxCollateralInputs()).isEqualTo(param.getMaxCollateralInputs()); } diff --git a/api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsToRosettaProtocolParamsTest.java b/api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsToRosettaProtocolParamsTest.java index d0b32675..0ae9d8ab 100644 --- a/api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsToRosettaProtocolParamsTest.java +++ b/api/src/test/java/org/cardanofoundation/rosetta/common/mapper/ProtocolParamsToRosettaProtocolParamsTest.java @@ -9,7 +9,6 @@ import org.cardanofoundation.rosetta.api.BaseMapperSetup; import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams; -import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams.ProtocolVersion; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -32,13 +31,11 @@ void fromDomainObjectToRosettaTest() { assertEquals(protocolParams.getMinFeeB(), protocolParameters.getMinFeeConstant()); assertEquals(protocolParams.getMinPoolCost().toString(), protocolParameters.getMinPoolCost()); assertEquals(protocolParams.getPoolDeposit().toString(), protocolParameters.getPoolDeposit()); - assertEquals(protocolParams.getProtocolVersion().getMajor(), protocolParameters.getProtocol()); + assertEquals(protocolParams.getProtocolMajorVer(), protocolParameters.getProtocol()); } private ProtocolParams newProtocolParams() { - ProtocolVersion protocolVersion = new ProtocolVersion(); - protocolVersion.setMajor(10); return ProtocolParams.builder() .adaPerUtxoByte(BigInteger.valueOf(1)) .maxTxSize(2) @@ -49,7 +46,7 @@ private ProtocolParams newProtocolParams() { .minFeeB(7) .minPoolCost(BigInteger.valueOf(8)) .poolDeposit(BigInteger.valueOf(9)) - .protocolVersion(protocolVersion) + .protocolMajorVer(10) .build(); } diff --git a/docker-compose-node.yaml b/docker-compose-node.yaml index f4658e87..b9a5d965 100644 --- a/docker-compose-node.yaml +++ b/docker-compose-node.yaml @@ -12,8 +12,6 @@ services: volumes: - ${CARDANO_NODE_DIR}:/node cardano-node: - build: - context: ./docker/dockerfiles/node image: ghcr.io/intersectmbo/cardano-node:${CARDANO_NODE_VERSION} environment: - NETWORK=${NETWORK} diff --git a/docker/dockerfiles/mithril/Dockerfile b/docker/dockerfiles/mithril/Dockerfile index 62456e70..2a9f7f50 100644 --- a/docker/dockerfiles/mithril/Dockerfile +++ b/docker/dockerfiles/mithril/Dockerfile @@ -2,15 +2,21 @@ FROM ubuntu:22.04 AS cardano-builder WORKDIR /root/src +RUN apt update --fix-missing \ + && apt install -y --no-install-recommends curl ca-certificates \ + && apt-get clean + # Mithril setup ARG MITHRIL_VERSION=2445.0 # Install dependencies RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y \ + && export PATH="$HOME/.cargo/bin:$PATH" \ && apt update --fix-missing \ && apt install -y --no-install-recommends \ - build-essential m4 libssl-dev docker jq git cargo ca-certificates wget \ + build-essential m4 libssl-dev docker jq git \ && apt-get clean RUN git clone https://github.com/input-output-hk/mithril.git \ + && export PATH="$HOME/.cargo/bin:$PATH" \ && cd mithril \ && git checkout $MITHRIL_VERSION \ && cd mithril-client-cli \