Skip to content
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
12 changes: 12 additions & 0 deletions .env.docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ API_DB_POOL_CONNECTION_TIMEOUT_MS=100000
API_DB_KEEP_ALIVE_MS=60000
API_DB_LEAK_CONNECTIONS_WARNING_MS=60000

## Indexer DB tuning / debugging
INDEXER_DB_SHOW_SQL=false
INDEXER_DB_MONITOR_PERFORMANCE=false

## Indexer DB pool tuning
INDEXER_DB_POOL_MIN_COUNT=12
INDEXER_DB_POOL_MAX_COUNT=12
INDEXER_DB_POOL_MAX_LIFETIME_MS=2000000
INDEXER_DB_POOL_CONNECTION_TIMEOUT_MS=100000
INDEXER_DB_KEEP_ALIVE_MS=60000
INDEXER_DB_LEAK_CONNECTIONS_WARNING_MS=60000

SYNC_GRACE_SLOTS_COUNT=100

## Monitoring variables
Expand Down
12 changes: 12 additions & 0 deletions .env.docker-compose-preprod
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ API_DB_POOL_CONNECTION_TIMEOUT_MS=100000
API_DB_KEEP_ALIVE_MS=60000
API_DB_LEAK_CONNECTIONS_WARNING_MS=60000

## Indexer DB tuning / debugging
INDEXER_DB_SHOW_SQL=false
INDEXER_DB_MONITOR_PERFORMANCE=false

## Indexer DB pool tuning
INDEXER_DB_POOL_MIN_COUNT=12
INDEXER_DB_POOL_MAX_COUNT=12
INDEXER_DB_POOL_MAX_LIFETIME_MS=2000000
INDEXER_DB_POOL_CONNECTION_TIMEOUT_MS=100000
INDEXER_DB_KEEP_ALIVE_MS=60000
INDEXER_DB_LEAK_CONNECTIONS_WARNING_MS=60000

SYNC_GRACE_SLOTS_COUNT=100

## When set to true, the parsing / processing blockchain data even if an error occurs.
Expand Down
4 changes: 4 additions & 0 deletions .env.docker-compose-profile-advanced-level
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
API_DB_POOL_MIN_COUNT=100
API_DB_POOL_MAX_COUNT=550

## Indexer DB pool performance tuning
INDEXER_DB_POOL_MIN_COUNT=50
INDEXER_DB_POOL_MAX_COUNT=150

DB_POSTGRES_MAX_CONNECTIONS=600
DB_POSTGRES_SHARED_BUFFERS=32GB
DB_POSTGRES_EFFECTIVE_CACHE_SIZE=32GB
Expand Down
4 changes: 4 additions & 0 deletions .env.docker-compose-profile-entry-level
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
API_DB_POOL_MIN_COUNT=12
API_DB_POOL_MAX_COUNT=12

## Indexer DB pool performance tuning
INDEXER_DB_POOL_MIN_COUNT=12
INDEXER_DB_POOL_MAX_COUNT=12

## PostgreSQL Tuning for Entry-Level Profile
DB_POSTGRES_MAX_CONNECTIONS=120
DB_POSTGRES_SHARED_BUFFERS=1GB
Expand Down
4 changes: 4 additions & 0 deletions .env.docker-compose-profile-mid-level
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
API_DB_POOL_MIN_COUNT=150
API_DB_POOL_MAX_COUNT=150

## Indexer DB pool performance tuning
INDEXER_DB_POOL_MIN_COUNT=50
INDEXER_DB_POOL_MAX_COUNT=50

DB_POSTGRES_MAX_CONNECTIONS=300
DB_POSTGRES_SHARED_BUFFERS=4GB
DB_POSTGRES_EFFECTIVE_CACHE_SIZE=8GB
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ settings.xml
!docker/.env.docker-profile-entry-level
!docker/.env.docker-profile-mid-level
!.claude/*
.claude/settings.local.json
.claude/settings.local.json

# Helm build artifacts (generated by helm package — do not commit)
helm/**/charts/*.tgz
helm/**/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.openapitools.client.model.CallResponse;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;

public interface CallService {
Expand All @@ -24,4 +25,9 @@ public interface CallService {
*/
CallResponse markParseErrorBlockChecked(Map<String, Object> params);

/**
* Get a list of supported method names for the /call endpoint
*/
List<String> getSupportedMethods();

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public class CallServiceImpl implements CallService {

private final BlockParsingErrorReviewService blockParsingErrorReviewService;

@Override
public List<String> getSupportedMethods() {
return List.of(METHOD_GET_PARSE_ERROR_BLOCKS, METHOD_MARK_PARSE_ERROR_BLOCK_CHECKED);
}

@Override
public CallResponse processCallRequest(CallRequest callRequest) {
String method = callRequest.getMethod();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ public ConstructionDeriveResponse constructionDeriveService(
}

// Default address type is enterprise
AddressType addressType =
metadata.getAddressType() != null ? AddressType.findByValue(metadata.getAddressType())
: null;
AddressType addressType = null;
if (metadata.getAddressType() != null && !metadata.getAddressType().trim().isEmpty()) {
addressType = AddressType.findByValue(metadata.getAddressType());
if (addressType == null) {
throw ExceptionFactory.invalidAddressTypeError();
}
}
addressType = addressType != null ? addressType : AddressType.ENTERPRISE;

PublicKey stakingCredential = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.cardanofoundation.rosetta.api.call.service.CallService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -42,6 +43,7 @@ public class NetworkServiceImpl implements NetworkService {
private final ResourceLoader resourceLoader;
private final GenesisDataProvider genesisDataProvider;
private final SyncStatusService syncStatusService;
private final CallService callService;

@Value("${cardano.rosetta.GENESIS_SHELLEY_PATH}")
private String genesisShelleyPath;
Expand Down Expand Up @@ -100,7 +102,7 @@ public NetworkOptionsResponse getNetworkOptions(NetworkRequest networkRequest) {
.sorted(Comparator.comparingInt(Error::getCode))
.toList())
.historicalBalanceLookup(true)
.callMethods(new ArrayList<>())
.callMethods(callService.getSupportedMethods())
.mempoolCoins(false))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.openapitools.client.model.ConstructionDeriveResponse;
import org.openapitools.client.model.NetworkIdentifier;

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

import org.cardanofoundation.rosetta.api.IntegrationTest;
Expand All @@ -29,28 +30,44 @@ private ConstructionDeriveRequest getDeriveRequest(String fileName) throws IOExc
return request;
}

@Test
void deriveAddressTest() throws IOException {
ConstructionDeriveRequest deriveRequest = getDeriveRequest(
"testdata/construction/derive/derive_request.json");
ConstructionDeriveResponse constructionDeriveResponse = constructionApiService.constructionDeriveService(
deriveRequest);
@Nested
class DeriveAddressTest {
@Test
void shouldReturnCorrectAddress() throws IOException {
ConstructionDeriveRequest deriveRequest = getDeriveRequest(
"testdata/construction/derive/derive_request.json");
ConstructionDeriveResponse constructionDeriveResponse = constructionApiService.constructionDeriveService(
deriveRequest);

String address = "addr_test1vza5pudxg77g3sdaddecmw8tvc6hmynywn49lltt4fmvn7c6mzywr";
assertEquals(address, constructionDeriveResponse.getAccountIdentifier().getAddress());
String address = "addr_test1vza5pudxg77g3sdaddecmw8tvc6hmynywn49lltt4fmvn7c6mzywr";
assertEquals(address, constructionDeriveResponse.getAccountIdentifier().getAddress());
}
}

@Test
void deriveAddressTestWithInvalidNetworkConfigurationTest() throws IOException {
ConstructionDeriveRequest deriveRequest = getDeriveRequest(
"testdata/construction/derive/derive_request.json");
deriveRequest.setNetworkIdentifier(new NetworkIdentifier());
ApiException exception = assertThrows(ApiException. class,
() -> constructionApiService.constructionDeriveService(
deriveRequest));
assertEquals(4000, exception.getError().getCode());
assertEquals("Invalid Network configuration", exception.getError().getMessage());
@Nested
class InvalidNetworkConfigurationTest {

}
@Test
void shouldThrowException() throws IOException {
ConstructionDeriveRequest deriveRequest = getDeriveRequest(
"testdata/construction/derive/derive_request.json");
deriveRequest.setNetworkIdentifier(new NetworkIdentifier());

assertThrows(ApiException.class,
() -> constructionApiService.constructionDeriveService(deriveRequest));
}

@Test
void shouldHaveCorrectErrorCodeAndMessage() throws IOException {
ConstructionDeriveRequest deriveRequest = getDeriveRequest(
"testdata/construction/derive/derive_request.json");
deriveRequest.setNetworkIdentifier(new NetworkIdentifier());

ApiException exception = assertThrows(ApiException.class,
() -> constructionApiService.constructionDeriveService(deriveRequest));

assertEquals(4000, exception.getError().getCode());
assertEquals("Invalid Network configuration", exception.getError().getMessage());
}
}
}
Loading
Loading