diff --git a/.env.IntegrationTest b/.env.IntegrationTest
index 1648513a..4d938fe2 100644
--- a/.env.IntegrationTest
+++ b/.env.IntegrationTest
@@ -43,7 +43,7 @@ GENESIS_VERIFICATION_KEY=
## Api env
API_DOCKER_IMAGE_TAG=main
-API_SPRING_PROFILES_ACTIVE=dev
+API_SPRING_PROFILES_ACTIVE=online
# staging, h2, test. Additional profiles: mempool (if mempool should be activated)
API_PORT=8082
PRINT_EXCEPTION=true
diff --git a/.env.docker-compose b/.env.docker-compose
index e31ec055..97d7c979 100644
--- a/.env.docker-compose
+++ b/.env.docker-compose
@@ -1,8 +1,9 @@
## Main variables
+API_SPRING_PROFILES_ACTIVE=online
LOG=INFO
-NETWORK=preprod
+NETWORK=mainnet
# mainnet, preprod, preview, sanchonet, devkit
-PROTOCOL_MAGIC=1
+PROTOCOL_MAGIC=764824073
# mainnet 764824073, preprod 1, preview 2, sanchonet 4, devkit 42
## Postgres image
@@ -42,7 +43,6 @@ GENESIS_VERIFICATION_KEY=
## Api env
API_DOCKER_IMAGE_TAG=main
-API_SPRING_PROFILES_ACTIVE=dev
# staging, h2, test. Additional profiles: mempool (if mempool should be activated)
API_PORT=8082
PRINT_EXCEPTION=true
diff --git a/README.md b/README.md
index b2514293..c45c21c5 100644
--- a/README.md
+++ b/README.md
@@ -48,9 +48,9 @@ Detailed explanation can be found in the [Wiki](https://github.com/cardano-found
Depending on using a snapshot feature or not, this will take X amount of time. You can follow along with the commands below. Your instance is ready when you see: `DONE`.
### Offline mode
-If you want to run rosetta-java in offline mode you need to set the `OFFLINE_MODE` environment variable to `true` in `./docker/.env.dockerfile`.
-
-This will disable the syncing of the node and the indexer.
+If you want to run rosetta-java in offline mode you need to set the `API_SPRING_PROFILES_ACTIVE` environment variable to `offline` in `./docker/.env.dockerfile`.
+This will disable the syncing of the node and won't start the db and the indexer.
+Default is `online`.
**Useful commands:**
- Following Docker container logs:
diff --git a/api/pom.xml b/api/pom.xml
index 9240600c..baf59cfd 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -163,7 +163,6 @@
com.h2database
h2
- test
org.mapstruct
diff --git a/api/src/main/java/org/cardanofoundation/rosetta/api/account/model/entity/AddressUtxoEntity.java b/api/src/main/java/org/cardanofoundation/rosetta/api/account/model/entity/AddressUtxoEntity.java
index 1cfcceee..b98b98bc 100644
--- a/api/src/main/java/org/cardanofoundation/rosetta/api/account/model/entity/AddressUtxoEntity.java
+++ b/api/src/main/java/org/cardanofoundation/rosetta/api/account/model/entity/AddressUtxoEntity.java
@@ -39,6 +39,7 @@ public class AddressUtxoEntity {
private String ownerStakeAddr;
@Type(JsonType.class)
+ @Column(columnDefinition = "TEXT") // Use TEXT for H2
private List amounts;
@Column(name = "block")
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
index 8de0b299..974a52a5 100644
--- 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
@@ -33,7 +33,7 @@ public class LocalProtocolParamsEntity {
private Long epoch;
@Type(JsonType.class)
- @Column(name = "params")
+ @Column(name = "params", columnDefinition = "TEXT")
private ProtocolParams protocolParams;
}
diff --git a/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/PoolRegistrationEntity.java b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/PoolRegistrationEntity.java
index 52811cab..385f28eb 100644
--- a/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/PoolRegistrationEntity.java
+++ b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/PoolRegistrationEntity.java
@@ -50,9 +50,11 @@ public class PoolRegistrationEntity {
private String rewardAccount;
@Type(JsonType.class)
+ @Column(columnDefinition = "TEXT") // Use TEXT for H2
private Set poolOwners;
@Type(JsonType.class)
+ @Column(columnDefinition = "TEXT") // Use TEXT for H2
private List relays;
}
diff --git a/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/TxnEntity.java b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/TxnEntity.java
index 372f782a..8e632363 100644
--- a/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/TxnEntity.java
+++ b/api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/TxnEntity.java
@@ -40,11 +40,11 @@ public class TxnEntity {
private BlockEntity block;
@Type(JsonType.class)
- @Column(name = "inputs")
+ @Column(name = "inputs", columnDefinition = "TEXT")
private List inputKeys;
@Type(JsonType.class)
- @Column(name = "outputs")
+ @Column(name = "outputs", columnDefinition = "TEXT")
private List outputKeys;
@Column(name = "fee")
diff --git a/api/src/main/resources/config/application-offline.yaml b/api/src/main/resources/config/application-offline.yaml
new file mode 100644
index 00000000..c97136e1
--- /dev/null
+++ b/api/src/main/resources/config/application-offline.yaml
@@ -0,0 +1,14 @@
+# Using H2 database as a dummy db for offline mode
+spring:
+ datasource:
+ driver-class-name: org.h2.Driver
+ username: ${DB_USER:rosetta_db_admin}
+ password: ${DB_SECRET:weakpwd#123_d}
+ url: jdbc:h2:mem:${DB_NAME:rosetta-java}
+ jpa:
+ hibernate:
+ ddl-auto: create-drop
+
+cardano:
+ rosetta:
+ OFFLINE_MODE: true
\ No newline at end of file
diff --git a/api/src/main/resources/config/application-dev.yaml b/api/src/main/resources/config/application-online.yaml
similarity index 52%
rename from api/src/main/resources/config/application-dev.yaml
rename to api/src/main/resources/config/application-online.yaml
index a253a1cf..afed9b9d 100644
--- a/api/src/main/resources/config/application-dev.yaml
+++ b/api/src/main/resources/config/application-online.yaml
@@ -1,6 +1,3 @@
-server:
- port: ${API_PORT:8082}
-
spring:
datasource:
username: ${DB_USER:rosetta_db_admin}
@@ -29,34 +26,4 @@ spring:
cardano:
rosetta:
- version:
- # devkit variables
- DEVKIT_URL: ${DEVKIT_URL:localhost}
-
-logging:
- level:
- root: INFO
- com:
- zaxxer:
- hikari:
- pool:
- HikariPool: DEBUG
- org:
- springframework:
- transaction: DEBUG
- orm:
- jpa: DEBUG
- web:
- filter:
- CommonsRequestLoggingFilter: DEBUG
- path: ${LOG_FILE_PATH:logs}
- file:
- name: ${LOG_FILE_NAME:logs/rosetta-api.log}
- max-size: ${LOG_FILE_MAX_SIZE:10MB}
- max-history: ${LOG_FILE_MAX_HISTORY:10}
-
-management:
- endpoints:
- web:
- exposure:
- include: "info"
+ OFFLINE_MODE: false
\ No newline at end of file
diff --git a/api/src/main/resources/config/application.yaml b/api/src/main/resources/config/application.yaml
index 8a81b3db..63fc678c 100644
--- a/api/src/main/resources/config/application.yaml
+++ b/api/src/main/resources/config/application.yaml
@@ -3,27 +3,17 @@ server:
enabled: true
mime-types: text/html,text/plain,text/css,application/javascript,application/json
min-response-size: 1024
+ port: ${API_PORT:8082}
spring:
profiles:
- active: ${API_SPRING_PROFILES_ACTIVE:dev}
+ active: ${API_SPRING_PROFILES_ACTIVE:online}
jackson:
default-property-inclusion: NON_NULL
serialization:
write-dates-as-timestamps: false
mvc:
log-resolved-exception: true
- datasource:
- driver-class-name: org.postgresql.Driver
- readOnly: true
- readOnlyMode: always
- hikari:
- maximumPoolSize: 12
- poolName: RosettaHikariCP
- readOnly: true
- autoCommit: false
- jpa:
- open-in-view: false
cardano:
rosetta:
@@ -43,7 +33,6 @@ cardano:
DEVKIT_URL: ${DEVKIT_URL:yaci-cli}
DEVKIT_PORT: ${DEVKIT_PORT:3333}
SEARCH_PAGE_SIZE: ${SEARCH_PAGE_SIZE:10}
- OFFLINE_MODE: ${OFFLINE_MODE:false}
logging:
level:
@@ -55,3 +44,9 @@ logging:
rollingpolicy:
max-file-size: ${LOG_FILE_MAX_SIZE:10MB}
max-history: ${LOG_FILE_MAX_HISTORY:10}
+
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "info"
diff --git a/docker-compose-api.yaml b/docker-compose-api.yaml
new file mode 100644
index 00000000..0933774f
--- /dev/null
+++ b/docker-compose-api.yaml
@@ -0,0 +1,47 @@
+version: '3.8'
+services:
+ api:
+ image: cardanofoundation/cardano-rosetta-java-api:${API_DOCKER_IMAGE_TAG}
+ build:
+ context: ./
+ dockerfile: ./api/Dockerfile
+ ports:
+ - ${API_PORT}:${API_PORT}
+ environment:
+ NETWORK: ${NETWORK}
+ API_SPRING_PROFILES_ACTIVE: ${API_SPRING_PROFILES_ACTIVE}
+ API_PORT: ${API_PORT}
+ DB_HOST: ${DB_HOST}
+ DB_PORT: ${DB_PORT}
+ DB_NAME: ${DB_NAME}
+ DB_USER: ${DB_USER}
+ DB_SECRET: ${DB_SECRET}
+ DB_SCHEMA: ${DB_SCHEMA}
+ CARDANO_NODE_VERSION: ${CARDANO_NODE_VERSION}
+ TOPOLOGY_FILEPATH: ${TOPOLOGY_FILEPATH}
+ GENESIS_SHELLEY_PATH: ${GENESIS_SHELLEY_PATH}
+ GENESIS_ALONZO_PATH: ${GENESIS_ALONZO_PATH}
+ GENESIS_CONWAY_PATH: ${GENESIS_CONWAY_PATH}
+ CARDANO_NODE_SUBMIT_HOST: ${CARDANO_NODE_SUBMIT_HOST}
+ NODE_SUBMIT_API_PORT: ${NODE_SUBMIT_API_PORT}
+ CARDANO_NODE_SOCKET_PATH: ${CARDANO_NODE_SOCKET_PATH}
+ DEVKIT_ENABLED: ${DEVKIT_ENABLED}
+ DEVKIT_URL: ${DEVKIT_URL}
+ DEVKIT_PORT: ${DEVKIT_PORT}
+ volumes:
+ - ${CARDANO_CONFIG}:/config
+ - ${CARDANO_NODE_DIR}:${CARDANO_NODE_DIR}
+ healthcheck:
+ test: [ "CMD-SHELL", "curl --fail http://localhost:${API_PORT}/network/options -H 'Content-Type: application/json' --data '{\"network_identifier\": {\"blockchain\": \"cardano\",\"network\": \"${NETWORK}\"},\"metadata\": {}}' -X POST" ]
+ interval: 30s
+ retries: 20
+ start_period: 20s
+ timeout: 10s
+ restart: always
+
+volumes:
+ data:
+
+networks:
+ default:
+ name: cardano-rosetta-java-${NETWORK}
diff --git a/docker-api-indexer.yaml b/docker-compose-indexer.yaml
similarity index 53%
rename from docker-api-indexer.yaml
rename to docker-compose-indexer.yaml
index fd4a2465..981b7857 100644
--- a/docker-api-indexer.yaml
+++ b/docker-compose-indexer.yaml
@@ -1,47 +1,5 @@
version: '3.8'
services:
- api:
- image: cardanofoundation/cardano-rosetta-java-api:${API_DOCKER_IMAGE_TAG}
- build:
- context: ./
- dockerfile: ./api/Dockerfile
- ports:
- - ${API_PORT}:${API_PORT}
- environment:
- NETWORK: ${NETWORK}
- API_SPRING_PROFILES_ACTIVE: ${API_SPRING_PROFILES_ACTIVE}
- API_PORT: ${API_PORT}
- DB_HOST: ${DB_HOST}
- DB_PORT: ${DB_PORT}
- DB_NAME: ${DB_NAME}
- DB_USER: ${DB_USER}
- DB_SECRET: ${DB_SECRET}
- DB_SCHEMA: ${DB_SCHEMA}
- CARDANO_NODE_VERSION: ${CARDANO_NODE_VERSION}
- TOPOLOGY_FILEPATH: ${TOPOLOGY_FILEPATH}
- GENESIS_SHELLEY_PATH: ${GENESIS_SHELLEY_PATH}
- GENESIS_ALONZO_PATH: ${GENESIS_ALONZO_PATH}
- GENESIS_CONWAY_PATH: ${GENESIS_CONWAY_PATH}
- CARDANO_NODE_SUBMIT_HOST: ${CARDANO_NODE_SUBMIT_HOST}
- NODE_SUBMIT_API_PORT: ${NODE_SUBMIT_API_PORT}
- CARDANO_NODE_SOCKET_PATH: ${CARDANO_NODE_SOCKET_PATH}
- DEVKIT_ENABLED: ${DEVKIT_ENABLED}
- DEVKIT_URL: ${DEVKIT_URL}
- DEVKIT_PORT: ${DEVKIT_PORT}
- volumes:
- - ${CARDANO_CONFIG}:/config
- - ${CARDANO_NODE_DIR}:${CARDANO_NODE_DIR}
- healthcheck:
- test: [ "CMD-SHELL", "curl --fail http://localhost:${API_PORT}/network/options -H 'Content-Type: application/json' --data '{\"network_identifier\": {\"blockchain\": \"cardano\",\"network\": \"${NETWORK}\"},\"metadata\": {}}' -X POST" ]
- interval: 30s
- retries: 20
- start_period: 20s
- timeout: 10s
- restart: always
- depends_on:
- db:
- condition: service_healthy
-
yaci-indexer:
image: cardanofoundation/cardano-rosetta-java-indexer:${INDEXER_DOCKER_IMAGE_TAG}
build:
diff --git a/docker-node.yaml b/docker-compose-node.yaml
similarity index 100%
rename from docker-node.yaml
rename to docker-compose-node.yaml
diff --git a/docker-compose.yaml b/docker-compose.yaml
index e1596ea7..25a0507d 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -1,7 +1,8 @@
version: '3.8'
include:
- - docker-api-indexer.yaml
- - docker-node.yaml
+ - docker-compose-indexer.yaml
+ - docker-compose-node.yaml
+ - docker-compose-api.yaml
networks:
default:
diff --git a/docker-integration-test-environment.yaml b/docker-integration-test-environment.yaml
index 3b38bcd6..a4b41f77 100644
--- a/docker-integration-test-environment.yaml
+++ b/docker-integration-test-environment.yaml
@@ -1,6 +1,7 @@
version: '3.8'
include:
- - docker-api-indexer.yaml
+ - docker-compose-indexer.yaml
+ - docker-compose-api.yaml
services:
yaci-cli:
diff --git a/docker/.env.dockerfile b/docker/.env.dockerfile
index fa532083..bfdd49fe 100644
--- a/docker/.env.dockerfile
+++ b/docker/.env.dockerfile
@@ -1,7 +1,8 @@
# In offline mode there will be no synchronization with the network
# and the following components will be disabled: Node, Submit-api, Mithril, Yaci Indexer
-# Set to false if you want to start everything needed to synchronize with the network
-OFFLINE_MODE=false
+# Set to offline for offline mode
+# Set to online for online mode
+API_SPRING_PROFILES_ACTIVE=online
## Main variables
LOG=INFO
@@ -37,8 +38,6 @@ CARDANO_NODE_SUBMIT_HOST=localhost
NODE_SUBMIT_API_PORT=8090
CARDANO_NODE_SOCKET_PATH=/node/node.socket
## Api env
-API_SPRING_PROFILES_ACTIVE=dev
-# staging, h2, test. Additional profiles: mempool (if mempool should be activated)
API_PORT=8082
ROSETTA_VERSION=1.4.13
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
index 1997fb74..835eb760 100644
--- a/docker/entrypoint.sh
+++ b/docker/entrypoint.sh
@@ -144,8 +144,8 @@ download_mithril_snapshot(){
cp -r /networks/$NETWORK/* /config/
rm -f $CARDANO_NODE_SOCKET_PATH
-if [ "$OFFLINE_MODE" == "true" ]; then
- echo "Starting in Offline mode - The Database won't be populated!"
+if [ "$API_SPRING_PROFILES_ACTIVE" == "offline" ]; then
+ echo "Starting in offline mode - No Database, Node, submit api or indexer will be started!"
else
echo "Network: $NETWORK"
if [ "$NETWORK" == "mainnet" ]; then
@@ -185,42 +185,31 @@ else
echo "Starting Cardano submit api..."
cardano-submit-api --listen-address 0.0.0.0 --socket-path "$CARDANO_NODE_SOCKET_PATH" --port $NODE_SUBMIT_API_PORT $NETWORK_STR --config /cardano-submit-api-config/cardano-submit-api.yaml > /logs/submit-api.log &
CARDANO_SUBMIT_PID=$!
-fi
-mkdir -p /node/postgres
-chown -R postgres:postgres /node/postgres
-chmod -R 0700 /node/postgres
-if [ ! -f "/node/postgres/PG_VERSION" ]; then
- database_initialization
-fi
-echo "Starting Postgres..."
-/etc/init.d/postgresql start
-create_database_and_user
+ mkdir -p /node/postgres
+ chown -R postgres:postgres /node/postgres
+ chmod -R 0700 /node/postgres
+ if [ ! -f "/node/postgres/PG_VERSION" ]; then
+ database_initialization
+ fi
+
+ echo "Starting Postgres..."
+ /etc/init.d/postgresql start
+ create_database_and_user
-echo "Starting Yaci indexer..."
-exec java -jar /yaci-indexer/app.jar > /logs/indexer.log &
-YACI_STORE_PID=$!
+ echo "Starting Yaci indexer..."
+ exec java -jar /yaci-indexer/app.jar > /logs/indexer.log &
+ YACI_STORE_PID=$!
-if [ "$OFFLINE_MODE" == "true" ]; then
- # We need to start the Yaci Indexer to create the database schema
- # But we don't want to populate the database so we kill it after 30 seconds
- echo "Waiting 30 seconds to let yaci store create the db schema. Killing it after..."
- sleep 30
- kill -9 $YACI_STORE_PID
- rm /logs/indexer.log
- rm /logs/yaci-store.log
fi
-
echo "Starting Rosetta API..."
exec java -jar /api/app.jar > /logs/api.log &
API_PID=$!
-if [ "$OFFLINE_MODE" == "true" ]; then
- echo "Starting API in offline mode - The Database won't be populated!"
-else
+if [ "$API_SPRING_PROFILES_ACTIVE" == "online" ]; then
echo "Waiting Rosetta API initialization..."
sleep 5
get_current_index
@@ -235,7 +224,7 @@ fi
echo "DONE"
-if [ "$OFFLINE_MODE" == "true" ]; then
+if [ "$API_SPRING_PROFILES_ACTIVE" == "offline" ]; then
tail -f -n +1 /logs/*.log > >(tee $logf) &
tail_pid=$!
wait $API_PID