Skip to content
Draft
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
5 changes: 2 additions & 3 deletions .github/workflows/pr-preprod-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ jobs:
# Output test result
echo "construction_result=${CONSTRUCTION_RESULT:-0}" >> $GITHUB_OUTPUT

# Don't fail the whole job if construction tests fail
# These are informational for now
exit 0
# Fail if construction tests failed
exit ${CONSTRUCTION_RESULT:-0}
env:
ROSETTA_URL: http://localhost:8082
CARDANO_NETWORK: preprod
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ hs_err_pid*
target
settings.xml
.env*
!.env.example

/data/
/node/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import java.math.BigInteger;
import java.util.*;

import static org.cardanofoundation.rosetta.common.util.Constants.ADA;
import static org.cardanofoundation.rosetta.common.util.Constants.ADA_DECIMALS;

@Component
@RequiredArgsConstructor
public class AccountMapperUtil {
Expand Down Expand Up @@ -76,7 +79,7 @@ public List<Coin> mapUtxosToCoins(List<Utxo> utxos,
Amt adaAsset = utxo.getAmounts().stream()
.filter(amt -> Constants.LOVELACE.equals(amt.getUnit()))
.findFirst()
.orElseGet(() -> new Amt(null, Constants.ADA, BigInteger.ZERO));
.orElseGet(() -> new Amt(null, ADA, BigInteger.ZERO));

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

Expand Down Expand Up @@ -144,8 +147,8 @@ private static int getDecimalsWithFallback(@NotNull TokenRegistryCurrencyData me

private CurrencyResponse getAdaCurrency() {
return CurrencyResponse.builder()
.symbol(Constants.ADA)
.decimals(Constants.ADA_DECIMALS)
.symbol(ADA)
.decimals(ADA_DECIMALS)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.math.BigInteger;
import java.util.List;
import jakarta.annotation.Nullable;
import jakarta.persistence.Column;
import jakarta.persistence.ConstraintMode;
import jakarta.persistence.Entity;
Expand Down Expand Up @@ -50,6 +51,10 @@ public class TxnEntity {
@Column(name = "fee")
private BigInteger fee;

@Column(name = "tx_index")
@Nullable
private Integer txIndex;

@OneToMany(mappedBy = "txHash")
private List<TxScriptEntity> script;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public List<TxnEntity> findTransactionsByBlockHash(String blockHash) {
TRANSACTION.OUTPUTS,
TRANSACTION.FEE,
TRANSACTION.SLOT,
TRANSACTION.TX_INDEX,
BLOCK.HASH.as("joined_block_hash"),
BLOCK.NUMBER.as("joined_block_number"),
BLOCK.SLOT.as("joined_block_slot"),
Expand All @@ -133,6 +134,7 @@ public List<TxnEntity> findTransactionsByBlockHash(String blockHash) {
.leftJoin(BLOCK).on(TRANSACTION.BLOCK_HASH.eq(BLOCK.HASH))
.leftJoin(TRANSACTION_SIZE).on(TRANSACTION.TX_HASH.eq(TRANSACTION_SIZE.TX_HASH))
.where(TRANSACTION.BLOCK_HASH.eq(blockHash))
.orderBy(TRANSACTION.TX_INDEX.asc())
.fetch(queryBuilder::mapRecordToTxnEntity);
}

Expand Down Expand Up @@ -182,12 +184,12 @@ protected int executeCountQuery(Condition conditions, @Nullable Boolean isSucces
* Ensures count and results queries use identical conditions and JOINs.
* Currency conditions use EXISTS subqueries - no JOIN needed.
*/
protected List<? extends org.jooq.Record> executeResultsQuery(Condition conditions,
@Nullable Boolean isSuccess,
protected List<? extends org.jooq.Record> executeResultsQuery(Condition conditions,
@Nullable Boolean isSuccess,
OffsetBasedPageRequest offsetBasedPageRequest) {
return buildBaseResultsQuery(isSuccess)
.where(conditions)
.orderBy(TRANSACTION.SLOT.desc())
.orderBy(TRANSACTION.SLOT.desc(), TRANSACTION.TX_INDEX.desc())
.limit(offsetBasedPageRequest.getLimit())
.offset(offsetBasedPageRequest.getOffset())
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ public interface CurrencyConditionBuilder {
Condition buildCurrencyCondition(Currency currency);
}

public SelectJoinStep<Record11<String, String, JSONB, JSONB, Long, Long, String, Long, Long, Integer, Integer>> buildTransactionSelectQuery(DSLContext dsl) {
public SelectJoinStep<Record12<String, String, JSONB, JSONB, Long, Long, Integer, String, Long, Long, Integer, Integer>> buildTransactionSelectQuery(DSLContext dsl) {
return dsl.select(
TRANSACTION.TX_HASH,
TRANSACTION.BLOCK_HASH,
TRANSACTION.INPUTS,
TRANSACTION.OUTPUTS,
TRANSACTION.FEE,
TRANSACTION.SLOT,
TRANSACTION.TX_INDEX,
BLOCK.HASH.as("joined_block_hash"),
BLOCK.NUMBER.as("joined_block_number"),
BLOCK.SLOT.as("joined_block_slot"),
Expand Down Expand Up @@ -161,6 +162,8 @@ public TxnEntity mapRecordToTxnEntity(org.jooq.Record record) {
@Nullable BigInteger fee = Optional.ofNullable(record.get(TRANSACTION.FEE))
.map(BigInteger::valueOf).orElse(null);

@Nullable Integer txIndex = record.get(TRANSACTION.TX_INDEX);

@Nullable BlockEntity blockEntity = null;
String blockHashFromRecord = record.get("joined_block_hash", String.class);
if (blockHashFromRecord != null) {
Expand All @@ -178,6 +181,7 @@ public TxnEntity mapRecordToTxnEntity(org.jooq.Record record) {
.inputKeys(readUtxoKeys(inputs, txHash))
.outputKeys(readUtxoKeys(outputs, txHash))
.fee(fee)
.txIndex(txIndex)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class CardanoConstructionServiceImpl implements CardanoConstructionServic

private final LedgerBlockService ledgerBlockService;
private final ProtocolParamService protocolParamService;
private final OperationService operationService;
private final TransactionOperationParser transactionOperationParser;
private final RestTemplate restTemplate;
private final OfflineSlotService offlineSlotService;

Expand All @@ -89,22 +89,27 @@ public class CardanoConstructionServiceImpl implements CardanoConstructionServic
@Override
public TransactionParsed parseTransaction(Network network, String transaction, boolean signed) {
Array decodeTransaction = decodeTransaction(transaction);

try {
TransactionData convertedTr = CborArrayToTransactionData.convert(decodeTransaction, signed);
List<Operation> operations = operationService.getOperationsFromTransactionData(convertedTr, network);
List<Operation> operations = transactionOperationParser.getOperationsFromTransactionData(convertedTr, network);
List<AccountIdentifier> accountIdentifierSigners = new ArrayList<>();

if (signed) {
log.info("[parseSignedTransaction] About to get signatures from parsed transaction");
List<String> accumulator = convertedTr.transactionExtraData().operations().stream()
.map(o -> operationService.getSignerFromOperation(network, o))
.map(o -> transactionOperationParser.getSignerFromOperation(network, o))
.flatMap(List::stream)
.toList();

accountIdentifierSigners = getUniqueAccountIdentifiers(accumulator);
}

return new TransactionParsed(operations, accountIdentifierSigners);
} catch (CborException | CborDeserializationException | CborSerializationException error) {
log.error("{} [parseTransaction] Cant instantiate transaction from transaction bytes",
error.getMessage(), error);

throw ExceptionFactory.invalidTransactionError();
}
}
Expand Down Expand Up @@ -624,7 +629,7 @@ private TransactionBody deserializeTransactionBody(String unsignedTransaction) {
private List<AccountIdentifier> getUniqueAccountIdentifiers(List<String> addresses) {
return new HashSet<>(addresses)
.stream()
.map(s -> new AccountIdentifier(s, null, null))
.map(address -> new AccountIdentifier(address, null, null))
.toList();
}

Expand Down

This file was deleted.

Loading
Loading