Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not index manifest for failed transactions #799

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Release built: _not released yet_

> [!CAUTION]
> **Breaking Changes:**
> - Manifest addresses are no longer indexed in the `/stream/transactions` endpoint for failed transactions. Affected filters:
> - `manifest_accounts_withdrawn_from_filter`
> - `manifest_accounts_deposited_into_filter`
> - `manifest_badges_presented_filter`
> - `manifest_resources_filter`
> - `accounts_with_manifest_owner_method_calls`
> - `accounts_without_manifest_owner_method_calls`
> - Changed ordering of entity metadata. Entries are no longer ordered by their last modification state version but rather by their first appearance on the network, descending. Affected endpoints:
> - `/state/entity/metadata`
> - `/state/entity/page/metadata`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static GatewayApiBuilder AddPostgresPersistenceCore(this GatewayApiBuilde
.AddScoped<IValidatorQuerier, ValidatorQuerier>()
.AddScoped<IPackageQuerier, PackageQuerier>()
.AddScoped<IEntityQuerier, EntityQuerier>()
.AddScoped<IVirtualEntityDataProvider, VirtualEntityDataProvider>()
.AddScoped<IPreAllocatedEntityDataProvider, PreAllocatedEntityDataProvider>()
.AddScoped<ISubmissionTrackingService, SubmissionTrackingService>()
.AddScoped<IDapperWrapper, DapperWrapper>()
.AddSingleton<MetricsInterceptor>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
*/

using RadixDlt.NetworkGateway.Abstractions;
using RadixDlt.NetworkGateway.Abstractions.Model;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand All @@ -74,28 +75,30 @@ internal static class ManifestAddressesExtractor
{
internal record PresentedProof(EntityAddress AccountAddress, EntityAddress ResourceAddress);

internal record AddressWithEntityType(ToolkitModel.EntityType EntityType, EntityAddress Address);

internal record ManifestAddresses(
List<EntityAddress> PackageAddresses,
List<EntityAddress> ComponentAddresses,
List<EntityAddress> ResourceAddresses,
List<EntityAddress> AccountAddresses,
List<EntityAddress> AccountsRequiringAuth,
List<EntityAddress> AccountsWithdrawnFrom,
List<EntityAddress> AccountsDepositedInto,
List<EntityAddress> IdentityAddresses,
List<EntityAddress> IdentitiesRequiringAuth,
List<AddressWithEntityType> AccountAddresses,
List<AddressWithEntityType> AccountsRequiringAuth,
List<AddressWithEntityType> AccountsWithdrawnFrom,
List<AddressWithEntityType> AccountsDepositedInto,
List<AddressWithEntityType> IdentityAddresses,
List<AddressWithEntityType> IdentitiesRequiringAuth,
List<PresentedProof> PresentedProofs)
{
public List<EntityAddress> All() =>
PackageAddresses
.Concat(ComponentAddresses)
.Concat(ResourceAddresses)
.Concat(AccountAddresses)
.Concat(AccountsRequiringAuth)
.Concat(AccountsWithdrawnFrom)
.Concat(AccountsDepositedInto)
.Concat(IdentityAddresses)
.Concat(IdentitiesRequiringAuth)
.Concat(AccountAddresses.Select(x => x.Address))
.Concat(AccountsRequiringAuth.Select(x => x.Address))
.Concat(AccountsWithdrawnFrom.Select(x => x.Address))
.Concat(AccountsDepositedInto.Select(x => x.Address))
.Concat(IdentityAddresses.Select(x => x.Address))
.Concat(IdentitiesRequiringAuth.Select(x => x.Address))
.Concat(PresentedProofs.Select(x => x.AccountAddress))
.Concat(PresentedProofs.Select(x => x.ResourceAddress))
.Distinct()
Expand All @@ -109,28 +112,42 @@ public static ManifestAddresses ExtractAddresses(ToolkitModel.TransactionManifes
var manifestSummary = manifest.Summary(networkId);

var presentedProofs = ExtractProofs(manifestSummary.presentedProofs);
var accountsRequiringAuth = manifestSummary.accountsRequiringAuth.Select(x => (EntityAddress)x.AddressString()).ToList();
var accountsWithdrawnFrom = manifestSummary.accountsWithdrawnFrom.Select(x => (EntityAddress)x.AddressString()).ToList();
var accountsDepositedInto = manifestSummary.accountsDepositedInto.Select(x => (EntityAddress)x.AddressString()).ToList();
var identitiesRequiringAuth = manifestSummary.identitiesRequiringAuth.Select(x => (EntityAddress)x.AddressString()).ToList();
var accountsRequiringAuth = manifestSummary.accountsRequiringAuth.Select(x => new AddressWithEntityType(x.EntityType(), (EntityAddress)x.AddressString())).ToList();
var accountsWithdrawnFrom = manifestSummary.accountsWithdrawnFrom.Select(x => new AddressWithEntityType(x.EntityType(), (EntityAddress)x.AddressString())).ToList();
var accountsDepositedInto = manifestSummary.accountsDepositedInto.Select(x => new AddressWithEntityType(x.EntityType(), (EntityAddress)x.AddressString())).ToList();
var identitiesRequiringAuth = manifestSummary.identitiesRequiringAuth.Select(x => new AddressWithEntityType(x.EntityType(), (EntityAddress)x.AddressString())).ToList();

var packageAddresses = allAddresses
.Where(x => x.Key == ToolkitModel.EntityType.GlobalPackage)
.SelectMany(x => x.Value.Select(y => (EntityAddress)y.AddressString()))
.ToList();

var packageAddresses = allAddresses.Where(x => x.Key == ToolkitModel.EntityType.GlobalPackage).SelectMany(x => x.Value.Select(y => (EntityAddress)y.AddressString())).ToList();
var componentAddresses = allAddresses
.Where(x => x.Key is ToolkitModel.EntityType.GlobalGenericComponent or ToolkitModel.EntityType.InternalGenericComponent)
.SelectMany(x => x.Value.Select(y => (EntityAddress)y.AddressString()))
.ToList();

var resourceAddresses = allAddresses
.Where(x => x.Key is ToolkitModel.EntityType.GlobalFungibleResourceManager or ToolkitModel.EntityType.GlobalNonFungibleResourceManager)
.SelectMany(x => x.Value.Select(y => (EntityAddress)y.AddressString()))
.ToList();

var accountAddresses = allAddresses
.Where(x => x.Key is ToolkitModel.EntityType.GlobalAccount or ToolkitModel.EntityType.GlobalVirtualEd25519Account
or ToolkitModel.EntityType.GlobalVirtualSecp256k1Account)
.SelectMany(x => x.Value.Select(y => (EntityAddress)y.AddressString()))
.Where(
x => x.Key
PawelPawelec-RDX marked this conversation as resolved.
Show resolved Hide resolved
is ToolkitModel.EntityType.GlobalAccount
or ToolkitModel.EntityType.GlobalVirtualEd25519Account
or ToolkitModel.EntityType.GlobalVirtualSecp256k1Account)
.SelectMany(x => x.Value.Select(y => new AddressWithEntityType(y.EntityType(), (EntityAddress)y.AddressString())))
.ToList();

var identityAddresses = allAddresses
.Where(x => x.Key is ToolkitModel.EntityType.GlobalIdentity or ToolkitModel.EntityType.GlobalVirtualEd25519Identity or ToolkitModel.EntityType.GlobalVirtualSecp256k1Identity)
.SelectMany(x => x.Value.Select(y => (EntityAddress)y.AddressString()))
.Where(
x => x.Key
is ToolkitModel.EntityType.GlobalIdentity
or ToolkitModel.EntityType.GlobalVirtualEd25519Identity
or ToolkitModel.EntityType.GlobalVirtualSecp256k1Identity)
.SelectMany(x => x.Value.Select(y => new AddressWithEntityType(y.EntityType(), (EntityAddress)y.AddressString())))
.ToList();

return new ManifestAddresses(
Expand Down Expand Up @@ -159,18 +176,18 @@ private static List<PresentedProof> ExtractProofs(Dictionary<string, ToolkitMode
switch (proof)
{
case ToolkitModel.ResourceSpecifier.Amount fungibleProof:
{
var resourceAddress = (EntityAddress)fungibleProof.resourceAddress.AddressString();
mapped.Add(new PresentedProof(accountAddress, resourceAddress));
break;
}
{
var resourceAddress = (EntityAddress)fungibleProof.resourceAddress.AddressString();
mapped.Add(new PresentedProof(accountAddress, resourceAddress));
break;
}

case ToolkitModel.ResourceSpecifier.Ids nonFungibleProof:
{
var resourceAddress = (EntityAddress)nonFungibleProof.resourceAddress.AddressString();
mapped.Add(new PresentedProof(accountAddress, resourceAddress));
break;
}
{
var resourceAddress = (EntityAddress)nonFungibleProof.resourceAddress.AddressString();
mapped.Add(new PresentedProof(accountAddress, resourceAddress));
break;
}

default:
throw new UnreachableException($"Unexpected proof type {proof.GetType()}");
Expand Down
Loading
Loading