From ffc0c6eac1dd2b950dd198ecabdf8f355d00211b Mon Sep 17 00:00:00 2001 From: Ajinkya <145996984+ajinkyaraj-23@users.noreply.github.com> Date: Mon, 2 Sep 2024 11:14:41 +0100 Subject: [PATCH] update shards count in dal commitment status (#23) * Add ShardsAttested and Attested (bool) field in DalCommitmentStatus * update cumulative attestations received from all bakers for a Dal commitment * Add API endpoints for cumulative DAL commitment status * Use cache services for dalcommitmentstatus in UpdateDalCommitmentStatus * Cache the dal attestation data for this level. * Revert status update made to DalCommitmentStatus due to this block. --- Tzkt.Api/Models/Dal/DalCommitment.cs | 10 + Tzkt.Api/Repositories/DalRepository.cs | 229 +- ...2210_DalCommitmentStatusUpdate.Designer.cs | 7040 +++++++++++++++++ ...0240814142210_DalCommitmentStatusUpdate.cs | 40 + .../Migrations/TzktContextModelSnapshot.cs | 6 + Tzkt.Data/Models/Dal/DalCommitmentStatus.cs | 4 +- .../Handlers/Proto19/Commits/BlockCommit.cs | 48 +- .../Commits/Operations/EndorsementsCommit.cs | 7 + .../Handlers/Proto19/Proto19Handler.cs | 2 + .../Handlers/Proto20/Proto20Handler.cs | 2 + Tzkt.Sync/Services/Cache/CacheService.cs | 3 + .../Services/Cache/DalAttestationsCache.cs | 47 + .../Cache/DalCommitmentStatusCache.cs | 17 +- 13 files changed, 7375 insertions(+), 80 deletions(-) create mode 100644 Tzkt.Data/Migrations/20240814142210_DalCommitmentStatusUpdate.Designer.cs create mode 100644 Tzkt.Data/Migrations/20240814142210_DalCommitmentStatusUpdate.cs create mode 100644 Tzkt.Sync/Services/Cache/DalAttestationsCache.cs diff --git a/Tzkt.Api/Models/Dal/DalCommitment.cs b/Tzkt.Api/Models/Dal/DalCommitment.cs index fe224a58..7af3e497 100644 --- a/Tzkt.Api/Models/Dal/DalCommitment.cs +++ b/Tzkt.Api/Models/Dal/DalCommitment.cs @@ -21,5 +21,15 @@ public class DalCommitment /// Information about the account who has published the commitment. /// public Alias Publisher { get; set; } + + /// + /// Total number of Shards attested by the delegates for this commitment + /// + public int ShardsAttested { get; set; } + + /// + /// Attestation successful for the commitment + /// + public bool Attested { get; set; } } } diff --git a/Tzkt.Api/Repositories/DalRepository.cs b/Tzkt.Api/Repositories/DalRepository.cs index f535126a..6678a2f5 100644 --- a/Tzkt.Api/Repositories/DalRepository.cs +++ b/Tzkt.Api/Repositories/DalRepository.cs @@ -50,10 +50,10 @@ public async Task> GetCommitments( int limit) { var sql = new SqlBuilder($""" - SELECT op.* - FROM "DalCommitmentStatus" AS dc - INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" - """) + SELECT op.*, dc."ShardsAttested", dc."Attested" + FROM "DalCommitmentStatus" AS dc + INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" + """) .FilterA(@"op.""Commitment""", hash) .FilterA(@"op.""Level""", level) .FilterA(@"op.""Slot""", slotIndex) @@ -72,7 +72,9 @@ SELECT op.* Level = row.Level, SlotIndex = row.Slot, Hash = row.Commitment, - Publisher = Accounts.GetAlias(row.SenderId) + Publisher = Accounts.GetAlias(row.SenderId), + ShardsAttested = row.ShardsAttested, + Attested = row.Attested }); } @@ -92,10 +94,24 @@ public async Task GetCommitments( { switch (field) { - case "level": columns.Add(@"op.""Level"""); break; - case "slotIndex": columns.Add(@"op.""Slot"""); break; - case "hash": columns.Add(@"op.""Commitment"""); break; - case "publisher": columns.Add(@"op.""SenderId"""); break; + case "level": + columns.Add(@"op.""Level"""); + break; + case "slotIndex": + columns.Add(@"op.""Slot"""); + break; + case "hash": + columns.Add(@"op.""Commitment"""); + break; + case "publisher": + columns.Add(@"op.""SenderId"""); + break; + case "shardsAttested": + columns.Add(@"dc.""ShardsAttested"""); + break; + case "attested": + columns.Add(@"dc.""Attested"""); + break; } } @@ -103,10 +119,10 @@ public async Task GetCommitments( return Array.Empty(); var sql = new SqlBuilder($""" - SELECT {string.Join(',', columns)} - FROM "DalCommitmentStatus" AS dc - INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" - """) + SELECT {string.Join(',', columns)} + FROM "DalCommitmentStatus" AS dc + INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" + """) .FilterA(@"op.""Commitment""", hash) .FilterA(@"op.""Level""", level) .FilterA(@"op.""Slot""", slotIndex) @@ -114,7 +130,7 @@ public async Task GetCommitments( .Take(new Pagination { sort = sort, offset = offset, limit = limit }, x => x switch { "slotIndex" => (@"op.""Slot""", @"op.""Slot"""), - "level" or _ => (@"op.""Level""", @"op.""Level""") + "level" or _ => (@"op.""Level""", @"op.""Level""") }, @"op.""Level"""); await using var db = await DataSource.OpenConnectionAsync(); @@ -144,6 +160,14 @@ public async Task GetCommitments( foreach (var row in rows) result[j++][i] = Accounts.GetAlias(row.SenderId); break; + case "shardsAttested": + foreach (var row in rows) + result[j++][i] = row.ShardsAttested; + break; + case "attested": + foreach (var row in rows) + result[j++][i] = row.Attested; + break; } } @@ -164,20 +188,34 @@ public async Task GetCommitments( switch (field) { - case "level": columns.Add(@"op.""Level"""); break; - case "slotIndex": columns.Add(@"op.""Slot"""); break; - case "hash": columns.Add(@"op.""Commitment"""); break; - case "publisher": columns.Add(@"op.""SenderId"""); break; + case "level": + columns.Add(@"op.""Level"""); + break; + case "slotIndex": + columns.Add(@"op.""Slot"""); + break; + case "hash": + columns.Add(@"op.""Commitment"""); + break; + case "publisher": + columns.Add(@"op.""SenderId"""); + break; + case "shardsAttested": + columns.Add(@"dc.""ShardsAttested"""); + break; + case "attested": + columns.Add(@"dc.""Attested"""); + break; } if (columns.Count == 0) return Array.Empty(); var sql = new SqlBuilder($""" - SELECT {string.Join(',', columns)} - FROM "DalCommitmentStatus" AS dc - INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" - """) + SELECT {string.Join(',', columns)} + FROM "DalCommitmentStatus" AS dc + INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" + """) .FilterA(@"op.""Commitment""", hash) .FilterA(@"op.""Level""", level) .FilterA(@"op.""Slot""", slotIndex) @@ -185,7 +223,7 @@ public async Task GetCommitments( .Take(new Pagination { sort = sort, offset = offset, limit = limit }, x => x switch { "slotIndex" => (@"op.""Slot""", @"op.""Slot"""), - "level" or _ => (@"op.""Level""", @"op.""Level""") + "level" or _ => (@"op.""Level""", @"op.""Level""") }, @"op.""Level"""); await using var db = await DataSource.OpenConnectionAsync(); @@ -212,6 +250,14 @@ public async Task GetCommitments( foreach (var row in rows) result[j++] = Accounts.GetAlias(row.SenderId); break; + case "shardsAttested": + foreach (var row in rows) + result[j++] = row.ShardsAttested; + break; + case "attested": + foreach (var row in rows) + result[j++] = row.Attested; + break; } return result; @@ -272,7 +318,7 @@ public async Task> GetAttestations( { "shardsCount" => (@"da.""ShardsCount""", @"da.""ShardsCount"""), "slotIndex" => (@"dpco.""Slot""", @"dpco.""Slot"""), - "publishLevel" or _ => (@"dpco.""Level""", @"dpco.""Level""") + "publishLevel" or _ => (@"dpco.""Level""", @"dpco.""Level""") }, @"dpco.""Level"""); await using var db = await DataSource.OpenConnectionAsync(); @@ -309,12 +355,28 @@ public async Task GetAttestations( { switch (field) { - case "publishLevel": columns.Add(@"dpco.""Level"""); needPublishOp = true; break; - case "slotIndex": columns.Add(@"dpco.""Slot"""); needPublishOp = true; break; - case "commitment": columns.Add(@"dpco.""Commitment"""); needPublishOp = true; break; - case "attester": columns.Add(@"eo.""DelegateId"""); needAttestationOp = true; break; - case "shardsCount": columns.Add(@"da.""ShardsCount"""); break; - case "attested": columns.Add(@"da.""Attested"""); break; + case "publishLevel": + columns.Add(@"dpco.""Level"""); + needPublishOp = true; + break; + case "slotIndex": + columns.Add(@"dpco.""Slot"""); + needPublishOp = true; + break; + case "commitment": + columns.Add(@"dpco.""Commitment"""); + needPublishOp = true; + break; + case "attester": + columns.Add(@"eo.""DelegateId"""); + needAttestationOp = true; + break; + case "shardsCount": + columns.Add(@"da.""ShardsCount"""); + break; + case "attested": + columns.Add(@"da.""Attested"""); + break; } } @@ -329,24 +391,24 @@ public async Task GetAttestations( return Array.Empty(); var sql = new SqlBuilder($""" - SELECT {string.Join(',', columns)} - FROM "DalAttestationStatus" AS da - { - (needPublishOp ? - $""" - LEFT JOIN "DalCommitmentStatus" AS dc ON da."DalCommitmentStatusId" = dc."Id" - LEFT JOIN "DalPublishCommitmentOps" AS dpco ON dc."PublishmentId" = dpco."Id" - """ - : string.Empty) - } - { - (needAttestationOp ? - $""" - LEFT JOIN "EndorsementOps" AS eo ON da."AttestationId" = eo."Id" - """ - : string.Empty) - } - """) + SELECT {string.Join(',', columns)} + FROM "DalAttestationStatus" AS da + { + (needPublishOp ? + $""" + LEFT JOIN "DalCommitmentStatus" AS dc ON da."DalCommitmentStatusId" = dc."Id" + LEFT JOIN "DalPublishCommitmentOps" AS dpco ON dc."PublishmentId" = dpco."Id" + """ + : string.Empty) + } + { + (needAttestationOp ? + $""" + LEFT JOIN "EndorsementOps" AS eo ON da."AttestationId" = eo."Id" + """ + : string.Empty) + } + """) .FilterA(@"dpco.""Commitment""", commitment) .FilterA(@"dpco.""Level""", publishLevel) .FilterA(@"dpco.""Slot""", slotIndex) @@ -357,7 +419,7 @@ public async Task GetAttestations( { "shardsCount" => (@"da.""ShardsCount""", @"da.""ShardsCount"""), "slotIndex" => (@"dpco.""Slot""", @"dpco.""Slot"""), - "publishLevel" or _ => (@"dpco.""Level""", @"dpco.""Level""") + "publishLevel" or _ => (@"dpco.""Level""", @"dpco.""Level""") }, @"dpco.""Level"""); await using var db = await DataSource.OpenConnectionAsync(); @@ -419,12 +481,28 @@ public async Task GetAttestations( switch (field) { - case "publishLevel": columns.Add(@"dpco.""Level"""); needPublishOp = true; break; - case "slotIndex": columns.Add(@"dpco.""Slot"""); needPublishOp = true; break; - case "commitment": columns.Add(@"dpco.""Commitment"""); needPublishOp = true; break; - case "attester": columns.Add(@"eo.""DelegateId"""); needAttestationOp = true; break; - case "shardsCount": columns.Add(@"da.""ShardsCount"""); break; - case "attested": columns.Add(@"da.""Attested"""); break; + case "publishLevel": + columns.Add(@"dpco.""Level"""); + needPublishOp = true; + break; + case "slotIndex": + columns.Add(@"dpco.""Slot"""); + needPublishOp = true; + break; + case "commitment": + columns.Add(@"dpco.""Commitment"""); + needPublishOp = true; + break; + case "attester": + columns.Add(@"eo.""DelegateId"""); + needAttestationOp = true; + break; + case "shardsCount": + columns.Add(@"da.""ShardsCount"""); + break; + case "attested": + columns.Add(@"da.""Attested"""); + break; } if (sort == null || sort.Validate("publishLevel", "slotIndex")) @@ -438,24 +516,24 @@ public async Task GetAttestations( return Array.Empty(); var sql = new SqlBuilder($""" - SELECT {string.Join(',', columns)} - FROM "DalAttestationStatus" AS da - { - (needPublishOp ? - $""" - LEFT JOIN "DalCommitmentStatus" AS dc ON da."DalCommitmentStatusId" = dc."Id" - LEFT JOIN "DalPublishCommitmentOps" AS dpco ON dc."PublishmentId" = dpco."Id" - """ - : string.Empty) - } - { - (needAttestationOp ? - $""" - LEFT JOIN "EndorsementOps" AS eo ON da."AttestationId" = eo."Id" - """ - : string.Empty) - } - """) + SELECT {string.Join(',', columns)} + FROM "DalAttestationStatus" AS da + { + (needPublishOp ? + $""" + LEFT JOIN "DalCommitmentStatus" AS dc ON da."DalCommitmentStatusId" = dc."Id" + LEFT JOIN "DalPublishCommitmentOps" AS dpco ON dc."PublishmentId" = dpco."Id" + """ + : string.Empty) + } + { + (needAttestationOp ? + $""" + LEFT JOIN "EndorsementOps" AS eo ON da."AttestationId" = eo."Id" + """ + : string.Empty) + } + """) .FilterA(@"dpco.""Commitment""", commitment) .FilterA(@"dpco.""Level""", publishLevel) .FilterA(@"dpco.""Slot""", slotIndex) @@ -466,7 +544,7 @@ public async Task GetAttestations( { "shardsCount" => (@"da.""ShardsCount""", @"da.""ShardsCount"""), "slotIndex" => (@"dpco.""Slot""", @"dpco.""Slot"""), - "publishLevel" or _ => (@"dpco.""Level""", @"dpco.""Level""") + "publishLevel" or _ => (@"dpco.""Level""", @"dpco.""Level""") }, @"dpco.""Level"""); await using var db = await DataSource.OpenConnectionAsync(); @@ -505,6 +583,7 @@ public async Task GetAttestations( return result; } + #endregion } -} +} \ No newline at end of file diff --git a/Tzkt.Data/Migrations/20240814142210_DalCommitmentStatusUpdate.Designer.cs b/Tzkt.Data/Migrations/20240814142210_DalCommitmentStatusUpdate.Designer.cs new file mode 100644 index 00000000..c95ca95e --- /dev/null +++ b/Tzkt.Data/Migrations/20240814142210_DalCommitmentStatusUpdate.Designer.cs @@ -0,0 +1,7040 @@ +// +using System; +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Tzkt.Data; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + [DbContext(typeof(TzktContext))] + [Migration("20240814142210_DalCommitmentStatusUpdate")] + partial class DalCommitmentStatusUpdate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.18") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveRefutationGamesCount") + .HasColumnType("integer"); + + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + + b.Property("ActiveTokensCount") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character varying(37)"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("ContractsCount") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegationLevel") + .HasColumnType("integer"); + + b.Property("DelegationsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageCount") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("MigrationsCount") + .HasColumnType("integer"); + + b.Property("OriginationsCount") + .HasColumnType("integer"); + + b.Property("RefutationGamesCount") + .HasColumnType("integer"); + + b.Property("RevealsCount") + .HasColumnType("integer"); + + b.Property("RollupBonds") + .HasColumnType("bigint"); + + b.Property("RollupsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesCount") + .HasColumnType("integer"); + + b.Property("SmartRollupBonds") + .HasColumnType("bigint"); + + b.Property("SmartRollupCementCount") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupsCount") + .HasColumnType("integer"); + + b.Property("Staked") + .HasColumnType("boolean"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TransactionsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchCount") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UpdateConsensusKeyCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("DelegateId"); + + b.HasIndex("Extras"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Type"); + + b.HasIndex("Staked", "Type") + .HasFilter("\"Staked\" = true"); + + b.ToTable("Accounts"); + + b.HasDiscriminator("Type").HasValue((byte)3); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("ActivationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AppState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountCounter") + .HasColumnType("integer"); + + b.Property("ActivationOpsCount") + .HasColumnType("integer"); + + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + + b.Property("BallotOpsCount") + .HasColumnType("integer"); + + b.Property("BigMapCounter") + .HasColumnType("integer"); + + b.Property("BigMapKeyCounter") + .HasColumnType("integer"); + + b.Property("BigMapUpdateCounter") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Chain") + .HasColumnType("text"); + + b.Property("ChainId") + .HasColumnType("text"); + + b.Property("CommitmentsCount") + .HasColumnType("integer"); + + b.Property("ConstantsCount") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("CyclesCount") + .HasColumnType("integer"); + + b.Property("DalPublishCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("DelegationOpsCount") + .HasColumnType("integer"); + + b.Property("DomainsLevel") + .HasColumnType("integer"); + + b.Property("DomainsNameRegistry") + .HasColumnType("text"); + + b.Property("DoubleBakingOpsCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsementOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardOpsCount") + .HasColumnType("integer"); + + b.Property("EventCounter") + .HasColumnType("integer"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxMessageCounter") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageOpsCount") + .HasColumnType("integer"); + + b.Property("KnownHead") + .HasColumnType("integer"); + + b.Property("LastSync") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerCounter") + .HasColumnType("integer"); + + b.Property("MigrationOpsCount") + .HasColumnType("integer"); + + b.Property("NextProtocol") + .HasColumnType("text"); + + b.Property("NonceRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("OperationCounter") + .HasColumnType("bigint"); + + b.Property("OriginationOpsCount") + .HasColumnType("integer"); + + b.Property("PendingDelegateParameters") + .HasColumnType("integer"); + + b.Property("PreendorsementOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("ProtocolsCount") + .HasColumnType("integer"); + + b.Property("QuoteBtc") + .HasColumnType("double precision"); + + b.Property("QuoteCny") + .HasColumnType("double precision"); + + b.Property("QuoteEth") + .HasColumnType("double precision"); + + b.Property("QuoteEur") + .HasColumnType("double precision"); + + b.Property("QuoteGbp") + .HasColumnType("double precision"); + + b.Property("QuoteJpy") + .HasColumnType("double precision"); + + b.Property("QuoteKrw") + .HasColumnType("double precision"); + + b.Property("QuoteLevel") + .HasColumnType("integer"); + + b.Property("QuoteUsd") + .HasColumnType("double precision"); + + b.Property("RefutationGameCounter") + .HasColumnType("integer"); + + b.Property("RegisterConstantOpsCount") + .HasColumnType("integer"); + + b.Property("RevealOpsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltyOpsCount") + .HasColumnType("integer"); + + b.Property("ScriptCounter") + .HasColumnType("integer"); + + b.Property("SetDelegateParametersOpsCount") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCementOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentCounter") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteOpsCount") + .HasColumnType("integer"); + + b.Property("StakingOpsCount") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("StorageCounter") + .HasColumnType("integer"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TransactionOpsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchOpsCount") + .HasColumnType("integer"); + + b.Property("UnstakeRequestsCount") + .HasColumnType("integer"); + + b.Property("UpdateConsensusKeyOpsCount") + .HasColumnType("integer"); + + b.Property("VdfRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("VotingEpoch") + .HasColumnType("integer"); + + b.Property("VotingPeriod") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("AppState"); + + b.HasData( + new + { + Id = -1, + AccountCounter = 0, + ActivationOpsCount = 0, + AutostakingOpsCount = 0, + BallotOpsCount = 0, + BigMapCounter = 0, + BigMapKeyCounter = 0, + BigMapUpdateCounter = 0, + BlocksCount = 0, + CommitmentsCount = 0, + ConstantsCount = 0, + Cycle = -1, + CyclesCount = 0, + DalPublishCommitmentOpsCount = 0, + DelegationOpsCount = 0, + DomainsLevel = 0, + DoubleBakingOpsCount = 0, + DoubleEndorsingOpsCount = 0, + DoublePreendorsingOpsCount = 0, + DrainDelegateOpsCount = 0, + EndorsementOpsCount = 0, + EndorsingRewardOpsCount = 0, + EventCounter = 0, + EventsCount = 0, + Hash = "", + InboxMessageCounter = 0, + IncreasePaidStorageOpsCount = 0, + KnownHead = 0, + LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Level = -1, + ManagerCounter = 0, + MigrationOpsCount = 0, + NextProtocol = "", + NonceRevelationOpsCount = 0, + OperationCounter = 0L, + OriginationOpsCount = 0, + PendingDelegateParameters = 0, + PreendorsementOpsCount = 0, + ProposalOpsCount = 0, + ProposalsCount = 0, + Protocol = "", + ProtocolsCount = 0, + QuoteBtc = 0.0, + QuoteCny = 0.0, + QuoteEth = 0.0, + QuoteEur = 0.0, + QuoteGbp = 0.0, + QuoteJpy = 0.0, + QuoteKrw = 0.0, + QuoteLevel = -1, + QuoteUsd = 0.0, + RefutationGameCounter = 0, + RegisterConstantOpsCount = 0, + RevealOpsCount = 0, + RevelationPenaltyOpsCount = 0, + ScriptCounter = 0, + SetDelegateParametersOpsCount = 0, + SetDepositsLimitOpsCount = 0, + SmartRollupAddMessagesOpsCount = 0, + SmartRollupCementOpsCount = 0, + SmartRollupCommitmentCounter = 0, + SmartRollupExecuteOpsCount = 0, + SmartRollupOriginateOpsCount = 0, + SmartRollupPublishOpsCount = 0, + SmartRollupRecoverBondOpsCount = 0, + SmartRollupRefuteOpsCount = 0, + StakingOpsCount = 0, + StakingUpdatesCount = 0, + StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, + TicketsCount = 0, + Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + TokenBalancesCount = 0, + TokenTransfersCount = 0, + TokensCount = 0, + TransactionOpsCount = 0, + TransferTicketOpsCount = 0, + TxRollupCommitOpsCount = 0, + TxRollupDispatchTicketsOpsCount = 0, + TxRollupFinalizeCommitmentOpsCount = 0, + TxRollupOriginationOpsCount = 0, + TxRollupRejectionOpsCount = 0, + TxRollupRemoveCommitmentOpsCount = 0, + TxRollupReturnBondOpsCount = 0, + TxRollupSubmitBatchOpsCount = 0, + UnstakeRequestsCount = 0, + UpdateConsensusKeyOpsCount = 0, + VdfRevelationOpsCount = 0, + VotingEpoch = -1, + VotingPeriod = -1 + }); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AutostakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("AutostakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("BakingPower") + .HasColumnType("bigint"); + + b.Property("BlockFees") + .HasColumnType("bigint"); + + b.Property("BlockRewardsDelegated") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedEdge") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedShared") + .HasColumnType("bigint"); + + b.Property("Blocks") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingLostExternalStaked") + .HasColumnType("bigint"); + + b.Property("DoubleBakingLostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("DoubleBakingLostStaked") + .HasColumnType("bigint"); + + b.Property("DoubleBakingLostUnstaked") + .HasColumnType("bigint"); + + b.Property("DoubleBakingRewards") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLostExternalStaked") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLostStaked") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLostUnstaked") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingRewards") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLostExternalStaked") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLostStaked") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLostUnstaked") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingRewards") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsDelegated") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedEdge") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedShared") + .HasColumnType("bigint"); + + b.Property("Endorsements") + .HasColumnType("integer"); + + b.Property("ExpectedBlocks") + .HasColumnType("double precision"); + + b.Property("ExpectedEndorsements") + .HasColumnType("double precision"); + + b.Property("ExternalDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("FutureBlockRewards") + .HasColumnType("bigint"); + + b.Property("FutureBlocks") + .HasColumnType("integer"); + + b.Property("FutureEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("FutureEndorsements") + .HasColumnType("integer"); + + b.Property("MissedBlockFees") + .HasColumnType("bigint"); + + b.Property("MissedBlockRewards") + .HasColumnType("bigint"); + + b.Property("MissedBlocks") + .HasColumnType("integer"); + + b.Property("MissedEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("MissedEndorsements") + .HasColumnType("integer"); + + b.Property("NonceRevelationLosses") + .HasColumnType("bigint"); + + b.Property("NonceRevelationRewardsDelegated") + .HasColumnType("bigint"); + + b.Property("NonceRevelationRewardsStakedEdge") + .HasColumnType("bigint"); + + b.Property("NonceRevelationRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("NonceRevelationRewardsStakedShared") + .HasColumnType("bigint"); + + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); + + b.Property("StakersCount") + .HasColumnType("integer"); + + b.Property("TotalBakingPower") + .HasColumnType("bigint"); + + b.Property("VdfRevelationRewardsDelegated") + .HasColumnType("bigint"); + + b.Property("VdfRevelationRewardsStakedEdge") + .HasColumnType("bigint"); + + b.Property("VdfRevelationRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("VdfRevelationRewardsStakedShared") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakerCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DalShards") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Round") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakingRights"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Vote") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("BallotOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("ActiveKeys") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("KeyType") + .HasColumnType("bytea"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Ptr") + .HasColumnType("integer"); + + b.Property("StoragePath") + .HasColumnType("text"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TotalKeys") + .HasColumnType("integer"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.Property("ValueType") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Ptr") + .IsUnique(); + + b.ToTable("BigMaps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("JsonKey") + .HasColumnType("jsonb"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("KeyHash") + .HasMaxLength(54) + .HasColumnType("character(54)") + .IsFixedLength(); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawKey") + .HasColumnType("bytea"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("JsonKey"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); + + b.HasIndex("JsonValue"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("BigMapPtr", "KeyHash"); + + b.HasIndex(new[] { "BigMapPtr" }, "IX_BigMapKeys_BigMapPtr_Partial") + .HasFilter("\"Active\" = true"); + + b.ToTable("BigMapKeys"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("BigMapKeyId") + .HasColumnType("integer"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" IS NOT NULL"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" IS NOT NULL"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" IS NOT NULL"); + + b.HasIndex("BigMapKeyId", "Id") + .HasFilter("\"BigMapKeyId\" IS NOT NULL"); + + b.HasIndex("BigMapPtr", "Id"); + + b.ToTable("BigMapUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AIToggle") + .HasColumnType("boolean"); + + b.Property("AIToggleEma") + .HasColumnType("integer"); + + b.Property("BlockRound") + .HasColumnType("integer"); + + b.Property("BonusDelegated") + .HasColumnType("bigint"); + + b.Property("BonusStakedEdge") + .HasColumnType("bigint"); + + b.Property("BonusStakedOwn") + .HasColumnType("bigint"); + + b.Property("BonusStakedShared") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Events") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Fees") + .HasColumnType("bigint"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggle") + .HasColumnType("boolean"); + + b.Property("LBToggleEma") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Operations") + .HasColumnType("bigint"); + + b.Property("PayloadRound") + .HasColumnType("integer"); + + b.Property("ProducerId") + .HasColumnType("integer"); + + b.Property("ProposerId") + .HasColumnType("integer"); + + b.Property("ProtoCode") + .HasColumnType("integer"); + + b.Property("ResetBakerDeactivation") + .HasColumnType("integer"); + + b.Property("ResetProposerDeactivation") + .HasColumnType("integer"); + + b.Property("RevelationId") + .HasColumnType("bigint"); + + b.Property("RewardDelegated") + .HasColumnType("bigint"); + + b.Property("RewardStakedEdge") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Validations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("Level") + .IsUnique(); + + b.HasIndex("ProducerId"); + + b.HasIndex("ProposerId"); + + b.HasIndex("ProtoCode"); + + b.HasIndex("RevelationId") + .IsUnique(); + + b.HasIndex("SoftwareId"); + + b.ToTable("Blocks"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character(37)") + .IsFixedLength(); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Address") + .IsUnique(); + + b.ToTable("Commitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("JsonPayload") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RawPayload") + .HasColumnType("bytea"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("JsonPayload"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("Tag"); + + b.HasIndex("TransactionId"); + + b.HasIndex("ContractCodeHash", "Tag"); + + b.HasIndex("ContractId", "Tag"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlockBonusPerSlot") + .HasColumnType("bigint"); + + b.Property("BlockReward") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardPerSlot") + .HasColumnType("bigint"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBlockReward") + .HasColumnType("bigint"); + + b.Property("NonceRevelationReward") + .HasColumnType("bigint"); + + b.Property("Seed") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("SnapshotLevel") + .HasColumnType("integer"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalBakingPower") + .HasColumnType("bigint"); + + b.Property("VdfRevelationReward") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("Cycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalAttestationStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AttestationId") + .HasColumnType("bigint"); + + b.Property("Attested") + .HasColumnType("boolean"); + + b.Property("DalCommitmentStatusId") + .HasColumnType("integer"); + + b.Property("ShardsCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AttestationId"); + + b.HasIndex("DalCommitmentStatusId"); + + b.ToTable("DalAttestationStatus"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalCommitmentStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Attested") + .HasColumnType("boolean"); + + b.Property("PublishmentId") + .HasColumnType("bigint"); + + b.Property("ShardsAttested") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PublishmentId") + .IsUnique(); + + b.ToTable("DalCommitmentStatus"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalPublishCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Commitment") + .HasColumnType("text"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("DalPublishCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevDelegateId") + .HasColumnType("integer"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("PrevDelegateId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId", "Id"); + + b.ToTable("DelegationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorId") + .HasColumnType("integer"); + + b.Property("StakedBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DelegatorId"); + + b.HasIndex("Cycle", "BakerId"); + + b.HasIndex("Cycle", "DelegatorId"); + + b.ToTable("DelegatorCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Domain", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("jsonb"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("Reverse") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("Address"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Level"); + + b.HasIndex("Name"); + + b.HasIndex("Owner"); + + b.ToTable("Domains"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); + + b.Property("LostUnstaked") + .HasColumnType("bigint"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleBakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); + + b.Property("LostUnstaked") + .HasColumnType("bigint"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleEndorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); + + b.Property("LostUnstaked") + .HasColumnType("bigint"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoublePreendorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Fee") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("TargetId"); + + b.ToTable("DrainDelegateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DalAttestation") + .HasColumnType("numeric"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("EndorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Expected") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RewardDelegated") + .HasColumnType("bigint"); + + b.Property("RewardStakedEdge") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") + .HasColumnType("bigint"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("EndorsingRewardOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OperationId") + .HasColumnType("bigint"); + + b.Property("Payload") + .HasColumnType("bytea"); + + b.Property("PredecessorLevel") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OperationId"); + + b.HasIndex("Type", "Id"); + + b.ToTable("InboxMessages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("IncreasePaidStorageOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BalanceChange") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Level"); + + b.HasIndex("ScriptId"); + + b.HasIndex("StorageId"); + + b.ToTable("MigrationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RevealedCycle") + .HasColumnType("integer"); + + b.Property("RevealedLevel") + .HasColumnType("integer"); + + b.Property("RewardDelegated") + .HasColumnType("bigint"); + + b.Property("RewardStakedEdge") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RevealedCycle"); + + b.HasIndex("SenderId"); + + b.ToTable("NonceRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash") + .HasFilter("\"ContractCodeHash\" IS NOT NULL"); + + b.HasIndex("ContractId"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("ManagerId"); + + b.HasIndex("OpHash"); + + b.HasIndex("ScriptId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.ToTable("OriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("PreendorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstPeriod") + .HasColumnType("integer"); + + b.Property("Hash") + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastPeriod") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Upvotes") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("FirstPeriod"); + + b.HasIndex("Hash"); + + b.HasIndex("LastPeriod"); + + b.HasIndex(new[] { "Status" }, "IX_Proposals_Status_Partial") + .HasFilter("\"Status\" = 0"); + + b.ToTable("Proposals"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Duplicated") + .HasColumnType("boolean"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("ProposalOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotQuorumMax") + .HasColumnType("integer"); + + b.Property("BallotQuorumMin") + .HasColumnType("integer"); + + b.Property("BlockDeposit") + .HasColumnType("bigint"); + + b.Property("BlockReward0") + .HasColumnType("bigint"); + + b.Property("BlockReward1") + .HasColumnType("bigint"); + + b.Property("BlocksPerCommitment") + .HasColumnType("integer"); + + b.Property("BlocksPerCycle") + .HasColumnType("integer"); + + b.Property("BlocksPerSnapshot") + .HasColumnType("integer"); + + b.Property("BlocksPerVoting") + .HasColumnType("integer"); + + b.Property("ByteCost") + .HasColumnType("integer"); + + b.Property("Code") + .HasColumnType("integer"); + + b.Property("ConsensusRightsDelay") + .HasColumnType("integer"); + + b.Property("ConsensusThreshold") + .HasColumnType("integer"); + + b.Property("DalAttestationLag") + .HasColumnType("integer"); + + b.Property("DalAttestationThreshold") + .HasColumnType("integer"); + + b.Property("DalShardsPerSlot") + .HasColumnType("integer"); + + b.Property("DalSlotsPerLevel") + .HasColumnType("integer"); + + b.Property("DelegateParametersActivationDelay") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("text"); + + b.Property("DoubleBakingSlashedPercentage") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingSlashedPercentage") + .HasColumnType("integer"); + + b.Property("EndorsementDeposit") + .HasColumnType("bigint"); + + b.Property("EndorsementReward0") + .HasColumnType("bigint"); + + b.Property("EndorsementReward1") + .HasColumnType("bigint"); + + b.Property("EndorsersPerBlock") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstCycle") + .HasColumnType("integer"); + + b.Property("FirstCycleLevel") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("HardBlockGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationStorageLimit") + .HasColumnType("integer"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggleThreshold") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBakingReward") + .HasColumnType("bigint"); + + b.Property("MaxDelegatedOverFrozenRatio") + .HasColumnType("integer"); + + b.Property("MaxEndorsingReward") + .HasColumnType("bigint"); + + b.Property("MaxExternalOverOwnStakeRatio") + .HasColumnType("integer"); + + b.Property("MaxSlashingPeriod") + .HasColumnType("integer"); + + b.Property("MinParticipationDenominator") + .HasColumnType("integer"); + + b.Property("MinParticipationNumerator") + .HasColumnType("integer"); + + b.Property("MinimalFrozenStake") + .HasColumnType("bigint"); + + b.Property("MinimalStake") + .HasColumnType("bigint"); + + b.Property("NoRewardCycles") + .HasColumnType("integer"); + + b.Property("OriginationSize") + .HasColumnType("integer"); + + b.Property("ProposalQuorum") + .HasColumnType("integer"); + + b.Property("RampUpCycles") + .HasColumnType("integer"); + + b.Property("SmartRollupChallengeWindow") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentPeriod") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginationSize") + .HasColumnType("integer"); + + b.Property("SmartRollupStakeAmount") + .HasColumnType("bigint"); + + b.Property("SmartRollupTimeoutPeriod") + .HasColumnType("integer"); + + b.Property("StakePowerMultiplier") + .HasColumnType("integer"); + + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("Hash") + .IsUnique(); + + b.ToTable("Protocols"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Btc") + .HasColumnType("double precision"); + + b.Property("Cny") + .HasColumnType("double precision"); + + b.Property("Eth") + .HasColumnType("double precision"); + + b.Property("Eur") + .HasColumnType("double precision"); + + b.Property("Gbp") + .HasColumnType("double precision"); + + b.Property("Jpy") + .HasColumnType("double precision"); + + b.Property("Krw") + .HasColumnType("double precision"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Usd") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("InitiatorCommitmentId") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InitiatorLoss") + .HasColumnType("bigint"); + + b.Property("InitiatorReward") + .HasColumnType("bigint"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("LastMoveId") + .HasColumnType("bigint"); + + b.Property("OpponentCommitmentId") + .HasColumnType("integer"); + + b.Property("OpponentId") + .HasColumnType("integer"); + + b.Property("OpponentLoss") + .HasColumnType("bigint"); + + b.Property("OpponentReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("InitiatorCommitmentId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("LastLevel"); + + b.HasIndex("OpponentCommitmentId"); + + b.HasIndex("OpponentId"); + + b.HasIndex("SmartRollupId", "Id"); + + b.ToTable("RefutationGames"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Refs") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Value") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .HasFilter("\"Address\" IS NOT NULL"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RegisterConstantOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RevealOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("MissedLevel") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("RevelationPenaltyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Script", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CodeSchema") + .HasColumnType("bytea"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("StorageSchema") + .HasColumnType("bytea"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("Views") + .HasColumnType("bytea[]"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "ContractId" }, "IX_Scripts_ContractId_Partial") + .HasFilter("\"Current\" = true"); + + b.ToTable("Scripts"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDelegateParametersOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ActivationCycle"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId", "Id"); + + b.ToTable("SetDelegateParametersOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Limit") + .HasColumnType("numeric"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId", "Id"); + + b.ToTable("SetDepositsLimitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MessagesCount") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupAddMessagesOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId", "Id"); + + b.ToTable("SmartRollupCementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("PredecessorId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Stakers") + .HasColumnType("integer"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Successors") + .HasColumnType("integer"); + + b.Property("Ticks") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("InboxLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("PredecessorId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("Hash", "SmartRollupId"); + + b.ToTable("SmartRollupCommitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("CommitmentId", "Id"); + + b.ToTable("SmartRollupExecuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("Kernel") + .HasColumnType("bytea"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ParameterType") + .HasColumnType("bytea"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupOriginateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("BondStatus") + .HasColumnType("integer"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Flags") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId", "BondStatus", "SenderId") + .HasFilter("\"BondStatus\" IS NOT NULL"); + + b.HasIndex("SmartRollupId", "SenderId", "Id"); + + b.ToTable("SmartRollupPublishOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("StakerId"); + + b.ToTable("SmartRollupRecoverBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DissectionEnd") + .HasColumnType("bigint"); + + b.Property("DissectionStart") + .HasColumnType("bigint"); + + b.Property("DissectionSteps") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GameId") + .HasColumnType("integer"); + + b.Property("GameStatus") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Move") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("GameId", "Id"); + + b.ToTable("SmartRollupRefuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("ExternalDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); + + b.Property("StakersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level", "AccountId", "BakerId"); + + b.HasIndex(new[] { "Level" }, "IX_SnapshotBalances_Level_Partial") + .HasFilter("\"AccountId\" = \"BakerId\""); + + b.ToTable("SnapshotBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("ShortHash") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character(8)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.StakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RequestedAmount") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("StakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.StakingUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("AutostakingOpId") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegationOpId") + .HasColumnType("bigint"); + + b.Property("DoubleBakingOpId") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingOpId") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingOpId") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Pseudotokens") + .HasColumnType("numeric"); + + b.Property("RoundingError") + .HasColumnType("bigint"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("StakingOpId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AutostakingOpId") + .HasFilter("\"AutostakingOpId\" IS NOT NULL"); + + b.HasIndex("DelegationOpId") + .HasFilter("\"DelegationOpId\" IS NOT NULL"); + + b.HasIndex("DoubleBakingOpId") + .HasFilter("\"DoubleBakingOpId\" IS NOT NULL"); + + b.HasIndex("DoubleEndorsingOpId") + .HasFilter("\"DoubleEndorsingOpId\" IS NOT NULL"); + + b.HasIndex("DoublePreendorsingOpId") + .HasFilter("\"DoublePreendorsingOpId\" IS NOT NULL"); + + b.HasIndex("StakingOpId") + .HasFilter("\"StakingOpId\" IS NOT NULL"); + + b.HasIndex("Level", "Id"); + + b.HasIndex("BakerId", "Cycle", "Id"); + + b.HasIndex("StakerId", "Cycle", "Id"); + + b.ToTable("StakingUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("TotalActivated") + .HasColumnType("bigint"); + + b.Property("TotalBanished") + .HasColumnType("bigint"); + + b.Property("TotalBootstrapped") + .HasColumnType("bigint"); + + b.Property("TotalBurned") + .HasColumnType("bigint"); + + b.Property("TotalCommitments") + .HasColumnType("bigint"); + + b.Property("TotalCreated") + .HasColumnType("bigint"); + + b.Property("TotalFrozen") + .HasColumnType("bigint"); + + b.Property("TotalLost") + .HasColumnType("bigint"); + + b.Property("TotalRollupBonds") + .HasColumnType("bigint"); + + b.Property("TotalSmartRollupBonds") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle") + .IsUnique() + .HasFilter("\"Cycle\" IS NOT NULL"); + + b.HasIndex("Date") + .IsUnique() + .HasFilter("\"Date\" IS NOT NULL"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Statistics"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Storage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("ContractId", "Id"); + + b.HasIndex(new[] { "ContractId" }, "IX_Storages_ContractId_Partial") + .HasFilter("\"Current\" = true"); + + b.ToTable("Storages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("jsonb"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContentHash"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("JsonContent"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonContent"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonContent"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("TypeHash"); + + b.HasIndex("TicketerId", "TypeHash", "ContentHash"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("numeric"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.HasIndex("AccountId", "TicketId") + .IsUnique(); + + b.HasIndex("AccountId", "TicketerId"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("TransferTicketId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("FromId"); + + b.HasIndex("SmartRollupExecuteId") + .HasFilter("\"SmartRollupExecuteId\" IS NOT NULL"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.HasIndex("ToId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" IS NOT NULL"); + + b.HasIndex("TransferTicketId") + .HasFilter("\"TransferTicketId\" IS NOT NULL"); + + b.HasIndex("Level", "Id"); + + b.ToTable("TicketTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Token", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("numeric"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" IS NOT NULL"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("ContractId", "TokenId") + .IsUnique(); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("numeric"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" IS NOT NULL"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TokenId"); + + b.HasIndex("AccountId", "ContractId"); + + b.HasIndex("AccountId", "TokenId") + .IsUnique(); + + b.HasIndex(new[] { "AccountId" }, "IX_TokenBalances_AccountId_Partial") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex(new[] { "ContractId" }, "IX_TokenBalances_ContractId_Partial") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex(new[] { "TokenId" }, "IX_TokenBalances_TokenId_Partial") + .HasFilter("\"Balance\" != '0'"); + + b.ToTable("TokenBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" IS NOT NULL"); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" IS NOT NULL"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" IS NOT NULL"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" IS NOT NULL"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" IS NOT NULL"); + + b.HasIndex("TokenId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" IS NOT NULL"); + + b.HasIndex("Level", "Id"); + + b.ToTable("TokenTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InternalDelegations") + .HasColumnType("smallint"); + + b.Property("InternalOperations") + .HasColumnType("smallint"); + + b.Property("InternalOriginations") + .HasColumnType("smallint"); + + b.Property("InternalTransactions") + .HasColumnType("smallint"); + + b.Property("JsonParameters") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawParameters") + .HasColumnType("bytea"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetCodeHash") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("JsonParameters"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.HasIndex("TargetCodeHash") + .HasFilter("\"TargetCodeHash\" IS NOT NULL"); + + b.HasIndex("TargetId"); + + b.HasIndex(new[] { "TargetId" }, "IX_TransactionOps_TargetId_Partial") + .HasFilter("\"Entrypoint\" = 'transfer'\nAND \"TokenTransfers\" IS NULL\nAND \"Status\" = 1"); + + b.ToTable("TransactionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("TargetId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TransferTicketOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupCommitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupDispatchTicketsOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupFinalizeCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupOriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitterId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitterId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRejectionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRemoveCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupReturnBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupSubmitBatchOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UnstakeRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("FinalizedAmount") + .HasColumnType("bigint"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RequestedAmount") + .HasColumnType("bigint"); + + b.Property("RestakedAmount") + .HasColumnType("bigint"); + + b.Property("RoundingError") + .HasColumnType("bigint"); + + b.Property("SlashedAmount") + .HasColumnType("bigint"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("UpdatesCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BakerId", "Cycle"); + + b.HasIndex("StakerId", "Cycle"); + + b.ToTable("UnstakeRequests"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("PublicKeyHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("UpdateConsensusKeyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Proof") + .HasColumnType("bytea"); + + b.Property("RewardDelegated") + .HasColumnType("bigint"); + + b.Property("RewardStakedEdge") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") + .HasColumnType("bigint"); + + b.Property("Solution") + .HasColumnType("bytea"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Cycle", "Id"); + + b.ToTable("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotsQuorum") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("integer"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("NayBallots") + .HasColumnType("integer"); + + b.Property("NayVotingPower") + .HasColumnType("bigint"); + + b.Property("ParticipationEma") + .HasColumnType("integer"); + + b.Property("PassBallots") + .HasColumnType("integer"); + + b.Property("PassVotingPower") + .HasColumnType("bigint"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("SingleWinner") + .HasColumnType("boolean"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Supermajority") + .HasColumnType("integer"); + + b.Property("TopUpvotes") + .HasColumnType("integer"); + + b.Property("TopVotingPower") + .HasColumnType("bigint"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalVotingPower") + .HasColumnType("bigint"); + + b.Property("UpvotesQuorum") + .HasColumnType("integer"); + + b.Property("YayBallots") + .HasColumnType("integer"); + + b.Property("YayVotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("VotingPeriods"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Period", "BakerId") + .IsUnique(); + + b.ToTable("VotingSnapshots"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("smallint"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Spendable") + .HasColumnType("boolean"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("WeirdDelegateId") + .HasColumnType("integer"); + + b.HasIndex("CodeHash"); + + b.HasIndex("CreatorId"); + + b.HasIndex("ManagerId"); + + b.HasIndex("TypeHash"); + + b.HasIndex("WeirdDelegateId") + .HasFilter("\"WeirdDelegateId\" IS NOT NULL"); + + b.HasIndex(new[] { "Kind" }, "IX_Accounts_Kind_Partial") + .HasFilter("\"Type\" = 2"); + + b.HasDiscriminator().HasValue((byte)2); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)4); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("CementedCommitments") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("ExecutedCommitments") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("LastCommitment") + .HasColumnType("text"); + + b.Property("OrphanCommitments") + .HasColumnType("integer"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("PendingCommitments") + .HasColumnType("integer"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("RefutedCommitments") + .HasColumnType("integer"); + + b.Property("TotalStakers") + .HasColumnType("integer"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)5); + }); + + modelBuilder.Entity("Tzkt.Data.Models.User", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActivationsCount") + .HasColumnType("integer"); + + b.Property("DalPublishCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("RegisterConstantsCount") + .HasColumnType("integer"); + + b.Property("Revealed") + .HasColumnType("boolean"); + + b.Property("SetDelegateParametersOpsCount") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitsCount") + .HasColumnType("integer"); + + b.Property("StakedPseudotokens") + .HasColumnType("numeric"); + + b.Property("StakingOpsCount") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("UnstakedBakerId") + .HasColumnType("integer"); + + b.Property("UnstakedBalance") + .HasColumnType("bigint"); + + b.HasIndex("UnstakedBakerId") + .HasFilter("\"UnstakedBakerId\" IS NOT NULL"); + + b.HasDiscriminator().HasValue((byte)0); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasBaseType("Tzkt.Data.Models.User"); + + b.Property("ActivationLevel") + .HasColumnType("integer"); + + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + + b.Property("BallotsCount") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("DeactivationLevel") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingCount") + .HasColumnType("integer"); + + b.Property("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + + b.Property("EndorsementsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardsCount") + .HasColumnType("integer"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalUnstakedBalance") + .HasColumnType("bigint"); + + b.Property("FrozenDepositLimit") + .HasColumnType("bigint"); + + b.Property("IssuedPseudotokens") + .HasColumnType("numeric"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + + b.Property("NonceRevelationsCount") + .HasColumnType("integer"); + + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); + + b.Property("PreendorsementsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltiesCount") + .HasColumnType("integer"); + + b.Property("RoundingError") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("StakersCount") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.Property("VdfRevelationsCount") + .HasColumnType("integer"); + + b.HasIndex("SoftwareId"); + + b.HasIndex(new[] { "DeactivationLevel" }, "IX_Accounts_DeactivationLevel_Partial") + .HasFilter("\"Type\" = 1"); + + b.HasIndex(new[] { "Staked" }, "IX_Accounts_Staked_Partial") + .HasFilter("\"Type\" = 1"); + + b.HasDiscriminator().HasValue((byte)1); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany("DelegatedAccounts") + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") + .WithMany("CreatedAccounts") + .HasForeignKey("FirstLevel") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Delegate"); + + b.Navigation("FirstBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.HasOne("Tzkt.Data.Models.User", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Activations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Ballots") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") + .WithMany() + .HasForeignKey("ProposerId"); + + b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") + .WithMany() + .HasForeignKey("ProtoCode") + .HasPrincipalKey("Code") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") + .WithOne("RevealedBlock") + .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); + + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Proposer"); + + b.Navigation("Protocol"); + + b.Navigation("Revelation"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalAttestationStatus", b => + { + b.HasOne("Tzkt.Data.Models.EndorsementOperation", "Attestation") + .WithMany() + .HasForeignKey("AttestationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.DalCommitmentStatus", "DalCommitmentStatus") + .WithMany() + .HasForeignKey("DalCommitmentStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Attestation"); + + b.Navigation("DalCommitmentStatus"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalCommitmentStatus", b => + { + b.HasOne("Tzkt.Data.Models.DalPublishCommitmentOperation", "Publishment") + .WithOne("DalCommitmentStatus") + .HasForeignKey("Tzkt.Data.Models.DalCommitmentStatus", "PublishmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Publishment"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalPublishCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DalPublishCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Delegations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") + .WithMany() + .HasForeignKey("PrevDelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("PrevDelegate"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleBakings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleEndorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoublePreendorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DrainDelegateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Endorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("IncreasePaidStorageOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Migrations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Account"); + + b.Navigation("Block"); + + b.Navigation("Script"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Revelations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Contract", "Contract") + .WithMany() + .HasForeignKey("ContractId"); + + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Originations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Block"); + + b.Navigation("Contract"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("Manager"); + + b.Navigation("Script"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Preendorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Proposals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RegisterConstants") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Reveals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RevelationPenalties") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDelegateParametersOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDelegateParametersOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDepositsLimits") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupAddMessagesOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupCementOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupExecuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupOriginateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupPublishOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRecoverBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRefuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.StakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("StakingOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Transactions") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.HasOne("Tzkt.Data.Models.Account", "Target") + .WithMany() + .HasForeignKey("TargetId"); + + b.Navigation("Block"); + + b.Navigation("Initiator"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TransferTicketOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupCommitOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupDispatchTicketsOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupFinalizeCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupOriginationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRejectionOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRemoveCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupReturnBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupSubmitBatchOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("UpdateConsensusKeyOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("VdfRevelationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") + .WithMany() + .HasForeignKey("WeirdDelegateId"); + + b.Navigation("Creator"); + + b.Navigation("Manager"); + + b.Navigation("WeirdDelegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Navigation("Activations"); + + b.Navigation("Ballots"); + + b.Navigation("CreatedAccounts"); + + b.Navigation("DalPublishCommitmentOps"); + + b.Navigation("Delegations"); + + b.Navigation("DoubleBakings"); + + b.Navigation("DoubleEndorsings"); + + b.Navigation("DoublePreendorsings"); + + b.Navigation("DrainDelegateOps"); + + b.Navigation("Endorsements"); + + b.Navigation("IncreasePaidStorageOps"); + + b.Navigation("Migrations"); + + b.Navigation("Originations"); + + b.Navigation("Preendorsements"); + + b.Navigation("Proposals"); + + b.Navigation("RegisterConstants"); + + b.Navigation("Reveals"); + + b.Navigation("RevelationPenalties"); + + b.Navigation("Revelations"); + + b.Navigation("SetDelegateParametersOps"); + + b.Navigation("SetDepositsLimits"); + + b.Navigation("SmartRollupAddMessagesOps"); + + b.Navigation("SmartRollupCementOps"); + + b.Navigation("SmartRollupExecuteOps"); + + b.Navigation("SmartRollupOriginateOps"); + + b.Navigation("SmartRollupPublishOps"); + + b.Navigation("SmartRollupRecoverBondOps"); + + b.Navigation("SmartRollupRefuteOps"); + + b.Navigation("StakingOps"); + + b.Navigation("Transactions"); + + b.Navigation("TransferTicketOps"); + + b.Navigation("TxRollupCommitOps"); + + b.Navigation("TxRollupDispatchTicketsOps"); + + b.Navigation("TxRollupFinalizeCommitmentOps"); + + b.Navigation("TxRollupOriginationOps"); + + b.Navigation("TxRollupRejectionOps"); + + b.Navigation("TxRollupRemoveCommitmentOps"); + + b.Navigation("TxRollupReturnBondOps"); + + b.Navigation("TxRollupSubmitBatchOps"); + + b.Navigation("UpdateConsensusKeyOps"); + + b.Navigation("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalPublishCommitmentOperation", b => + { + b.Navigation("DalCommitmentStatus"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Navigation("RevealedBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.Navigation("DelegatedAccounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Tzkt.Data/Migrations/20240814142210_DalCommitmentStatusUpdate.cs b/Tzkt.Data/Migrations/20240814142210_DalCommitmentStatusUpdate.cs new file mode 100644 index 00000000..10d17976 --- /dev/null +++ b/Tzkt.Data/Migrations/20240814142210_DalCommitmentStatusUpdate.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class DalCommitmentStatusUpdate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Attested", + table: "DalCommitmentStatus", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "ShardsAttested", + table: "DalCommitmentStatus", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Attested", + table: "DalCommitmentStatus"); + + migrationBuilder.DropColumn( + name: "ShardsAttested", + table: "DalCommitmentStatus"); + } + } +} diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 352ea26f..39abdeda 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -1429,9 +1429,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("Attested") + .HasColumnType("boolean"); + b.Property("PublishmentId") .HasColumnType("bigint"); + b.Property("ShardsAttested") + .HasColumnType("integer"); + b.HasKey("Id"); b.HasIndex("PublishmentId") diff --git a/Tzkt.Data/Models/Dal/DalCommitmentStatus.cs b/Tzkt.Data/Models/Dal/DalCommitmentStatus.cs index 57e60463..99bbc3dd 100644 --- a/Tzkt.Data/Models/Dal/DalCommitmentStatus.cs +++ b/Tzkt.Data/Models/Dal/DalCommitmentStatus.cs @@ -7,7 +7,9 @@ public class DalCommitmentStatus { public int Id { get; set; } public long PublishmentId { get; set; } - + public int ShardsAttested { get; set; } + public bool Attested { get; set; } + #region relations [ForeignKey(nameof(PublishmentId))] public DalPublishCommitmentOperation Publishment { get; set; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/BlockCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/BlockCommit.cs index 9d52dd4a..6b7e121b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/BlockCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/BlockCommit.cs @@ -1,4 +1,6 @@ using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto19 { @@ -104,5 +106,49 @@ protected override (long, long, long, long, long, long, long, long) ParseRewards return (rewardDelegated, rewardStakedOwn, rewardStakedEdge, rewardStakedShared, bonusDelegated, bonusStakedOwn, bonusStakedEdge, bonusStakedShared); } + + public virtual async Task UpdateDalCommitmentStatus(JsonElement rawBlock) + { + var level = rawBlock.Required("header").RequiredInt32("level"); + var dalAttStatusList = Cache.DalAttestations.GetCached(level); + if (dalAttStatusList.Count == 0) return; + var dalStatusEntries = dalAttStatusList.Where(das => das.Attested ).GroupBy(das => + new { publishCommitmentId = das.DalCommitmentStatusId}) + .Select(group => new + { + CommitmentStatusId = group.Key.publishCommitmentId, + ShardsCount = group.Sum(das => das.ShardsCount) + }).ToList(); + // These DalAttestations were done for DAL commitments published at level exactly DalAttestationLag before current level. + var statusEntries = + await Cache.DalCommitmentStatus.GetOrDefaultAsync(level - Block.Protocol.DalAttestationLag); + var shardsThreshold = Math.Round((Block.Protocol.DalAttestationThreshold / 100.0f) * + (Block.Protocol.DalShardsPerSlot), MidpointRounding.AwayFromZero); + foreach (var item in dalStatusEntries) + { + var statusEntry = statusEntries.Find(d => d.Id == item.CommitmentStatusId); + statusEntry.ShardsAttested = item.ShardsCount; + statusEntry.Attested = (item.ShardsCount >= shardsThreshold); + } + + Db.DalCommitmentStatus.UpdateRange(statusEntries); + } + + public virtual async Task RevertDalCommitmentStatusUpdate(Block block) + { + // Revert the status updates done to DalCommitmentStatus table for rows which were updated due to attestations + var commitmentStatus = + await Cache.DalCommitmentStatus.GetOrDefaultAsync(block.Level - block.Protocol.DalAttestationLag); + if (commitmentStatus != null) + { + commitmentStatus.ForEach(commit => + { + commit.ShardsAttested = 0; + commit.Attested = false; + }); + Db.DalCommitmentStatus.UpdateRange(commitmentStatus); + await Db.SaveChangesAsync(); + } + } } -} +} \ No newline at end of file diff --git a/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/Operations/EndorsementsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/Operations/EndorsementsCommit.cs index aad716ae..71b52126 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/Operations/EndorsementsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/Operations/EndorsementsCommit.cs @@ -2,6 +2,7 @@ using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; +using Tzkt.Sync.Services.Cache; namespace Tzkt.Sync.Protocols.Proto19 { @@ -43,11 +44,17 @@ protected override async Task ApplyDalAttestations(EndorsementOperation endorsem dalAttestationsStatus.Add(attestationsStatus); } } + + if(dalAttestationsStatus.Count > 0) + { + DalAttestationsCache.Add(block.Level, dalAttestationsStatus); + } Db.DalAttestationStatus.AddRange(dalAttestationsStatus); } } protected override async Task RevertDalAttestations(EndorsementOperation endorsement) { + DalAttestationsCache.Reset(); await Db.Database.ExecuteSqlRawAsync($""" DELETE FROM "DalAttestationStatus" WHERE "AttestationId" = {endorsement.Id} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto19/Proto19Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto19/Proto19Handler.cs index 6c7c5a28..a738f7f6 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto19/Proto19Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto19/Proto19Handler.cs @@ -325,6 +325,7 @@ public override async Task Commit(JsonElement block) #endregion await blockCommit.ApplyRewards(block); + await blockCommit.UpdateDalCommitmentStatus(block); new InboxCommit(this).Apply(blockCommit.Block); @@ -497,6 +498,7 @@ public override async Task Revert() await new ContractEventCommit(this).Revert(currBlock); await new InboxCommit(this).Revert(currBlock); await new BlockCommit(this).RevertRewards(currBlock); + await new BlockCommit(this).RevertDalCommitmentStatusUpdate(currBlock); foreach (var operation in operations.OrderByDescending(x => x.Id)) { diff --git a/Tzkt.Sync/Protocols/Handlers/Proto20/Proto20Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto20/Proto20Handler.cs index 37214107..0350ff55 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto20/Proto20Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto20/Proto20Handler.cs @@ -325,6 +325,7 @@ public override async Task Commit(JsonElement block) #endregion await blockCommit.ApplyRewards(block); + await blockCommit.UpdateDalCommitmentStatus(block); new InboxCommit(this).Apply(blockCommit.Block); @@ -497,6 +498,7 @@ public override async Task Revert() await new ContractEventCommit(this).Revert(currBlock); await new InboxCommit(this).Revert(currBlock); await new BlockCommit(this).RevertRewards(currBlock); + await new BlockCommit(this).RevertDalCommitmentStatusUpdate(currBlock); foreach (var operation in operations.OrderByDescending(x => x.Id)) { diff --git a/Tzkt.Sync/Services/Cache/CacheService.cs b/Tzkt.Sync/Services/Cache/CacheService.cs index e4fad447..6e786a21 100644 --- a/Tzkt.Sync/Services/Cache/CacheService.cs +++ b/Tzkt.Sync/Services/Cache/CacheService.cs @@ -28,6 +28,7 @@ public class CacheService public RefutationGameCache RefutationGames { get; private set; } public UnstakeRequestsCache UnstakeRequests { get; private set; } public DalCommitmentStatusCache DalCommitmentStatus { get; private set; } + public DalAttestationsCache DalAttestations { get; private set; } public CacheService(TzktContext db) { @@ -54,6 +55,7 @@ public CacheService(TzktContext db) RefutationGames = new(db); UnstakeRequests = new(db); DalCommitmentStatus = new(db); + DalAttestations = new (db); } public async Task ResetAsync() @@ -77,6 +79,7 @@ public async Task ResetAsync() RefutationGames.Reset(); UnstakeRequests.Reset(); DalCommitmentStatus.Reset(); + DalAttestationsCache.Reset(); await Protocols.ResetAsync(); await AppState.ResetAsync(); diff --git a/Tzkt.Sync/Services/Cache/DalAttestationsCache.cs b/Tzkt.Sync/Services/Cache/DalAttestationsCache.cs new file mode 100644 index 00000000..d830162c --- /dev/null +++ b/Tzkt.Sync/Services/Cache/DalAttestationsCache.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +using Tzkt.Data; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Services.Cache +{ + public class DalAttestationsCache + { + static int CachedLevel = -1; + static List CachedStatus = new(); + + readonly TzktContext Db; + + public DalAttestationsCache(TzktContext db) + { + Db = db; + } + + public static void Reset() + { + CachedLevel = -1; + CachedStatus.Clear(); + } + + public static void Add(int level, IEnumerable entry) + { + if (CachedLevel != level) + { + Reset(); + CachedLevel = level; + } + CachedStatus.AddRange(entry); + } + + public List GetCached(int level) + { + if (CachedLevel == level && CachedStatus is not null) + return CachedStatus; + return new List(); + } + } +} diff --git a/Tzkt.Sync/Services/Cache/DalCommitmentStatusCache.cs b/Tzkt.Sync/Services/Cache/DalCommitmentStatusCache.cs index 6a8185d9..3416bfa1 100644 --- a/Tzkt.Sync/Services/Cache/DalCommitmentStatusCache.cs +++ b/Tzkt.Sync/Services/Cache/DalCommitmentStatusCache.cs @@ -27,21 +27,32 @@ public void Reset() CachedStatus = null; } - public async Task GetOrDefaultAsync(int level, int slot) + private async Task LoadCachedStatusAsync(int level) { if (CachedLevel != level) { var status = await Db.DalCommitmentStatus .AsNoTracking() - .Join(Db.DalPublishCommitmentOps, x => x.PublishmentId, x => x.Id, (commitment, publishment) => new { commitment, publishment }) + .Join(Db.DalPublishCommitmentOps, x => x.PublishmentId, x => x.Id, + (commitment, publishment) => new { commitment, publishment }) .Where(x => x.publishment.Level == level) .ToListAsync(); CachedStatus = status.ToDictionary(x => x.publishment.Slot, x => x.commitment); CachedLevel = level; } - + } + + public async Task GetOrDefaultAsync(int level, int slot) + { + await LoadCachedStatusAsync(level); return CachedStatus.TryGetValue(slot, out var res) ? res : null; } + + public async Task> GetOrDefaultAsync(int level) + { + await LoadCachedStatusAsync(level); + return CachedStatus.Values.ToList(); + } } }