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