diff --git a/.env.IntegrationTest b/.env.IntegrationTest index afc5e7427..92e070b61 100644 --- a/.env.IntegrationTest +++ b/.env.IntegrationTest @@ -29,7 +29,7 @@ CARDANO_NODE_PORT=3001 CARDANO_NODE_SUBMIT_HOST=yaci-cli NODE_SUBMIT_API_PORT=8090 CARDANO_NODE_VERSION=0.0.0 -CARDANO_NODE_DIR=/node +CARDANO_NODE_DIR=/Users/thkammer/Documents/dev/cardano/cardano-rosetta-java/node CARDANO_NODE_SOCKET_PATH=${CARDANO_NODE_DIR}/node.socket CARDANO_NODE_DB=${CARDANO_NODE_DIR}/db CARDANO_CONFIG=./config/${NETWORK} @@ -59,7 +59,7 @@ GENESIS_CONWAY_PATH=/config/conway-genesis.json INDEXER_DOCKER_IMAGE_TAG=main PRUNING_ENABLED=false -YACI_SPRING_PROFILES=postgres +YACI_SPRING_PROFILES=postgres,n2c-socat # database profiles: h2, h2-testData, postgres MEMPOOL_ENABLED=false @@ -67,6 +67,7 @@ MEMPOOL_ENABLED=false HOST_N2N_PORT=${CARDANO_NODE_PORT} HOST_SUBMIT_API_PORT=${NODE_SUBMIT_API_PORT} HOST_N2C_SOCAT_PORT=3333 +HOST_N2C_SOCAT_HOST=${CARDANO_NODE_HOST} HOST_STORE_API_PORT=8080 HOST_CLUSTER_API_PORT=10000 HOST_OGMIOS_PORT=1337 diff --git a/.env.docker-compose b/.env.docker-compose index 0129c2fb7..4250890c7 100644 --- a/.env.docker-compose +++ b/.env.docker-compose @@ -58,7 +58,7 @@ GENESIS_CONWAY_PATH=/config/conway-genesis.json INDEXER_DOCKER_IMAGE_TAG=main PRUNING_ENABLED=false -YACI_SPRING_PROFILES=postgres +YACI_SPRING_PROFILES=postgres,n2c-socket # database profiles: h2, h2-testData, postgres MEMPOOL_ENABLED=false diff --git a/.env.h2 b/.env.h2 index 19e5d8775..a8b43df72 100644 --- a/.env.h2 +++ b/.env.h2 @@ -41,7 +41,7 @@ GENESIS_CONWAY_PATH=./config/${NETWORK}/conway-genesis.json INDEXER_DOCKER_IMAGE_TAG=main PRUNING_ENABLED=false -YACI_SPRING_PROFILES=h2 +YACI_SPRING_PROFILES=h2,n2c-socket # database profiles: h2, h2-testData, postgres MEMPOOL_ENABLED=false diff --git a/README.md b/README.md index d8306c9fe..101ea328f 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ The default config is focused on mainnet. If you want to test this on other Card git clone https://github.com/cardano-foundation/cardano-rosetta-java cd cardano-rosetta-java docker build -t rosetta-java -f ./docker/Dockerfile . - docker run --name rosetta --env-file ./docker/.env.dockerfile -p 8082:8082 -d rosetta-java:latest + docker run --name rosetta -v {CUSTOM_MOUNT_PATH}:/node --env-file ./docker/.env.dockerfile -p 8082:8082 -d rosetta-java:latest ``` Detailed explanation can be found in the [Wiki](https://github.com/cardano-foundation/cardano-rosetta-java/wiki/3.-Getting-Started-with-Docker). 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 1642c2d6c..2c553399c 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 @@ -10,6 +10,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; @Data @NoArgsConstructor @@ -17,6 +19,7 @@ @Builder @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class ProtocolParams { private Integer minFeeA; //0 diff --git a/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/LocalProtocolParamsEntity.java b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/LocalProtocolParamsEntity.java new file mode 100644 index 000000000..8de0b2998 --- /dev/null +++ b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/LocalProtocolParamsEntity.java @@ -0,0 +1,39 @@ +package org.cardanofoundation.rosetta.api.block.model.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import io.hypersistence.utils.hibernate.type.json.JsonType; +import org.hibernate.annotations.Type; + +import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Entity +@Table(name = "local_epoch_param") +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class LocalProtocolParamsEntity { + @Id + private Long epoch; + + @Type(JsonType.class) + @Column(name = "params") + private ProtocolParams protocolParams; + +} diff --git a/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/repository/LocalProtocolParamsRepository.java b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/repository/LocalProtocolParamsRepository.java new file mode 100644 index 000000000..88409de5f --- /dev/null +++ b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/repository/LocalProtocolParamsRepository.java @@ -0,0 +1,17 @@ +package org.cardanofoundation.rosetta.api.block.model.repository; + +import java.util.Optional; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import org.cardanofoundation.rosetta.api.block.model.entity.LocalProtocolParamsEntity; + +public interface LocalProtocolParamsRepository extends JpaRepository { + + @Query(value = """ + SELECT p FROM LocalProtocolParamsEntity p ORDER BY p.epoch DESC LIMIT 1 + """ + ) + Optional getLocalProtocolParams(); +} diff --git a/api/src/main/java/org/cardanofoundation/rosetta/common/services/ProtocolParamServiceImpl.java b/api/src/main/java/org/cardanofoundation/rosetta/common/services/ProtocolParamServiceImpl.java index 958a4f33d..285a93ab2 100644 --- a/api/src/main/java/org/cardanofoundation/rosetta/common/services/ProtocolParamServiceImpl.java +++ b/api/src/main/java/org/cardanofoundation/rosetta/common/services/ProtocolParamServiceImpl.java @@ -1,5 +1,7 @@ package org.cardanofoundation.rosetta.common.services; +import java.util.Optional; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -11,8 +13,10 @@ import org.springframework.transaction.annotation.Transactional; import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams; +import org.cardanofoundation.rosetta.api.block.model.entity.LocalProtocolParamsEntity; import org.cardanofoundation.rosetta.api.block.model.entity.ProtocolParamsEntity; import org.cardanofoundation.rosetta.api.block.model.repository.EpochParamRepository; +import org.cardanofoundation.rosetta.api.block.model.repository.LocalProtocolParamsRepository; import org.cardanofoundation.rosetta.common.mapper.ProtocolParamsMapper; @Service @@ -20,19 +24,24 @@ @RequiredArgsConstructor public class ProtocolParamServiceImpl implements ProtocolParamService { - private final EpochParamRepository epochParamRepository; + private final LocalProtocolParamsRepository localProtocolParamsRepository; private final ProtocolParamsMapper mapperProtocolParams; + private final EpochParamRepository epochParamRepository; @Override @Cacheable(value = "protocolParamsCache") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true) public ProtocolParams findProtocolParametersFromIndexer() { log.info("Fetching protocol parameters from the indexer"); - ProtocolParamsEntity paramsEntity = epochParamRepository.findLatestProtocolParams(); - ProtocolParams protocolParams = mapperProtocolParams.mapProtocolParamsToEntity(paramsEntity); + Optional protocolParams = localProtocolParamsRepository.getLocalProtocolParams(); log.debug("Protocol parameters fetched from the indexer: {} \nand saved in cachedProtocolParams", - paramsEntity); - return protocolParams; + protocolParams); + if(protocolParams.isEmpty()) { + ProtocolParamsEntity paramsEntity = epochParamRepository.findLatestProtocolParams(); + return mapperProtocolParams.mapProtocolParamsToEntity(paramsEntity); + } else { + return protocolParams.get().getProtocolParams(); + } } @Scheduled(fixedRate = 3600000) // 1 hour diff --git a/api/src/main/resources/config/application.yaml b/api/src/main/resources/config/application.yaml index 5c95a4ed2..9fc1a425a 100644 --- a/api/src/main/resources/config/application.yaml +++ b/api/src/main/resources/config/application.yaml @@ -6,7 +6,7 @@ server: spring: profiles: - active: ${API_SPRING_PROFILES_ACTIVE:staging, standalone} + active: ${API_SPRING_PROFILES_ACTIVE:dev} jackson: default-property-inclusion: NON_NULL serialization: diff --git a/api/src/test/java/org/cardanofoundation/rosetta/api/data/account/AccountBalanceApiTest.java b/api/src/test/java/org/cardanofoundation/rosetta/api/account/controller/AccountBalanceApiTest.java similarity index 98% rename from api/src/test/java/org/cardanofoundation/rosetta/api/data/account/AccountBalanceApiTest.java rename to api/src/test/java/org/cardanofoundation/rosetta/api/account/controller/AccountBalanceApiTest.java index 84d8da553..29bbf46c6 100644 --- a/api/src/test/java/org/cardanofoundation/rosetta/api/data/account/AccountBalanceApiTest.java +++ b/api/src/test/java/org/cardanofoundation/rosetta/api/account/controller/AccountBalanceApiTest.java @@ -1,4 +1,4 @@ -package org.cardanofoundation.rosetta.api.data.account; +package org.cardanofoundation.rosetta.api.account.controller; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; @@ -35,7 +35,6 @@ class AccountBalanceApiTest extends BaseSpringMvcSetup { private final String currentAdaBalance = "3636394"; private final String previousAdaBalance = "1636394"; - private final String currentLovelaceBalance = "1939500"; @Test void accountBalance2Ada_Test() { @@ -71,7 +70,7 @@ void accountBalanceMintedTokenAndEmptyName_Test() { accountBalanceResponse.getBalances().get(1).getValue()); assertNotEquals(accountBalanceResponse.getBalances().getFirst().getCurrency().getSymbol(), accountBalanceResponse.getBalances().get(1).getCurrency().getSymbol()); - assertEquals("", accountBalanceResponse.getBalances().get(2).getCurrency().getSymbol()); + assertEquals("", accountBalanceResponse.getBalances().get(1).getCurrency().getSymbol()); } @Test diff --git a/api/src/test/java/org/cardanofoundation/rosetta/api/data/account/AccountCoinsApiTest.java b/api/src/test/java/org/cardanofoundation/rosetta/api/account/controller/AccountCoinsApiTest.java similarity index 99% rename from api/src/test/java/org/cardanofoundation/rosetta/api/data/account/AccountCoinsApiTest.java rename to api/src/test/java/org/cardanofoundation/rosetta/api/account/controller/AccountCoinsApiTest.java index fe410aa13..7d263e87c 100644 --- a/api/src/test/java/org/cardanofoundation/rosetta/api/data/account/AccountCoinsApiTest.java +++ b/api/src/test/java/org/cardanofoundation/rosetta/api/account/controller/AccountCoinsApiTest.java @@ -1,4 +1,4 @@ -package org.cardanofoundation.rosetta.api.data.account; +package org.cardanofoundation.rosetta.api.account.controller; import java.util.Arrays; import java.util.List; @@ -36,7 +36,7 @@ class AccountCoinsApiTest extends BaseSpringMvcSetup { - private final String myAssetPolicyId = "7fb3df13910c057bd9254e847c076fb02de78503b9fa0ecdd70b566c"; + private final String myAssetPolicyId = "d97e36383ae494e72b736ace04080f2953934626376ee06cf84adeb4"; private final String latestTxHashOnZeroSlot = generatedDataMap.get( TestTransactionNames.SIMPLE_NEW_EMPTY_NAME_COINS_TRANSACTION.getName()).txHash() + ":0"; private final String expectedTestAccountCoinAmount = "1636394"; diff --git a/api/src/test/java/org/cardanofoundation/rosetta/api/construction/service/MetadataApiTest.java b/api/src/test/java/org/cardanofoundation/rosetta/api/construction/service/MetadataApiTest.java index e5dbb265e..581632058 100644 --- a/api/src/test/java/org/cardanofoundation/rosetta/api/construction/service/MetadataApiTest.java +++ b/api/src/test/java/org/cardanofoundation/rosetta/api/construction/service/MetadataApiTest.java @@ -43,7 +43,7 @@ void combineWithMetadataTest() throws IOException { assertEquals(ADA, constructionMetadataResponse.getSuggestedFee().getFirst().getCurrency().getSymbol()); assertEquals(ADA_DECIMALS, constructionMetadataResponse.getSuggestedFee().getFirst().getCurrency().getDecimals()); - assertEquals(BigDecimal.valueOf(68), constructionMetadataResponse.getMetadata().getTtl()); + assertEquals(BigDecimal.valueOf(79), constructionMetadataResponse.getMetadata().getTtl()); assertEquals("4310", constructionMetadataResponse.getMetadata().getProtocolParameters().getCoinsPerUtxoSize()); assertEquals("2000000", constructionMetadataResponse.getMetadata().getProtocolParameters().getKeyDeposit()); assertEquals("500000000", constructionMetadataResponse.getMetadata().getProtocolParameters().getPoolDeposit()); diff --git a/api/src/test/java/org/cardanofoundation/rosetta/common/cache/ProtocolParamsCacheTest.java b/api/src/test/java/org/cardanofoundation/rosetta/common/cache/ProtocolParamsCacheTest.java index d9a4aa10b..c2c9fa3f0 100644 --- a/api/src/test/java/org/cardanofoundation/rosetta/common/cache/ProtocolParamsCacheTest.java +++ b/api/src/test/java/org/cardanofoundation/rosetta/common/cache/ProtocolParamsCacheTest.java @@ -1,5 +1,7 @@ package org.cardanofoundation.rosetta.common.cache; +import java.util.Optional; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; @@ -12,8 +14,10 @@ import org.junit.jupiter.api.Test; import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams; +import org.cardanofoundation.rosetta.api.block.model.entity.LocalProtocolParamsEntity; import org.cardanofoundation.rosetta.api.block.model.entity.ProtocolParamsEntity; import org.cardanofoundation.rosetta.api.block.model.repository.EpochParamRepository; +import org.cardanofoundation.rosetta.api.block.model.repository.LocalProtocolParamsRepository; import org.cardanofoundation.rosetta.common.mapper.ProtocolParamsMapper; import org.cardanofoundation.rosetta.common.services.ProtocolParamServiceImpl; @@ -32,6 +36,8 @@ class ProtocolParamsCacheTest { @MockBean private EpochParamRepository epochParamRepository; + @MockBean + private LocalProtocolParamsRepository localProtocolParamsRepository; @MockBean private ProtocolParamsMapper protocolParamsToEntity; @@ -56,16 +62,14 @@ void protocolParamsCacheTest() { paramsEntity.setMinFeeA(1); ProtocolParams protocolParams = new ProtocolParams(); protocolParams.setMinFeeA(1); - - when(epochParamRepository.findLatestProtocolParams()).thenReturn(paramsEntity); - when(protocolParamsToEntity.mapProtocolParamsToEntity(paramsEntity)).thenReturn(protocolParams); + LocalProtocolParamsEntity localProtocolParamsEntity = LocalProtocolParamsEntity.builder().protocolParams(protocolParams).build(); + when(localProtocolParamsRepository.getLocalProtocolParams()).thenReturn(Optional.of(localProtocolParamsEntity)); ProtocolParams result1 = genesisService.findProtocolParametersFromIndexer(); ProtocolParams result2 = genesisService.findProtocolParametersFromIndexer(); // Assert that the repository & mapper method is only called once - verify(epochParamRepository, times(1)).findLatestProtocolParams(); - verify(protocolParamsToEntity, times(1)).mapProtocolParamsToEntity(paramsEntity); + verify(localProtocolParamsRepository, times(1)).getLocalProtocolParams(); assertEquals(result1, result2); Cache cache = cacheManager.getCache(PROTOCOL_PARAMS_CACHE); diff --git a/api/src/test/java/org/cardanofoundation/rosetta/common/services/ProtocolParamServiceImplTest.java b/api/src/test/java/org/cardanofoundation/rosetta/common/services/ProtocolParamServiceImplTest.java index 42b8f336b..153eabca6 100644 --- a/api/src/test/java/org/cardanofoundation/rosetta/common/services/ProtocolParamServiceImplTest.java +++ b/api/src/test/java/org/cardanofoundation/rosetta/common/services/ProtocolParamServiceImplTest.java @@ -1,5 +1,7 @@ package org.cardanofoundation.rosetta.common.services; +import java.util.Optional; + import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -8,9 +10,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.cardanofoundation.rosetta.api.block.model.domain.ProtocolParams; -import org.cardanofoundation.rosetta.api.block.model.entity.ProtocolParamsEntity; -import org.cardanofoundation.rosetta.api.block.model.repository.EpochParamRepository; -import org.cardanofoundation.rosetta.common.mapper.ProtocolParamsMapper; +import org.cardanofoundation.rosetta.api.block.model.entity.LocalProtocolParamsEntity; +import org.cardanofoundation.rosetta.api.block.model.repository.LocalProtocolParamsRepository; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -19,24 +20,19 @@ class ProtocolParamServiceImplTest { @Mock - EpochParamRepository epochParamRepository; - @Mock - ProtocolParamsMapper protocolParamsMapper; + LocalProtocolParamsRepository protocolParamsRepository; @InjectMocks ProtocolParamServiceImpl genesisService; - @Test - void getProtocolParameters() { - when(genesisService.findProtocolParametersFromIndexer()).thenReturn(new ProtocolParams()); - assertNotNull(genesisService.findProtocolParametersFromIndexer()); - } - @Test void findProtocolParametersFromIndexerTest() { //given - ProtocolParamsEntity protocolParams = new ProtocolParamsEntity(); - when(epochParamRepository.findLatestProtocolParams()).thenReturn(protocolParams); - when(protocolParamsMapper.mapProtocolParamsToEntity(protocolParams)).thenReturn(new ProtocolParams()); + when(protocolParamsRepository.getLocalProtocolParams()).thenReturn(Optional.of( + LocalProtocolParamsEntity.builder() + .epoch(5L) + .protocolParams( + ProtocolParams.builder().build()) + .build())); //when ProtocolParams protocolParameters = genesisService.findProtocolParametersFromIndexer(); //then diff --git a/api/src/test/resources/config/application-test-integration.yaml b/api/src/test/resources/config/application-test-integration.yaml index c5432c2e9..af61a6194 100644 --- a/api/src/test/resources/config/application-test-integration.yaml +++ b/api/src/test/resources/config/application-test-integration.yaml @@ -16,8 +16,8 @@ spring: max-request-size: 16MB datasource: driver-class-name: org.h2.Driver - username: ${DB_USER:rosetta_db_admin} - password: ${DB_SECRET:weakpwd#123_d} + username: rosetta_db_admin + password: weakpwd#123_d url: jdbc:h2:file:../testData/devkit.db # url: jdbc:h2:mem:${DB_NAME:rosetta-java};INIT=RUNSCRIPT FROM 'classpath:init.sql;DB_CLOSE_DELAY=-1;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;DEFAULT_NULL_ORDERING=HIGH sql: diff --git a/config/mainnet/config.json b/config/mainnet/config.json index 90fc38db2..dade1c284 100644 --- a/config/mainnet/config.json +++ b/config/mainnet/config.json @@ -3,14 +3,12 @@ "AlonzoGenesisHash": "7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874", "ByronGenesisFile": "byron-genesis.json", "ByronGenesisHash": "5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940ebb", - "ConwayGenesisFile": "conway-genesis.json", - "ConwayGenesisHash": "de609b281cb3d8ae91a9d63a00c87092975612d603aa54c0f1c6a781e33d6e1e", "EnableP2P": true, "LastKnownBlockVersion-Alt": 0, "LastKnownBlockVersion-Major": 3, "LastKnownBlockVersion-Minor": 0, "MaxKnownMajorProtocolVersion": 2, - "MinNodeVersion": "8.9.2", + "MinNodeVersion": "8.12.0", "PeerSharing": true, "Protocol": "Cardano", "RequiresNetworkMagic": "RequiresNoMagic", @@ -18,7 +16,7 @@ "ShelleyGenesisHash": "1a3be38bcbb7911969283716ad7aa550250226b76a61fc51cc9a9a35d9276d81", "TargetNumberOfActivePeers": 20, "TargetNumberOfEstablishedPeers": 50, - "TargetNumberOfKnownPeers": 100, + "TargetNumberOfKnownPeers": 150, "TargetNumberOfRootPeers": 60, "TraceAcceptPolicy": true, "TraceBlockFetchClient": false, diff --git a/config/mainnet/topology.json b/config/mainnet/topology.json index dbb09fd92..0a91fd227 100644 --- a/config/mainnet/topology.json +++ b/config/mainnet/topology.json @@ -28,4 +28,4 @@ } ], "useLedgerAfterSlot": 116812831 -} \ No newline at end of file +} diff --git a/config/preprod/config.json b/config/preprod/config.json index 92297d10f..ec2b280c4 100644 --- a/config/preprod/config.json +++ b/config/preprod/config.json @@ -1,23 +1,21 @@ { - "AlonzoGenesisFile": "/config/alonzo-genesis.json", + "AlonzoGenesisFile": "alonzo-genesis.json", "AlonzoGenesisHash": "7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874", - "ByronGenesisFile": "/config/byron-genesis.json", + "ByronGenesisFile": "byron-genesis.json", "ByronGenesisHash": "d4b8de7a11d929a323373cbab6c1a9bdc931beffff11db111cf9d57356ee1937", - "ConwayGenesisFile": "/config/conway-genesis.json", - "ConwayGenesisHash": "de609b281cb3d8ae91a9d63a00c87092975612d603aa54c0f1c6a781e33d6e1e", "EnableP2P": true, "LastKnownBlockVersion-Alt": 0, "LastKnownBlockVersion-Major": 2, "LastKnownBlockVersion-Minor": 0, - "MinNodeVersion": "8.9.2", + "MinNodeVersion": "8.12.0", "PeerSharing": true, "Protocol": "Cardano", "RequiresNetworkMagic": "RequiresMagic", - "ShelleyGenesisFile": "/config/shelley-genesis.json", + "ShelleyGenesisFile": "shelley-genesis.json", "ShelleyGenesisHash": "162d29c4e1cf6b8a84f2d692e67a3ac6bc7851bc3e6e4afe64d15778bed8bd86", "TargetNumberOfActivePeers": 20, "TargetNumberOfEstablishedPeers": 50, - "TargetNumberOfKnownPeers": 100, + "TargetNumberOfKnownPeers": 150, "TargetNumberOfRootPeers": 60, "TraceAcceptPolicy": true, "TraceBlockFetchClient": false, diff --git a/config/preview/config.json b/config/preview/config.json index 9a658f075..14a2834b7 100644 --- a/config/preview/config.json +++ b/config/preview/config.json @@ -1,25 +1,23 @@ { - "AlonzoGenesisFile": "/config/alonzo-genesis.json", + "AlonzoGenesisFile": "alonzo-genesis.json", "AlonzoGenesisHash": "7e94a15f55d1e82d10f09203fa1d40f8eede58fd8066542cf6566008068ed874", - "ByronGenesisFile": "/config/byron-genesis.json", + "ByronGenesisFile": "byron-genesis.json", "ByronGenesisHash": "83de1d7302569ad56cf9139a41e2e11346d4cb4a31c00142557b6ab3fa550761", - "ConwayGenesisFile": "/config/conway-genesis.json", - "ConwayGenesisHash": "de609b281cb3d8ae91a9d63a00c87092975612d603aa54c0f1c6a781e33d6e1e", "EnableP2P": true, "ExperimentalHardForksEnabled": false, "ExperimentalProtocolsEnabled": false, "LastKnownBlockVersion-Alt": 0, "LastKnownBlockVersion-Major": 3, "LastKnownBlockVersion-Minor": 1, - "MinNodeVersion": "8.9.2", + "MinNodeVersion": "8.12.0", "PeerSharing": true, "Protocol": "Cardano", "RequiresNetworkMagic": "RequiresMagic", - "ShelleyGenesisFile": "/config/shelley-genesis.json", + "ShelleyGenesisFile": "shelley-genesis.json", "ShelleyGenesisHash": "363498d1024f84bb39d3fa9593ce391483cb40d479b87233f868d6e57c3a400d", "TargetNumberOfActivePeers": 20, "TargetNumberOfEstablishedPeers": 50, - "TargetNumberOfKnownPeers": 100, + "TargetNumberOfKnownPeers": 150, "TargetNumberOfRootPeers": 60, "TestAllegraHardForkAtEpoch": 0, "TestAlonzoHardForkAtEpoch": 0, diff --git a/config/sanchonet/config.json b/config/sanchonet/config.json index 509c95f10..9a73fd21b 100644 --- a/config/sanchonet/config.json +++ b/config/sanchonet/config.json @@ -1,21 +1,21 @@ { - "AlonzoGenesisFile": "/config/alonzo-genesis.json", + "AlonzoGenesisFile": "alonzo-genesis.json", "AlonzoGenesisHash": "8bedcaea62107d8a79ed5293b0027b3f8706a4bc2422f33380cb1fd01c6fa6ec", - "ByronGenesisFile": "/config/byron-genesis.json", + "ByronGenesisFile": "byron-genesis.json", "ByronGenesisHash": "785eb88427e136378a15b0a152a8bfbeec7a611529ccda29c43a1e60ffb48eaa", - "ConwayGenesisFile": "/config/conway-genesis.json", - "ConwayGenesisHash": "49ef010ff0d13b090893a919bbc22022038a8b782faa0b1561a256b781672174", + "ConwayGenesisFile": "conway-genesis.json", + "ConwayGenesisHash": "79766b0c18076e9abefc806526714f30d42b14dba9f187fb316bd4e70c815ef4", "EnableP2P": true, "ExperimentalHardForksEnabled": true, "ExperimentalProtocolsEnabled": true, "LastKnownBlockVersion-Alt": 0, "LastKnownBlockVersion-Major": 3, "LastKnownBlockVersion-Minor": 1, - "MinNodeVersion": "8.10.0", + "MinNodeVersion": "8.11.0", "PeerSharing": true, "Protocol": "Cardano", "RequiresNetworkMagic": "RequiresMagic", - "ShelleyGenesisFile": "/config/shelley-genesis.json", + "ShelleyGenesisFile": "shelley-genesis.json", "ShelleyGenesisHash": "f94457ec45a0c6773057a529533cf7ccf746cb44dabd56ae970e1dbfb55bfdb2", "TargetNumberOfActivePeers": 20, "TargetNumberOfEstablishedPeers": 50, diff --git a/config/sanchonet/conway-genesis.json b/config/sanchonet/conway-genesis.json index 87c9bb30f..33719afca 100644 --- a/config/sanchonet/conway-genesis.json +++ b/config/sanchonet/conway-genesis.json @@ -1,39 +1,278 @@ { "poolVotingThresholds": { - "committeeNormal": 0.60, + "committeeNormal": 0.6, "committeeNoConfidence": 0.51, "hardForkInitiation": 0.51, - "motionNoConfidence": 0.60, - "ppSecurityGroup": 0.60 + "motionNoConfidence": 0.6, + "ppSecurityGroup": 0.6 }, "dRepVotingThresholds": { "motionNoConfidence": 0.67, "committeeNormal": 0.67, - "committeeNoConfidence": 0.60, + "committeeNoConfidence": 0.6, "updateToConstitution": 0.75, - "hardForkInitiation": 0.60, + "hardForkInitiation": 0.6, "ppNetworkGroup": 0.67, "ppEconomicGroup": 0.67, "ppTechnicalGroup": 0.67, "ppGovGroup": 0.75, "treasuryWithdrawal": 0.67 }, - "committeeMinSize": 7, + "committeeMinSize": 3, "committeeMaxTermLength": 73, - "govActionLifetime": 6, + "govActionLifetime": 8, "govActionDeposit": 50000000000, "dRepDeposit": 500000000, "dRepActivity": 20, "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://raw.githubusercontent.com/carloslodelar/proposals/main/constitution.txt", + "dataHash": "f89cc2469ce31c3dfda2f3e0b56c5c8b4ee4f0e5f66c30a3f12a95298b01179e" } }, "committee": { "members": { + "scriptHash-8fc13431159fdda66347a38c55105d50d77d67abc1c368b876d52ad1": 336, + "scriptHash-921e1ccb4812c4280510c9ccab81c561f3d413e7d744d48d61215d1f": 400, + "scriptHash-d5d09d9380cf9dcde1f3c6cd88b08ca9e00a3d550022ca7ee4026342": 400, + "scriptHash-2c698e41831684b16477fb50082b0c0e396d436504e39037d5366582": 400 }, - "threshold": 0.67 + "threshold": 0.66 } } diff --git a/docker-api-indexer.yaml b/docker-api-indexer.yaml index 204445e71..7e69344d1 100644 --- a/docker-api-indexer.yaml +++ b/docker-api-indexer.yaml @@ -62,8 +62,12 @@ services: GENESIS_ALONZO_PATH: ${GENESIS_ALONZO_PATH} GENESIS_CONWAY_PATH: ${GENESIS_CONWAY_PATH} PRUNING_ENABLED: ${PRUNING_ENABLED} + CARDANO_NODE_SOCKET_PATH: ${CARDANO_NODE_SOCKET_PATH} + HOST_N2C_SOCAT_HOST: ${HOST_N2C_SOCAT_HOST} + HOST_N2C_SOCAT_PORT: ${HOST_N2C_SOCAT_PORT} volumes: - ${CARDANO_CONFIG}:/config + - ${CARDANO_NODE_DIR}:${CARDANO_NODE_DIR} restart: always depends_on: db: diff --git a/docker/.env.dockerfile b/docker/.env.dockerfile index eaf9264aa..6fd759b83 100644 --- a/docker/.env.dockerfile +++ b/docker/.env.dockerfile @@ -27,7 +27,7 @@ DB_PORT=5432 ## Cardano node variables CARDANO_NODE_HOST=localhost CARDANO_NODE_PORT=3001 -CARDANO_NODE_VERSION=8.9.0 +CARDANO_NODE_VERSION=9.0.0 CARDANO_NODE_SUBMIT_HOST=localhost NODE_SUBMIT_API_PORT=8090 CARDANO_NODE_SOCKET_PATH=/node/node.socket diff --git a/docker/Dockerfile b/docker/Dockerfile index c15998239..9e6a114fd 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -48,7 +48,7 @@ RUN git clone https://github.com/input-output-hk/mithril.git \ # Cardano node version -ARG CARDANO_NODE_VERSION=8.9.4 +ARG CARDANO_NODE_VERSION=9.0.0 # Install sodium RUN export IOHKNIX_VERSION=$(curl https://raw.githubusercontent.com/IntersectMBO/cardano-node/${CARDANO_NODE_VERSION}/flake.lock | jq -r '.nodes.iohkNix.locked.rev') \ diff --git a/pom.xml b/pom.xml index f699c9aa2..105bbca43 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ 0.4.3 0.5.1 0.2.5 - 0.1.0-rc2-323a1a4-SNAPSHOT + 0.1.0-rc5-d3672d3-SNAPSHOT 2.11.0 2.0.1.Final 2.43.0 diff --git a/testData/devkit.db.mv.db b/testData/devkit.db.mv.db index 163cd8c5e..2235c4662 100644 Binary files a/testData/devkit.db.mv.db and b/testData/devkit.db.mv.db differ diff --git a/testData/testdata.json b/testData/testdata.json index 6d8c2343d..0de988247 100644 --- a/testData/testdata.json +++ b/testData/testdata.json @@ -1,57 +1,57 @@ { "stake_key_deregistration" : { "txHash" : "032ce4a519f2068703b0c78a00e8140f0f99de88e0b653750bf5d6f95b1c5ed2", - "blockHash" : "f9b9efb723ce51281cd7dbeb8ea22d405aa20b0be1678d71c60768aa9b1284fc", - "blockNumber" : 33 + "blockHash" : "e9ec3a7699137ca64d4afbdfa5372cf9f0b4317853b7a74d9514fe940f207774", + "blockNumber" : 49 }, "pool_retirement" : { "txHash" : "03b2264a382d87124b4f967fae166ff2ffc6cb0ce699f4b7812fdb81139f8264", - "blockHash" : "9982166a157fa3ecad7bb597ac5941aea11de4f18b765642dab6f120acc99ec2", - "blockNumber" : 44 + "blockHash" : "2ed3c484827494695f62f3e486f1a0348345a08ca6106404e7602fcd33691f96", + "blockNumber" : 61 }, "simple_new_empty_name_coins_transaction" : { - "txHash" : "e7d9a6e8e315a5bc60fd56afcfce38d07bde9ee6e27b2fe4f9c8b6ff9099c8c4", - "blockHash" : "602587bc0e908055fec5397cc6589d18671a282507942b833fdf674285e4b56e", - "blockNumber" : 28 + "txHash" : "5d72461b01e6fb9c0e11ef96f0a7a3cb10ab8df8c480390507b5af45500d7bb5", + "blockHash" : "8e3168ffa499b738976639d39cb63afb9b13d4ba5ddb12885d90700a005d5541", + "blockNumber" : 44 }, "simple_second_lovelace_transaction" : { "txHash" : "6dcbc6a6a5522970a06c85b7655eb3b766624efa90b539b4f39963da4197b719", - "blockHash" : "9f00a0855efe6a8fb6b0f98b5594cfba2e7e071f43929ad48fe5bfe236b08331", - "blockNumber" : 24 + "blockHash" : "0a305167b84f33fea002929ca3c27e1ff439c265d209d164aeb2a8d75ae72242", + "blockNumber" : 40 }, "pool_delegation" : { "txHash" : "f9636da9997361320db793dd6f9d7812ac186afadb28731bb3d57b3309d76ebd", - "blockHash" : "ed77ebe525228d3331fa98ce9eeb70eee7b32409e390ec6534afb9d64c8ee680", - "blockNumber" : 42 + "blockHash" : "dd83cbad41fa8a38393c15c967a9f7e013346af17ea6a10df3afa6d6934bb3fe", + "blockNumber" : 59 }, "simple_first_lovelace_transaction" : { "txHash" : "97f5a0de75fe0a0098228765b44a09b15cee7142fcf97868817f594b51729553", - "blockHash" : "4828dcc220d6924ba280c4e41b7339a1e12606b7aaa0588cbccb3954497021fa", - "blockNumber" : 22 + "blockHash" : "7e7845a1608cef674c75cc1eb0dac7122e2f552d6be1ecfedd7f20be0acc62e8", + "blockNumber" : 38 }, "simple_transaction_2" : { "txHash" : "820999c1a9236cd0bf0c2d1f576d317049a5f54d205227ec308ec08cada54528", - "blockHash" : "9a530536f286245f2c9e2faff4c1364472172e84d3246a7591adc1a79c5e5260", - "blockNumber" : 35 + "blockHash" : "603f93edf14ffbcefeaad59ddbbcad15ade41737119bc76143ebf942d8963335", + "blockNumber" : 51 }, "pool_registration" : { "txHash" : "f0a4f95c9952b95570f33e0b6bfe71c262206945925c71115160b7070d878a4a", - "blockHash" : "ee14291f2210865a241fbfe5e16570bff9d8240c363473d513f9ddfeb667b8da", - "blockNumber" : 37 + "blockHash" : "3b580a2a0e0e5ed8c05e28323f1bdc540123666622142d53655fbaff5bbccf46", + "blockNumber" : 53 }, "simple_new_coins_transaction" : { - "txHash" : "ca3e467c8bc9aa2d5cb17576169cf66cd3694bf1f14682c3b94ad70e89498a06", - "blockHash" : "2c590cb5662aee6ec8e6282d99846df45f03b56c6f68b04c648e1e04ddf2b402", - "blockNumber" : 26 + "txHash" : "f7ae2c35f5a5562b8364061dc103ca99a2066704436a82ff3c969bb1ec3d5a5f", + "blockHash" : "65c8cedc9525ef921c34d58c85435e8dcd59820b9322da1dafa9f9e3239ff818", + "blockNumber" : 42 }, "stake_key_registration" : { "txHash" : "d6d8ed0323bf594e692569d2d256ed1472e1c9e132552ef659452c9140191fec", - "blockHash" : "eec3a4ec9358b425068d942c20a4a73f020e36e6cf958fa1dc9d17d1f10aff8b", - "blockNumber" : 31 + "blockHash" : "610578ced4c6c121f10494f77df354b0cefdea72ee5fc46cb98510b3ad039054", + "blockNumber" : 47 }, "simple_transaction" : { "txHash" : "6a8ace2755a79bd239f43b7562cb80a11c062c5ec5ed9418da6553c89c5405b3", - "blockHash" : "65067e5651bd8b3051463ab46464f2c45cda8b3669aa2cf69f5d2297d613d4f4", - "blockNumber" : 20 + "blockHash" : "15bb0756e14a7faebaea092ac56d7b4d5c54cdaa964b1382e0a6d2523de05b0e", + "blockNumber" : 35 } } \ No newline at end of file diff --git a/yaci-indexer/pom.xml b/yaci-indexer/pom.xml index 0a4e8d1e8..c6cba5a25 100644 --- a/yaci-indexer/pom.xml +++ b/yaci-indexer/pom.xml @@ -16,7 +16,7 @@ yaci-indexer 21 - 0.1.0-rc2-323a1a4-SNAPSHOT + 0.1.0-rc5-d3672d3-SNAPSHOT src/main/java/org/cardanofoundation/rosetta/yaciindexer/stores/txsize/model/* 2.43.0 diff --git a/yaci-indexer/src/main/resources/application-h2-testdata.properties b/yaci-indexer/src/main/resources/application-h2-testdata.properties index 234cb21c8..cf067f902 100644 --- a/yaci-indexer/src/main/resources/application-h2-testdata.properties +++ b/yaci-indexer/src/main/resources/application-h2-testdata.properties @@ -5,6 +5,6 @@ ##################### H2 DB ####################### spring.datasource.url=jdbc:h2:file:./testData/devkit.db -spring.datasource.username=${DB_USER:rosetta_db_admin} -spring.datasource.password=${DB_SECRET:weakpwd#123_d} +spring.datasource.username=rosetta_db_admin +spring.datasource.password=weakpwd#123_d spring.h2.console.enabled=true \ No newline at end of file diff --git a/yaci-indexer/src/main/resources/application-n2c-socat.properties b/yaci-indexer/src/main/resources/application-n2c-socat.properties new file mode 100644 index 000000000..ffe1fccf9 --- /dev/null +++ b/yaci-indexer/src/main/resources/application-n2c-socat.properties @@ -0,0 +1,13 @@ +################ Local Node Configuration for Node-to-Client (Optional) ###### +# Most of the information in the indexer are fetched through remote +# host and port configured in the previous section, but few information +# like protocol parameters are fetched through "Node Socket" file of +# local Cardano node using node-to-client protocol. The transaction submission +# endpoint also uses this interface. +# If a local node configuration is not found, the yaci-store just ignores those data. +# Alternatively, Local node socket for node-to-client protocol can be exposed to remote client +# using relay like "socat". In that case, set cardano.n2c.host and cardano.n2c.port +########################################################### +#store.cardano.n2c-node-socket-path=${CARDANO_NODE_SOCKET_PATH} +store.cardano.n2c-host=${HOST_N2C_SOCAT_HOST} +store.cardano.n2c-port=${HOST_N2C_SOCAT_PORT} \ No newline at end of file diff --git a/yaci-indexer/src/main/resources/application-n2c-socket.properties b/yaci-indexer/src/main/resources/application-n2c-socket.properties new file mode 100644 index 000000000..a9ff0ff28 --- /dev/null +++ b/yaci-indexer/src/main/resources/application-n2c-socket.properties @@ -0,0 +1,13 @@ +################ Local Node Configuration for Node-to-Client (Optional) ###### +# Most of the information in the indexer are fetched through remote +# host and port configured in the previous section, but few information +# like protocol parameters are fetched through "Node Socket" file of +# local Cardano node using node-to-client protocol. The transaction submission +# endpoint also uses this interface. +# If a local node configuration is not found, the yaci-store just ignores those data. +# Alternatively, Local node socket for node-to-client protocol can be exposed to remote client +# using relay like "socat". In that case, set cardano.n2c.host and cardano.n2c.port +########################################################### +store.cardano.n2c-node-socket-path=${CARDANO_NODE_SOCKET_PATH} +#store.cardano.n2c-host=192.168.0.228 +#store.cardano.n2c-port=31001 \ No newline at end of file diff --git a/yaci-indexer/src/main/resources/application.properties b/yaci-indexer/src/main/resources/application.properties index b7b315ca3..6ac89c977 100644 --- a/yaci-indexer/src/main/resources/application.properties +++ b/yaci-indexer/src/main/resources/application.properties @@ -19,20 +19,6 @@ store.cardano.host=${CARDANO_NODE_HOST:preprod-node.world.dev.cardano.org} store.cardano.port=${CARDANO_NODE_PORT:30000} store.cardano.protocol-magic=${PROTOCOL_MAGIC:1} -################ Local Node Configuration for Node-to-Client (Optional) ###### -# Most of the information in the indexer are fetched through remote -# host and port configured in the previous section, but few information -# like protocol parameters are fetched through "Node Socket" file of -# local Cardano node using node-to-client protocol. The transaction submission -# endpoint also uses this interface. -# If a local node configuration is not found, the yaci-store just ignores those data. -# Alternatively, Local node socket for node-to-client protocol can be exposed to remote client -# using relay like "socat". In that case, set cardano.n2c.host and cardano.n2c.port -########################################################### -#store.cardano.n2c-node-socket-path=/Users/satya/work/cardano-node/preprod/db/node.socket -#store.cardano.n2c-host=192.168.0.228 -#store.cardano.n2c-port=31001 - ############### Genesis files ############################# # The application reads the below genesis files to get data like slotLength, maxLovelaceSupply # etc. If this section is not provided, the application will try to use the values defined in the application itself. The @@ -107,7 +93,7 @@ store.executor.use-virtual-thread-for-batch-processing=true store.executor.use-virtual-thread-for-event-processing=true ## Enable this flag to automatically delete optional indexes at the start of synchronization and recreate them once it approaches completion -store.auto-index-management=true +store.auto-index-management=trueso ##################################### # DB insert batch properties for JOOQ @@ -122,4 +108,6 @@ store.admin.health-check-interval=20 store.utxo.pruning-enabled=${PRUNING_ENABLED:false} -store.utxo.pruning-interval=600 \ No newline at end of file +store.utxo.pruning-interval=600 + +store.epoch.endpoints.epoch.local.enabled=true \ No newline at end of file