From f03b15f746a4a9446b97cc3f17eb567735f01511 Mon Sep 17 00:00:00 2001
From: Maksim Strebkov <257byte@gmail.com>
Date: Thu, 23 May 2024 18:16:59 +0300
Subject: [PATCH] Add version to the protocol API model, update sr constants.
---
Tzkt.Api/Models/Protocol.cs | 5 +++++
Tzkt.Api/Repositories/ProtocolRepository.cs | 4 ++++
.../Protocols/Handlers/Proto19/Activation/ProtoActivator.cs | 3 +++
3 files changed, 12 insertions(+)
diff --git a/Tzkt.Api/Models/Protocol.cs b/Tzkt.Api/Models/Protocol.cs
index 3e66ffc40..5263307b6 100644
--- a/Tzkt.Api/Models/Protocol.cs
+++ b/Tzkt.Api/Models/Protocol.cs
@@ -14,6 +14,11 @@ public class Protocol
///
public string Hash { get; set; }
+ ///
+ /// Global version number
+ ///
+ public int Version { get; set; }
+
///
/// Block height where the protocol was applied
///
diff --git a/Tzkt.Api/Repositories/ProtocolRepository.cs b/Tzkt.Api/Repositories/ProtocolRepository.cs
index 30c453ced..d09a5edbb 100644
--- a/Tzkt.Api/Repositories/ProtocolRepository.cs
+++ b/Tzkt.Api/Repositories/ProtocolRepository.cs
@@ -37,6 +37,7 @@ ORDER BY ""FirstLevel"" DESC
{
Code = row.Code,
Hash = row.Hash,
+ Version = row.Version,
FirstLevel = row.FirstLevel,
FirstCycle = row.FirstCycle,
FirstCycleLevel = row.FirstCycleLevel,
@@ -105,6 +106,7 @@ public async Task Get(int code)
{
Code = code,
Hash = row.Hash,
+ Version = row.Version,
FirstLevel = row.FirstLevel,
FirstCycle = row.FirstCycle,
FirstCycleLevel = row.FirstCycleLevel,
@@ -173,6 +175,7 @@ public async Task Get(string hash)
{
Code = row.Code,
Hash = hash,
+ Version = row.Version,
FirstLevel = row.FirstLevel,
FirstCycle = row.FirstCycle,
FirstCycleLevel = row.FirstCycleLevel,
@@ -242,6 +245,7 @@ public async Task> Get(SortParameter sort, OffsetParameter
{
Code = row.Code,
Hash = row.Hash,
+ Version = row.Version,
FirstLevel = row.FirstLevel,
FirstCycle = row.FirstCycle,
FirstCycleLevel = row.FirstCycleLevel,
diff --git a/Tzkt.Sync/Protocols/Handlers/Proto19/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto19/Activation/ProtoActivator.cs
index 8f9bcb749..976128c7e 100644
--- a/Tzkt.Sync/Protocols/Handlers/Proto19/Activation/ProtoActivator.cs
+++ b/Tzkt.Sync/Protocols/Handlers/Proto19/Activation/ProtoActivator.cs
@@ -30,6 +30,9 @@ protected override void UpgradeParameters(Protocol protocol, Protocol prev)
protocol.BlocksPerVoting = protocol.BlocksPerVoting * 3 / 2;
protocol.TimeBetweenBlocks = protocol.TimeBetweenBlocks * 2 / 3;
protocol.HardBlockGasLimit = prev.HardBlockGasLimit * 2 / 3;
+ protocol.SmartRollupCommitmentPeriod = 15 * 60 / protocol.TimeBetweenBlocks;
+ protocol.SmartRollupChallengeWindow = 14 * 24 * 60 * 60 / protocol.TimeBetweenBlocks;
+ protocol.SmartRollupTimeoutPeriod = 7 * 24 * 60 * 60 / protocol.TimeBetweenBlocks;
}
protected override async Task MigrateContext(AppState state)