Skip to content

Commit

Permalink
Fix missing round updates for stream transactions (#801)
Browse files Browse the repository at this point in the history
* add missing round update transactions to stream transactions endpoint.
  • Loading branch information
PawelPawelec-RDX authored Oct 11, 2024
1 parent caab8d4 commit f9b83ec
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 148 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Release built: _not released yet_
### Bug fixes
- Added missing `total_count` property to `/state/validators/list` response.
- Fix `/transaction/account-deposit-pre-validation` for uninstantiated pre-allocated accounts. It no longer returns error with code 404 `Entity not found`.
- Restored missing round update transactions from the `/stream/transactions` endpoint.

### API Changes
- Restored previously removed `total_count` property to `/state/key-value-store/keys` endpoint.
Expand Down Expand Up @@ -72,7 +73,8 @@ Release built: _not released yet_
- Key value store
- New `key_value_store_totals_history` table, which holds total count of all keys under a given store at a given state version.
- Changed `receipt_state_updates` in the `ledger_transactions` table to be nullable.
- Moved all `receipt_event_*` columns from `ledger_transactions` to separate `ledger_transaction_events` table.
- Moved all `receipt_event_*` columns from the `ledger_transactions` table to a new separate `ledger_transaction_events` table.
- Added new `origin_type` types (`Genesis`, `Flash`, and `RoundUpdate`) to the `ledger_transaction_markers` table.

## 1.7.3
Release built: 26.09.2024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@

using RadixDlt.NetworkGateway.Abstractions.Network;
using RadixDlt.NetworkGateway.PostgresIntegration.Models;
using System;
using System.Collections.Generic;
using FlashLedgerTransaction = RadixDlt.CoreApiSdk.Model.FlashLedgerTransaction;
using GenesisLedgerTransaction = RadixDlt.CoreApiSdk.Model.GenesisLedgerTransaction;
using RoundUpdateLedgerTransaction = RadixDlt.CoreApiSdk.Model.RoundUpdateLedgerTransaction;
using UserLedgerTransaction = RadixDlt.CoreApiSdk.Model.UserLedgerTransaction;

namespace RadixDlt.NetworkGateway.PostgresIntegration.LedgerExtension.Processors.LedgerTransactionMarkers;

Expand All @@ -91,16 +96,22 @@ public void VisitTransaction(CoreApiSdk.Model.CommittedTransaction committedTran
});
}

if (committedTransaction.LedgerTransaction is CoreApiSdk.Model.UserLedgerTransaction)
var origin = committedTransaction.LedgerTransaction switch
{
_ledgerTransactionMarkersToAdd.Add(
new OriginLedgerTransactionMarker
{
Id = _context.Sequences.LedgerTransactionMarkerSequence++,
StateVersion = stateVersion,
OriginType = LedgerTransactionMarkerOriginType.User,
});
}
FlashLedgerTransaction => LedgerTransactionMarkerOriginType.ProtocolUpdate,
GenesisLedgerTransaction => LedgerTransactionMarkerOriginType.Genesis,
RoundUpdateLedgerTransaction => LedgerTransactionMarkerOriginType.Validator,
UserLedgerTransaction => LedgerTransactionMarkerOriginType.User,
_ => throw new ArgumentOutOfRangeException($"Unexpected ledger transaction type: {committedTransaction.LedgerTransaction.GetType()}"),
};

_ledgerTransactionMarkersToAdd.Add(
new OriginLedgerTransactionMarker
{
Id = _context.Sequences.LedgerTransactionMarkerSequence++,
StateVersion = stateVersion,
OriginType = origin,
});
}

public IEnumerable<LedgerTransactionMarker> CreateTransactionMarkers()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
.Annotation("Npgsql:Enum:ledger_transaction_manifest_class", "general,transfer,validator_stake,validator_unstake,validator_claim,account_deposit_settings_update,pool_contribution,pool_redemption")
.Annotation("Npgsql:Enum:ledger_transaction_marker_event_type", "withdrawal,deposit")
.Annotation("Npgsql:Enum:ledger_transaction_marker_operation_type", "resource_in_use,account_deposited_into,account_withdrawn_from,account_owner_method_call,badge_presented")
.Annotation("Npgsql:Enum:ledger_transaction_marker_origin_type", "user,epoch_change")
.Annotation("Npgsql:Enum:ledger_transaction_marker_origin_type", "user,epoch_change,validator,protocol_update,genesis")
.Annotation("Npgsql:Enum:ledger_transaction_marker_type", "origin,event,manifest_address,affected_global_entity,manifest_class,event_global_emitter")
.Annotation("Npgsql:Enum:ledger_transaction_status", "succeeded,failed")
.Annotation("Npgsql:Enum:ledger_transaction_type", "genesis,user,round_update,flash")
Expand Down
Loading

0 comments on commit f9b83ec

Please sign in to comment.