Skip to content

Commit 7dc0015

Browse files
author
Mateusz Czeladka
committed
fix: disable peer discovery, remove explicit token registry cache cleanup.
1 parent a2331f6 commit 7dc0015

File tree

11 files changed

+16
-21
lines changed

11 files changed

+16
-21
lines changed

.env.IntegrationTest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ PEER_DISCOVERY=false
158158
TOKEN_REGISTRY_ENABLED=false
159159
TOKEN_REGISTRY_BASE_URL=https://tokens.cardano.org/api
160160
TOKEN_REGISTRY_CACHE_TTL_HOURS=12
161-
TOKEN_REGISTRY_CACHE_CLEAR_RATE=15m
162161
TOKEN_REGISTRY_LOGO_FETCH=false
162+
TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS=2
163163

164164
## Mithril version for Docker build
165165
MITHRIL_VERSION=2524.0

.env.docker-compose

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ CONTINUE_PARSING_ON_ERROR=true
109109
SYNC=true
110110

111111
## Peer Discovery
112-
PEER_DISCOVERY=true
112+
PEER_DISCOVERY=false
113113

114114
## Token Registry
115115
# Token registry is enabled for mainnet
116116
TOKEN_REGISTRY_ENABLED=true
117117
TOKEN_REGISTRY_BASE_URL=https://tokens.cardano.org/api
118118
TOKEN_REGISTRY_CACHE_TTL_HOURS=12
119-
TOKEN_REGISTRY_CACHE_CLEAR_RATE=15m
120119
TOKEN_REGISTRY_LOGO_FETCH=false
120+
TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS=2

.env.docker-compose-preprod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ PEER_DISCOVERY=true
116116
TOKEN_REGISTRY_ENABLED=true
117117
TOKEN_REGISTRY_BASE_URL=http://preview.integrations.cf-systems.internal:8080/api
118118
TOKEN_REGISTRY_CACHE_TTL_HOURS=1
119-
TOKEN_REGISTRY_CACHE_CLEAR_RATE=15m
120119
TOKEN_REGISTRY_LOGO_FETCH=true
120+
TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS=2

.env.h2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,5 @@ SYNC=false
109109
TOKEN_REGISTRY_ENABLED=false
110110
TOKEN_REGISTRY_BASE_URL=https://tokens.cardano.org/api
111111
TOKEN_REGISTRY_CACHE_TTL_HOURS=12
112-
TOKEN_REGISTRY_CACHE_CLEAR_RATE=15m
113112
TOKEN_REGISTRY_LOGO_FETCH=false
113+
TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS=2

.env.h2-testdata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,5 @@ SYNC=false
110110
TOKEN_REGISTRY_ENABLED=false
111111
TOKEN_REGISTRY_BASE_URL=https://tokens.cardano.org/api
112112
TOKEN_REGISTRY_CACHE_TTL_HOURS=12
113-
TOKEN_REGISTRY_CACHE_CLEAR_RATE=15m
114113
TOKEN_REGISTRY_LOGO_FETCH=false
114+
TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS=2

api/src/main/java/org/cardanofoundation/rosetta/client/CachingTokenRegistryHttpGatewayImpl.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import lombok.NonNull;
88
import lombok.RequiredArgsConstructor;
99
import lombok.extern.slf4j.Slf4j;
10-
import org.cardanofoundation.rosetta.client.model.domain.*;
10+
import org.cardanofoundation.rosetta.client.model.domain.TokenCacheEntry;
11+
import org.cardanofoundation.rosetta.client.model.domain.TokenRegistryBatchRequest;
12+
import org.cardanofoundation.rosetta.client.model.domain.TokenRegistryBatchResponse;
13+
import org.cardanofoundation.rosetta.client.model.domain.TokenSubject;
1114
import org.springframework.beans.factory.annotation.Value;
12-
import org.springframework.scheduling.annotation.Scheduled;
1315
import org.springframework.stereotype.Service;
1416

1517
import java.io.IOException;
@@ -35,7 +37,7 @@ public class CachingTokenRegistryHttpGatewayImpl implements TokenRegistryHttpGat
3537
@Value("${cardano.rosetta.TOKEN_REGISTRY_BASE_URL:https://tokens.cardano.org/api}")
3638
protected String tokenRegistryBaseUrl;
3739

38-
@Value("${cardano.rosetta.HTTP_REQUEST_TIMEOUT_SECONDS:2}") // aggressive timeout as we do not want to block the request
40+
@Value("${cardano.rosetta.TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS:2}") // aggressive timeout as we do not want to block the request
3941
protected int httpRequestTimeoutSeconds;
4042

4143
@Value("${cardano.rosetta.TOKEN_REGISTRY_LOGO_FETCH:false}")
@@ -84,7 +86,7 @@ public Map<String, Optional<TokenSubject>> getTokenMetadataBatch(@NonNull Set<St
8486
return result;
8587
}
8688

87-
log.info("Initiating remote token registry request for {} subjects", subjectsToFetch.size());
89+
log.info("Initiating remote token registry HTTP POST request: {} for {} subjects", batchEndpointUrl, subjectsToFetch.size());
8890
log.debug("Subjects to fetch from token registry: {}", subjectsToFetch);
8991

9092
Stopwatch stopwatch = Stopwatch.createStarted();
@@ -162,17 +164,12 @@ public Map<String, Optional<TokenSubject>> getTokenMetadataBatch(@NonNull Set<St
162164
}
163165
}
164166

167+
/** helper for testing */
165168
void evictFromCache(String subject) {
166169
tokenMetadataCache.invalidate(subject);
167170
log.debug("Evicted cache entry for subject: {}", subject);
168171
}
169172

170-
@Scheduled(fixedRateString = "${cardano.rosetta.TOKEN_REGISTRY_CACHE_CLEAR_RATE:15m}")
171-
void clearCache() {
172-
tokenMetadataCache.invalidateAll();
173-
log.info("Cleared all token metadata cache entries.");
174-
}
175-
176173
List<String> buildPropertiesList() {
177174
List<String> properties = new ArrayList<>();
178175

api/src/main/java/org/cardanofoundation/rosetta/config/CacheConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public ConcurrentMapCacheManager cacheManager() {
2323
//a cache for token metadata from token registry
2424
@Bean
2525
public Cache<String, TokenCacheEntry> tokenMetadataCache(
26-
@Value("${cardano.rosetta.TOKEN_REGISTRY_CACHE_TTL_HOURS:1}") int cacheTtlHours) {
26+
@Value("${cardano.rosetta.TOKEN_REGISTRY_CACHE_TTL_HOURS:12}") int cacheTtlHours) {
2727
return CacheBuilder.newBuilder()
2828
.maximumSize(10_000) // Maximum 10k cached entries
2929
.expireAfterWrite(cacheTtlHours, HOURS)

api/src/main/resources/config/application-online.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ cardano:
4545
TOKEN_REGISTRY_ENABLED: ${TOKEN_REGISTRY_ENABLED:true}
4646
TOKEN_REGISTRY_BASE_URL: ${TOKEN_REGISTRY_BASE_URL:https://tokens.cardano.org/api}
4747
TOKEN_REGISTRY_CACHE_TTL_HOURS: ${TOKEN_REGISTRY_CACHE_TTL_HOURS:1}
48-
TOKEN_REGISTRY_CACHE_CLEAR_RATE: ${TOKEN_REGISTRY_CACHE_CLEAR_RATE:15m}

api/src/main/resources/config/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ cardano:
5252
TOKEN_REGISTRY_ENABLED: ${TOKEN_REGISTRY_ENABLED:true}
5353
TOKEN_REGISTRY_BASE_URL: ${TOKEN_REGISTRY_BASE_URL:https://tokens.cardano.org/api}
5454
TOKEN_REGISTRY_CACHE_TTL_HOURS: ${TOKEN_REGISTRY_CACHE_TTL_HOURS:1}
55-
TOKEN_REGISTRY_CACHE_CLEAR_RATE: ${TOKEN_REGISTRY_CACHE_CLEAR_RATE:15m}
5655
TOKEN_REGISTRY_LOGO_FETCH: ${TOKEN_REGISTRY_LOGO_FETCH:false}
56+
TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS: ${TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS:2}
5757

5858
logging:
5959
level:

docker-compose-api.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ services:
5252
TOKEN_REGISTRY_ENABLED: ${TOKEN_REGISTRY_ENABLED}
5353
TOKEN_REGISTRY_BASE_URL: ${TOKEN_REGISTRY_BASE_URL}
5454
TOKEN_REGISTRY_CACHE_TTL_HOURS: ${TOKEN_REGISTRY_CACHE_TTL_HOURS}
55-
TOKEN_REGISTRY_CACHE_CLEAR_RATE: ${TOKEN_REGISTRY_CACHE_CLEAR_RATE}
5655
TOKEN_REGISTRY_LOGO_FETCH: ${TOKEN_REGISTRY_LOGO_FETCH}
56+
TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS: ${TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS}
5757

5858
volumes:
5959
- ${CARDANO_CONFIG}:/config

0 commit comments

Comments
 (0)