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
8 changes: 4 additions & 4 deletions .env.IntegrationTest
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ DB_SECRET=weakpwd#123_d
DB_HOST=db
# Service name in docker-compose or local db
DB_PORT=5432
DB_SCHEMA=${NETWORK}
DB_SCHEMA=public
DB_PATH=data
UPDATE_GENESIS_BLOCK_QUERY="UPDATE devkit.block SET number = 0 WHERE number = -1; UPDATE devkit.block SET prev_hash = 'Genesis' WHERE number = 1"
#UPDATE_GENESIS_BLOCK_QUERY="UPDATE devkit.block SET prev_hash = 'Genesis' WHERE number = 1"
UPDATE_GENESIS_BLOCK_QUERY="UPDATE \"public\".block SET number = 0 WHERE number = -1; UPDATE \"public\".block SET prev_hash = 'Genesis' WHERE number = 1"
#UPDATE_GENESIS_BLOCK_QUERY="UPDATE \"public\".block SET prev_hash = 'Genesis' WHERE number = 1"

## Cardano Node variables
CARDANO_NODE_HOST=yaci-cli
Expand Down Expand Up @@ -162,4 +162,4 @@ TOKEN_REGISTRY_LOGO_FETCH=false
TOKEN_REGISTRY_REQUEST_TIMEOUT_SECONDS=2

## Mithril version for Docker build
MITHRIL_VERSION=2524.0
MITHRIL_VERSION=2537.0
8 changes: 4 additions & 4 deletions .env.docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ DB_SECRET=weakpwd#123_d
DB_HOST=db
# Service name in docker-compose or local db
DB_PORT=5432
DB_SCHEMA=${NETWORK}
DB_SCHEMA=public
DB_PATH=data

## Cardano Node variables
CARDANO_NODE_HOST=cardano-node
# Service name in docker-compose or local cardano node
CARDANO_NODE_PORT=3001
# Uncomment if you are using local cardano node
CARDANO_NODE_VERSION=10.4.1
CARDANO_NODE_VERSION=10.5.1
CARDANO_NODE_SUBMIT_HOST=cardano-submit-api
NODE_SUBMIT_API_PORT=8090
CARDANO_NODE_DIR=/node
Expand All @@ -34,7 +34,7 @@ CARDANO_CONFIG=./config/node/${NETWORK}

## Mithril
MITHRIL_SYNC=true
MITHRIL_VERSION=2524.0
MITHRIL_VERSION=2537.0
SNAPSHOT_DIGEST=latest
# if not set standard values will be used
AGGREGATOR_ENDPOINT=
Expand Down Expand Up @@ -109,7 +109,7 @@ CONTINUE_PARSING_ON_ERROR=true
SYNC=true

## Peer Discovery
PEER_DISCOVERY=false
PEER_DISCOVERY=true

## Token Registry
TOKEN_REGISTRY_ENABLED=false
Expand Down
5 changes: 2 additions & 3 deletions .env.docker-compose-preprod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CARDANO_NODE_HOST=cardano-node
# Service name in docker-compose or local cardano node
CARDANO_NODE_PORT=3001
# Uncomment if you are using local cardano node
CARDANO_NODE_VERSION=10.4.1
CARDANO_NODE_VERSION=10.5.1
CARDANO_NODE_SUBMIT_HOST=cardano-submit-api
NODE_SUBMIT_API_PORT=8090
CARDANO_NODE_DIR=/opt/rosetta-java-preprod/node_data
Expand All @@ -34,7 +34,7 @@ CARDANO_CONFIG=./config/node/${NETWORK}

## Mithril
MITHRIL_SYNC=true
MITHRIL_VERSION=2524.0
MITHRIL_VERSION=2537.0
SNAPSHOT_DIGEST=latest
# if not set standard values will be used
AGGREGATOR_ENDPOINT=
Expand Down Expand Up @@ -112,7 +112,6 @@ POSTGRESQL_EXPORTER_PORT=9187
PEER_DISCOVERY=true

## Token Registry
# Externally hosted token registry is currently only available for mainnet
TOKEN_REGISTRY_ENABLED=false
TOKEN_REGISTRY_BASE_URL=
TOKEN_REGISTRY_CACHE_TTL_HOURS=1
Expand Down
2 changes: 1 addition & 1 deletion .env.h2
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CARDANO_NODE_HOST=localhost
# Service name in docker-compose or local cardano node
CARDANO_NODE_PORT=3001
# Uncomment if you are using local cardano node
CARDANO_NODE_VERSION=10.4.1
CARDANO_NODE_VERSION=10.5.1
CARDANO_NODE_SUBMIT_HOST=localhost
NODE_SUBMIT_API_PORT=8090

Expand Down
2 changes: 1 addition & 1 deletion .env.h2-testdata
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CARDANO_NODE_HOST=localhost
# Service name in docker-compose or local cardano node
CARDANO_NODE_PORT=3001
# Uncomment if you are using local cardano node
CARDANO_NODE_VERSION=10.4.1
CARDANO_NODE_VERSION=10.5.1
CARDANO_NODE_SUBMIT_HOST=localhost
NODE_SUBMIT_API_PORT=8090

Expand Down
94 changes: 64 additions & 30 deletions .github/actions/build_docker_images/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,74 @@ inputs:
description: Is this a release build? If true, the latest tag will be applied
required: false
default: false
node_version_key:
required: false
default: CARDANO_NODE_VERSION
pg_version_key:
required: false
default: PG_VERSION_TAG
mithril_version_key:
required: false
default: MITHRIL_VERSION

secrets:
DOCKERHUB_USERNAME:
description: Docker Hub username
required: true
DOCKERHUB_TOKEN:
description: Docker Hub token
required: true
DOCKERHUB_TOKEN:
description: Docker Hub token
required: true
runs:
using: composite
steps:
- name: Read versions from .env
id: envver
shell: bash
run: |
NODE_KEY='${{ inputs.node_version_key }}'
PG_KEY='${{ inputs.pg_version_key }}'
MITHRIL_KEY='${{ inputs.mithril_version_key }}'

if [[ ! -f .env ]]; then
echo ".env not found"
exit 0
fi

get_val() {
local key="$1"
grep -E "^${key}=" .env | head -1 | cut -d= -f2- | tr -d '\r'
}

NODE_VAL="$(get_val "$NODE_KEY")"
PG_VAL="$(get_val "$PG_KEY")"
MITHRIL_VAL="$(get_val "$MITHRIL_KEY")"

if [[ -n "$NODE_VAL" ]]; then
echo "node_version=$NODE_VAL" >> "$GITHUB_OUTPUT"
else
echo "No value for $NODE_KEY in .env"
fi

if [[ -n "$PG_VAL" ]]; then
echo "pg_version=$PG_VAL" >> "$GITHUB_OUTPUT"
else
echo "No value for $PG_KEY in .env"
fi

if [[ -n "$MITHRIL_VAL" ]]; then
echo "mithril_version=$MITHRIL_VAL" >> "$GITHUB_OUTPUT"
else
echo "No value for $MITHRIL_KEY in .env"
fi

- name: API - Build and push Docker ${{ inputs.tag }} image
uses: docker/build-push-action@v4
with:
context: .
file: ./api/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-api:${{ inputs.tag }}
push: true

- name: API - Build and push Docker latest image
uses: docker/build-push-action@v4
if: ${{ inputs.isRelease == 'true' }}
Expand All @@ -34,13 +85,15 @@ runs:
file: ./api/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-api:latest
push: true

- name: Indexer - Build and push Docker ${{ inputs.tag }} image
uses: docker/build-push-action@v4
with:
context: .
file: ./yaci-indexer/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-indexer:${{ inputs.tag }}
push: true

- name: Indexer - Build and push Docker latest image
uses: docker/build-push-action@v4
if: ${{ inputs.isRelease == 'true' }}
Expand All @@ -49,58 +102,39 @@ runs:
file: ./yaci-indexer/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-indexer:latest
push: true

- name: Cardano Node - Build and push Docker ${{ inputs.tag }} image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/dockerfiles/node/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-cardano-node:${{ inputs.tag }}
push: true
- name: Cardano Node - Build and push Docker latest image
uses: docker/build-push-action@v4
if: ${{ inputs.isRelease == 'true' }}
with:
context: .
file: ./docker/dockerfiles/node/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-cardano-node:latest
tags: cardanofoundation/cardano-rosetta-java-cardano-node:${{ steps.envver.outputs.node_version }}
push: true

- name: Postgres - Build and push Docker ${{ inputs.tag }} image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/dockerfiles/postgres/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-postgres:${{ inputs.tag }}
push: true
- name: Postgres - Build and push Docker latest image
uses: docker/build-push-action@v4
if: ${{ inputs.isRelease == 'true' }}
with:
context: .
file: ./docker/dockerfiles/postgres/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-postgres:latest
tags: cardanofoundation/cardano-rosetta-java-postgres:${{ steps.envver.outputs.pg_version }}
push: true

- name: Mithril - Build and push Docker ${{ inputs.tag }} image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/dockerfiles/mithril/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-mithril:${{ inputs.tag }}
push: true
- name: Mithril - Build and push Docker latest image
uses: docker/build-push-action@v4
if: ${{ inputs.isRelease == 'true' }}
with:
context: .
file: ./docker/dockerfiles/mithril/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-mithril:latest
tags: cardanofoundation/cardano-rosetta-java-mithril:${{ steps.envver.outputs.mithril_version }}
push: true

- name: All-in-one - Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile
tags: cardanofoundation/cardano-rosetta-java:${{ inputs.tag }}
push: true

- name: All-in-one - Build and push Docker latest image
uses: docker/build-push-action@v4
if: ${{ inputs.isRelease == 'true' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public List<Coin> mapUtxosToCoins(List<Utxo> utxos,
Amt adaAsset = utxo.getAmounts().stream()
.filter(amt -> Constants.LOVELACE.equals(amt.getUnit()))
.findFirst()
.orElseGet(() -> new Amt(null, null, Constants.ADA, BigInteger.ZERO));
.orElseGet(() -> new Amt(null, Constants.ADA, BigInteger.ZERO));

String coinIdentifier = "%s:%d".formatted(utxo.getTxHash(), utxo.getOutputIndex());

return Coin.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ public class Amt implements Serializable {
private String unit; // subject = policyId + hex(assetName)
private String policyId;

// TODO avoid using assetName field for now
// TODO ASCI in case of CIP-26 and bech32 in case of CIP-68, actually it should always be ASCII and never bech32
@Deprecated
// consider removing
private String assetName;

private BigInteger quantity;

/**
* Returns symbol as hex
*
* unit (subject) = policyId(hex) + symbol(hex)
*/
@Nullable
public String getAssetNameAsHex() {
return getSymbolHex();
}

/**
* Returns symbol as hex
*
Expand All @@ -45,10 +49,4 @@ public String getSymbolHex() {
return unit.replace(policyId, "");
}

@Deprecated
// TODO avoid using assetName field for now
public String getAssetName() {
return assetName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public final Condition buildCurrencyCondition(Currency currency) {
!"lovelace".equalsIgnoreCase(symbol) && !"ada".equalsIgnoreCase(symbol)) {
String escapedSymbol = symbol.trim().replace("\"", "\\\"");
return buildPolicyIdAndSymbolCondition(escapedPolicyId, escapedSymbol);
} else {
return buildPolicyIdOnlyCondition(escapedPolicyId);
}

return buildPolicyIdOnlyCondition(escapedPolicyId);
}

if (symbol != null && !symbol.trim().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,17 @@ public Page<TxnEntity> searchTxnEntitiesOR(Set<String> txHashes,

/**
* H2-specific currency condition builder using LIKE operator for JSON string matching.
* Searches by hex-encoded symbols in the unit field to support CIP-68 assets.
*/
private static class H2CurrencyConditionBuilder extends BaseCurrencyConditionBuilder {

@Override
protected Condition buildPolicyIdAndSymbolCondition(String escapedPolicyId, String escapedSymbol) {
// Search for unit field containing policyId+symbol (hex-encoded)
// unit = policyId + symbol where symbol is hex-encoded asset name
String expectedUnit = escapedPolicyId + escapedSymbol;
return DSL.condition("EXISTS (SELECT 1 FROM address_utxo au WHERE au.tx_hash = transaction.tx_hash " +
"AND au.amounts LIKE '%\"policy_id\":\"" + escapedPolicyId + "\"%' " +
"AND au.amounts LIKE '%\"asset_name\":\"" + escapedSymbol + "\"%')");
"AND au.amounts LIKE '%\"unit\":\"" + expectedUnit + "\"%')");
}

@Override
Expand All @@ -176,8 +179,12 @@ protected Condition buildLovelaceCondition() {

@Override
protected Condition buildSymbolOnlyCondition(String escapedSymbol) {
// Search for unit field containing the hex-encoded symbol
// Since unit = policyId + symbol, the unit will contain the symbol substring
// We need to exclude lovelace since it's a special case
return DSL.condition("EXISTS (SELECT 1 FROM address_utxo au WHERE au.tx_hash = transaction.tx_hash " +
"AND au.amounts LIKE '%\"asset_name\":\"" + escapedSymbol + "\"%')");
"AND au.amounts LIKE '%\"unit\":\"%" + escapedSymbol + "\"%' " +
"AND au.amounts NOT LIKE '%\"unit\":\"lovelace\"%')");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,14 @@ private Table<?> createValuesTable(Set<String> hashes) {
* PostgreSQL-specific currency condition builder using JSONB @> operator.
*/
private static class PostgreSQLCurrencyConditionBuilder extends BaseCurrencyConditionBuilder {

@Override
protected Condition buildPolicyIdAndSymbolCondition(String escapedPolicyId, String escapedSymbol) {
// Search for unit field containing policyId+symbol (hex-encoded)
// unit = policyId + symbol where symbol is hex-encoded asset name
String expectedUnit = escapedPolicyId + escapedSymbol;
return DSL.condition("EXISTS (SELECT 1 FROM address_utxo au WHERE au.tx_hash = transaction.tx_hash " +
"AND au.amounts::jsonb @> '[{\"policy_id\": \"" + escapedPolicyId + "\", \"asset_name\": \"" + escapedSymbol + "\"}]')");
"AND au.amounts::jsonb @> '[{\"unit\": \"" + expectedUnit + "\"}]')");
}

@Override
Expand All @@ -214,8 +217,14 @@ protected Condition buildLovelaceCondition() {

@Override
protected Condition buildSymbolOnlyCondition(String escapedSymbol) {
return DSL.condition("EXISTS (SELECT 1 FROM address_utxo au WHERE au.tx_hash = transaction.tx_hash " +
"AND au.amounts::jsonb @> '[{\"asset_name\": \"" + escapedSymbol + "\"}]')");
// Search for unit field ending with the hex-encoded symbol
// Since unit = policyId + symbol, we look for units that end with the symbol
// Using jsonb_array_elements to iterate through amounts array and check each unit
return DSL.condition("EXISTS (SELECT 1 FROM address_utxo au, " +
"jsonb_array_elements(au.amounts::jsonb) AS amt " +
"WHERE au.tx_hash = transaction.tx_hash " +
"AND amt->>'unit' LIKE '%" + escapedSymbol + "' " +
"AND amt->>'unit' != 'lovelace')");
}
}

Expand Down
Loading
Loading