Skip to content

Commit fd7df3c

Browse files
authored
Feat/ra 32 adjust stores to reduce data footprint (#125)
* feat: removed unused data from block, account, transaction and utxo * feat: removed unused data from other used stores * chore: removed epoch mapper for testing purposes * chore: adjusted yaci-store version * chore: adjusted yaci-store version * chore: fixed yaci indexing issues due to missing fields. * chore: added txhash to withdrawalEntity * updated fields * updated fields * updated fields * removed policyID and assetname from account_balance * removed policyID and assetname from account_balance * feat: removed all unused fields * chore: updated test to use right fees * Chore: removed unused file and added epoch to blockResponse
1 parent e61725a commit fd7df3c

File tree

52 files changed

+290
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+290
-480
lines changed

api/src/main/java/org/cardanofoundation/rosetta/api/account/model/domain/AddressBalance.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ public record AddressBalance(String address,
1111
String unit,
1212
Long slot,
1313
BigInteger quantity,
14-
String policy,
15-
String assetName) {
14+
Long number) {
1615

1716
public static AddressBalance fromEntity(AddressBalanceEntity addressBalanceEntity) {
1817
return AddressBalance.builder()
19-
.assetName(addressBalanceEntity.getAssetName())
2018
.address(addressBalanceEntity.getAddress())
2119
.unit(addressBalanceEntity.getUnit())
2220
.slot(addressBalanceEntity.getSlot())
2321
.quantity(addressBalanceEntity.getQuantity())
24-
.policy(addressBalanceEntity.getPolicy())
22+
.number(addressBalanceEntity.getBlockNumber())
2523
.build();
2624
}
2725
}

api/src/main/java/org/cardanofoundation/rosetta/api/account/model/domain/Utxo.java

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,8 @@ public class Utxo {
1919

2020
private String txHash;
2121
private Integer outputIndex;
22-
private Long slot;
23-
private String blockHash;
24-
private Integer epoch;
2522
private String ownerAddr;
26-
private String ownerAddrFull;
27-
private String ownerStakeAddr;
28-
private String ownerPaymentCredential;
29-
private String ownerStakeCredential;
30-
private BigInteger lovelaceAmount;
3123
private List<Amt> amounts;
32-
private String dataHash;
33-
private String inlineDatum;
34-
private String scriptRef;
35-
private String referenceScriptHash;
36-
private Boolean isCollateralReturn;
3724

3825
public Utxo(String txHash, Integer outputIndex) {
3926
this.txHash = txHash;
@@ -45,20 +32,9 @@ public static Utxo fromUtxoKey(UtxoKey utxoKey) {
4532
}
4633

4734
public void populateFromUtxoEntity(AddressUtxoEntity entity) {
48-
this.slot = entity.getSlot();
49-
this.blockHash = entity.getBlockHash();
50-
this.epoch = entity.getEpoch();
35+
this.txHash = entity.getTxHash();
36+
this.outputIndex = entity.getOutputIndex();
5137
this.ownerAddr = entity.getOwnerAddr();
52-
this.ownerAddrFull = entity.getOwnerAddrFull();
53-
this.ownerStakeAddr = entity.getOwnerStakeAddr();
54-
this.ownerPaymentCredential = entity.getOwnerPaymentCredential();
55-
this.ownerStakeCredential = entity.getOwnerStakeCredential();
56-
this.lovelaceAmount = entity.getLovelaceAmount();
5738
this.amounts = entity.getAmounts();
58-
this.dataHash = entity.getDataHash();
59-
this.inlineDatum = entity.getInlineDatum();
60-
this.scriptRef = entity.getScriptRef();
61-
this.referenceScriptHash = entity.getReferenceScriptHash();
62-
this.isCollateralReturn = entity.getIsCollateralReturn();
6339
}
6440
}

api/src/main/java/org/cardanofoundation/rosetta/api/account/model/entity/AddressBalanceEntity.java

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
import org.cardanofoundation.rosetta.api.block.model.entity.BlockAwareEntity;
1919

2020
@Data
21-
@EqualsAndHashCode(callSuper = true)
2221
@NoArgsConstructor
2322
@AllArgsConstructor
2423
@SuperBuilder
2524
@Entity
2625
@Table(name = "address_balance")
2726
@IdClass(AddressBalanceId.class)
2827
@DynamicUpdate
29-
public class AddressBalanceEntity extends BlockAwareEntity {
28+
public class AddressBalanceEntity {
3029

3130
@Id
3231
@Column(name = "address")
@@ -43,26 +42,6 @@ public class AddressBalanceEntity extends BlockAwareEntity {
4342
@Column(name = "quantity")
4443
private BigInteger quantity;
4544

46-
//Only set if address doesn't fit in ownerAddr field. Required for few Byron Era addr
47-
@Column(name = "addr_full")
48-
private String addrFull;
49-
50-
@Column(name = "policy")
51-
private String policy;
52-
53-
@Column(name = "asset_name")
54-
private String assetName;
55-
56-
@Column(name = "payment_credential")
57-
private String paymentCredential;
58-
59-
@Column(name = "stake_address")
60-
private String stakeAddress;
61-
62-
@Column(name = "block_hash")
63-
private String blockHash;
64-
65-
@Column(name = "epoch")
66-
private Integer epoch;
67-
45+
@Column(name = "block")
46+
private Long blockNumber;
6847
}

api/src/main/java/org/cardanofoundation/rosetta/api/account/model/entity/AddressUtxoEntity.java

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@
1919
import org.hibernate.annotations.Type;
2020

2121
import org.cardanofoundation.rosetta.api.account.model.domain.Amt;
22-
import org.cardanofoundation.rosetta.api.block.model.entity.BlockAwareEntity;
2322

2423
@Data
25-
@EqualsAndHashCode(callSuper = true)
2624
@NoArgsConstructor
2725
@AllArgsConstructor
2826
@SuperBuilder
2927
@Entity
3028
@Table(name = "address_utxo")
3129
@IdClass(UtxoId.class)
3230
@DynamicUpdate
33-
public class AddressUtxoEntity extends BlockAwareEntity {
31+
public class AddressUtxoEntity {
3432

3533
@Id
3634
@Column(name = "tx_hash")
@@ -40,49 +38,9 @@ public class AddressUtxoEntity extends BlockAwareEntity {
4038
@Column(name = "output_index")
4139
private Integer outputIndex;
4240

43-
@Column(name = "slot")
44-
private Long slot;
45-
46-
@Column(name = "block_hash")
47-
private String blockHash;
48-
49-
@Column(name = "epoch")
50-
private Integer epoch;
51-
5241
@Column(name = "owner_addr")
5342
private String ownerAddr;
5443

55-
//Only set if address doesn't fit in ownerAddr field. Required for few Byron Era addr
56-
@Column(name = "owner_addr_full")
57-
private String ownerAddrFull;
58-
59-
@Column(name = "owner_stake_addr")
60-
private String ownerStakeAddr;
61-
62-
@Column(name = "owner_payment_credential")
63-
private String ownerPaymentCredential;
64-
65-
@Column(name = "owner_stake_credential")
66-
private String ownerStakeCredential;
67-
68-
@Column(name = "lovelace_amount")
69-
private BigInteger lovelaceAmount;
70-
7144
@Type(JsonType.class)
7245
private List<Amt> amounts;
73-
74-
@Column(name = "data_hash")
75-
private String dataHash;
76-
77-
@Column(name = "inline_datum")
78-
private String inlineDatum;
79-
80-
@Column(name = "script_ref")
81-
private String scriptRef;
82-
83-
@Column(name = "reference_script_hash")
84-
private String referenceScriptHash;
85-
86-
@Column(name = "is_collateral_return")
87-
private Boolean isCollateralReturn;
8846
}

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/StakeAddressBalanceEntity.java renamed to api/src/main/java/org/cardanofoundation/rosetta/api/account/model/entity/StakeAddressBalanceEntity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.cardanofoundation.rosetta.api.block.model.entity;
1+
package org.cardanofoundation.rosetta.api.account.model.entity;
22

33
import java.math.BigInteger;
44
import jakarta.persistence.Column;
@@ -12,6 +12,7 @@
1212
import lombok.NoArgsConstructor;
1313
import lombok.experimental.SuperBuilder;
1414

15+
import org.cardanofoundation.rosetta.api.block.model.entity.BlockAwareEntity;
1516
import org.hibernate.annotations.DynamicUpdate;
1617

1718
@Data

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/StakeAddressBalanceId.java renamed to api/src/main/java/org/cardanofoundation/rosetta/api/account/model/entity/StakeAddressBalanceId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.cardanofoundation.rosetta.api.block.model.entity;
1+
package org.cardanofoundation.rosetta.api.account.model.entity;
22

33
import java.io.Serializable;
44
import jakarta.persistence.Column;

api/src/main/java/org/cardanofoundation/rosetta/api/account/model/repository/AddressBalanceRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface AddressBalanceRepository extends
1818
// "WHERE b.address = :address AND b.blockNumber <= :number " +
1919
// "GROUP BY b.address, b.unit, b.quantity, b.addrFull, b.policy, b.assetName, b.paymentCredential, b.stakeAddress, b.blockHash, b.epoch")
2020
@Query(value =
21-
"SELECT b from AddressBalanceEntity b WHERE b.slot in (SELECT MAX(c.slot) FROM AddressBalanceEntity c WHERE c.address = :address AND c.blockNumber <= :number GROUP BY c.unit) AND b.address = :address")
21+
"SELECT b from AddressBalanceEntity b WHERE b.blockNumber in (SELECT MAX(c.blockNumber) FROM AddressBalanceEntity c WHERE c.address = :address AND c.blockNumber <= :number GROUP BY c.unit) AND b.address = :address")
2222
List<AddressBalanceEntity> findAddressBalanceByAddressAndBlockNumber(
2323
@Param("address") String address, @Param("number") Long number);
2424
}

api/src/main/java/org/cardanofoundation/rosetta/api/account/model/repository/AddressUtxoRepository.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111

1212
public interface AddressUtxoRepository extends JpaRepository<AddressUtxoEntity, UtxoId> {
1313

14-
@Query(value =
15-
"SELECT a FROM AddressUtxoEntity a WHERE a.ownerAddr = :address AND a.blockHash = :blockHash")
16-
List<AddressUtxoEntity> findUtxoByAddressAndBlock(@Param("address") String address,
17-
@Param("blockHash") String blockHash);
18-
1914
List<AddressUtxoEntity> findAddressUtxoEntitiesByOutputIndexAndTxHash(Integer outputIndex,
2015
String txHash);
2116

api/src/main/java/org/cardanofoundation/rosetta/api/block/mapper/BlockToBlockResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public BlockResponse toDto(Block model) {
5151
.transactionsCount(source.getTransactionsCount())
5252
.createdBy(source.getCreatedBy())
5353
.size(source.getSize())
54-
.epochNo(source.getEpochNo())
5554
.slotNo(source.getSlotNo())
55+
.epochNo(source.getEpochNo())
5656
.build()
5757
);
5858

api/src/main/java/org/cardanofoundation/rosetta/api/block/mapper/BlockToEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public Block fromEntity(BlockEntity entity) {
2929

3030
mapper.map(BlockEntity::getSlotLeader, Block::setCreatedBy);
3131
mapper.map(BlockEntity::getNoOfTxs, Block::setTransactionsCount);
32-
mapper.map(BlockEntity::getEpochNumber, Block::setEpochNo);
3332
mapper.map(BlockEntity::getSlot, Block::setSlotNo);
33+
mapper.map(BlockEntity::getEpochNumber, Block::setEpochNo);
3434

3535
})
3636
.setPostConverter(ctx -> {

api/src/main/java/org/cardanofoundation/rosetta/api/block/mapper/BlockTxToEntity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public BlockTx fromEntity(TxnEntity model) {
3131
mapper.map(tx -> 0L, BlockTx::setSize); // will be calcualted, within the population method
3232
mapper.map(tx -> 0L, BlockTx::setScriptSize); // TODO Needs to be calulated if needed
3333

34-
mapper.map(TxnEntity::getInvalid, BlockTx::setValidContract);
35-
3634
})
3735
.setPostConverter(ctx -> {
3836
TxnEntity source = ctx.getSource();

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/Block.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public class Block {
1919
private String previousBlockHash;
2020
private Long previousBlockNumber;
2121
private Long transactionsCount;
22+
private Integer epochNo;
2223
private String createdBy;
2324
private Integer size;
24-
private Integer epochNo;
2525
private Long slotNo;
2626
private List<BlockTx> transactions;
2727
private String poolDeposit;

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/BlockTx.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ public class BlockTx {
2121
protected String hash;
2222
protected String blockHash;
2323
protected Long blockNo;
24-
protected String fee;
24+
protected String fee; // TODO can be removed if we found another way to calculate the size
2525
protected Long size;
26-
protected Boolean validContract;
2726
protected Long scriptSize;
2827
protected List<Utxo> inputs;
2928
protected List<Utxo> outputs;

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/Delegation.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,14 @@ public class Delegation {
1515

1616
private String poolId;
1717

18-
private String credential;
19-
2018
private String address;
2119

22-
private Integer epoch;
23-
24-
private Long slot;
25-
26-
private String blockHash;
27-
2820
public static Delegation fromEntity(DelegationEntity entity) {
2921
return Delegation.builder()
3022
.txHash(entity.getTxHash())
3123
.certIndex(entity.getCertIndex())
3224
.poolId(entity.getPoolId())
33-
.credential(entity.getCredential())
3425
.address(entity.getAddress())
35-
.epoch(entity.getEpoch())
36-
.slot(entity.getSlot())
37-
.blockHash(entity.getBlockHash())
3826
.build();
3927
}
4028
}

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/PoolRegistration.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
public class PoolRegistration {
1515

1616
private String txHash;
17-
private long certIndex;
17+
private int certIndex;
1818
private String poolId;
1919
private String vrfKeyHash;
2020
private String pledge;
@@ -23,9 +23,6 @@ public class PoolRegistration {
2323
private String rewardAccount;
2424
private Set<String> owners;
2525
private List<Relay> relays;
26-
private Integer epoch;
27-
private Long slot;
28-
private String blockHash;
2926

3027
public static PoolRegistration fromEntity(PoolRegistrationEnity entity) {
3128
return PoolRegistration.builder()
@@ -41,9 +38,6 @@ public static PoolRegistration fromEntity(PoolRegistrationEnity entity) {
4138
relay -> new Relay(relay.getIpv4(), relay.getIpv6(), relay.getDnsName(),
4239
relay.getPort(), "")).toList()) // TODO check type
4340
.owners(entity.getPoolOwners())
44-
.epoch(entity.getEpoch())
45-
.slot(entity.getSlot())
46-
.blockHash(entity.getBlockHash())
4741
.build();
4842
}
4943
}

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/PoolRetirement.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,18 @@ public class PoolRetirement {
1111

1212
private String txHash;
1313

14-
private long certIndex;
14+
private int certIndex;
1515

1616
private String poolId;
1717

1818
private Integer epoch;
1919

20-
private Long slot;
21-
22-
private String blockHash;
23-
2420
public static PoolRetirement fromEntity(PoolRetirementEntity entity) {
2521
return PoolRetirement.builder()
2622
.txHash(entity.getTxHash())
2723
.certIndex(entity.getCertIndex())
2824
.poolId(entity.getPoolId())
2925
.epoch(entity.getEpoch())
30-
.slot(entity.getSlot())
31-
.blockHash(entity.getBlockHash())
3226
.build();
3327
}
3428
}

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/StakeAddressBalance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import lombok.Builder;
66
import lombok.Data;
77

8-
import org.cardanofoundation.rosetta.api.block.model.entity.StakeAddressBalanceEntity;
8+
import org.cardanofoundation.rosetta.api.account.model.entity.StakeAddressBalanceEntity;
99

1010
@Data
1111
@Builder

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/domain/StakeRegistration.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,16 @@ public class StakeRegistration {
1515

1616
private long certIndex;
1717

18-
private String credential;
19-
2018
private CertificateType type;
2119

2220
private String address;
2321

24-
private Integer epoch;
25-
26-
private Long slot;
27-
28-
private String blockHash;
29-
3022
public static StakeRegistration fromEntity(StakeRegistrationEntity entity) {
3123
return StakeRegistration.builder()
3224
.txHash(entity.getTxHash())
3325
.certIndex(entity.getCertIndex())
34-
.credential(entity.getCredential())
3526
.type(entity.getType())
3627
.address(entity.getAddress())
37-
.epoch(entity.getEpoch())
38-
.slot(entity.getSlot())
39-
.blockHash(entity.getBlockHash())
4028
.build();
4129
}
4230
}

0 commit comments

Comments
 (0)