From 4b4bc3b5b95d1ddc50d1a1c09548534562d99b05 Mon Sep 17 00:00:00 2001 From: 257Byte <257Byte@gmail.com> Date: Wed, 29 Sep 2021 01:22:17 +0300 Subject: [PATCH] Init hangzhounet scaffold --- .../Proto11/Activation/ProtoActivator.cs | 18 + .../Proto11/Commits/BakerCycleCommit.cs | 7 + .../Proto11/Commits/BakingRightsCommit.cs | 7 + .../Handlers/Proto11/Commits/BigMapCommit.cs | 7 + .../Handlers/Proto11/Commits/BlockCommit.cs | 7 + .../Handlers/Proto11/Commits/CycleCommit.cs | 7 + .../Proto11/Commits/DeactivationCommit.cs | 7 + .../Proto11/Commits/DelegatorCycleCommit.cs | 7 + .../Handlers/Proto11/Commits/FreezerCommit.cs | 7 + .../Commits/Operations/ActivationsCommit.cs | 7 + .../Commits/Operations/BallotsCommit.cs | 7 + .../Commits/Operations/DelegationsCommit.cs | 7 + .../Commits/Operations/DoubleBakingCommit.cs | 7 + .../Operations/DoubleEndorsingCommit.cs | 7 + .../Commits/Operations/EndorsementsCommit.cs | 7 + .../Operations/NonceRevelationsCommit.cs | 7 + .../Commits/Operations/OriginationsCommit.cs | 7 + .../Commits/Operations/ProposalsCommit.cs | 7 + .../Commits/Operations/RevealsCommit.cs | 7 + .../Commits/Operations/TransactionsCommit.cs | 7 + .../Commits/RevelationPenaltyCommit.cs | 7 + .../Proto11/Commits/SnapshotBalanceCommit.cs | 7 + .../Proto11/Commits/SoftwareCommit.cs | 7 + .../Handlers/Proto11/Commits/StateCommit.cs | 7 + .../Proto11/Commits/StatisticsCommit.cs | 7 + .../Handlers/Proto11/Commits/SubsidyCommit.cs | 7 + .../Handlers/Proto11/Commits/VotingCommit.cs | 7 + .../Proto11/Diagnostics/Diagnostics.cs | 7 + .../Handlers/Proto11/Proto11Handler.cs | 346 ++++++++++++++++++ .../Protocols/Handlers/Proto11/Rpc/Rpc.cs | 9 + .../Handlers/Proto11/Validation/Validator.cs | 7 + Tzkt.Sync/Protocols/Helpers/Chains.cs | 1 + Tzkt.Sync/Protocols/TezosProtocols.cs | 2 + 33 files changed, 572 insertions(+) create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Activation/ProtoActivator.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BakerCycleCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BakingRightsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BigMapCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BlockCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/CycleCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/DeactivationCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/DelegatorCycleCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/FreezerCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/ActivationsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/BallotsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DelegationsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DoubleBakingCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DoubleEndorsingCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/EndorsementsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/NonceRevelationsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/OriginationsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/ProposalsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/RevealsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/TransactionsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/RevelationPenaltyCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SnapshotBalanceCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SoftwareCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/StateCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/StatisticsCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SubsidyCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Commits/VotingCommit.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Diagnostics/Diagnostics.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Proto11Handler.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Rpc/Rpc.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto11/Validation/Validator.cs diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Activation/ProtoActivator.cs new file mode 100644 index 000000000..ca28ffa66 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Activation/ProtoActivator.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto11 +{ + class ProtoActivator : Proto10.ProtoActivator + { + public ProtoActivator(ProtocolHandler proto) : base(proto) { } + + protected override void UpgradeParameters(Protocol protocol, Protocol prev) { } + protected override Task MigrateContext(AppState state) => Task.CompletedTask; + protected override Task RevertContext(AppState state) => Task.CompletedTask; + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BakerCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BakerCycleCommit.cs new file mode 100644 index 000000000..2cd03882e --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BakerCycleCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class BakerCycleCommit : Proto6.BakerCycleCommit + { + public BakerCycleCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BakingRightsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BakingRightsCommit.cs new file mode 100644 index 000000000..73971fab0 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BakingRightsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class BakingRightsCommit : Proto10.BakingRightsCommit + { + public BakingRightsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BigMapCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BigMapCommit.cs new file mode 100644 index 000000000..63feda26e --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BigMapCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class BigMapCommit : Proto1.BigMapCommit + { + public BigMapCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BlockCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BlockCommit.cs new file mode 100644 index 000000000..2e11ab657 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/BlockCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class BlockCommit : Proto10.BlockCommit + { + public BlockCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/CycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/CycleCommit.cs new file mode 100644 index 000000000..505e22983 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/CycleCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class CycleCommit : Proto1.CycleCommit + { + public CycleCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/DeactivationCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/DeactivationCommit.cs new file mode 100644 index 000000000..5b957eed9 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/DeactivationCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class DeactivationCommit : Proto2.DeactivationCommit + { + public DeactivationCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/DelegatorCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/DelegatorCycleCommit.cs new file mode 100644 index 000000000..7c50482f6 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/DelegatorCycleCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class DelegatorCycleCommit : Proto3.DelegatorCycleCommit + { + public DelegatorCycleCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/FreezerCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/FreezerCommit.cs new file mode 100644 index 000000000..0015f29dd --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/FreezerCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class FreezerCommit : Proto9.FreezerCommit + { + public FreezerCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/ActivationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/ActivationsCommit.cs new file mode 100644 index 000000000..306cb3714 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/ActivationsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class ActivationsCommit : Proto5.ActivationsCommit + { + public ActivationsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/BallotsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/BallotsCommit.cs new file mode 100644 index 000000000..f4ed0f6ee --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/BallotsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class BallotsCommit : Proto3.BallotsCommit + { + public BallotsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DelegationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DelegationsCommit.cs new file mode 100644 index 000000000..df7a97efb --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DelegationsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class DelegationsCommit : Proto1.DelegationsCommit + { + public DelegationsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DoubleBakingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DoubleBakingCommit.cs new file mode 100644 index 000000000..868df019c --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DoubleBakingCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class DoubleBakingCommit : Proto2.DoubleBakingCommit + { + public DoubleBakingCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DoubleEndorsingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DoubleEndorsingCommit.cs new file mode 100644 index 000000000..fefe288fa --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/DoubleEndorsingCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class DoubleEndorsingCommit : Proto4.DoubleEndorsingCommit + { + public DoubleEndorsingCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/EndorsementsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/EndorsementsCommit.cs new file mode 100644 index 000000000..f0f637dc2 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/EndorsementsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class EndorsementsCommit : Proto1.EndorsementsCommit + { + public EndorsementsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/NonceRevelationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/NonceRevelationsCommit.cs new file mode 100644 index 000000000..12382334b --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/NonceRevelationsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class NonceRevelationsCommit : Proto1.NonceRevelationsCommit + { + public NonceRevelationsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/OriginationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/OriginationsCommit.cs new file mode 100644 index 000000000..3ef244d07 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/OriginationsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class OriginationsCommit : Proto5.OriginationsCommit + { + public OriginationsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/ProposalsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/ProposalsCommit.cs new file mode 100644 index 000000000..ca4acab51 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/ProposalsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class ProposalsCommit : Proto3.ProposalsCommit + { + public ProposalsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/RevealsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/RevealsCommit.cs new file mode 100644 index 000000000..ce6f50736 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/RevealsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class RevealsCommit : Proto1.RevealsCommit + { + public RevealsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/TransactionsCommit.cs new file mode 100644 index 000000000..361a5e90d --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/TransactionsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class TransactionsCommit : Proto5.TransactionsCommit + { + public TransactionsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/RevelationPenaltyCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/RevelationPenaltyCommit.cs new file mode 100644 index 000000000..7e9a86fd0 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/RevelationPenaltyCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class RevelationPenaltyCommit : Proto9.RevelationPenaltyCommit + { + public RevelationPenaltyCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SnapshotBalanceCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SnapshotBalanceCommit.cs new file mode 100644 index 000000000..94c3e98d4 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SnapshotBalanceCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class SnapshotBalanceCommit : Proto9.SnapshotBalanceCommit + { + public SnapshotBalanceCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SoftwareCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SoftwareCommit.cs new file mode 100644 index 000000000..c0f2a4b2c --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SoftwareCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class SoftwareCommit : Proto5.SoftwareCommit + { + public SoftwareCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/StateCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/StateCommit.cs new file mode 100644 index 000000000..fbd09b634 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/StateCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class StateCommit : Proto1.StateCommit + { + public StateCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/StatisticsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/StatisticsCommit.cs new file mode 100644 index 000000000..114c62d02 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/StatisticsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class StatisticsCommit : Proto1.StatisticsCommit + { + public StatisticsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SubsidyCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SubsidyCommit.cs new file mode 100644 index 000000000..ce3abbf6a --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/SubsidyCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class SubsidyCommit : Proto10.SubsidyCommit + { + public SubsidyCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/VotingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/VotingCommit.cs new file mode 100644 index 000000000..0fc0a0aa1 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/VotingCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class VotingCommit : Proto8.VotingCommit + { + public VotingCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Diagnostics/Diagnostics.cs new file mode 100644 index 000000000..1c41abc7a --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Diagnostics/Diagnostics.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class Diagnostics : Proto10.Diagnostics + { + public Diagnostics(ProtocolHandler handler) : base(handler) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Proto11Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Proto11Handler.cs new file mode 100644 index 000000000..188ac3950 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Proto11Handler.cs @@ -0,0 +1,346 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +using Tzkt.Data; +using Tzkt.Data.Models; +using Tzkt.Data.Models.Base; +using Tzkt.Sync.Services; +using Tzkt.Sync.Protocols.Proto11; +using System.Text.Json; + +namespace Tzkt.Sync.Protocols +{ + class Proto11Handler : ProtocolHandler + { + public override IDiagnostics Diagnostics { get; } + public override IValidator Validator { get; } + public override IRpc Rpc { get; } + + public Proto11Handler(TezosNode node, TzktContext db, CacheService cache, QuotesService quotes, IServiceProvider services, IConfiguration config, ILogger logger) + : base(node, db, cache, quotes, services, config, logger) + { + Rpc = new Rpc(node); + Diagnostics = new Diagnostics(this); + Validator = new Validator(this); + } + + public override Task Activate(AppState state, JsonElement block) => new ProtoActivator(this).Activate(state, block); + public override Task Deactivate(AppState state) => new ProtoActivator(this).Deactivate(state); + + public override async Task Commit(JsonElement block) + { + var blockCommit = new BlockCommit(this); + await blockCommit.Apply(block); + + await new SoftwareCommit(this).Apply(blockCommit.Block, block); + + var freezerCommit = new FreezerCommit(this); + await freezerCommit.Apply(blockCommit.Block, block); + + await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); + await new DeactivationCommit(this).Apply(blockCommit.Block, block); + + #region implicit operations + foreach (var op in block + .Required("metadata") + .RequiredArray("implicit_operations_results") + .EnumerateArray() + .Where(x => x.RequiredString("kind") == "transaction")) + await new SubsidyCommit(this).Apply(blockCommit.Block, op); + #endregion + + var operations = block.RequiredArray("operations", 4); + + #region operations 0 + foreach (var operation in operations[0].EnumerateArray()) + { + foreach (var content in operation.RequiredArray("contents", 1).EnumerateArray()) + { + switch (content.RequiredString("kind")) + { + case "endorsement_with_slot": + await new EndorsementsCommit(this).Apply(blockCommit.Block, operation, content); + break; + default: + throw new NotImplementedException($"'{content.RequiredString("kind")}' is not allowed in operations[0]"); + } + } + } + #endregion + + #region operations 1 + foreach (var operation in operations[1].EnumerateArray()) + { + foreach (var content in operation.RequiredArray("contents", 1).EnumerateArray()) + { + switch (content.RequiredString("kind")) + { + case "proposals": + await new ProposalsCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "ballot": + await new BallotsCommit(this).Apply(blockCommit.Block, operation, content); + break; + default: + throw new NotImplementedException($"'{content.RequiredString("kind")}' is not allowed in operations[1]"); + } + } + } + #endregion + + #region operations 2 + foreach (var operation in operations[2].EnumerateArray()) + { + foreach (var content in operation.RequiredArray("contents", 1).EnumerateArray()) + { + switch (content.RequiredString("kind")) + { + case "activate_account": + await new ActivationsCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "double_baking_evidence": + await new DoubleBakingCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "double_endorsement_evidence": + await new DoubleEndorsingCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "seed_nonce_revelation": + await new NonceRevelationsCommit(this).Apply(blockCommit.Block, operation, content); + break; + default: + throw new NotImplementedException($"'{content.RequiredString("kind")}' is not allowed in operations[2]"); + } + } + } + #endregion + + var bigMapCommit = new BigMapCommit(this); + + #region operations 3 + foreach (var operation in operations[3].EnumerateArray()) + { + Cache.AppState.IncreaseManagerCounter(operation.RequiredArray("contents").Count()); + + foreach (var content in operation.RequiredArray("contents").EnumerateArray()) + { + switch (content.RequiredString("kind")) + { + case "reveal": + await new RevealsCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "delegation": + await new DelegationsCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "origination": + var orig = new OriginationsCommit(this); + await orig.Apply(blockCommit.Block, operation, content); + if (orig.BigMapDiffs != null) + bigMapCommit.Append(orig.Origination, orig.Origination.Contract, orig.BigMapDiffs); + break; + case "transaction": + var parent = new TransactionsCommit(this); + await parent.Apply(blockCommit.Block, operation, content); + if (parent.BigMapDiffs != null) + bigMapCommit.Append(parent.Transaction, parent.Transaction.Target as Contract, parent.BigMapDiffs); + + if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult)) + { + foreach (var internalContent in internalResult.EnumerateArray()) + { + switch (internalContent.RequiredString("kind")) + { + case "delegation": + await new DelegationsCommit(this).ApplyInternal(blockCommit.Block, parent.Transaction, internalContent); + break; + case "origination": + var internalOrig = new OriginationsCommit(this); + await internalOrig.ApplyInternal(blockCommit.Block, parent.Transaction, internalContent); + if (internalOrig.BigMapDiffs != null) + bigMapCommit.Append(internalOrig.Origination, internalOrig.Origination.Contract, internalOrig.BigMapDiffs); + break; + case "transaction": + var internalTx = new TransactionsCommit(this); + await internalTx.ApplyInternal(blockCommit.Block, parent.Transaction, internalContent); + if (internalTx.BigMapDiffs != null) + bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); + break; + default: + throw new NotImplementedException($"internal '{content.RequiredString("kind")}' is not implemented"); + } + } + } + break; + default: + throw new NotImplementedException($"'{content.RequiredString("kind")}' is not expected in operations[3]"); + } + } + } + #endregion + + await bigMapCommit.Apply(); + + var brCommit = new BakingRightsCommit(this); + await brCommit.Apply(blockCommit.Block); + + var cycleCommit = new CycleCommit(this); + await cycleCommit.Apply(blockCommit.Block); + + await new DelegatorCycleCommit(this).Apply(blockCommit.Block, cycleCommit.FutureCycle); + + await new BakerCycleCommit(this).Apply( + blockCommit.Block, + cycleCommit.FutureCycle, + brCommit.FutureBakingRights, + brCommit.FutureEndorsingRights, + cycleCommit.Snapshots, + brCommit.CurrentRights); + + await new StatisticsCommit(this).Apply(blockCommit.Block, freezerCommit.FreezerUpdates); + await new VotingCommit(this).Apply(blockCommit.Block, block); + await new StateCommit(this).Apply(blockCommit.Block, block); + } + + public override async Task AfterCommit(JsonElement rawBlock) + { + var block = await Cache.Blocks.CurrentAsync(); + await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + } + + public override async Task BeforeRevert() + { + var block = await Cache.Blocks.CurrentAsync(); + await new SnapshotBalanceCommit(this).Revert(block); + } + + public override async Task Revert() + { + var currBlock = await Cache.Blocks.CurrentAsync(); + Db.TryAttach(currBlock); + + #region load operations + var operations = new List(40); + + if (currBlock.Operations.HasFlag(Operations.Activations)) + operations.AddRange(await Db.ActivationOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.Delegations)) + operations.AddRange(await Db.DelegationOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.Endorsements)) + operations.AddRange(await Db.EndorsementOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.Originations)) + operations.AddRange(await Db.OriginationOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.Reveals)) + operations.AddRange(await Db.RevealOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.Revelations)) + operations.AddRange(await Db.NonceRevelationOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.Transactions)) + operations.AddRange(await Db.TransactionOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.DoubleBakings)) + operations.AddRange(await Db.DoubleBakingOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.DoubleEndorsings)) + operations.AddRange(await Db.DoubleEndorsingOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.Ballots)) + operations.AddRange(await Db.BallotOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.Proposals)) + operations.AddRange(await Db.ProposalOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.RevelationPenalty)) + await Db.Entry(currBlock).Collection(x => x.RevelationPenalties).LoadAsync(); + + if (currBlock.Operations.HasFlag(Operations.Migrations)) + await Db.Entry(currBlock).Collection(x => x.Migrations).LoadAsync(); + + if (currBlock.Events.HasFlag(BlockEvents.NewAccounts)) + { + await Db.Entry(currBlock).Collection(x => x.CreatedAccounts).LoadAsync(); + foreach (var account in currBlock.CreatedAccounts) + Cache.Accounts.Add(account); + } + #endregion + + await new VotingCommit(this).Revert(currBlock); + await new StatisticsCommit(this).Revert(currBlock); + + await new BakerCycleCommit(this).Revert(currBlock); + await new DelegatorCycleCommit(this).Revert(currBlock); + await new CycleCommit(this).Revert(currBlock); + await new BakingRightsCommit(this).Revert(currBlock); + await new BigMapCommit(this).Revert(currBlock); + + foreach (var operation in operations.OrderByDescending(x => x.Id)) + { + switch (operation) + { + case EndorsementOperation endorsement: + await new EndorsementsCommit(this).Revert(currBlock, endorsement); + break; + case ProposalOperation proposal: + await new ProposalsCommit(this).Revert(currBlock, proposal); + break; + case BallotOperation ballot: + await new BallotsCommit(this).Revert(currBlock, ballot); + break; + case ActivationOperation activation: + await new ActivationsCommit(this).Revert(currBlock, activation); + break; + case DoubleBakingOperation doubleBaking: + await new DoubleBakingCommit(this).Revert(currBlock, doubleBaking); + break; + case DoubleEndorsingOperation doubleEndorsing: + await new DoubleEndorsingCommit(this).Revert(currBlock, doubleEndorsing); + break; + case NonceRevelationOperation revelation: + await new NonceRevelationsCommit(this).Revert(currBlock, revelation); + break; + case RevealOperation reveal: + await new RevealsCommit(this).Revert(currBlock, reveal); + break; + case DelegationOperation delegation: + if (delegation.InitiatorId == null) + await new DelegationsCommit(this).Revert(currBlock, delegation); + else + await new DelegationsCommit(this).RevertInternal(currBlock, delegation); + break; + case OriginationOperation origination: + if (origination.InitiatorId == null) + await new OriginationsCommit(this).Revert(currBlock, origination); + else + await new OriginationsCommit(this).RevertInternal(currBlock, origination); + break; + case TransactionOperation transaction: + if (transaction.InitiatorId == null) + await new TransactionsCommit(this).Revert(currBlock, transaction); + else + await new TransactionsCommit(this).RevertInternal(currBlock, transaction); + break; + default: + throw new NotImplementedException($"'{operation.GetType()}' is not implemented"); + } + } + + await new SubsidyCommit(this).Revert(currBlock); + + await new DeactivationCommit(this).Revert(currBlock); + await new RevelationPenaltyCommit(this).Revert(currBlock); + await new FreezerCommit(this).Revert(currBlock); + await new SoftwareCommit(this).Revert(currBlock); + await new BlockCommit(this).Revert(currBlock); + + await new StateCommit(this).Revert(currBlock); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Rpc/Rpc.cs new file mode 100644 index 000000000..2da0b0fe9 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Rpc/Rpc.cs @@ -0,0 +1,9 @@ +using Tzkt.Sync.Services; + +namespace Tzkt.Sync.Protocols.Proto11 +{ + class Rpc : Proto6.Rpc + { + public Rpc(TezosNode node) : base(node) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Validation/Validator.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Validation/Validator.cs new file mode 100644 index 000000000..66716d1f6 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Validation/Validator.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto11 +{ + class Validator : Proto10.Validator + { + public Validator(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Helpers/Chains.cs b/Tzkt.Sync/Protocols/Helpers/Chains.cs index e2779689e..7f66f775f 100644 --- a/Tzkt.Sync/Protocols/Helpers/Chains.cs +++ b/Tzkt.Sync/Protocols/Helpers/Chains.cs @@ -8,6 +8,7 @@ static class Chains "NetXSgo1ZT2DRUG" => "edo2net", "NetXxkAx4woPLyu" => "florencenet", "NetXz969SFaFn8k" => "granadanet", + "NetXuXoGoLxNK6o" => "hangzhounet", _ => "private" }; } diff --git a/Tzkt.Sync/Protocols/TezosProtocols.cs b/Tzkt.Sync/Protocols/TezosProtocols.cs index a2b29b913..20b73db7c 100644 --- a/Tzkt.Sync/Protocols/TezosProtocols.cs +++ b/Tzkt.Sync/Protocols/TezosProtocols.cs @@ -21,6 +21,7 @@ public static void AddTezosProtocols(this IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); } public static ProtocolHandler GetProtocolHandler(this IServiceProvider services, int level, string protocol) @@ -39,6 +40,7 @@ public static ProtocolHandler GetProtocolHandler(this IServiceProvider services, "PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA" => services.GetRequiredService(), "PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i" => services.GetRequiredService(), "PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV" => services.GetRequiredService(), + "PtHangzHogokSuiMHemCuowEavgYTP8J5qQ9fQS793MHYFpCY3r" => services.GetRequiredService(), _ => throw new NotImplementedException($"Protocol '{protocol}' is not supported"), }; }