diff --git a/Makefile b/Makefile index 531a89df7..301aeedd9 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ init: docker-compose exec -T db createdb -U tzkt -T template0 tzkt_db docker-compose exec -T db apt update docker-compose exec -T db apt install -y wget - docker-compose exec -T db wget "https://snapshots.tzkt.io/tzkt_v1.12_mainnet.backup" -O tzkt_db.backup + docker-compose exec -T db wget "https://snapshots.tzkt.io/tzkt_v1.13_mainnet.backup" -O tzkt_db.backup docker-compose exec -T db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup docker-compose exec -T db rm tzkt_db.backup docker-compose exec -T db apt autoremove --purge -y wget @@ -52,7 +52,7 @@ ghost-init: docker-compose -f docker-compose.ghost.yml exec -T ghost-db createdb -U tzkt -T template0 tzkt_db docker-compose -f docker-compose.ghost.yml exec -T ghost-db apt update docker-compose -f docker-compose.ghost.yml exec -T ghost-db apt install -y wget - docker-compose -f docker-compose.ghost.yml exec -T ghost-db wget "https://snapshots.tzkt.io/tzkt_v1.12_ghostnet.backup" -O tzkt_db.backup + docker-compose -f docker-compose.ghost.yml exec -T ghost-db wget "https://snapshots.tzkt.io/tzkt_v1.13_ghostnet.backup" -O tzkt_db.backup docker-compose -f docker-compose.ghost.yml exec -T ghost-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup docker-compose -f docker-compose.ghost.yml exec -T ghost-db rm tzkt_db.backup docker-compose -f docker-compose.ghost.yml exec -T ghost-db apt autoremove --purge -y wget @@ -67,49 +67,27 @@ ghost-stop: ghost-db-start: docker-compose -f docker-compose.ghost.yml up -d ghost-db -nairobi-init: - docker-compose -f docker-compose.nairobi.yml up -d nairobi-db - docker-compose -f docker-compose.nairobi.yml exec -T nairobi-db psql -U tzkt postgres -c '\l' - docker-compose -f docker-compose.nairobi.yml exec -T nairobi-db dropdb -U tzkt --if-exists tzkt_db - docker-compose -f docker-compose.nairobi.yml exec -T nairobi-db createdb -U tzkt -T template0 tzkt_db - docker-compose -f docker-compose.nairobi.yml exec -T nairobi-db apt update - docker-compose -f docker-compose.nairobi.yml exec -T nairobi-db apt install -y wget - docker-compose -f docker-compose.nairobi.yml exec -T nairobi-db wget "https://snapshots.tzkt.io/tzkt_v1.12_nairobinet.backup" -O tzkt_db.backup - docker-compose -f docker-compose.nairobi.yml exec -T nairobi-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup - docker-compose -f docker-compose.nairobi.yml exec -T nairobi-db rm tzkt_db.backup - docker-compose -f docker-compose.nairobi.yml exec -T nairobi-db apt autoremove --purge -y wget +oxford-init: + docker-compose -f docker-compose.oxford.yml up -d oxford-db + docker-compose -f docker-compose.oxford.yml exec -T oxford-db psql -U tzkt postgres -c '\l' + docker-compose -f docker-compose.oxford.yml exec -T oxford-db dropdb -U tzkt --if-exists tzkt_db + docker-compose -f docker-compose.oxford.yml exec -T oxford-db createdb -U tzkt -T template0 tzkt_db + docker-compose -f docker-compose.oxford.yml exec -T oxford-db apt update + docker-compose -f docker-compose.oxford.yml exec -T oxford-db apt install -y wget + docker-compose -f docker-compose.oxford.yml exec -T oxford-db wget "https://snapshots.tzkt.io/tzkt_v1.13_oxfordnet.backup" -O tzkt_db.backup + docker-compose -f docker-compose.oxford.yml exec -T oxford-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup + docker-compose -f docker-compose.oxford.yml exec -T oxford-db rm tzkt_db.backup + docker-compose -f docker-compose.oxford.yml exec -T oxford-db apt autoremove --purge -y wget docker-compose pull -nairobi-start: - docker-compose -f docker-compose.nairobi.yml up -d - -nairobi-stop: - docker-compose -f docker-compose.nairobi.yml down - -nairobi-db-start: - docker-compose -f docker-compose.nairobi.yml up -d nairobi-db - -mumbai-init: - docker-compose -f docker-compose.mumbai.yml up -d mumbai-db - docker-compose -f docker-compose.mumbai.yml exec -T mumbai-db psql -U tzkt postgres -c '\l' - docker-compose -f docker-compose.mumbai.yml exec -T mumbai-db dropdb -U tzkt --if-exists tzkt_db - docker-compose -f docker-compose.mumbai.yml exec -T mumbai-db createdb -U tzkt -T template0 tzkt_db - docker-compose -f docker-compose.mumbai.yml exec -T mumbai-db apt update - docker-compose -f docker-compose.mumbai.yml exec -T mumbai-db apt install -y wget - docker-compose -f docker-compose.mumbai.yml exec -T mumbai-db wget "https://snapshots.tzkt.io/tzkt_v1.12_mumbainet.backup" -O tzkt_db.backup - docker-compose -f docker-compose.mumbai.yml exec -T mumbai-db pg_restore -U tzkt -O -x -v -d tzkt_db -e -j 4 tzkt_db.backup - docker-compose -f docker-compose.mumbai.yml exec -T mumbai-db rm tzkt_db.backup - docker-compose -f docker-compose.mumbai.yml exec -T mumbai-db apt autoremove --purge -y wget - docker-compose pull - -mumbai-start: - docker-compose -f docker-compose.mumbai.yml up -d +oxford-start: + docker-compose -f docker-compose.oxford.yml up -d -mumbai-stop: - docker-compose -f docker-compose.mumbai.yml down +oxford-stop: + docker-compose -f docker-compose.oxford.yml down -mumbai-db-start: - docker-compose -f docker-compose.mumbai.yml up -d mumbai-db +oxford-db-start: + docker-compose -f docker-compose.oxford.yml up -d oxford-db reset: - docker-compose -f docker-compose.mumbai.yml down --volumes - docker-compose -f docker-compose.mumbai.yml up -d mumbai-db \ No newline at end of file + docker-compose -f docker-compose.oxford.yml down --volumes + docker-compose -f docker-compose.oxford.yml up -d oxford-db \ No newline at end of file diff --git a/README.md b/README.md index 46c7a0f2c..be0a77cfe 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,10 @@ sudo apt install -y dotnet-sdk-7.0 #### Install Postgresql ```` +sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt update -sudo apt -y install postgresql postgresql-contrib +sudo apt -y install postgresql-16 postgresql-contrib-16 ```` --- @@ -85,7 +87,7 @@ postgres=# \q #### Download fresh snapshot (example for mainnet) ```` -wget "https://snapshots.tzkt.io/tzkt_v1.12_mainnet.backup" -O /tmp/tzkt_db.backup +wget "https://snapshots.tzkt.io/tzkt_v1.13_mainnet.backup" -O /tmp/tzkt_db.backup ```` #### Restore database from the snapshot @@ -255,14 +257,11 @@ That's it. If you want to run the API as a daemon, take a look at this guide: ht In general the steps are the same as for the mainnet, you will just need to use a different RPC endpoint and DB snapshot. Here are presets for the current testnets: - Ghostnet: - - Snapshot: https://snapshots.tzkt.io/tzkt_v1.12_ghostnet.backup + - Snapshot: https://snapshots.tzkt.io/tzkt_v1.13_ghostnet.backup - RPC node: https://rpc.tzkt.io/ghostnet/ - - Mumbainet: - - Snapshot: https://snapshots.tzkt.io/tzkt_v1.12_mumbainet.backup - - RPC node: https://rpc.tzkt.io/mumbainet/ - - Nairobinet: - - Snapshot: https://snapshots.tzkt.io/tzkt_v1.12_nairobinet.backup - - RPC node: https://rpc.tzkt.io/nairobinet/ + - Oxfordnet: + - Snapshot: https://snapshots.tzkt.io/tzkt_v1.13_oxfordnet.backup + - RPC node: https://rpc.tzkt.io/oxfordnet/ ### Testnets & docker diff --git a/Tzkt.Api/Controllers/OperationsController.cs b/Tzkt.Api/Controllers/OperationsController.cs index e4ac31ee6..d307674ef 100644 --- a/Tzkt.Api/Controllers/OperationsController.cs +++ b/Tzkt.Api/Controllers/OperationsController.cs @@ -5030,6 +5030,63 @@ public async Task> GetSmartRollupRefuteOpsCount([FromQuery] Sr } #endregion + #region staking + /// + /// Get staking ops + /// + /// + /// Returns a list of staking operations. + /// + /// Filter + /// Pagination + /// Selection + /// Comma-separated list of ticker symbols to inject historical prices into response + /// + [HttpGet("staking")] + public async Task>> GetStakingOps( + [FromQuery] StakingOperationFilter filter, + [FromQuery] Pagination pagination, + [FromQuery] Selection selection, + [FromQuery] Symbols quote = Symbols.None) + { + var query = ResponseCacheService.BuildKey(Request.Path.Value, + ("filter", filter), ("pagination", pagination), ("selection", selection), ("quote", quote)); + + if (!ResponseCache.TryGet(query, out var res)) + res = ResponseCache.Set(query, selection.select == null + ? await Operations.GetStakingOps(filter, pagination, quote) + : new SelectionResponse + { + Cols = selection.Cols, + Rows = await Operations.GetStakingOps(filter, pagination, selection, quote) + }); + + return this.Bytes(res); + } + + /// + /// Get staking ops count + /// + /// + /// Returns a total number of staking operations. + /// + /// Filter + /// + [HttpGet("staking/count")] + public async Task> GetStakingOpsCount([FromQuery] StakingOperationFilter filter) + { + if (filter.Empty) + return Ok(State.Current.StakingOpsCount); + + var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); + + if (!ResponseCache.TryGet(query, out var res)) + res = ResponseCache.Set(query, await Operations.GetStakingOpsCount(filter)); + + return this.Bytes(res); + } + #endregion + #region migrations /// /// Get migrations @@ -5038,7 +5095,7 @@ public async Task> GetSmartRollupRefuteOpsCount([FromQuery] Sr /// Returns a list of migration operations (synthetic type). /// /// Filters migration operations by account. Allowed fields for `.eqx` mode: none. - /// Filters migration operations by kind (`bootstrap`, `activate_delegate`, `airdrop`, `proposal_invoice`, `origination`, `subsidy`). + /// Filters migration operations by kind (`bootstrap`, `activate_delegate`, `airdrop`, `proposal_invoice`, `origination`, `subsidy`, `remove_bigmap_key`). /// Filters migration operations by amount. /// Filters migration operations by internal TzKT id. /// Filters migration operations by level. @@ -5611,5 +5668,62 @@ public async Task> GetEndorsingRewardsCount( return this.Bytes(cached); } #endregion + + #region autostaking + /// + /// Get autostaking ops + /// + /// + /// Returns a list of autostaking operations. + /// + /// Filter + /// Pagination + /// Selection + /// Comma-separated list of ticker symbols to inject historical prices into response + /// + [HttpGet("autostaking")] + public async Task>> GetAutostakingOps( + [FromQuery] AutostakingOperationFilter filter, + [FromQuery] Pagination pagination, + [FromQuery] Selection selection, + [FromQuery] Symbols quote = Symbols.None) + { + var query = ResponseCacheService.BuildKey(Request.Path.Value, + ("filter", filter), ("pagination", pagination), ("selection", selection), ("quote", quote)); + + if (!ResponseCache.TryGet(query, out var res)) + res = ResponseCache.Set(query, selection.select == null + ? await Operations.GetAutostakingOps(filter, pagination, quote) + : new SelectionResponse + { + Cols = selection.Cols, + Rows = await Operations.GetAutostakingOps(filter, pagination, selection, quote) + }); + + return this.Bytes(res); + } + + /// + /// Get autostaking ops count + /// + /// + /// Returns a total number of autostaking operations. + /// + /// Filter + /// + [HttpGet("autostaking/count")] + public async Task> GetAutostakingOpsCount([FromQuery] AutostakingOperationFilter filter) + { + if (filter.Empty) + return Ok(State.Current.AutostakingOpsCount); + + var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); + + if (!ResponseCache.TryGet(query, out var res)) + res = ResponseCache.Set(query, await Operations.GetAutostakingOpsCount(filter)); + + return this.Bytes(res); + } + #endregion } } diff --git a/Tzkt.Api/Controllers/RewardsController.cs b/Tzkt.Api/Controllers/RewardsController.cs index afe2335a3..6614911d2 100644 --- a/Tzkt.Api/Controllers/RewardsController.cs +++ b/Tzkt.Api/Controllers/RewardsController.cs @@ -1,9 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Mvc; - +using NSwag.Annotations; using Tzkt.Api.Models; using Tzkt.Api.Repositories; @@ -88,20 +85,12 @@ public async Task>> GetBakerRewards( } } - /// - /// Get baker cycle rewards by cycle - /// - /// - /// Returns baker cycle rewards for the specified cycle. - /// - /// Baker address - /// Rewards cycle - /// Comma-separated list of ticker symbols to inject historical prices into response - /// + // deprecated + [OpenApiIgnore] [HttpGet("bakers/{address}/{cycle:int}")] - public Task GetBakerRewardsByCycle([Required][TzAddress] string address, [Min(0)] int cycle, Symbols quote = Symbols.None) + public async Task GetBakerRewardsByCycle([Required][TzAddress] string address, [Min(0)] int cycle, Symbols quote = Symbols.None) { - return Rewards.GetBakerRewards(address, cycle, quote); + return (await Rewards.GetBakerRewards(address, cycle, null, null, 100, quote)).FirstOrDefault(); } /// @@ -172,20 +161,12 @@ public async Task>> GetDelegatorRewar } } - /// - /// Get delegator cycle rewards by cycle - /// - /// - /// Returns delegator cycle rewards for the specified cycle. - /// - /// Delegator address - /// Rewards cycle - /// Comma-separated list of ticker symbols to inject historical prices into response - /// + // deprecated + [OpenApiIgnore] [HttpGet("delegators/{address}/{cycle:int}")] - public Task GetDelegatorRewardsByCycle([Required][Address] string address, [Min(0)] int cycle, Symbols quote = Symbols.None) + public async Task GetDelegatorRewardsByCycle([Required][Address] string address, [Min(0)] int cycle, Symbols quote = Symbols.None) { - return Rewards.GetDelegatorRewards(address, cycle, quote); + return (await Rewards.GetDelegatorRewards(address, cycle, null, null, 100, quote)).FirstOrDefault(); } /// diff --git a/Tzkt.Api/Extensions/ModelBindingContextExtension.cs b/Tzkt.Api/Extensions/ModelBindingContextExtension.cs index 883317f22..156c2306a 100644 --- a/Tzkt.Api/Extensions/ModelBindingContextExtension.cs +++ b/Tzkt.Api/Extensions/ModelBindingContextExtension.cs @@ -1442,6 +1442,126 @@ public static bool TryGetSrBondStatusList(this ModelBindingContext bindingContex return true; } + public static bool TryGetAutostakingAction(this ModelBindingContext bindingContext, string name, ref bool hasValue, out int? result) + { + result = null; + var valueObject = bindingContext.ValueProvider.GetValue(name); + + if (valueObject != ValueProviderResult.None) + { + bindingContext.ModelState.SetModelValue(name, valueObject); + if (!string.IsNullOrEmpty(valueObject.FirstValue)) + { + if (!AutostakingActions.TryParse(valueObject.FirstValue, out var value)) + { + bindingContext.ModelState.TryAddModelError(name, "Invalid autostaking action."); + return false; + } + hasValue = true; + result = value; + } + } + + return true; + } + + public static bool TryGetAutostakingActionsList(this ModelBindingContext bindingContext, string name, ref bool hasValue, out List result) + { + result = null; + var valueObject = bindingContext.ValueProvider.GetValue(name); + + if (valueObject != ValueProviderResult.None) + { + bindingContext.ModelState.SetModelValue(name, valueObject); + if (!string.IsNullOrEmpty(valueObject.FirstValue)) + { + var rawValues = valueObject.FirstValue.Split(',', StringSplitOptions.RemoveEmptyEntries); + + if (rawValues.Length == 0) + { + bindingContext.ModelState.TryAddModelError(name, "List should contain at least one item."); + return false; + } + + hasValue = true; + result = new List(rawValues.Length); + + foreach (var rawValue in rawValues) + { + if (!AutostakingActions.TryParse(rawValue, out var value)) + { + bindingContext.ModelState.TryAddModelError(name, "List contains invalid autostaking action."); + return false; + } + hasValue = true; + result.Add(value); + } + } + } + + return true; + } + + public static bool TryGetStakingOperationKind(this ModelBindingContext bindingContext, string name, ref bool hasValue, out int? result) + { + result = null; + var valueObject = bindingContext.ValueProvider.GetValue(name); + + if (valueObject != ValueProviderResult.None) + { + bindingContext.ModelState.SetModelValue(name, valueObject); + if (!string.IsNullOrEmpty(valueObject.FirstValue)) + { + if (!StakingOperationKinds.TryParse(valueObject.FirstValue, out var value)) + { + bindingContext.ModelState.TryAddModelError(name, "Invalid staking operation kind."); + return false; + } + hasValue = true; + result = value; + } + } + + return true; + } + + public static bool TryGetStakingOperationKindsList(this ModelBindingContext bindingContext, string name, ref bool hasValue, out List result) + { + result = null; + var valueObject = bindingContext.ValueProvider.GetValue(name); + + if (valueObject != ValueProviderResult.None) + { + bindingContext.ModelState.SetModelValue(name, valueObject); + if (!string.IsNullOrEmpty(valueObject.FirstValue)) + { + var rawValues = valueObject.FirstValue.Split(',', StringSplitOptions.RemoveEmptyEntries); + + if (rawValues.Length == 0) + { + bindingContext.ModelState.TryAddModelError(name, "List should contain at least one item."); + return false; + } + + hasValue = true; + result = new List(rawValues.Length); + + foreach (var rawValue in rawValues) + { + if (!StakingOperationKinds.TryParse(rawValue, out var value)) + { + bindingContext.ModelState.TryAddModelError(name, "List contains invalid staking operation kind."); + return false; + } + hasValue = true; + result.Add(value); + } + } + } + + return true; + } + public static bool TryGetSrMessageType(this ModelBindingContext bindingContext, string name, ref bool hasValue, out int? result) { result = null; diff --git a/Tzkt.Api/Models/Accounts/Delegate.cs b/Tzkt.Api/Models/Accounts/Delegate.cs index 5aefb6d8d..3b889c558 100644 --- a/Tzkt.Api/Models/Accounts/Delegate.cs +++ b/Tzkt.Api/Models/Accounts/Delegate.cs @@ -1,5 +1,4 @@ -using System; -using NJsonSchema.Annotations; +using NJsonSchema.Annotations; namespace Tzkt.Api.Models { @@ -56,15 +55,73 @@ public class Delegate : Account public long SmartRollupBonds { get; set; } /// - /// Amount of security deposit, currently locked for baked (produced) blocks and (or) given endorsements (micro tez) + /// Amount staked from the own balance (micro tez). + /// Like delegated amount, except for it is frozen and can be slashed. /// - public long FrozenDeposit { get; set; } + public long StakedBalance { get; set; } + + /// + /// Amount of "pseudo-tokens" received after staking. These pseudotokens are used for unstaking. + /// + public long StakedPseudotokens { get; set; } + + /// + /// Amount that was unstaked, but not yet finalized (i.e. it is still frozen) (micro tez). + /// + public long UnstakedBalance { get; set; } + + /// + /// Information about the baker, for which there are pending unstake requests. + /// + public Alias UnstakedBaker { get; set; } + + /// + /// Amount staked from external stakers (micro tez). + /// Like delegated amount, except for it is frozen and can be slashed. + /// + public long ExternalStakedBalance { get; set; } + + /// + /// Amount that was unstaked by external stakers, but not yet finalized (i.e. it is still frozen) (micro tez). + /// + public long ExternalUnstakedBalance { get; set; } + + /// + /// Total staked balance, which is `stakedBalance + externalStakedBalance`. + /// + public long TotalStakedBalance { get; set; } + + /// + /// Total amount of issued "pseudo-tokens". These pseudotokens are used for unstaking. + /// + public long IssuedPseudotokens { get; set; } + + /// + /// Number of external stakers. + /// + public int StakersCount { get; set; } + + /// + /// Amount lost due to inaccuracy of the economic protocol introduced in Oxford. + /// This amount is literally lost, because it is no longer available for the account in any mean, but for some reason it is counted as delegated. + /// + public long LostBalance { get; set; } /// /// Configured max amount allowed to be locked as a security deposit (micro tez) /// public long? FrozenDepositLimit { get; set; } + /// + /// This parameter determines the maximum portion (millionth) of external stake by stakers over the baker's own staked funds. + /// + public long? LimitOfStakingOverBaking { get; set; } + + /// + /// This parameter determines the fraction (billionth) of the rewards that accrue to the baker's liquid spendable balance — the remainder accrues to frozen stakes. + /// + public long? EdgeOfBakingOverStaking { get; set; } + /// /// An account nonce which is used to prevent operation replay /// @@ -361,6 +418,16 @@ public class Delegate : Account /// public int ActiveRefutationGamesCount { get; set; } + /// + /// Number of staking operations related to the account + /// + public int StakingOpsCount { get; set; } + + /// + /// Number of autostaking operations related to the account + /// + public int AutostakingOpsCount { get; set; } + /// /// Block height of the first operation, related to the delegate (baker) /// @@ -393,6 +460,11 @@ public class Delegate : Account public SoftwareAlias Software { get; set; } #region deprecated + /// + /// [DEPRECATED] + /// + public long FrozenDeposit => StakedBalance; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Accounts/User.cs b/Tzkt.Api/Models/Accounts/User.cs index 14c6ebf74..251c6eab0 100644 --- a/Tzkt.Api/Models/Accounts/User.cs +++ b/Tzkt.Api/Models/Accounts/User.cs @@ -1,5 +1,4 @@ -using System; -using NJsonSchema.Annotations; +using NJsonSchema.Annotations; namespace Tzkt.Api.Models { @@ -48,6 +47,33 @@ public class User : Account /// public long SmartRollupBonds { get; set; } + /// + /// Amount staked with the selected baker (micro tez). + /// Like delegated amount, except for it is frozen and can be slashed. + /// + public long StakedBalance { get; set; } + + /// + /// Amount of "pseudo-tokens" received after staking. These pseudotokens are used for unstaking. + /// + public long StakedPseudotokens { get; set; } + + /// + /// Amount that was unstaked, but not yet finalized (i.e. it is still frozen) (micro tez) + /// + public long UnstakedBalance { get; set; } + + /// + /// Information about the baker, for which there are pending unstake requests + /// + public Alias UnstakedBaker { get; set; } + + /// + /// Amount lost due to inaccuracy of the economic protocol introduced in Oxford. + /// This amount is literally lost, because it is no longer available for the account in any mean, but for some reason it is counted as delegated. + /// + public long LostBalance { get; set; } + /// /// An account nonce which is used to prevent operation replay /// @@ -255,6 +281,11 @@ public class User : Account /// public int ActiveRefutationGamesCount { get; set; } + /// + /// Number of staking operations related to the account + /// + public int StakingOpsCount { get; set; } + /// /// Block height of the first operation, related to the account /// diff --git a/Tzkt.Api/Models/Baking/BakerRewards.cs b/Tzkt.Api/Models/Baking/BakerRewards.cs index 50bf9b9e6..6b12f8d0e 100644 --- a/Tzkt.Api/Models/Baking/BakerRewards.cs +++ b/Tzkt.Api/Models/Baking/BakerRewards.cs @@ -8,29 +8,46 @@ public class BakerRewards public int Cycle { get; set; } /// - /// Staking balance at the snapshot time. + /// Baker's baking power /// - public long StakingBalance { get; set; } + public long BakingPower { get; set; } /// - /// Active stake participating in rights distribution. + /// Sum of baking power of all active bakers /// - public long ActiveStake { get; set; } + public long TotalBakingPower { get; set; } /// - /// Total active stake among all selected bakers. + /// Amount delegated from the baker's own balance (micro tez). + /// This amount doesn't include staked amount. /// - public long SelectedStake { get; set; } + public long OwnDelegatedBalance { get; set; } /// - /// Balance delegated to the baker at the snapshot time (sum of delegators' balances). + /// Amount delegated from external delegators (micro tez). + /// This amount doesn't include external staked amount. /// - public long DelegatedBalance { get; set; } + public long ExternalDelegatedBalance { get; set; } /// - /// Number of delegators at the snapshot time. + /// Number of delegators (those who delegated to the baker). /// - public int NumDelegators { get; set; } + public int DelegatorsCount { get; set; } + + /// + /// Amount staked from the baker's own balance (micro tez). + /// + public long OwnStakedBalance { get; set; } + + /// + /// Amount staked from external stakers (micro tez). + /// + public long ExternalStakedBalance { get; set; } + + /// + /// Number of external stakers (those who delegated to the baker and also staked some amount). + /// + public int StakersCount { get; set; } /// /// Expected value of how many blocks baker should produce based on baker's active stake, selected stake and blocks per cycle. @@ -58,9 +75,21 @@ public class BakerRewards public int Blocks { get; set; } /// - /// Rewards received for baked blocks (both proposed and re-proposed blocks). + /// Rewards received for baked blocks (both proposed and re-proposed blocks) on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long BlockRewardsLiquid { get; set; } + + /// + /// Rewards received for baked blocks (both proposed and re-proposed blocks) on baker's staked balance (i.e. they are frozen). + /// + public long BlockRewardsStakedOwn { get; set; } + + /// + /// Rewards received for baked blocks (both proposed and re-proposed blocks) on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). /// - public long BlockRewards { get; set; } + public long BlockRewardsStakedShared { get; set; } /// /// Number of missed opportunities to bake block. @@ -88,9 +117,21 @@ public class BakerRewards public int Endorsements { get; set; } /// - /// Rewards received for endorsed slots. + /// Rewards received for endorsed slots on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long EndorsementRewardsLiquid { get; set; } + + /// + /// Rewards received for endorsed slots on baker's staked balance (i.e. they are frozen). + /// + public long EndorsementRewardsStakedOwn { get; set; } + + /// + /// Rewards received for endorsed slots on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). /// - public long EndorsementRewards { get; set; } + public long EndorsementRewardsStakedShared { get; set; } /// /// Number of not endorsed (missed) slots. @@ -118,9 +159,24 @@ public class BakerRewards public long DoubleBakingRewards { get; set; } /// - /// Amount of frozen deposits lost due to double baking + /// Amount of baker's own staked balance lost due to double baking /// - public long DoubleBakingLosses { get; set; } + public long DoubleBakingLostStaked { get; set; } + + /// + /// Amount of baker's own unstaked balance lost due to double baking + /// + public long DoubleBakingLostUnstaked { get; set; } + + /// + /// Amount of baker's external staked balance lost due to double baking + /// + public long DoubleBakingLostExternalStaked { get; set; } + + /// + /// Amount of baker's external unstaked balance lost due to double baking + /// + public long DoubleBakingLostExternalUnstaked { get; set; } /// /// Rewards for detecting double endorsing (accusing someone of validating two different blocks at the same level). @@ -128,9 +184,24 @@ public class BakerRewards public long DoubleEndorsingRewards { get; set; } /// - /// Amount of frozen deposits lost due to double endorsing + /// Amount of baker's own staked balance lost due to double endorsing + /// + public long DoubleEndorsingLostStaked { get; set; } + + /// + /// Amount of baker's own unstaked balance lost due to double endorsing + /// + public long DoubleEndorsingLostUnstaked { get; set; } + + /// + /// Amount of baker's external staked balance lost due to double endorsing + /// + public long DoubleEndorsingLostExternalStaked { get; set; } + + /// + /// Amount of baker's external unstaked balance lost due to double endorsing /// - public long DoubleEndorsingLosses { get; set; } + public long DoubleEndorsingLostExternalUnstaked { get; set; } /// /// Rewards for detecting double preendorsing (accusing someone of pre-validating two different blocks at the same level). @@ -138,19 +209,63 @@ public class BakerRewards public long DoublePreendorsingRewards { get; set; } /// - /// Amount of frozen deposits lost due to double preendorsing + /// Amount of baker's own staked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostStaked { get; set; } + + /// + /// Amount of baker's own unstaked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostUnstaked { get; set; } + + /// + /// Amount of baker's external staked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostExternalStaked { get; set; } + + /// + /// Amount of baker's external unstaked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostExternalUnstaked { get; set; } + + /// + /// Rewards for including vdf revelations, received on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long VdfRevelationRewardsLiquid { get; set; } + + /// + /// Rewards for including vdf revelations, received on baker's staked balance (i.e. they are frozen). + /// + public long VdfRevelationRewardsStakedOwn { get; set; } + + /// + /// Rewards for including vdf revelations, received on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). + /// + public long VdfRevelationRewardsStakedShared { get; set; } + + /// + /// Rewards for including seed nonce revelations, received on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long NonceRevelationRewardsLiquid { get; set; } + + /// + /// Rewards for including seed nonce revelations, received on baker's staked balance (i.e. they are frozen). /// - public long DoublePreendorsingLosses { get; set; } + public long NonceRevelationRewardsStakedOwn { get; set; } /// - /// Rewards for including into a block seed nonce revelation operations. + /// Rewards for including seed nonce revelations, received on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). /// - public long RevelationRewards { get; set; } + public long NonceRevelationRewardsStakedShared { get; set; } /// /// Amount of frozen deposits lost due to missing seed nonce revelation (always zero after Ithaca). /// - public long RevelationLosses { get; set; } + public long NonceRevelationLosses { get; set; } #region injecting /// @@ -160,6 +275,66 @@ public class BakerRewards #endregion #region deprecated + /// + /// [DEPRECATED] + /// + public long RevelationRewards => NonceRevelationRewardsLiquid + NonceRevelationRewardsStakedOwn + NonceRevelationRewardsStakedShared + VdfRevelationRewardsLiquid + VdfRevelationRewardsStakedOwn + VdfRevelationRewardsStakedShared; + + /// + /// [DEPRECATED] + /// + public long RevelationLosses => NonceRevelationLosses; + + /// + /// [DEPRECATED] + /// + public long DoublePreendorsingLosses => DoublePreendorsingLostStaked + DoublePreendorsingLostExternalStaked + DoublePreendorsingLostUnstaked + DoublePreendorsingLostExternalUnstaked; + + /// + /// [DEPRECATED] + /// + public long DoubleEndorsingLosses => DoubleEndorsingLostStaked + DoubleEndorsingLostExternalStaked + DoubleEndorsingLostUnstaked + DoubleEndorsingLostExternalUnstaked; + + /// + /// [DEPRECATED] + /// + public long DoubleBakingLosses => DoubleBakingLostStaked + DoubleBakingLostExternalStaked + DoubleBakingLostUnstaked + DoubleBakingLostExternalUnstaked; + + /// + /// [DEPRECATED] + /// + public long EndorsementRewards => EndorsementRewardsLiquid + EndorsementRewardsStakedOwn + EndorsementRewardsStakedShared; + + /// + /// [DEPRECATED] + /// + public long BlockRewards => BlockRewardsLiquid + BlockRewardsStakedOwn + BlockRewardsStakedShared; + + /// + /// [DEPRECATED] + /// + public long StakingBalance => OwnDelegatedBalance + ExternalDelegatedBalance + OwnStakedBalance + ExternalStakedBalance; + + /// + /// [DEPRECATED] + /// + public long ActiveStake => BakingPower; + + /// + /// [DEPRECATED] + /// + public long SelectedStake => TotalBakingPower; + + /// + /// [DEPRECATED] + /// + public long DelegatedBalance => ExternalStakedBalance + ExternalDelegatedBalance; + + /// + /// [DEPRECATED] + /// + public int NumDelegators => DelegatorsCount; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Baking/Cycle.cs b/Tzkt.Api/Models/Baking/Cycle.cs index 1e7d4dc40..652c10b51 100644 --- a/Tzkt.Api/Models/Baking/Cycle.cs +++ b/Tzkt.Api/Models/Baking/Cycle.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class Cycle { @@ -50,29 +48,39 @@ public class Cycle public int TotalBakers { get; set; } /// - /// Total staking balance of all active in this cycle bakers + /// Total baking power of all active in this cycle bakers + /// + public long TotalBakingPower { get; set; } + + /// + /// Fixed reward paid to the block payload proposer in this cycle (micro tez) + /// + public long BlockReward { get; set; } + + /// + /// Bonus reward paid to the block producer in this cycle (micro tez) /// - public long TotalStaking { get; set; } + public long BlockBonusPerSlot { get; set; } /// - /// Total number of active bakers' delegators + /// Reward for endorsing in this cycle (micro tez) /// - public int TotalDelegators { get; set; } + public long EndorsementRewardPerSlot { get; set; } /// - /// Total balance delegated to active bakers + /// Reward for seed nonce revelation in this cycle (micro tez) /// - public long TotalDelegated { get; set; } + public long NonceRevelationReward { get; set; } /// - /// Total number of bakers in stake distribution for the cycle + /// Reward for vdf revelation in this cycle (micro tez) /// - public int SelectedBakers { get; set; } + public long VdfRevelationReward { get; set; } /// - /// Total stake of bakers in stake distribution for the cycle + /// Liquidity baking subsidy in this cycle (micro tez) /// - public long SelectedStake { get; set; } + public long LBSubsidy { get; set; } #region injecting /// @@ -82,6 +90,31 @@ public class Cycle #endregion #region deprecated + /// + /// [DEPRECATED] + /// + public long TotalStaking => TotalBakingPower; + + /// + /// [DEPRECATED] + /// + public int TotalDelegators => 0; + + /// + /// [DEPRECATED] + /// + public long TotalDelegated => 0; + + /// + /// [DEPRECATED] + /// + public int SelectedBakers => TotalBakers; + + /// + /// [DEPRECATED] + /// + public long SelectedStake => TotalBakingPower; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Baking/DelegatorRewards.cs b/Tzkt.Api/Models/Baking/DelegatorRewards.cs index 2541fbf01..e7063a42d 100644 --- a/Tzkt.Api/Models/Baking/DelegatorRewards.cs +++ b/Tzkt.Api/Models/Baking/DelegatorRewards.cs @@ -8,9 +8,15 @@ public class DelegatorRewards public int Cycle { get; set; } /// - /// Delegator balance at the snapshot time. + /// Amount delegated to the baker at the snapshot time (micro tez). + /// This amount doesn't include staked amount. /// - public long Balance { get; set; } + public long DelegatedBalance { get; set; } + + /// + /// Amount staked to the baker at the snapshot time (micro tez). + /// + public long StakedBalance { get; set; } /// /// Baker at the snapshot time. @@ -18,19 +24,36 @@ public class DelegatorRewards public Alias Baker { get; set; } /// - /// Staking balance of the baker at the snapshot time. + /// Baker's baking power + /// + public long BakingPower { get; set; } + + /// + /// Sum of baking power of all active bakers + /// + public long TotalBakingPower { get; set; } + + /// + /// Amount delegated from the baker's own balance (micro tez). + /// This amount doesn't include staked amount. /// - public long StakingBalance { get; set; } + public long BakerDelegatedBalance { get; set; } /// - /// Active stake of the baker participating in rights distribution. + /// Amount delegated from external delegators (micro tez). + /// This amount doesn't include external staked amount. /// - public long ActiveStake { get; set; } + public long ExternalDelegatedBalance { get; set; } /// - /// Total active stake among all selected bakers. + /// Amount staked from the baker's own balance (micro tez). /// - public long SelectedStake { get; set; } + public long BakerStakedBalance { get; set; } + + /// + /// Amount staked from external stakers (micro tez). + /// + public long ExternalStakedBalance { get; set; } /// /// Expected value of how many blocks baker should produce based on baker's active stake, selected stake and blocks per cycle. @@ -58,9 +81,21 @@ public class DelegatorRewards public int Blocks { get; set; } /// - /// Rewards received for baked blocks (both proposed and re-proposed blocks). + /// Rewards received for baked blocks (both proposed and re-proposed blocks) on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long BlockRewardsLiquid { get; set; } + + /// + /// Rewards received for baked blocks (both proposed and re-proposed blocks) on baker's staked balance (i.e. they are frozen). + /// + public long BlockRewardsStakedOwn { get; set; } + + /// + /// Rewards received for baked blocks (both proposed and re-proposed blocks) on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). /// - public long BlockRewards { get; set; } + public long BlockRewardsStakedShared { get; set; } /// /// Number of missed opportunities to bake block. @@ -88,9 +123,21 @@ public class DelegatorRewards public int Endorsements { get; set; } /// - /// Rewards received for endorsed slots. + /// Rewards received for endorsed slots on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long EndorsementRewardsLiquid { get; set; } + + /// + /// Rewards received for endorsed slots on baker's staked balance (i.e. they are frozen). /// - public long EndorsementRewards { get; set; } + public long EndorsementRewardsStakedOwn { get; set; } + + /// + /// Rewards received for endorsed slots on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). + /// + public long EndorsementRewardsStakedShared { get; set; } /// /// Number of not endorsed (missed) slots. @@ -118,9 +165,24 @@ public class DelegatorRewards public long DoubleBakingRewards { get; set; } /// - /// Amount of frozen deposits lost due to double baking + /// Amount of baker's own staked balance lost due to double baking /// - public long DoubleBakingLosses { get; set; } + public long DoubleBakingLostStaked { get; set; } + + /// + /// Amount of baker's own unstaked balance lost due to double baking + /// + public long DoubleBakingLostUnstaked { get; set; } + + /// + /// Amount of baker's external staked balance lost due to double baking + /// + public long DoubleBakingLostExternalStaked { get; set; } + + /// + /// Amount of baker's external unstaked balance lost due to double baking + /// + public long DoubleBakingLostExternalUnstaked { get; set; } /// /// Rewards for detecting double endorsing (accusing someone of validating two different blocks at the same level). @@ -128,9 +190,24 @@ public class DelegatorRewards public long DoubleEndorsingRewards { get; set; } /// - /// Amount of frozen deposits lost due to double endorsing + /// Amount of baker's own staked balance lost due to double endorsing + /// + public long DoubleEndorsingLostStaked { get; set; } + + /// + /// Amount of baker's own unstaked balance lost due to double endorsing + /// + public long DoubleEndorsingLostUnstaked { get; set; } + + /// + /// Amount of baker's external staked balance lost due to double endorsing + /// + public long DoubleEndorsingLostExternalStaked { get; set; } + + /// + /// Amount of baker's external unstaked balance lost due to double endorsing /// - public long DoubleEndorsingLosses { get; set; } + public long DoubleEndorsingLostExternalUnstaked { get; set; } /// /// Rewards for detecting double preendorsing (accusing someone of pre-validating two different blocks at the same level). @@ -138,19 +215,63 @@ public class DelegatorRewards public long DoublePreendorsingRewards { get; set; } /// - /// Amount of frozen deposits lost due to double preendorsing + /// Amount of baker's own staked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostStaked { get; set; } + + /// + /// Amount of baker's own unstaked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostUnstaked { get; set; } + + /// + /// Amount of baker's external staked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostExternalStaked { get; set; } + + /// + /// Amount of baker's external unstaked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostExternalUnstaked { get; set; } + + /// + /// Rewards for including vdf revelations, received on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long VdfRevelationRewardsLiquid { get; set; } + + /// + /// Rewards for including vdf revelations, received on baker's staked balance (i.e. they are frozen). + /// + public long VdfRevelationRewardsStakedOwn { get; set; } + + /// + /// Rewards for including vdf revelations, received on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). + /// + public long VdfRevelationRewardsStakedShared { get; set; } + + /// + /// Rewards for including seed nonce revelations, received on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long NonceRevelationRewardsLiquid { get; set; } + + /// + /// Rewards for including seed nonce revelations, received on baker's staked balance (i.e. they are frozen). /// - public long DoublePreendorsingLosses { get; set; } + public long NonceRevelationRewardsStakedOwn { get; set; } /// - /// Rewards for including into a block seed nonce revelation operations. + /// Rewards for including seed nonce revelations, received on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). /// - public long RevelationRewards { get; set; } + public long NonceRevelationRewardsStakedShared { get; set; } /// /// Amount of frozen deposits lost due to missing seed nonce revelation (always zero after Ithaca). /// - public long RevelationLosses { get; set; } + public long NonceRevelationLosses { get; set; } #region injecting /// @@ -160,6 +281,61 @@ public class DelegatorRewards #endregion #region deprecated + /// + /// [DEPRECATED] + /// + public long RevelationRewards => NonceRevelationRewardsLiquid + NonceRevelationRewardsStakedOwn + NonceRevelationRewardsStakedShared + VdfRevelationRewardsLiquid + VdfRevelationRewardsStakedOwn + VdfRevelationRewardsStakedShared; + + /// + /// [DEPRECATED] + /// + public long RevelationLosses => NonceRevelationLosses; + + /// + /// [DEPRECATED] + /// + public long DoublePreendorsingLosses => DoublePreendorsingLostStaked + DoublePreendorsingLostExternalStaked + DoublePreendorsingLostUnstaked + DoublePreendorsingLostExternalUnstaked; + + /// + /// [DEPRECATED] + /// + public long DoubleEndorsingLosses => DoubleEndorsingLostStaked + DoubleEndorsingLostExternalStaked + DoubleEndorsingLostUnstaked + DoubleEndorsingLostExternalUnstaked; + + /// + /// [DEPRECATED] + /// + public long DoubleBakingLosses => DoubleBakingLostStaked + DoubleBakingLostExternalStaked + DoubleBakingLostUnstaked + DoubleBakingLostExternalUnstaked; + + /// + /// [DEPRECATED] + /// + public long EndorsementRewards => EndorsementRewardsLiquid + EndorsementRewardsStakedOwn + EndorsementRewardsStakedShared; + + /// + /// [DEPRECATED] + /// + public long BlockRewards => BlockRewardsLiquid + BlockRewardsStakedOwn + BlockRewardsStakedShared; + + /// + /// [DEPRECATED] + /// + public long StakingBalance => BakerDelegatedBalance + ExternalDelegatedBalance + BakerStakedBalance + ExternalStakedBalance; + + /// + /// [DEPRECATED] + /// + public long ActiveStake => BakingPower; + + /// + /// [DEPRECATED] + /// + public long SelectedStake => TotalBakingPower; + + /// + /// [DEPRECATED] + /// + public long Balance => DelegatedBalance + StakedBalance; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Baking/RewardSplit.cs b/Tzkt.Api/Models/Baking/RewardSplit.cs index 48b34e84c..e02a69e2c 100644 --- a/Tzkt.Api/Models/Baking/RewardSplit.cs +++ b/Tzkt.Api/Models/Baking/RewardSplit.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class RewardSplit { @@ -10,29 +8,46 @@ public class RewardSplit public int Cycle { get; set; } /// - /// Staking balance at the snapshot time. + /// Baker's baking power + /// + public long BakingPower { get; set; } + + /// + /// Sum of baking power of all active bakers + /// + public long TotalBakingPower { get; set; } + + /// + /// Amount delegated from the baker's own balance (micro tez). + /// This amount doesn't include staked amount. /// - public long StakingBalance { get; set; } + public long OwnDelegatedBalance { get; set; } /// - /// Active stake participating in rights distribution. + /// Amount delegated from external delegators (micro tez). + /// This amount doesn't include external staked amount. /// - public long ActiveStake { get; set; } + public long ExternalDelegatedBalance { get; set; } /// - /// Total active stake among all selected bakers. + /// Number of delegators (those who delegated to the baker). /// - public long SelectedStake { get; set; } + public int DelegatorsCount { get; set; } /// - /// Balance delegated to the baker at the snapshot time (sum of delegators' balances). + /// Amount staked from the baker's own balance (micro tez). /// - public long DelegatedBalance { get; set; } + public long OwnStakedBalance { get; set; } /// - /// Number of delegators at the snapshot time. + /// Amount staked from external stakers (micro tez). /// - public int NumDelegators { get; set; } + public long ExternalStakedBalance { get; set; } + + /// + /// Number of external stakers (those who delegated to the baker and also staked some amount). + /// + public int StakersCount { get; set; } /// /// Expected value of how many blocks baker should produce based on baker's active stake, selected stake and blocks per cycle. @@ -59,9 +74,21 @@ public class RewardSplit public int Blocks { get; set; } /// - /// Rewards received for baked blocks (both proposed and re-proposed blocks). + /// Rewards received for baked blocks (both proposed and re-proposed blocks) on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long BlockRewardsLiquid { get; set; } + + /// + /// Rewards received for baked blocks (both proposed and re-proposed blocks) on baker's staked balance (i.e. they are frozen). + /// + public long BlockRewardsStakedOwn { get; set; } + + /// + /// Rewards received for baked blocks (both proposed and re-proposed blocks) on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). /// - public long BlockRewards { get; set; } + public long BlockRewardsStakedShared { get; set; } /// /// Number of missed opportunities to bake block. @@ -89,9 +116,21 @@ public class RewardSplit public int Endorsements { get; set; } /// - /// Rewards received for endorsed slots. + /// Rewards received for endorsed slots on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long EndorsementRewardsLiquid { get; set; } + + /// + /// Rewards received for endorsed slots on baker's staked balance (i.e. they are frozen). + /// + public long EndorsementRewardsStakedOwn { get; set; } + + /// + /// Rewards received for endorsed slots on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). /// - public long EndorsementRewards { get; set; } + public long EndorsementRewardsStakedShared { get; set; } /// /// Number of not endorsed (missed) slots. @@ -119,9 +158,24 @@ public class RewardSplit public long DoubleBakingRewards { get; set; } /// - /// Amount of frozen deposits lost due to double baking + /// Amount of baker's own staked balance lost due to double baking + /// + public long DoubleBakingLostStaked { get; set; } + + /// + /// Amount of baker's own unstaked balance lost due to double baking + /// + public long DoubleBakingLostUnstaked { get; set; } + + /// + /// Amount of baker's external staked balance lost due to double baking /// - public long DoubleBakingLosses { get; set; } + public long DoubleBakingLostExternalStaked { get; set; } + + /// + /// Amount of baker's external unstaked balance lost due to double baking + /// + public long DoubleBakingLostExternalUnstaked { get; set; } /// /// Rewards for detecting double endorsing (accusing someone of validating two different blocks at the same level). @@ -129,9 +183,24 @@ public class RewardSplit public long DoubleEndorsingRewards { get; set; } /// - /// Amount of frozen deposits lost due to double endorsing + /// Amount of baker's own staked balance lost due to double endorsing + /// + public long DoubleEndorsingLostStaked { get; set; } + + /// + /// Amount of baker's own unstaked balance lost due to double endorsing + /// + public long DoubleEndorsingLostUnstaked { get; set; } + + /// + /// Amount of baker's external staked balance lost due to double endorsing /// - public long DoubleEndorsingLosses { get; set; } + public long DoubleEndorsingLostExternalStaked { get; set; } + + /// + /// Amount of baker's external unstaked balance lost due to double endorsing + /// + public long DoubleEndorsingLostExternalUnstaked { get; set; } /// /// Rewards for detecting double preendorsing (accusing someone of pre-validating two different blocks at the same level). @@ -139,19 +208,63 @@ public class RewardSplit public long DoublePreendorsingRewards { get; set; } /// - /// Amount of frozen deposits lost due to double preendorsing + /// Amount of baker's own staked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostStaked { get; set; } + + /// + /// Amount of baker's own unstaked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostUnstaked { get; set; } + + /// + /// Amount of baker's external staked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostExternalStaked { get; set; } + + /// + /// Amount of baker's external unstaked balance lost due to double preendorsing + /// + public long DoublePreendorsingLostExternalUnstaked { get; set; } + + /// + /// Rewards for including vdf revelations, received on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long VdfRevelationRewardsLiquid { get; set; } + + /// + /// Rewards for including vdf revelations, received on baker's staked balance (i.e. they are frozen). + /// + public long VdfRevelationRewardsStakedOwn { get; set; } + + /// + /// Rewards for including vdf revelations, received on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). + /// + public long VdfRevelationRewardsStakedShared { get; set; } + + /// + /// Rewards for including seed nonce revelations, received on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long NonceRevelationRewardsLiquid { get; set; } + + /// + /// Rewards for including seed nonce revelations, received on baker's staked balance (i.e. they are frozen). /// - public long DoublePreendorsingLosses { get; set; } + public long NonceRevelationRewardsStakedOwn { get; set; } /// - /// Rewards for including into a block seed nonce revelation operations. + /// Rewards for including seed nonce revelations, received on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). /// - public long RevelationRewards { get; set; } + public long NonceRevelationRewardsStakedShared { get; set; } /// /// Amount of frozen deposits lost due to missing seed nonce revelation (always zero after Ithaca). /// - public long RevelationLosses { get; set; } + public long NonceRevelationLosses { get; set; } /// /// List of delegators at the snapshot time @@ -159,6 +272,66 @@ public class RewardSplit public IEnumerable Delegators { get; set; } #region deprecated + /// + /// [DEPRECATED] + /// + public long RevelationRewards => NonceRevelationRewardsLiquid + NonceRevelationRewardsStakedOwn + NonceRevelationRewardsStakedShared + VdfRevelationRewardsLiquid + VdfRevelationRewardsStakedOwn + VdfRevelationRewardsStakedShared; + + /// + /// [DEPRECATED] + /// + public long RevelationLosses => NonceRevelationLosses; + + /// + /// [DEPRECATED] + /// + public long DoublePreendorsingLosses => DoublePreendorsingLostStaked + DoublePreendorsingLostExternalStaked + DoublePreendorsingLostUnstaked + DoublePreendorsingLostExternalUnstaked; + + /// + /// [DEPRECATED] + /// + public long DoubleEndorsingLosses => DoubleEndorsingLostStaked + DoubleEndorsingLostExternalStaked + DoubleEndorsingLostUnstaked + DoubleEndorsingLostExternalUnstaked; + + /// + /// [DEPRECATED] + /// + public long DoubleBakingLosses => DoubleBakingLostStaked + DoubleBakingLostExternalStaked + DoubleBakingLostUnstaked + DoubleBakingLostExternalUnstaked; + + /// + /// [DEPRECATED] + /// + public long EndorsementRewards => EndorsementRewardsLiquid + EndorsementRewardsStakedOwn + EndorsementRewardsStakedShared; + + /// + /// [DEPRECATED] + /// + public long BlockRewards => BlockRewardsLiquid + BlockRewardsStakedOwn + BlockRewardsStakedShared; + + /// + /// [DEPRECATED] + /// + public long StakingBalance => OwnDelegatedBalance + ExternalDelegatedBalance + OwnStakedBalance + ExternalStakedBalance; + + /// + /// [DEPRECATED] + /// + public long ActiveStake => BakingPower; + + /// + /// [DEPRECATED] + /// + public long SelectedStake => TotalBakingPower; + + /// + /// [DEPRECATED] + /// + public long DelegatedBalance => ExternalStakedBalance + ExternalDelegatedBalance; + + /// + /// [DEPRECATED] + /// + public int NumDelegators => DelegatorsCount; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Baking/SplitDelegator.cs b/Tzkt.Api/Models/Baking/SplitDelegator.cs index 1bb610a11..d170c0d7b 100644 --- a/Tzkt.Api/Models/Baking/SplitDelegator.cs +++ b/Tzkt.Api/Models/Baking/SplitDelegator.cs @@ -8,19 +8,43 @@ public class SplitDelegator public string Address { get; set; } /// - /// Balance of the delegator at the snapshot time + /// Amount delegated to the baker at the snapshot time (micro tez). + /// This amount doesn't include staked amount. /// - public long Balance { get; set; } + public long DelegatedBalance { get; set; } /// - /// Balance of the delegator at the moment + /// Amount staked to the baker at the snapshot time (micro tez). /// - public long CurrentBalance { get; set; } + public long StakedBalance { get; set; } + + /// + /// Amount delegated to the baker at the moment (micro tez). + /// This amount doesn't include staked amount. + /// + public long CurrentDelegatedBalance { get; set; } + + /// + /// Amount staked to the baker at the moment (micro tez). + /// + public long CurrentStakedBalance { get; set; } /// /// Indicates whether the delegator is emptied (at the moment, not at the snapshot time). - /// Emptied accounts (users with zero balance) should be re-allocated, so if you make payment to emptied account you will pay (burn) `0.257 tez` allocation fee. + /// Emptied accounts (users with zero balance) should be re-allocated, so if you make payment to the emptied account you will pay allocation fee. /// public bool Emptied { get; set; } + + #region deprecated + /// + /// [DEPRECATED] + /// + public long Balance => DelegatedBalance + StakedBalance; + + /// + /// [DEPRECATED] + /// + public long CurrentBalance => CurrentDelegatedBalance + CurrentStakedBalance; + #endregion } } diff --git a/Tzkt.Api/Models/Block.cs b/Tzkt.Api/Models/Block.cs index becee50ca..444366ffe 100644 --- a/Tzkt.Api/Models/Block.cs +++ b/Tzkt.Api/Models/Block.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class Block { @@ -51,14 +48,38 @@ public class Block public long Deposit { get; set; } /// - /// Fixed reward paid to the payload proposer (micro tez) + /// Fixed reward paid to the payload proposer (micro tez) on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). /// - public long Reward { get; set; } + public long RewardLiquid { get; set; } /// - /// Bonus reward paid to the block producer (micro tez) + /// Fixed reward paid to the payload proposer (micro tez) on baker's staked balance (i.e. they are frozen). /// - public long Bonus { get; set; } + public long RewardStakedOwn { get; set; } + + /// + /// Fixed reward paid to the payload proposer (micro tez) on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). + /// + public long RewardStakedShared { get; set; } + + /// + /// Bonus reward paid to the block producer (micro tez) on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long BonusLiquid { get; set; } + + /// + /// Bonus reward paid to the block producer (micro tez) on baker's staked balance (i.e. they are frozen). + /// + public long BonusStakedOwn { get; set; } + + /// + /// Bonus reward paid to the block producer (micro tez) on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). + /// + public long BonusStakedShared { get; set; } /// /// Total fee gathered from operations, included into the block @@ -97,6 +118,16 @@ public class Block /// public int LBToggleEma { get; set; } + /// + /// Adaptive issuance toggle (`true` if enabled, `false` if disabled, or `null` if the baker says 'pass') + /// + public bool? AIToggle { get; set; } + + /// + /// Adaptive issuance EMA value with precision of 1000000 for integer computation + /// + public int AIToggleEma { get; set; } + #region operations /// /// List of endorsement (is operation, which specifies the head of the chain as seen by the endorser of a given slot) @@ -280,6 +311,11 @@ public class Block /// public IEnumerable SrRefuteOps { get; set; } + /// + /// List of staking operations, included in the block + /// + public IEnumerable StakingOps { get; set; } + /// /// List of migration operations, implicitly applied at the end of the block /// @@ -294,6 +330,11 @@ public class Block /// List of endorsing rewards, implicitly applied at the end of the block /// public IEnumerable EndorsingRewards { get; set; } + + /// + /// List of autostaking operations, implicitly applied at the end of the block + /// + public IEnumerable AutostakingOps { get; set; } #endregion #region injecting @@ -304,6 +345,16 @@ public class Block #endregion #region deprecated + /// + /// [DEPRECATED] + /// + public long Reward => RewardLiquid + RewardStakedOwn + RewardStakedShared; + + /// + /// [DEPRECATED] + /// + public long Bonus => BonusLiquid + BonusStakedOwn + BonusStakedShared; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Operations/AutostakingOperation.cs b/Tzkt.Api/Models/Operations/AutostakingOperation.cs new file mode 100644 index 000000000..4c9b0397d --- /dev/null +++ b/Tzkt.Api/Models/Operations/AutostakingOperation.cs @@ -0,0 +1,54 @@ +namespace Tzkt.Api.Models +{ + public class AutostakingOperation : Operation + { + /// + /// Type of the operation, `autostaking` + /// + public override string Type => OpTypes.Autostaking; + + /// + /// Internal TzKT ID. + /// **[sortable]** + /// + public override long Id { get; set; } + + /// + /// Height of the block from the genesis + /// + public int Level { get; set; } + + /// + /// Datetime at which the block is claimed to have been created (ISO 8601, e.g. `2020-02-20T02:40:57Z`) + /// + public DateTime Timestamp { get; set; } + + /// + /// Baker for which autostaking event happened + /// + public Alias Baker { get; set; } + + /// + /// Autostaking action (`stake`, `unstake`, `finalize`, or `restake`) + /// + public string Action { get; set; } + + /// + /// If action is `stake`, this field contains an index of a cycle, from which the staked amount is applied. + /// Otherwise, it contains an index of a cycle of the unstaked deposits affected. + /// + public int Cycle { get; set; } + + /// + /// Amount (micro tez) + /// + public long Amount { get; set; } + + #region injecting + /// + /// Injected historical quote at the time of operation + /// + public QuoteShort Quote { get; set; } + #endregion + } +} diff --git a/Tzkt.Api/Models/Operations/BakingOperation.cs b/Tzkt.Api/Models/Operations/BakingOperation.cs index 51bd9cb91..927b0262a 100644 --- a/Tzkt.Api/Models/Operations/BakingOperation.cs +++ b/Tzkt.Api/Models/Operations/BakingOperation.cs @@ -55,14 +55,38 @@ public class BakingOperation : Operation public long Deposit { get; set; } /// - /// Fixed reward paid to the payload proposer (micro tez) + /// Fixed reward paid to the payload proposer (micro tez) on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). /// - public long Reward { get; set; } + public long RewardLiquid { get; set; } /// - /// Bonus reward paid to the block producer (micro tez) + /// Fixed reward paid to the payload proposer (micro tez) on baker's staked balance (i.e. they are frozen). /// - public long Bonus { get; set; } + public long RewardStakedOwn { get; set; } + + /// + /// Fixed reward paid to the payload proposer (micro tez) on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). + /// + public long RewardStakedShared { get; set; } + + /// + /// Bonus reward paid to the block producer (micro tez) on baker's liquid balance + /// (i.e. they are not frozen and can be spent immediately). + /// + public long BonusLiquid { get; set; } + + /// + /// Bonus reward paid to the block producer (micro tez) on baker's staked balance (i.e. they are frozen). + /// + public long BonusStakedOwn { get; set; } + + /// + /// Bonus reward paid to the block producer (micro tez) on baker's external staked balance + /// (i.e. they are frozen and belong to stakers and can be withdrawn by unstaking). + /// + public long BonusStakedShared { get; set; } /// /// Total fee gathered from operations, included into the block @@ -77,6 +101,16 @@ public class BakingOperation : Operation #endregion #region deprecated + /// + /// [DEPRECATED] + /// + public long Reward => RewardLiquid + RewardStakedOwn + RewardStakedShared; + + /// + /// [DEPRECATED] + /// + public long Bonus => BonusLiquid + BonusStakedOwn + BonusStakedShared; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Operations/Base/Operation.cs b/Tzkt.Api/Models/Operations/Base/Operation.cs index 4ad6dfd1f..d93e92683 100644 --- a/Tzkt.Api/Models/Operations/Base/Operation.cs +++ b/Tzkt.Api/Models/Operations/Base/Operation.cs @@ -44,6 +44,8 @@ namespace Tzkt.Api.Models [KnownType(typeof(SmartRollupPublishOperation))] [KnownType(typeof(SmartRollupRecoverBondOperation))] [KnownType(typeof(SmartRollupRefuteOperation))] + [KnownType(typeof(AutostakingOperation))] + [KnownType(typeof(StakingOperation))] public abstract class Operation { /// @@ -180,6 +182,12 @@ public override string GetDiscriminatorValue(Type type) if (type == typeof(SmartRollupRefuteOperation)) return OpTypes.SmartRollupRefute; + if (type == typeof(AutostakingOperation)) + return OpTypes.Autostaking; + + if (type == typeof(StakingOperation)) + return OpTypes.Staking; + return base.GetDiscriminatorValue(type); } } diff --git a/Tzkt.Api/Models/Operations/DelegationOperation.cs b/Tzkt.Api/Models/Operations/DelegationOperation.cs index 1a552f2fe..c7a89b1a7 100644 --- a/Tzkt.Api/Models/Operations/DelegationOperation.cs +++ b/Tzkt.Api/Models/Operations/DelegationOperation.cs @@ -88,6 +88,21 @@ public class DelegationOperation : Operation /// public long Amount { get; set; } + /// + /// Amount of pseudotokens unstaked due to re-delegating. + /// + public long? UnstakedPseudotokens { get; set; } + + /// + /// Amount staked balance unstaked due to re-delegating. + /// + public long? UnstakedBalance { get; set; } + + /// + /// Amount of pending rewards unstaked due to re-delegating. + /// + public long? UnstakedRewards { get; set; } + /// /// Information about the previous delegate of the account. `null` if there is no previous delegate /// diff --git a/Tzkt.Api/Models/Operations/DoubleBakingOperation.cs b/Tzkt.Api/Models/Operations/DoubleBakingOperation.cs index 19a7ddbfa..001e323be 100644 --- a/Tzkt.Api/Models/Operations/DoubleBakingOperation.cs +++ b/Tzkt.Api/Models/Operations/DoubleBakingOperation.cs @@ -40,6 +40,11 @@ public class DoubleBakingOperation : Operation /// public int AccusedLevel { get; set; } + /// + /// Height of the block from the genesis, at which the offender was slashed + /// + public int SlashedLevel { get; set; } + /// /// Information about the baker, produced the block, in which the accusation was included /// @@ -48,7 +53,7 @@ public class DoubleBakingOperation : Operation /// /// Reward of the baker, produced the block, in which the accusation was included /// - public long AccuserReward { get; set; } + public long Reward { get; set; } /// /// Information about the baker, accused for producing two different blocks at the same level @@ -56,9 +61,29 @@ public class DoubleBakingOperation : Operation public Alias Offender { get; set; } /// - /// Amount of frozen deposits lost by accused baker + /// Amount slashed from baker's own staked balance + /// + public long LostStaked { get; set; } + + /// + /// Amount slashed from baker's own unstaked balance + /// + public long LostUnstaked { get; set; } + + /// + /// Amount slashed from baker's external staked balance + /// + public long LostExternalStaked { get; set; } + + /// + /// Amount slashed from baker's external unstaked balance /// - public long OffenderLoss { get; set; } + public long LostExternalUnstaked { get; set; } + + /// + /// Amount lost due to inaccuracy of the economic protocol introduced in Oxford. + /// + public long RoundingLoss { get; set; } #region injecting /// @@ -68,6 +93,16 @@ public class DoubleBakingOperation : Operation #endregion #region deprecated + /// + /// [DEPRECATED] + /// + public long OffenderLoss => LostStaked + LostUnstaked + LostExternalStaked + LostExternalUnstaked + RoundingLoss; + + /// + /// [DEPRECATED] + /// + public long AccuserReward => Reward; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Operations/DoubleEndorsingOperation.cs b/Tzkt.Api/Models/Operations/DoubleEndorsingOperation.cs index cfe094afd..2f61d5443 100644 --- a/Tzkt.Api/Models/Operations/DoubleEndorsingOperation.cs +++ b/Tzkt.Api/Models/Operations/DoubleEndorsingOperation.cs @@ -40,6 +40,11 @@ public class DoubleEndorsingOperation : Operation /// public int AccusedLevel { get; set; } + /// + /// Height of the block from the genesis, at which the offender was slashed + /// + public int SlashedLevel { get; set; } + /// /// Information about the baker, produced the block, in which the accusation was included /// @@ -48,7 +53,7 @@ public class DoubleEndorsingOperation : Operation /// /// Reward of the baker, produced the block, in which the accusation was included /// - public long AccuserReward { get; set; } + public long Reward { get; set; } /// /// Information about the baker, accused for producing two different endorsements at the same level @@ -56,9 +61,29 @@ public class DoubleEndorsingOperation : Operation public Alias Offender { get; set; } /// - /// Amount of frozen deposits lost by accused baker + /// Amount slashed from baker's own staked balance + /// + public long LostStaked { get; set; } + + /// + /// Amount slashed from baker's own unstaked balance + /// + public long LostUnstaked { get; set; } + + /// + /// Amount slashed from baker's external staked balance + /// + public long LostExternalStaked { get; set; } + + /// + /// Amount slashed from baker's external unstaked balance /// - public long OffenderLoss { get; set; } + public long LostExternalUnstaked { get; set; } + + /// + /// Amount lost due to inaccuracy of the economic protocol introduced in Oxford. + /// + public long RoundingLoss { get; set; } #region injecting /// @@ -68,6 +93,16 @@ public class DoubleEndorsingOperation : Operation #endregion #region deprecated + /// + /// [DEPRECATED] + /// + public long OffenderLoss => LostStaked + LostUnstaked + LostExternalStaked + LostExternalUnstaked + RoundingLoss; + + /// + /// [DEPRECATED] + /// + public long AccuserReward => Reward; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Operations/DoublePreendorsingOperation.cs b/Tzkt.Api/Models/Operations/DoublePreendorsingOperation.cs index 7225874e9..fd3da4ea9 100644 --- a/Tzkt.Api/Models/Operations/DoublePreendorsingOperation.cs +++ b/Tzkt.Api/Models/Operations/DoublePreendorsingOperation.cs @@ -39,6 +39,11 @@ public class DoublePreendorsingOperation : Operation /// public int AccusedLevel { get; set; } + /// + /// Height of the block from the genesis, at which the offender was slashed + /// + public int SlashedLevel { get; set; } + /// /// Information about the baker, produced the block, in which the accusation was included /// @@ -47,7 +52,7 @@ public class DoublePreendorsingOperation : Operation /// /// Reward of the baker, produced the block, in which the accusation was included /// - public long AccuserReward { get; set; } + public long Reward { get; set; } /// /// Information about the baker, accused for producing two different preendorsements at the same level @@ -55,9 +60,29 @@ public class DoublePreendorsingOperation : Operation public Alias Offender { get; set; } /// - /// Amount of frozen deposits lost by accused baker + /// Amount slashed from baker's own staked balance + /// + public long LostStaked { get; set; } + + /// + /// Amount slashed from baker's own unstaked balance + /// + public long LostUnstaked { get; set; } + + /// + /// Amount slashed from baker's external staked balance + /// + public long LostExternalStaked { get; set; } + + /// + /// Amount slashed from baker's external unstaked balance + /// + public long LostExternalUnstaked { get; set; } + + /// + /// Amount lost due to inaccuracy of the economic protocol introduced in Oxford. /// - public long OffenderLoss { get; set; } + public long RoundingLoss { get; set; } #region injecting /// @@ -65,5 +90,17 @@ public class DoublePreendorsingOperation : Operation /// public QuoteShort Quote { get; set; } #endregion + + #region deprecated + /// + /// [DEPRECATED] + /// + public long OffenderLoss => LostStaked + LostUnstaked + LostExternalStaked + LostExternalUnstaked + RoundingLoss; + + /// + /// [DEPRECATED] + /// + public long AccuserReward => Reward; + #endregion } } diff --git a/Tzkt.Api/Models/Operations/EndorsingRewardOperation.cs b/Tzkt.Api/Models/Operations/EndorsingRewardOperation.cs index d2157cd73..077bae612 100644 --- a/Tzkt.Api/Models/Operations/EndorsingRewardOperation.cs +++ b/Tzkt.Api/Models/Operations/EndorsingRewardOperation.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class EndorsingRewardOperation : Operation { @@ -40,9 +38,19 @@ public class EndorsingRewardOperation : Operation public long Expected { get; set; } /// - /// Actually received endorsing reward (micro tez) + /// Reward received on baker's liquid balance (micro tez) + /// + public long RewardLiquid { get; set; } + + /// + /// Reward received on baker's staked balance (micro tez) /// - public long Received { get; set; } + public long RewardStakedOwn { get; set; } + + /// + /// Reward received on baker's external staked balance (micro tez) + /// + public long RewardStakedShared { get; set; } #region injecting /// @@ -50,5 +58,12 @@ public class EndorsingRewardOperation : Operation /// public QuoteShort Quote { get; set; } #endregion + + #region deprecated + /// + /// [DEPRECATED] + /// + public long Received => RewardLiquid + RewardStakedOwn + RewardStakedShared; + #endregion } } diff --git a/Tzkt.Api/Models/Operations/MigrationOperation.cs b/Tzkt.Api/Models/Operations/MigrationOperation.cs index 5cd2d6206..b159d70fe 100644 --- a/Tzkt.Api/Models/Operations/MigrationOperation.cs +++ b/Tzkt.Api/Models/Operations/MigrationOperation.cs @@ -43,6 +43,7 @@ public class MigrationOperation : Operation /// `code_change` - changing contract scripts during Babylon protocol upgrade /// `origination` - implicit (hardcoded in the protocol) origination of liquidity baking contracts /// `subsidy` - liquidity baking subsidy + /// `remove_bigmap_key` - removing the key from the bigmap /// public string Kind { get; set; } diff --git a/Tzkt.Api/Models/Operations/NonceRevelationOperation.cs b/Tzkt.Api/Models/Operations/NonceRevelationOperation.cs index 2f98f3841..6486e2f1c 100644 --- a/Tzkt.Api/Models/Operations/NonceRevelationOperation.cs +++ b/Tzkt.Api/Models/Operations/NonceRevelationOperation.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class NonceRevelationOperation : Operation { @@ -60,9 +58,19 @@ public class NonceRevelationOperation : Operation public string Nonce { get; set; } /// - /// Baker reward for including seed nonce revelation into a block + /// Reward received on baker's liquid balance (micro tez) + /// + public long RewardLiquid { get; set; } + + /// + /// Reward received on baker's staked balance (micro tez) /// - public long Reward { get; set; } + public long RewardStakedOwn { get; set; } + + /// + /// Reward received on baker's external staked balance (micro tez) + /// + public long RewardStakedShared { get; set; } #region injecting /// @@ -72,6 +80,11 @@ public class NonceRevelationOperation : Operation #endregion #region deprecated + /// + /// [DEPRECATED] + /// + public long Reward => RewardLiquid + RewardStakedOwn + RewardStakedShared; + /// /// [DEPRECATED] /// diff --git a/Tzkt.Api/Models/Operations/SmartRollupOriginateOperation.cs b/Tzkt.Api/Models/Operations/SmartRollupOriginateOperation.cs index 66af029ea..6bd0e66a0 100644 --- a/Tzkt.Api/Models/Operations/SmartRollupOriginateOperation.cs +++ b/Tzkt.Api/Models/Operations/SmartRollupOriginateOperation.cs @@ -86,11 +86,6 @@ public class SmartRollupOriginateOperation : Operation /// public byte[] Kernel { get; set; } - /// - /// Origination proof bytes (in base64). - /// - public byte[] OriginationProof { get; set; } - /// /// Smart rollup parameter type. Note: you can configure format by setting `micheline` query parameter. /// diff --git a/Tzkt.Api/Models/Operations/StakingOperation.cs b/Tzkt.Api/Models/Operations/StakingOperation.cs new file mode 100644 index 000000000..902e8fa5d --- /dev/null +++ b/Tzkt.Api/Models/Operations/StakingOperation.cs @@ -0,0 +1,116 @@ +namespace Tzkt.Api.Models +{ + public class StakingOperation : Operation + { + /// + /// Type of the operation, `staking` + /// + public override string Type => OpTypes.Staking; + + /// + /// Internal TzKT ID. + /// **[sortable]** + /// + public override long Id { get; set; } + + /// + /// Height of the block from the genesis + /// + public int Level { get; set; } + + /// + /// Datetime at which the block is claimed to have been created (ISO 8601, e.g. `2020-02-20T02:40:57Z`) + /// + public DateTime Timestamp { get; set; } + + /// + /// Hash of the operation + /// + public string Hash { get; set; } + + /// + /// Information about the account who has sent the operation + /// + public Alias Sender { get; set; } + + /// + /// An account nonce which is used to prevent operation replay + /// + public int Counter { get; set; } + + /// + /// A cap on the amount of gas a given operation can consume + /// + public int GasLimit { get; set; } + + /// + /// Amount of gas, consumed by the operation + /// + public int GasUsed { get; set; } + + /// + /// A cap on the amount of storage a given operation can consume + /// + public int StorageLimit { get; set; } + + /// + /// Fee to the baker, produced block, in which the operation was included (micro tez) + /// + public long BakerFee { get; set; } + + /// + /// Staking operation kind (`stake`, `unstake`, `finalize`, `set_parameters`) + /// + public string Kind { get; set; } + + /// + /// Information about the baker + /// + public Alias Baker { get; set; } + + /// + /// Amount (micro tez) + /// + public long? Amount { get; set; } + + /// + /// Pseudotokens + /// + public long? Pseudotokens { get; set; } + + /// + /// This parameter determines the maximum portion (millionth) of external stake by stakers over the baker's own staked funds. + /// + public long? LimitOfStakingOverBaking { get; set; } + + /// + /// This parameter determines the fraction (billionth) of the rewards that accrue to the baker's liquid spendable balance — the remainder accrues to frozen stakes. + /// + public long? EdgeOfBakingOverStaking { get; set; } + + /// + /// Cycle from which the specified staking parameters are activated + /// + public int? ActivationCycle { get; set; } + + /// + /// Operation status (`applied` - an operation applied by the node and successfully added to the blockchain, + /// `failed` - an operation which failed with some particular error (not enough balance, gas limit, etc), + /// `backtracked` - an operation which was successful but reverted due to one of the following operations in the same operation group was failed, + /// `skipped` - all operations after the failed one in an operation group) + /// + public string Status { get; set; } + + /// + /// List of errors provided by the node, injected the operation to the blockchain. `null` if there is no errors + /// + public List Errors { get; set; } + + #region injecting + /// + /// Injected historical quote at the time of operation + /// + public QuoteShort Quote { get; set; } + #endregion + } +} diff --git a/Tzkt.Api/Models/Operations/VdfRevelationOperation.cs b/Tzkt.Api/Models/Operations/VdfRevelationOperation.cs index b1df17ef9..33ef1f67b 100644 --- a/Tzkt.Api/Models/Operations/VdfRevelationOperation.cs +++ b/Tzkt.Api/Models/Operations/VdfRevelationOperation.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class VdfRevelationOperation : Operation { @@ -55,9 +53,19 @@ public class VdfRevelationOperation : Operation public string Proof { get; set; } /// - /// Baker reward for including vdf revelation into a block + /// Reward received on baker's liquid balance (micro tez) + /// + public long RewardLiquid { get; set; } + + /// + /// Reward received on baker's staked balance (micro tez) /// - public long Reward { get; set; } + public long RewardStakedOwn { get; set; } + + /// + /// Reward received on baker's external staked balance (micro tez) + /// + public long RewardStakedShared { get; set; } #region injecting /// @@ -65,5 +73,12 @@ public class VdfRevelationOperation : Operation /// public QuoteShort Quote { get; set; } #endregion + + #region deprecated + /// + /// [DEPRECATED] + /// + public long Reward => RewardLiquid + RewardStakedOwn + RewardStakedShared; + #endregion } } diff --git a/Tzkt.Api/Models/ProtocolConstants.cs b/Tzkt.Api/Models/ProtocolConstants.cs index 7a4d521f7..f60360be0 100644 --- a/Tzkt.Api/Models/ProtocolConstants.cs +++ b/Tzkt.Api/Models/ProtocolConstants.cs @@ -67,18 +67,18 @@ public class ProtocolConstants /// /// Required number of tokens to get 1 roll (micro tez) /// - public long TokensPerRoll { get; set; } - + public long MinimalStake { get; set; } + /// - /// Reward for seed nonce revelation (micro tez) + /// Required number of tokens to be frozen by bakers (micro tez) /// - public long RevelationReward { get; set; } + public long MinimalFrozenStake { get; set; } /// /// Security deposit for baking (producing) a block (micro tez) /// public long BlockDeposit { get; set; } - + //TODO Think about it /// /// Reward for baking (producing) a block (micro tez) @@ -120,11 +120,6 @@ public class ProtocolConstants /// public double BallotQuorumMax { get; set; } - /// - /// Liquidity baking subsidy is 1/16th of total rewards for a block of priority 0 with all endorsements - /// - public int LBSubsidy { get; set; } - /// /// 1/2 window size of 2000 blocks with precision of 1000000 for integer computation /// @@ -151,34 +146,14 @@ public class ProtocolConstants public int MaxSlashingPeriod { get; set; } /// - /// How much of baker's active stake is frozen as a security deposit - /// - public int FrozenDepositsPercentage { get; set; } - - /// - /// How much mutez is burned from baker's frozen deposits, in case of double baking - /// - public long DoubleBakingPunishment { get; set; } - - /// - /// How much is burned from baker's frozen deposits, in case of double (pre)endorsing - /// - public int DoubleEndorsingPunishmentNumerator { get; set; } - - /// - /// How much is burned from baker's frozen deposits, in case of double (pre)endorsing + /// The ratio of delegated tez over the baker’s frozen stake /// - public int DoubleEndorsingPunishmentDenominator { get; set; } + public int MaxDelegatedOverFrozenRatio { get; set; } /// - /// Initial storage size of an originated (created) tx rollup (bytes) + /// The ratio of external staked balance over the baker’s own staked balance /// - public int TxRollupOriginationSize { get; set; } - - /// - /// Tx rollup commitment bond (mutez) - /// - public long TxRollupCommitmentBond { get; set; } + public int MaxExternalOverOwnStakeRatio { get; set; } /// /// Initial storage size of an originated (created) smart rollup (bytes) @@ -220,6 +195,51 @@ public class ProtocolConstants /// [DEPRECATED] /// public int LBSunsetLevel => 3_063_809; + + /// + /// [DEPRECATED] + /// + public int FrozenDepositsPercentage => 10; + + /// + /// [DEPRECATED] + /// + public int TxRollupOriginationSize => 4_000; + + /// + /// [DEPRECATED] + /// + public long TxRollupCommitmentBond => 10_000_000_000; + + /// + /// [DEPRECATED] + /// + public long DoubleBakingPunishment => 640_000_000; + + /// + /// [DEPRECATED] + /// + public int DoubleEndorsingPunishmentNumerator => 1; + + /// + /// [DEPRECATED] + /// + public int DoubleEndorsingPunishmentDenominator => 2; + + /// + /// [DEPRECATED] + /// + public long RevelationReward => 125_000; + + /// + /// [DEPRECATED] + /// + public int LBSubsidy => 80_000_000 * TimeBetweenBlocks / 60 / 16; + + /// + /// [DEPRECATED] + /// + public long TokensPerRoll => MinimalStake; #endregion } } diff --git a/Tzkt.Api/Models/Statistics/Statistics.cs b/Tzkt.Api/Models/Statistics/Statistics.cs index 97935a2ad..612b7cfe4 100644 --- a/Tzkt.Api/Models/Statistics/Statistics.cs +++ b/Tzkt.Api/Models/Statistics/Statistics.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class Statistics { @@ -79,6 +77,12 @@ public class Statistics /// public long TotalSmartRollupBonds { get; set; } + /// + /// Total amount lost due to inaccuracy of the economic protocol introduced in Oxford. + /// This amount is literally lost, because it is no longer available for the account in any mean, but for some reason it is counted as delegated. + /// + public long TotalLost { get; set; } + #region injecting /// /// Injected historical quote at the time of the block at which the statistics has been calculated @@ -90,7 +94,7 @@ public class Statistics /// /// [DEPRECATED] /// - public long TotalVested { get; set; } + public long TotalVested => 0; #endregion } } diff --git a/Tzkt.Api/Parameters/AutostakingActionParameter.cs b/Tzkt.Api/Parameters/AutostakingActionParameter.cs new file mode 100644 index 000000000..ff0d1e655 --- /dev/null +++ b/Tzkt.Api/Parameters/AutostakingActionParameter.cs @@ -0,0 +1,75 @@ +using System.Text; +using Microsoft.AspNetCore.Mvc; +using NJsonSchema.Annotations; + +namespace Tzkt.Api +{ + [ModelBinder(BinderType = typeof(AutostakingActionBinder))] + [JsonSchemaExtensionData("x-tzkt-extension", "query-parameter")] + [JsonSchemaExtensionData("x-tzkt-query-parameter", "stake,unstake,finalize,restake")] + public class AutostakingActionParameter : INormalizable + { + /// + /// **Equal** filter mode (optional, i.e. `param.eq=123` is the same as `param=123`). \ + /// Specify an autostaking action to get items where the specified field is equal to the specified value. + /// + /// Example: `?action=stake`. + /// + [JsonSchemaType(typeof(string))] + public int? Eq { get; set; } + + /// + /// **Not equal** filter mode. \ + /// Specify an autostaking action to get items where the specified field is not equal to the specified value. + /// + /// Example: `?action.ne=finalize`. + /// + [JsonSchemaType(typeof(string))] + public int? Ne { get; set; } + + /// + /// **In list** (any of) filter mode. \ + /// Specify a comma-separated list of autostaking actions to get items where the specified field is equal to one of the specified values. + /// + /// Example: `?action.in=stake,unstake`. + /// + [JsonSchemaType(typeof(List))] + public List In { get; set; } + + /// + /// **Not in list** (none of) filter mode. \ + /// Specify a comma-separated list of autostaking actions to get items where the specified field is not equal to all the specified values. + /// + /// Example: `?action.ni=finalize,restake`. + /// + [JsonSchemaType(typeof(List))] + public List Ni { get; set; } + + public string Normalize(string name) + { + var sb = new StringBuilder(); + + if (Eq != null) + { + sb.Append($"{name}.eq={Eq}&"); + } + + if (Ne != null) + { + sb.Append($"{name}.ne={Ne}&"); + } + + if (In?.Count > 0) + { + sb.Append($"{name}.in={string.Join(",", In.OrderBy(x => x))}&"); + } + + if (Ni?.Count > 0) + { + sb.Append($"{name}.ni={string.Join(",", Ni.OrderBy(x => x))}&"); + } + + return sb.ToString(); + } + } +} diff --git a/Tzkt.Api/Parameters/AutostakingOperationFilter.cs b/Tzkt.Api/Parameters/AutostakingOperationFilter.cs new file mode 100644 index 000000000..db884501b --- /dev/null +++ b/Tzkt.Api/Parameters/AutostakingOperationFilter.cs @@ -0,0 +1,67 @@ +using NSwag.Annotations; +using Tzkt.Api.Services; + +namespace Tzkt.Api +{ + public class AutostakingOperationFilter : INormalizable + { + /// + /// Filter by internal TzKT id. + /// Click on the parameter to expand more details. + /// + public Int64Parameter id { get; set; } + + /// + /// Filter by level of the block where the operation happened. + /// Click on the parameter to expand more details. + /// + public Int32Parameter level { get; set; } + + /// + /// Filter by timestamp (ISO 8601) of the block where the operation happened. + /// Click on the parameter to expand more details. + /// + public TimestampParameter timestamp { get; set; } + + /// + /// Filter by baker. + /// Click on the parameter to expand more details. + /// + public AccountParameter baker { get; set; } + + /// + /// Filter by autostaking action. + /// Click on the parameter to expand more details. + /// + public AutostakingActionParameter action { get; set; } + + /// + /// Filter by cycle. + /// Click on the parameter to expand more details. + /// + public Int32Parameter cycle { get; set; } + + /// + /// Filter by amount. + /// Click on the parameter to expand more details. + /// + public Int64Parameter amount { get; set; } + + [OpenApiIgnore] + public bool Empty => + id == null && + level == null && + timestamp == null && + baker == null && + action == null && + cycle == null && + amount == null; + + public string Normalize(string name) + { + return ResponseCacheService.BuildKey("", + ("id", id), ("level", level), ("timestamp", timestamp), ("baker", baker), + ("action", action), ("cycle", cycle), ("amount", amount)); + } + } +} diff --git a/Tzkt.Api/Parameters/Binders/AutostakingActionBinder.cs b/Tzkt.Api/Parameters/Binders/AutostakingActionBinder.cs new file mode 100644 index 000000000..65231606f --- /dev/null +++ b/Tzkt.Api/Parameters/Binders/AutostakingActionBinder.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Tzkt.Api +{ + public class AutostakingActionBinder : IModelBinder + { + public Task BindModelAsync(ModelBindingContext bindingContext) + { + var model = bindingContext.ModelName; + var hasValue = false; + + if (!bindingContext.TryGetAutostakingAction($"{model}", ref hasValue, out var value)) + return Task.CompletedTask; + + if (!bindingContext.TryGetAutostakingAction($"{model}.eq", ref hasValue, out var eq)) + return Task.CompletedTask; + + if (!bindingContext.TryGetAutostakingAction($"{model}.ne", ref hasValue, out var ne)) + return Task.CompletedTask; + + if (!bindingContext.TryGetAutostakingActionsList($"{model}.in", ref hasValue, out var @in)) + return Task.CompletedTask; + + if (!bindingContext.TryGetAutostakingActionsList($"{model}.ni", ref hasValue, out var ni)) + return Task.CompletedTask; + + if (!hasValue) + { + bindingContext.Result = ModelBindingResult.Success(null); + return Task.CompletedTask; + } + + bindingContext.Result = ModelBindingResult.Success(new AutostakingActionParameter + { + Eq = value ?? eq, + Ne = ne, + In = @in, + Ni = ni + }); + + return Task.CompletedTask; + } + } +} diff --git a/Tzkt.Api/Parameters/Binders/StakingOperationKindBinder.cs b/Tzkt.Api/Parameters/Binders/StakingOperationKindBinder.cs new file mode 100644 index 000000000..86d95c3ee --- /dev/null +++ b/Tzkt.Api/Parameters/Binders/StakingOperationKindBinder.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Tzkt.Api +{ + public class StakingOperationKindBinder : IModelBinder + { + public Task BindModelAsync(ModelBindingContext bindingContext) + { + var model = bindingContext.ModelName; + var hasValue = false; + + if (!bindingContext.TryGetStakingOperationKind($"{model}", ref hasValue, out var value)) + return Task.CompletedTask; + + if (!bindingContext.TryGetStakingOperationKind($"{model}.eq", ref hasValue, out var eq)) + return Task.CompletedTask; + + if (!bindingContext.TryGetStakingOperationKind($"{model}.ne", ref hasValue, out var ne)) + return Task.CompletedTask; + + if (!bindingContext.TryGetStakingOperationKindsList($"{model}.in", ref hasValue, out var @in)) + return Task.CompletedTask; + + if (!bindingContext.TryGetStakingOperationKindsList($"{model}.ni", ref hasValue, out var ni)) + return Task.CompletedTask; + + if (!hasValue) + { + bindingContext.Result = ModelBindingResult.Success(null); + return Task.CompletedTask; + } + + bindingContext.Result = ModelBindingResult.Success(new StakingOperationKindParameter + { + Eq = value ?? eq, + Ne = ne, + In = @in, + Ni = ni + }); + + return Task.CompletedTask; + } + } +} diff --git a/Tzkt.Api/Parameters/MigrationKindParameter.cs b/Tzkt.Api/Parameters/MigrationKindParameter.cs index 99db203f9..93113ac93 100644 --- a/Tzkt.Api/Parameters/MigrationKindParameter.cs +++ b/Tzkt.Api/Parameters/MigrationKindParameter.cs @@ -8,7 +8,7 @@ namespace Tzkt.Api { [ModelBinder(BinderType = typeof(MigrationKindBinder))] [JsonSchemaExtensionData("x-tzkt-extension", "query-parameter")] - [JsonSchemaExtensionData("x-tzkt-query-parameter", "bootstrap,activate_delegate,airdrop,proposal_invoice,code_change,origination,subsidy")] + [JsonSchemaExtensionData("x-tzkt-query-parameter", "bootstrap,activate_delegate,airdrop,proposal_invoice,code_change,origination,subsidy,remove_bigmap_key")] public class MigrationKindParameter : INormalizable { /// diff --git a/Tzkt.Api/Parameters/StakingOperationFilter.cs b/Tzkt.Api/Parameters/StakingOperationFilter.cs new file mode 100644 index 000000000..dc5b1f7ac --- /dev/null +++ b/Tzkt.Api/Parameters/StakingOperationFilter.cs @@ -0,0 +1,41 @@ +using Tzkt.Api.Services; + +namespace Tzkt.Api +{ + public class StakingOperationFilter : ManagerOperationFilter + { + /// + /// Filter by any of the specified fields (`sender`, or `baker`). + /// Example: `anyof.sender.baker=tz1...` will return operations where `sender` OR `baker` is equal to the specified value. + /// This parameter is useful when you need to get all operations somehow related to the account in a single request. + /// Click on the parameter to expand more details. + /// + public AnyOfParameter anyof { get; set; } + + /// + /// Filter by baker address. + /// Click on the parameter to expand more details. + /// + public AccountParameter baker { get; set; } + + /// + /// Filter by operation kind (`stake`, `unstake`, `finalize`, or `set_parameters`). + /// Click on the parameter to expand more details. + /// + public StakingOperationKindParameter kind { get; set; } + + public override bool Empty => + base.Empty && + anyof == null && + baker == null && + kind == null; + + public override string Normalize(string name) + { + return ResponseCacheService.BuildKey("", + ("id", id), ("hash", hash), ("counter", counter), ("level", level), + ("timestamp", timestamp), ("status", status), ("sender", sender), + ("anyof", anyof), ("baker", baker), ("kind", kind)); + } + } +} diff --git a/Tzkt.Api/Parameters/StakingOperationKindParameter.cs b/Tzkt.Api/Parameters/StakingOperationKindParameter.cs new file mode 100644 index 000000000..346dd432b --- /dev/null +++ b/Tzkt.Api/Parameters/StakingOperationKindParameter.cs @@ -0,0 +1,75 @@ +using System.Text; +using Microsoft.AspNetCore.Mvc; +using NJsonSchema.Annotations; + +namespace Tzkt.Api +{ + [ModelBinder(BinderType = typeof(StakingOperationKindBinder))] + [JsonSchemaExtensionData("x-tzkt-extension", "query-parameter")] + [JsonSchemaExtensionData("x-tzkt-query-parameter", "stake,unstake,finalize,set_parameters")] + public class StakingOperationKindParameter : INormalizable + { + /// + /// **Equal** filter mode (optional, i.e. `param.eq=123` is the same as `param=123`). \ + /// Specify a staking operation kind to get items where the specified field is equal to the specified value. + /// + /// Example: `?kind=stake`. + /// + [JsonSchemaType(typeof(string))] + public int? Eq { get; set; } + + /// + /// **Not equal** filter mode. \ + /// Specify a staking operation kind to get items where the specified field is not equal to the specified value. + /// + /// Example: `?kind.ne=finalize`. + /// + [JsonSchemaType(typeof(string))] + public int? Ne { get; set; } + + /// + /// **In list** (any of) filter mode. \ + /// Specify a comma-separated list of staking operation kinds to get items where the specified field is equal to one of the specified values. + /// + /// Example: `?kind.in=stake,unstake`. + /// + [JsonSchemaType(typeof(List))] + public List In { get; set; } + + /// + /// **Not in list** (none of) filter mode. \ + /// Specify a comma-separated list of staking operation kinds to get items where the specified field is not equal to all the specified values. + /// + /// Example: `?kind.ni=finalize,set_parameters`. + /// + [JsonSchemaType(typeof(List))] + public List Ni { get; set; } + + public string Normalize(string name) + { + var sb = new StringBuilder(); + + if (Eq != null) + { + sb.Append($"{name}.eq={Eq}&"); + } + + if (Ne != null) + { + sb.Append($"{name}.ne={Ne}&"); + } + + if (In?.Count > 0) + { + sb.Append($"{name}.in={string.Join(",", In.OrderBy(x => x))}&"); + } + + if (Ni?.Count > 0) + { + sb.Append($"{name}.ni={string.Join(",", Ni.OrderBy(x => x))}&"); + } + + return sb.ToString(); + } + } +} diff --git a/Tzkt.Api/Repositories/AccountRepository.Bakers.cs b/Tzkt.Api/Repositories/AccountRepository.Bakers.cs index 6f6b9d048..8c12638ce 100644 --- a/Tzkt.Api/Repositories/AccountRepository.Bakers.cs +++ b/Tzkt.Api/Repositories/AccountRepository.Bakers.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Threading.Tasks; +using System.Data; using Dapper; using Tzkt.Api.Services.Cache; @@ -27,6 +23,16 @@ public partial class AccountRepository : DbConnection Balance = delegat.Balance, RollupBonds = delegat.RollupBonds, RollupsCount = delegat.RollupsCount, + StakedBalance = delegat.StakedBalance, + StakedPseudotokens = delegat.StakedPseudotokens, + UnstakedBalance = delegat.UnstakedBalance, + UnstakedBaker = delegat.UnstakedBakerId == null ? null : Accounts.GetAlias(delegat.UnstakedBakerId.Value), + TotalStakedBalance = delegat.TotalStakedBalance, + ExternalStakedBalance = delegat.ExternalStakedBalance, + ExternalUnstakedBalance = delegat.ExternalUnstakedBalance, + IssuedPseudotokens = delegat.IssuedPseudotokens, + StakersCount = delegat.StakersCount, + LostBalance = delegat.LostBalance, TransferTicketCount = delegat.TransferTicketCount, TxRollupCommitCount = delegat.TxRollupCommitCount, TxRollupDispatchTicketsCount = delegat.TxRollupDispatchTicketsCount, @@ -40,8 +46,9 @@ public partial class AccountRepository : DbConnection IncreasePaidStorageCount = delegat.IncreasePaidStorageCount, UpdateConsensusKeyCount = delegat.UpdateConsensusKeyCount, DrainDelegateCount = delegat.DrainDelegateCount, - FrozenDeposit = delegat.FrozenDeposit, FrozenDepositLimit = delegat.FrozenDepositLimit, + LimitOfStakingOverBaking = delegat.LimitOfStakingOverBaking, + EdgeOfBakingOverStaking = delegat.EdgeOfBakingOverStaking, DelegatedBalance = delegat.DelegatedBalance, Counter = delegat.Counter, ActivationLevel = delegat.ActivationLevel, @@ -80,17 +87,19 @@ public partial class AccountRepository : DbConnection NumSetDepositsLimits = delegat.SetDepositsLimitsCount, NumMigrations = delegat.MigrationsCount, NumTransactions = delegat.TransactionsCount, - SmartRollupBonds=delegat.SmartRollupBonds, - SmartRollupsCount=delegat.SmartRollupsCount, - SmartRollupAddMessagesCount=delegat.SmartRollupAddMessagesCount, - SmartRollupCementCount=delegat.SmartRollupCementCount, - SmartRollupExecuteCount=delegat.SmartRollupExecuteCount, - SmartRollupOriginateCount=delegat.SmartRollupOriginateCount, - SmartRollupPublishCount=delegat.SmartRollupPublishCount, - SmartRollupRecoverBondCount=delegat.SmartRollupRecoverBondCount, - SmartRollupRefuteCount=delegat.SmartRollupRefuteCount, - RefutationGamesCount= delegat.RefutationGamesCount, - ActiveRefutationGamesCount= delegat.ActiveRefutationGamesCount, + SmartRollupBonds = delegat.SmartRollupBonds, + SmartRollupsCount = delegat.SmartRollupsCount, + SmartRollupAddMessagesCount = delegat.SmartRollupAddMessagesCount, + SmartRollupCementCount = delegat.SmartRollupCementCount, + SmartRollupExecuteCount = delegat.SmartRollupExecuteCount, + SmartRollupOriginateCount = delegat.SmartRollupOriginateCount, + SmartRollupPublishCount = delegat.SmartRollupPublishCount, + SmartRollupRecoverBondCount = delegat.SmartRollupRecoverBondCount, + SmartRollupRefuteCount = delegat.SmartRollupRefuteCount, + RefutationGamesCount = delegat.RefutationGamesCount, + ActiveRefutationGamesCount = delegat.ActiveRefutationGamesCount, + StakingOpsCount = delegat.StakingOpsCount, + AutostakingOpsCount = delegat.AutostakingOpsCount, Software = delegat.SoftwareId == null ? null : Software[(int)delegat.SoftwareId] }; } @@ -142,6 +151,16 @@ public async Task GetDelegatesCount(BoolParameter active) Balance = row.Balance, RollupBonds = row.RollupBonds, RollupsCount = row.RollupsCount, + StakedBalance = row.StakedBalance, + StakedPseudotokens = row.StakedPseudotokens, + UnstakedBalance = row.UnstakedBalance, + UnstakedBaker = row.UnstakedBakerId == null ? null : Accounts.GetAlias(row.UnstakedBakerId.Value), + TotalStakedBalance = row.TotalStakedBalance, + ExternalStakedBalance = row.ExternalStakedBalance, + ExternalUnstakedBalance = row.ExternalUnstakedBalance, + IssuedPseudotokens = row.IssuedPseudotokens, + StakersCount = row.StakersCount, + LostBalance = row.LostBalance, TransferTicketCount = row.TransferTicketCount, TxRollupCommitCount = row.TxRollupCommitCount, TxRollupDispatchTicketsCount = row.TxRollupDispatchTicketsCount, @@ -155,8 +174,9 @@ public async Task GetDelegatesCount(BoolParameter active) IncreasePaidStorageCount = row.IncreasePaidStorageCount, UpdateConsensusKeyCount = row.UpdateConsensusKeyCount, DrainDelegateCount = row.DrainDelegateCount, - FrozenDeposit = row.FrozenDeposit, FrozenDepositLimit = row.FrozenDepositLimit, + LimitOfStakingOverBaking = row.LimitOfStakingOverBaking, + EdgeOfBakingOverStaking = row.EdgeOfBakingOverStaking, DelegatedBalance = row.DelegatedBalance, Counter = row.Counter, ActivationLevel = row.ActivationLevel, @@ -206,6 +226,8 @@ public async Task GetDelegatesCount(BoolParameter active) SmartRollupRefuteCount = row.SmartRollupRefuteCount, RefutationGamesCount = row.RefutationGamesCount, ActiveRefutationGamesCount = row.ActiveRefutationGamesCount, + StakingOpsCount = row.StakingOpsCount, + AutostakingOpsCount = row.AutostakingOpsCount, Software = row.SoftwareId == null ? null : Software[row.SoftwareId] }; }); @@ -232,8 +254,10 @@ public async Task GetDelegates( case "publicKey": columns.Add(@"""PublicKey"""); break; case "revealed": columns.Add(@"""Revealed"""); break; case "balance": columns.Add(@"""Balance"""); break; - case "frozenDeposit": columns.Add(@"""FrozenDeposit"""); break; - case "frozenDepositLimit": columns.Add(@"""FrozenDepositLimit"""); break; + case "frozenDeposit": columns.Add(@"""TotalStakedBalance"""); break; + case "frozenDepositLimit": columns.Add(@"""FrozenDepositLimit"""); break; + case "limitOfStakingOverBaking": columns.Add(@"""LimitOfStakingOverBaking"""); break; + case "edgeOfBakingOverStaking": columns.Add(@"""EdgeOfBakingOverStaking"""); break; case "delegatedBalance": columns.Add(@"""DelegatedBalance"""); break; case "counter": columns.Add(@"""Counter"""); break; case "activationLevel": columns.Add(@"""ActivationLevel"""); break; @@ -275,6 +299,16 @@ public async Task GetDelegates( case "software": columns.Add(@"""SoftwareId"""); break; case "rollupBonds": columns.Add(@"""RollupBonds"""); break; case "rollupsCount": columns.Add(@"""RollupsCount"""); break; + case "stakedBalance": columns.Add(@"""StakedBalance"""); break; + case "stakedPseudotokens": columns.Add(@"""StakedPseudotokens"""); break; + case "unstakedBalance": columns.Add(@"""UnstakedBalance"""); break; + case "unstakedBaker": columns.Add(@"""UnstakedBakerId"""); break; + case "totalStakedBalance": columns.Add(@"""TotalStakedBalance"""); break; + case "externalStakedBalance": columns.Add(@"""ExternalStakedBalance"""); break; + case "externalUnstakedBalance": columns.Add(@"""ExternalUnstakedBalance"""); break; + case "issuedPseudotokens": columns.Add(@"""IssuedPseudotokens"""); break; + case "stakersCount": columns.Add(@"""StakersCount"""); break; + case "lostBalance": columns.Add(@"""LostBalance"""); break; case "transferTicketCount": columns.Add(@"""TransferTicketCount"""); break; case "txRollupCommitCount": columns.Add(@"""TxRollupCommitCount"""); break; case "txRollupDispatchTicketsCount": columns.Add(@"""TxRollupDispatchTicketsCount"""); break; @@ -299,6 +333,8 @@ public async Task GetDelegates( case "smartRollupRefuteCount": columns.Add(@"""SmartRollupRefuteCount"""); break; case "refutationGamesCount": columns.Add(@"""RefutationGamesCount"""); break; case "activeRefutationGamesCount": columns.Add(@"""ActiveRefutationGamesCount"""); break; + case "stakingOpsCount": columns.Add(@"""StakingOpsCount"""); break; + case "autostakingOpsCount": columns.Add(@"""AutostakingOpsCount"""); break; } } @@ -364,12 +400,20 @@ public async Task GetDelegates( break; case "frozenDeposit": foreach (var row in rows) - result[j++][i] = row.FrozenDeposit; + result[j++][i] = row.TotalStakedBalance; break; case "frozenDepositLimit": foreach (var row in rows) result[j++][i] = row.FrozenDepositLimit; break; + case "limitOfStakingOverBaking": + foreach (var row in rows) + result[j++][i] = row.LimitOfStakingOverBaking; + break; + case "edgeOfBakingOverStaking": + foreach (var row in rows) + result[j++][i] = row.EdgeOfBakingOverStaking; + break; case "delegatedBalance": foreach (var row in rows) result[j++][i] = row.DelegatedBalance; @@ -534,6 +578,46 @@ public async Task GetDelegates( foreach (var row in rows) result[j++][i] = row.RollupsCount; break; + case "stakedBalance": + foreach (var row in rows) + result[j++][i] = row.StakedBalance; + break; + case "stakedPseudotokens": + foreach (var row in rows) + result[j++][i] = row.StakedPseudotokens; + break; + case "unstakedBalance": + foreach (var row in rows) + result[j++][i] = row.UnstakedBalance; + break; + case "unstakedBaker": + foreach (var row in rows) + result[j++][i] = row.UnstakedBakerId == null ? null : Accounts.GetAlias(row.UnstakedBakerId); + break; + case "totalStakedBalance": + foreach (var row in rows) + result[j++][i] = row.TotalStakedBalance; + break; + case "externalStakedBalance": + foreach (var row in rows) + result[j++][i] = row.ExternalStakedBalance; + break; + case "externalUnstakedBalance": + foreach (var row in rows) + result[j++][i] = row.ExternalUnstakedBalance; + break; + case "issuedPseudotokens": + foreach (var row in rows) + result[j++][i] = row.IssuedPseudotokens; + break; + case "stakersCount": + foreach (var row in rows) + result[j++][i] = row.StakersCount; + break; + case "lostBalance": + foreach (var row in rows) + result[j++][i] = row.LostBalance; + break; case "transferTicketCount": foreach (var row in rows) result[j++][i] = row.TransferTicketCount; @@ -630,6 +714,14 @@ public async Task GetDelegates( foreach (var row in rows) result[j++][i] = row.ActiveRefutationGamesCount; break; + case "stakingOpsCount": + foreach (var row in rows) + result[j++][i] = row.StakingOpsCount; + break; + case "autostakingOpsCount": + foreach (var row in rows) + result[j++][i] = row.AutostakingOpsCount; + break; } } @@ -655,8 +747,10 @@ public async Task GetDelegates( case "publicKey": columns.Add(@"""PublicKey"""); break; case "revealed": columns.Add(@"""Revealed"""); break; case "balance": columns.Add(@"""Balance"""); break; - case "frozenDeposit": columns.Add(@"""FrozenDeposit"""); break; + case "frozenDeposit": columns.Add(@"""TotalStakedBalance"""); break; case "frozenDepositLimit": columns.Add(@"""FrozenDepositLimit"""); break; + case "limitOfStakingOverBaking": columns.Add(@"""LimitOfStakingOverBaking"""); break; + case "edgeOfBakingOverStaking": columns.Add(@"""EdgeOfBakingOverStaking"""); break; case "delegatedBalance": columns.Add(@"""DelegatedBalance"""); break; case "counter": columns.Add(@"""Counter"""); break; case "activationLevel": columns.Add(@"""ActivationLevel"""); break; @@ -698,6 +792,16 @@ public async Task GetDelegates( case "software": columns.Add(@"""SoftwareId"""); break; case "rollupBonds": columns.Add(@"""RollupBonds"""); break; case "rollupsCount": columns.Add(@"""RollupsCount"""); break; + case "stakedBalance": columns.Add(@"""StakedBalance"""); break; + case "stakedPseudotokens": columns.Add(@"""StakedPseudotokens"""); break; + case "unstakedBalance": columns.Add(@"""UnstakedBalance"""); break; + case "unstakedBaker": columns.Add(@"""UnstakedBakerId"""); break; + case "totalStakedBalance": columns.Add(@"""TotalStakedBalance"""); break; + case "externalStakedBalance": columns.Add(@"""ExternalStakedBalance"""); break; + case "externalUnstakedBalance": columns.Add(@"""ExternalUnstakedBalance"""); break; + case "issuedPseudotokens": columns.Add(@"""IssuedPseudotokens"""); break; + case "stakersCount": columns.Add(@"""StakersCount"""); break; + case "lostBalance": columns.Add(@"""LostBalance"""); break; case "transferTicketCount": columns.Add(@"""TransferTicketCount"""); break; case "txRollupCommitCount": columns.Add(@"""TxRollupCommitCount"""); break; case "txRollupDispatchTicketsCount": columns.Add(@"""TxRollupDispatchTicketsCount"""); break; @@ -722,6 +826,8 @@ public async Task GetDelegates( case "smartRollupRefuteCount": columns.Add(@"""SmartRollupRefuteCount"""); break; case "refutationGamesCount": columns.Add(@"""RefutationGamesCount"""); break; case "activeRefutationGamesCount": columns.Add(@"""ActiveRefutationGamesCount"""); break; + case "stakingOpsCount": columns.Add(@"""StakingOpsCount"""); break; + case "autostakingOpsCount": columns.Add(@"""AutostakingOpsCount"""); break; } if (columns.Count == 0) @@ -780,15 +886,23 @@ public async Task GetDelegates( case "balance": foreach (var row in rows) result[j++] = row.Balance; - break; + break; case "frozenDeposit": foreach (var row in rows) - result[j++] = row.FrozenDeposit; + result[j++] = row.TotalStakedBalance; break; case "frozenDepositLimit": foreach (var row in rows) result[j++] = row.FrozenDepositLimit; break; + case "limitOfStakingOverBaking": + foreach (var row in rows) + result[j++] = row.LimitOfStakingOverBaking; + break; + case "edgeOfBakingOverStaking": + foreach (var row in rows) + result[j++] = row.EdgeOfBakingOverStaking; + break; case "delegatedBalance": foreach (var row in rows) result[j++] = row.DelegatedBalance; @@ -953,6 +1067,46 @@ public async Task GetDelegates( foreach (var row in rows) result[j++] = row.RollupsCount; break; + case "stakedBalance": + foreach (var row in rows) + result[j++] = row.StakedBalance; + break; + case "stakedPseudotokens": + foreach (var row in rows) + result[j++] = row.StakedPseudotokens; + break; + case "unstakedBalance": + foreach (var row in rows) + result[j++] = row.UnstakedBalance; + break; + case "unstakedBaker": + foreach (var row in rows) + result[j++] = row.UnstakedBakerId == null ? null : Accounts.GetAlias(row.UnstakedBakerId); + break; + case "totalStakedBalance": + foreach (var row in rows) + result[j++] = row.TotalStakedBalance; + break; + case "externalStakedBalance": + foreach (var row in rows) + result[j++] = row.ExternalStakedBalance; + break; + case "externalUnstakedBalance": + foreach (var row in rows) + result[j++] = row.ExternalUnstakedBalance; + break; + case "issuedPseudotokens": + foreach (var row in rows) + result[j++] = row.IssuedPseudotokens; + break; + case "stakersCount": + foreach (var row in rows) + result[j++] = row.StakersCount; + break; + case "lostBalance": + foreach (var row in rows) + result[j++] = row.LostBalance; + break; case "transferTicketCount": foreach (var row in rows) result[j++] = row.TransferTicketCount; @@ -1049,6 +1203,14 @@ public async Task GetDelegates( foreach (var row in rows) result[j++] = row.ActiveRefutationGamesCount; break; + case "stakingOpsCount": + foreach (var row in rows) + result[j++] = row.StakingOpsCount; + break; + case "autostakingOpsCount": + foreach (var row in rows) + result[j++] = row.AutostakingOpsCount; + break; } return result; diff --git a/Tzkt.Api/Repositories/AccountRepository.cs b/Tzkt.Api/Repositories/AccountRepository.cs index d4849afc0..227772c2d 100644 --- a/Tzkt.Api/Repositories/AccountRepository.cs +++ b/Tzkt.Api/Repositories/AccountRepository.cs @@ -55,6 +55,16 @@ public async Task Get(string address, bool legacy) Balance = delegat.Balance, RollupBonds = delegat.RollupBonds, RollupsCount = delegat.RollupsCount, + StakedBalance = delegat.StakedBalance, + StakedPseudotokens = delegat.StakedPseudotokens, + UnstakedBalance = delegat.UnstakedBalance, + UnstakedBaker = delegat.UnstakedBakerId == null ? null : Accounts.GetAlias(delegat.UnstakedBakerId.Value), + TotalStakedBalance = delegat.TotalStakedBalance, + ExternalStakedBalance = delegat.ExternalStakedBalance, + ExternalUnstakedBalance = delegat.ExternalUnstakedBalance, + IssuedPseudotokens = delegat.IssuedPseudotokens, + StakersCount = delegat.StakersCount, + LostBalance = delegat.LostBalance, TransferTicketCount = delegat.TransferTicketCount, TxRollupCommitCount = delegat.TxRollupCommitCount, TxRollupDispatchTicketsCount = delegat.TxRollupDispatchTicketsCount, @@ -68,8 +78,9 @@ public async Task Get(string address, bool legacy) VdfRevelationsCount = delegat.VdfRevelationsCount, UpdateConsensusKeyCount = delegat.UpdateConsensusKeyCount, DrainDelegateCount = delegat.DrainDelegateCount, - FrozenDeposit = delegat.FrozenDeposit, FrozenDepositLimit = delegat.FrozenDepositLimit, + LimitOfStakingOverBaking = delegat.LimitOfStakingOverBaking, + EdgeOfBakingOverStaking = delegat.EdgeOfBakingOverStaking, DelegatedBalance = delegat.DelegatedBalance, Counter = delegat.Counter, ActivationLevel = delegat.ActivationLevel, @@ -119,6 +130,8 @@ public async Task Get(string address, bool legacy) SmartRollupRefuteCount = delegat.SmartRollupRefuteCount, RefutationGamesCount = delegat.RefutationGamesCount, ActiveRefutationGamesCount = delegat.ActiveRefutationGamesCount, + StakingOpsCount = delegat.StakingOpsCount, + AutostakingOpsCount = delegat.AutostakingOpsCount, Metadata = legacy ? delegat.Profile : null, Extras = legacy ? null : delegat.Extras, Software = delegat.SoftwareId == null ? null : Software[(int)delegat.SoftwareId] @@ -137,6 +150,11 @@ public async Task Get(string address, bool legacy) Balance = user.Balance, RollupBonds = user.RollupBonds, RollupsCount = user.RollupsCount, + StakedBalance = user.StakedBalance, + StakedPseudotokens = user.StakedPseudotokens, + UnstakedBalance = user.UnstakedBalance, + UnstakedBaker = user.UnstakedBakerId == null ? null : Accounts.GetAlias(user.UnstakedBakerId.Value), + LostBalance = user.LostBalance, TransferTicketCount = user.TransferTicketCount, TxRollupCommitCount = user.TxRollupCommitCount, TxRollupDispatchTicketsCount = user.TxRollupDispatchTicketsCount, @@ -189,6 +207,7 @@ public async Task Get(string address, bool legacy) SmartRollupRefuteCount = user.SmartRollupRefuteCount, RefutationGamesCount = user.RefutationGamesCount, ActiveRefutationGamesCount = user.ActiveRefutationGamesCount, + StakingOpsCount = user.StakingOpsCount, Metadata = legacy ? user.Profile : null, Extras = legacy ? null : user.Extras }; @@ -427,6 +446,11 @@ public async Task> Get( Balance = row.Balance, RollupBonds = row.RollupBonds, RollupsCount = row.RollupsCount, + StakedBalance = row.StakedBalance, + StakedPseudotokens = row.StakedPseudotokens, + UnstakedBalance = row.UnstakedBalance, + UnstakedBaker = row.UnstakedBakerId == null ? null : Accounts.GetAlias(row.UnstakedBakerId), + LostBalance = row.LostBalance, TransferTicketCount = row.TransferTicketCount, TxRollupCommitCount = row.TxRollupCommitCount, TxRollupDispatchTicketsCount = row.TxRollupDispatchTicketsCount, @@ -478,7 +502,8 @@ public async Task> Get( SmartRollupRecoverBondCount = row.SmartRollupRecoverBondCount, SmartRollupRefuteCount = row.SmartRollupRefuteCount, RefutationGamesCount = row.RefutationGamesCount, - ActiveRefutationGamesCount = row.ActiveRefutationGamesCount + ActiveRefutationGamesCount = row.ActiveRefutationGamesCount, + StakingOpsCount = row.StakingOpsCount }); #endregion break; @@ -495,6 +520,16 @@ public async Task> Get( Balance = row.Balance, RollupBonds = row.RollupBonds, RollupsCount = row.RollupsCount, + StakedBalance = row.StakedBalance, + StakedPseudotokens = row.StakedPseudotokens, + UnstakedBalance = row.UnstakedBalance, + UnstakedBaker = row.UnstakedBakerId == null ? null : Accounts.GetAlias(row.UnstakedBakerId), + TotalStakedBalance = row.TotalStakedBalance, + ExternalStakedBalance = row.ExternalStakedBalance, + ExternalUnstakedBalance = row.ExternalUnstakedBalance, + IssuedPseudotokens = row.IssuedPseudotokens, + StakersCount = row.StakersCount, + LostBalance = row.LostBalance, TransferTicketCount = row.TransferTicketCount, TxRollupCommitCount = row.TxRollupCommitCount, TxRollupDispatchTicketsCount = row.TxRollupDispatchTicketsCount, @@ -508,8 +543,9 @@ public async Task> Get( VdfRevelationsCount = row.VdfRevelationsCount, UpdateConsensusKeyCount = row.UpdateConsensusKeyCount, DrainDelegateCount = row.DrainDelegateCount, - FrozenDeposit = row.FrozenDeposit, FrozenDepositLimit = row.FrozenDepositLimit, + LimitOfStakingOverBaking = row.LimitOfStakingOverBaking, + EdgeOfBakingOverStaking = row.EdgeOfBakingOverStaking, DelegatedBalance = row.DelegatedBalance, Counter = row.Counter, ActivationLevel = row.ActivationLevel, @@ -559,6 +595,8 @@ public async Task> Get( SmartRollupRefuteCount = row.SmartRollupRefuteCount, RefutationGamesCount = row.RefutationGamesCount, ActiveRefutationGamesCount = row.ActiveRefutationGamesCount, + StakingOpsCount = row.StakingOpsCount, + AutostakingOpsCount = row.AutostakingOpsCount, Software = row.SoftwareId == null ? null : Software[row.SoftwareId] }); #endregion @@ -754,9 +792,11 @@ public async Task Get( case "address": columns.Add(@"""Address"""); break; case "publicKey": columns.Add(@"""PublicKey"""); break; case "revealed": columns.Add(@"""Revealed"""); break; - case "balance": columns.Add(@"""Balance"""); break; - case "frozenDeposit": columns.Add(@"""FrozenDeposit"""); break; + case "balance": columns.Add(@"""Balance"""); break; + case "frozenDeposit": columns.Add(@"""TotalStakedBalance"""); break; case "frozenDepositLimit": columns.Add(@"""FrozenDepositLimit"""); break; + case "limitOfStakingOverBaking": columns.Add(@"""LimitOfStakingOverBaking"""); break; + case "edgeOfBakingOverStaking": columns.Add(@"""EdgeOfBakingOverStaking"""); break; case "delegatedBalance": columns.Add(@"""DelegatedBalance"""); break; case "counter": columns.Add(@"""Counter"""); break; case "activationLevel": columns.Add(@"""ActivationLevel"""); break; @@ -798,6 +838,16 @@ public async Task Get( case "software": columns.Add(@"""SoftwareId"""); break; case "rollupBonds": columns.Add(@"""RollupBonds"""); break; case "rollupsCount": columns.Add(@"""RollupsCount"""); break; + case "stakedBalance": columns.Add(@"""StakedBalance"""); break; + case "stakedPseudotokens": columns.Add(@"""StakedPseudotokens"""); break; + case "unstakedBalance": columns.Add(@"""UnstakedBalance"""); break; + case "unstakedBaker": columns.Add(@"""UnstakedBakerId"""); break; + case "totalStakedBalance": columns.Add(@"""TotalStakedBalance"""); break; + case "externalStakedBalance": columns.Add(@"""ExternalStakedBalance"""); break; + case "externalUnstakedBalance": columns.Add(@"""ExternalUnstakedBalance"""); break; + case "issuedPseudotokens": columns.Add(@"""IssuedPseudotokens"""); break; + case "stakersCount": columns.Add(@"""StakersCount"""); break; + case "lostBalance": columns.Add(@"""LostBalance"""); break; case "transferTicketCount": columns.Add(@"""TransferTicketCount"""); break; case "txRollupCommitCount": columns.Add(@"""TxRollupCommitCount"""); break; case "txRollupDispatchTicketsCount": columns.Add(@"""TxRollupDispatchTicketsCount"""); break; @@ -822,6 +872,8 @@ public async Task Get( case "smartRollupRefuteCount": columns.Add(@"""SmartRollupRefuteCount"""); break; case "refutationGamesCount": columns.Add(@"""RefutationGamesCount"""); break; case "activeRefutationGamesCount": columns.Add(@"""ActiveRefutationGamesCount"""); break; + case "stakingOpsCount": columns.Add(@"""StakingOpsCount"""); break; + case "autostakingOpsCount": columns.Add(@"""AutostakingOpsCount"""); break; case "delegate": columns.Add(@"""DelegateId"""); break; case "delegationLevel": columns.Add(@"""DelegationLevel"""); columns.Add(@"""DelegateId"""); break; @@ -917,12 +969,20 @@ public async Task Get( break; case "frozenDeposit": foreach (var row in rows) - result[j++][i] = row.FrozenDeposit; + result[j++][i] = row.TotalStakedBalance; break; case "frozenDepositLimit": foreach (var row in rows) result[j++][i] = row.FrozenDepositLimit; break; + case "limitOfStakingOverBaking": + foreach (var row in rows) + result[j++][i] = row.LimitOfStakingOverBaking; + break; + case "edgeOfBakingOverStaking": + foreach (var row in rows) + result[j++][i] = row.EdgeOfBakingOverStaking; + break; case "delegatedBalance": foreach (var row in rows) result[j++][i] = row.DelegatedBalance; @@ -1087,6 +1147,46 @@ public async Task Get( foreach (var row in rows) result[j++][i] = row.RollupsCount; break; + case "stakedBalance": + foreach (var row in rows) + result[j++][i] = row.StakedBalance; + break; + case "stakedPseudotokens": + foreach (var row in rows) + result[j++][i] = row.StakedPseudotokens; + break; + case "unstakedBalance": + foreach (var row in rows) + result[j++][i] = row.UnstakedBalance; + break; + case "unstakedBaker": + foreach (var row in rows) + result[j++][i] = row.UnstakedBakerId == null ? null : Accounts.GetAlias(row.UnstakedBakerId); + break; + case "totalStakedBalance": + foreach (var row in rows) + result[j++][i] = row.TotalStakedBalance; + break; + case "externalStakedBalance": + foreach (var row in rows) + result[j++][i] = row.ExternalStakedBalance; + break; + case "externalUnstakedBalance": + foreach (var row in rows) + result[j++][i] = row.ExternalUnstakedBalance; + break; + case "issuedPseudotokens": + foreach (var row in rows) + result[j++][i] = row.IssuedPseudotokens; + break; + case "stakersCount": + foreach (var row in rows) + result[j++][i] = row.StakersCount; + break; + case "lostBalance": + foreach (var row in rows) + result[j++][i] = row.LostBalance; + break; case "transferTicketCount": foreach (var row in rows) result[j++][i] = row.TransferTicketCount; @@ -1183,6 +1283,14 @@ public async Task Get( foreach (var row in rows) result[j++][i] = row.ActiveRefutationGamesCount; break; + case "stakingOpsCount": + foreach (var row in rows) + result[j++][i] = row.StakingOpsCount; + break; + case "autostakingOpsCount": + foreach (var row in rows) + result[j++][i] = row.AutostakingOpsCount; + break; case "delegate": foreach (var row in rows) { @@ -1321,8 +1429,10 @@ public async Task Get( case "publicKey": columns.Add(@"""PublicKey"""); break; case "revealed": columns.Add(@"""Revealed"""); break; case "balance": columns.Add(@"""Balance"""); break; - case "frozenDeposit": columns.Add(@"""FrozenDeposit"""); break; + case "frozenDeposit": columns.Add(@"""TotalStakedBalance"""); break; case "frozenDepositLimit": columns.Add(@"""FrozenDepositLimit"""); break; + case "limitOfStakingOverBaking": columns.Add(@"""LimitOfStakingOverBaking"""); break; + case "edgeOfBakingOverStaking": columns.Add(@"""EdgeOfBakingOverStaking"""); break; case "delegatedBalance": columns.Add(@"""DelegatedBalance"""); break; case "counter": columns.Add(@"""Counter"""); break; case "activationLevel": columns.Add(@"""ActivationLevel"""); break; @@ -1364,6 +1474,16 @@ public async Task Get( case "software": columns.Add(@"""SoftwareId"""); break; case "rollupBonds": columns.Add(@"""RollupBonds"""); break; case "rollupsCount": columns.Add(@"""RollupsCount"""); break; + case "stakedBalance": columns.Add(@"""StakedBalance"""); break; + case "stakedPseudotokens": columns.Add(@"""StakedPseudotokens"""); break; + case "unstakedBalance": columns.Add(@"""UnstakedBalance"""); break; + case "unstakedBaker": columns.Add(@"""UnstakedBakerId"""); break; + case "totalStakedBalance": columns.Add(@"""TotalStakedBalance"""); break; + case "externalStakedBalance": columns.Add(@"""ExternalStakedBalance"""); break; + case "externalUnstakedBalance": columns.Add(@"""ExternalUnstakedBalance"""); break; + case "issuedPseudotokens": columns.Add(@"""IssuedPseudotokens"""); break; + case "stakersCount": columns.Add(@"""StakersCount"""); break; + case "lostBalance": columns.Add(@"""LostBalance"""); break; case "transferTicketCount": columns.Add(@"""TransferTicketCount"""); break; case "txRollupCommitCount": columns.Add(@"""TxRollupCommitCount"""); break; case "txRollupDispatchTicketsCount": columns.Add(@"""TxRollupDispatchTicketsCount"""); break; @@ -1388,6 +1508,8 @@ public async Task Get( case "smartRollupRefuteCount": columns.Add(@"""SmartRollupRefuteCount"""); break; case "refutationGamesCount": columns.Add(@"""RefutationGamesCount"""); break; case "activeRefutationGamesCount": columns.Add(@"""ActiveRefutationGamesCount"""); break; + case "stakingOpsCount": columns.Add(@"""StakingOpsCount"""); break; + case "autostakingOpsCount": columns.Add(@"""AutostakingOpsCount"""); break; case "delegate": columns.Add(@"""DelegateId"""); break; case "delegationLevel": columns.Add(@"""DelegationLevel"""); columns.Add(@"""DelegateId"""); break; @@ -1479,12 +1601,20 @@ public async Task Get( break; case "frozenDeposit": foreach (var row in rows) - result[j++] = row.FrozenDeposit; + result[j++] = row.TotalStakedBalance; break; case "frozenDepositLimit": foreach (var row in rows) result[j++] = row.FrozenDepositLimit; break; + case "limitOfStakingOverBaking": + foreach (var row in rows) + result[j++] = row.LimitOfStakingOverBaking; + break; + case "edgeOfBakingOverStaking": + foreach (var row in rows) + result[j++] = row.EdgeOfBakingOverStaking; + break; case "delegatedBalance": foreach (var row in rows) result[j++] = row.DelegatedBalance; @@ -1649,6 +1779,46 @@ public async Task Get( foreach (var row in rows) result[j++] = row.RollupsCount; break; + case "stakedBalance": + foreach (var row in rows) + result[j++] = row.StakedBalance; + break; + case "stakedPseudotokens": + foreach (var row in rows) + result[j++] = row.StakedPseudotokens; + break; + case "unstakedBalance": + foreach (var row in rows) + result[j++] = row.UnstakedBalance; + break; + case "unstakedBaker": + foreach (var row in rows) + result[j++] = row.UnstakedBakerId == null ? null : Accounts.GetAlias(row.UnstakedBakerId); + break; + case "totalStakedBalance": + foreach (var row in rows) + result[j++] = row.TotalStakedBalance; + break; + case "externalStakedBalance": + foreach (var row in rows) + result[j++] = row.ExternalStakedBalance; + break; + case "externalUnstakedBalance": + foreach (var row in rows) + result[j++] = row.ExternalUnstakedBalance; + break; + case "issuedPseudotokens": + foreach (var row in rows) + result[j++] = row.IssuedPseudotokens; + break; + case "stakersCount": + foreach (var row in rows) + result[j++] = row.StakersCount; + break; + case "lostBalance": + foreach (var row in rows) + result[j++] = row.LostBalance; + break; case "transferTicketCount": foreach (var row in rows) result[j++] = row.TransferTicketCount; @@ -1745,6 +1915,14 @@ public async Task Get( foreach (var row in rows) result[j++] = row.ActiveRefutationGamesCount; break; + case "stakingOpsCount": + foreach (var row in rows) + result[j++] = row.StakingOpsCount; + break; + case "autostakingOpsCount": + foreach (var row in rows) + result[j++] = row.AutostakingOpsCount; + break; case "delegate": foreach (var row in rows) { @@ -2125,6 +2303,10 @@ public async Task> GetOperations( ? Operations.GetSmartRollupRefuteOps(new() { anyof = new() { Fields = new[] { "sender", "initiator", "opponent" }, Eq = delegat.Id } }, pagination, quote) : Task.FromResult(Enumerable.Empty()); + var stakingOps = delegat.StakingOpsCount > 0 && types.Contains(OpTypes.Staking) + ? Operations.GetStakingOps(new() { anyof = new() { Fields = new[] { "sender", "baker" }, Eq = delegat.Id } }, pagination, quote) + : Task.FromResult(Enumerable.Empty()); + var migrations = delegat.MigrationsCount > 0 && types.Contains(OpTypes.Migration) ? Operations.GetMigrations(_delegat, null, null, null, level, timestamp, sort, offset, limit, format, quote) : Task.FromResult(Enumerable.Empty()); @@ -2141,6 +2323,10 @@ public async Task> GetOperations( ? Operations.GetEndorsingRewards(null, _delegat, level, timestamp, sort, offset, limit, quote) : Task.FromResult(Enumerable.Empty()); + var autostakingOps = delegat.AutostakingOpsCount > 0 && types.Contains(OpTypes.Autostaking) + ? Operations.GetAutostakingOps(new() { baker = _delegat }, pagination, quote) + : Task.FromResult(Enumerable.Empty()); + await Task.WhenAll( endorsements, preendorsements, @@ -2177,10 +2363,12 @@ await Task.WhenAll( srPublishOps, srRecoverBondOps, srRefuteOps, + stakingOps, migrations, revelationPenalties, bakingOps, - endorsingRewards); + endorsingRewards, + autostakingOps); result.AddRange(endorsements.Result); result.AddRange(preendorsements.Result); @@ -2217,10 +2405,12 @@ await Task.WhenAll( result.AddRange(srPublishOps.Result); result.AddRange(srRecoverBondOps.Result); result.AddRange(srRefuteOps.Result); + result.AddRange(stakingOps.Result); result.AddRange(migrations.Result); result.AddRange(revelationPenalties.Result); result.AddRange(bakingOps.Result); result.AddRange(endorsingRewards.Result); + result.AddRange(autostakingOps.Result); break; case RawUser user: @@ -2326,6 +2516,10 @@ await Task.WhenAll( ? Operations.GetSmartRollupRefuteOps(new() { anyof = new() { Fields = new[] { "sender", "initiator", "opponent" }, Eq = user.Id } }, pagination, quote) : Task.FromResult(Enumerable.Empty()); + var userStakingOps = user.StakingOpsCount > 0 && types.Contains(OpTypes.Staking) + ? Operations.GetStakingOps(new() { anyof = new() { Fields = new[] { "sender", "baker" }, Eq = user.Id } }, pagination, quote) + : Task.FromResult(Enumerable.Empty()); + var userMigrations = user.MigrationsCount > 0 && types.Contains(OpTypes.Migration) ? Operations.GetMigrations(_user, null, null, null, level, timestamp, sort, offset, limit, format, quote) : Task.FromResult(Enumerable.Empty()); @@ -2356,6 +2550,7 @@ await Task.WhenAll( userSrPublishOps, userSrRecoverBondOps, userSrRefuteOps, + userStakingOps, userMigrations); result.AddRange(userActivations.Result); @@ -2383,6 +2578,7 @@ await Task.WhenAll( result.AddRange(userSrPublishOps.Result); result.AddRange(userSrRecoverBondOps.Result); result.AddRange(userSrRefuteOps.Result); + result.AddRange(userStakingOps.Result); result.AddRange(userMigrations.Result); break; diff --git a/Tzkt.Api/Repositories/BalanceHistoryRepository.cs b/Tzkt.Api/Repositories/BalanceHistoryRepository.cs index 92e879970..01acf5a7d 100644 --- a/Tzkt.Api/Repositories/BalanceHistoryRepository.cs +++ b/Tzkt.Api/Repositories/BalanceHistoryRepository.cs @@ -280,6 +280,7 @@ string SumUnion(RawAccount account, int from, int to) if (user.RegisterConstantsCount > 0) SumRegisterConstants(union, from, to); if (user.SetDepositsLimitsCount > 0) SumSetDepositsLimits(union, from, to); if (user.DrainDelegateCount > 0) SumDrainDelegateOps(union, from, to); + if (user.StakingOpsCount > 0) SumStakingOps(union, from, to); } if (account is RawDelegate delegat) @@ -303,10 +304,10 @@ void SumEndorsingRewards(StringBuilder sql, int from, int to) { sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); - sql.Append(@"SUM(""Received"") as ""Change"" "); + sql.Append(@"SUM(""RewardLiquid"" + ""RewardStakedOwn"") as ""Change"" "); sql.Append(@"FROM ""EndorsingRewardOps"" "); sql.Append(@"WHERE ""BakerId"" = @account "); - sql.Append(@"AND ""Received"" != 0 "); + sql.Append(@"AND (""RewardLiquid"" != 0 OR ""RewardStakedOwn"" != 0) "); if (from > 0) sql.Append($@"AND ""Level"" > {from} "); @@ -321,7 +322,7 @@ void SumBaking(StringBuilder sql, int from, int to) sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); #region proposer - sql.Append(@"SUM(""Reward"" + ""Fees"") as ""Change"" "); + sql.Append(@"SUM(""RewardLiquid"" + ""RewardStakedOwn"" + ""Fees"") as ""Change"" "); sql.Append(@"FROM ""Blocks"" "); sql.Append(@"WHERE ""ProposerId"" = @account "); @@ -336,7 +337,7 @@ void SumBaking(StringBuilder sql, int from, int to) sql.Append("UNION ALL SELECT "); #region producer - sql.Append(@"SUM(""Bonus"") as ""Change"" "); + sql.Append(@"SUM(""BonusLiquid"" + ""BonusStakedOwn"") as ""Change"" "); sql.Append(@"FROM ""Blocks"" "); sql.Append(@"WHERE ""ProducerId"" = @account "); @@ -387,7 +388,7 @@ void SumDoubleBaking(StringBuilder sql, int from, int to) sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); #region accuser - sql.Append(@"SUM(""AccuserReward"") as ""Change"" "); + sql.Append(@"SUM(""Reward"") as ""Change"" "); sql.Append(@"FROM ""DoubleBakingOps"" "); sql.Append(@"WHERE ""AccuserId"" = @account "); @@ -402,7 +403,7 @@ void SumDoubleBaking(StringBuilder sql, int from, int to) sql.Append("UNION ALL SELECT "); #region offender - sql.Append(@"SUM(-""OffenderLoss"") as ""Change"" "); + sql.Append(@"SUM(-""LostStaked"" - ""LostUnstaked"") as ""Change"" "); sql.Append(@"FROM ""DoubleBakingOps"" "); sql.Append(@"WHERE ""OffenderId"" = @account "); @@ -420,7 +421,7 @@ void SumDoubleEndorsing(StringBuilder sql, int from, int to) sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); #region accuser - sql.Append(@"SUM(""AccuserReward"") as ""Change"" "); + sql.Append(@"SUM(""Reward"") as ""Change"" "); sql.Append(@"FROM ""DoubleEndorsingOps"" "); sql.Append(@"WHERE ""AccuserId"" = @account "); @@ -435,7 +436,7 @@ void SumDoubleEndorsing(StringBuilder sql, int from, int to) sql.Append("UNION ALL SELECT "); #region offender - sql.Append(@"SUM(-""OffenderLoss"") as ""Change"" "); + sql.Append(@"SUM(-""LostStaked"" - ""LostUnstaked"") as ""Change"" "); sql.Append(@"FROM ""DoubleEndorsingOps"" "); sql.Append(@"WHERE ""OffenderId"" = @account "); @@ -453,7 +454,7 @@ void SumDoublePreendorsing(StringBuilder sql, int from, int to) sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); #region accuser - sql.Append(@"SUM(""AccuserReward"") as ""Change"" "); + sql.Append(@"SUM(""Reward"") as ""Change"" "); sql.Append(@"FROM ""DoublePreendorsingOps"" "); sql.Append(@"WHERE ""AccuserId"" = @account "); @@ -468,7 +469,7 @@ void SumDoublePreendorsing(StringBuilder sql, int from, int to) sql.Append("UNION ALL SELECT "); #region offender - sql.Append(@"SUM(-""OffenderLoss"") as ""Change"" "); + sql.Append(@"SUM(-""LostStaked"" - ""LostUnstaked"") as ""Change"" "); sql.Append(@"FROM ""DoublePreendorsingOps"" "); sql.Append(@"WHERE ""OffenderId"" = @account "); @@ -485,7 +486,7 @@ void SumNonceRevelations(StringBuilder sql, int from, int to) { sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); - sql.Append(@"SUM(""Reward"") "); + sql.Append(@"SUM(""RewardLiquid"" + ""RewardStakedOwn"") as ""Change"" "); sql.Append(@"FROM ""NonceRevelationOps"" "); sql.Append(@"WHERE ""BakerId"" = @account "); @@ -501,7 +502,7 @@ void SumVdfRevelations(StringBuilder sql, int from, int to) { sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); - sql.Append(@"SUM(""Reward"") "); + sql.Append(@"SUM(""RewardLiquid"" + ""RewardStakedOwn"") as ""Change"" "); sql.Append(@"FROM ""VdfRevelationOps"" "); sql.Append(@"WHERE ""BakerId"" = @account "); @@ -936,6 +937,22 @@ void SumDrainDelegateOps(StringBuilder sql, int from, int to) #endregion } + void SumStakingOps(StringBuilder sql, int from, int to) + { + sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); + + sql.Append(@"SUM(-""BakerFee"") as ""Change"" "); + sql.Append(@"FROM ""StakingOps"" "); + sql.Append(@"WHERE ""SenderId"" = @account "); + + if (from > 0) + sql.Append($@"AND ""Level"" > {from} "); + else if (to > 0) + sql.Append($@"AND ""Level"" <= {to} "); + + sql.AppendLine(); + } + void SumSrAddMessagesOps(StringBuilder sql, int from, int to) { sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); @@ -1151,6 +1168,7 @@ string SelectUnion(RawAccount account) if (user.RegisterConstantsCount > 0) UnionRegisterConstants(union); if (user.SetDepositsLimitsCount > 0) UnionSetDepositsLimits(union); if (user.DrainDelegateCount > 0) UnionDrainDelegateOps(union); + if (user.StakingOpsCount > 0) UnionStakingOps(union); } if (account is RawDelegate delegat) @@ -1175,11 +1193,11 @@ void UnionEndorsingRewards(StringBuilder sql) sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"(""Received"") as ""Change"" "); + sql.Append(@"(""RewardLiquid"" + ""RewardStakedOwn"") as ""Change"" "); sql.Append(@"FROM ""EndorsingRewardOps"" "); sql.Append(@"WHERE ""BakerId"" = @account "); - sql.Append(@"AND ""Received"" != 0 "); + sql.Append(@"AND (""RewardLiquid"" != 0 OR ""RewardStakedOwn"" != 0) "); sql.AppendLine(); } @@ -1190,7 +1208,7 @@ void UnionBaking(StringBuilder sql) #region proposer sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"(""Reward"" + ""Fees"") as ""Change"" "); + sql.Append(@"(""RewardLiquid"" + ""RewardStakedOwn"" + ""Fees"") as ""Change"" "); sql.Append(@"FROM ""Blocks"" "); sql.Append(@"WHERE ""ProposerId"" = @account "); @@ -1202,7 +1220,7 @@ void UnionBaking(StringBuilder sql) #region producer sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"""Bonus"" as ""Change"" "); + sql.Append(@"(""BonusLiquid"" + ""BonusStakedOwn"") as ""Change"" "); sql.Append(@"FROM ""Blocks"" "); sql.Append(@"WHERE ""ProducerId"" = @account "); @@ -1244,7 +1262,7 @@ void UnionDoubleBaking(StringBuilder sql) #region accuser sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"""AccuserReward"" as ""Change"" "); + sql.Append(@"""Reward"" as ""Change"" "); sql.Append(@"FROM ""DoubleBakingOps"" "); sql.Append(@"WHERE ""AccuserId"" = @account "); @@ -1256,7 +1274,7 @@ void UnionDoubleBaking(StringBuilder sql) #region offender sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"(-""OffenderLoss"") as ""Change"" "); + sql.Append(@"(-""LostStaked"" - ""LostUnstaked"") as ""Change"" "); sql.Append(@"FROM ""DoubleBakingOps"" "); sql.Append(@"WHERE ""OffenderId"" = @account "); @@ -1271,7 +1289,7 @@ void UnionDoubleEndorsing(StringBuilder sql) #region accuser sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"""AccuserReward"" as ""Change"" "); + sql.Append(@"""Reward"" as ""Change"" "); sql.Append(@"FROM ""DoubleEndorsingOps"" "); sql.Append(@"WHERE ""AccuserId"" = @account "); @@ -1283,7 +1301,7 @@ void UnionDoubleEndorsing(StringBuilder sql) #region offender sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"(-""OffenderLoss"") as ""Change"" "); + sql.Append(@"(-""LostStaked"" - ""LostUnstaked"") as ""Change"" "); sql.Append(@"FROM ""DoubleEndorsingOps"" "); sql.Append(@"WHERE ""OffenderId"" = @account "); @@ -1298,7 +1316,7 @@ void UnionDoublePreendorsing(StringBuilder sql) #region accuser sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"""AccuserReward"" as ""Change"" "); + sql.Append(@"""Reward"" as ""Change"" "); sql.Append(@"FROM ""DoublePreendorsingOps"" "); sql.Append(@"WHERE ""AccuserId"" = @account "); @@ -1310,7 +1328,7 @@ void UnionDoublePreendorsing(StringBuilder sql) #region offender sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"(-""OffenderLoss"") as ""Change"" "); + sql.Append(@"(-""LostStaked"" - ""LostUnstaked"") as ""Change"" "); sql.Append(@"FROM ""DoublePreendorsingOps"" "); sql.Append(@"WHERE ""OffenderId"" = @account "); @@ -1324,7 +1342,7 @@ void UnionNonceRevelations(StringBuilder sql) sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"""Reward"" as ""Change"" "); + sql.Append(@"(""RewardLiquid"" + ""RewardStakedOwn"") as ""Change"" "); sql.Append(@"FROM ""NonceRevelationOps"" "); sql.Append(@"WHERE ""BakerId"" = @account "); @@ -1337,7 +1355,7 @@ void UnionVdfRevelations(StringBuilder sql) sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); sql.Append(@"""Level"" as ""Level"", "); - sql.Append(@"""Reward"" as ""Change"" "); + sql.Append(@"(""RewardLiquid"" + ""RewardStakedOwn"") as ""Change"" "); sql.Append(@"FROM ""VdfRevelationOps"" "); sql.Append(@"WHERE ""BakerId"" = @account "); @@ -1690,6 +1708,19 @@ void UnionDrainDelegateOps(StringBuilder sql) #endregion } + void UnionStakingOps(StringBuilder sql) + { + sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); + + sql.Append(@"""Level"" as ""Level"", "); + sql.Append(@"(-""BakerFee"") as ""Change"" "); + + sql.Append(@"FROM ""StakingOps"" "); + sql.Append(@"WHERE ""SenderId"" = @account "); + + sql.AppendLine(); + } + void UnionSrAddMessagesOps(StringBuilder sql) { sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); diff --git a/Tzkt.Api/Repositories/BlockRepository.cs b/Tzkt.Api/Repositories/BlockRepository.cs index 2a726ea20..ed63c4e4b 100644 --- a/Tzkt.Api/Repositories/BlockRepository.cs +++ b/Tzkt.Api/Repositories/BlockRepository.cs @@ -28,11 +28,12 @@ public Task GetCount() public async Task Get(int level, bool operations, MichelineFormat format, Symbols quote) { - var sql = @" + var sql = """ SELECT * - FROM ""Blocks"" - WHERE ""Level"" = @level - LIMIT 1"; + FROM "Blocks" + WHERE "Level" = @level + LIMIT 1 + """; using var db = GetConnection(); var row = await db.QueryFirstOrDefaultAsync(sql, new { level }); @@ -49,8 +50,12 @@ public async Task Get(int level, bool operations, MichelineFormat format, BlockRound = row.BlockRound, Validations = row.Validations, Deposit = row.Deposit, - Reward = row.Reward, - Bonus = row.Bonus, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, + BonusLiquid = row.BonusLiquid, + BonusStakedOwn = row.BonusStakedOwn, + BonusStakedShared = row.BonusStakedShared, Fees = row.Fees, NonceRevealed = row.RevelationId != null, Proposer = row.ProposerId != null ? await Accounts.GetAliasAsync(row.ProposerId) : null, @@ -58,6 +63,8 @@ public async Task Get(int level, bool operations, MichelineFormat format, Software = row.SoftwareId != null ? Software[row.SoftwareId] : null, LBToggle = row.LBToggle, LBToggleEma = row.LBToggleEma, + AIToggle = row.AIToggle, + AIToggleEma = row.AIToggleEma, Quote = Quotes.Get(quote, level) }; @@ -69,11 +76,12 @@ public async Task Get(int level, bool operations, MichelineFormat format, public async Task Get(string hash, bool operations, MichelineFormat format, Symbols quote) { - var sql = @" + var sql = """ SELECT * - FROM ""Blocks"" - WHERE ""Hash"" = @hash::character(51) - LIMIT 1"; + FROM "Blocks" + WHERE "Hash" = @hash::character(51) + LIMIT 1 + """; using var db = GetConnection(); var row = await db.QueryFirstOrDefaultAsync(sql, new { hash }); @@ -90,8 +98,12 @@ public async Task Get(string hash, bool operations, MichelineFormat forma BlockRound = row.BlockRound, Validations = row.Validations, Deposit = row.Deposit, - Reward = row.Reward, - Bonus = row.Bonus, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, + BonusLiquid = row.BonusLiquid, + BonusStakedOwn = row.BonusStakedOwn, + BonusStakedShared = row.BonusStakedShared, Fees = row.Fees, NonceRevealed = row.RevelationId != null, Proposer = row.ProposerId != null ? await Accounts.GetAliasAsync(row.ProposerId) : null, @@ -99,6 +111,8 @@ public async Task Get(string hash, bool operations, MichelineFormat forma Software = row.SoftwareId != null ? Software[row.SoftwareId] : null, LBToggle = row.LBToggle, LBToggleEma = row.LBToggleEma, + AIToggle = row.AIToggle, + AIToggleEma = row.AIToggleEma, Quote = Quotes.Get(quote, row.Level) }; @@ -133,8 +147,14 @@ public async Task> Get( "payloadRound" => ("PayloadRound", "PayloadRound"), "blockRound" => ("BlockRound", "BlockRound"), "validations" => ("Validations", "Validations"), - "reward" => ("Reward", "Reward"), - "bonus" => ("Bonus", "Bonus"), + "reward" => ("RewardLiquid", "RewardLiquid"), + "rewardLiquid" => ("RewardLiquid", "RewardLiquid"), + "rewardStakedOwn" => ("RewardStakedOwn", "RewardStakedOwn"), + "rewardStakedShared" => ("RewardStakedShared", "RewardStakedShared"), + "bonus" => ("BonusLiquid", "BonusLiquid"), + "bonusLiquid" => ("BonusLiquid", "BonusLiquid"), + "bonusStakedOwn" => ("BonusStakedOwn", "BonusStakedOwn"), + "bonusStakedShared" => ("BonusStakedShared", "BonusStakedShared"), "fees" => ("Fees", "Fees"), _ => ("Id", "Id") }); @@ -153,8 +173,12 @@ public async Task> Get( BlockRound = row.BlockRound, Validations = row.Validations, Deposit = row.Deposit, - Reward = row.Reward, - Bonus = row.Bonus, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, + BonusLiquid = row.BonusLiquid, + BonusStakedOwn = row.BonusStakedOwn, + BonusStakedShared = row.BonusStakedShared, Fees = row.Fees, NonceRevealed = row.RevelationId != null, Proposer = row.ProposerId != null ? Accounts.GetAlias(row.ProposerId) : null, @@ -162,6 +186,8 @@ public async Task> Get( Software = row.SoftwareId != null ? Software[row.SoftwareId] : null, LBToggle = row.LBToggle, LBToggleEma = row.LBToggleEma, + AIToggle = row.AIToggle, + AIToggleEma = row.AIToggleEma, Quote = Quotes.Get(quote, row.Level) }); } @@ -193,8 +219,12 @@ public async Task Get( case "blockRound": columns.Add(@"""BlockRound"""); break; case "validations": columns.Add(@"""Validations"""); break; case "deposit": columns.Add(@"""Deposit"""); break; - case "reward": columns.Add(@"""Reward"""); break; - case "bonus": columns.Add(@"""Bonus"""); break; + case "rewardLiquid": columns.Add(@"""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"""RewardStakedShared"""); break; + case "bonusLiquid": columns.Add(@"""BonusLiquid"""); break; + case "bonusStakedOwn": columns.Add(@"""BonusStakedOwn"""); break; + case "bonusStakedShared": columns.Add(@"""BonusStakedShared"""); break; case "fees": columns.Add(@"""Fees"""); break; case "nonceRevealed": columns.Add(@"""RevelationId"""); break; case "proposer": columns.Add(@"""ProposerId"""); break; @@ -202,7 +232,21 @@ public async Task Get( case "software": columns.Add(@"""SoftwareId"""); break; case "quote": columns.Add(@"""Level"""); break; case "lbToggle": columns.Add(@"""LBToggle"""); break; - case "lbToggleEma": columns.Add(@"""LBToggleEma"""); break; + case "lbToggleEma": columns.Add(@"""LBToggleEma"""); break; + case "aiToggle": columns.Add(@"""AIToggle"""); break; + case "aiToggleEma": columns.Add(@"""AIToggleEma"""); break; + #region deprecated + case "reward": + columns.Add(@"""RewardLiquid"""); + columns.Add(@"""RewardStakedOwn"""); + columns.Add(@"""RewardStakedShared"""); + break; + case "bonus": + columns.Add(@"""BonusLiquid"""); + columns.Add(@"""BonusStakedOwn"""); + columns.Add(@"""BonusStakedShared"""); + break; + #endregion } } @@ -222,9 +266,17 @@ public async Task Get( "payloadRound" => ("PayloadRound", "PayloadRound"), "blockRound" => ("BlockRound", "BlockRound"), "validations" => ("Validations", "Validations"), - "reward" => ("Reward", "Reward"), - "bonus" => ("Bonus", "Bonus"), + "rewardLiquid" => ("RewardLiquid", "RewardLiquid"), + "rewardStakedOwn" => ("RewardStakedOwn", "RewardStakedOwn"), + "rewardStakedShared" => ("RewardStakedShared", "RewardStakedShared"), + "bonusLiquid" => ("BonusLiquid", "BonusLiquid"), + "bonusStakedOwn" => ("BonusStakedOwn", "BonusStakedOwn"), + "bonusStakedShared" => ("BonusStakedShared", "BonusStakedShared"), "fees" => ("Fees", "Fees"), + #region deprecated + "reward" => ("RewardLiquid", "RewardLiquid"), + "bonus" => ("BonusLiquid", "BonusLiquid"), + #endregion _ => ("Id", "Id") }); @@ -275,13 +327,29 @@ public async Task Get( foreach (var row in rows) result[j++][i] = row.Deposit; break; - case "reward": + case "rewardLiquid": foreach (var row in rows) - result[j++][i] = row.Reward; + result[j++][i] = row.RewardLiquid; break; - case "bonus": + case "rewardStakedOwn": + foreach (var row in rows) + result[j++][i] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++][i] = row.RewardStakedShared; + break; + case "bonusLiquid": + foreach (var row in rows) + result[j++][i] = row.BonusLiquid; + break; + case "bonusStakedOwn": foreach (var row in rows) - result[j++][i] = row.Bonus; + result[j++][i] = row.BonusStakedOwn; + break; + case "bonusStakedShared": + foreach (var row in rows) + result[j++][i] = row.BonusStakedShared; break; case "fees": foreach (var row in rows) @@ -311,10 +379,29 @@ public async Task Get( foreach (var row in rows) result[j++][i] = row.LBToggleEma; break; + case "aiToggle": + foreach (var row in rows) + result[j++][i] = row.AIToggle; + break; + case "aiToggleEma": + foreach (var row in rows) + result[j++][i] = row.AIToggleEma; + break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); break; + + #region deprecated + case "reward": + foreach (var row in rows) + result[j++][i] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + case "bonus": + foreach (var row in rows) + result[j++][i] = row.BonusLiquid + row.BonusStakedOwn + row.BonusStakedShared; + break; + #endregion } } @@ -346,8 +433,12 @@ public async Task Get( case "blockRound": columns.Add(@"""BlockRound"""); break; case "validations": columns.Add(@"""Validations"""); break; case "deposit": columns.Add(@"""Deposit"""); break; - case "reward": columns.Add(@"""Reward"""); break; - case "bonus": columns.Add(@"""Bonus"""); break; + case "rewardLiquid": columns.Add(@"""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"""RewardStakedShared"""); break; + case "bonusLiquid": columns.Add(@"""BonusLiquid"""); break; + case "bonusStakedOwn": columns.Add(@"""BonusStakedOwn"""); break; + case "bonusStakedShared": columns.Add(@"""BonusStakedShared"""); break; case "fees": columns.Add(@"""Fees"""); break; case "nonceRevealed": columns.Add(@"""RevelationId"""); break; case "proposer": columns.Add(@"""ProposerId"""); break; @@ -356,6 +447,20 @@ public async Task Get( case "quote": columns.Add(@"""Level"""); break; case "lbToggle": columns.Add(@"""LBToggle"""); break; case "lbToggleEma": columns.Add(@"""LBToggleEma"""); break; + case "aiToggle": columns.Add(@"""AIToggle"""); break; + case "aiToggleEma": columns.Add(@"""AIToggleEma"""); break; + #region deprecated + case "reward": + columns.Add(@"""RewardLiquid"""); + columns.Add(@"""RewardStakedOwn"""); + columns.Add(@"""RewardStakedShared"""); + break; + case "bonus": + columns.Add(@"""BonusLiquid"""); + columns.Add(@"""BonusStakedOwn"""); + columns.Add(@"""BonusStakedShared"""); + break; + #endregion } if (columns.Count == 0) @@ -374,8 +479,14 @@ public async Task Get( "payloadRound" => ("PayloadRound", "PayloadRound"), "blockRound" => ("BlockRound", "BlockRound"), "validations" => ("Validations", "Validations"), - "reward" => ("Reward", "Reward"), - "bonus" => ("Bonus", "Bonus"), + "reward" => ("RewardLiquid", "RewardLiquid"), + "rewardLiquid" => ("RewardLiquid", "RewardLiquid"), + "rewardStakedOwn" => ("RewardStakedOwn", "RewardStakedOwn"), + "rewardStakedShared" => ("RewardStakedShared", "RewardStakedShared"), + "bonus" => ("BonusLiquid", "BonusLiquid"), + "bonusLiquid" => ("BonusLiquid", "BonusLiquid"), + "bonusStakedOwn" => ("BonusStakedOwn", "BonusStakedOwn"), + "bonusStakedShared" => ("BonusStakedShared", "BonusStakedShared"), "fees" => ("Fees", "Fees"), _ => ("Id", "Id") }); @@ -425,9 +536,29 @@ public async Task Get( foreach (var row in rows) result[j++] = row.Deposit; break; - case "reward": + case "rewardLiquid": + foreach (var row in rows) + result[j++] = row.RewardLiquid; + break; + case "rewardStakedOwn": + foreach (var row in rows) + result[j++] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++] = row.RewardStakedShared; + break; + case "bonusLiquid": + foreach (var row in rows) + result[j++] = row.BonusLiquid; + break; + case "bonusStakedOwn": + foreach (var row in rows) + result[j++] = row.BonusStakedOwn; + break; + case "bonusStakedShared": foreach (var row in rows) - result[j++] = row.Reward; + result[j++] = row.BonusStakedShared; break; case "fees": foreach (var row in rows) @@ -457,10 +588,29 @@ public async Task Get( foreach (var row in rows) result[j++] = row.LBToggleEma; break; + case "aiToggle": + foreach (var row in rows) + result[j++] = row.AIToggle; + break; + case "aiToggleEma": + foreach (var row in rows) + result[j++] = row.AIToggleEma; + break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); break; + + #region deprecated + case "reward": + foreach (var row in rows) + result[j++] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + case "bonus": + foreach (var row in rows) + result[j++] = row.BonusLiquid + row.BonusStakedOwn + row.BonusStakedShared; + break; + #endregion } return result; @@ -631,6 +781,10 @@ async Task LoadOperations(Block block, Data.Models.Operations operations, Michel ? Operations.GetSmartRollupRefuteOps(new() { level = block.Level }, new() { limit = -1 }, quote) : Task.FromResult(Enumerable.Empty()); + var staking = operations.HasFlag(Data.Models.Operations.Staking) + ? Operations.GetStakingOps(new() { level = block.Level }, new() { limit = -1 }, quote) + : Task.FromResult(Enumerable.Empty()); + var migrations = operations.HasFlag(Data.Models.Operations.Migrations) ? Operations.GetMigrations(null, null, null, null, new Int32Parameter { Eq = block.Level }, null, null, null, 10_000, format, quote) : Task.FromResult(Enumerable.Empty()); @@ -643,6 +797,10 @@ async Task LoadOperations(Block block, Data.Models.Operations operations, Michel ? Operations.GetEndorsingRewards(null, null, new Int32Parameter { Eq = block.Level }, null, null, null, 10_000, quote) : Task.FromResult(Enumerable.Empty()); + var autostakingOps = operations.HasFlag(Data.Models.Operations.Autostaking) + ? Operations.GetAutostakingOps(new() { level = block.Level }, new() { limit = -1 }, quote) + : Task.FromResult(Enumerable.Empty()); + await Task.WhenAll( endorsements, preendorsements, @@ -679,9 +837,11 @@ await Task.WhenAll( srPublishOps, srRecoverBondOps, srRefuteOps, + staking, migrations, penalties, - endorsingRewards); + endorsingRewards, + autostakingOps); block.Endorsements = endorsements.Result; block.Preendorsements = preendorsements.Result; @@ -718,9 +878,11 @@ await Task.WhenAll( block.SrPublishOps = srPublishOps.Result; block.SrRecoverBondOps = srRecoverBondOps.Result; block.SrRefuteOps = srRefuteOps.Result; + block.StakingOps = staking.Result; block.Migrations = migrations.Result; block.RevelationPenalties = penalties.Result; block.EndorsingRewards = endorsingRewards.Result; + block.AutostakingOps = autostakingOps.Result; } } } diff --git a/Tzkt.Api/Repositories/CyclesRepository.cs b/Tzkt.Api/Repositories/CyclesRepository.cs index 773917a3e..891177479 100644 --- a/Tzkt.Api/Repositories/CyclesRepository.cs +++ b/Tzkt.Api/Repositories/CyclesRepository.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using Dapper; +using Dapper; using Netezos.Encoding; - using Tzkt.Api.Models; using Tzkt.Api.Services.Cache; @@ -30,11 +24,12 @@ public async Task GetCount() public async Task Get(int index, Symbols quote) { - var sql = @" + var sql = """ SELECT * - FROM ""Cycles"" - WHERE ""Index"" = @index - LIMIT 1"; + FROM "Cycles" + WHERE "Index" = @index + LIMIT 1 + """; using var db = GetConnection(); var row = await db.QueryFirstOrDefaultAsync(sql, new { index }); @@ -51,11 +46,13 @@ public async Task Get(int index, Symbols quote) SnapshotIndex = row.SnapshotIndex, SnapshotLevel = row.SnapshotLevel, TotalBakers = row.TotalBakers, - TotalDelegated = row.TotalDelegated, - TotalDelegators = row.TotalDelegators, - TotalStaking = row.TotalStaking, - SelectedBakers = row.SelectedBakers, - SelectedStake = row.SelectedStake, + TotalBakingPower = row.TotalBakingPower, + BlockReward = row.BlockReward, + BlockBonusPerSlot = row.BlockBonusPerSlot, + EndorsementRewardPerSlot = row.EndorsementRewardPerSlot, + NonceRevelationReward = row.NonceRevelationReward, + VdfRevelationReward = row.VdfRevelationReward, + LBSubsidy = row.LBSubsidy, Quote = Quotes.Get(quote, row.LastLevel) }; } @@ -85,11 +82,13 @@ public async Task> Get( SnapshotIndex = row.SnapshotIndex, SnapshotLevel = row.SnapshotLevel, TotalBakers = row.TotalBakers, - TotalDelegated = row.TotalDelegated, - TotalDelegators = row.TotalDelegators, - TotalStaking = row.TotalStaking, - SelectedBakers = row.SelectedBakers, - SelectedStake = row.SelectedStake, + TotalBakingPower = row.TotalBakingPower, + BlockReward = row.BlockReward, + BlockBonusPerSlot = row.BlockBonusPerSlot, + EndorsementRewardPerSlot = row.EndorsementRewardPerSlot, + NonceRevelationReward = row.NonceRevelationReward, + VdfRevelationReward = row.VdfRevelationReward, + LBSubsidy = row.LBSubsidy, Quote = Quotes.Get(quote, row.LastLevel) }); } @@ -116,12 +115,21 @@ public async Task Get( case "snapshotIndex": columns.Add(@"""SnapshotIndex"""); break; case "snapshotLevel": columns.Add(@"""SnapshotLevel"""); break; case "totalBakers": columns.Add(@"""TotalBakers"""); break; - case "totalDelegated": columns.Add(@"""TotalDelegated"""); break; - case "totalDelegators": columns.Add(@"""TotalDelegators"""); break; - case "totalStaking": columns.Add(@"""TotalStaking"""); break; - case "selectedBakers": columns.Add(@"""SelectedBakers"""); break; - case "selectedStake": columns.Add(@"""SelectedStake"""); break; + case "totalBakingPower": columns.Add(@"""TotalBakingPower"""); break; + case "blockReward": columns.Add(@"""BlockReward"""); break; + case "blockBonusPerSlot": columns.Add(@"""BlockBonusPerSlot"""); break; + case "endorsementRewardPerSlot": columns.Add(@"""EndorsementRewardPerSlot"""); break; + case "nonceRevelationReward": columns.Add(@"""NonceRevelationReward"""); break; + case "vdfRevelationReward": columns.Add(@"""VdfRevelationReward"""); break; + case "lbSubsidy": columns.Add(@"""LBSubsidy"""); break; case "quote": columns.Add(@"""LastLevel"""); break; + #region deprecated + case "totalDelegated": columns.Add(@"0"); break; + case "totalDelegators": columns.Add(@"0"); break; + case "totalStaking": columns.Add(@"""TotalBakingPower"""); break; + case "selectedBakers": columns.Add(@"""TotalBakers"""); break; + case "selectedStake": columns.Add(@"""TotalBakingPower"""); break; + #endregion } } @@ -179,30 +187,60 @@ public async Task Get( foreach (var row in rows) result[j++][i] = row.TotalBakers; break; + case "totalBakingPower": + foreach (var row in rows) + result[j++][i] = row.TotalBakingPower; + break; + case "blockReward": + foreach (var row in rows) + result[j++][i] = row.BlockReward; + break; + case "blockBonusPerSlot": + foreach (var row in rows) + result[j++][i] = row.BlockBonusPerSlot; + break; + case "endorsementRewardPerSlot": + foreach (var row in rows) + result[j++][i] = row.EndorsementRewardPerSlot; + break; + case "nonceRevelationReward": + foreach (var row in rows) + result[j++][i] = row.NonceRevelationReward; + break; + case "vdfRevelationReward": + foreach (var row in rows) + result[j++][i] = row.VdfRevelationReward; + break; + case "lbSubsidy": + foreach (var row in rows) + result[j++][i] = row.LBSubsidy; + break; + case "quote": + foreach (var row in rows) + result[j++][i] = Quotes.Get(quote, row.LastLevel); + break; + #region deprecated case "totalDelegated": foreach (var row in rows) - result[j++][i] = row.TotalDelegated; + result[j++][i] = 0; break; case "totalDelegators": foreach (var row in rows) - result[j++][i] = row.TotalDelegators; + result[j++][i] = 0; break; case "totalStaking": foreach (var row in rows) - result[j++][i] = row.TotalStaking; + result[j++][i] = row.TotalBakingPower; break; case "selectedBakers": foreach (var row in rows) - result[j++][i] = row.SelectedBakers; + result[j++][i] = row.TotalBakers; break; case "selectedStake": foreach (var row in rows) - result[j++][i] = row.SelectedStake; - break; - case "quote": - foreach (var row in rows) - result[j++][i] = Quotes.Get(quote, row.LastLevel); + result[j++][i] = row.TotalBakingPower; break; + #endregion } } @@ -229,12 +267,21 @@ public async Task Get( case "snapshotIndex": columns.Add(@"""SnapshotIndex"""); break; case "snapshotLevel": columns.Add(@"""SnapshotLevel"""); break; case "totalBakers": columns.Add(@"""TotalBakers"""); break; - case "totalDelegated": columns.Add(@"""TotalDelegated"""); break; - case "totalDelegators": columns.Add(@"""TotalDelegators"""); break; - case "totalStaking": columns.Add(@"""TotalStaking"""); break; - case "selectedBakers": columns.Add(@"""SelectedBakers"""); break; - case "selectedStake": columns.Add(@"""SelectedStake"""); break; + case "totalBakingPower": columns.Add(@"""TotalBakingPower"""); break; + case "blockReward": columns.Add(@"""BlockReward"""); break; + case "blockBonusPerSlot": columns.Add(@"""BlockBonusPerSlot"""); break; + case "endorsementRewardPerSlot": columns.Add(@"""EndorsementRewardPerSlot"""); break; + case "nonceRevelationReward": columns.Add(@"""NonceRevelationReward"""); break; + case "vdfRevelationReward": columns.Add(@"""VdfRevelationReward"""); break; + case "lbSubsidy": columns.Add(@"""LBSubsidy"""); break; case "quote": columns.Add(@"""LastLevel"""); break; + #region deprecated + case "totalDelegated": columns.Add(@"0"); break; + case "totalDelegators": columns.Add(@"0"); break; + case "totalStaking": columns.Add(@"""TotalBakingPower"""); break; + case "selectedBakers": columns.Add(@"""TotalBakers"""); break; + case "selectedStake": columns.Add(@"""TotalBakingPower"""); break; + #endregion } if (columns.Count == 0) @@ -289,30 +336,60 @@ public async Task Get( foreach (var row in rows) result[j++] = row.TotalBakers; break; + case "totalBakingPower": + foreach (var row in rows) + result[j++] = row.TotalBakingPower; + break; + case "blockReward": + foreach (var row in rows) + result[j++] = row.BlockReward; + break; + case "blockBonusPerSlot": + foreach (var row in rows) + result[j++] = row.BlockBonusPerSlot; + break; + case "endorsementRewardPerSlot": + foreach (var row in rows) + result[j++] = row.EndorsementRewardPerSlot; + break; + case "nonceRevelationReward": + foreach (var row in rows) + result[j++] = row.NonceRevelationReward; + break; + case "vdfRevelationReward": + foreach (var row in rows) + result[j++] = row.VdfRevelationReward; + break; + case "lbSubsidy": + foreach (var row in rows) + result[j++] = row.LBSubsidy; + break; + case "quote": + foreach (var row in rows) + result[j++] = Quotes.Get(quote, row.LastLevel); + break; + #region deprecated case "totalDelegated": foreach (var row in rows) - result[j++] = row.TotalDelegated; + result[j++] = 0; break; case "totalDelegators": foreach (var row in rows) - result[j++] = row.TotalDelegators; + result[j++] = 0; break; case "totalStaking": foreach (var row in rows) - result[j++] = row.TotalStaking; + result[j++] = row.TotalBakingPower; break; case "selectedBakers": foreach (var row in rows) - result[j++] = row.SelectedBakers; + result[j++] = row.TotalBakers; break; case "selectedStake": foreach (var row in rows) - result[j++] = row.SelectedStake; - break; - case "quote": - foreach (var row in rows) - result[j++] = Quotes.Get(quote, row.LastLevel); + result[j++] = row.TotalBakingPower; break; + #endregion } return result; diff --git a/Tzkt.Api/Repositories/Enums/AutostakingActions.cs b/Tzkt.Api/Repositories/Enums/AutostakingActions.cs new file mode 100644 index 000000000..dda3360ef --- /dev/null +++ b/Tzkt.Api/Repositories/Enums/AutostakingActions.cs @@ -0,0 +1,34 @@ +using Tzkt.Data.Models; + +namespace Tzkt.Api +{ + static class AutostakingActions + { + public const string Stake = "stake"; + public const string Unstake = "unstake"; + public const string Finalize = "finalize"; + public const string Restake = "restake"; + + public static bool TryParse(string value, out int res) + { + res = value switch + { + Stake => (int)AutostakingAction.Stake, + Unstake => (int)AutostakingAction.Unstake, + Finalize => (int)AutostakingAction.Finalize, + Restake => (int)AutostakingAction.Restake, + _ => -1 + }; + return res != -1; + } + + public static string ToString(int value) => value switch + { + (int)AutostakingAction.Stake => Stake, + (int)AutostakingAction.Unstake => Unstake, + (int)AutostakingAction.Finalize => Finalize, + (int)AutostakingAction.Restake => Restake, + _ => throw new Exception("invalid autostaking action value") + }; + } +} diff --git a/Tzkt.Api/Repositories/Enums/MigrationKinds.cs b/Tzkt.Api/Repositories/Enums/MigrationKinds.cs index 017509e11..eaa18a701 100644 --- a/Tzkt.Api/Repositories/Enums/MigrationKinds.cs +++ b/Tzkt.Api/Repositories/Enums/MigrationKinds.cs @@ -1,5 +1,4 @@ -using System; -using Tzkt.Data.Models; +using Tzkt.Data.Models; namespace Tzkt.Api { @@ -12,6 +11,7 @@ static class MigrationKinds public const string CodeChange = "code_change"; public const string Origination = "origination"; public const string Subsidy = "subsidy"; + public const string RemoveBigMapKey = "remove_bigmap_key"; public static bool TryParse(string value, out int res) { @@ -24,6 +24,7 @@ public static bool TryParse(string value, out int res) CodeChange => (int)MigrationKind.CodeChange, Origination => (int)MigrationKind.Origination, Subsidy => (int)MigrationKind.Subsidy, + RemoveBigMapKey => (int)MigrationKind.RemoveBigMapKey, _ => -1 }; return res != -1; @@ -38,6 +39,7 @@ public static bool TryParse(string value, out int res) (int)MigrationKind.CodeChange => CodeChange, (int)MigrationKind.Origination => Origination, (int)MigrationKind.Subsidy => Subsidy, + (int)MigrationKind.RemoveBigMapKey => RemoveBigMapKey, _ => throw new Exception("invalid migration kind value") }; } diff --git a/Tzkt.Api/Repositories/Enums/OpTypes.cs b/Tzkt.Api/Repositories/Enums/OpTypes.cs index 705737a2f..3cf715acc 100644 --- a/Tzkt.Api/Repositories/Enums/OpTypes.cs +++ b/Tzkt.Api/Repositories/Enums/OpTypes.cs @@ -24,6 +24,7 @@ static class OpTypes public const string Reveal = "reveal"; public const string RegisterConstant = "register_constant"; public const string SetDepositsLimit = "set_deposits_limit"; + public const string Staking = "staking"; public const string TxRollupOrigination = "tx_rollup_origination"; public const string TxRollupSubmitBatch = "tx_rollup_submit_batch"; @@ -50,6 +51,7 @@ static class OpTypes public const string RevelationPenalty = "revelation_penalty"; public const string Baking = "baking"; public const string EndorsingReward = "endorsing_reward"; + public const string Autostaking = "autostaking"; public static bool TryParse(string type, out Operations res) { @@ -73,6 +75,7 @@ public static bool TryParse(string type, out Operations res) case Reveal: res = Operations.Reveals; break; case RegisterConstant: res = Operations.RegisterConstant; break; case SetDepositsLimit: res = Operations.SetDepositsLimits; break; + case Staking: res = Operations.Staking; break; case Migration: res = Operations.Migrations; break; case RevelationPenalty: res = Operations.RevelationPenalty; break; case Baking: res = Operations.Baking; break; @@ -95,6 +98,7 @@ public static bool TryParse(string type, out Operations res) case SmartRollupPublish: res = Operations.SmartRollupPublish; break; case SmartRollupRecoverBond: res = Operations.SmartRollupRecoverBond; break; case SmartRollupRefute: res = Operations.SmartRollupRefute; break; + case Autostaking: res = Operations.Autostaking; break; default: return false; } return true; @@ -116,6 +120,7 @@ public static bool TryParse(string type, out Operations res) Reveal, RegisterConstant, SetDepositsLimit, + Staking, Migration, RevelationPenalty, TransferTicket, diff --git a/Tzkt.Api/Repositories/Enums/StakingOperationKinds.cs b/Tzkt.Api/Repositories/Enums/StakingOperationKinds.cs new file mode 100644 index 000000000..5a9d45240 --- /dev/null +++ b/Tzkt.Api/Repositories/Enums/StakingOperationKinds.cs @@ -0,0 +1,34 @@ +using Tzkt.Data.Models; + +namespace Tzkt.Api +{ + static class StakingOperationKinds + { + public const string Stake = "stake"; + public const string Unstake = "unstake"; + public const string Finalize = "finalize"; + public const string SetParameters = "set_parameters"; + + public static bool TryParse(string value, out int res) + { + res = value switch + { + Stake => (int)StakingOperationKind.Stake, + Unstake => (int)StakingOperationKind.Unstake, + Finalize => (int)StakingOperationKind.FinalizeUnstake, + SetParameters => (int)StakingOperationKind.SetDelegateParameter, + _ => -1 + }; + return res != -1; + } + + public static string ToString(int value) => value switch + { + (int)StakingOperationKind.Stake => Stake, + (int)StakingOperationKind.Unstake => Unstake, + (int)StakingOperationKind.FinalizeUnstake => Finalize, + (int)StakingOperationKind.SetDelegateParameter => SetParameters, + _ => throw new Exception("invalid staking operation kind value") + }; + } +} diff --git a/Tzkt.Api/Repositories/OperationRepository.AutostakingOperation.cs b/Tzkt.Api/Repositories/OperationRepository.AutostakingOperation.cs new file mode 100644 index 000000000..600716e70 --- /dev/null +++ b/Tzkt.Api/Repositories/OperationRepository.AutostakingOperation.cs @@ -0,0 +1,156 @@ +using Dapper; +using Tzkt.Api.Models; + +namespace Tzkt.Api.Repositories +{ + public partial class OperationRepository : DbConnection + { + public async Task GetAutostakingOpsCount(AutostakingOperationFilter filter) + { + var sql = new SqlBuilder(""" + SELECT COUNT(*) + FROM "AutostakingOps" as o + """) + .FilterA(@"o.""Id""", filter.id) + .FilterA(@"o.""Level""", filter.level) + .FilterA(@"o.""Level""", filter.timestamp) + .FilterA(@"o.""BakerId""", filter.baker) + .FilterA(@"o.""Action""", filter.action) + .FilterA(@"o.""Cycle""", filter.cycle) + .FilterA(@"o.""Amount""", filter.amount); + + using var db = GetConnection(); + return await db.QueryFirstAsync(sql.Query, sql.Params); + } + + async Task> QueryAutostakingOps(AutostakingOperationFilter filter, Pagination pagination, List fields = null) + { + var select = """ + o."Id", + o."Level", + o."BakerId", + o."Action", + o."Cycle", + o."Amount" + """; + + if (fields != null) + { + var columns = new HashSet(fields.Count); + foreach (var field in fields) + { + switch (field.Field) + { + case "id": columns.Add(@"o.""Id"""); break; + case "level": columns.Add(@"o.""Level"""); break; + case "timestamp": columns.Add(@"o.""Level"""); break; + case "baker": columns.Add(@"o.""BakerId"""); break; + case "action": columns.Add(@"o.""Action"""); break; + case "cycle": columns.Add(@"o.""Cycle"""); break; + case "amount": columns.Add(@"o.""Amount"""); break; + case "quote": columns.Add(@"o.""Level"""); break; + } + } + + if (columns.Count == 0) + return Enumerable.Empty(); + + select = string.Join(',', columns); + } + + var sql = new SqlBuilder($""" + SELECT {select} + FROM "AutostakingOps" as o + """) + .FilterA(@"o.""Id""", filter.id) + .FilterA(@"o.""Level""", filter.level) + .FilterA(@"o.""Level""", filter.timestamp) + .FilterA(@"o.""BakerId""", filter.baker) + .FilterA(@"o.""Action""", filter.action) + .FilterA(@"o.""Cycle""", filter.cycle) + .FilterA(@"o.""Amount""", filter.amount) + .Take(pagination, x => (@"o.""Id""", @"o.""Id"""), @"o.""Id"""); + + using var db = GetConnection(); + return await db.QueryAsync(sql.Query, sql.Params); + } + + public async Task> GetAutostakingOps(AutostakingOperationFilter filter, Pagination pagination, Symbols quote) + { + var rows = await QueryAutostakingOps(filter, pagination); + return rows.Select(row => new AutostakingOperation + { + Id = row.Id, + Level = row.Level, + Timestamp = Times[row.Level], + Baker = Accounts.GetAlias(row.BakerId), + Action = AutostakingActions.ToString(row.Action), + Cycle = row.Cycle, + Amount = row.Amount, + Quote = Quotes.Get(quote, row.Level) + }); + } + + public async Task GetAutostakingOps(AutostakingOperationFilter filter, Pagination pagination, List fields, Symbols quote) + { + var rows = await QueryAutostakingOps(filter, pagination, fields); + + var result = new object[rows.Count()][]; + for (int i = 0; i < result.Length; i++) + result[i] = new object[fields.Count]; + + for (int i = 0, j = 0; i < fields.Count; j = 0, i++) + { + switch (fields[i].Full) + { + case "type": + foreach (var row in rows) + result[j++][i] = OpTypes.Autostaking; + break; + case "id": + foreach (var row in rows) + result[j++][i] = row.Id; + break; + case "level": + foreach (var row in rows) + result[j++][i] = row.Level; + break; + case "timestamp": + foreach (var row in rows) + result[j++][i] = Times[row.Level]; + break; + case "baker": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.BakerId); + break; + case "baker.alias": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.BakerId).Name; + break; + case "baker.address": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.BakerId).Address; + break; + case "action": + foreach (var row in rows) + result[j++][i] = AutostakingActions.ToString(row.Action); + break; + case "cycle": + foreach (var row in rows) + result[j++][i] = row.Cycle; + break; + case "amount": + foreach (var row in rows) + result[j++][i] = row.Amount; + break; + case "quote": + foreach (var row in rows) + result[j++][i] = Quotes.Get(quote, row.Level); + break; + } + } + + return result; + } + } +} diff --git a/Tzkt.Api/Repositories/OperationRepository.Baking.cs b/Tzkt.Api/Repositories/OperationRepository.Baking.cs index 721f52e93..6c532a4e0 100644 --- a/Tzkt.Api/Repositories/OperationRepository.Baking.cs +++ b/Tzkt.Api/Repositories/OperationRepository.Baking.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Dapper; +using Dapper; using Tzkt.Api.Models; namespace Tzkt.Api.Repositories @@ -45,8 +41,12 @@ public async Task GetBaking(long id, Symbols quote) BlockRound = row.BlockRound, Block = row.Hash, Deposit = row.Deposit, - Reward = row.Reward, - Bonus = row.Bonus, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, + BonusLiquid = row.BonusLiquid, + BonusStakedOwn = row.BonusStakedOwn, + BonusStakedShared = row.BonusStakedShared, Fees = row.Fees, Quote = Quotes.Get(quote, row.Level) }; @@ -86,8 +86,12 @@ public async Task> GetBakings( BlockRound = row.BlockRound, Block = row.Hash, Deposit = row.Deposit, - Reward = row.Reward, - Bonus = row.Bonus, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, + BonusLiquid = row.BonusLiquid, + BonusStakedOwn = row.BonusStakedOwn, + BonusStakedShared = row.BonusStakedShared, Fees = row.Fees, Quote = Quotes.Get(quote, row.Level) }); @@ -119,10 +123,26 @@ public async Task GetBakings( case "payloadRound": columns.Add(@"""PayloadRound"""); break; case "blockRound": columns.Add(@"""BlockRound"""); break; case "deposit": columns.Add(@"""Deposit"""); break; - case "reward": columns.Add(@"""Reward"""); break; - case "bonus": columns.Add(@"""Bonus"""); break; + case "rewardLiquid": columns.Add(@"""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"""RewardStakedShared"""); break; + case "bonusLiquid": columns.Add(@"""BonusLiquid"""); break; + case "bonusStakedOwn": columns.Add(@"""BonusStakedOwn"""); break; + case "bonusStakedShared": columns.Add(@"""BonusStakedShared"""); break; case "fees": columns.Add(@"""Fees"""); break; case "quote": columns.Add(@"""Level"""); break; + #region deprecated + case "reward": + columns.Add(@"""RewardLiquid"""); + columns.Add(@"""RewardStakedOwn"""); + columns.Add(@"""RewardStakedShared"""); + break; + case "bonus": + columns.Add(@"""BonusLiquid"""); + columns.Add(@"""BonusStakedOwn"""); + columns.Add(@"""BonusStakedShared"""); + break; + #endregion } } @@ -185,13 +205,29 @@ public async Task GetBakings( foreach (var row in rows) result[j++][i] = row.Deposit; break; - case "reward": + case "rewardLiquid": foreach (var row in rows) - result[j++][i] = row.Reward; + result[j++][i] = row.RewardLiquid; break; - case "bonus": + case "rewardStakedOwn": foreach (var row in rows) - result[j++][i] = row.Bonus; + result[j++][i] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++][i] = row.RewardStakedShared; + break; + case "bonusLiquid": + foreach (var row in rows) + result[j++][i] = row.BonusLiquid; + break; + case "bonusStakedOwn": + foreach (var row in rows) + result[j++][i] = row.BonusStakedOwn; + break; + case "bonusStakedShared": + foreach (var row in rows) + result[j++][i] = row.BonusStakedShared; break; case "fees": foreach (var row in rows) @@ -201,6 +237,17 @@ public async Task GetBakings( foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); break; + + #region deprecated + case "reward": + foreach (var row in rows) + result[j++][i] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + case "bonus": + foreach (var row in rows) + result[j++][i] = row.BonusLiquid + row.BonusStakedOwn + row.BonusStakedShared; + break; + #endregion } } @@ -231,10 +278,26 @@ public async Task GetBakings( case "payloadRound": columns.Add(@"""PayloadRound"""); break; case "blockRound": columns.Add(@"""BlockRound"""); break; case "deposit": columns.Add(@"""Deposit"""); break; - case "reward": columns.Add(@"""Reward"""); break; - case "bonus": columns.Add(@"""Bonus"""); break; + case "rewardLiquid": columns.Add(@"""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"""RewardStakedShared"""); break; + case "bonusLiquid": columns.Add(@"""BonusLiquid"""); break; + case "bonusStakedOwn": columns.Add(@"""BonusStakedOwn"""); break; + case "bonusStakedShared": columns.Add(@"""BonusStakedShared"""); break; case "fees": columns.Add(@"""Fees"""); break; case "quote": columns.Add(@"""Level"""); break; + #region deprecated + case "reward": + columns.Add(@"""RewardLiquid"""); + columns.Add(@"""RewardStakedOwn"""); + columns.Add(@"""RewardStakedShared"""); + break; + case "bonus": + columns.Add(@"""BonusLiquid"""); + columns.Add(@"""BonusStakedOwn"""); + columns.Add(@"""BonusStakedShared"""); + break; + #endregion } if (columns.Count == 0) @@ -294,13 +357,29 @@ public async Task GetBakings( foreach (var row in rows) result[j++] = row.Deposit; break; - case "reward": + case "rewardLiquid": foreach (var row in rows) - result[j++] = row.Reward; + result[j++] = row.RewardLiquid; break; - case "bonus": + case "rewardStakedOwn": foreach (var row in rows) - result[j++] = row.Bonus; + result[j++] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++] = row.RewardStakedShared; + break; + case "bonusLiquid": + foreach (var row in rows) + result[j++] = row.BonusLiquid; + break; + case "bonusStakedOwn": + foreach (var row in rows) + result[j++] = row.BonusStakedOwn; + break; + case "bonusStakedShared": + foreach (var row in rows) + result[j++] = row.BonusStakedShared; break; case "fees": foreach (var row in rows) @@ -310,6 +389,17 @@ public async Task GetBakings( foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); break; + + #region deprecated + case "reward": + foreach (var row in rows) + result[j++] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + case "bonus": + foreach (var row in rows) + result[j++] = row.BonusLiquid + row.BonusStakedOwn + row.BonusStakedShared; + break; + #endregion } return result; diff --git a/Tzkt.Api/Repositories/OperationRepository.Delegations.cs b/Tzkt.Api/Repositories/OperationRepository.Delegations.cs index 96524182b..608674adb 100644 --- a/Tzkt.Api/Repositories/OperationRepository.Delegations.cs +++ b/Tzkt.Api/Repositories/OperationRepository.Delegations.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Dapper; +using Dapper; using Tzkt.Api.Models; using Tzkt.Data; @@ -31,8 +27,7 @@ public async Task GetDelegationsCount( public async Task> GetDelegations(string hash, Symbols quote) { var sql = @" - SELECT o.""Id"", o.""Level"", o.""Timestamp"", o.""SenderId"", o.""InitiatorId"", o.""Counter"", o.""BakerFee"", - o.""GasLimit"", o.""GasUsed"", o.""StorageLimit"", o.""Status"", o.""Nonce"", o.""Amount"", o.""PrevDelegateId"", o.""DelegateId"", o.""Errors"", b.""Hash"" + SELECT o.*, b.""Hash"" FROM ""DelegationOps"" as o INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"" @@ -59,6 +54,9 @@ INNER JOIN ""Blocks"" as b StorageLimit = row.StorageLimit, BakerFee = row.BakerFee, Amount = row.Amount, + UnstakedPseudotokens = row.UnstakedPseudotokens, + UnstakedBalance = row.UnstakedBalance, + UnstakedRewards = row.UnstakedRewards, PrevDelegate = row.PrevDelegateId != null ? Accounts.GetAlias(row.PrevDelegateId) : null, NewDelegate = row.DelegateId != null ? Accounts.GetAlias(row.DelegateId) : null, Status = OpStatuses.ToString(row.Status), @@ -70,8 +68,7 @@ INNER JOIN ""Blocks"" as b public async Task> GetDelegations(string hash, int counter, Symbols quote) { var sql = @" - SELECT o.""Id"", o.""Level"", o.""Timestamp"", o.""SenderId"", o.""InitiatorId"", o.""BakerFee"", - o.""GasLimit"", o.""GasUsed"", o.""StorageLimit"", o.""Status"", o.""Nonce"", o.""Amount"", o.""PrevDelegateId"", o.""DelegateId"", o.""Errors"", b.""Hash"" + SELECT o.*, b.""Hash"" FROM ""DelegationOps"" as o INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"" @@ -98,6 +95,9 @@ INNER JOIN ""Blocks"" as b StorageLimit = row.StorageLimit, BakerFee = row.BakerFee, Amount = row.Amount, + UnstakedPseudotokens = row.UnstakedPseudotokens, + UnstakedBalance = row.UnstakedBalance, + UnstakedRewards = row.UnstakedRewards, PrevDelegate = row.PrevDelegateId != null ? Accounts.GetAlias(row.PrevDelegateId) : null, NewDelegate = row.DelegateId != null ? Accounts.GetAlias(row.DelegateId) : null, Status = OpStatuses.ToString(row.Status), @@ -109,8 +109,7 @@ INNER JOIN ""Blocks"" as b public async Task> GetDelegations(string hash, int counter, int nonce, Symbols quote) { var sql = @" - SELECT o.""Id"", o.""Level"", o.""Timestamp"", o.""SenderId"", o.""InitiatorId"", o.""BakerFee"", - o.""GasLimit"", o.""GasUsed"", o.""StorageLimit"", o.""Status"", o.""Amount"", o.""PrevDelegateId"", o.""DelegateId"", o.""Errors"", b.""Hash"" + SELECT o.*, b.""Hash"" FROM ""DelegationOps"" as o INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"" @@ -137,6 +136,9 @@ INNER JOIN ""Blocks"" as b StorageLimit = row.StorageLimit, BakerFee = row.BakerFee, Amount = row.Amount, + UnstakedPseudotokens = row.UnstakedPseudotokens, + UnstakedBalance = row.UnstakedBalance, + UnstakedRewards = row.UnstakedRewards, PrevDelegate = row.PrevDelegateId != null ? Accounts.GetAlias(row.PrevDelegateId) : null, NewDelegate = row.DelegateId != null ? Accounts.GetAlias(row.DelegateId) : null, Status = OpStatuses.ToString(row.Status), @@ -148,8 +150,7 @@ INNER JOIN ""Blocks"" as b public async Task> GetDelegations(Block block, Symbols quote) { var sql = @" - SELECT ""Id"", ""Timestamp"", ""OpHash"", ""SenderId"", ""InitiatorId"", ""Counter"", ""BakerFee"", - ""GasLimit"", ""GasUsed"", ""StorageLimit"", ""Status"", ""Nonce"", ""Amount"", ""PrevDelegateId"", ""DelegateId"", ""Errors"" + SELECT * FROM ""DelegationOps"" WHERE ""Level"" = @level ORDER BY ""Id"""; @@ -174,6 +175,9 @@ public async Task> GetDelegations(Block block, StorageLimit = row.StorageLimit, BakerFee = row.BakerFee, Amount = row.Amount, + UnstakedPseudotokens = row.UnstakedPseudotokens, + UnstakedBalance = row.UnstakedBalance, + UnstakedRewards = row.UnstakedRewards, PrevDelegate = row.PrevDelegateId != null ? Accounts.GetAlias(row.PrevDelegateId) : null, NewDelegate = row.DelegateId != null ? Accounts.GetAlias(row.DelegateId) : null, Status = OpStatuses.ToString(row.Status), @@ -241,6 +245,9 @@ public async Task> GetDelegations( StorageLimit = row.StorageLimit, BakerFee = row.BakerFee, Amount = row.Amount, + UnstakedPseudotokens = row.UnstakedPseudotokens, + UnstakedBalance = row.UnstakedBalance, + UnstakedRewards = row.UnstakedRewards, PrevDelegate = row.PrevDelegateId != null ? Accounts.GetAlias(row.PrevDelegateId) : null, NewDelegate = row.DelegateId != null ? Accounts.GetAlias(row.DelegateId) : null, Status = OpStatuses.ToString(row.Status), @@ -286,6 +293,9 @@ public async Task GetDelegations( case "storageLimit": columns.Add(@"o.""StorageLimit"""); break; case "bakerFee": columns.Add(@"o.""BakerFee"""); break; case "amount": columns.Add(@"o.""Amount"""); break; + case "unstakedPseudotokens": columns.Add(@"o.""UnstakedPseudotokens"""); break; + case "unstakedBalance": columns.Add(@"o.""UnstakedBalance"""); break; + case "unstakedRewards": columns.Add(@"o.""UnstakedRewards"""); break; case "prevDelegate": columns.Add(@"o.""PrevDelegateId"""); break; case "newDelegate": columns.Add(@"o.""DelegateId"""); break; case "status": columns.Add(@"o.""Status"""); break; @@ -396,6 +406,18 @@ public async Task GetDelegations( foreach (var row in rows) result[j++][i] = row.Amount; break; + case "unstakedPseudotokens": + foreach (var row in rows) + result[j++][i] = row.UnstakedPseudotokens; + break; + case "unstakedBalance": + foreach (var row in rows) + result[j++][i] = row.UnstakedBalance; + break; + case "unstakedRewards": + foreach (var row in rows) + result[j++][i] = row.UnstakedRewards; + break; case "prevDelegate": foreach (var row in rows) result[j++][i] = row.PrevDelegateId != null ? await Accounts.GetAliasAsync(row.PrevDelegateId) : null; @@ -457,6 +479,9 @@ public async Task GetDelegations( case "storageLimit": columns.Add(@"o.""StorageLimit"""); break; case "bakerFee": columns.Add(@"o.""BakerFee"""); break; case "amount": columns.Add(@"o.""Amount"""); break; + case "unstakedPseudotokens": columns.Add(@"o.""UnstakedPseudotokens"""); break; + case "unstakedBalance": columns.Add(@"o.""UnstakedBalance"""); break; + case "unstakedRewards": columns.Add(@"o.""UnstakedRewards"""); break; case "prevDelegate": columns.Add(@"o.""PrevDelegateId"""); break; case "newDelegate": columns.Add(@"o.""DelegateId"""); break; case "status": columns.Add(@"o.""Status"""); break; @@ -564,6 +589,18 @@ public async Task GetDelegations( foreach (var row in rows) result[j++] = row.Amount; break; + case "unstakedPseudotokens": + foreach (var row in rows) + result[j++] = row.UnstakedPseudotokens; + break; + case "unstakedBalance": + foreach (var row in rows) + result[j++] = row.UnstakedBalance; + break; + case "unstakedRewards": + foreach (var row in rows) + result[j++] = row.UnstakedRewards; + break; case "prevDelegate": foreach (var row in rows) result[j++] = row.PrevDelegateId != null ? await Accounts.GetAliasAsync(row.PrevDelegateId) : null; diff --git a/Tzkt.Api/Repositories/OperationRepository.DoubleBaking.cs b/Tzkt.Api/Repositories/OperationRepository.DoubleBaking.cs index 114514b5e..487cd9924 100644 --- a/Tzkt.Api/Repositories/OperationRepository.DoubleBaking.cs +++ b/Tzkt.Api/Repositories/OperationRepository.DoubleBaking.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Dapper; +using Dapper; using Tzkt.Api.Models; namespace Tzkt.Api.Repositories @@ -23,13 +19,14 @@ public async Task GetDoubleBakingsCount( public async Task> GetDoubleBakings(string hash, Symbols quote) { - var sql = @" - SELECT o.*, b.""Hash"" - FROM ""DoubleBakingOps"" as o - INNER JOIN ""Blocks"" as b - ON b.""Level"" = o.""Level"" - WHERE o.""OpHash"" = @hash::character(51) - LIMIT 1"; + var sql = """ + SELECT o.*, b."Hash" + FROM "DoubleBakingOps" as o + INNER JOIN "Blocks" as b + ON b."Level" = o."Level" + WHERE o."OpHash" = @hash::character(51) + LIMIT 1 + """; using var db = GetConnection(); var rows = await db.QueryAsync(sql, new { hash }); @@ -42,21 +39,27 @@ INNER JOIN ""Blocks"" as b Timestamp = row.Timestamp, Hash = hash, AccusedLevel = row.AccusedLevel, + SlashedLevel = row.SlashedLevel, Accuser = Accounts.GetAlias(row.AccuserId), - AccuserReward = row.AccuserReward, + Reward = row.Reward, Offender = Accounts.GetAlias(row.OffenderId), - OffenderLoss = row.OffenderLoss, + LostStaked = row.LostStaked, + LostUnstaked = row.LostUnstaked, + LostExternalStaked = row.LostExternalStaked, + LostExternalUnstaked = row.LostExternalUnstaked, + RoundingLoss = row.RoundingLoss, Quote = Quotes.Get(quote, row.Level) }); } public async Task> GetDoubleBakings(Block block, Symbols quote) { - var sql = @" + var sql = """ SELECT * - FROM ""DoubleBakingOps"" - WHERE ""Level"" = @level - ORDER BY ""Id"""; + FROM "DoubleBakingOps" + WHERE "Level" = @level + ORDER BY "Id" + """; using var db = GetConnection(); var rows = await db.QueryAsync(sql, new { level = block.Level }); @@ -69,10 +72,15 @@ public async Task> GetDoubleBakings(Block blo Timestamp = row.Timestamp, Hash = row.OpHash, AccusedLevel = row.AccusedLevel, + SlashedLevel = row.SlashedLevel, Accuser = Accounts.GetAlias(row.AccuserId), - AccuserReward = row.AccuserReward, + Reward = row.Reward, Offender = Accounts.GetAlias(row.OffenderId), - OffenderLoss = row.OffenderLoss, + LostStaked = row.LostStaked, + LostUnstaked = row.LostUnstaked, + LostExternalStaked = row.LostExternalStaked, + LostExternalUnstaked = row.LostExternalUnstaked, + RoundingLoss = row.RoundingLoss, Quote = Quotes.Get(quote, block.Level) }); } @@ -88,7 +96,12 @@ public async Task> GetDoubleBakings( int limit, Symbols quote) { - var sql = new SqlBuilder(@"SELECT o.*, b.""Hash"" FROM ""DoubleBakingOps"" AS o INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level""") + var sql = new SqlBuilder(""" + SELECT o.*, b."Hash" + FROM "DoubleBakingOps" AS o + INNER JOIN "Blocks" as b + ON b."Level" = o."Level" + """) .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") @@ -98,8 +111,11 @@ public async Task> GetDoubleBakings( { "level" => ("Level", "Level"), "accusedLevel" => ("AccusedLevel", "AccusedLevel"), - "accuserReward" => ("AccuserReward", "AccuserReward"), - "offenderLoss" => ("OffenderLoss", "OffenderLoss"), + "slashedLevel" => ("SlashedLevel", "SlashedLevel"), + #region deprecated + "accuserReward" => ("Reward", "Reward"), + "offenderLoss" => ("LostStaked", "LostStaked"), + #endregion _ => ("Id", "Id") }, "o"); @@ -114,10 +130,15 @@ public async Task> GetDoubleBakings( Timestamp = row.Timestamp, Hash = row.OpHash, AccusedLevel = row.AccusedLevel, + SlashedLevel = row.SlashedLevel, Accuser = Accounts.GetAlias(row.AccuserId), - AccuserReward = row.AccuserReward, + Reward = row.Reward, Offender = Accounts.GetAlias(row.OffenderId), - OffenderLoss = row.OffenderLoss, + LostStaked = row.LostStaked, + LostUnstaked = row.LostUnstaked, + LostExternalStaked = row.LostExternalStaked, + LostExternalUnstaked = row.LostExternalUnstaked, + RoundingLoss = row.RoundingLoss, Quote = Quotes.Get(quote, row.Level) }); } @@ -146,15 +167,32 @@ public async Task GetDoubleBakings( case "timestamp": columns.Add(@"o.""Timestamp"""); break; case "hash": columns.Add(@"o.""OpHash"""); break; case "accusedLevel": columns.Add(@"o.""AccusedLevel"""); break; + case "slashedLevel": columns.Add(@"o.""SlashedLevel"""); break; case "accuser": columns.Add(@"o.""AccuserId"""); break; - case "accuserReward": columns.Add(@"o.""AccuserReward"""); break; + case "reward": columns.Add(@"o.""Reward"""); break; case "offender": columns.Add(@"o.""OffenderId"""); break; - case "offenderLoss": columns.Add(@"o.""OffenderLoss"""); break; + case "lostStaked": columns.Add(@"o.""LostStaked"""); break; + case "lostUnstaked": columns.Add(@"o.""LostUnstaked"""); break; + case "lostExternalStaked": columns.Add(@"o.""LostExternalStaked"""); break; + case "lostExternalUnstaked": columns.Add(@"o.""LostExternalUnstaked"""); break; + case "roundingLoss": columns.Add(@"o.""RoundingLoss"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "accuserReward": + columns.Add(@"o.""Reward"""); + break; + case "offenderLoss": + columns.Add(@"o.""LostStaked"""); + columns.Add(@"o.""LostUnstaked"""); + columns.Add(@"o.""LostExternalStaked"""); + columns.Add(@"o.""LostExternalUnstaked"""); + columns.Add(@"o.""RoundingLoss"""); + break; + #endregion } } @@ -171,8 +209,11 @@ public async Task GetDoubleBakings( { "level" => ("Level", "Level"), "accusedLevel" => ("AccusedLevel", "AccusedLevel"), - "accuserReward" => ("AccuserReward", "AccuserReward"), - "offenderLoss" => ("OffenderLoss", "OffenderLoss"), + "slashedLevel" => ("SlashedLevel", "SlashedLevel"), + #region deprecated + "accuserReward" => ("Reward", "Reward"), + "offenderLoss" => ("LostStaked", "LostStaked"), + #endregion _ => ("Id", "Id") }, "o"); @@ -211,26 +252,56 @@ public async Task GetDoubleBakings( foreach (var row in rows) result[j++][i] = row.AccusedLevel; break; + case "slashedLevel": + foreach (var row in rows) + result[j++][i] = row.SlashedLevel; + break; case "accuser": foreach (var row in rows) result[j++][i] = await Accounts.GetAliasAsync(row.AccuserId); break; - case "accuserReward": + case "reward": foreach (var row in rows) - result[j++][i] = row.AccuserReward; + result[j++][i] = row.Reward; break; case "offender": foreach (var row in rows) result[j++][i] = await Accounts.GetAliasAsync(row.OffenderId); break; - case "offenderLoss": + case "lostStaked": + foreach (var row in rows) + result[j++][i] = row.LostStaked; + break; + case "lostUnstaked": + foreach (var row in rows) + result[j++][i] = row.LostUnstaked; + break; + case "lostExternalStaked": + foreach (var row in rows) + result[j++][i] = row.LostExternalStaked; + break; + case "lostExternalUnstaked": foreach (var row in rows) - result[j++][i] = row.OffenderLoss; + result[j++][i] = row.LostExternalUnstaked; + break; + case "roundingLoss": + foreach (var row in rows) + result[j++][i] = row.RoundingLoss; break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "accuserReward": + foreach (var row in rows) + result[j++][i] = row.Reward; + break; + case "offenderLoss": + foreach (var row in rows) + result[j++][i] = row.LostStaked + row.LostUnstaked + row.LostExternalStaked + row.LostExternalUnstaked + row.RoundingLoss; + break; + #endregion } } @@ -259,15 +330,32 @@ public async Task GetDoubleBakings( case "timestamp": columns.Add(@"o.""Timestamp"""); break; case "hash": columns.Add(@"o.""OpHash"""); break; case "accusedLevel": columns.Add(@"o.""AccusedLevel"""); break; + case "slashedLevel": columns.Add(@"o.""SlashedLevel"""); break; case "accuser": columns.Add(@"o.""AccuserId"""); break; - case "accuserReward": columns.Add(@"o.""AccuserReward"""); break; + case "reward": columns.Add(@"o.""Reward"""); break; case "offender": columns.Add(@"o.""OffenderId"""); break; - case "offenderLoss": columns.Add(@"o.""OffenderLoss"""); break; + case "lostStaked": columns.Add(@"o.""LostStaked"""); break; + case "lostUnstaked": columns.Add(@"o.""LostUnstaked"""); break; + case "lostExternalStaked": columns.Add(@"o.""LostExternalStaked"""); break; + case "lostExternalUnstaked": columns.Add(@"o.""LostExternalUnstaked"""); break; + case "roundingLoss": columns.Add(@"o.""RoundingLoss"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "accuserReward": + columns.Add(@"o.""Reward"""); + break; + case "offenderLoss": + columns.Add(@"o.""LostStaked"""); + columns.Add(@"o.""LostUnstaked"""); + columns.Add(@"o.""LostExternalStaked"""); + columns.Add(@"o.""LostExternalUnstaked"""); + columns.Add(@"o.""RoundingLoss"""); + break; + #endregion } if (columns.Count == 0) @@ -283,8 +371,11 @@ public async Task GetDoubleBakings( { "level" => ("Level", "Level"), "accusedLevel" => ("AccusedLevel", "AccusedLevel"), - "accuserReward" => ("AccuserReward", "AccuserReward"), - "offenderLoss" => ("OffenderLoss", "OffenderLoss"), + "slashedLevel" => ("SlashedLevel", "SlashedLevel"), + #region deprecated + "accuserReward" => ("Reward", "Reward"), + "offenderLoss" => ("LostStaked", "LostStaked"), + #endregion _ => ("Id", "Id") }, "o"); @@ -321,26 +412,56 @@ public async Task GetDoubleBakings( foreach (var row in rows) result[j++] = row.AccusedLevel; break; + case "slashedLevel": + foreach (var row in rows) + result[j++] = row.SlashedLevel; + break; case "accuser": foreach (var row in rows) result[j++] = await Accounts.GetAliasAsync(row.AccuserId); break; - case "accuserReward": + case "reward": foreach (var row in rows) - result[j++] = row.AccuserReward; + result[j++] = row.Reward; break; case "offender": foreach (var row in rows) result[j++] = await Accounts.GetAliasAsync(row.OffenderId); break; - case "offenderLoss": + case "lostStaked": + foreach (var row in rows) + result[j++] = row.LostStaked; + break; + case "lostUnstaked": + foreach (var row in rows) + result[j++] = row.LostUnstaked; + break; + case "lostExternalStaked": + foreach (var row in rows) + result[j++] = row.LostExternalStaked; + break; + case "lostExternalUnstaked": foreach (var row in rows) - result[j++] = row.OffenderLoss; + result[j++] = row.LostExternalUnstaked; + break; + case "roundingLoss": + foreach (var row in rows) + result[j++] = row.RoundingLoss; break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "accuserReward": + foreach (var row in rows) + result[j++] = row.Reward; + break; + case "offenderLoss": + foreach (var row in rows) + result[j++] = row.LostStaked + row.LostUnstaked + row.LostExternalStaked + row.LostExternalUnstaked + row.RoundingLoss; + break; + #endregion } return result; diff --git a/Tzkt.Api/Repositories/OperationRepository.DoubleEndorsing.cs b/Tzkt.Api/Repositories/OperationRepository.DoubleEndorsing.cs index f865ed090..25b2076db 100644 --- a/Tzkt.Api/Repositories/OperationRepository.DoubleEndorsing.cs +++ b/Tzkt.Api/Repositories/OperationRepository.DoubleEndorsing.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Dapper; +using Dapper; using Tzkt.Api.Models; namespace Tzkt.Api.Repositories @@ -14,8 +10,8 @@ public async Task GetDoubleEndorsingsCount( DateTimeParameter timestamp) { var sql = new SqlBuilder(@"SELECT COUNT(*) FROM ""DoubleEndorsingOps""") - .Filter(@"Level", level) - .Filter(@"Timestamp", timestamp); + .Filter("Level", level) + .Filter("Timestamp", timestamp); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); @@ -23,13 +19,14 @@ public async Task GetDoubleEndorsingsCount( public async Task> GetDoubleEndorsings(string hash, Symbols quote) { - var sql = @" - SELECT o.*, b.""Hash"" - FROM ""DoubleEndorsingOps"" as o - INNER JOIN ""Blocks"" as b - ON b.""Level"" = o.""Level"" - WHERE o.""OpHash"" = @hash::character(51) - LIMIT 1"; + var sql = """ + SELECT o.*, b."Hash" + FROM "DoubleEndorsingOps" as o + INNER JOIN "Blocks" as b + ON b."Level" = o."Level" + WHERE o."OpHash" = @hash::character(51) + LIMIT 1 + """; using var db = GetConnection(); var rows = await db.QueryAsync(sql, new { hash }); @@ -42,21 +39,27 @@ INNER JOIN ""Blocks"" as b Timestamp = row.Timestamp, Hash = hash, AccusedLevel = row.AccusedLevel, + SlashedLevel = row.SlashedLevel, Accuser = Accounts.GetAlias(row.AccuserId), - AccuserReward = row.AccuserReward, + Reward = row.Reward, Offender = Accounts.GetAlias(row.OffenderId), - OffenderLoss = row.OffenderLoss, + LostStaked = row.LostStaked, + LostUnstaked = row.LostUnstaked, + LostExternalStaked = row.LostExternalStaked, + LostExternalUnstaked = row.LostExternalUnstaked, + RoundingLoss = row.RoundingLoss, Quote = Quotes.Get(quote, row.Level) }); } public async Task> GetDoubleEndorsings(Block block, Symbols quote) { - var sql = @" + var sql = """ SELECT * - FROM ""DoubleEndorsingOps"" - WHERE ""Level"" = @level - ORDER BY ""Id"""; + FROM "DoubleEndorsingOps" + WHERE "Level" = @level + ORDER BY "Id" + """; using var db = GetConnection(); var rows = await db.QueryAsync(sql, new { level = block.Level }); @@ -69,10 +72,15 @@ public async Task> GetDoubleEndorsings(Blo Timestamp = row.Timestamp, Hash = row.OpHash, AccusedLevel = row.AccusedLevel, + SlashedLevel = row.SlashedLevel, Accuser = Accounts.GetAlias(row.AccuserId), - AccuserReward = row.AccuserReward, + Reward = row.Reward, Offender = Accounts.GetAlias(row.OffenderId), - OffenderLoss = row.OffenderLoss, + LostStaked = row.LostStaked, + LostUnstaked = row.LostUnstaked, + LostExternalStaked = row.LostExternalStaked, + LostExternalUnstaked = row.LostExternalUnstaked, + RoundingLoss = row.RoundingLoss, Quote = Quotes.Get(quote, block.Level) }); } @@ -88,7 +96,12 @@ public async Task> GetDoubleEndorsings( int limit, Symbols quote) { - var sql = new SqlBuilder(@"SELECT o.*, b.""Hash"" FROM ""DoubleEndorsingOps"" AS o INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level""") + var sql = new SqlBuilder(""" + SELECT o.*, b."Hash" + FROM "DoubleEndorsingOps" AS o + INNER JOIN "Blocks" as b + ON b."Level" = o."Level" + """) .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") @@ -98,8 +111,11 @@ public async Task> GetDoubleEndorsings( { "level" => ("Level", "Level"), "accusedLevel" => ("AccusedLevel", "AccusedLevel"), - "accuserReward" => ("AccuserReward", "AccuserReward"), - "offenderLoss" => ("OffenderLoss", "OffenderLoss"), + "slashedLevel" => ("SlashedLevel", "SlashedLevel"), + #region deprecated + "accuserReward" => ("Reward", "Reward"), + "offenderLoss" => ("LostStaked", "LostStaked"), + #endregion _ => ("Id", "Id") }, "o"); @@ -114,10 +130,15 @@ public async Task> GetDoubleEndorsings( Timestamp = row.Timestamp, Hash = row.OpHash, AccusedLevel = row.AccusedLevel, + SlashedLevel = row.SlashedLevel, Accuser = Accounts.GetAlias(row.AccuserId), - AccuserReward = row.AccuserReward, + Reward = row.Reward, Offender = Accounts.GetAlias(row.OffenderId), - OffenderLoss = row.OffenderLoss, + LostStaked = row.LostStaked, + LostUnstaked = row.LostUnstaked, + LostExternalStaked = row.LostExternalStaked, + LostExternalUnstaked = row.LostExternalUnstaked, + RoundingLoss = row.RoundingLoss, Quote = Quotes.Get(quote, row.Level) }); } @@ -146,15 +167,32 @@ public async Task GetDoubleEndorsings( case "timestamp": columns.Add(@"o.""Timestamp"""); break; case "hash": columns.Add(@"o.""OpHash"""); break; case "accusedLevel": columns.Add(@"o.""AccusedLevel"""); break; + case "slashedLevel": columns.Add(@"o.""SlashedLevel"""); break; case "accuser": columns.Add(@"o.""AccuserId"""); break; - case "accuserReward": columns.Add(@"o.""AccuserReward"""); break; + case "reward": columns.Add(@"o.""Reward"""); break; case "offender": columns.Add(@"o.""OffenderId"""); break; - case "offenderLoss": columns.Add(@"o.""OffenderLoss"""); break; + case "lostStaked": columns.Add(@"o.""LostStaked"""); break; + case "lostUnstaked": columns.Add(@"o.""LostUnstaked"""); break; + case "lostExternalStaked": columns.Add(@"o.""LostExternalStaked"""); break; + case "lostExternalUnstaked": columns.Add(@"o.""LostExternalUnstaked"""); break; + case "roundingLoss": columns.Add(@"o.""RoundingLoss"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "accuserReward": + columns.Add(@"o.""Reward"""); + break; + case "offenderLoss": + columns.Add(@"o.""LostStaked"""); + columns.Add(@"o.""LostUnstaked"""); + columns.Add(@"o.""LostExternalStaked"""); + columns.Add(@"o.""LostExternalUnstaked"""); + columns.Add(@"o.""RoundingLoss"""); + break; + #endregion } } @@ -171,8 +209,11 @@ public async Task GetDoubleEndorsings( { "level" => ("Level", "Level"), "accusedLevel" => ("AccusedLevel", "AccusedLevel"), - "accuserReward" => ("AccuserReward", "AccuserReward"), - "offenderLoss" => ("OffenderLoss", "OffenderLoss"), + "slashedLevel" => ("SlashedLevel", "SlashedLevel"), + #region deprecated + "accuserReward" => ("Reward", "Reward"), + "offenderLoss" => ("LostStaked", "LostStaked"), + #endregion _ => ("Id", "Id") }, "o"); @@ -211,26 +252,56 @@ public async Task GetDoubleEndorsings( foreach (var row in rows) result[j++][i] = row.AccusedLevel; break; + case "slashedLevel": + foreach (var row in rows) + result[j++][i] = row.SlashedLevel; + break; case "accuser": foreach (var row in rows) result[j++][i] = await Accounts.GetAliasAsync(row.AccuserId); break; - case "accuserReward": + case "reward": foreach (var row in rows) - result[j++][i] = row.AccuserReward; + result[j++][i] = row.Reward; break; case "offender": foreach (var row in rows) result[j++][i] = await Accounts.GetAliasAsync(row.OffenderId); break; - case "offenderLoss": + case "lostStaked": + foreach (var row in rows) + result[j++][i] = row.LostStaked; + break; + case "lostUnstaked": + foreach (var row in rows) + result[j++][i] = row.LostUnstaked; + break; + case "lostExternalStaked": + foreach (var row in rows) + result[j++][i] = row.LostExternalStaked; + break; + case "lostExternalUnstaked": foreach (var row in rows) - result[j++][i] = row.OffenderLoss; + result[j++][i] = row.LostExternalUnstaked; + break; + case "roundingLoss": + foreach (var row in rows) + result[j++][i] = row.RoundingLoss; break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "accuserReward": + foreach (var row in rows) + result[j++][i] = row.Reward; + break; + case "offenderLoss": + foreach (var row in rows) + result[j++][i] = row.LostStaked + row.LostUnstaked + row.LostExternalStaked + row.LostExternalUnstaked + row.RoundingLoss; + break; + #endregion } } @@ -259,15 +330,32 @@ public async Task GetDoubleEndorsings( case "timestamp": columns.Add(@"o.""Timestamp"""); break; case "hash": columns.Add(@"o.""OpHash"""); break; case "accusedLevel": columns.Add(@"o.""AccusedLevel"""); break; + case "slashedLevel": columns.Add(@"o.""SlashedLevel"""); break; case "accuser": columns.Add(@"o.""AccuserId"""); break; - case "accuserReward": columns.Add(@"o.""AccuserReward"""); break; + case "reward": columns.Add(@"o.""Reward"""); break; case "offender": columns.Add(@"o.""OffenderId"""); break; - case "offenderLoss": columns.Add(@"o.""OffenderLoss"""); break; + case "lostStaked": columns.Add(@"o.""LostStaked"""); break; + case "lostUnstaked": columns.Add(@"o.""LostUnstaked"""); break; + case "lostExternalStaked": columns.Add(@"o.""LostExternalStaked"""); break; + case "lostExternalUnstaked": columns.Add(@"o.""LostExternalUnstaked"""); break; + case "roundingLoss": columns.Add(@"o.""RoundingLoss"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "accuserReward": + columns.Add(@"o.""Reward"""); + break; + case "offenderLoss": + columns.Add(@"o.""LostStaked"""); + columns.Add(@"o.""LostUnstaked"""); + columns.Add(@"o.""LostExternalStaked"""); + columns.Add(@"o.""LostExternalUnstaked"""); + columns.Add(@"o.""RoundingLoss"""); + break; + #endregion } if (columns.Count == 0) @@ -283,8 +371,11 @@ public async Task GetDoubleEndorsings( { "level" => ("Level", "Level"), "accusedLevel" => ("AccusedLevel", "AccusedLevel"), - "accuserReward" => ("AccuserReward", "AccuserReward"), - "offenderLoss" => ("OffenderLoss", "OffenderLoss"), + "slashedLevel" => ("SlashedLevel", "SlashedLevel"), + #region deprecated + "accuserReward" => ("Reward", "Reward"), + "offenderLoss" => ("LostStaked", "LostStaked"), + #endregion _ => ("Id", "Id") }, "o"); @@ -321,26 +412,56 @@ public async Task GetDoubleEndorsings( foreach (var row in rows) result[j++] = row.AccusedLevel; break; + case "slashedLevel": + foreach (var row in rows) + result[j++] = row.SlashedLevel; + break; case "accuser": foreach (var row in rows) result[j++] = await Accounts.GetAliasAsync(row.AccuserId); break; - case "accuserReward": + case "reward": foreach (var row in rows) - result[j++] = row.AccuserReward; + result[j++] = row.Reward; break; case "offender": foreach (var row in rows) result[j++] = await Accounts.GetAliasAsync(row.OffenderId); break; - case "offenderLoss": + case "lostStaked": + foreach (var row in rows) + result[j++] = row.LostStaked; + break; + case "lostUnstaked": + foreach (var row in rows) + result[j++] = row.LostUnstaked; + break; + case "lostExternalStaked": + foreach (var row in rows) + result[j++] = row.LostExternalStaked; + break; + case "lostExternalUnstaked": foreach (var row in rows) - result[j++] = row.OffenderLoss; + result[j++] = row.LostExternalUnstaked; + break; + case "roundingLoss": + foreach (var row in rows) + result[j++] = row.RoundingLoss; break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "accuserReward": + foreach (var row in rows) + result[j++] = row.Reward; + break; + case "offenderLoss": + foreach (var row in rows) + result[j++] = row.LostStaked + row.LostUnstaked + row.LostExternalStaked + row.LostExternalUnstaked + row.RoundingLoss; + break; + #endregion } return result; diff --git a/Tzkt.Api/Repositories/OperationRepository.DoublePreendorsing.cs b/Tzkt.Api/Repositories/OperationRepository.DoublePreendorsing.cs index 99633b5c6..636783977 100644 --- a/Tzkt.Api/Repositories/OperationRepository.DoublePreendorsing.cs +++ b/Tzkt.Api/Repositories/OperationRepository.DoublePreendorsing.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Dapper; +using Dapper; using Tzkt.Api.Models; namespace Tzkt.Api.Repositories @@ -14,8 +10,8 @@ public async Task GetDoublePreendorsingsCount( DateTimeParameter timestamp) { var sql = new SqlBuilder(@"SELECT COUNT(*) FROM ""DoublePreendorsingOps""") - .Filter(@"Level", level) - .Filter(@"Timestamp", timestamp); + .Filter("Level", level) + .Filter("Timestamp", timestamp); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); @@ -23,13 +19,14 @@ public async Task GetDoublePreendorsingsCount( public async Task> GetDoublePreendorsings(string hash, Symbols quote) { - var sql = @" - SELECT o.*, b.""Hash"" - FROM ""DoublePreendorsingOps"" as o - INNER JOIN ""Blocks"" as b - ON b.""Level"" = o.""Level"" - WHERE o.""OpHash"" = @hash::character(51) - LIMIT 1"; + var sql = """ + SELECT o.*, b."Hash" + FROM "DoublePreendorsingOps" as o + INNER JOIN "Blocks" as b + ON b."Level" = o."Level" + WHERE o."OpHash" = @hash::character(51) + LIMIT 1 + """; using var db = GetConnection(); var rows = await db.QueryAsync(sql, new { hash }); @@ -42,21 +39,27 @@ INNER JOIN ""Blocks"" as b Timestamp = row.Timestamp, Hash = hash, AccusedLevel = row.AccusedLevel, + SlashedLevel = row.SlashedLevel, Accuser = Accounts.GetAlias(row.AccuserId), - AccuserReward = row.AccuserReward, + Reward = row.Reward, Offender = Accounts.GetAlias(row.OffenderId), - OffenderLoss = row.OffenderLoss, + LostStaked = row.LostStaked, + LostUnstaked = row.LostUnstaked, + LostExternalStaked = row.LostExternalStaked, + LostExternalUnstaked = row.LostExternalUnstaked, + RoundingLoss = row.RoundingLoss, Quote = Quotes.Get(quote, row.Level) }); } public async Task> GetDoublePreendorsings(Block block, Symbols quote) { - var sql = @" + var sql = """ SELECT * - FROM ""DoublePreendorsingOps"" - WHERE ""Level"" = @level - ORDER BY ""Id"""; + FROM "DoublePreendorsingOps" + WHERE "Level" = @level + ORDER BY "Id" + """; using var db = GetConnection(); var rows = await db.QueryAsync(sql, new { level = block.Level }); @@ -69,10 +72,15 @@ public async Task> GetDoublePreendorsin Timestamp = row.Timestamp, Hash = row.OpHash, AccusedLevel = row.AccusedLevel, + SlashedLevel = row.SlashedLevel, Accuser = Accounts.GetAlias(row.AccuserId), - AccuserReward = row.AccuserReward, + Reward = row.Reward, Offender = Accounts.GetAlias(row.OffenderId), - OffenderLoss = row.OffenderLoss, + LostStaked = row.LostStaked, + LostUnstaked = row.LostUnstaked, + LostExternalStaked = row.LostExternalStaked, + LostExternalUnstaked = row.LostExternalUnstaked, + RoundingLoss = row.RoundingLoss, Quote = Quotes.Get(quote, block.Level) }); } @@ -88,7 +96,12 @@ public async Task> GetDoublePreendorsin int limit, Symbols quote) { - var sql = new SqlBuilder(@"SELECT o.*, b.""Hash"" FROM ""DoublePreendorsingOps"" AS o INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level""") + var sql = new SqlBuilder(""" + SELECT o.*, b."Hash" + FROM "DoublePreendorsingOps" AS o + INNER JOIN "Blocks" as b + ON b."Level" = o."Level" + """) .Filter(anyof, x => x == "accuser" ? "AccuserId" : "OffenderId") .Filter("AccuserId", accuser, x => "OffenderId") .Filter("OffenderId", offender, x => "AccuserId") @@ -98,8 +111,11 @@ public async Task> GetDoublePreendorsin { "level" => ("Level", "Level"), "accusedLevel" => ("AccusedLevel", "AccusedLevel"), - "accuserReward" => ("AccuserReward", "AccuserReward"), - "offenderLoss" => ("OffenderLoss", "OffenderLoss"), + "slashedLevel" => ("SlashedLevel", "SlashedLevel"), + #region deprecated + "accuserReward" => ("Reward", "Reward"), + "offenderLoss" => ("LostStaked", "LostStaked"), + #endregion _ => ("Id", "Id") }, "o"); @@ -114,10 +130,15 @@ public async Task> GetDoublePreendorsin Timestamp = row.Timestamp, Hash = row.OpHash, AccusedLevel = row.AccusedLevel, + SlashedLevel = row.SlashedLevel, Accuser = Accounts.GetAlias(row.AccuserId), - AccuserReward = row.AccuserReward, + Reward = row.Reward, Offender = Accounts.GetAlias(row.OffenderId), - OffenderLoss = row.OffenderLoss, + LostStaked = row.LostStaked, + LostUnstaked = row.LostUnstaked, + LostExternalStaked = row.LostExternalStaked, + LostExternalUnstaked = row.LostExternalUnstaked, + RoundingLoss = row.RoundingLoss, Quote = Quotes.Get(quote, row.Level) }); } @@ -146,15 +167,32 @@ public async Task GetDoublePreendorsings( case "timestamp": columns.Add(@"o.""Timestamp"""); break; case "hash": columns.Add(@"o.""OpHash"""); break; case "accusedLevel": columns.Add(@"o.""AccusedLevel"""); break; + case "slashedLevel": columns.Add(@"o.""SlashedLevel"""); break; case "accuser": columns.Add(@"o.""AccuserId"""); break; - case "accuserReward": columns.Add(@"o.""AccuserReward"""); break; + case "reward": columns.Add(@"o.""Reward"""); break; case "offender": columns.Add(@"o.""OffenderId"""); break; - case "offenderLoss": columns.Add(@"o.""OffenderLoss"""); break; + case "lostStaked": columns.Add(@"o.""LostStaked"""); break; + case "lostUnstaked": columns.Add(@"o.""LostUnstaked"""); break; + case "lostExternalStaked": columns.Add(@"o.""LostExternalStaked"""); break; + case "lostExternalUnstaked": columns.Add(@"o.""LostExternalUnstaked"""); break; + case "roundingLoss": columns.Add(@"o.""RoundingLoss"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "accuserReward": + columns.Add(@"o.""Reward"""); + break; + case "offenderLoss": + columns.Add(@"o.""LostStaked"""); + columns.Add(@"o.""LostUnstaked"""); + columns.Add(@"o.""LostExternalStaked"""); + columns.Add(@"o.""LostExternalUnstaked"""); + columns.Add(@"o.""RoundingLoss"""); + break; + #endregion } } @@ -171,8 +209,11 @@ public async Task GetDoublePreendorsings( { "level" => ("Level", "Level"), "accusedLevel" => ("AccusedLevel", "AccusedLevel"), - "accuserReward" => ("AccuserReward", "AccuserReward"), - "offenderLoss" => ("OffenderLoss", "OffenderLoss"), + "slashedLevel" => ("SlashedLevel", "SlashedLevel"), + #region deprecated + "accuserReward" => ("Reward", "Reward"), + "offenderLoss" => ("LostStaked", "LostStaked"), + #endregion _ => ("Id", "Id") }, "o"); @@ -211,26 +252,56 @@ public async Task GetDoublePreendorsings( foreach (var row in rows) result[j++][i] = row.AccusedLevel; break; + case "slashedLevel": + foreach (var row in rows) + result[j++][i] = row.SlashedLevel; + break; case "accuser": foreach (var row in rows) result[j++][i] = await Accounts.GetAliasAsync(row.AccuserId); break; - case "accuserReward": + case "reward": foreach (var row in rows) - result[j++][i] = row.AccuserReward; + result[j++][i] = row.Reward; break; case "offender": foreach (var row in rows) result[j++][i] = await Accounts.GetAliasAsync(row.OffenderId); break; - case "offenderLoss": + case "lostStaked": + foreach (var row in rows) + result[j++][i] = row.LostStaked; + break; + case "lostUnstaked": + foreach (var row in rows) + result[j++][i] = row.LostUnstaked; + break; + case "lostExternalStaked": + foreach (var row in rows) + result[j++][i] = row.LostExternalStaked; + break; + case "lostExternalUnstaked": foreach (var row in rows) - result[j++][i] = row.OffenderLoss; + result[j++][i] = row.LostExternalUnstaked; + break; + case "roundingLoss": + foreach (var row in rows) + result[j++][i] = row.RoundingLoss; break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "accuserReward": + foreach (var row in rows) + result[j++][i] = row.Reward; + break; + case "offenderLoss": + foreach (var row in rows) + result[j++][i] = row.LostStaked + row.LostUnstaked + row.LostExternalStaked + row.LostExternalUnstaked + row.RoundingLoss; + break; + #endregion } } @@ -259,15 +330,32 @@ public async Task GetDoublePreendorsings( case "timestamp": columns.Add(@"o.""Timestamp"""); break; case "hash": columns.Add(@"o.""OpHash"""); break; case "accusedLevel": columns.Add(@"o.""AccusedLevel"""); break; + case "slashedLevel": columns.Add(@"o.""SlashedLevel"""); break; case "accuser": columns.Add(@"o.""AccuserId"""); break; - case "accuserReward": columns.Add(@"o.""AccuserReward"""); break; + case "reward": columns.Add(@"o.""Reward"""); break; case "offender": columns.Add(@"o.""OffenderId"""); break; - case "offenderLoss": columns.Add(@"o.""OffenderLoss"""); break; + case "lostStaked": columns.Add(@"o.""LostStaked"""); break; + case "lostUnstaked": columns.Add(@"o.""LostUnstaked"""); break; + case "lostExternalStaked": columns.Add(@"o.""LostExternalStaked"""); break; + case "lostExternalUnstaked": columns.Add(@"o.""LostExternalUnstaked"""); break; + case "roundingLoss": columns.Add(@"o.""RoundingLoss"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "accuserReward": + columns.Add(@"o.""Reward"""); + break; + case "offenderLoss": + columns.Add(@"o.""LostStaked"""); + columns.Add(@"o.""LostUnstaked"""); + columns.Add(@"o.""LostExternalStaked"""); + columns.Add(@"o.""LostExternalUnstaked"""); + columns.Add(@"o.""RoundingLoss"""); + break; + #endregion } if (columns.Count == 0) @@ -283,8 +371,11 @@ public async Task GetDoublePreendorsings( { "level" => ("Level", "Level"), "accusedLevel" => ("AccusedLevel", "AccusedLevel"), - "accuserReward" => ("AccuserReward", "AccuserReward"), - "offenderLoss" => ("OffenderLoss", "OffenderLoss"), + "slashedLevel" => ("SlashedLevel", "SlashedLevel"), + #region deprecated + "accuserReward" => ("Reward", "Reward"), + "offenderLoss" => ("LostStaked", "LostStaked"), + #endregion _ => ("Id", "Id") }, "o"); @@ -321,26 +412,56 @@ public async Task GetDoublePreendorsings( foreach (var row in rows) result[j++] = row.AccusedLevel; break; + case "slashedLevel": + foreach (var row in rows) + result[j++] = row.SlashedLevel; + break; case "accuser": foreach (var row in rows) result[j++] = await Accounts.GetAliasAsync(row.AccuserId); break; - case "accuserReward": + case "reward": foreach (var row in rows) - result[j++] = row.AccuserReward; + result[j++] = row.Reward; break; case "offender": foreach (var row in rows) result[j++] = await Accounts.GetAliasAsync(row.OffenderId); break; - case "offenderLoss": + case "lostStaked": + foreach (var row in rows) + result[j++] = row.LostStaked; + break; + case "lostUnstaked": + foreach (var row in rows) + result[j++] = row.LostUnstaked; + break; + case "lostExternalStaked": + foreach (var row in rows) + result[j++] = row.LostExternalStaked; + break; + case "lostExternalUnstaked": foreach (var row in rows) - result[j++] = row.OffenderLoss; + result[j++] = row.LostExternalUnstaked; + break; + case "roundingLoss": + foreach (var row in rows) + result[j++] = row.RoundingLoss; break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "accuserReward": + foreach (var row in rows) + result[j++] = row.Reward; + break; + case "offenderLoss": + foreach (var row in rows) + result[j++] = row.LostStaked + row.LostUnstaked + row.LostExternalStaked + row.LostExternalUnstaked + row.RoundingLoss; + break; + #endregion } return result; diff --git a/Tzkt.Api/Repositories/OperationRepository.EndorsingRewards.cs b/Tzkt.Api/Repositories/OperationRepository.EndorsingRewards.cs index ec18330ea..d170d9be6 100644 --- a/Tzkt.Api/Repositories/OperationRepository.EndorsingRewards.cs +++ b/Tzkt.Api/Repositories/OperationRepository.EndorsingRewards.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Dapper; +using Dapper; using Tzkt.Api.Models; namespace Tzkt.Api.Repositories @@ -43,7 +39,9 @@ INNER JOIN ""Blocks"" as b Timestamp = row.Timestamp, Baker = Accounts.GetAlias(row.BakerId), Expected = row.Expected, - Received = row.Received, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, Quote = Quotes.Get(quote, row.Level) }; } @@ -76,7 +74,9 @@ public async Task> GetEndorsingRewards( Timestamp = row.Timestamp, Baker = Accounts.GetAlias(row.BakerId), Expected = row.Expected, - Received = row.Received, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, Quote = Quotes.Get(quote, row.Level) }); } @@ -104,12 +104,21 @@ public async Task GetEndorsingRewards( case "timestamp": columns.Add(@"o.""Timestamp"""); break; case "baker": columns.Add(@"o.""BakerId"""); break; case "expected": columns.Add(@"o.""Expected"""); break; - case "received": columns.Add(@"o.""Received"""); break; + case "rewardLiquid": columns.Add(@"o.""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"o.""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"o.""RewardStakedShared"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "received": + columns.Add(@"o.""RewardLiquid"""); + columns.Add(@"o.""RewardStakedOwn"""); + columns.Add(@"o.""RewardStakedShared"""); + break; + #endregion } } @@ -158,14 +167,28 @@ public async Task GetEndorsingRewards( foreach (var row in rows) result[j++][i] = row.Expected; break; - case "received": + case "rewardLiquid": + foreach (var row in rows) + result[j++][i] = row.RewardLiquid; + break; + case "rewardStakedOwn": foreach (var row in rows) - result[j++][i] = row.Received; + result[j++][i] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++][i] = row.RewardStakedShared; break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "received": + foreach (var row in rows) + result[j++][i] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + #endregion } } @@ -193,12 +216,21 @@ public async Task GetEndorsingRewards( case "timestamp": columns.Add(@"o.""Timestamp"""); break; case "baker": columns.Add(@"o.""BakerId"""); break; case "expected": columns.Add(@"o.""Expected"""); break; - case "received": columns.Add(@"o.""Received"""); break; + case "rewardLiquid": columns.Add(@"o.""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"o.""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"o.""RewardStakedShared"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "received": + columns.Add(@"o.""RewardLiquid"""); + columns.Add(@"o.""RewardStakedOwn"""); + columns.Add(@"o.""RewardStakedShared"""); + break; + #endregion } if (columns.Count == 0) @@ -244,14 +276,28 @@ public async Task GetEndorsingRewards( foreach (var row in rows) result[j++] = row.Expected; break; - case "received": + case "rewardLiquid": + foreach (var row in rows) + result[j++] = row.RewardLiquid; + break; + case "rewardStakedOwn": foreach (var row in rows) - result[j++] = row.Received; + result[j++] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++] = row.RewardStakedShared; break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "received": + foreach (var row in rows) + result[j++] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + #endregion } return result; diff --git a/Tzkt.Api/Repositories/OperationRepository.NonceRevelations.cs b/Tzkt.Api/Repositories/OperationRepository.NonceRevelations.cs index a10b18416..5ec23e638 100644 --- a/Tzkt.Api/Repositories/OperationRepository.NonceRevelations.cs +++ b/Tzkt.Api/Repositories/OperationRepository.NonceRevelations.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Dapper; +using Dapper; using Netezos.Encoding; using Tzkt.Api.Models; @@ -47,7 +43,9 @@ INNER JOIN ""Blocks"" as b RevealedLevel = row.RevealedLevel, RevealedCycle = row.RevealedCycle, Nonce = Hex.Convert(row.Nonce), - Reward = row.Reward, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, Quote = Quotes.Get(quote, row.Level) }); } @@ -75,7 +73,9 @@ public async Task> GetNonceRevelations(Blo RevealedLevel = row.RevealedLevel, RevealedCycle = row.RevealedCycle, Nonce = Hex.Convert(row.Nonce), - Reward = row.Reward, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, Quote = Quotes.Get(quote, block.Level) }); } @@ -121,7 +121,9 @@ public async Task> GetNonceRevelations( RevealedLevel = row.RevealedLevel, RevealedCycle = row.RevealedCycle, Nonce = Hex.Convert(row.Nonce), - Reward = row.Reward, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, Quote = Quotes.Get(quote, row.Level) }); } @@ -155,12 +157,21 @@ public async Task GetNonceRevelations( case "revealedLevel": columns.Add(@"o.""RevealedLevel"""); break; case "revealedCycle": columns.Add(@"o.""RevealedCycle"""); break; case "nonce": columns.Add(@"o.""Nonce"""); break; - case "reward": columns.Add(@"o.""Reward"""); break; + case "rewardLiquid": columns.Add(@"o.""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"o.""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"o.""RewardStakedShared"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "reward": + columns.Add(@"o.""RewardLiquid"""); + columns.Add(@"o.""RewardStakedOwn"""); + columns.Add(@"o.""RewardStakedShared"""); + break; + #endregion } } @@ -232,14 +243,28 @@ public async Task GetNonceRevelations( foreach (var row in rows) result[j++][i] = Hex.Convert(row.Nonce); break; - case "reward": + case "rewardLiquid": + foreach (var row in rows) + result[j++][i] = row.RewardLiquid; + break; + case "rewardStakedOwn": foreach (var row in rows) - result[j++][i] = row.Reward; + result[j++][i] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++][i] = row.RewardStakedShared; break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "reward": + foreach (var row in rows) + result[j++][i] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + #endregion } } @@ -273,12 +298,21 @@ public async Task GetNonceRevelations( case "revealedLevel": columns.Add(@"o.""RevealedLevel"""); break; case "revealedCycle": columns.Add(@"o.""RevealedCycle"""); break; case "nonce": columns.Add(@"o.""Nonce"""); break; - case "reward": columns.Add(@"o.""Reward"""); break; + case "rewardLiquid": columns.Add(@"o.""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"o.""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"o.""RewardStakedShared"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "reward": + columns.Add(@"o.""RewardLiquid"""); + columns.Add(@"o.""RewardStakedOwn"""); + columns.Add(@"o.""RewardStakedShared"""); + break; + #endregion } if (columns.Count == 0) @@ -347,14 +381,28 @@ public async Task GetNonceRevelations( foreach (var row in rows) result[j++] = Hex.Convert(row.Nonce); break; - case "reward": + case "rewardLiquid": + foreach (var row in rows) + result[j++] = row.RewardLiquid; + break; + case "rewardStakedOwn": foreach (var row in rows) - result[j++] = row.Reward; + result[j++] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++] = row.RewardStakedShared; break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "reward": + foreach (var row in rows) + result[j++] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + #endregion } return result; diff --git a/Tzkt.Api/Repositories/OperationRepository.SmartRollupOriginateOperation.cs b/Tzkt.Api/Repositories/OperationRepository.SmartRollupOriginateOperation.cs index c7400a1a5..74291382f 100644 --- a/Tzkt.Api/Repositories/OperationRepository.SmartRollupOriginateOperation.cs +++ b/Tzkt.Api/Repositories/OperationRepository.SmartRollupOriginateOperation.cs @@ -55,7 +55,6 @@ async Task> QuerySmartRollupOriginateOps(SrOperationFilter case "status": columns.Add(@"o.""Status"""); break; case "pvmKind": columns.Add(@"o.""PvmKind"""); break; case "kernel": columns.Add(@"o.""Kernel"""); break; - case "originationProof": columns.Add(@"o.""OriginationProof"""); break; case "parameterType": columns.Add(@"o.""ParameterType"""); break; case "genesisCommitment": columns.Add(@"o.""GenesisCommitment"""); break; case "rollup": columns.Add(@"o.""SmartRollupId"""); break; @@ -105,7 +104,6 @@ public async Task> GetSmartRollupOrig Status = OpStatuses.ToString(row.Status), PvmKind = PvmKinds.ToString((int)row.PvmKind), Kernel = row.Kernel, - OriginationProof = row.OriginationProof, ParameterType = row.ParameterType is not byte[] bytes ? null : micheline switch { MichelineFormat.JsonString => Schema.Create(Micheline.FromBytes(bytes) as MichelinePrim).Humanize(), @@ -204,10 +202,6 @@ public async Task GetSmartRollupOriginateOps(SrOperationFilter filte foreach (var row in rows) result[j++][i] = row.Kernel; break; - case "originationProof": - foreach (var row in rows) - result[j++][i] = row.OriginationProof; - break; case "parameterType": foreach (var row in rows) result[j++][i] = row.ParameterType is not byte[] bytes ? null : micheline switch diff --git a/Tzkt.Api/Repositories/OperationRepository.StakingOperation.cs b/Tzkt.Api/Repositories/OperationRepository.StakingOperation.cs new file mode 100644 index 000000000..3b3dc9015 --- /dev/null +++ b/Tzkt.Api/Repositories/OperationRepository.StakingOperation.cs @@ -0,0 +1,243 @@ +using Dapper; +using Tzkt.Api.Models; + +namespace Tzkt.Api.Repositories +{ + public partial class OperationRepository : DbConnection + { + public async Task GetStakingOpsCount(StakingOperationFilter filter) + { + var sql = new SqlBuilder(""" + SELECT COUNT(*) + FROM "StakingOps" as o + """) + .FilterA(@"o.""Id""", filter.id) + .FilterA(@"o.""OpHash""", filter.hash) + .FilterA(@"o.""Counter""", filter.counter) + .FilterA(@"o.""Level""", filter.level) + .FilterA(@"o.""Level""", filter.timestamp) + .FilterA(@"o.""SenderId""", filter.sender) + .FilterA(@"o.""Status""", filter.status) + .FilterA(filter.anyof, x => x switch + { + "sender" => @"o.""SenderId""", + _ => @"o.""BakerId""" + }) + .FilterA(@"o.""BakerId""", filter.baker) + .FilterA(@"o.""Kind""", filter.kind); + + using var db = GetConnection(); + return await db.QueryFirstAsync(sql.Query, sql.Params); + } + + async Task> QueryStakingOps(StakingOperationFilter filter, Pagination pagination, List fields = null) + { + var select = "o.*"; + + if (fields != null) + { + var columns = new HashSet(fields.Count); + foreach (var field in fields) + { + switch (field.Field) + { + case "id": columns.Add(@"o.""Id"""); break; + case "level": columns.Add(@"o.""Level"""); break; + case "timestamp": columns.Add(@"o.""Timestamp"""); break; + case "hash": columns.Add(@"o.""OpHash"""); break; + case "sender": columns.Add(@"o.""SenderId"""); break; + case "counter": columns.Add(@"o.""Counter"""); break; + case "gasLimit": columns.Add(@"o.""GasLimit"""); break; + case "gasUsed": columns.Add(@"o.""GasUsed"""); break; + case "storageLimit": columns.Add(@"o.""StorageLimit"""); break; + case "bakerFee": columns.Add(@"o.""BakerFee"""); break; + case "kind": columns.Add(@"o.""Kind"""); break; + case "baker": columns.Add(@"o.""BakerId"""); break; + case "amount": columns.Add(@"o.""Amount"""); break; + case "pseudotokens": columns.Add(@"o.""Pseudotokens"""); break; + case "limitOfStakingOverBaking": columns.Add(@"o.""LimitOfStakingOverBaking"""); break; + case "edgeOfBakingOverStaking": columns.Add(@"o.""EdgeOfBakingOverStaking"""); break; + case "activationCycle": columns.Add(@"o.""ActivationCycle"""); break; + case "status": columns.Add(@"o.""Status"""); break; + case "errors": columns.Add(@"o.""Errors"""); break; + case "quote": columns.Add(@"o.""Level"""); break; + } + } + + if (columns.Count == 0) + return Enumerable.Empty(); + + select = string.Join(',', columns); + } + + var sql = new SqlBuilder($""" + SELECT {select} + FROM "StakingOps" as o + """) + .FilterA(@"o.""Id""", filter.id) + .FilterA(@"o.""OpHash""", filter.hash) + .FilterA(@"o.""Counter""", filter.counter) + .FilterA(@"o.""Level""", filter.level) + .FilterA(@"o.""Level""", filter.timestamp) + .FilterA(@"o.""SenderId""", filter.sender) + .FilterA(@"o.""Status""", filter.status) + .FilterA(filter.anyof, x => x switch + { + "sender" => @"o.""SenderId""", + _ => @"o.""BakerId""" + }) + .FilterA(@"o.""BakerId""", filter.baker) + .FilterA(@"o.""Kind""", filter.kind) + .Take(pagination, x => (@"o.""Id""", @"o.""Id"""), @"o.""Id"""); + + using var db = GetConnection(); + return await db.QueryAsync(sql.Query, sql.Params); + } + + public async Task> GetStakingOps(StakingOperationFilter filter, Pagination pagination, Symbols quote) + { + var rows = await QueryStakingOps(filter, pagination); + return rows.Select(row => new StakingOperation + { + Id = row.Id, + Level = row.Level, + Timestamp = row.Timestamp, + Hash = row.OpHash, + Sender = Accounts.GetAlias(row.SenderId), + Counter = row.Counter, + GasLimit = row.GasLimit, + GasUsed = row.GasUsed, + StorageLimit = row.StorageLimit, + BakerFee = row.BakerFee, + Kind = StakingOperationKinds.ToString(row.Kind), + Baker = row.BakerId == null ? null : Accounts.GetAlias(row.BakerId), + Amount = row.Amount, + Pseudotokens = row.Pseudotokens, + LimitOfStakingOverBaking = row.LimitOfStakingOverBaking, + EdgeOfBakingOverStaking = row.EdgeOfBakingOverStaking, + ActivationCycle = row.ActivationCycle, + Status = OpStatuses.ToString(row.Status), + Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, + Quote = Quotes.Get(quote, row.Level) + }); + } + + public async Task GetStakingOps(StakingOperationFilter filter, Pagination pagination, List fields, Symbols quote) + { + var rows = await QueryStakingOps(filter, pagination, fields); + + var result = new object[rows.Count()][]; + for (int i = 0; i < result.Length; i++) + result[i] = new object[fields.Count]; + + for (int i = 0, j = 0; i < fields.Count; j = 0, i++) + { + switch (fields[i].Full) + { + case "type": + foreach (var row in rows) + result[j++][i] = OpTypes.Staking; + break; + case "id": + foreach (var row in rows) + result[j++][i] = row.Id; + break; + case "level": + foreach (var row in rows) + result[j++][i] = row.Level; + break; + case "timestamp": + foreach (var row in rows) + result[j++][i] = row.Timestamp; + break; + case "hash": + foreach (var row in rows) + result[j++][i] = row.OpHash; + break; + case "sender": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.SenderId); + break; + case "sender.alias": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.SenderId).Name; + break; + case "sender.address": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.SenderId).Address; + break; + case "counter": + foreach (var row in rows) + result[j++][i] = row.Counter; + break; + case "gasLimit": + foreach (var row in rows) + result[j++][i] = row.GasLimit; + break; + case "gasUsed": + foreach (var row in rows) + result[j++][i] = row.GasUsed; + break; + case "storageLimit": + foreach (var row in rows) + result[j++][i] = row.StorageLimit; + break; + case "bakerFee": + foreach (var row in rows) + result[j++][i] = row.BakerFee; + break; + case "kind": + foreach (var row in rows) + result[j++][i] = StakingOperationKinds.ToString(row.Kind); + break; + case "baker": + foreach (var row in rows) + result[j++][i] = row.BakerId == null ? null : Accounts.GetAlias(row.BakerId); + break; + case "baker.alias": + foreach (var row in rows) + result[j++][i] = row.BakerId == null ? null : Accounts.GetAlias(row.BakerId).Name; + break; + case "baker.address": + foreach (var row in rows) + result[j++][i] = row.BakerId == null ? null : Accounts.GetAlias(row.BakerId).Address; + break; + case "amount": + foreach (var row in rows) + result[j++][i] = row.Amount; + break; + case "pseudotokens": + foreach (var row in rows) + result[j++][i] = row.Pseudotokens; + break; + case "limitOfStakingOverBaking": + foreach (var row in rows) + result[j++][i] = row.LimitOfStakingOverBaking; + break; + case "edgeOfBakingOverStaking": + foreach (var row in rows) + result[j++][i] = row.EdgeOfBakingOverStaking; + break; + case "activationCycle": + foreach (var row in rows) + result[j++][i] = row.ActivationCycle; + break; + case "status": + foreach (var row in rows) + result[j++][i] = OpStatuses.ToString(row.Status); + break; + case "errors": + foreach (var row in rows) + result[j++][i] = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null; + break; + case "quote": + foreach (var row in rows) + result[j++][i] = Quotes.Get(quote, row.Level); + break; + } + } + + return result; + } + } +} diff --git a/Tzkt.Api/Repositories/OperationRepository.VdfRevelations.cs b/Tzkt.Api/Repositories/OperationRepository.VdfRevelations.cs index 684a011af..1c38a23ae 100644 --- a/Tzkt.Api/Repositories/OperationRepository.VdfRevelations.cs +++ b/Tzkt.Api/Repositories/OperationRepository.VdfRevelations.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Dapper; +using Dapper; using Netezos.Encoding; using Tzkt.Api.Models; @@ -46,7 +42,9 @@ INNER JOIN ""Blocks"" as b Cycle = row.Cycle, Solution = Hex.Convert(row.Solution), Proof = Hex.Convert(row.Proof), - Reward = row.Reward, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, Quote = Quotes.Get(quote, row.Level) }); } @@ -73,7 +71,9 @@ public async Task> GetVdfRevelations(Block b Cycle = row.Cycle, Solution = Hex.Convert(row.Solution), Proof = Hex.Convert(row.Proof), - Reward = row.Reward, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, Quote = Quotes.Get(quote, block.Level) }); } @@ -113,7 +113,9 @@ public async Task> GetVdfRevelations( Cycle = row.Cycle, Solution = Hex.Convert(row.Solution), Proof = Hex.Convert(row.Proof), - Reward = row.Reward, + RewardLiquid = row.RewardLiquid, + RewardStakedOwn = row.RewardStakedOwn, + RewardStakedShared = row.RewardStakedShared, Quote = Quotes.Get(quote, row.Level) }); } @@ -144,12 +146,21 @@ public async Task GetVdfRevelations( case "cycle": columns.Add(@"o.""Cycle"""); break; case "solution": columns.Add(@"o.""Solution"""); break; case "proof": columns.Add(@"o.""Proof"""); break; - case "reward": columns.Add(@"o.""Reward"""); break; + case "rewardLiquid": columns.Add(@"o.""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"o.""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"o.""RewardStakedShared"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "reward": + columns.Add(@"o.""RewardLiquid"""); + columns.Add(@"o.""RewardStakedOwn"""); + columns.Add(@"o.""RewardStakedShared"""); + break; + #endregion } } @@ -214,14 +225,28 @@ public async Task GetVdfRevelations( foreach (var row in rows) result[j++][i] = Hex.Convert(row.Proof); break; - case "reward": + case "rewardLiquid": + foreach (var row in rows) + result[j++][i] = row.RewardLiquid; + break; + case "rewardStakedOwn": foreach (var row in rows) - result[j++][i] = row.Reward; + result[j++][i] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++][i] = row.RewardStakedShared; break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "reward": + foreach (var row in rows) + result[j++][i] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + #endregion } } @@ -252,12 +277,21 @@ public async Task GetVdfRevelations( case "cycle": columns.Add(@"o.""Cycle"""); break; case "solution": columns.Add(@"o.""Solution"""); break; case "proof": columns.Add(@"o.""Proof"""); break; - case "reward": columns.Add(@"o.""Reward"""); break; + case "rewardLiquid": columns.Add(@"o.""RewardLiquid"""); break; + case "rewardStakedOwn": columns.Add(@"o.""RewardStakedOwn"""); break; + case "rewardStakedShared": columns.Add(@"o.""RewardStakedShared"""); break; case "block": columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; case "quote": columns.Add(@"o.""Level"""); break; + #region deprecated + case "reward": + columns.Add(@"o.""RewardLiquid"""); + columns.Add(@"o.""RewardStakedOwn"""); + columns.Add(@"o.""RewardStakedShared"""); + break; + #endregion } if (columns.Count == 0) @@ -319,14 +353,28 @@ public async Task GetVdfRevelations( foreach (var row in rows) result[j++] = Hex.Convert(row.Proof); break; - case "reward": + case "rewardLiquid": + foreach (var row in rows) + result[j++] = row.RewardLiquid; + break; + case "rewardStakedOwn": foreach (var row in rows) - result[j++] = row.Reward; + result[j++] = row.RewardStakedOwn; + break; + case "rewardStakedShared": + foreach (var row in rows) + result[j++] = row.RewardStakedShared; break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); break; + #region deprecated + case "reward": + foreach (var row in rows) + result[j++] = row.RewardLiquid + row.RewardStakedOwn + row.RewardStakedShared; + break; + #endregion } return result; diff --git a/Tzkt.Api/Repositories/OperationRepository.cs b/Tzkt.Api/Repositories/OperationRepository.cs index 3f12ac37c..65c9912e4 100644 --- a/Tzkt.Api/Repositories/OperationRepository.cs +++ b/Tzkt.Api/Repositories/OperationRepository.cs @@ -48,6 +48,7 @@ public OperationRepository(AccountsCache accounts, TimeCache times, QuotesCache ?? await GetStatus(db, nameof(TzktContext.SmartRollupPublishOps), hash) ?? await GetStatus(db, nameof(TzktContext.SmartRollupRecoverBondOps), hash) ?? await GetStatus(db, nameof(TzktContext.SmartRollupRefuteOps), hash) + ?? await GetStatus(db, nameof(TzktContext.StakingOps), hash) ?? await GetStatus(db, nameof(TzktContext.TxRollupCommitOps), hash) ?? await GetStatus(db, nameof(TzktContext.TxRollupDispatchTicketsOps), hash) ?? await GetStatus(db, nameof(TzktContext.TxRollupFinalizeCommitmentOps), hash) @@ -108,6 +109,7 @@ await Task.WhenAll( var srPublish = GetSmartRollupPublishOps(new() { hash = hash }, new() { limit = -1 }, quote); var srRecoverBond = GetSmartRollupRecoverBondOps(new() { hash = hash }, new() { limit = -1 }, quote); var srRefute = GetSmartRollupRefuteOps(new() { hash = hash }, new() { limit = -1 }, quote); + var staking = GetStakingOps(new() { hash = hash }, new() { limit = -1 }, quote); await Task.WhenAll( srAddMessages, @@ -116,7 +118,8 @@ await Task.WhenAll( srOriginate, srPublish, srRecoverBond, - srRefute); + srRefute, + staking); var managerOps = ((IEnumerable)delegations.Result) .Concat(originations.Result) @@ -141,7 +144,8 @@ await Task.WhenAll( .Concat(srOriginate.Result) .Concat(srPublish.Result) .Concat(srRecoverBond.Result) - .Concat(srRefute.Result); + .Concat(srRefute.Result) + .Concat(staking.Result); if (managerOps.Any()) return managerOps.OrderBy(x => x.Id); @@ -214,6 +218,7 @@ public async Task> Get(string hash, int counter, Michelin var srPublish = GetSmartRollupPublishOps(new() { hash = hash, counter = counter }, new() { limit = -1 }, quote); var srRecoverBond = GetSmartRollupRecoverBondOps(new() { hash = hash, counter = counter }, new() { limit = -1 }, quote); var srRefute = GetSmartRollupRefuteOps(new() { hash = hash, counter = counter }, new() { limit = -1 }, quote); + var staking = GetStakingOps(new() { hash = hash, counter = counter }, new() { limit = -1 }, quote); await Task.WhenAll( increasePaidStorageOps, @@ -223,7 +228,8 @@ await Task.WhenAll( srOriginate, srPublish, srRecoverBond, - srRefute); + srRefute, + staking); if (increasePaidStorageOps.Result.Any()) return increasePaidStorageOps.Result; @@ -249,6 +255,9 @@ await Task.WhenAll( if (srRefute.Result.Any()) return srRefute.Result; + if (staking.Result.Any()) + return staking.Result; + var txRollupCommitOps = GetTxRollupCommitOps(hash, counter, quote); var txRollupDispatchTicketsOps = GetTxRollupDispatchTicketsOps(hash, counter, quote); var txRollupFinalizeCommitmentOps = GetTxRollupFinalizeCommitmentOps(hash, counter, quote); diff --git a/Tzkt.Api/Repositories/ProtocolRepository.cs b/Tzkt.Api/Repositories/ProtocolRepository.cs index fa58b8a47..e1b4cedc5 100644 --- a/Tzkt.Api/Repositories/ProtocolRepository.cs +++ b/Tzkt.Api/Repositories/ProtocolRepository.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using Dapper; +using Dapper; using Tzkt.Api.Models; namespace Tzkt.Api.Repositories @@ -65,24 +61,19 @@ ORDER BY ""FirstLevel"" DESC HardOperationStorageLimit = row.HardOperationStorageLimit, OriginationSize = row.OriginationSize, PreservedCycles = row.PreservedCycles, - RevelationReward = row.RevelationReward, TimeBetweenBlocks = row.TimeBetweenBlocks, - TokensPerRoll = row.TokensPerRoll, + MinimalStake = row.MinimalStake, + MinimalFrozenStake = row.MinimalFrozenStake, ProposalQuorum = row.ProposalQuorum / 100.0, BallotQuorumMin = row.BallotQuorumMin / 100.0, BallotQuorumMax = row.BallotQuorumMax / 100.0, - LBSubsidy = row.LBSubsidy, LBToggleThreshold = row.LBToggleThreshold, ConsensusThreshold = row.ConsensusThreshold, - DoubleBakingPunishment = row.DoubleBakingPunishment, - DoubleEndorsingPunishmentDenominator = row.DoubleEndorsingPunishmentDenominator, - DoubleEndorsingPunishmentNumerator = row.DoubleEndorsingPunishmentNumerator, - FrozenDepositsPercentage = row.FrozenDepositsPercentage, + MaxDelegatedOverFrozenRatio = row.MaxDelegatedOverFrozenRatio, + MaxExternalOverOwnStakeRatio = row.MaxExternalOverOwnStakeRatio, MaxSlashingPeriod = row.MaxSlashingPeriod, MinParticipationDenominator = row.MinParticipationDenominator, MinParticipationNumerator = row.MinParticipationNumerator, - TxRollupOriginationSize = row.TxRollupOriginationSize, - TxRollupCommitmentBond = row.TxRollupCommitmentBond, SmartRollupChallengeWindow= row.SmartRollupChallengeWindow, SmartRollupCommitmentPeriod= row.SmartRollupCommitmentPeriod, SmartRollupOriginationSize= row.SmartRollupOriginationSize, @@ -137,24 +128,19 @@ public async Task Get(int code) HardOperationStorageLimit = row.HardOperationStorageLimit, OriginationSize = row.OriginationSize, PreservedCycles = row.PreservedCycles, - RevelationReward = row.RevelationReward, TimeBetweenBlocks = row.TimeBetweenBlocks, - TokensPerRoll = row.TokensPerRoll, + MinimalStake = row.MinimalStake, + MinimalFrozenStake = row.MinimalFrozenStake, ProposalQuorum = row.ProposalQuorum / 100.0, BallotQuorumMin = row.BallotQuorumMin / 100.0, BallotQuorumMax = row.BallotQuorumMax / 100.0, - LBSubsidy = row.LBSubsidy, LBToggleThreshold = row.LBToggleThreshold, ConsensusThreshold = row.ConsensusThreshold, - DoubleBakingPunishment = row.DoubleBakingPunishment, - DoubleEndorsingPunishmentDenominator = row.DoubleEndorsingPunishmentDenominator, - DoubleEndorsingPunishmentNumerator = row.DoubleEndorsingPunishmentNumerator, - FrozenDepositsPercentage = row.FrozenDepositsPercentage, + MaxDelegatedOverFrozenRatio = row.MaxDelegatedOverFrozenRatio, + MaxExternalOverOwnStakeRatio = row.MaxExternalOverOwnStakeRatio, MaxSlashingPeriod = row.MaxSlashingPeriod, MinParticipationDenominator = row.MinParticipationDenominator, MinParticipationNumerator = row.MinParticipationNumerator, - TxRollupOriginationSize = row.TxRollupOriginationSize, - TxRollupCommitmentBond = row.TxRollupCommitmentBond, SmartRollupChallengeWindow = row.SmartRollupChallengeWindow, SmartRollupCommitmentPeriod = row.SmartRollupCommitmentPeriod, SmartRollupOriginationSize = row.SmartRollupOriginationSize, @@ -209,24 +195,19 @@ public async Task Get(string hash) HardOperationStorageLimit = row.HardOperationStorageLimit, OriginationSize = row.OriginationSize, PreservedCycles = row.PreservedCycles, - RevelationReward = row.RevelationReward, TimeBetweenBlocks = row.TimeBetweenBlocks, - TokensPerRoll = row.TokensPerRoll, + MinimalStake = row.MinimalStake, + MinimalFrozenStake = row.MinimalFrozenStake, ProposalQuorum = row.ProposalQuorum / 100.0, BallotQuorumMin = row.BallotQuorumMin / 100.0, BallotQuorumMax = row.BallotQuorumMax / 100.0, - LBSubsidy = row.LBSubsidy, LBToggleThreshold = row.LBToggleThreshold, ConsensusThreshold = row.ConsensusThreshold, - DoubleBakingPunishment = row.DoubleBakingPunishment, - DoubleEndorsingPunishmentDenominator = row.DoubleEndorsingPunishmentDenominator, - DoubleEndorsingPunishmentNumerator = row.DoubleEndorsingPunishmentNumerator, - FrozenDepositsPercentage = row.FrozenDepositsPercentage, + MaxDelegatedOverFrozenRatio = row.MaxDelegatedOverFrozenRatio, + MaxExternalOverOwnStakeRatio = row.MaxExternalOverOwnStakeRatio, MaxSlashingPeriod = row.MaxSlashingPeriod, MinParticipationDenominator = row.MinParticipationDenominator, MinParticipationNumerator = row.MinParticipationNumerator, - TxRollupOriginationSize = row.TxRollupOriginationSize, - TxRollupCommitmentBond = row.TxRollupCommitmentBond, SmartRollupChallengeWindow = row.SmartRollupChallengeWindow, SmartRollupCommitmentPeriod = row.SmartRollupCommitmentPeriod, SmartRollupOriginationSize = row.SmartRollupOriginationSize, @@ -282,24 +263,19 @@ public async Task> Get(SortParameter sort, OffsetParameter HardOperationStorageLimit = row.HardOperationStorageLimit, OriginationSize = row.OriginationSize, PreservedCycles = row.PreservedCycles, - RevelationReward = row.RevelationReward, TimeBetweenBlocks = row.TimeBetweenBlocks, - TokensPerRoll = row.TokensPerRoll, + MinimalStake = row.MinimalStake, + MinimalFrozenStake = row.MinimalFrozenStake, ProposalQuorum = row.ProposalQuorum / 100.0, BallotQuorumMin = row.BallotQuorumMin / 100.0, BallotQuorumMax = row.BallotQuorumMax / 100.0, - LBSubsidy = row.LBSubsidy, LBToggleThreshold = row.LBToggleThreshold, ConsensusThreshold = row.ConsensusThreshold, - DoubleBakingPunishment = row.DoubleBakingPunishment, - DoubleEndorsingPunishmentDenominator = row.DoubleEndorsingPunishmentDenominator, - DoubleEndorsingPunishmentNumerator = row.DoubleEndorsingPunishmentNumerator, - FrozenDepositsPercentage = row.FrozenDepositsPercentage, + MaxDelegatedOverFrozenRatio = row.MaxDelegatedOverFrozenRatio, + MaxExternalOverOwnStakeRatio = row.MaxExternalOverOwnStakeRatio, MaxSlashingPeriod = row.MaxSlashingPeriod, MinParticipationDenominator = row.MinParticipationDenominator, MinParticipationNumerator = row.MinParticipationNumerator, - TxRollupOriginationSize = row.TxRollupOriginationSize, - TxRollupCommitmentBond = row.TxRollupCommitmentBond, SmartRollupChallengeWindow = row.SmartRollupChallengeWindow, SmartRollupCommitmentPeriod = row.SmartRollupCommitmentPeriod, SmartRollupOriginationSize = row.SmartRollupOriginationSize, diff --git a/Tzkt.Api/Repositories/ReportRepository.cs b/Tzkt.Api/Repositories/ReportRepository.cs index c4742821c..bb9a35c32 100644 --- a/Tzkt.Api/Repositories/ReportRepository.cs +++ b/Tzkt.Api/Repositories/ReportRepository.cs @@ -53,6 +53,7 @@ public async Task Write(StreamWriter csv, string address, DateTime from, DateTim if (user.RegisterConstantsCount > 0) UnionRegisterConstant(sql); if (user.SetDepositsLimitsCount > 0) UnionSetDepositsLimits(sql); if (user.DrainDelegateCount > 0) UnionDrainDelegateOps(sql); + if (user.StakingOpsCount > 0) UnionStakingOps(sql); } if (account is RawDelegate delegat) @@ -187,6 +188,7 @@ public async Task Write(StreamWriter csv, string address, DateTime from, DateTim if (user.RegisterConstantsCount > 0) UnionRegisterConstant(sql); if (user.SetDepositsLimitsCount > 0) UnionSetDepositsLimits(sql); if (user.DrainDelegateCount > 0) UnionDrainDelegateOps(sql); + if (user.StakingOpsCount > 0) UnionStakingOps(sql); } if (account is RawDelegate delegat) @@ -355,6 +357,7 @@ public async Task WriteHistorical(StreamWriter csv, string address, DateTime fro if (user.RegisterConstantsCount > 0) UnionRegisterConstant(sql); if (user.SetDepositsLimitsCount > 0) UnionSetDepositsLimits(sql); if (user.DrainDelegateCount > 0) UnionDrainDelegateOps(sql); + if (user.StakingOpsCount > 0) UnionStakingOps(sql); } if (account is RawDelegate delegat) @@ -498,7 +501,7 @@ void UnionEndorsingRewards(StringBuilder sql) sql.Append(@"null::integer as ""Counter"", "); sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); - sql.Append(@"""Received"" as ""Reward"", "); + sql.Append(@"(""RewardLiquid"" + ""RewardStakedOwn"") as ""Reward"", "); sql.Append(@"null::integer as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); @@ -509,7 +512,7 @@ void UnionEndorsingRewards(StringBuilder sql) sql.Append(@"FROM ""EndorsingRewardOps"" "); sql.Append(@"WHERE ""BakerId"" = @account "); sql.Append(@"AND ""Timestamp"" >= @from AND ""Timestamp"" < @to "); - sql.Append(@"AND ""Received"" > 0 "); + sql.Append(@"AND (""RewardLiquid"" > 0 OR ""RewardStakedOwn"" > 0) "); sql.AppendLine(); } @@ -526,7 +529,7 @@ void UnionBaking(StringBuilder sql) sql.Append(@"null::integer as ""Counter"", "); sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); - sql.Append(@"(""Reward"" + ""Fees"") as ""Reward"", "); + sql.Append(@"(""RewardLiquid"" + ""RewardStakedOwn"" + ""Fees"") as ""Reward"", "); sql.Append(@"null::integer as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); @@ -537,7 +540,7 @@ void UnionBaking(StringBuilder sql) sql.Append(@"FROM ""Blocks"" "); sql.Append(@"WHERE ""ProposerId"" = @account "); sql.Append(@"AND ""Timestamp"" >= @from AND ""Timestamp"" < @to "); - sql.Append(@"AND (""Reward"" > 0 OR ""Fees"" > 0) "); + sql.Append(@"AND (""RewardLiquid"" > 0 OR ""RewardStakedOwn"" > 0 OR ""Fees"" > 0) "); sql.AppendLine(); #endregion @@ -552,7 +555,7 @@ void UnionBaking(StringBuilder sql) sql.Append(@"null::integer as ""Counter"", "); sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); - sql.Append(@"""Bonus"" as ""Reward"", "); + sql.Append(@"(""BonusLiquid"" + ""BonusStakedOwn"") as ""Reward"", "); sql.Append(@"null::integer as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); @@ -563,7 +566,7 @@ void UnionBaking(StringBuilder sql) sql.Append(@"FROM ""Blocks"" "); sql.Append(@"WHERE ""ProducerId"" = @account "); sql.Append(@"AND ""Timestamp"" >= @from AND ""Timestamp"" < @to "); - sql.Append(@"AND ""Bonus"" > 0 "); + sql.Append(@"AND (""BonusLiquid"" > 0 OR ""BonusStakedOwn"" > 0) "); sql.AppendLine(); #endregion @@ -635,7 +638,7 @@ void UnionDoubleBaking(StringBuilder sql) sql.Append(@"null::integer as ""Counter"", "); sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); - sql.Append(@"""AccuserReward"" as ""Reward"", "); + sql.Append(@"""Reward"" as ""Reward"", "); sql.Append(@"null::integer as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); @@ -661,7 +664,7 @@ void UnionDoubleBaking(StringBuilder sql) sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); sql.Append(@"null::integer as ""Reward"", "); - sql.Append(@"""OffenderLoss"" as ""Loss"", "); + sql.Append(@"(""LostStaked"" + ""LostUnstaked"") as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); sql.Append(@"null::integer as ""Sent"", "); @@ -688,7 +691,7 @@ void UnionDoubleEndorsing(StringBuilder sql) sql.Append(@"null::integer as ""Counter"", "); sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); - sql.Append(@"""AccuserReward"" as ""Reward"", "); + sql.Append(@"""Reward"" as ""Reward"", "); sql.Append(@"null::integer as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); @@ -714,7 +717,7 @@ void UnionDoubleEndorsing(StringBuilder sql) sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); sql.Append(@"null::integer as ""Reward"", "); - sql.Append(@"""OffenderLoss"" as ""Loss"", "); + sql.Append(@"(""LostStaked"" + ""LostUnstaked"") as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); sql.Append(@"null::integer as ""Sent"", "); @@ -741,7 +744,7 @@ void UnionDoublePreendorsing(StringBuilder sql) sql.Append(@"null::integer as ""Counter"", "); sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); - sql.Append(@"""AccuserReward"" as ""Reward"", "); + sql.Append(@"""Reward"" as ""Reward"", "); sql.Append(@"null::integer as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); @@ -767,7 +770,7 @@ void UnionDoublePreendorsing(StringBuilder sql) sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); sql.Append(@"null::integer as ""Reward"", "); - sql.Append(@"""OffenderLoss"" as ""Loss"", "); + sql.Append(@"(""LostStaked"" + ""LostUnstaked"") as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); sql.Append(@"null::integer as ""Sent"", "); @@ -793,7 +796,7 @@ void UnionNonceRevelations(StringBuilder sql) sql.Append(@"null::integer as ""Counter"", "); sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); - sql.Append(@"""Reward"" as ""Reward"", "); + sql.Append(@"(""RewardLiquid"" + ""RewardStakedOwn"") as ""Reward"", "); sql.Append(@"null::integer as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); @@ -819,7 +822,7 @@ void UnionVdfRevelations(StringBuilder sql) sql.Append(@"null::integer as ""Counter"", "); sql.Append(@"null::integer as ""Nonce"", "); sql.Append(@"""Timestamp"" as ""Timestamp"", "); - sql.Append(@"""Reward"" as ""Reward"", "); + sql.Append(@"(""RewardLiquid"" + ""RewardStakedOwn"") as ""Reward"", "); sql.Append(@"null::integer as ""Loss"", "); sql.Append(@"null::integer as ""Received"", "); sql.Append(@"null::integer as ""From"", "); @@ -1785,6 +1788,33 @@ void UnionSrGames(StringBuilder sql) #endregion } + void UnionStakingOps(StringBuilder sql) + { + sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); + + sql.Append(@"43 as ""Type"", "); + sql.Append(@"""Id"" as ""Id"", "); + sql.Append(@"""Level"" as ""Level"", "); + sql.Append(@"""OpHash"" as ""OpHash"", "); + sql.Append(@"""Counter"" as ""Counter"", "); + sql.Append(@"null::integer as ""Nonce"", "); + sql.Append(@"""Timestamp"" as ""Timestamp"", "); + sql.Append(@"null::integer as ""Reward"", "); + sql.Append(@"null::integer as ""Loss"", "); + sql.Append(@"null::integer as ""Received"", "); + sql.Append(@"null::integer as ""From"", "); + sql.Append(@"null::integer as ""Sent"", "); + sql.Append(@"""BakerFee"" as ""Fee"", "); + sql.Append(@"null::integer as ""To"" "); + + sql.Append(@"FROM ""StakingOps"" "); + sql.Append(@"WHERE ""SenderId"" = @account "); + sql.Append(@"AND ""Timestamp"" >= @from AND ""Timestamp"" < @to "); + sql.Append(@"AND ""BakerFee"" > 0 "); + + sql.AppendLine(); + } + void UnionRevelationPenalties(StringBuilder sql) { sql.Append(sql.Length == 0 ? "SELECT " : "UNION ALL SELECT "); @@ -1890,7 +1920,8 @@ void UnionMigrations(StringBuilder sql) "smart rollup publish", // 39 "smart rollup recover bond", // 40 "smart rollup refute", // 41 - "smart rollup game" // 42 + "smart rollup game", // 42 + "staking" // 43 }; } } diff --git a/Tzkt.Api/Repositories/RewardsRepository.cs b/Tzkt.Api/Repositories/RewardsRepository.cs index 358e888e4..441372426 100644 --- a/Tzkt.Api/Repositories/RewardsRepository.cs +++ b/Tzkt.Api/Repositories/RewardsRepository.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using Dapper; - +using Dapper; using Tzkt.Api.Models; using Tzkt.Api.Services.Cache; @@ -33,58 +27,6 @@ public async Task GetBakerRewardsCount(string address) return await db.QueryFirstAsync($@"SELECT COUNT(*) FROM ""BakerCycles"" WHERE ""BakerId"" = {baker.Id}"); } - public async Task GetBakerRewards(string address, int cycle, Symbols quote) - { - if (await Accounts.GetAsync(address) is not RawDelegate baker) - return null; - - var sql = $@" - SELECT * - FROM ""BakerCycles"" - WHERE ""BakerId"" = {baker.Id} - AND ""Cycle"" = {cycle} - LIMIT 1"; - - using var db = GetConnection(); - var row = await db.QueryFirstOrDefaultAsync(sql); - if (row == null) return null; - - return new BakerRewards - { - ActiveStake = row.ActiveStake, - SelectedStake = row.SelectedStake, - DoubleBakingRewards = row.DoubleBakingRewards, - DoubleBakingLosses = row.DoubleBakingLosses, - DoubleEndorsingRewards = row.DoubleEndorsingRewards, - DoubleEndorsingLosses = row.DoubleEndorsingLosses, - DoublePreendorsingRewards = row.DoublePreendorsingRewards, - DoublePreendorsingLosses = row.DoublePreendorsingLosses, - Cycle = row.Cycle, - DelegatedBalance = row.DelegatedBalance, - EndorsementRewards = row.EndorsementRewards, - Endorsements = row.Endorsements, - ExpectedBlocks = Math.Round(row.ExpectedBlocks, 2), - ExpectedEndorsements = Math.Round(row.ExpectedEndorsements, 2), - FutureBlockRewards = row.FutureBlockRewards, - FutureBlocks = row.FutureBlocks, - FutureEndorsementRewards = row.FutureEndorsementRewards, - FutureEndorsements = row.FutureEndorsements, - MissedEndorsementRewards = row.MissedEndorsementRewards, - MissedEndorsements = row.MissedEndorsements, - MissedBlockFees = row.MissedBlockFees, - MissedBlockRewards = row.MissedBlockRewards, - MissedBlocks = row.MissedBlocks, - NumDelegators = row.DelegatorsCount, - BlockFees = row.BlockFees, - BlockRewards = row.BlockRewards, - Blocks = row.Blocks, - RevelationLosses = row.RevelationLosses, - RevelationRewards = row.RevelationRewards, - StakingBalance = row.StakingBalance, - Quote = Quotes.Get(quote, Protocols.FindByCycle((int)row.Cycle).GetCycleEnd((int)row.Cycle)) - }; - } - public async Task> GetBakerRewards( string address, Int32Parameter cycle, @@ -106,36 +48,57 @@ public async Task> GetBakerRewards( return rows.Select(row => new BakerRewards { - ActiveStake = row.ActiveStake, - SelectedStake = row.SelectedStake, - DoubleBakingRewards = row.DoubleBakingRewards, - DoubleBakingLosses = row.DoubleBakingLosses, - DoubleEndorsingRewards = row.DoubleEndorsingRewards, - DoubleEndorsingLosses = row.DoubleEndorsingLosses, - DoublePreendorsingRewards = row.DoublePreendorsingRewards, - DoublePreendorsingLosses = row.DoublePreendorsingLosses, Cycle = row.Cycle, - DelegatedBalance = row.DelegatedBalance, - EndorsementRewards = row.EndorsementRewards, - Endorsements = row.Endorsements, + BakingPower = row.BakingPower, + TotalBakingPower = row.TotalBakingPower, + OwnDelegatedBalance = row.OwnDelegatedBalance, + ExternalDelegatedBalance = row.ExternalDelegatedBalance, + DelegatorsCount = row.DelegatorsCount, + OwnStakedBalance = row.OwnStakedBalance, + ExternalStakedBalance = row.ExternalStakedBalance, + StakersCount = row.StakersCount, ExpectedBlocks = Math.Round(row.ExpectedBlocks, 2), ExpectedEndorsements = Math.Round(row.ExpectedEndorsements, 2), - FutureBlockRewards = row.FutureBlockRewards, FutureBlocks = row.FutureBlocks, - FutureEndorsementRewards = row.FutureEndorsementRewards, + FutureBlockRewards = row.FutureBlockRewards, + Blocks = row.Blocks, + BlockRewardsLiquid = row.BlockRewardsLiquid, + BlockRewardsStakedOwn = row.BlockRewardsStakedOwn, + BlockRewardsStakedShared = row.BlockRewardsStakedShared, + MissedBlocks = row.MissedBlocks, + MissedBlockRewards = row.MissedBlockRewards, FutureEndorsements = row.FutureEndorsements, - MissedEndorsementRewards = row.MissedEndorsementRewards, + FutureEndorsementRewards = row.FutureEndorsementRewards, + Endorsements = row.Endorsements, + EndorsementRewardsLiquid = row.EndorsementRewardsLiquid, + EndorsementRewardsStakedOwn = row.EndorsementRewardsStakedOwn, + EndorsementRewardsStakedShared = row.EndorsementRewardsStakedShared, MissedEndorsements = row.MissedEndorsements, - MissedBlockFees = row.MissedBlockFees, - MissedBlockRewards = row.MissedBlockRewards, - MissedBlocks = row.MissedBlocks, - NumDelegators = row.DelegatorsCount, + MissedEndorsementRewards = row.MissedEndorsementRewards, BlockFees = row.BlockFees, - BlockRewards = row.BlockRewards, - Blocks = row.Blocks, - RevelationLosses = row.RevelationLosses, - RevelationRewards = row.RevelationRewards, - StakingBalance = row.StakingBalance, + MissedBlockFees = row.MissedBlockFees, + DoubleBakingRewards = row.DoubleBakingRewards, + DoubleBakingLostStaked = row.DoubleBakingLostStaked, + DoubleBakingLostUnstaked = row.DoubleBakingLostUnstaked, + DoubleBakingLostExternalStaked = row.DoubleBakingLostExternalStaked, + DoubleBakingLostExternalUnstaked = row.DoubleBakingLostExternalUnstaked, + DoubleEndorsingRewards = row.DoubleEndorsingRewards, + DoubleEndorsingLostStaked = row.DoubleEndorsingLostStaked, + DoubleEndorsingLostUnstaked = row.DoubleEndorsingLostUnstaked, + DoubleEndorsingLostExternalStaked = row.DoubleEndorsingLostExternalStaked, + DoubleEndorsingLostExternalUnstaked = row.DoubleEndorsingLostExternalUnstaked, + DoublePreendorsingRewards = row.DoublePreendorsingRewards, + DoublePreendorsingLostStaked = row.DoublePreendorsingLostStaked, + DoublePreendorsingLostUnstaked = row.DoublePreendorsingLostUnstaked, + DoublePreendorsingLostExternalStaked = row.DoublePreendorsingLostExternalStaked, + DoublePreendorsingLostExternalUnstaked = row.DoublePreendorsingLostExternalUnstaked, + VdfRevelationRewardsLiquid = row.VdfRevelationRewardsLiquid, + VdfRevelationRewardsStakedOwn = row.VdfRevelationRewardsStakedOwn, + VdfRevelationRewardsStakedShared = row.VdfRevelationRewardsStakedShared, + NonceRevelationRewardsLiquid = row.NonceRevelationRewardsLiquid, + NonceRevelationRewardsStakedOwn = row.NonceRevelationRewardsStakedOwn, + NonceRevelationRewardsStakedShared = row.NonceRevelationRewardsStakedShared, + NonceRevelationLosses = row.NonceRevelationLosses, Quote = Quotes.Get(quote, Protocols.FindByCycle((int)row.Cycle).GetCycleEnd((int)row.Cycle)) }); } @@ -157,37 +120,118 @@ public async Task GetBakerRewards( { switch (field) { - case "activeStake": columns.Add(@"""ActiveStake"""); break; - case "selectedStake": columns.Add(@"""SelectedStake"""); break; - case "doubleBakingRewards": columns.Add(@"""DoubleBakingRewards"""); break; - case "doubleBakingLosses": columns.Add(@"""DoubleBakingLosses"""); break; - case "doubleEndorsingRewards": columns.Add(@"""DoubleEndorsingRewards"""); break; - case "doubleEndorsingLosses": columns.Add(@"""DoubleEndorsingLosses"""); break; - case "doublePreendorsingRewards": columns.Add(@"""DoublePreendorsingRewards"""); break; - case "doublePreendorsingLosses": columns.Add(@"""DoublePreendorsingLosses"""); break; case "cycle": columns.Add(@"""Cycle"""); break; - case "delegatedBalance": columns.Add(@"""DelegatedBalance"""); break; - case "endorsementRewards": columns.Add(@"""EndorsementRewards"""); break; - case "endorsements": columns.Add(@"""Endorsements"""); break; + case "bakingPower": columns.Add(@"""BakingPower"""); break; + case "totalBakingPower": columns.Add(@"""TotalBakingPower"""); break; + case "ownDelegatedBalance": columns.Add(@"""OwnDelegatedBalance"""); break; + case "externalDelegatedBalance": columns.Add(@"""ExternalDelegatedBalance"""); break; + case "delegatorsCount": columns.Add(@"""DelegatorsCount"""); break; + case "ownStakedBalance": columns.Add(@"""OwnStakedBalance"""); break; + case "externalStakedBalance": columns.Add(@"""ExternalStakedBalance"""); break; + case "stakersCount": columns.Add(@"""StakersCount"""); break; case "expectedBlocks": columns.Add(@"""ExpectedBlocks"""); break; case "expectedEndorsements": columns.Add(@"""ExpectedEndorsements"""); break; - case "futureBlockRewards": columns.Add(@"""FutureBlockRewards"""); break; case "futureBlocks": columns.Add(@"""FutureBlocks"""); break; - case "futureEndorsementRewards": columns.Add(@"""FutureEndorsementRewards"""); break; + case "futureBlockRewards": columns.Add(@"""FutureBlockRewards"""); break; + case "blocks": columns.Add(@"""Blocks"""); break; + case "blockRewardsLiquid": columns.Add(@"""BlockRewardsLiquid"""); break; + case "blockRewardsStakedOwn": columns.Add(@"""BlockRewardsStakedOwn"""); break; + case "blockRewardsStakedShared": columns.Add(@"""BlockRewardsStakedShared"""); break; + case "missedBlocks": columns.Add(@"""MissedBlocks"""); break; + case "missedBlockRewards": columns.Add(@"""MissedBlockRewards"""); break; case "futureEndorsements": columns.Add(@"""FutureEndorsements"""); break; - case "missedEndorsementRewards": columns.Add(@"""MissedEndorsementRewards"""); break; + case "futureEndorsementRewards": columns.Add(@"""FutureEndorsementRewards"""); break; + case "endorsements": columns.Add(@"""Endorsements"""); break; + case "endorsementRewardsLiquid": columns.Add(@"""EndorsementRewardsLiquid"""); break; + case "endorsementRewardsStakedOwn": columns.Add(@"""EndorsementRewardsStakedOwn"""); break; + case "endorsementRewardsStakedShared": columns.Add(@"""EndorsementRewardsStakedShared"""); break; case "missedEndorsements": columns.Add(@"""MissedEndorsements"""); break; - case "missedBlockFees": columns.Add(@"""MissedBlockFees"""); break; - case "missedBlockRewards": columns.Add(@"""MissedBlockRewards"""); break; - case "missedBlocks": columns.Add(@"""MissedBlocks"""); break; - case "numDelegators": columns.Add(@"""DelegatorsCount"""); break; + case "missedEndorsementRewards": columns.Add(@"""MissedEndorsementRewards"""); break; case "blockFees": columns.Add(@"""BlockFees"""); break; - case "blockRewards": columns.Add(@"""BlockRewards"""); break; - case "blocks": columns.Add(@"""Blocks"""); break; - case "revelationLosses": columns.Add(@"""RevelationLosses"""); break; - case "revelationRewards": columns.Add(@"""RevelationRewards"""); break; - case "stakingBalance": columns.Add(@"""StakingBalance"""); break; + case "missedBlockFees": columns.Add(@"""MissedBlockFees"""); break; + case "doubleBakingRewards": columns.Add(@"""DoubleBakingRewards"""); break; + case "doubleBakingLostStaked": columns.Add(@"""DoubleBakingLostStaked"""); break; + case "doubleBakingLostUnstaked": columns.Add(@"""DoubleBakingLostUnstaked"""); break; + case "doubleBakingLostExternalStaked": columns.Add(@"""DoubleBakingLostExternalStaked"""); break; + case "doubleBakingLostExternalUnstaked": columns.Add(@"""DoubleBakingLostExternalUnstaked"""); break; + case "doubleEndorsingRewards": columns.Add(@"""DoubleEndorsingRewards"""); break; + case "doubleEndorsingLostStaked": columns.Add(@"""DoubleEndorsingLostStaked"""); break; + case "doubleEndorsingLostUnstaked": columns.Add(@"""DoubleEndorsingLostUnstaked"""); break; + case "doubleEndorsingLostExternalStaked": columns.Add(@"""DoubleEndorsingLostExternalStaked"""); break; + case "doubleEndorsingLostExternalUnstaked": columns.Add(@"""DoubleEndorsingLostExternalUnstaked"""); break; + case "doublePreendorsingRewards": columns.Add(@"""DoublePreendorsingRewards"""); break; + case "doublePreendorsingLostStaked": columns.Add(@"""DoublePreendorsingLostStaked"""); break; + case "doublePreendorsingLostUnstaked": columns.Add(@"""DoublePreendorsingLostUnstaked"""); break; + case "doublePreendorsingLostExternalStaked": columns.Add(@"""DoublePreendorsingLostExternalStaked"""); break; + case "doublePreendorsingLostExternalUnstaked": columns.Add(@"""DoublePreendorsingLostExternalUnstaked"""); break; + case "vdfRevelationRewardsLiquid": columns.Add(@"""VdfRevelationRewardsLiquid"""); break; + case "vdfRevelationRewardsStakedOwn": columns.Add(@"""VdfRevelationRewardsStakedOwn"""); break; + case "vdfRevelationRewardsStakedShared": columns.Add(@"""VdfRevelationRewardsStakedShared"""); break; + case "nonceRevelationRewardsLiquid": columns.Add(@"""NonceRevelationRewardsLiquid"""); break; + case "nonceRevelationRewardsStakedOwn": columns.Add(@"""NonceRevelationRewardsStakedOwn"""); break; + case "nonceRevelationRewardsStakedShared": columns.Add(@"""NonceRevelationRewardsStakedShared"""); break; + case "nonceRevelationLosses": columns.Add(@"""NonceRevelationLosses"""); break; case "quote": columns.Add(@"""Cycle"""); break; + + #region deprecated + case "revelationRewards": + columns.Add(@"""NonceRevelationRewardsLiquid"""); + columns.Add(@"""NonceRevelationRewardsStakedOwn"""); + columns.Add(@"""NonceRevelationRewardsStakedShared"""); + columns.Add(@"""VdfRevelationRewardsLiquid"""); + columns.Add(@"""VdfRevelationRewardsStakedOwn"""); + columns.Add(@"""VdfRevelationRewardsStakedShared"""); + break; + case "revelationLosses": + columns.Add(@"""NonceRevelationLosses"""); + break; + case "doublePreendorsingLosses": + columns.Add(@"""DoublePreendorsingLostStaked"""); + columns.Add(@"""DoublePreendorsingLostExternalStaked"""); + columns.Add(@"""DoublePreendorsingLostUnstaked"""); + columns.Add(@"""DoublePreendorsingLostExternalUnstaked"""); + break; + case "doubleEndorsingLosses": + columns.Add(@"""DoubleEndorsingLostStaked"""); + columns.Add(@"""DoubleEndorsingLostExternalStaked"""); + columns.Add(@"""DoubleEndorsingLostUnstaked"""); + columns.Add(@"""DoubleEndorsingLostExternalUnstaked"""); + break; + case "doubleBakingLosses": + columns.Add(@"""DoubleBakingLostStaked"""); + columns.Add(@"""DoubleBakingLostExternalStaked"""); + columns.Add(@"""DoubleBakingLostUnstaked"""); + columns.Add(@"""DoubleBakingLostExternalUnstaked"""); + break; + case "endorsementRewards": + columns.Add(@"""EndorsementRewardsLiquid"""); + columns.Add(@"""EndorsementRewardsStakedOwn"""); + columns.Add(@"""EndorsementRewardsStakedShared"""); + break; + case "blockRewards": + columns.Add(@"""BlockRewardsLiquid"""); + columns.Add(@"""BlockRewardsStakedOwn"""); + columns.Add(@"""BlockRewardsStakedShared"""); + break; + case "stakingBalance": + columns.Add(@"""OwnDelegatedBalance"""); + columns.Add(@"""ExternalDelegatedBalance"""); + columns.Add(@"""OwnStakedBalance"""); + columns.Add(@"""ExternalStakedBalance"""); + break; + case "activeStake": + columns.Add(@"""BakingPower"""); + break; + case "selectedStake": + columns.Add(@"""BakingPower"""); + break; + case "delegatedBalance": + columns.Add(@"""ExternalDelegatedBalance"""); + break; + case "numDelegators": + columns.Add(@"""DelegatorsCount"""); + break; + #endregion } } @@ -210,53 +254,41 @@ public async Task GetBakerRewards( { switch (fields[i]) { - case "activeStake": - foreach (var row in rows) - result[j++][i] = row.ActiveStake; - break; - case "selectedStake": - foreach (var row in rows) - result[j++][i] = row.SelectedStake; - break; - case "doubleBakingRewards": - foreach (var row in rows) - result[j++][i] = row.DoubleBakingRewards; - break; - case "doubleBakingLosses": + case "cycle": foreach (var row in rows) - result[j++][i] = row.DoubleBakingLosses; + result[j++][i] = row.Cycle; break; - case "doubleEndorsingRewards": + case "bakingPower": foreach (var row in rows) - result[j++][i] = row.DoubleEndorsingRewards; + result[j++][i] = row.BakingPower; break; - case "doubleEndorsingLosses": + case "totalBakingPower": foreach (var row in rows) - result[j++][i] = row.DoubleEndorsingLosses; + result[j++][i] = row.TotalBakingPower; break; - case "doublePreendorsingRewards": + case "ownDelegatedBalance": foreach (var row in rows) - result[j++][i] = row.DoublePreendorsingRewards; + result[j++][i] = row.OwnDelegatedBalance; break; - case "doublePreendorsingLosses": + case "externalDelegatedBalance": foreach (var row in rows) - result[j++][i] = row.DoublePreendorsingLosses; + result[j++][i] = row.ExternalDelegatedBalance; break; - case "cycle": + case "delegatorsCount": foreach (var row in rows) - result[j++][i] = row.Cycle; + result[j++][i] = row.DelegatorsCount; break; - case "delegatedBalance": + case "ownStakedBalance": foreach (var row in rows) - result[j++][i] = row.DelegatedBalance; + result[j++][i] = row.OwnStakedBalance; break; - case "endorsementRewards": + case "externalStakedBalance": foreach (var row in rows) - result[j++][i] = row.EndorsementRewards; + result[j++][i] = row.ExternalStakedBalance; break; - case "endorsements": + case "stakersCount": foreach (var row in rows) - result[j++][i] = row.Endorsements; + result[j++][i] = row.StakersCount; break; case "expectedBlocks": foreach (var row in rows) @@ -266,126 +298,354 @@ public async Task GetBakerRewards( foreach (var row in rows) result[j++][i] = Math.Round(row.ExpectedEndorsements, 2); break; + case "futureBlocks": + foreach (var row in rows) + result[j++][i] = row.FutureBlocks; + break; case "futureBlockRewards": foreach (var row in rows) result[j++][i] = row.FutureBlockRewards; break; - case "futureBlocks": + case "blocks": foreach (var row in rows) - result[j++][i] = row.FutureBlocks; + result[j++][i] = row.Blocks; break; - case "futureEndorsementRewards": + case "blockRewardsLiquid": foreach (var row in rows) - result[j++][i] = row.FutureEndorsementRewards; + result[j++][i] = row.BlockRewardsLiquid; + break; + case "blockRewardsStakedOwn": + foreach (var row in rows) + result[j++][i] = row.BlockRewardsStakedOwn; + break; + case "blockRewardsStakedShared": + foreach (var row in rows) + result[j++][i] = row.BlockRewardsStakedShared; + break; + case "missedBlocks": + foreach (var row in rows) + result[j++][i] = row.MissedBlocks; + break; + case "missedBlockRewards": + foreach (var row in rows) + result[j++][i] = row.MissedBlockRewards; break; case "futureEndorsements": foreach (var row in rows) result[j++][i] = row.FutureEndorsements; break; - case "missedEndorsementRewards": + case "futureEndorsementRewards": foreach (var row in rows) - result[j++][i] = row.MissedEndorsementRewards; + result[j++][i] = row.FutureEndorsementRewards; + break; + case "endorsements": + foreach (var row in rows) + result[j++][i] = row.Endorsements; + break; + case "endorsementRewardsLiquid": + foreach (var row in rows) + result[j++][i] = row.EndorsementRewardsLiquid; + break; + case "endorsementRewardsStakedOwn": + foreach (var row in rows) + result[j++][i] = row.EndorsementRewardsStakedOwn; + break; + case "endorsementRewardsStakedShared": + foreach (var row in rows) + result[j++][i] = row.EndorsementRewardsStakedShared; break; case "missedEndorsements": foreach (var row in rows) result[j++][i] = row.MissedEndorsements; break; + case "missedEndorsementRewards": + foreach (var row in rows) + result[j++][i] = row.MissedEndorsementRewards; + break; + case "blockFees": + foreach (var row in rows) + result[j++][i] = row.BlockFees; + break; case "missedBlockFees": foreach (var row in rows) result[j++][i] = row.MissedBlockFees; break; - case "missedBlockRewards": + case "doubleBakingRewards": foreach (var row in rows) - result[j++][i] = row.MissedBlockRewards; + result[j++][i] = row.DoubleBakingRewards; break; - case "missedBlocks": + case "doubleBakingLostStaked": foreach (var row in rows) - result[j++][i] = row.MissedBlocks; + result[j++][i] = row.DoubleBakingLostStaked; break; - case "numDelegators": + case "doubleBakingLostUnstaked": foreach (var row in rows) - result[j++][i] = row.DelegatorsCount; + result[j++][i] = row.DoubleBakingLostUnstaked; break; - case "blockFees": + case "doubleBakingLostExternalStaked": foreach (var row in rows) - result[j++][i] = row.BlockFees; + result[j++][i] = row.DoubleBakingLostExternalStaked; break; - case "blockRewards": + case "doubleBakingLostExternalUnstaked": foreach (var row in rows) - result[j++][i] = row.OwnRewards; + result[j++][i] = row.DoubleBakingLostExternalUnstaked; break; - case "blocks": + case "doubleEndorsingRewards": foreach (var row in rows) - result[j++][i] = row.Blocks; + result[j++][i] = row.DoubleEndorsingRewards; break; - case "revelationLosses": + case "doubleEndorsingLostStaked": foreach (var row in rows) - result[j++][i] = row.RevelationLosses; + result[j++][i] = row.DoubleEndorsingLostStaked; break; - case "revelationRewards": + case "doubleEndorsingLostUnstaked": foreach (var row in rows) - result[j++][i] = row.RevelationRewards; + result[j++][i] = row.DoubleEndorsingLostUnstaked; break; - case "stakingBalance": + case "doubleEndorsingLostExternalStaked": + foreach (var row in rows) + result[j++][i] = row.DoubleEndorsingLostExternalStaked; + break; + case "doubleEndorsingLostExternalUnstaked": + foreach (var row in rows) + result[j++][i] = row.DoubleEndorsingLostExternalUnstaked; + break; + case "doublePreendorsingRewards": + foreach (var row in rows) + result[j++][i] = row.DoublePreendorsingRewards; + break; + case "doublePreendorsingLostStaked": + foreach (var row in rows) + result[j++][i] = row.DoublePreendorsingLostStaked; + break; + case "doublePreendorsingLostUnstaked": + foreach (var row in rows) + result[j++][i] = row.DoublePreendorsingLostUnstaked; + break; + case "doublePreendorsingLostExternalStaked": + foreach (var row in rows) + result[j++][i] = row.DoublePreendorsingLostExternalStaked; + break; + case "doublePreendorsingLostExternalUnstaked": foreach (var row in rows) - result[j++][i] = row.StakingBalance; + result[j++][i] = row.DoublePreendorsingLostExternalUnstaked; + break; + case "vdfRevelationRewardsLiquid": + foreach (var row in rows) + result[j++][i] = row.VdfRevelationRewardsLiquid; + break; + case "vdfRevelationRewardsStakedOwn": + foreach (var row in rows) + result[j++][i] = row.VdfRevelationRewardsStakedOwn; + break; + case "vdfRevelationRewardsStakedShared": + foreach (var row in rows) + result[j++][i] = row.VdfRevelationRewardsStakedShared; + break; + case "nonceRevelationRewardsLiquid": + foreach (var row in rows) + result[j++][i] = row.NonceRevelationRewardsLiquid; + break; + case "nonceRevelationRewardsStakedOwn": + foreach (var row in rows) + result[j++][i] = row.NonceRevelationRewardsStakedOwn; + break; + case "nonceRevelationRewardsStakedShared": + foreach (var row in rows) + result[j++][i] = row.NonceRevelationRewardsStakedShared; + break; + case "nonceRevelationLosses": + foreach (var row in rows) + result[j++][i] = row.NonceRevelationLosses; break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, Protocols.FindByCycle((int)row.Cycle).GetCycleEnd((int)row.Cycle)); break; - } - } - return result; - } - - public async Task GetBakerRewards( - string address, - Int32Parameter cycle, - SortParameter sort, - OffsetParameter offset, - int limit, - string field, - Symbols quote) - { - if (await Accounts.GetAsync(address) is not RawDelegate baker) - return Array.Empty(); - - var columns = new HashSet(1); - switch (field) - { - case "activeStake": columns.Add(@"""ActiveStake"""); break; - case "selectedStake": columns.Add(@"""SelectedStake"""); break; - case "doubleBakingRewards": columns.Add(@"""DoubleBakingRewards"""); break; - case "doubleBakingLosses": columns.Add(@"""DoubleBakingLosses"""); break; - case "doubleEndorsingRewards": columns.Add(@"""DoubleEndorsingRewards"""); break; - case "doubleEndorsingLosses": columns.Add(@"""DoubleEndorsingLosses"""); break; - case "doublePreendorsingRewards": columns.Add(@"""DoublePreendorsingRewards"""); break; - case "doublePreendorsingLosses": columns.Add(@"""DoublePreendorsingLosses"""); break; - case "cycle": columns.Add(@"""Cycle"""); break; - case "delegatedBalance": columns.Add(@"""DelegatedBalance"""); break; - case "endorsementRewards": columns.Add(@"""EndorsementRewards"""); break; - case "endorsements": columns.Add(@"""Endorsements"""); break; - case "expectedBlocks": columns.Add(@"""ExpectedBlocks"""); break; - case "expectedEndorsements": columns.Add(@"""ExpectedEndorsements"""); break; - case "futureBlockRewards": columns.Add(@"""FutureBlockRewards"""); break; - case "futureBlocks": columns.Add(@"""FutureBlocks"""); break; - case "futureEndorsementRewards": columns.Add(@"""FutureEndorsementRewards"""); break; - case "futureEndorsements": columns.Add(@"""FutureEndorsements"""); break; - case "missedEndorsementRewards": columns.Add(@"""MissedEndorsementRewards"""); break; - case "missedEndorsements": columns.Add(@"""MissedEndorsements"""); break; - case "missedBlockFees": columns.Add(@"""MissedBlockFees"""); break; - case "missedBlockRewards": columns.Add(@"""MissedBlockRewards"""); break; + #region deprecated + case "revelationRewards": + foreach (var row in rows) + result[j++][i] = row.NonceRevelationRewardsLiquid + row.NonceRevelationRewardsStakedOwn + row.NonceRevelationRewardsStakedShared + row.VdfRevelationRewardsLiquid + row.VdfRevelationRewardsStakedOwn + row.VdfRevelationRewardsStakedShared; + break; + case "revelationLosses": + foreach (var row in rows) + result[j++][i] = row.NonceRevelationLosses; + break; + case "doublePreendorsingLosses": + foreach (var row in rows) + result[j++][i] = row.DoublePreendorsingLostStaked + row.DoublePreendorsingLostExternalStaked + row.DoublePreendorsingLostUnstaked + row.DoublePreendorsingLostExternalUnstaked; + break; + case "doubleEndorsingLosses": + foreach (var row in rows) + result[j++][i] = row.DoubleEndorsingLostStaked + row.DoubleEndorsingLostExternalStaked + row.DoubleEndorsingLostUnstaked + row.DoubleEndorsingLostExternalUnstaked; + break; + case "doubleBakingLosses": + foreach (var row in rows) + result[j++][i] = row.DoubleBakingLostStaked + row.DoubleBakingLostExternalStaked + row.DoubleBakingLostUnstaked + row.DoubleBakingLostExternalUnstaked; + break; + case "endorsementRewards": + foreach (var row in rows) + result[j++][i] = row.EndorsementRewardsLiquid + row.EndorsementRewardsStakedOwn + row.EndorsementRewardsStakedShared; + break; + case "blockRewards": + foreach (var row in rows) + result[j++][i] = row.BlockRewardsLiquid + row.BlockRewardsStakedOwn + row.BlockRewardsStakedShared; + break; + case "stakingBalance": + foreach (var row in rows) + result[j++][i] = row.OwnDelegatedBalance + row.ExternalDelegatedBalance + row.OwnStakedBalance + row.ExternalStakedBalance; + break; + case "activeStake": + foreach (var row in rows) + result[j++][i] = row.BakingPower; + break; + case "selectedStake": + foreach (var row in rows) + result[j++][i] = row.BakingPower; + break; + case "delegatedBalance": + foreach (var row in rows) + result[j++][i] = row.ExternalDelegatedBalance; + break; + case "numDelegators": + foreach (var row in rows) + result[j++][i] = row.DelegatorsCount; + break; + #endregion + } + } + + return result; + } + + public async Task GetBakerRewards( + string address, + Int32Parameter cycle, + SortParameter sort, + OffsetParameter offset, + int limit, + string field, + Symbols quote) + { + if (await Accounts.GetAsync(address) is not RawDelegate baker) + return Array.Empty(); + + var columns = new HashSet(1); + switch (field) + { + case "cycle": columns.Add(@"""Cycle"""); break; + case "bakingPower": columns.Add(@"""BakingPower"""); break; + case "totalBakingPower": columns.Add(@"""TotalBakingPower"""); break; + case "ownDelegatedBalance": columns.Add(@"""OwnDelegatedBalance"""); break; + case "externalDelegatedBalance": columns.Add(@"""ExternalDelegatedBalance"""); break; + case "delegatorsCount": columns.Add(@"""DelegatorsCount"""); break; + case "ownStakedBalance": columns.Add(@"""OwnStakedBalance"""); break; + case "externalStakedBalance": columns.Add(@"""ExternalStakedBalance"""); break; + case "stakersCount": columns.Add(@"""StakersCount"""); break; + case "expectedBlocks": columns.Add(@"""ExpectedBlocks"""); break; + case "expectedEndorsements": columns.Add(@"""ExpectedEndorsements"""); break; + case "futureBlocks": columns.Add(@"""FutureBlocks"""); break; + case "futureBlockRewards": columns.Add(@"""FutureBlockRewards"""); break; + case "blocks": columns.Add(@"""Blocks"""); break; + case "blockRewardsLiquid": columns.Add(@"""BlockRewardsLiquid"""); break; + case "blockRewardsStakedOwn": columns.Add(@"""BlockRewardsStakedOwn"""); break; + case "blockRewardsStakedShared": columns.Add(@"""BlockRewardsStakedShared"""); break; case "missedBlocks": columns.Add(@"""MissedBlocks"""); break; - case "numDelegators": columns.Add(@"""DelegatorsCount"""); break; + case "missedBlockRewards": columns.Add(@"""MissedBlockRewards"""); break; + case "futureEndorsements": columns.Add(@"""FutureEndorsements"""); break; + case "futureEndorsementRewards": columns.Add(@"""FutureEndorsementRewards"""); break; + case "endorsements": columns.Add(@"""Endorsements"""); break; + case "endorsementRewardsLiquid": columns.Add(@"""EndorsementRewardsLiquid"""); break; + case "endorsementRewardsStakedOwn": columns.Add(@"""EndorsementRewardsStakedOwn"""); break; + case "endorsementRewardsStakedShared": columns.Add(@"""EndorsementRewardsStakedShared"""); break; + case "missedEndorsements": columns.Add(@"""MissedEndorsements"""); break; + case "missedEndorsementRewards": columns.Add(@"""MissedEndorsementRewards"""); break; case "blockFees": columns.Add(@"""BlockFees"""); break; - case "blockRewards": columns.Add(@"""BlockRewards"""); break; - case "blocks": columns.Add(@"""Blocks"""); break; - case "revelationLosses": columns.Add(@"""RevelationLosses"""); break; - case "revelationRewards": columns.Add(@"""RevelationRewards"""); break; - case "stakingBalance": columns.Add(@"""StakingBalance"""); break; + case "missedBlockFees": columns.Add(@"""MissedBlockFees"""); break; + case "doubleBakingRewards": columns.Add(@"""DoubleBakingRewards"""); break; + case "doubleBakingLostStaked": columns.Add(@"""DoubleBakingLostStaked"""); break; + case "doubleBakingLostUnstaked": columns.Add(@"""DoubleBakingLostUnstaked"""); break; + case "doubleBakingLostExternalStaked": columns.Add(@"""DoubleBakingLostExternalStaked"""); break; + case "doubleBakingLostExternalUnstaked": columns.Add(@"""DoubleBakingLostExternalUnstaked"""); break; + case "doubleEndorsingRewards": columns.Add(@"""DoubleEndorsingRewards"""); break; + case "doubleEndorsingLostStaked": columns.Add(@"""DoubleEndorsingLostStaked"""); break; + case "doubleEndorsingLostUnstaked": columns.Add(@"""DoubleEndorsingLostUnstaked"""); break; + case "doubleEndorsingLostExternalStaked": columns.Add(@"""DoubleEndorsingLostExternalStaked"""); break; + case "doubleEndorsingLostExternalUnstaked": columns.Add(@"""DoubleEndorsingLostExternalUnstaked"""); break; + case "doublePreendorsingRewards": columns.Add(@"""DoublePreendorsingRewards"""); break; + case "doublePreendorsingLostStaked": columns.Add(@"""DoublePreendorsingLostStaked"""); break; + case "doublePreendorsingLostUnstaked": columns.Add(@"""DoublePreendorsingLostUnstaked"""); break; + case "doublePreendorsingLostExternalStaked": columns.Add(@"""DoublePreendorsingLostExternalStaked"""); break; + case "doublePreendorsingLostExternalUnstaked": columns.Add(@"""DoublePreendorsingLostExternalUnstaked"""); break; + case "vdfRevelationRewardsLiquid": columns.Add(@"""VdfRevelationRewardsLiquid"""); break; + case "vdfRevelationRewardsStakedOwn": columns.Add(@"""VdfRevelationRewardsStakedOwn"""); break; + case "vdfRevelationRewardsStakedShared": columns.Add(@"""VdfRevelationRewardsStakedShared"""); break; + case "nonceRevelationRewardsLiquid": columns.Add(@"""NonceRevelationRewardsLiquid"""); break; + case "nonceRevelationRewardsStakedOwn": columns.Add(@"""NonceRevelationRewardsStakedOwn"""); break; + case "nonceRevelationRewardsStakedShared": columns.Add(@"""NonceRevelationRewardsStakedShared"""); break; + case "nonceRevelationLosses": columns.Add(@"""NonceRevelationLosses"""); break; case "quote": columns.Add(@"""Cycle"""); break; + + #region deprecated + case "revelationRewards": + columns.Add(@"""NonceRevelationRewardsLiquid"""); + columns.Add(@"""NonceRevelationRewardsStakedOwn"""); + columns.Add(@"""NonceRevelationRewardsStakedShared"""); + columns.Add(@"""VdfRevelationRewardsLiquid"""); + columns.Add(@"""VdfRevelationRewardsStakedOwn"""); + columns.Add(@"""VdfRevelationRewardsStakedShared"""); + break; + case "revelationLosses": + columns.Add(@"""NonceRevelationLosses"""); + break; + case "doublePreendorsingLosses": + columns.Add(@"""DoublePreendorsingLostStaked"""); + columns.Add(@"""DoublePreendorsingLostExternalStaked"""); + columns.Add(@"""DoublePreendorsingLostUnstaked"""); + columns.Add(@"""DoublePreendorsingLostExternalUnstaked"""); + break; + case "doubleEndorsingLosses": + columns.Add(@"""DoubleEndorsingLostStaked"""); + columns.Add(@"""DoubleEndorsingLostExternalStaked"""); + columns.Add(@"""DoubleEndorsingLostUnstaked"""); + columns.Add(@"""DoubleEndorsingLostExternalUnstaked"""); + break; + case "doubleBakingLosses": + columns.Add(@"""DoubleBakingLostStaked"""); + columns.Add(@"""DoubleBakingLostExternalStaked"""); + columns.Add(@"""DoubleBakingLostUnstaked"""); + columns.Add(@"""DoubleBakingLostExternalUnstaked"""); + break; + case "endorsementRewards": + columns.Add(@"""EndorsementRewardsLiquid"""); + columns.Add(@"""EndorsementRewardsStakedOwn"""); + columns.Add(@"""EndorsementRewardsStakedShared"""); + break; + case "blockRewards": + columns.Add(@"""BlockRewardsLiquid"""); + columns.Add(@"""BlockRewardsStakedOwn"""); + columns.Add(@"""BlockRewardsStakedShared"""); + break; + case "stakingBalance": + columns.Add(@"""OwnDelegatedBalance"""); + columns.Add(@"""ExternalDelegatedBalance"""); + columns.Add(@"""OwnStakedBalance"""); + columns.Add(@"""ExternalStakedBalance"""); + break; + case "activeStake": + columns.Add(@"""BakingPower"""); + break; + case "selectedStake": + columns.Add(@"""BakingPower"""); + break; + case "delegatedBalance": + columns.Add(@"""ExternalDelegatedBalance"""); + break; + case "numDelegators": + columns.Add(@"""DelegatorsCount"""); + break; + #endregion } if (columns.Count == 0) @@ -405,53 +665,41 @@ public async Task GetBakerRewards( switch (field) { - case "activeStake": - foreach (var row in rows) - result[j++] = row.ActiveStake; - break; - case "selectedStake": + case "cycle": foreach (var row in rows) - result[j++] = row.SelectedStake; + result[j++] = row.Cycle; break; - case "doubleBakingRewards": + case "bakingPower": foreach (var row in rows) - result[j++] = row.DoubleBakingRewards; + result[j++] = row.BakingPower; break; - case "doubleBakingLosses": + case "totalBakingPower": foreach (var row in rows) - result[j++] = row.DoubleBakingLosses; + result[j++] = row.TotalBakingPower; break; - case "doubleEndorsingRewards": + case "ownDelegatedBalance": foreach (var row in rows) - result[j++] = row.DoubleEndorsingRewards; + result[j++] = row.OwnDelegatedBalance; break; - case "doubleEndorsingLosses": + case "externalDelegatedBalance": foreach (var row in rows) - result[j++] = row.DoubleEndorsingLosses; + result[j++] = row.ExternalDelegatedBalance; break; - case "doublePreendorsingRewards": + case "delegatorsCount": foreach (var row in rows) - result[j++] = row.DoublePreendorsingRewards; - break; - case "doublePreendorsingLosses": - foreach (var row in rows) - result[j++] = row.DoublePreendorsingLosses; - break; - case "cycle": - foreach (var row in rows) - result[j++] = row.Cycle; + result[j++] = row.DelegatorsCount; break; - case "delegatedBalance": + case "ownStakedBalance": foreach (var row in rows) - result[j++] = row.DelegatedBalance; + result[j++] = row.OwnStakedBalance; break; - case "endorsementRewards": + case "externalStakedBalance": foreach (var row in rows) - result[j++] = row.EndorsementRewards; + result[j++] = row.ExternalStakedBalance; break; - case "endorsements": + case "stakersCount": foreach (var row in rows) - result[j++] = row.Endorsements; + result[j++] = row.StakersCount; break; case "expectedBlocks": foreach (var row in rows) @@ -461,74 +709,221 @@ public async Task GetBakerRewards( foreach (var row in rows) result[j++] = Math.Round(row.ExpectedEndorsements, 2); break; + case "futureBlocks": + foreach (var row in rows) + result[j++] = row.FutureBlocks; + break; case "futureBlockRewards": foreach (var row in rows) result[j++] = row.FutureBlockRewards; break; - case "futureBlocks": + case "blocks": foreach (var row in rows) - result[j++] = row.FutureBlocks; + result[j++] = row.Blocks; break; - case "futureEndorsementRewards": + case "blockRewardsLiquid": foreach (var row in rows) - result[j++] = row.FutureEndorsementRewards; + result[j++] = row.BlockRewardsLiquid; + break; + case "blockRewardsStakedOwn": + foreach (var row in rows) + result[j++] = row.BlockRewardsStakedOwn; + break; + case "blockRewardsStakedShared": + foreach (var row in rows) + result[j++] = row.BlockRewardsStakedShared; + break; + case "missedBlocks": + foreach (var row in rows) + result[j++] = row.MissedBlocks; + break; + case "missedBlockRewards": + foreach (var row in rows) + result[j++] = row.MissedBlockRewards; break; case "futureEndorsements": foreach (var row in rows) result[j++] = row.FutureEndorsements; break; - case "missedEndorsementRewards": + case "futureEndorsementRewards": foreach (var row in rows) - result[j++] = row.MissedEndorsementRewards; + result[j++] = row.FutureEndorsementRewards; + break; + case "endorsements": + foreach (var row in rows) + result[j++] = row.Endorsements; + break; + case "endorsementRewardsLiquid": + foreach (var row in rows) + result[j++] = row.EndorsementRewardsLiquid; + break; + case "endorsementRewardsStakedOwn": + foreach (var row in rows) + result[j++] = row.EndorsementRewardsStakedOwn; + break; + case "endorsementRewardsStakedShared": + foreach (var row in rows) + result[j++] = row.EndorsementRewardsStakedShared; break; case "missedEndorsements": foreach (var row in rows) result[j++] = row.MissedEndorsements; break; + case "missedEndorsementRewards": + foreach (var row in rows) + result[j++] = row.MissedEndorsementRewards; + break; + case "blockFees": + foreach (var row in rows) + result[j++] = row.BlockFees; + break; case "missedBlockFees": foreach (var row in rows) result[j++] = row.MissedBlockFees; break; - case "missedBlockRewards": + case "doubleBakingRewards": foreach (var row in rows) - result[j++] = row.MissedBlockRewards; + result[j++] = row.DoubleBakingRewards; break; - case "missedBlocks": + case "doubleBakingLostStaked": foreach (var row in rows) - result[j++] = row.MissedBlocks; + result[j++] = row.DoubleBakingLostStaked; break; - case "numDelegators": + case "doubleBakingLostUnstaked": foreach (var row in rows) - result[j++] = row.DelegatorsCount; + result[j++] = row.DoubleBakingLostUnstaked; break; - case "blockFees": + case "doubleBakingLostExternalStaked": foreach (var row in rows) - result[j++] = row.BlockFees; + result[j++] = row.DoubleBakingLostExternalStaked; break; - case "blockRewards": + case "doubleBakingLostExternalUnstaked": foreach (var row in rows) - result[j++] = row.BlockRewards; + result[j++] = row.DoubleBakingLostExternalUnstaked; break; - case "blocks": + case "doubleEndorsingRewards": foreach (var row in rows) - result[j++] = row.Blocks; + result[j++] = row.DoubleEndorsingRewards; break; - case "revelationLosses": + case "doubleEndorsingLostStaked": foreach (var row in rows) - result[j++] = row.RevelationLosses; + result[j++] = row.DoubleEndorsingLostStaked; break; - case "revelationRewards": + case "doubleEndorsingLostUnstaked": foreach (var row in rows) - result[j++] = row.RevelationRewards; + result[j++] = row.DoubleEndorsingLostUnstaked; break; - case "stakingBalance": + case "doubleEndorsingLostExternalStaked": + foreach (var row in rows) + result[j++] = row.DoubleEndorsingLostExternalStaked; + break; + case "doubleEndorsingLostExternalUnstaked": + foreach (var row in rows) + result[j++] = row.DoubleEndorsingLostExternalUnstaked; + break; + case "doublePreendorsingRewards": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingRewards; + break; + case "doublePreendorsingLostStaked": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostStaked; + break; + case "doublePreendorsingLostUnstaked": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostUnstaked; + break; + case "doublePreendorsingLostExternalStaked": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostExternalStaked; + break; + case "doublePreendorsingLostExternalUnstaked": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostExternalUnstaked; + break; + case "vdfRevelationRewardsLiquid": + foreach (var row in rows) + result[j++] = row.VdfRevelationRewardsLiquid; + break; + case "vdfRevelationRewardsStakedOwn": + foreach (var row in rows) + result[j++] = row.VdfRevelationRewardsStakedOwn; + break; + case "vdfRevelationRewardsStakedShared": foreach (var row in rows) - result[j++] = row.StakingBalance; + result[j++] = row.VdfRevelationRewardsStakedShared; + break; + case "nonceRevelationRewardsLiquid": + foreach (var row in rows) + result[j++] = row.NonceRevelationRewardsLiquid; + break; + case "nonceRevelationRewardsStakedOwn": + foreach (var row in rows) + result[j++] = row.NonceRevelationRewardsStakedOwn; + break; + case "nonceRevelationRewardsStakedShared": + foreach (var row in rows) + result[j++] = row.NonceRevelationRewardsStakedShared; + break; + case "nonceRevelationLosses": + foreach (var row in rows) + result[j++] = row.NonceRevelationLosses; break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, Protocols.FindByCycle((int)row.Cycle).GetCycleEnd((int)row.Cycle)); break; + + #region deprecated + case "revelationRewards": + foreach (var row in rows) + result[j++] = row.NonceRevelationRewardsLiquid + row.NonceRevelationRewardsStakedOwn + row.NonceRevelationRewardsStakedShared + row.VdfRevelationRewardsLiquid + row.VdfRevelationRewardsStakedOwn + row.VdfRevelationRewardsStakedShared; + break; + case "revelationLosses": + foreach (var row in rows) + result[j++] = row.NonceRevelationLosses; + break; + case "doublePreendorsingLosses": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostStaked + row.DoublePreendorsingLostExternalStaked + row.DoublePreendorsingLostUnstaked + row.DoublePreendorsingLostExternalUnstaked; + break; + case "doubleEndorsingLosses": + foreach (var row in rows) + result[j++] = row.DoubleEndorsingLostStaked + row.DoubleEndorsingLostExternalStaked + row.DoubleEndorsingLostUnstaked + row.DoubleEndorsingLostExternalUnstaked; + break; + case "doubleBakingLosses": + foreach (var row in rows) + result[j++] = row.DoubleBakingLostStaked + row.DoubleBakingLostExternalStaked + row.DoubleBakingLostUnstaked + row.DoubleBakingLostExternalUnstaked; + break; + case "endorsementRewards": + foreach (var row in rows) + result[j++] = row.EndorsementRewardsLiquid + row.EndorsementRewardsStakedOwn + row.EndorsementRewardsStakedShared; + break; + case "blockRewards": + foreach (var row in rows) + result[j++] = row.BlockRewardsLiquid + row.BlockRewardsStakedOwn + row.BlockRewardsStakedShared; + break; + case "stakingBalance": + foreach (var row in rows) + result[j++] = row.OwnDelegatedBalance + row.ExternalDelegatedBalance + row.OwnStakedBalance + row.ExternalStakedBalance; + break; + case "activeStake": + foreach (var row in rows) + result[j++] = row.BakingPower; + break; + case "selectedStake": + foreach (var row in rows) + result[j++] = row.BakingPower; + break; + case "delegatedBalance": + foreach (var row in rows) + result[j++] = row.ExternalDelegatedBalance; + break; + case "numDelegators": + foreach (var row in rows) + result[j++] = row.DelegatorsCount; + break; + #endregion } return result; @@ -545,61 +940,6 @@ public async Task GetDelegatorRewardsCount(string address) return await db.QueryFirstAsync($@"SELECT COUNT(*) FROM ""DelegatorCycles"" WHERE ""DelegatorId"" = {acc.Id}"); } - public async Task GetDelegatorRewards(string address, int cycle, Symbols quote) - { - var acc = await Accounts.GetAsync(address); - if (acc == null) return null; - - var sql = $@" - SELECT bc.*, dc.""Balance"" - FROM ""DelegatorCycles"" as dc - INNER JOIN ""BakerCycles"" as bc - ON bc.""BakerId"" = dc.""BakerId"" - AND bc.""Cycle"" = dc.""Cycle"" - WHERE dc.""DelegatorId"" = {acc.Id} - AND dc.""Cycle"" = {cycle} - LIMIT 1"; - - using var db = GetConnection(); - var row = await db.QueryFirstOrDefaultAsync(sql); - if (row == null) return null; - - return new DelegatorRewards - { - Baker = Accounts.GetAlias(row.BakerId), - Balance = row.Balance, - ActiveStake = row.ActiveStake, - SelectedStake = row.SelectedStake, - DoubleBakingRewards = row.DoubleBakingRewards, - DoubleBakingLosses = row.DoubleBakingLosses, - DoubleEndorsingRewards = row.DoubleEndorsingRewards, - DoubleEndorsingLosses = row.DoubleEndorsingLosses, - DoublePreendorsingRewards = row.DoublePreendorsingRewards, - DoublePreendorsingLosses = row.DoublePreendorsingLosses, - Cycle = row.Cycle, - EndorsementRewards = row.EndorsementRewards, - Endorsements = row.Endorsements, - ExpectedBlocks = Math.Round(row.ExpectedBlocks, 2), - ExpectedEndorsements = Math.Round(row.ExpectedEndorsements, 2), - FutureBlockRewards = row.FutureBlockRewards, - FutureBlocks = row.FutureBlocks, - FutureEndorsementRewards = row.FutureEndorsementRewards, - FutureEndorsements = row.FutureEndorsements, - MissedEndorsementRewards = row.MissedEndorsementRewards, - MissedEndorsements = row.MissedEndorsements, - MissedBlockFees = row.MissedBlockFees, - MissedBlockRewards = row.MissedBlockRewards, - MissedBlocks = row.MissedBlocks, - BlockFees = row.BlockFees, - BlockRewards = row.BlockRewards, - Blocks = row.Blocks, - RevelationLosses = row.RevelationLosses, - RevelationRewards = row.RevelationRewards, - StakingBalance = row.StakingBalance, - Quote = Quotes.Get(quote, Protocols.FindByCycle((int)row.Cycle).GetCycleEnd((int)row.Cycle)) - }; - } - public async Task> GetDelegatorRewards( string address, Int32Parameter cycle, @@ -611,13 +951,13 @@ public async Task> GetDelegatorRewards( var acc = await Accounts.GetAsync(address); if (acc == null) return Enumerable.Empty(); - var sql = new SqlBuilder(@" - SELECT bc.*, dc.""Balance"" - FROM ""DelegatorCycles"" as dc - INNER JOIN ""BakerCycles"" as bc - ON bc.""BakerId"" = dc.""BakerId"" - AND bc.""Cycle"" = dc.""Cycle"" - ") + var sql = new SqlBuilder(""" + SELECT bc.*, dc."DelegatedBalance", dc."StakedBalance" + FROM "DelegatorCycles" as dc + INNER JOIN "BakerCycles" as bc + ON bc."BakerId" = dc."BakerId" + AND bc."Cycle" = dc."Cycle" + """) .FilterA(@"dc.""DelegatorId""", acc.Id) .FilterA(@"dc.""Cycle""", cycle) .Take(sort ?? new SortParameter { Desc = "cycle" }, offset, limit, x => ("Cycle", "Cycle"), "dc"); @@ -627,36 +967,58 @@ INNER JOIN ""BakerCycles"" as bc return rows.Select(row => new DelegatorRewards { - Baker = Accounts.GetAlias(row.BakerId), - Balance = row.Balance, - ActiveStake = row.ActiveStake, - SelectedStake = row.SelectedStake, - DoubleBakingRewards = row.DoubleBakingRewards, - DoubleBakingLosses = row.DoubleBakingLosses, - DoubleEndorsingRewards = row.DoubleEndorsingRewards, - DoubleEndorsingLosses = row.DoubleEndorsingLosses, - DoublePreendorsingRewards = row.DoublePreendorsingRewards, - DoublePreendorsingLosses = row.DoublePreendorsingLosses, Cycle = row.Cycle, - EndorsementRewards = row.EndorsementRewards, - Endorsements = row.Endorsements, + DelegatedBalance = row.DelegatedBalance, + StakedBalance = row.StakedBalance, + Baker = Accounts.GetAlias(row.BakerId), + BakingPower = row.BakingPower, + TotalBakingPower = row.TotalBakingPower, + BakerDelegatedBalance = row.OwnDelegatedBalance, + ExternalDelegatedBalance = row.ExternalDelegatedBalance, + BakerStakedBalance = row.OwnStakedBalance, + ExternalStakedBalance = row.ExternalStakedBalance, ExpectedBlocks = Math.Round(row.ExpectedBlocks, 2), ExpectedEndorsements = Math.Round(row.ExpectedEndorsements, 2), - FutureBlockRewards = row.FutureBlockRewards, FutureBlocks = row.FutureBlocks, - FutureEndorsementRewards = row.FutureEndorsementRewards, + FutureBlockRewards = row.FutureBlockRewards, + Blocks = row.Blocks, + BlockRewardsLiquid = row.BlockRewardsLiquid, + BlockRewardsStakedOwn = row.BlockRewardsStakedOwn, + BlockRewardsStakedShared = row.BlockRewardsStakedShared, + MissedBlocks = row.MissedBlocks, + MissedBlockRewards = row.MissedBlockRewards, FutureEndorsements = row.FutureEndorsements, - MissedEndorsementRewards = row.MissedEndorsementRewards, + FutureEndorsementRewards = row.FutureEndorsementRewards, + Endorsements = row.Endorsements, + EndorsementRewardsLiquid = row.EndorsementRewardsLiquid, + EndorsementRewardsStakedOwn = row.EndorsementRewardsStakedOwn, + EndorsementRewardsStakedShared = row.EndorsementRewardsStakedShared, MissedEndorsements = row.MissedEndorsements, - MissedBlockFees = row.MissedBlockFees, - MissedBlockRewards = row.MissedBlockRewards, - MissedBlocks = row.MissedBlocks, + MissedEndorsementRewards = row.MissedEndorsementRewards, BlockFees = row.BlockFees, - BlockRewards = row.BlockRewards, - Blocks = row.Blocks, - RevelationLosses = row.RevelationLosses, - RevelationRewards = row.RevelationRewards, - StakingBalance = row.StakingBalance, + MissedBlockFees = row.MissedBlockFees, + DoubleBakingRewards = row.DoubleBakingRewards, + DoubleBakingLostStaked = row.DoubleBakingLostStaked, + DoubleBakingLostUnstaked = row.DoubleBakingLostUnstaked, + DoubleBakingLostExternalStaked = row.DoubleBakingLostExternalStaked, + DoubleBakingLostExternalUnstaked = row.DoubleBakingLostExternalUnstaked, + DoubleEndorsingRewards = row.DoubleEndorsingRewards, + DoubleEndorsingLostStaked = row.DoubleEndorsingLostStaked, + DoubleEndorsingLostUnstaked = row.DoubleEndorsingLostUnstaked, + DoubleEndorsingLostExternalStaked = row.DoubleEndorsingLostExternalStaked, + DoubleEndorsingLostExternalUnstaked = row.DoubleEndorsingLostExternalUnstaked, + DoublePreendorsingRewards = row.DoublePreendorsingRewards, + DoublePreendorsingLostStaked = row.DoublePreendorsingLostStaked, + DoublePreendorsingLostUnstaked = row.DoublePreendorsingLostUnstaked, + DoublePreendorsingLostExternalStaked = row.DoublePreendorsingLostExternalStaked, + DoublePreendorsingLostExternalUnstaked = row.DoublePreendorsingLostExternalUnstaked, + VdfRevelationRewardsLiquid = row.VdfRevelationRewardsLiquid, + VdfRevelationRewardsStakedOwn = row.VdfRevelationRewardsStakedOwn, + VdfRevelationRewardsStakedShared = row.VdfRevelationRewardsStakedShared, + NonceRevelationRewardsLiquid = row.NonceRevelationRewardsLiquid, + NonceRevelationRewardsStakedOwn = row.NonceRevelationRewardsStakedOwn, + NonceRevelationRewardsStakedShared = row.NonceRevelationRewardsStakedShared, + NonceRevelationLosses = row.NonceRevelationLosses, Quote = Quotes.Get(quote, Protocols.FindByCycle((int)row.Cycle).GetCycleEnd((int)row.Cycle)) }); } @@ -674,54 +1036,134 @@ public async Task GetDelegatorRewards( if (acc == null) return Array.Empty(); var columns = new HashSet(fields.Length); - var join = false; - foreach (var field in fields) { switch (field) { + case "cycle": columns.Add(@"""Cycle"""); break; + case "delegatedBalance": columns.Add(@"dc.""DelegatedBalance"""); break; + case "stakedBalance": columns.Add(@"dc.""StakedBalance"""); break; case "baker": columns.Add(@"dc.""BakerId"""); break; - case "balance": columns.Add(@"dc.""Balance"""); break; - case "cycle": columns.Add(@"dc.""Cycle"""); break; - case "quote": columns.Add(@"dc.""Cycle"""); break; - case "activeStake": columns.Add(@"bc.""ActiveStake"""); join = true; break; - case "selectedStake": columns.Add(@"bc.""SelectedStake"""); join = true; break; - case "doubleBakingRewards": columns.Add(@"bc.""DoubleBakingRewards"""); join = true; break; - case "doubleBakingLosses": columns.Add(@"bc.""DoubleBakingLosses"""); join = true; break; - case "doubleEndorsingRewards": columns.Add(@"bc.""DoubleEndorsingRewards"""); join = true; break; - case "doubleEndorsingLosses": columns.Add(@"bc.""DoubleEndorsingLosses"""); join = true; break; - case "doublePreendorsingRewards": columns.Add(@"bc.""DoublePreendorsingRewards"""); join = true; break; - case "doublePreendorsingLosses": columns.Add(@"bc.""DoublePreendorsingLosses"""); join = true; break; - case "endorsementRewards": columns.Add(@"bc.""EndorsementRewards"""); join = true; break; - case "endorsements": columns.Add(@"bc.""Endorsements"""); join = true; break; - case "expectedBlocks": columns.Add(@"bc.""ExpectedBlocks"""); join = true; break; - case "expectedEndorsements": columns.Add(@"bc.""ExpectedEndorsements"""); join = true; break; - case "futureBlockRewards": columns.Add(@"bc.""FutureBlockRewards"""); join = true; break; - case "futureBlocks": columns.Add(@"bc.""FutureBlocks"""); join = true; break; - case "futureEndorsementRewards": columns.Add(@"bc.""FutureEndorsementRewards"""); join = true; break; - case "futureEndorsements": columns.Add(@"bc.""FutureEndorsements"""); join = true; break; - case "missedEndorsementRewards": columns.Add(@"bc.""MissedEndorsementRewards"""); join = true; break; - case "missedEndorsements": columns.Add(@"bc.""MissedEndorsements"""); join = true; break; - case "missedBlockFees": columns.Add(@"bc.""MissedBlockFees"""); join = true; break; - case "missedBlockRewards": columns.Add(@"bc.""MissedBlockRewards"""); join = true; break; - case "missedBlocks": columns.Add(@"bc.""MissedBlocks"""); join = true; break; - case "blockFees": columns.Add(@"bc.""BlockFees"""); join = true; break; - case "blockRewards": columns.Add(@"bc.""BlockRewards"""); join = true; break; - case "blocks": columns.Add(@"bc.""Blocks"""); join = true; break; - case "revelationLosses": columns.Add(@"bc.""RevelationLosses"""); join = true; break; - case "revelationRewards": columns.Add(@"bc.""RevelationRewards"""); join = true; break; - case "stakingBalance": columns.Add(@"bc.""StakingBalance"""); join = true; break; + case "bakingPower": columns.Add(@"""BakingPower"""); break; + case "totalBakingPower": columns.Add(@"""TotalBakingPower"""); break; + case "bakerDelegatedBalance": columns.Add(@"""OwnDelegatedBalance"""); break; + case "externalDelegatedBalance": columns.Add(@"""ExternalDelegatedBalance"""); break; + case "bakerStakedBalance": columns.Add(@"""OwnStakedBalance"""); break; + case "externalStakedBalance": columns.Add(@"""ExternalStakedBalance"""); break; + case "expectedBlocks": columns.Add(@"""ExpectedBlocks"""); break; + case "expectedEndorsements": columns.Add(@"""ExpectedEndorsements"""); break; + case "futureBlocks": columns.Add(@"""FutureBlocks"""); break; + case "futureBlockRewards": columns.Add(@"""FutureBlockRewards"""); break; + case "blocks": columns.Add(@"""Blocks"""); break; + case "blockRewardsLiquid": columns.Add(@"""BlockRewardsLiquid"""); break; + case "blockRewardsStakedOwn": columns.Add(@"""BlockRewardsStakedOwn"""); break; + case "blockRewardsStakedShared": columns.Add(@"""BlockRewardsStakedShared"""); break; + case "missedBlocks": columns.Add(@"""MissedBlocks"""); break; + case "missedBlockRewards": columns.Add(@"""MissedBlockRewards"""); break; + case "futureEndorsements": columns.Add(@"""FutureEndorsements"""); break; + case "futureEndorsementRewards": columns.Add(@"""FutureEndorsementRewards"""); break; + case "endorsements": columns.Add(@"""Endorsements"""); break; + case "endorsementRewardsLiquid": columns.Add(@"""EndorsementRewardsLiquid"""); break; + case "endorsementRewardsStakedOwn": columns.Add(@"""EndorsementRewardsStakedOwn"""); break; + case "endorsementRewardsStakedShared": columns.Add(@"""EndorsementRewardsStakedShared"""); break; + case "missedEndorsements": columns.Add(@"""MissedEndorsements"""); break; + case "missedEndorsementRewards": columns.Add(@"""MissedEndorsementRewards"""); break; + case "blockFees": columns.Add(@"""BlockFees"""); break; + case "missedBlockFees": columns.Add(@"""MissedBlockFees"""); break; + case "doubleBakingRewards": columns.Add(@"""DoubleBakingRewards"""); break; + case "doubleBakingLostStaked": columns.Add(@"""DoubleBakingLostStaked"""); break; + case "doubleBakingLostUnstaked": columns.Add(@"""DoubleBakingLostUnstaked"""); break; + case "doubleBakingLostExternalStaked": columns.Add(@"""DoubleBakingLostExternalStaked"""); break; + case "doubleBakingLostExternalUnstaked": columns.Add(@"""DoubleBakingLostExternalUnstaked"""); break; + case "doubleEndorsingRewards": columns.Add(@"""DoubleEndorsingRewards"""); break; + case "doubleEndorsingLostStaked": columns.Add(@"""DoubleEndorsingLostStaked"""); break; + case "doubleEndorsingLostUnstaked": columns.Add(@"""DoubleEndorsingLostUnstaked"""); break; + case "doubleEndorsingLostExternalStaked": columns.Add(@"""DoubleEndorsingLostExternalStaked"""); break; + case "doubleEndorsingLostExternalUnstaked": columns.Add(@"""DoubleEndorsingLostExternalUnstaked"""); break; + case "doublePreendorsingRewards": columns.Add(@"""DoublePreendorsingRewards"""); break; + case "doublePreendorsingLostStaked": columns.Add(@"""DoublePreendorsingLostStaked"""); break; + case "doublePreendorsingLostUnstaked": columns.Add(@"""DoublePreendorsingLostUnstaked"""); break; + case "doublePreendorsingLostExternalStaked": columns.Add(@"""DoublePreendorsingLostExternalStaked"""); break; + case "doublePreendorsingLostExternalUnstaked": columns.Add(@"""DoublePreendorsingLostExternalUnstaked"""); break; + case "vdfRevelationRewardsLiquid": columns.Add(@"""VdfRevelationRewardsLiquid"""); break; + case "vdfRevelationRewardsStakedOwn": columns.Add(@"""VdfRevelationRewardsStakedOwn"""); break; + case "vdfRevelationRewardsStakedShared": columns.Add(@"""VdfRevelationRewardsStakedShared"""); break; + case "nonceRevelationRewardsLiquid": columns.Add(@"""NonceRevelationRewardsLiquid"""); break; + case "nonceRevelationRewardsStakedOwn": columns.Add(@"""NonceRevelationRewardsStakedOwn"""); break; + case "nonceRevelationRewardsStakedShared": columns.Add(@"""NonceRevelationRewardsStakedShared"""); break; + case "nonceRevelationLosses": columns.Add(@"""NonceRevelationLosses"""); break; + case "quote": columns.Add(@"""Cycle"""); break; + + #region deprecated + case "revelationRewards": + columns.Add(@"""NonceRevelationRewardsLiquid"""); + columns.Add(@"""NonceRevelationRewardsStakedOwn"""); + columns.Add(@"""NonceRevelationRewardsStakedShared"""); + columns.Add(@"""VdfRevelationRewardsLiquid"""); + columns.Add(@"""VdfRevelationRewardsStakedOwn"""); + columns.Add(@"""VdfRevelationRewardsStakedShared"""); + break; + case "revelationLosses": + columns.Add(@"""NonceRevelationLosses"""); + break; + case "doublePreendorsingLosses": + columns.Add(@"""DoublePreendorsingLostStaked"""); + columns.Add(@"""DoublePreendorsingLostExternalStaked"""); + columns.Add(@"""DoublePreendorsingLostUnstaked"""); + columns.Add(@"""DoublePreendorsingLostExternalUnstaked"""); + break; + case "doubleEndorsingLosses": + columns.Add(@"""DoubleEndorsingLostStaked"""); + columns.Add(@"""DoubleEndorsingLostExternalStaked"""); + columns.Add(@"""DoubleEndorsingLostUnstaked"""); + columns.Add(@"""DoubleEndorsingLostExternalUnstaked"""); + break; + case "doubleBakingLosses": + columns.Add(@"""DoubleBakingLostStaked"""); + columns.Add(@"""DoubleBakingLostExternalStaked"""); + columns.Add(@"""DoubleBakingLostUnstaked"""); + columns.Add(@"""DoubleBakingLostExternalUnstaked"""); + break; + case "endorsementRewards": + columns.Add(@"""EndorsementRewardsLiquid"""); + columns.Add(@"""EndorsementRewardsStakedOwn"""); + columns.Add(@"""EndorsementRewardsStakedShared"""); + break; + case "blockRewards": + columns.Add(@"""BlockRewardsLiquid"""); + columns.Add(@"""BlockRewardsStakedOwn"""); + columns.Add(@"""BlockRewardsStakedShared"""); + break; + case "stakingBalance": + columns.Add(@"""OwnDelegatedBalance"""); + columns.Add(@"""ExternalDelegatedBalance"""); + columns.Add(@"""OwnStakedBalance"""); + columns.Add(@"""ExternalStakedBalance"""); + break; + case "activeStake": + columns.Add(@"""BakingPower"""); + break; + case "selectedStake": + columns.Add(@"""BakingPower"""); + break; + case "balance": + columns.Add(@"dc.""DelegatedBalance"""); + columns.Add(@"dc.""StakedBalance"""); + break; + #endregion } } if (columns.Count == 0) return Array.Empty(); - var joinStr = join - ? @"INNER JOIN ""BakerCycles"" as bc ON bc.""BakerId"" = dc.""BakerId"" AND bc.""Cycle"" = dc.""Cycle""" - : string.Empty; - - var sql = new SqlBuilder($@"SELECT {string.Join(',', columns)} FROM ""DelegatorCycles"" as dc {joinStr}") + var sql = new SqlBuilder($""" + SELECT {string.Join(',', columns)} + FROM "DelegatorCycles" as dc + INNER JOIN "BakerCycles" as bc + ON bc."BakerId" = dc."BakerId" + AND bc."Cycle" = dc."Cycle" + """) .FilterA(@"dc.""DelegatorId""", acc.Id) .FilterA(@"dc.""Cycle""", cycle) .Take(sort ?? new SortParameter { Desc = "cycle" }, offset, limit, x => ("Cycle", "Cycle"), "dc"); @@ -737,130 +1179,265 @@ public async Task GetDelegatorRewards( { switch (fields[i]) { + case "cycle": + foreach (var row in rows) + result[j++][i] = row.Cycle; + break; + case "delegatedBalance": + foreach (var row in rows) + result[j++][i] = row.DelegatedBalance; + break; + case "stakedBalance": + foreach (var row in rows) + result[j++][i] = row.StakedBalance; + break; case "baker": foreach (var row in rows) result[j++][i] = Accounts.GetAlias(row.BakerId); break; - case "balance": + case "bakingPower": foreach (var row in rows) - result[j++][i] = row.Balance; + result[j++][i] = row.BakingPower; break; - case "activeStake": + case "totalBakingPower": foreach (var row in rows) - result[j++][i] = row.ActiveStake; + result[j++][i] = row.TotalBakingPower; break; - case "selectedStake": + case "bakerDelegatedBalance": + foreach (var row in rows) + result[j++][i] = row.OwnDelegatedBalance; + break; + case "externalDelegatedBalance": + foreach (var row in rows) + result[j++][i] = row.ExternalDelegatedBalance; + break; + case "bakerStakedBalance": + foreach (var row in rows) + result[j++][i] = row.OwnStakedBalance; + break; + case "externalStakedBalance": + foreach (var row in rows) + result[j++][i] = row.ExternalStakedBalance; + break; + case "expectedBlocks": + foreach (var row in rows) + result[j++][i] = Math.Round(row.ExpectedBlocks, 2); + break; + case "expectedEndorsements": + foreach (var row in rows) + result[j++][i] = Math.Round(row.ExpectedEndorsements, 2); + break; + case "futureBlocks": + foreach (var row in rows) + result[j++][i] = row.FutureBlocks; + break; + case "futureBlockRewards": + foreach (var row in rows) + result[j++][i] = row.FutureBlockRewards; + break; + case "blocks": + foreach (var row in rows) + result[j++][i] = row.Blocks; + break; + case "blockRewardsLiquid": + foreach (var row in rows) + result[j++][i] = row.BlockRewardsLiquid; + break; + case "blockRewardsStakedOwn": foreach (var row in rows) - result[j++][i] = row.SelectedStake; + result[j++][i] = row.BlockRewardsStakedOwn; + break; + case "blockRewardsStakedShared": + foreach (var row in rows) + result[j++][i] = row.BlockRewardsStakedShared; + break; + case "missedBlocks": + foreach (var row in rows) + result[j++][i] = row.MissedBlocks; + break; + case "missedBlockRewards": + foreach (var row in rows) + result[j++][i] = row.MissedBlockRewards; + break; + case "futureEndorsements": + foreach (var row in rows) + result[j++][i] = row.FutureEndorsements; + break; + case "futureEndorsementRewards": + foreach (var row in rows) + result[j++][i] = row.FutureEndorsementRewards; + break; + case "endorsements": + foreach (var row in rows) + result[j++][i] = row.Endorsements; + break; + case "endorsementRewardsLiquid": + foreach (var row in rows) + result[j++][i] = row.EndorsementRewardsLiquid; + break; + case "endorsementRewardsStakedOwn": + foreach (var row in rows) + result[j++][i] = row.EndorsementRewardsStakedOwn; + break; + case "endorsementRewardsStakedShared": + foreach (var row in rows) + result[j++][i] = row.EndorsementRewardsStakedShared; + break; + case "missedEndorsements": + foreach (var row in rows) + result[j++][i] = row.MissedEndorsements; + break; + case "missedEndorsementRewards": + foreach (var row in rows) + result[j++][i] = row.MissedEndorsementRewards; + break; + case "blockFees": + foreach (var row in rows) + result[j++][i] = row.BlockFees; + break; + case "missedBlockFees": + foreach (var row in rows) + result[j++][i] = row.MissedBlockFees; break; case "doubleBakingRewards": foreach (var row in rows) result[j++][i] = row.DoubleBakingRewards; break; - case "doubleBakingLosses": + case "doubleBakingLostStaked": foreach (var row in rows) - result[j++][i] = row.DoubleBakingLosses; + result[j++][i] = row.DoubleBakingLostStaked; + break; + case "doubleBakingLostUnstaked": + foreach (var row in rows) + result[j++][i] = row.DoubleBakingLostUnstaked; + break; + case "doubleBakingLostExternalStaked": + foreach (var row in rows) + result[j++][i] = row.DoubleBakingLostExternalStaked; + break; + case "doubleBakingLostExternalUnstaked": + foreach (var row in rows) + result[j++][i] = row.DoubleBakingLostExternalUnstaked; break; case "doubleEndorsingRewards": foreach (var row in rows) result[j++][i] = row.DoubleEndorsingRewards; break; - case "doubleEndorsingLosses": + case "doubleEndorsingLostStaked": foreach (var row in rows) - result[j++][i] = row.DoubleEndorsingLosses; + result[j++][i] = row.DoubleEndorsingLostStaked; + break; + case "doubleEndorsingLostUnstaked": + foreach (var row in rows) + result[j++][i] = row.DoubleEndorsingLostUnstaked; + break; + case "doubleEndorsingLostExternalStaked": + foreach (var row in rows) + result[j++][i] = row.DoubleEndorsingLostExternalStaked; + break; + case "doubleEndorsingLostExternalUnstaked": + foreach (var row in rows) + result[j++][i] = row.DoubleEndorsingLostExternalUnstaked; break; case "doublePreendorsingRewards": foreach (var row in rows) result[j++][i] = row.DoublePreendorsingRewards; break; - case "doublePreendorsingLosses": + case "doublePreendorsingLostStaked": foreach (var row in rows) - result[j++][i] = row.DoublePreendorsingLosses; + result[j++][i] = row.DoublePreendorsingLostStaked; break; - case "cycle": + case "doublePreendorsingLostUnstaked": foreach (var row in rows) - result[j++][i] = row.Cycle; + result[j++][i] = row.DoublePreendorsingLostUnstaked; break; - case "endorsementRewards": + case "doublePreendorsingLostExternalStaked": foreach (var row in rows) - result[j++][i] = row.EndorsementRewards; + result[j++][i] = row.DoublePreendorsingLostExternalStaked; break; - case "endorsements": + case "doublePreendorsingLostExternalUnstaked": foreach (var row in rows) - result[j++][i] = row.Endorsements; + result[j++][i] = row.DoublePreendorsingLostExternalUnstaked; break; - case "expectedBlocks": + case "vdfRevelationRewardsLiquid": foreach (var row in rows) - result[j++][i] = Math.Round(row.ExpectedBlocks, 2); + result[j++][i] = row.VdfRevelationRewardsLiquid; break; - case "expectedEndorsements": + case "vdfRevelationRewardsStakedOwn": foreach (var row in rows) - result[j++][i] = Math.Round(row.ExpectedEndorsements, 2); + result[j++][i] = row.VdfRevelationRewardsStakedOwn; break; - case "futureBlockRewards": + case "vdfRevelationRewardsStakedShared": foreach (var row in rows) - result[j++][i] = row.FutureBlockRewards; + result[j++][i] = row.VdfRevelationRewardsStakedShared; break; - case "futureBlocks": + case "nonceRevelationRewardsLiquid": foreach (var row in rows) - result[j++][i] = row.FutureBlocks; + result[j++][i] = row.NonceRevelationRewardsLiquid; + break; + case "nonceRevelationRewardsStakedOwn": + foreach (var row in rows) + result[j++][i] = row.NonceRevelationRewardsStakedOwn; break; - case "futureEndorsementRewards": + case "nonceRevelationRewardsStakedShared": foreach (var row in rows) - result[j++][i] = row.FutureEndorsementRewards; + result[j++][i] = row.NonceRevelationRewardsStakedShared; break; - case "futureEndorsements": + case "nonceRevelationLosses": foreach (var row in rows) - result[j++][i] = row.FutureEndorsements; + result[j++][i] = row.NonceRevelationLosses; break; - case "missedEndorsementRewards": + case "quote": foreach (var row in rows) - result[j++][i] = row.MissedEndorsementRewards; + result[j++][i] = Quotes.Get(quote, Protocols.FindByCycle((int)row.Cycle).GetCycleEnd((int)row.Cycle)); break; - case "missedEndorsements": + + #region deprecated + case "revelationRewards": foreach (var row in rows) - result[j++][i] = row.MissedEndorsements; + result[j++][i] = row.NonceRevelationRewardsLiquid + row.NonceRevelationRewardsStakedOwn + row.NonceRevelationRewardsStakedShared + row.VdfRevelationRewardsLiquid + row.VdfRevelationRewardsStakedOwn + row.VdfRevelationRewardsStakedShared; break; - case "missedBlockFees": + case "revelationLosses": foreach (var row in rows) - result[j++][i] = row.MissedBlockFees; + result[j++][i] = row.NonceRevelationLosses; break; - case "missedBlockRewards": + case "doublePreendorsingLosses": foreach (var row in rows) - result[j++][i] = row.MissedBlockRewards; + result[j++][i] = row.DoublePreendorsingLostStaked + row.DoublePreendorsingLostExternalStaked + row.DoublePreendorsingLostUnstaked + row.DoublePreendorsingLostExternalUnstaked; break; - case "missedBlocks": + case "doubleEndorsingLosses": foreach (var row in rows) - result[j++][i] = row.MissedBlocks; + result[j++][i] = row.DoubleEndorsingLostStaked + row.DoubleEndorsingLostExternalStaked + row.DoubleEndorsingLostUnstaked + row.DoubleEndorsingLostExternalUnstaked; break; - case "blockFees": + case "doubleBakingLosses": foreach (var row in rows) - result[j++][i] = row.BlockFees; + result[j++][i] = row.DoubleBakingLostStaked + row.DoubleBakingLostExternalStaked + row.DoubleBakingLostUnstaked + row.DoubleBakingLostExternalUnstaked; break; - case "blockRewards": + case "endorsementRewards": foreach (var row in rows) - result[j++][i] = row.BlockRewards; + result[j++][i] = row.EndorsementRewardsLiquid + row.EndorsementRewardsStakedOwn + row.EndorsementRewardsStakedShared; break; - case "blocks": + case "blockRewards": foreach (var row in rows) - result[j++][i] = row.Blocks; + result[j++][i] = row.BlockRewardsLiquid + row.BlockRewardsStakedOwn + row.BlockRewardsStakedShared; break; - case "revelationLosses": + case "stakingBalance": foreach (var row in rows) - result[j++][i] = row.RevelationLosses; + result[j++][i] = row.OwnDelegatedBalance + row.ExternalDelegatedBalance + row.OwnStakedBalance + row.ExternalStakedBalance; break; - case "revelationRewards": + case "activeStake": foreach (var row in rows) - result[j++][i] = row.RevelationRewards; + result[j++][i] = row.BakingPower; break; - case "stakingBalance": + case "selectedStake": foreach (var row in rows) - result[j++][i] = row.StakingBalance; + result[j++][i] = row.BakingPower; break; - case "quote": + case "balance": foreach (var row in rows) - result[j++][i] = Quotes.Get(quote, Protocols.FindByCycle((int)row.Cycle).GetCycleEnd((int)row.Cycle)); + result[j++][i] = row.DelegatedBalance + row.StakedBalance; break; + #endregion } } @@ -884,37 +1461,117 @@ public async Task GetDelegatorRewards( switch (field) { + case "cycle": columns.Add(@"""Cycle"""); break; + case "delegatedBalance": columns.Add(@"dc.""DelegatedBalance"""); break; + case "stakedBalance": columns.Add(@"dc.""StakedBalance"""); break; case "baker": columns.Add(@"dc.""BakerId"""); break; - case "balance": columns.Add(@"dc.""Balance"""); break; - case "cycle": columns.Add(@"dc.""Cycle"""); break; - case "quote": columns.Add(@"dc.""Cycle"""); break; - case "activeStake": columns.Add(@"bc.""ActiveStake"""); join = true; break; - case "selectedStake": columns.Add(@"bc.""SelectedStake"""); join = true; break; - case "doubleBakingRewards": columns.Add(@"bc.""DoubleBakingRewards"""); join = true; break; - case "doubleBakingLosses": columns.Add(@"bc.""DoubleBakingLosses"""); join = true; break; - case "doubleEndorsingRewards": columns.Add(@"bc.""DoubleEndorsingRewards"""); join = true; break; - case "doubleEndorsingLosses": columns.Add(@"bc.""DoubleEndorsingLosses"""); join = true; break; - case "doublePreendorsingRewards": columns.Add(@"bc.""DoublePreendorsingRewards"""); join = true; break; - case "doublePreendorsingLosses": columns.Add(@"bc.""DoublePreendorsingLosses"""); join = true; break; - case "endorsementRewards": columns.Add(@"bc.""EndorsementRewards"""); join = true; break; - case "endorsements": columns.Add(@"bc.""Endorsements"""); join = true; break; - case "expectedBlocks": columns.Add(@"bc.""ExpectedBlocks"""); join = true; break; - case "expectedEndorsements": columns.Add(@"bc.""ExpectedEndorsements"""); join = true; break; - case "futureBlockRewards": columns.Add(@"bc.""FutureBlockRewards"""); join = true; break; - case "futureBlocks": columns.Add(@"bc.""FutureBlocks"""); join = true; break; - case "futureEndorsementRewards": columns.Add(@"bc.""FutureEndorsementRewards"""); join = true; break; - case "futureEndorsements": columns.Add(@"bc.""FutureEndorsements"""); join = true; break; - case "missedEndorsementRewards": columns.Add(@"bc.""MissedEndorsementRewards"""); join = true; break; - case "missedEndorsements": columns.Add(@"bc.""MissedEndorsements"""); join = true; break; - case "missedBlockFees": columns.Add(@"bc.""MissedBlockFees"""); join = true; break; - case "missedBlockRewards": columns.Add(@"bc.""MissedBlockRewards"""); join = true; break; - case "missedBlocks": columns.Add(@"bc.""MissedBlocks"""); join = true; break; - case "blockFees": columns.Add(@"bc.""BlockFees"""); join = true; break; - case "blockRewards": columns.Add(@"bc.""BlockRewards"""); join = true; break; - case "blocks": columns.Add(@"bc.""Blocks"""); join = true; break; - case "revelationLosses": columns.Add(@"bc.""RevelationLosses"""); join = true; break; - case "revelationRewards": columns.Add(@"bc.""RevelationRewards"""); join = true; break; - case "stakingBalance": columns.Add(@"bc.""StakingBalance"""); join = true; break; + case "bakingPower": columns.Add(@"""BakingPower"""); break; + case "totalBakingPower": columns.Add(@"""TotalBakingPower"""); break; + case "bakerDelegatedBalance": columns.Add(@"""OwnDelegatedBalance"""); break; + case "externalDelegatedBalance": columns.Add(@"""ExternalDelegatedBalance"""); break; + case "bakerStakedBalance": columns.Add(@"""OwnStakedBalance"""); break; + case "externalStakedBalance": columns.Add(@"""ExternalStakedBalance"""); break; + case "expectedBlocks": columns.Add(@"""ExpectedBlocks"""); break; + case "expectedEndorsements": columns.Add(@"""ExpectedEndorsements"""); break; + case "futureBlocks": columns.Add(@"""FutureBlocks"""); break; + case "futureBlockRewards": columns.Add(@"""FutureBlockRewards"""); break; + case "blocks": columns.Add(@"""Blocks"""); break; + case "blockRewardsLiquid": columns.Add(@"""BlockRewardsLiquid"""); break; + case "blockRewardsStakedOwn": columns.Add(@"""BlockRewardsStakedOwn"""); break; + case "blockRewardsStakedShared": columns.Add(@"""BlockRewardsStakedShared"""); break; + case "missedBlocks": columns.Add(@"""MissedBlocks"""); break; + case "missedBlockRewards": columns.Add(@"""MissedBlockRewards"""); break; + case "futureEndorsements": columns.Add(@"""FutureEndorsements"""); break; + case "futureEndorsementRewards": columns.Add(@"""FutureEndorsementRewards"""); break; + case "endorsements": columns.Add(@"""Endorsements"""); break; + case "endorsementRewardsLiquid": columns.Add(@"""EndorsementRewardsLiquid"""); break; + case "endorsementRewardsStakedOwn": columns.Add(@"""EndorsementRewardsStakedOwn"""); break; + case "endorsementRewardsStakedShared": columns.Add(@"""EndorsementRewardsStakedShared"""); break; + case "missedEndorsements": columns.Add(@"""MissedEndorsements"""); break; + case "missedEndorsementRewards": columns.Add(@"""MissedEndorsementRewards"""); break; + case "blockFees": columns.Add(@"""BlockFees"""); break; + case "missedBlockFees": columns.Add(@"""MissedBlockFees"""); break; + case "doubleBakingRewards": columns.Add(@"""DoubleBakingRewards"""); break; + case "doubleBakingLostStaked": columns.Add(@"""DoubleBakingLostStaked"""); break; + case "doubleBakingLostUnstaked": columns.Add(@"""DoubleBakingLostUnstaked"""); break; + case "doubleBakingLostExternalStaked": columns.Add(@"""DoubleBakingLostExternalStaked"""); break; + case "doubleBakingLostExternalUnstaked": columns.Add(@"""DoubleBakingLostExternalUnstaked"""); break; + case "doubleEndorsingRewards": columns.Add(@"""DoubleEndorsingRewards"""); break; + case "doubleEndorsingLostStaked": columns.Add(@"""DoubleEndorsingLostStaked"""); break; + case "doubleEndorsingLostUnstaked": columns.Add(@"""DoubleEndorsingLostUnstaked"""); break; + case "doubleEndorsingLostExternalStaked": columns.Add(@"""DoubleEndorsingLostExternalStaked"""); break; + case "doubleEndorsingLostExternalUnstaked": columns.Add(@"""DoubleEndorsingLostExternalUnstaked"""); break; + case "doublePreendorsingRewards": columns.Add(@"""DoublePreendorsingRewards"""); break; + case "doublePreendorsingLostStaked": columns.Add(@"""DoublePreendorsingLostStaked"""); break; + case "doublePreendorsingLostUnstaked": columns.Add(@"""DoublePreendorsingLostUnstaked"""); break; + case "doublePreendorsingLostExternalStaked": columns.Add(@"""DoublePreendorsingLostExternalStaked"""); break; + case "doublePreendorsingLostExternalUnstaked": columns.Add(@"""DoublePreendorsingLostExternalUnstaked"""); break; + case "vdfRevelationRewardsLiquid": columns.Add(@"""VdfRevelationRewardsLiquid"""); break; + case "vdfRevelationRewardsStakedOwn": columns.Add(@"""VdfRevelationRewardsStakedOwn"""); break; + case "vdfRevelationRewardsStakedShared": columns.Add(@"""VdfRevelationRewardsStakedShared"""); break; + case "nonceRevelationRewardsLiquid": columns.Add(@"""NonceRevelationRewardsLiquid"""); break; + case "nonceRevelationRewardsStakedOwn": columns.Add(@"""NonceRevelationRewardsStakedOwn"""); break; + case "nonceRevelationRewardsStakedShared": columns.Add(@"""NonceRevelationRewardsStakedShared"""); break; + case "nonceRevelationLosses": columns.Add(@"""NonceRevelationLosses"""); break; + case "quote": columns.Add(@"""Cycle"""); break; + + #region deprecated + case "revelationRewards": + columns.Add(@"""NonceRevelationRewardsLiquid"""); + columns.Add(@"""NonceRevelationRewardsStakedOwn"""); + columns.Add(@"""NonceRevelationRewardsStakedShared"""); + columns.Add(@"""VdfRevelationRewardsLiquid"""); + columns.Add(@"""VdfRevelationRewardsStakedOwn"""); + columns.Add(@"""VdfRevelationRewardsStakedShared"""); + break; + case "revelationLosses": + columns.Add(@"""NonceRevelationLosses"""); + break; + case "doublePreendorsingLosses": + columns.Add(@"""DoublePreendorsingLostStaked"""); + columns.Add(@"""DoublePreendorsingLostExternalStaked"""); + columns.Add(@"""DoublePreendorsingLostUnstaked"""); + columns.Add(@"""DoublePreendorsingLostExternalUnstaked"""); + break; + case "doubleEndorsingLosses": + columns.Add(@"""DoubleEndorsingLostStaked"""); + columns.Add(@"""DoubleEndorsingLostExternalStaked"""); + columns.Add(@"""DoubleEndorsingLostUnstaked"""); + columns.Add(@"""DoubleEndorsingLostExternalUnstaked"""); + break; + case "doubleBakingLosses": + columns.Add(@"""DoubleBakingLostStaked"""); + columns.Add(@"""DoubleBakingLostExternalStaked"""); + columns.Add(@"""DoubleBakingLostUnstaked"""); + columns.Add(@"""DoubleBakingLostExternalUnstaked"""); + break; + case "endorsementRewards": + columns.Add(@"""EndorsementRewardsLiquid"""); + columns.Add(@"""EndorsementRewardsStakedOwn"""); + columns.Add(@"""EndorsementRewardsStakedShared"""); + break; + case "blockRewards": + columns.Add(@"""BlockRewardsLiquid"""); + columns.Add(@"""BlockRewardsStakedOwn"""); + columns.Add(@"""BlockRewardsStakedShared"""); + break; + case "stakingBalance": + columns.Add(@"""OwnDelegatedBalance"""); + columns.Add(@"""ExternalDelegatedBalance"""); + columns.Add(@"""OwnStakedBalance"""); + columns.Add(@"""ExternalStakedBalance"""); + break; + case "activeStake": + columns.Add(@"""BakingPower"""); + break; + case "selectedStake": + columns.Add(@"""BakingPower"""); + break; + case "balance": + columns.Add(@"dc.""DelegatedBalance"""); + columns.Add(@"dc.""StakedBalance"""); + break; + #endregion } if (columns.Count == 0) @@ -938,130 +1595,265 @@ public async Task GetDelegatorRewards( switch (field) { + case "cycle": + foreach (var row in rows) + result[j++] = row.Cycle; + break; + case "delegatedBalance": + foreach (var row in rows) + result[j++] = row.DelegatedBalance; + break; + case "stakedBalance": + foreach (var row in rows) + result[j++] = row.StakedBalance; + break; case "baker": foreach (var row in rows) result[j++] = Accounts.GetAlias(row.BakerId); break; - case "balance": + case "bakingPower": foreach (var row in rows) - result[j++] = row.Balance; + result[j++] = row.BakingPower; break; - case "activeStake": + case "totalBakingPower": foreach (var row in rows) - result[j++] = row.ActiveStake; + result[j++] = row.TotalBakingPower; break; - case "selectedStake": + case "bakerDelegatedBalance": foreach (var row in rows) - result[j++] = row.SelectedStake; + result[j++] = row.OwnDelegatedBalance; break; - case "doubleBakingRewards": + case "externalDelegatedBalance": foreach (var row in rows) - result[j++] = row.DoubleBakingRewards; + result[j++] = row.ExternalDelegatedBalance; break; - case "doubleBakingLosses": + case "bakerStakedBalance": foreach (var row in rows) - result[j++] = row.DoubleBakingLosses; + result[j++] = row.OwnStakedBalance; break; - case "doubleEndorsingRewards": + case "externalStakedBalance": foreach (var row in rows) - result[j++] = row.DoubleEndorsingRewards; + result[j++] = row.ExternalStakedBalance; break; - case "doubleEndorsingLosses": + case "expectedBlocks": foreach (var row in rows) - result[j++] = row.DoubleEndorsingLosses; + result[j++] = Math.Round(row.ExpectedBlocks, 2); break; - case "doublePreendorsingRewards": + case "expectedEndorsements": foreach (var row in rows) - result[j++] = row.DoublePreendorsingRewards; + result[j++] = Math.Round(row.ExpectedEndorsements, 2); break; - case "doublePreendorsingLosses": + case "futureBlocks": foreach (var row in rows) - result[j++] = row.DoublePreendorsingLosses; + result[j++] = row.FutureBlocks; break; - case "cycle": + case "futureBlockRewards": foreach (var row in rows) - result[j++] = row.Cycle; + result[j++] = row.FutureBlockRewards; break; - case "endorsementRewards": + case "blocks": foreach (var row in rows) - result[j++] = row.EndorsementRewards; + result[j++] = row.Blocks; break; - case "endorsements": + case "blockRewardsLiquid": foreach (var row in rows) - result[j++] = row.Endorsements; + result[j++] = row.BlockRewardsLiquid; break; - case "expectedBlocks": + case "blockRewardsStakedOwn": foreach (var row in rows) - result[j++] = Math.Round(row.ExpectedBlocks, 2); + result[j++] = row.BlockRewardsStakedOwn; break; - case "expectedEndorsements": + case "blockRewardsStakedShared": foreach (var row in rows) - result[j++] = Math.Round(row.ExpectedEndorsements, 2); + result[j++] = row.BlockRewardsStakedShared; break; - case "futureBlockRewards": + case "missedBlocks": foreach (var row in rows) - result[j++] = row.FutureBlockRewards; + result[j++] = row.MissedBlocks; break; - case "futureBlocks": + case "missedBlockRewards": foreach (var row in rows) - result[j++] = row.FutureBlocks; + result[j++] = row.MissedBlockRewards; + break; + case "futureEndorsements": + foreach (var row in rows) + result[j++] = row.FutureEndorsements; break; case "futureEndorsementRewards": foreach (var row in rows) result[j++] = row.FutureEndorsementRewards; break; - case "futureEndorsements": + case "endorsements": foreach (var row in rows) - result[j++] = row.FutureEndorsements; + result[j++] = row.Endorsements; break; - case "missedEndorsementRewards": + case "endorsementRewardsLiquid": foreach (var row in rows) - result[j++] = row.MissedEndorsementRewards; + result[j++] = row.EndorsementRewardsLiquid; + break; + case "endorsementRewardsStakedOwn": + foreach (var row in rows) + result[j++] = row.EndorsementRewardsStakedOwn; + break; + case "endorsementRewardsStakedShared": + foreach (var row in rows) + result[j++] = row.EndorsementRewardsStakedShared; break; case "missedEndorsements": foreach (var row in rows) result[j++] = row.MissedEndorsements; break; + case "missedEndorsementRewards": + foreach (var row in rows) + result[j++] = row.MissedEndorsementRewards; + break; + case "blockFees": + foreach (var row in rows) + result[j++] = row.BlockFees; + break; case "missedBlockFees": foreach (var row in rows) result[j++] = row.MissedBlockFees; break; - case "missedBlockRewards": + case "doubleBakingRewards": foreach (var row in rows) - result[j++] = row.MissedBlockRewards; + result[j++] = row.DoubleBakingRewards; break; - case "missedBlocks": + case "doubleBakingLostStaked": foreach (var row in rows) - result[j++] = row.MissedBlocks; + result[j++] = row.DoubleBakingLostStaked; break; - case "blockFees": + case "doubleBakingLostUnstaked": foreach (var row in rows) - result[j++] = row.BlockFees; + result[j++] = row.DoubleBakingLostUnstaked; break; - case "blockRewards": + case "doubleBakingLostExternalStaked": foreach (var row in rows) - result[j++] = row.BlockRewards; + result[j++] = row.DoubleBakingLostExternalStaked; break; - case "blocks": + case "doubleBakingLostExternalUnstaked": foreach (var row in rows) - result[j++] = row.Blocks; + result[j++] = row.DoubleBakingLostExternalUnstaked; break; - case "revelationLosses": + case "doubleEndorsingRewards": foreach (var row in rows) - result[j++] = row.RevelationLosses; + result[j++] = row.DoubleEndorsingRewards; break; - case "revelationRewards": + case "doubleEndorsingLostStaked": foreach (var row in rows) - result[j++] = row.RevelationRewards; + result[j++] = row.DoubleEndorsingLostStaked; break; - case "stakingBalance": + case "doubleEndorsingLostUnstaked": + foreach (var row in rows) + result[j++] = row.DoubleEndorsingLostUnstaked; + break; + case "doubleEndorsingLostExternalStaked": + foreach (var row in rows) + result[j++] = row.DoubleEndorsingLostExternalStaked; + break; + case "doubleEndorsingLostExternalUnstaked": + foreach (var row in rows) + result[j++] = row.DoubleEndorsingLostExternalUnstaked; + break; + case "doublePreendorsingRewards": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingRewards; + break; + case "doublePreendorsingLostStaked": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostStaked; + break; + case "doublePreendorsingLostUnstaked": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostUnstaked; + break; + case "doublePreendorsingLostExternalStaked": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostExternalStaked; + break; + case "doublePreendorsingLostExternalUnstaked": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostExternalUnstaked; + break; + case "vdfRevelationRewardsLiquid": + foreach (var row in rows) + result[j++] = row.VdfRevelationRewardsLiquid; + break; + case "vdfRevelationRewardsStakedOwn": + foreach (var row in rows) + result[j++] = row.VdfRevelationRewardsStakedOwn; + break; + case "vdfRevelationRewardsStakedShared": + foreach (var row in rows) + result[j++] = row.VdfRevelationRewardsStakedShared; + break; + case "nonceRevelationRewardsLiquid": + foreach (var row in rows) + result[j++] = row.NonceRevelationRewardsLiquid; + break; + case "nonceRevelationRewardsStakedOwn": + foreach (var row in rows) + result[j++] = row.NonceRevelationRewardsStakedOwn; + break; + case "nonceRevelationRewardsStakedShared": + foreach (var row in rows) + result[j++] = row.NonceRevelationRewardsStakedShared; + break; + case "nonceRevelationLosses": foreach (var row in rows) - result[j++] = row.StakingBalance; + result[j++] = row.NonceRevelationLosses; break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, Protocols.FindByCycle((int)row.Cycle).GetCycleEnd((int)row.Cycle)); break; + + #region deprecated + case "revelationRewards": + foreach (var row in rows) + result[j++] = row.NonceRevelationRewardsLiquid + row.NonceRevelationRewardsStakedOwn + row.NonceRevelationRewardsStakedShared + row.VdfRevelationRewardsLiquid + row.VdfRevelationRewardsStakedOwn + row.VdfRevelationRewardsStakedShared; + break; + case "revelationLosses": + foreach (var row in rows) + result[j++] = row.NonceRevelationLosses; + break; + case "doublePreendorsingLosses": + foreach (var row in rows) + result[j++] = row.DoublePreendorsingLostStaked + row.DoublePreendorsingLostExternalStaked + row.DoublePreendorsingLostUnstaked + row.DoublePreendorsingLostExternalUnstaked; + break; + case "doubleEndorsingLosses": + foreach (var row in rows) + result[j++] = row.DoubleEndorsingLostStaked + row.DoubleEndorsingLostExternalStaked + row.DoubleEndorsingLostUnstaked + row.DoubleEndorsingLostExternalUnstaked; + break; + case "doubleBakingLosses": + foreach (var row in rows) + result[j++] = row.DoubleBakingLostStaked + row.DoubleBakingLostExternalStaked + row.DoubleBakingLostUnstaked + row.DoubleBakingLostExternalUnstaked; + break; + case "endorsementRewards": + foreach (var row in rows) + result[j++] = row.EndorsementRewardsLiquid + row.EndorsementRewardsStakedOwn + row.EndorsementRewardsStakedShared; + break; + case "blockRewards": + foreach (var row in rows) + result[j++] = row.BlockRewardsLiquid + row.BlockRewardsStakedOwn + row.BlockRewardsStakedShared; + break; + case "stakingBalance": + foreach (var row in rows) + result[j++] = row.OwnDelegatedBalance + row.ExternalDelegatedBalance + row.OwnStakedBalance + row.ExternalStakedBalance; + break; + case "activeStake": + foreach (var row in rows) + result[j++] = row.BakingPower; + break; + case "selectedStake": + foreach (var row in rows) + result[j++] = row.BakingPower; + break; + case "balance": + foreach (var row in rows) + result[j++] = row.DelegatedBalance + row.StakedBalance; + break; + #endregion } return result; @@ -1074,26 +1866,29 @@ public async Task GetRewardSplit(string address, int cycle, int off if (await Accounts.GetAsync(address) is not RawDelegate baker) return null; - var sqlRewards = $@" + var sqlRewards = $""" SELECT * - FROM ""BakerCycles"" - WHERE ""BakerId"" = {baker.Id} - AND ""Cycle"" = {cycle} - LIMIT 1"; - - var sqlDelegators = $@" - SELECT ""DelegatorId"", ""Balance"" - FROM ""DelegatorCycles"" - WHERE ""BakerId"" = {baker.Id} - AND ""Cycle"" = {cycle} - ORDER BY ""Balance"" DESC + FROM "BakerCycles" + WHERE "BakerId" = {baker.Id} + AND "Cycle" = {cycle} + LIMIT 1 + """; + + var sqlDelegators = $""" + SELECT "DelegatorId", "DelegatedBalance", "StakedBalance" + FROM "DelegatorCycles" + WHERE "BakerId" = {baker.Id} + AND "Cycle" = {cycle} + ORDER BY "StakedBalance" DESC, "DelegatedBalance" DESC OFFSET {offset} - LIMIT {limit}"; + LIMIT {limit} + """; using var db = GetConnection(); - using var result = await db.QueryMultipleAsync($@" + using var result = await db.QueryMultipleAsync($""" {sqlRewards}; - {sqlDelegators};"); + {sqlDelegators}; + """); var rewards = result.ReadFirstOrDefault(); if (rewards == null) return null; @@ -1102,44 +1897,67 @@ ORDER BY ""Balance"" DESC return new RewardSplit { - ActiveStake = rewards.ActiveStake, - SelectedStake = rewards.SelectedStake, - DoubleBakingRewards = rewards.DoubleBakingRewards, - DoubleBakingLosses = rewards.DoubleBakingLosses, - DoubleEndorsingRewards = rewards.DoubleEndorsingRewards, - DoubleEndorsingLosses = rewards.DoubleEndorsingLosses, - DoublePreendorsingRewards = rewards.DoublePreendorsingRewards, - DoublePreendorsingLosses = rewards.DoublePreendorsingLosses, Cycle = rewards.Cycle, - DelegatedBalance = rewards.DelegatedBalance, - EndorsementRewards = rewards.EndorsementRewards, - Endorsements = rewards.Endorsements, + BakingPower = rewards.BakingPower, + TotalBakingPower = rewards.TotalBakingPower, + OwnDelegatedBalance = rewards.OwnDelegatedBalance, + ExternalDelegatedBalance = rewards.ExternalDelegatedBalance, + DelegatorsCount = rewards.DelegatorsCount, + OwnStakedBalance = rewards.OwnStakedBalance, + ExternalStakedBalance = rewards.ExternalStakedBalance, + StakersCount = rewards.StakersCount, ExpectedBlocks = Math.Round(rewards.ExpectedBlocks, 2), ExpectedEndorsements = Math.Round(rewards.ExpectedEndorsements, 2), - FutureBlockRewards = rewards.FutureBlockRewards, FutureBlocks = rewards.FutureBlocks, - FutureEndorsementRewards = rewards.FutureEndorsementRewards, + FutureBlockRewards = rewards.FutureBlockRewards, + Blocks = rewards.Blocks, + BlockRewardsLiquid = rewards.BlockRewardsLiquid, + BlockRewardsStakedOwn = rewards.BlockRewardsStakedOwn, + BlockRewardsStakedShared = rewards.BlockRewardsStakedShared, + MissedBlocks = rewards.MissedBlocks, + MissedBlockRewards = rewards.MissedBlockRewards, FutureEndorsements = rewards.FutureEndorsements, - MissedEndorsementRewards = rewards.MissedEndorsementRewards, + FutureEndorsementRewards = rewards.FutureEndorsementRewards, + Endorsements = rewards.Endorsements, + EndorsementRewardsLiquid = rewards.EndorsementRewardsLiquid, + EndorsementRewardsStakedOwn = rewards.EndorsementRewardsStakedOwn, + EndorsementRewardsStakedShared = rewards.EndorsementRewardsStakedShared, MissedEndorsements = rewards.MissedEndorsements, - MissedBlockFees = rewards.MissedBlockFees, - MissedBlockRewards = rewards.MissedBlockRewards, - MissedBlocks = rewards.MissedBlocks, - NumDelegators = rewards.DelegatorsCount, + MissedEndorsementRewards = rewards.MissedEndorsementRewards, BlockFees = rewards.BlockFees, - BlockRewards = rewards.BlockRewards, - Blocks = rewards.Blocks, - RevelationLosses = rewards.RevelationLosses, - RevelationRewards = rewards.RevelationRewards, - StakingBalance = rewards.StakingBalance, + MissedBlockFees = rewards.MissedBlockFees, + DoubleBakingRewards = rewards.DoubleBakingRewards, + DoubleBakingLostStaked = rewards.DoubleBakingLostStaked, + DoubleBakingLostUnstaked = rewards.DoubleBakingLostUnstaked, + DoubleBakingLostExternalStaked = rewards.DoubleBakingLostExternalStaked, + DoubleBakingLostExternalUnstaked = rewards.DoubleBakingLostExternalUnstaked, + DoubleEndorsingRewards = rewards.DoubleEndorsingRewards, + DoubleEndorsingLostStaked = rewards.DoubleEndorsingLostStaked, + DoubleEndorsingLostUnstaked = rewards.DoubleEndorsingLostUnstaked, + DoubleEndorsingLostExternalStaked = rewards.DoubleEndorsingLostExternalStaked, + DoubleEndorsingLostExternalUnstaked = rewards.DoubleEndorsingLostExternalUnstaked, + DoublePreendorsingRewards = rewards.DoublePreendorsingRewards, + DoublePreendorsingLostStaked = rewards.DoublePreendorsingLostStaked, + DoublePreendorsingLostUnstaked = rewards.DoublePreendorsingLostUnstaked, + DoublePreendorsingLostExternalStaked = rewards.DoublePreendorsingLostExternalStaked, + DoublePreendorsingLostExternalUnstaked = rewards.DoublePreendorsingLostExternalUnstaked, + VdfRevelationRewardsLiquid = rewards.VdfRevelationRewardsLiquid, + VdfRevelationRewardsStakedOwn = rewards.VdfRevelationRewardsStakedOwn, + VdfRevelationRewardsStakedShared = rewards.VdfRevelationRewardsStakedShared, + NonceRevelationRewardsLiquid = rewards.NonceRevelationRewardsLiquid, + NonceRevelationRewardsStakedOwn = rewards.NonceRevelationRewardsStakedOwn, + NonceRevelationRewardsStakedShared = rewards.NonceRevelationRewardsStakedShared, + NonceRevelationLosses = rewards.NonceRevelationLosses, Delegators = delegators.Select(x => { var delegator = Accounts.Get((int)x.DelegatorId); return new SplitDelegator { Address = delegator.Address, - Balance = x.Balance, - CurrentBalance = delegator.Balance, + DelegatedBalance = x.DelegatedBalance, + StakedBalance = x.StakedBalance, + CurrentDelegatedBalance = delegator.Balance - ((delegator as RawUser)?.StakedBalance ?? 0), + CurrentStakedBalance = (delegator as RawUser)?.StakedBalance ?? 0, Emptied = delegator is RawUser && delegator.Balance == 0 }; }) @@ -1154,22 +1972,25 @@ public async Task GetRewardSplitDelegator(string baker, int cycl if (await Accounts.GetAsync(delegator) is not RawAccount delegatorAccount) return null; - var sql = $@" - SELECT ""Balance"" - FROM ""DelegatorCycles"" - WHERE ""BakerId"" = {bakerAccount.Id} - AND ""Cycle"" = {cycle} - AND ""DelegatorId"" = {delegatorAccount.Id} - LIMIT 1"; + var sql = $""" + SELECT "DelegatedBalance", "StakedBalance" + FROM "DelegatorCycles" + WHERE "BakerId" = {bakerAccount.Id} + AND "Cycle" = {cycle} + AND "DelegatorId" = {delegatorAccount.Id} + LIMIT 1 + """; using var db = GetConnection(); - var result = await db.ExecuteScalarAsync(sql); - if (result == null) return null; + var row = await db.QueryFirstOrDefaultAsync(sql); + if (row == null) return null; return new SplitDelegator { - Balance = (long)result, - CurrentBalance = delegatorAccount.Balance, + DelegatedBalance = row.DelegatedBalance, + StakedBalance = row.StakedBalance, + CurrentDelegatedBalance = delegatorAccount.Balance - ((delegatorAccount as RawUser)?.StakedBalance ?? 0), + CurrentStakedBalance = (delegatorAccount as RawUser)?.StakedBalance ?? 0, Emptied = delegatorAccount is RawUser && delegatorAccount.Balance == 0 }; } diff --git a/Tzkt.Api/Repositories/StatisticsRepository.cs b/Tzkt.Api/Repositories/StatisticsRepository.cs index 684d7d5cb..8792b38fd 100644 --- a/Tzkt.Api/Repositories/StatisticsRepository.cs +++ b/Tzkt.Api/Repositories/StatisticsRepository.cs @@ -63,6 +63,7 @@ public async Task> Get( TotalFrozen = row.TotalFrozen, TotalRollupBonds = row.TotalRollupBonds, TotalSmartRollupBonds = row.TotalSmartRollupBonds, + TotalLost = row.TotalLost, TotalSupply = row.TotalBootstrapped + row.TotalCommitments + row.TotalCreated - row.TotalBurned - row.TotalBanished, CirculatingSupply = row.TotalBootstrapped + row.TotalActivated + row.TotalCreated @@ -101,6 +102,7 @@ public async Task Get( case "totalFrozen": columns.Add(@"""TotalFrozen"""); break; case "totalRollupBonds": columns.Add(@"""TotalRollupBonds"""); break; case "totalSmartRollupBonds": columns.Add(@"""TotalSmartRollupBonds"""); break; + case "totalLost": columns.Add(@"""TotalLost"""); break; case "totalSupply": columns.Add(@"""TotalBootstrapped"""); columns.Add(@"""TotalCommitments"""); @@ -207,6 +209,10 @@ public async Task Get( foreach (var row in rows) result[j++][i] = row.TotalSmartRollupBonds; break; + case "totalLost": + foreach (var row in rows) + result[j++][i] = row.TotalLost; + break; case "totalSupply": foreach (var row in rows) result[j++][i] = row.TotalBootstrapped + row.TotalCommitments + row.TotalCreated @@ -255,6 +261,7 @@ public async Task Get( case "totalFrozen": columns.Add(@"""TotalFrozen"""); break; case "totalRollupBonds": columns.Add(@"""TotalRollupBonds"""); break; case "totalSmartRollupBonds": columns.Add(@"""TotalSmartRollupBonds"""); break; + case "totalLost": columns.Add(@"""TotalLost"""); break; case "totalSupply": columns.Add(@"""TotalBootstrapped"""); columns.Add(@"""TotalCommitments"""); @@ -357,6 +364,10 @@ public async Task Get( foreach (var row in rows) result[j++] = row.TotalSmartRollupBonds; break; + case "totalLost": + foreach (var row in rows) + result[j++] = row.TotalLost; + break; case "totalSupply": foreach (var row in rows) result[j++] = row.TotalBootstrapped + row.TotalCommitments + row.TotalCreated diff --git a/Tzkt.Api/Services/Cache/Accounts/Models/RawAccount.cs b/Tzkt.Api/Services/Cache/Accounts/Models/RawAccount.cs index 5f3fdff23..2f869d3d7 100644 --- a/Tzkt.Api/Services/Cache/Accounts/Models/RawAccount.cs +++ b/Tzkt.Api/Services/Cache/Accounts/Models/RawAccount.cs @@ -14,6 +14,8 @@ public class RawAccount public long SmartRollupBonds { get; set; } public int Counter { get; set; } + public long LostBalance { get; set; } + public int ContractsCount { get; set; } public int RollupsCount { get; set; } public int SmartRollupsCount { get; set; } diff --git a/Tzkt.Api/Services/Cache/Accounts/Models/RawDelegate.cs b/Tzkt.Api/Services/Cache/Accounts/Models/RawDelegate.cs index 4a2fb21e7..9af2a3c99 100644 --- a/Tzkt.Api/Services/Cache/Accounts/Models/RawDelegate.cs +++ b/Tzkt.Api/Services/Cache/Accounts/Models/RawDelegate.cs @@ -5,13 +5,20 @@ public class RawDelegate : RawUser public int ActivationLevel { get; set; } public int DeactivationLevel { get; set; } - public long? FrozenDepositLimit { get; set; } - public long FrozenDeposit { get; set; } - public long StakingBalance { get; set; } public long DelegatedBalance { get; set; } public int DelegatorsCount { get; set; } + public long TotalStakedBalance { get; set; } + public long ExternalStakedBalance { get; set; } + public long ExternalUnstakedBalance { get; set; } + public long IssuedPseudotokens { get; set; } + public int StakersCount { get; set; } + + public long? FrozenDepositLimit { get; set; } + public long? LimitOfStakingOverBaking { get; set; } + public long? EdgeOfBakingOverStaking { get; set; } + public int BlocksCount { get; set; } public int EndorsementsCount { get; set; } public int PreendorsementsCount { get; set; } @@ -24,6 +31,7 @@ public class RawDelegate : RawUser public int VdfRevelationsCount { get; set; } public int RevelationPenaltiesCount { get; set; } public int EndorsingRewardsCount { get; set; } + public int AutostakingOpsCount { get; set; } public int? SoftwareId { get; set; } } diff --git a/Tzkt.Api/Services/Cache/Accounts/Models/RawUser.cs b/Tzkt.Api/Services/Cache/Accounts/Models/RawUser.cs index 1664caf12..176aa202f 100644 --- a/Tzkt.Api/Services/Cache/Accounts/Models/RawUser.cs +++ b/Tzkt.Api/Services/Cache/Accounts/Models/RawUser.cs @@ -2,10 +2,17 @@ { public class RawUser : RawAccount { - public bool? Activated { get; set; } - public string PublicKey { get; set; } public bool Revealed { get; set; } + public string PublicKey { get; set; } + + public long StakedBalance { get; set; } + public long StakedPseudotokens { get; set; } + public long UnstakedBalance { get; set; } + public int? UnstakedBakerId { get; set; } + + public bool? Activated { get; set; } public int RegisterConstantsCount { get; set; } public int SetDepositsLimitsCount { get; set; } + public int StakingOpsCount { get; set; } } } diff --git a/Tzkt.Api/Services/Cache/State/RawModels/RawState.cs b/Tzkt.Api/Services/Cache/State/RawModels/RawState.cs index 1fc26fb9d..284c08288 100644 --- a/Tzkt.Api/Services/Cache/State/RawModels/RawState.cs +++ b/Tzkt.Api/Services/Cache/State/RawModels/RawState.cs @@ -45,12 +45,14 @@ public class RawState public int OriginationOpsCount { get; set; } public int ProposalOpsCount { get; set; } public int RevealOpsCount { get; set; } + public int StakingOpsCount { get; set; } public int RegisterConstantOpsCount { get; set; } public int SetDepositsLimitOpsCount { get; set; } public int TransactionOpsCount { get; set; } public int MigrationOpsCount { get; set; } public int RevelationPenaltyOpsCount { get; set; } public int EndorsingRewardOpsCount { get; set; } + public int AutostakingOpsCount { get; set; } public int TxRollupOriginationOpsCount { get; set; } public int TxRollupSubmitBatchOpsCount { get; set; } diff --git a/Tzkt.Api/Services/Home/HomeService.cs b/Tzkt.Api/Services/Home/HomeService.cs index e36f7df1a..04db90afb 100644 --- a/Tzkt.Api/Services/Home/HomeService.cs +++ b/Tzkt.Api/Services/Home/HomeService.cs @@ -31,7 +31,8 @@ public class HomeService : DbConnection public static object[][] BlocksTab { get; private set; } = Array.Empty(); public static readonly string[] BlockFields = new[] { - "timestamp", "level", "proposer", "producer", "payloadRound", "blockRound", "validations", "reward", "bonus", "fees", "hash" + "timestamp", "level", "proposer", "producer", "payloadRound", "blockRound", "validations", "reward", "bonus", "fees", "hash", + "rewardLiquid", "rewardStakedOwn", "rewardStakedShared", "bonusLiquid", "bonusStakedOwn", "bonusStakedShared" // TODO: remove deprecated reward and bonus }; #endregion @@ -205,7 +206,10 @@ async Task GetBlocks() new Int32NullParameter { Eq = 0 }, null, new SortParameter { Desc = "level" }, - null, 5, new string[] { "timestamp", "level", "baker", "baker", "round", "round", "validations", "reward", "bonus", "fees", "hash" }); + null, 5, new string[] { + "timestamp", "level", "baker", "baker", "round", "round", "validations", "reward", "bonus", "fees", "hash", + "rewardLiquid", "rewardStakedOwn", "rewardStakedShared", "bonusLiquid", "bonusStakedOwn", "bonusStakedShared" // TODO: remove deprecated reward and bonus + }); var blocks = await BlocksRepo.Get(null, null, null, null, null, null, new SortParameter { Desc = "level" }, null, 7, BlockFields, Symbols.None); @@ -258,6 +262,7 @@ async Task GetStatistics(IDbConnection db) TotalFrozen = row.TotalFrozen, TotalRollupBonds = row.TotalRollupBonds, TotalSmartRollupBonds = row.TotalSmartRollupBonds, + TotalLost = row.TotalLost, TotalSupply = row.TotalBootstrapped + row.TotalCommitments + row.TotalCreated - row.TotalBurned - row.TotalBanished, CirculatingSupply = row.TotalBootstrapped + row.TotalActivated + row.TotalCreated @@ -496,13 +501,15 @@ SELECT COUNT(*) FROM "Accounts" WHERE "Type" = 1 AND "Staked" = true - AND "StakingBalance" >= {protocol.TokensPerRoll} + AND "StakingBalance" >= {protocol.MinimalStake} """); + // TODO: use current cycle rewards after Oxford2 activation + var lbSubsidy = 80_000_000 * protocol.TimeBetweenBlocks / 60 / 16; var blocksPerYear = 365 * 24 * 60 * 60 / protocol.TimeBetweenBlocks; var maxBlockReward = protocol.MaxBakingReward + protocol.MaxEndorsingReward; //microtez var totalRewardsPerYear = maxBlockReward * blocksPerYear; - var maxBlockCreated = maxBlockReward + protocol.LBSubsidy; //microtez + var maxBlockCreated = maxBlockReward + lbSubsidy; //microtez var totalCreatedPerYear = maxBlockCreated * blocksPerYear; return new StakingData diff --git a/Tzkt.Api/Utils/SqlBuilder.cs b/Tzkt.Api/Utils/SqlBuilder.cs index 237a6ee82..250f3687d 100644 --- a/Tzkt.Api/Utils/SqlBuilder.cs +++ b/Tzkt.Api/Utils/SqlBuilder.cs @@ -199,6 +199,44 @@ public SqlBuilder FilterA(string column, ContractKindParameter kind) return this; } + public SqlBuilder FilterA(string column, AutostakingActionParameter action) + { + if (action == null) return this; + + if (action.Eq != null) + AppendFilter($"{column} = {action.Eq}"); + + if (action.Ne != null) + AppendFilter($"{column} != {action.Ne}"); + + if (action.In != null) + AppendFilter($"{column} = ANY ({Param(action.In)})"); + + if (action.Ni != null && action.Ni.Count > 0) + AppendFilter($"NOT ({column} = ANY ({Param(action.Ni)}))"); + + return this; + } + + public SqlBuilder FilterA(string column, StakingOperationKindParameter value) + { + if (value == null) return this; + + if (value.Eq != null) + AppendFilter($"{column} = {value.Eq}"); + + if (value.Ne != null) + AppendFilter($"{column} != {value.Ne}"); + + if (value.In != null) + AppendFilter($"{column} = ANY ({Param(value.In)})"); + + if (value.Ni != null && value.Ni.Count > 0) + AppendFilter($"NOT ({column} = ANY ({Param(value.Ni)}))"); + + return this; + } + public SqlBuilder Filter(string column, BigMapActionParameter action) { if (action == null) return this; diff --git a/Tzkt.Api/Websocket/Processors/EventsProcessor.cs b/Tzkt.Api/Websocket/Processors/EventsProcessor.cs index 3b9effb0a..713bae862 100644 --- a/Tzkt.Api/Websocket/Processors/EventsProcessor.cs +++ b/Tzkt.Api/Websocket/Processors/EventsProcessor.cs @@ -124,7 +124,7 @@ void Add(HashSet subs, ContractEvent e) #endregion #region tag subs - if (TagSubs.TryGetValue(e.Tag, out var tagSubs)) + if (e.Tag != null && TagSubs.TryGetValue(e.Tag, out var tagSubs)) Add(tagSubs, e); #endregion @@ -135,7 +135,7 @@ void Add(HashSet subs, ContractEvent e) Add(contractSubs.All, e); if (contractSubs.Tags != null) - if (contractSubs.Tags.TryGetValue(e.Tag, out var contractTagSubs)) + if (e.Tag != null && contractSubs.Tags.TryGetValue(e.Tag, out var contractTagSubs)) Add(contractTagSubs, e); } #endregion @@ -147,7 +147,7 @@ void Add(HashSet subs, ContractEvent e) Add(codeHashSubs.All, e); if (codeHashSubs.Tags != null) - if (codeHashSubs.Tags.TryGetValue(e.Tag, out var codeHashTagSubs)) + if (e.Tag != null && codeHashSubs.Tags.TryGetValue(e.Tag, out var codeHashTagSubs)) Add(codeHashTagSubs, e); } #endregion diff --git a/Tzkt.Api/Websocket/Processors/OperationsProcessor.cs b/Tzkt.Api/Websocket/Processors/OperationsProcessor.cs index a44eda803..dc8100952 100644 --- a/Tzkt.Api/Websocket/Processors/OperationsProcessor.cs +++ b/Tzkt.Api/Websocket/Processors/OperationsProcessor.cs @@ -228,6 +228,10 @@ public async Task OnStateChanged() ? Repo.GetSmartRollupRefuteOps(new() { level = level }, new() { limit = -1 }, symbols) : Task.FromResult(Enumerable.Empty()); + var stakingOps = TypeSubs.TryGetValue(Operations.Staking, out var stakingSubs) + ? Repo.GetStakingOps(new() { level = level }, new() { limit = -1 }, symbols) + : Task.FromResult(Enumerable.Empty()); + var migrations = TypeSubs.TryGetValue(Operations.Migrations, out var migrationsSub) ? Repo.GetMigrations(null, null, null, null, level, null, null, null, limit, MichelineFormat.Json, symbols, true, true) : Task.FromResult(Enumerable.Empty()); @@ -244,6 +248,10 @@ public async Task OnStateChanged() ? Repo.GetEndorsingRewards(null, null, level, null, null, null, limit, symbols) : Task.FromResult(Enumerable.Empty()); + var autostakingOps = TypeSubs.TryGetValue(Operations.Autostaking, out var autostakingOpsSub) + ? Repo.GetAutostakingOps(new() { level = level }, new() { limit = -1 }, symbols) + : Task.FromResult(Enumerable.Empty()); + await Task.WhenAll( endorsements, preendorsements, @@ -280,10 +288,12 @@ await Task.WhenAll( srPublishOps, srRecoverBondOps, srRefuteOps, + stakingOps, migrations, penalties, baking, - endorsingRewards); + endorsingRewards, + autostakingOps); #endregion #region prepare to send @@ -956,6 +966,22 @@ void AddByCodeHash(Dictionary> subs, Models.TransactionOper } } + if (stakingOps.Result.Any()) + { + if (stakingSubs.Subs != null) + AddRange(srRefuteSubs.Subs, stakingOps.Result); + + if (stakingSubs.AddressSubs != null) + foreach (var op in stakingOps.Result) + { + if (stakingSubs.AddressSubs.TryGetValue(op.Sender.Address, out var senderSubs)) + Add(senderSubs.Subs, op); + + if (op.Baker != null && stakingSubs.AddressSubs.TryGetValue(op.Baker.Address, out var bakerSubs)) + Add(bakerSubs.Subs, op); + } + } + if (migrations.Result.Any()) { if (migrationsSub.Subs != null) @@ -1004,6 +1030,17 @@ void AddByCodeHash(Dictionary> subs, Models.TransactionOper if (endorsingRewardsSub.AddressSubs.TryGetValue(op.Baker.Address, out var bakerSubs)) Add(bakerSubs.Subs, op); } + + if (autostakingOps.Result.Any()) + { + if (autostakingOpsSub.Subs != null) + AddRange(autostakingOpsSub.Subs, autostakingOps.Result); + + if (autostakingOpsSub.AddressSubs != null) + foreach (var op in autostakingOps.Result) + if (autostakingOpsSub.AddressSubs.TryGetValue(op.Baker.Address, out var bakerSubs)) + Add(bakerSubs.Subs, op); + } #endregion #region send diff --git a/Tzkt.Data/Migrations/20220911122259_Initial.Designer.cs b/Tzkt.Data/Migrations/20220911122259_Initial.Designer.cs deleted file mode 100644 index 66a605927..000000000 --- a/Tzkt.Data/Migrations/20220911122259_Initial.Designer.cs +++ /dev/null @@ -1,4747 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Tzkt.Data; - -namespace Tzkt.Data.Migrations -{ - [DbContext(typeof(TzktContext))] - [Migration("20220911122259_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.10") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("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("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - 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.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("DelegateId"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata") - .HasMethod("gin") - .HasOperators(new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - b.ToTable("Accounts"); - - b.HasDiscriminator("Type").HasValue((byte)3); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountCounter") - .HasColumnType("integer"); - - b.Property("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .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("DelegationOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsementOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardOpsCount") - .HasColumnType("integer"); - - b.Property("EventCounter") - .HasColumnType("integer"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("IncreasePaidStorageOpsCount") - .HasColumnType("integer"); - - b.Property("KnownHead") - .HasColumnType("integer"); - - b.Property("LastSync") - .HasColumnType("timestamp without time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerCounter") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - 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("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("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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("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, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - 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, - 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, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - StorageCounter = 0, - Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - 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, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - 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("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - b.ToTable("BakerCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .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("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("Cycle", "BakerId"); - - b.ToTable("BakingRights"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Ptr") - .IsUnique(); - - b.ToTable("BigMaps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 varying(54)"); - - 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("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonKey") - .HasMethod("gin") - .HasOperators(new[] { "jsonb_path_ops" }); - - b.HasIndex("JsonValue") - .HasMethod("gin") - .HasOperators(new[] { "jsonb_path_ops" }); - - b.HasIndex("LastLevel"); - - b.HasIndex("BigMapPtr", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - b.ToTable("BigMapKeys"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - b.Property("Fees") - .HasColumnType("bigint"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("LBToggle") - .HasColumnType("boolean"); - - b.Property("LBToggleEma") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("Operations") - .HasColumnType("integer"); - - 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("Reward") - .HasColumnType("bigint"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character(37)") - .IsFixedLength(true); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("Commitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonPayload") - .HasMethod("gin") - .HasOperators(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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(true); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("PrevDelegateId") - .HasColumnType("integer"); - - 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("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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"); - - b.ToTable("DelegationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - b.ToTable("DelegatorCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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.EndorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Expected") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Received") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("EndorsingRewardOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(true); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("RevealedCycle") - .HasColumnType("integer"); - - b.Property("RevealedLevel") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - b.ToTable("Proposals"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .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(true); - - b.Property("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBSunsetLevel") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Protocols"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 without time zone"); - - b.Property("Usd") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Quotes"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OpHash") - .HasColumnType("text"); - - 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 without time zone"); - - b.Property("Value") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique() - .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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("text"); - - b.Property("OpHash") - .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 without time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SetDepositsLimitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - b.ToTable("SnapshotBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(true); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Date") - .HasColumnType("timestamp without 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("TotalRollupBonds") - .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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Token", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata") - .HasMethod("gin") - .HasOperators(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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - 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("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - 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.ToTable("TokenTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("JsonParameters") - .HasMethod("gin") - .HasOperators(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.ToTable("TransactionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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(true); - - 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("TargetId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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.VdfRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("Proof") - .HasColumnType("bytea"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("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.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("VotingPeriods"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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"); - - 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("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"); - - b.HasIndex("Type", "Kind") - .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.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasMaxLength(55) - .HasColumnType("character varying(55)"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - 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("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("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .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.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.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.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.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.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("Delegations"); - - b.Navigation("DoubleBakings"); - - b.Navigation("DoubleEndorsings"); - - b.Navigation("DoublePreendorsings"); - - 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("SetDepositsLimits"); - - 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("VdfRevelationOps"); - }); - - 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/20220911122311_Triggers.Designer.cs b/Tzkt.Data/Migrations/20220911122311_Triggers.Designer.cs deleted file mode 100644 index 5ef3eaf9a..000000000 --- a/Tzkt.Data/Migrations/20220911122311_Triggers.Designer.cs +++ /dev/null @@ -1,4747 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Tzkt.Data; - -namespace Tzkt.Data.Migrations -{ - [DbContext(typeof(TzktContext))] - [Migration("20220911122311_Triggers")] - partial class Triggers - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.10") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("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("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - 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.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("DelegateId"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata") - .HasMethod("gin") - .HasOperators(new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - b.ToTable("Accounts"); - - b.HasDiscriminator("Type").HasValue((byte)3); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountCounter") - .HasColumnType("integer"); - - b.Property("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .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("DelegationOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsementOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardOpsCount") - .HasColumnType("integer"); - - b.Property("EventCounter") - .HasColumnType("integer"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("IncreasePaidStorageOpsCount") - .HasColumnType("integer"); - - b.Property("KnownHead") - .HasColumnType("integer"); - - b.Property("LastSync") - .HasColumnType("timestamp without time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerCounter") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - 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("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("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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("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, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - 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, - 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, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - StorageCounter = 0, - Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - 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, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - 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("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - b.ToTable("BakerCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .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("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("Cycle", "BakerId"); - - b.ToTable("BakingRights"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Ptr") - .IsUnique(); - - b.ToTable("BigMaps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 varying(54)"); - - 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("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonKey") - .HasMethod("gin") - .HasOperators(new[] { "jsonb_path_ops" }); - - b.HasIndex("JsonValue") - .HasMethod("gin") - .HasOperators(new[] { "jsonb_path_ops" }); - - b.HasIndex("LastLevel"); - - b.HasIndex("BigMapPtr", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - b.ToTable("BigMapKeys"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - b.Property("Fees") - .HasColumnType("bigint"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("LBToggle") - .HasColumnType("boolean"); - - b.Property("LBToggleEma") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("Operations") - .HasColumnType("integer"); - - 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("Reward") - .HasColumnType("bigint"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character(37)") - .IsFixedLength(true); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("Commitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonPayload") - .HasMethod("gin") - .HasOperators(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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(true); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("PrevDelegateId") - .HasColumnType("integer"); - - 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("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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"); - - b.ToTable("DelegationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - b.ToTable("DelegatorCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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.EndorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Expected") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Received") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("EndorsingRewardOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(true); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("RevealedCycle") - .HasColumnType("integer"); - - b.Property("RevealedLevel") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - b.ToTable("Proposals"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .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(true); - - b.Property("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBSunsetLevel") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Protocols"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 without time zone"); - - b.Property("Usd") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Quotes"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OpHash") - .HasColumnType("text"); - - 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 without time zone"); - - b.Property("Value") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique() - .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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("text"); - - b.Property("OpHash") - .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 without time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SetDepositsLimitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - b.ToTable("SnapshotBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(true); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Date") - .HasColumnType("timestamp without 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("TotalRollupBonds") - .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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Token", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata") - .HasMethod("gin") - .HasOperators(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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - 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("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - 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.ToTable("TokenTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("JsonParameters") - .HasMethod("gin") - .HasOperators(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.ToTable("TransactionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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(true); - - 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("TargetId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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.VdfRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("Proof") - .HasColumnType("bytea"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("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.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("VotingPeriods"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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"); - - 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("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"); - - b.HasIndex("Type", "Kind") - .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.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasMaxLength(55) - .HasColumnType("character varying(55)"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - 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("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("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .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.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.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.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.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.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("Delegations"); - - b.Navigation("DoubleBakings"); - - b.Navigation("DoubleEndorsings"); - - b.Navigation("DoublePreendorsings"); - - 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("SetDepositsLimits"); - - 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("VdfRevelationOps"); - }); - - 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/20221103054843_SingleWinner.Designer.cs b/Tzkt.Data/Migrations/20221103054843_SingleWinner.Designer.cs deleted file mode 100644 index 8d7e209dd..000000000 --- a/Tzkt.Data/Migrations/20221103054843_SingleWinner.Designer.cs +++ /dev/null @@ -1,4750 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Tzkt.Data; - -namespace Tzkt.Data.Migrations -{ - [DbContext(typeof(TzktContext))] - [Migration("20221103054843_SingleWinner")] - partial class SingleWinner - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:MaxIdentifierLength", 63) - .HasAnnotation("ProductVersion", "5.0.10") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("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("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - 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.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("DelegateId"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata") - .HasMethod("gin") - .HasOperators(new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - b.ToTable("Accounts"); - - b.HasDiscriminator("Type").HasValue((byte)3); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountCounter") - .HasColumnType("integer"); - - b.Property("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .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("DelegationOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsementOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardOpsCount") - .HasColumnType("integer"); - - b.Property("EventCounter") - .HasColumnType("integer"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("IncreasePaidStorageOpsCount") - .HasColumnType("integer"); - - b.Property("KnownHead") - .HasColumnType("integer"); - - b.Property("LastSync") - .HasColumnType("timestamp without time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerCounter") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - 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("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("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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("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, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - 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, - 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, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - StorageCounter = 0, - Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - 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, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - 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("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - b.ToTable("BakerCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .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("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("Cycle", "BakerId"); - - b.ToTable("BakingRights"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Ptr") - .IsUnique(); - - b.ToTable("BigMaps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 varying(54)"); - - 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("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonKey") - .HasMethod("gin") - .HasOperators(new[] { "jsonb_path_ops" }); - - b.HasIndex("JsonValue") - .HasMethod("gin") - .HasOperators(new[] { "jsonb_path_ops" }); - - b.HasIndex("LastLevel"); - - b.HasIndex("BigMapPtr", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - b.ToTable("BigMapKeys"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - b.Property("Fees") - .HasColumnType("bigint"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("LBToggle") - .HasColumnType("boolean"); - - b.Property("LBToggleEma") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("Operations") - .HasColumnType("integer"); - - 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("Reward") - .HasColumnType("bigint"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character(37)") - .IsFixedLength(true); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("Commitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonPayload") - .HasMethod("gin") - .HasOperators(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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(true); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("PrevDelegateId") - .HasColumnType("integer"); - - 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("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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"); - - b.ToTable("DelegationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - b.ToTable("DelegatorCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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.EndorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Expected") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Received") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("EndorsingRewardOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(true); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("RevealedCycle") - .HasColumnType("integer"); - - b.Property("RevealedLevel") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(true); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - b.ToTable("Proposals"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .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(true); - - b.Property("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBSunsetLevel") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Protocols"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 without time zone"); - - b.Property("Usd") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Quotes"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OpHash") - .HasColumnType("text"); - - 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 without time zone"); - - b.Property("Value") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique() - .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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("text"); - - b.Property("OpHash") - .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 without time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SetDepositsLimitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - b.ToTable("SnapshotBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(true); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Date") - .HasColumnType("timestamp without 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("TotalRollupBonds") - .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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Token", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata") - .HasMethod("gin") - .HasOperators(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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - 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("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - 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.ToTable("TokenTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("JsonParameters") - .HasMethod("gin") - .HasOperators(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.ToTable("TransactionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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(true); - - 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("TargetId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - 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 without 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.VdfRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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(true); - - b.Property("Proof") - .HasColumnType("bytea"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp without time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("VotingPeriods"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - 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"); - - 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("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"); - - b.HasIndex("Type", "Kind") - .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.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasMaxLength(55) - .HasColumnType("character varying(55)"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - 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("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("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .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.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.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.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.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.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("Delegations"); - - b.Navigation("DoubleBakings"); - - b.Navigation("DoubleEndorsings"); - - b.Navigation("DoublePreendorsings"); - - 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("SetDepositsLimits"); - - 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("VdfRevelationOps"); - }); - - 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/20221103054843_SingleWinner.cs b/Tzkt.Data/Migrations/20221103054843_SingleWinner.cs deleted file mode 100644 index a64c2fafd..000000000 --- a/Tzkt.Data/Migrations/20221103054843_SingleWinner.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Tzkt.Data.Models; - -namespace Tzkt.Data.Migrations -{ - public partial class SingleWinner : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "SingleWinner", - table: "VotingPeriods", - type: "boolean", - nullable: true); - - migrationBuilder.Sql($@" - UPDATE ""VotingPeriods"" - SET ""SingleWinner"" = false - WHERE ""Kind"" = {(int)PeriodKind.Proposal} - AND ""TopVotingPower"" = 0"); - - migrationBuilder.Sql($@" - UPDATE ""VotingPeriods"" - SET ""SingleWinner"" = true - WHERE ""Kind"" = {(int)PeriodKind.Proposal} - AND ""TopVotingPower"" > 0"); - - migrationBuilder.Sql($@" - UPDATE ""VotingPeriods"" - SET ""Status"" = {(int)PeriodStatus.Success} - WHERE ""Status"" = {(int)PeriodStatus.NoSingleWinner}"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "SingleWinner", - table: "VotingPeriods"); - } - } -} diff --git a/Tzkt.Data/Migrations/20221124151948_Lima.Designer.cs b/Tzkt.Data/Migrations/20221124151948_Lima.Designer.cs deleted file mode 100644 index b7f2cd1a9..000000000 --- a/Tzkt.Data/Migrations/20221124151948_Lima.Designer.cs +++ /dev/null @@ -1,4982 +0,0 @@ -// -using System; -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("20221124151948_Lima")] - partial class Lima - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .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("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("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("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - 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("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - 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("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .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("DelegationOpsCount") - .HasColumnType("integer"); - - 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("Hash") - .HasColumnType("text"); - - 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("Metadata") - .HasColumnType("jsonb"); - - 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("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("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .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("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, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - DrainDelegateOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - 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, - 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, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - StorageCounter = 0, - Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - 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, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - 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("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - 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("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("Cycle"); - - 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.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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 varying(54)"); - - 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("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - 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("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - 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("Metadata") - .HasColumnType("jsonb"); - - 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("Reward") - .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("Address") - .IsUnique(); - - b.HasIndex("Id") - .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("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - 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("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"); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - b.ToTable("DelegatorCycles"); - }); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("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("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("Received") - .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.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - 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("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - 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("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .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("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - 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.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("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OpHash") - .HasColumnType("text"); - - 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") - .IsUnique() - .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("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - 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("text"); - - b.Property("OpHash") - .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("SetDepositsLimitOps"); - }); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - 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("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - 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("TotalRollupBonds") - .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("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - 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") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - 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.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("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.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") - .IsRequired() - .HasColumnType("text"); - - 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("TargetId") - .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.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("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - 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.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - 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"); - - 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("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"); - - b.HasIndex("Type", "Kind") - .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.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasMaxLength(55) - .HasColumnType("character varying(55)"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - 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("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("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .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.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.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.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("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("SetDepositsLimits"); - - 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.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/20221124151948_Lima.cs b/Tzkt.Data/Migrations/20221124151948_Lima.cs deleted file mode 100644 index d16ad63f8..000000000 --- a/Tzkt.Data/Migrations/20221124151948_Lima.cs +++ /dev/null @@ -1,290 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class Lima : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - void ToTimestamptz(string table, string column) => - migrationBuilder.Sql($@"ALTER TABLE ""{table}"" ALTER ""{column}"" TYPE timestamptz USING ""{column}"" AT TIME ZONE 'UTC';"); - - Triggers.RemoveNotificationTrigger(migrationBuilder, "sync_state_changed", "AppState"); - - ToTimestamptz("VdfRevelationOps", "Timestamp"); - ToTimestamptz("TxRollupSubmitBatchOps", "Timestamp"); - ToTimestamptz("TxRollupReturnBondOps", "Timestamp"); - ToTimestamptz("TxRollupRemoveCommitmentOps", "Timestamp"); - ToTimestamptz("TxRollupRejectionOps", "Timestamp"); - ToTimestamptz("TxRollupOriginationOps", "Timestamp"); - ToTimestamptz("TxRollupFinalizeCommitmentOps", "Timestamp"); - ToTimestamptz("TxRollupDispatchTicketsOps", "Timestamp"); - ToTimestamptz("TxRollupCommitOps", "Timestamp"); - ToTimestamptz("TransferTicketOps", "Timestamp"); - ToTimestamptz("TransactionOps", "Timestamp"); - ToTimestamptz("Statistics", "Date"); - ToTimestamptz("SetDepositsLimitOps", "Timestamp"); - ToTimestamptz("RevelationPenaltyOps", "Timestamp"); - ToTimestamptz("RevealOps", "Timestamp"); - ToTimestamptz("RegisterConstantOps", "Timestamp"); - ToTimestamptz("Quotes", "Timestamp"); - ToTimestamptz("ProposalOps", "Timestamp"); - ToTimestamptz("PreendorsementOps", "Timestamp"); - ToTimestamptz("OriginationOps", "Timestamp"); - ToTimestamptz("NonceRevelationOps", "Timestamp"); - ToTimestamptz("MigrationOps", "Timestamp"); - ToTimestamptz("IncreasePaidStorageOps", "Timestamp"); - ToTimestamptz("EndorsingRewardOps", "Timestamp"); - ToTimestamptz("EndorsementOps", "Timestamp"); - ToTimestamptz("DoublePreendorsingOps", "Timestamp"); - ToTimestamptz("DoubleEndorsingOps", "Timestamp"); - ToTimestamptz("DoubleBakingOps", "Timestamp"); - ToTimestamptz("DelegationOps", "Timestamp"); - ToTimestamptz("Blocks", "Timestamp"); - ToTimestamptz("BallotOps", "Timestamp"); - ToTimestamptz("AppState", "Timestamp"); - ToTimestamptz("AppState", "LastSync"); - ToTimestamptz("ActivationOps", "Timestamp"); - - Triggers.AddNotificationTrigger(migrationBuilder, - name: "sync_state_changed", - table: "AppState", - column: "LastSync", - payload: @"NEW.""KnownHead"" || ':' || NEW.""LastSync"""); - - migrationBuilder.DropColumn( - name: "LBSunsetLevel", - table: "Protocols"); - - migrationBuilder.AlterColumn( - name: "Operations", - table: "Blocks", - type: "bigint", - nullable: false, - oldClrType: typeof(int), - oldType: "integer"); - - migrationBuilder.AddColumn( - name: "DrainDelegateOpsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "UpdateConsensusKeyOpsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "DrainDelegateCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "UpdateConsensusKeyCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.CreateTable( - name: "DrainDelegateOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DelegateId = table.Column(type: "integer", nullable: false), - TargetId = table.Column(type: "integer", nullable: false), - Amount = table.Column(type: "bigint", nullable: false), - Fee = table.Column(type: "bigint", nullable: false), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DrainDelegateOps", x => x.Id); - table.ForeignKey( - name: "FK_DrainDelegateOps_Blocks_Level", - column: x => x.Level, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "UpdateConsensusKeyOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ActivationCycle = table.Column(type: "integer", nullable: false), - PublicKey = table.Column(type: "text", nullable: true), - PublicKeyHash = table.Column(type: "text", nullable: true), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - Counter = table.Column(type: "integer", nullable: false), - BakerFee = table.Column(type: "bigint", nullable: false), - StorageFee = table.Column(type: "bigint", nullable: true), - AllocationFee = table.Column(type: "bigint", nullable: true), - GasLimit = table.Column(type: "integer", nullable: false), - GasUsed = table.Column(type: "integer", nullable: false), - StorageLimit = table.Column(type: "integer", nullable: false), - StorageUsed = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_UpdateConsensusKeyOps", x => x.Id); - table.ForeignKey( - name: "FK_UpdateConsensusKeyOps_Accounts_SenderId", - column: x => x.SenderId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_UpdateConsensusKeyOps_Blocks_Level", - column: x => x.Level, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_DrainDelegateOps_DelegateId", - table: "DrainDelegateOps", - column: "DelegateId"); - - migrationBuilder.CreateIndex( - name: "IX_DrainDelegateOps_Level", - table: "DrainDelegateOps", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_DrainDelegateOps_OpHash", - table: "DrainDelegateOps", - column: "OpHash"); - - migrationBuilder.CreateIndex( - name: "IX_DrainDelegateOps_TargetId", - table: "DrainDelegateOps", - column: "TargetId"); - - migrationBuilder.CreateIndex( - name: "IX_UpdateConsensusKeyOps_Level", - table: "UpdateConsensusKeyOps", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_UpdateConsensusKeyOps_OpHash", - table: "UpdateConsensusKeyOps", - column: "OpHash"); - - migrationBuilder.CreateIndex( - name: "IX_UpdateConsensusKeyOps_SenderId", - table: "UpdateConsensusKeyOps", - column: "SenderId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - void ToTimestamp(string table, string column) => - migrationBuilder.Sql($@"ALTER TABLE ""{table}"" ALTER ""{column}"" TYPE timestamp;"); - - Triggers.RemoveNotificationTrigger(migrationBuilder, "sync_state_changed", "AppState"); - - ToTimestamp("VdfRevelationOps", "Timestamp"); - ToTimestamp("TxRollupSubmitBatchOps", "Timestamp"); - ToTimestamp("TxRollupReturnBondOps", "Timestamp"); - ToTimestamp("TxRollupRemoveCommitmentOps", "Timestamp"); - ToTimestamp("TxRollupRejectionOps", "Timestamp"); - ToTimestamp("TxRollupOriginationOps", "Timestamp"); - ToTimestamp("TxRollupFinalizeCommitmentOps", "Timestamp"); - ToTimestamp("TxRollupDispatchTicketsOps", "Timestamp"); - ToTimestamp("TxRollupCommitOps", "Timestamp"); - ToTimestamp("TransferTicketOps", "Timestamp"); - ToTimestamp("TransactionOps", "Timestamp"); - ToTimestamp("Statistics", "Date"); - ToTimestamp("SetDepositsLimitOps", "Timestamp"); - ToTimestamp("RevelationPenaltyOps", "Timestamp"); - ToTimestamp("RevealOps", "Timestamp"); - ToTimestamp("RegisterConstantOps", "Timestamp"); - ToTimestamp("Quotes", "Timestamp"); - ToTimestamp("ProposalOps", "Timestamp"); - ToTimestamp("PreendorsementOps", "Timestamp"); - ToTimestamp("OriginationOps", "Timestamp"); - ToTimestamp("NonceRevelationOps", "Timestamp"); - ToTimestamp("MigrationOps", "Timestamp"); - ToTimestamp("IncreasePaidStorageOps", "Timestamp"); - ToTimestamp("EndorsingRewardOps", "Timestamp"); - ToTimestamp("EndorsementOps", "Timestamp"); - ToTimestamp("DoublePreendorsingOps", "Timestamp"); - ToTimestamp("DoubleEndorsingOps", "Timestamp"); - ToTimestamp("DoubleBakingOps", "Timestamp"); - ToTimestamp("DelegationOps", "Timestamp"); - ToTimestamp("Blocks", "Timestamp"); - ToTimestamp("BallotOps", "Timestamp"); - ToTimestamp("AppState", "Timestamp"); - ToTimestamp("AppState", "LastSync"); - ToTimestamp("ActivationOps", "Timestamp"); - - Triggers.AddNotificationTrigger(migrationBuilder, - name: "sync_state_changed", - table: "AppState", - column: "LastSync", - payload: @"NEW.""KnownHead"" || ':' || NEW.""LastSync"""); - - migrationBuilder.DropTable( - name: "DrainDelegateOps"); - - migrationBuilder.DropTable( - name: "UpdateConsensusKeyOps"); - - migrationBuilder.DropColumn( - name: "DrainDelegateOpsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "UpdateConsensusKeyOpsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "DrainDelegateCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "UpdateConsensusKeyCount", - table: "Accounts"); - - migrationBuilder.AddColumn( - name: "LBSunsetLevel", - table: "Protocols", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AlterColumn( - name: "Operations", - table: "Blocks", - type: "integer", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint"); - } - } -} diff --git a/Tzkt.Data/Migrations/20221204065246_Domains.Designer.cs b/Tzkt.Data/Migrations/20221204065246_Domains.Designer.cs deleted file mode 100644 index 3efa3dd9b..000000000 --- a/Tzkt.Data/Migrations/20221204065246_Domains.Designer.cs +++ /dev/null @@ -1,5039 +0,0 @@ -// -using System; -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("20221204065246_Domains")] - partial class Domains - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .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("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("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("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - 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("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - 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("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .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("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("Hash") - .HasColumnType("text"); - - 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("Metadata") - .HasColumnType("jsonb"); - - 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("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("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .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("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, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DomainsLevel = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - DrainDelegateOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - 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, - 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, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - StorageCounter = 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, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - 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("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - 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("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("Cycle"); - - 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.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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 varying(54)"); - - 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("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - 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("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - 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("Metadata") - .HasColumnType("jsonb"); - - 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("Reward") - .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("Address") - .IsUnique(); - - b.HasIndex("Id") - .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("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - 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("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"); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - 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.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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("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("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("Received") - .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.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - 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("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - 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("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .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("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - 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.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("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OpHash") - .HasColumnType("text"); - - 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") - .IsUnique() - .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("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - 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("text"); - - b.Property("OpHash") - .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("SetDepositsLimitOps"); - }); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - 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("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - 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("TotalRollupBonds") - .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("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - 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") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - 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.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("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.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") - .IsRequired() - .HasColumnType("text"); - - 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("TargetId") - .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.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("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - 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.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - 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"); - - 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("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"); - - b.HasIndex("Type", "Kind") - .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.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasMaxLength(55) - .HasColumnType("character varying(55)"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - 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("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("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .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.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.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.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("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("SetDepositsLimits"); - - 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.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/20221204065246_Domains.cs b/Tzkt.Data/Migrations/20221204065246_Domains.cs deleted file mode 100644 index c723bd7de..000000000 --- a/Tzkt.Data/Migrations/20221204065246_Domains.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Text.Json; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class Domains : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "DomainsLevel", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "DomainsNameRegistry", - table: "AppState", - type: "text", - nullable: true); - - migrationBuilder.CreateTable( - name: "Domains", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Level = table.Column(type: "integer", nullable: false), - Name = table.Column(type: "text", nullable: true), - Address = table.Column(type: "text", nullable: true), - Owner = table.Column(type: "text", nullable: true), - Expiration = table.Column(type: "timestamp with time zone", nullable: false), - Data = table.Column(type: "jsonb", nullable: true), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Domains", x => x.Id); - }); - - migrationBuilder.UpdateData( - table: "AppState", - keyColumn: "Id", - keyValue: -1, - columns: new[] { "DomainsLevel", "DomainsNameRegistry" }, - values: new object[] { 0, null }); - - migrationBuilder.CreateIndex( - name: "IX_Domains_Address", - table: "Domains", - column: "Address"); - - migrationBuilder.CreateIndex( - name: "IX_Domains_FirstLevel", - table: "Domains", - column: "FirstLevel"); - - migrationBuilder.CreateIndex( - name: "IX_Domains_LastLevel", - table: "Domains", - column: "LastLevel"); - - migrationBuilder.CreateIndex( - name: "IX_Domains_Level", - table: "Domains", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_Domains_Name", - table: "Domains", - column: "Name"); - - migrationBuilder.CreateIndex( - name: "IX_Domains_Owner", - table: "Domains", - column: "Owner"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Domains"); - - migrationBuilder.DropColumn( - name: "DomainsLevel", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "DomainsNameRegistry", - table: "AppState"); - } - } -} diff --git a/Tzkt.Data/Migrations/20230112111428_Metadata.Designer.cs b/Tzkt.Data/Migrations/20230112111428_Metadata.Designer.cs deleted file mode 100644 index 7ef66b8e7..000000000 --- a/Tzkt.Data/Migrations/20230112111428_Metadata.Designer.cs +++ /dev/null @@ -1,5050 +0,0 @@ -// -using System; -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("20230112111428_Metadata")] - partial class Metadata - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.1") - .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("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("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - 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("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - 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("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .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("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("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("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("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .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("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, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DomainsLevel = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - DrainDelegateOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - 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, - 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, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - StorageCounter = 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, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - 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("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - 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("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("Cycle"); - - 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.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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 varying(54)"); - - 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("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - 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("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .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("Reward") - .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("Address") - .IsUnique(); - - b.HasIndex("Id") - .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("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - 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("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"); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("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("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("Received") - .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.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - 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("Hash"); - - 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("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .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("FrozenDepositsPercentage") - .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("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - 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.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") - .HasColumnType("text"); - - 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") - .IsUnique() - .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("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - 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("text"); - - b.Property("OpHash") - .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("SetDepositsLimitOps"); - }); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - 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.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("TotalRollupBonds") - .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("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - 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") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - 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.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("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.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") - .IsRequired() - .HasColumnType("text"); - - 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("TargetId") - .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.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("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - 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.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - 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"); - - 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("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"); - - b.HasIndex("Type", "Kind") - .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.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasMaxLength(55) - .HasColumnType("character varying(55)"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - 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("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("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .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.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.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.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("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("SetDepositsLimits"); - - 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.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/20230112111428_Metadata.cs b/Tzkt.Data/Migrations/20230112111428_Metadata.cs deleted file mode 100644 index 84b3961a8..000000000 --- a/Tzkt.Data/Migrations/20230112111428_Metadata.cs +++ /dev/null @@ -1,249 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class Metadata : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - Triggers.RemoveNotificationTrigger(migrationBuilder, "state_metadata_changed", "AppState"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "account_metadata_changed", "Accounts"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "proposal_metadata_changed", "Proposals"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "protocol_metadata_changed", "Protocols"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "software_metadata_changed", "Software"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "block_metadata_changed", "Blocks"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "constant_metadata_changed", "RegisterConstantOps"); - - migrationBuilder.AddColumn( - name: "Reverse", - table: "Domains", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.RenameColumn( - name: "Metadata", - table: "Software", - newName: "Extras"); - - migrationBuilder.RenameColumn( - name: "Metadata", - table: "RegisterConstantOps", - newName: "Extras"); - - migrationBuilder.RenameColumn( - name: "Metadata", - table: "Protocols", - newName: "Extras"); - - migrationBuilder.RenameColumn( - name: "Metadata", - table: "Proposals", - newName: "Extras"); - - migrationBuilder.RenameColumn( - name: "Metadata", - table: "Blocks", - newName: "Extras"); - - migrationBuilder.RenameColumn( - name: "Metadata", - table: "AppState", - newName: "Extras"); - - migrationBuilder.RenameColumn( - name: "Metadata", - table: "Accounts", - newName: "Extras"); - - migrationBuilder.AddColumn( - name: "Metadata", - table: "Accounts", - type: "jsonb", - nullable: true); - - migrationBuilder.DropIndex( - name: "IX_Accounts_Metadata", - table: "Accounts"); - - migrationBuilder.CreateIndex( - name: "IX_Accounts_Metadata", - table: "Accounts", - column: "Metadata") - .Annotation("Npgsql:IndexMethod", "gin") - .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); - - migrationBuilder.CreateIndex( - name: "IX_Accounts_Extras", - table: "Accounts", - column: "Extras") - .Annotation("Npgsql:IndexMethod", "gin") - .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); - - Triggers.AddNotificationTrigger(migrationBuilder, - "state_extras_changed", - "AppState", - "Extras", - @"NEW.""Id"" || ':' || COALESCE(NEW.""Extras""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "account_extras_changed", - "Accounts", - "Extras", - @"NEW.""Address"" || ':' || COALESCE(NEW.""Extras""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "account_metadata_changed", - "Accounts", - "Metadata", - @"NEW.""Address"" || ':'"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "proposal_extras_changed", - "Proposals", - "Extras", - @"NEW.""Hash"" || ':' || COALESCE(NEW.""Extras""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "protocol_extras_changed", - "Protocols", - "Extras", - @"NEW.""Hash"" || ':' || COALESCE(NEW.""Extras""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "software_extras_changed", - "Software", - "Extras", - @"NEW.""ShortHash"" || ':' || COALESCE(NEW.""Extras""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "block_extras_changed", - "Blocks", - "Extras", - @"NEW.""Level"" || ':' || COALESCE(NEW.""Extras""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "constant_extras_changed", - "RegisterConstantOps", - "Extras", - @"COALESCE(NEW.""Address"", '') || ':' || COALESCE(NEW.""Extras""::text, '')"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - Triggers.RemoveNotificationTrigger(migrationBuilder, "state_extras_changed", "AppState"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "account_extras_changed", "Accounts"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "account_metadata_changed", "Accounts"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "proposal_extras_changed", "Proposals"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "protocol_extras_changed", "Protocols"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "software_extras_changed", "Software"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "block_extras_changed", "Blocks"); - Triggers.RemoveNotificationTrigger(migrationBuilder, "constant_extras_changed", "RegisterConstantOps"); - - migrationBuilder.DropIndex( - name: "IX_Accounts_Extras", - table: "Accounts"); - - migrationBuilder.DropIndex( - name: "IX_Accounts_Metadata", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "Metadata", - table: "Accounts"); - - migrationBuilder.RenameColumn( - name: "Extras", - table: "Accounts", - newName: "Metadata"); - - migrationBuilder.CreateIndex( - name: "IX_Accounts_Metadata", - table: "Accounts", - column: "Metadata") - .Annotation("Npgsql:IndexMethod", "gin") - .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); - - migrationBuilder.RenameColumn( - name: "Extras", - table: "Software", - newName: "Metadata"); - - migrationBuilder.RenameColumn( - name: "Extras", - table: "RegisterConstantOps", - newName: "Metadata"); - - migrationBuilder.RenameColumn( - name: "Extras", - table: "Protocols", - newName: "Metadata"); - - migrationBuilder.RenameColumn( - name: "Extras", - table: "Proposals", - newName: "Metadata"); - - migrationBuilder.RenameColumn( - name: "Extras", - table: "Blocks", - newName: "Metadata"); - - migrationBuilder.RenameColumn( - name: "Extras", - table: "AppState", - newName: "Metadata"); - - migrationBuilder.DropColumn( - name: "Reverse", - table: "Domains"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "state_metadata_changed", - "AppState", - "Metadata", - @"NEW.""Id"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "account_metadata_changed", - "Accounts", - "Metadata", - @"NEW.""Address"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "proposal_metadata_changed", - "Proposals", - "Metadata", - @"NEW.""Hash"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "protocol_metadata_changed", - "Protocols", - "Metadata", - @"NEW.""Hash"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "software_metadata_changed", - "Software", - "Metadata", - @"NEW.""ShortHash"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "block_metadata_changed", - "Blocks", - "Metadata", - @"NEW.""Level"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); - - Triggers.AddNotificationTrigger(migrationBuilder, - "constant_metadata_changed", - "RegisterConstantOps", - "Metadata", - @"COALESCE(NEW.""Address"", '') || ':' || COALESCE(NEW.""Metadata""::text, '')"); - } - } -} diff --git a/Tzkt.Data/Migrations/20230228204409_Mumbai.Designer.cs b/Tzkt.Data/Migrations/20230228204409_Mumbai.Designer.cs deleted file mode 100644 index 66b1c3a12..000000000 --- a/Tzkt.Data/Migrations/20230228204409_Mumbai.Designer.cs +++ /dev/null @@ -1,6049 +0,0 @@ -// -using System; -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("20230228204409_Mumbai")] - partial class Mumbai - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") - .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("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("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("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - 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("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .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("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("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("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("StorageCounter") - .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("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, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 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, - 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, - SetDepositsLimitOpsCount = 0, - SmartRollupAddMessagesOpsCount = 0, - SmartRollupCementOpsCount = 0, - SmartRollupCommitmentCounter = 0, - SmartRollupExecuteOpsCount = 0, - SmartRollupOriginateOpsCount = 0, - SmartRollupPublishOpsCount = 0, - SmartRollupRecoverBondOpsCount = 0, - SmartRollupRefuteOpsCount = 0, - StorageCounter = 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, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - 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("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - 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("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("Cycle"); - - 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.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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 varying(54)"); - - 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("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - 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("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .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("Reward") - .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("Address") - .IsUnique(); - - b.HasIndex("Id") - .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("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - 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("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"); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("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("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("Received") - .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.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OperationId") - .HasColumnType("bigint"); - - b.Property("Payload") - .HasColumnType("bytea"); - - b.Property("PredecessorLevel") - .HasColumnType("integer"); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - 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("Hash"); - - 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("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .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("FrozenDepositsPercentage") - .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("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - 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("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - 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"); - - 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") - .HasColumnType("text"); - - 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") - .IsUnique() - .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("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - 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("text"); - - b.Property("OpHash") - .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("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("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - 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("Hash"); - - 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("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - 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("OriginationProof") - .HasColumnType("bytea"); - - 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"); - - b.HasIndex("SmartRollupId", "BondStatus", "SenderId") - .HasFilter("\"BondStatus\" IS NOT NULL"); - - 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("GameId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - 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.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("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("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - 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") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - 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.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("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.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") - .IsRequired() - .HasColumnType("text"); - - 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("TargetId") - .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.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("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - 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.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - 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"); - - 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("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"); - - b.HasIndex("Type", "Kind") - .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("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("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - 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("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("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .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.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.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.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("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("SetDepositsLimits"); - - b.Navigation("SmartRollupAddMessagesOps"); - - b.Navigation("SmartRollupCementOps"); - - b.Navigation("SmartRollupExecuteOps"); - - b.Navigation("SmartRollupOriginateOps"); - - b.Navigation("SmartRollupPublishOps"); - - b.Navigation("SmartRollupRecoverBondOps"); - - b.Navigation("SmartRollupRefuteOps"); - - 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.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/20230228204409_Mumbai.cs b/Tzkt.Data/Migrations/20230228204409_Mumbai.cs deleted file mode 100644 index 4c714cdb4..000000000 --- a/Tzkt.Data/Migrations/20230228204409_Mumbai.cs +++ /dev/null @@ -1,1078 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class Mumbai : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "TotalSmartRollupBonds", - table: "Statistics", - type: "bigint", - nullable: false, - defaultValue: 0L); - - migrationBuilder.AddColumn( - name: "SmartRollupChallengeWindow", - table: "Protocols", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupCommitmentPeriod", - table: "Protocols", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupOriginationSize", - table: "Protocols", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupStakeAmount", - table: "Protocols", - type: "bigint", - nullable: false, - defaultValue: 0L); - - migrationBuilder.AddColumn( - name: "SmartRollupTimeoutPeriod", - table: "Protocols", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "InboxMessageCounter", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "RefutationGameCounter", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupAddMessagesOpsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupCementOpsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupCommitmentCounter", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupExecuteOpsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupOriginateOpsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupPublishOpsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupRecoverBondOpsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupRefuteOpsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AlterColumn( - name: "PublicKey", - table: "Accounts", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(55)", - oldMaxLength: 55, - oldNullable: true); - - migrationBuilder.AddColumn( - name: "ActiveRefutationGamesCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "ActiveStakers", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "CementedCommitments", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "ExecutedCommitments", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "GenesisCommitment", - table: "Accounts", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "InboxLevel", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "LastCommitment", - table: "Accounts", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "OrphanCommitments", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "PendingCommitments", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "PvmKind", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "RefutationGamesCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "RefutedCommitments", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "SmartRollupAddMessagesCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupBonds", - table: "Accounts", - type: "bigint", - nullable: false, - defaultValue: 0L); - - migrationBuilder.AddColumn( - name: "SmartRollupCementCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupExecuteCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupOriginateCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupPublishCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupRecoverBondCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupRefuteCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SmartRollupsCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TotalStakers", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.CreateTable( - name: "InboxMessages", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Level = table.Column(type: "integer", nullable: false), - Type = table.Column(type: "integer", nullable: false), - PredecessorLevel = table.Column(type: "integer", nullable: true), - OperationId = table.Column(type: "bigint", nullable: true), - Payload = table.Column(type: "bytea", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_InboxMessages", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "RefutationGames", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - SmartRollupId = table.Column(type: "integer", nullable: false), - InitiatorId = table.Column(type: "integer", nullable: false), - OpponentId = table.Column(type: "integer", nullable: false), - InitiatorCommitmentId = table.Column(type: "integer", nullable: false), - OpponentCommitmentId = table.Column(type: "integer", nullable: false), - LastMoveId = table.Column(type: "bigint", nullable: false), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false), - InitiatorReward = table.Column(type: "bigint", nullable: true), - InitiatorLoss = table.Column(type: "bigint", nullable: true), - OpponentReward = table.Column(type: "bigint", nullable: true), - OpponentLoss = table.Column(type: "bigint", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_RefutationGames", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "SmartRollupAddMessagesOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - MessagesCount = table.Column(type: "integer", nullable: false), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - Counter = table.Column(type: "integer", nullable: false), - BakerFee = table.Column(type: "bigint", nullable: false), - StorageFee = table.Column(type: "bigint", nullable: true), - AllocationFee = table.Column(type: "bigint", nullable: true), - GasLimit = table.Column(type: "integer", nullable: false), - GasUsed = table.Column(type: "integer", nullable: false), - StorageLimit = table.Column(type: "integer", nullable: false), - StorageUsed = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SmartRollupAddMessagesOps", x => x.Id); - table.ForeignKey( - name: "FK_SmartRollupAddMessagesOps_Accounts_SenderId", - column: x => x.SenderId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SmartRollupAddMessagesOps_Blocks_Level", - column: x => x.Level, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SmartRollupCementOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - SmartRollupId = table.Column(type: "integer", nullable: true), - CommitmentId = table.Column(type: "integer", nullable: true), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - Counter = table.Column(type: "integer", nullable: false), - BakerFee = table.Column(type: "bigint", nullable: false), - StorageFee = table.Column(type: "bigint", nullable: true), - AllocationFee = table.Column(type: "bigint", nullable: true), - GasLimit = table.Column(type: "integer", nullable: false), - GasUsed = table.Column(type: "integer", nullable: false), - StorageLimit = table.Column(type: "integer", nullable: false), - StorageUsed = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SmartRollupCementOps", x => x.Id); - table.ForeignKey( - name: "FK_SmartRollupCementOps_Accounts_SenderId", - column: x => x.SenderId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SmartRollupCementOps_Blocks_Level", - column: x => x.Level, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SmartRollupCommitments", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - InitiatorId = table.Column(type: "integer", nullable: false), - SmartRollupId = table.Column(type: "integer", nullable: false), - PredecessorId = table.Column(type: "integer", nullable: true), - InboxLevel = table.Column(type: "integer", nullable: false), - State = table.Column(type: "text", nullable: true), - Hash = table.Column(type: "text", nullable: true), - Ticks = table.Column(type: "bigint", nullable: false), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false), - Stakers = table.Column(type: "integer", nullable: false), - ActiveStakers = table.Column(type: "integer", nullable: false), - Successors = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SmartRollupCommitments", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "SmartRollupExecuteOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - SmartRollupId = table.Column(type: "integer", nullable: true), - CommitmentId = table.Column(type: "integer", nullable: true), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - Counter = table.Column(type: "integer", nullable: false), - BakerFee = table.Column(type: "bigint", nullable: false), - StorageFee = table.Column(type: "bigint", nullable: true), - AllocationFee = table.Column(type: "bigint", nullable: true), - GasLimit = table.Column(type: "integer", nullable: false), - GasUsed = table.Column(type: "integer", nullable: false), - StorageLimit = table.Column(type: "integer", nullable: false), - StorageUsed = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SmartRollupExecuteOps", x => x.Id); - table.ForeignKey( - name: "FK_SmartRollupExecuteOps_Accounts_SenderId", - column: x => x.SenderId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SmartRollupExecuteOps_Blocks_Level", - column: x => x.Level, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SmartRollupOriginateOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - PvmKind = table.Column(type: "integer", nullable: false), - Kernel = table.Column(type: "bytea", nullable: true), - OriginationProof = table.Column(type: "bytea", nullable: true), - ParameterType = table.Column(type: "bytea", nullable: true), - GenesisCommitment = table.Column(type: "text", nullable: true), - SmartRollupId = table.Column(type: "integer", nullable: true), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - Counter = table.Column(type: "integer", nullable: false), - BakerFee = table.Column(type: "bigint", nullable: false), - StorageFee = table.Column(type: "bigint", nullable: true), - AllocationFee = table.Column(type: "bigint", nullable: true), - GasLimit = table.Column(type: "integer", nullable: false), - GasUsed = table.Column(type: "integer", nullable: false), - StorageLimit = table.Column(type: "integer", nullable: false), - StorageUsed = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SmartRollupOriginateOps", x => x.Id); - table.ForeignKey( - name: "FK_SmartRollupOriginateOps_Accounts_SenderId", - column: x => x.SenderId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SmartRollupOriginateOps_Blocks_Level", - column: x => x.Level, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SmartRollupPublishOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - SmartRollupId = table.Column(type: "integer", nullable: true), - CommitmentId = table.Column(type: "integer", nullable: true), - Bond = table.Column(type: "bigint", nullable: false), - BondStatus = table.Column(type: "integer", nullable: true), - Flags = table.Column(type: "integer", nullable: false), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - Counter = table.Column(type: "integer", nullable: false), - BakerFee = table.Column(type: "bigint", nullable: false), - StorageFee = table.Column(type: "bigint", nullable: true), - AllocationFee = table.Column(type: "bigint", nullable: true), - GasLimit = table.Column(type: "integer", nullable: false), - GasUsed = table.Column(type: "integer", nullable: false), - StorageLimit = table.Column(type: "integer", nullable: false), - StorageUsed = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SmartRollupPublishOps", x => x.Id); - table.ForeignKey( - name: "FK_SmartRollupPublishOps_Accounts_SenderId", - column: x => x.SenderId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SmartRollupPublishOps_Blocks_Level", - column: x => x.Level, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SmartRollupRecoverBondOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - SmartRollupId = table.Column(type: "integer", nullable: true), - StakerId = table.Column(type: "integer", nullable: true), - Bond = table.Column(type: "bigint", nullable: false), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - Counter = table.Column(type: "integer", nullable: false), - BakerFee = table.Column(type: "bigint", nullable: false), - StorageFee = table.Column(type: "bigint", nullable: true), - AllocationFee = table.Column(type: "bigint", nullable: true), - GasLimit = table.Column(type: "integer", nullable: false), - GasUsed = table.Column(type: "integer", nullable: false), - StorageLimit = table.Column(type: "integer", nullable: false), - StorageUsed = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SmartRollupRecoverBondOps", x => x.Id); - table.ForeignKey( - name: "FK_SmartRollupRecoverBondOps_Accounts_SenderId", - column: x => x.SenderId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SmartRollupRecoverBondOps_Blocks_Level", - column: x => x.Level, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "SmartRollupRefuteOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - SmartRollupId = table.Column(type: "integer", nullable: true), - GameId = table.Column(type: "integer", nullable: true), - Move = table.Column(type: "integer", nullable: false), - GameStatus = table.Column(type: "integer", nullable: false), - DissectionStart = table.Column(type: "bigint", nullable: true), - DissectionEnd = table.Column(type: "bigint", nullable: true), - DissectionSteps = table.Column(type: "integer", nullable: true), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - Counter = table.Column(type: "integer", nullable: false), - BakerFee = table.Column(type: "bigint", nullable: false), - StorageFee = table.Column(type: "bigint", nullable: true), - AllocationFee = table.Column(type: "bigint", nullable: true), - GasLimit = table.Column(type: "integer", nullable: false), - GasUsed = table.Column(type: "integer", nullable: false), - StorageLimit = table.Column(type: "integer", nullable: false), - StorageUsed = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SmartRollupRefuteOps", x => x.Id); - table.ForeignKey( - name: "FK_SmartRollupRefuteOps_Accounts_SenderId", - column: x => x.SenderId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SmartRollupRefuteOps_Blocks_Level", - column: x => x.Level, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.UpdateData( - table: "AppState", - keyColumn: "Id", - keyValue: -1, - columns: new[] { "InboxMessageCounter", "RefutationGameCounter", "SmartRollupAddMessagesOpsCount", "SmartRollupCementOpsCount", "SmartRollupCommitmentCounter", "SmartRollupExecuteOpsCount", "SmartRollupOriginateOpsCount", "SmartRollupPublishOpsCount", "SmartRollupRecoverBondOpsCount", "SmartRollupRefuteOpsCount" }, - values: new object[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }); - - migrationBuilder.CreateIndex( - name: "IX_InboxMessages_Level", - table: "InboxMessages", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_InboxMessages_OperationId", - table: "InboxMessages", - column: "OperationId"); - - migrationBuilder.CreateIndex( - name: "IX_InboxMessages_Type_Id", - table: "InboxMessages", - columns: new[] { "Type", "Id" }); - - migrationBuilder.CreateIndex( - name: "IX_RefutationGames_FirstLevel", - table: "RefutationGames", - column: "FirstLevel"); - - migrationBuilder.CreateIndex( - name: "IX_RefutationGames_InitiatorCommitmentId", - table: "RefutationGames", - column: "InitiatorCommitmentId"); - - migrationBuilder.CreateIndex( - name: "IX_RefutationGames_InitiatorId", - table: "RefutationGames", - column: "InitiatorId"); - - migrationBuilder.CreateIndex( - name: "IX_RefutationGames_LastLevel", - table: "RefutationGames", - column: "LastLevel"); - - migrationBuilder.CreateIndex( - name: "IX_RefutationGames_OpponentCommitmentId", - table: "RefutationGames", - column: "OpponentCommitmentId"); - - migrationBuilder.CreateIndex( - name: "IX_RefutationGames_OpponentId", - table: "RefutationGames", - column: "OpponentId"); - - migrationBuilder.CreateIndex( - name: "IX_RefutationGames_SmartRollupId", - table: "RefutationGames", - column: "SmartRollupId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupAddMessagesOps_Level", - table: "SmartRollupAddMessagesOps", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupAddMessagesOps_OpHash", - table: "SmartRollupAddMessagesOps", - column: "OpHash"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupAddMessagesOps_SenderId", - table: "SmartRollupAddMessagesOps", - column: "SenderId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupCementOps_Level", - table: "SmartRollupCementOps", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupCementOps_OpHash", - table: "SmartRollupCementOps", - column: "OpHash"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupCementOps_SenderId", - table: "SmartRollupCementOps", - column: "SenderId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupCommitments_Hash", - table: "SmartRollupCommitments", - column: "Hash"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupCommitments_Hash_SmartRollupId", - table: "SmartRollupCommitments", - columns: new[] { "Hash", "SmartRollupId" }); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupCommitments_InboxLevel", - table: "SmartRollupCommitments", - column: "InboxLevel"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupCommitments_LastLevel", - table: "SmartRollupCommitments", - column: "LastLevel"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupCommitments_PredecessorId", - table: "SmartRollupCommitments", - column: "PredecessorId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupCommitments_SmartRollupId", - table: "SmartRollupCommitments", - column: "SmartRollupId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupExecuteOps_CommitmentId", - table: "SmartRollupExecuteOps", - column: "CommitmentId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupExecuteOps_Level", - table: "SmartRollupExecuteOps", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupExecuteOps_OpHash", - table: "SmartRollupExecuteOps", - column: "OpHash"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupExecuteOps_SenderId", - table: "SmartRollupExecuteOps", - column: "SenderId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupExecuteOps_SmartRollupId", - table: "SmartRollupExecuteOps", - column: "SmartRollupId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupOriginateOps_Level", - table: "SmartRollupOriginateOps", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupOriginateOps_OpHash", - table: "SmartRollupOriginateOps", - column: "OpHash"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupOriginateOps_SenderId", - table: "SmartRollupOriginateOps", - column: "SenderId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupOriginateOps_SmartRollupId", - table: "SmartRollupOriginateOps", - column: "SmartRollupId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupPublishOps_CommitmentId", - table: "SmartRollupPublishOps", - column: "CommitmentId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupPublishOps_Level", - table: "SmartRollupPublishOps", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupPublishOps_OpHash", - table: "SmartRollupPublishOps", - column: "OpHash"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupPublishOps_SenderId", - table: "SmartRollupPublishOps", - column: "SenderId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupPublishOps_SmartRollupId", - table: "SmartRollupPublishOps", - column: "SmartRollupId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupPublishOps_SmartRollupId_BondStatus_SenderId", - table: "SmartRollupPublishOps", - columns: new[] { "SmartRollupId", "BondStatus", "SenderId" }, - filter: "\"BondStatus\" IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRecoverBondOps_Level", - table: "SmartRollupRecoverBondOps", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRecoverBondOps_OpHash", - table: "SmartRollupRecoverBondOps", - column: "OpHash"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRecoverBondOps_SenderId", - table: "SmartRollupRecoverBondOps", - column: "SenderId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRecoverBondOps_SmartRollupId", - table: "SmartRollupRecoverBondOps", - column: "SmartRollupId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRecoverBondOps_StakerId", - table: "SmartRollupRecoverBondOps", - column: "StakerId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRefuteOps_GameId", - table: "SmartRollupRefuteOps", - column: "GameId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRefuteOps_Level", - table: "SmartRollupRefuteOps", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRefuteOps_OpHash", - table: "SmartRollupRefuteOps", - column: "OpHash"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRefuteOps_SenderId", - table: "SmartRollupRefuteOps", - column: "SenderId"); - - migrationBuilder.CreateIndex( - name: "IX_SmartRollupRefuteOps_SmartRollupId", - table: "SmartRollupRefuteOps", - column: "SmartRollupId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "InboxMessages"); - - migrationBuilder.DropTable( - name: "RefutationGames"); - - migrationBuilder.DropTable( - name: "SmartRollupAddMessagesOps"); - - migrationBuilder.DropTable( - name: "SmartRollupCementOps"); - - migrationBuilder.DropTable( - name: "SmartRollupCommitments"); - - migrationBuilder.DropTable( - name: "SmartRollupExecuteOps"); - - migrationBuilder.DropTable( - name: "SmartRollupOriginateOps"); - - migrationBuilder.DropTable( - name: "SmartRollupPublishOps"); - - migrationBuilder.DropTable( - name: "SmartRollupRecoverBondOps"); - - migrationBuilder.DropTable( - name: "SmartRollupRefuteOps"); - - migrationBuilder.DropColumn( - name: "TotalSmartRollupBonds", - table: "Statistics"); - - migrationBuilder.DropColumn( - name: "SmartRollupChallengeWindow", - table: "Protocols"); - - migrationBuilder.DropColumn( - name: "SmartRollupCommitmentPeriod", - table: "Protocols"); - - migrationBuilder.DropColumn( - name: "SmartRollupOriginationSize", - table: "Protocols"); - - migrationBuilder.DropColumn( - name: "SmartRollupStakeAmount", - table: "Protocols"); - - migrationBuilder.DropColumn( - name: "SmartRollupTimeoutPeriod", - table: "Protocols"); - - migrationBuilder.DropColumn( - name: "InboxMessageCounter", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "RefutationGameCounter", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "SmartRollupAddMessagesOpsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "SmartRollupCementOpsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "SmartRollupCommitmentCounter", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "SmartRollupExecuteOpsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "SmartRollupOriginateOpsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "SmartRollupPublishOpsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "SmartRollupRecoverBondOpsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "SmartRollupRefuteOpsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "ActiveRefutationGamesCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "ActiveStakers", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "CementedCommitments", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "ExecutedCommitments", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "GenesisCommitment", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "InboxLevel", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "LastCommitment", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "OrphanCommitments", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "PendingCommitments", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "PvmKind", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "RefutationGamesCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "RefutedCommitments", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "SmartRollupAddMessagesCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "SmartRollupBonds", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "SmartRollupCementCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "SmartRollupExecuteCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "SmartRollupOriginateCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "SmartRollupPublishCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "SmartRollupRecoverBondCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "SmartRollupRefuteCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "SmartRollupsCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TotalStakers", - table: "Accounts"); - - migrationBuilder.AlterColumn( - name: "PublicKey", - table: "Accounts", - type: "character varying(55)", - maxLength: 55, - nullable: true, - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - } - } -} diff --git a/Tzkt.Data/Migrations/20230329183955_AmendProtoConstants.Designer.cs b/Tzkt.Data/Migrations/20230329183955_AmendProtoConstants.Designer.cs deleted file mode 100644 index 32dee1934..000000000 --- a/Tzkt.Data/Migrations/20230329183955_AmendProtoConstants.Designer.cs +++ /dev/null @@ -1,6049 +0,0 @@ -// -using System; -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("20230329183955_AmendProtoConstants")] - partial class AmendProtoConstants - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.4") - .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("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("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("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - 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("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .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("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("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("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("StorageCounter") - .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("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, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 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, - 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, - SetDepositsLimitOpsCount = 0, - SmartRollupAddMessagesOpsCount = 0, - SmartRollupCementOpsCount = 0, - SmartRollupCommitmentCounter = 0, - SmartRollupExecuteOpsCount = 0, - SmartRollupOriginateOpsCount = 0, - SmartRollupPublishOpsCount = 0, - SmartRollupRecoverBondOpsCount = 0, - SmartRollupRefuteOpsCount = 0, - StorageCounter = 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, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - 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("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - 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("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("Cycle"); - - 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.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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 varying(54)"); - - 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("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - 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("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .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("Reward") - .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("Address") - .IsUnique(); - - b.HasIndex("Id") - .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("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - 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("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"); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("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("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("Received") - .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.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OperationId") - .HasColumnType("bigint"); - - b.Property("Payload") - .HasColumnType("bytea"); - - b.Property("PredecessorLevel") - .HasColumnType("integer"); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - 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("Hash"); - - 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("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .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("FrozenDepositsPercentage") - .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("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - 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("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - 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"); - - 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") - .HasColumnType("text"); - - 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") - .IsUnique() - .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("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - 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("text"); - - b.Property("OpHash") - .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("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("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - 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("Hash"); - - 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("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - 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("OriginationProof") - .HasColumnType("bytea"); - - 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"); - - b.HasIndex("SmartRollupId", "BondStatus", "SenderId") - .HasFilter("\"BondStatus\" IS NOT NULL"); - - 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("GameId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - 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.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("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("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - 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") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - 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.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("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.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") - .IsRequired() - .HasColumnType("text"); - - 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("TargetId") - .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.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("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - 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.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - 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"); - - 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("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"); - - b.HasIndex("Type", "Kind") - .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("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("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - 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("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("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .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.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.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.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("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("SetDepositsLimits"); - - b.Navigation("SmartRollupAddMessagesOps"); - - b.Navigation("SmartRollupCementOps"); - - b.Navigation("SmartRollupExecuteOps"); - - b.Navigation("SmartRollupOriginateOps"); - - b.Navigation("SmartRollupPublishOps"); - - b.Navigation("SmartRollupRecoverBondOps"); - - b.Navigation("SmartRollupRefuteOps"); - - 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.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/20230329183955_AmendProtoConstants.cs b/Tzkt.Data/Migrations/20230329183955_AmendProtoConstants.cs deleted file mode 100644 index f4acf87bc..000000000 --- a/Tzkt.Data/Migrations/20230329183955_AmendProtoConstants.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Tzkt.Data.Migrations -{ - public partial class AmendProtoConstants : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql(""" - UPDATE "Protocols" - SET "MaxBakingReward" = "BlockReward0" + "EndorsersPerBlock" / 3 * "BlockReward1" - WHERE "Hash" = 'PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1'; - - UPDATE "Protocols" - SET "MaxEndorsingReward" = "EndorsersPerBlock" * "EndorsementReward0" - WHERE "Hash" = 'PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1'; - - UPDATE "BakerCycles" - SET "FutureBlockRewards" = updates.value - FROM ( - SELECT - bc."Id" AS id, - bc."FutureBlocks" * p."MaxBakingReward" AS value - FROM "BakerCycles" AS bc - INNER JOIN "Protocols" AS p - ON p."Hash" = 'PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1' - WHERE bc."Cycle" >= p."FirstCycle" - ) updates - WHERE "Id" = updates.id; - """); - } - - protected override void Down(MigrationBuilder migrationBuilder) { } - } -} diff --git a/Tzkt.Data/Migrations/20230425183139_Nairobi.Designer.cs b/Tzkt.Data/Migrations/20230425183139_Nairobi.Designer.cs deleted file mode 100644 index 19dca4a2e..000000000 --- a/Tzkt.Data/Migrations/20230425183139_Nairobi.Designer.cs +++ /dev/null @@ -1,6052 +0,0 @@ -// -using System; -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("20230425183139_Nairobi")] - partial class Nairobi - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.4") - .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("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("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("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - 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("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .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("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("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("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("StorageCounter") - .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("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, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 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, - 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, - SetDepositsLimitOpsCount = 0, - SmartRollupAddMessagesOpsCount = 0, - SmartRollupCementOpsCount = 0, - SmartRollupCommitmentCounter = 0, - SmartRollupExecuteOpsCount = 0, - SmartRollupOriginateOpsCount = 0, - SmartRollupPublishOpsCount = 0, - SmartRollupRecoverBondOpsCount = 0, - SmartRollupRefuteOpsCount = 0, - StorageCounter = 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, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - 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("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - 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("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("Cycle"); - - 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.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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 varying(54)"); - - 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("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - 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("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - 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.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .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("Reward") - .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("Address") - .IsUnique(); - - b.HasIndex("Id") - .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("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - 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("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - 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("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"); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - 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("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("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("Received") - .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.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - 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("Hash"); - - 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("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .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("FrozenDepositsPercentage") - .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("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - 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("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - 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"); - - 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") - .HasColumnType("text"); - - 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") - .IsUnique() - .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("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - 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("text"); - - b.Property("OpHash") - .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("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("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - 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("Hash"); - - 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("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - 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("OriginationProof") - .HasColumnType("bytea"); - - 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"); - - b.HasIndex("SmartRollupId", "BondStatus", "SenderId") - .HasFilter("\"BondStatus\" IS NOT NULL"); - - 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("GameId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - 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("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - 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.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("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("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - 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") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - 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") - .IsRequired() - .HasColumnType("text"); - - 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("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - 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("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - 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.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("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.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") - .IsRequired() - .HasColumnType("text"); - - 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("TargetId") - .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.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("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - 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.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - 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"); - - 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("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"); - - b.HasIndex("Type", "Kind") - .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("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("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - 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("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("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .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.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.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.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("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("SetDepositsLimits"); - - b.Navigation("SmartRollupAddMessagesOps"); - - b.Navigation("SmartRollupCementOps"); - - b.Navigation("SmartRollupExecuteOps"); - - b.Navigation("SmartRollupOriginateOps"); - - b.Navigation("SmartRollupPublishOps"); - - b.Navigation("SmartRollupRecoverBondOps"); - - b.Navigation("SmartRollupRefuteOps"); - - 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.NonceRevelationOperation", b => - { - b.Navigation("RevealedBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.Navigation("DelegatedAccounts"); - }); -#pragma warning restore 612, 618 - } - } -} \ No newline at end of file diff --git a/Tzkt.Data/Migrations/20230425183139_Nairobi.cs b/Tzkt.Data/Migrations/20230425183139_Nairobi.cs deleted file mode 100644 index cf63c2ef9..000000000 --- a/Tzkt.Data/Migrations/20230425183139_Nairobi.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class Nairobi : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Protocol", - table: "InboxMessages", - type: "text", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Protocol", - table: "InboxMessages"); - } - } -} diff --git a/Tzkt.Data/Migrations/20230809172912_TokensSupply.cs b/Tzkt.Data/Migrations/20230809172912_TokensSupply.cs deleted file mode 100644 index 046baf9e0..000000000 --- a/Tzkt.Data/Migrations/20230809172912_TokensSupply.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class TokensSupply : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql(""" - update "Tokens" set "TotalMinted" = ss."Sum" from (select s.* from (select tr."TokenId", sum(tr."Amount"::numeric) as "Sum" from "TokenTransfers" as tr where "FromId" is null group by "TokenId") as s inner join "Tokens" as t on t."Id" = s."TokenId" where s."Sum" != t."TotalMinted"::numeric) as ss where "Id" = ss."TokenId"; - update "Tokens" set "TotalBurned" = ss."Sum" from (select s.* from (select tr."TokenId", sum(tr."Amount"::numeric) as "Sum" from "TokenTransfers" as tr where "ToId" is null group by "TokenId") as s inner join "Tokens" as t on t."Id" = s."TokenId" where s."Sum" != t."TotalBurned"::numeric) as ss where "Id" = ss."TokenId"; - update "Tokens" set "TotalSupply" = "TotalMinted"::numeric - "TotalBurned"::numeric where "TotalMinted"::numeric - "TotalBurned"::numeric != "TotalSupply"::numeric; - """); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - // Do nothing - } - } -} diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.cs deleted file mode 100644 index 399126d52..000000000 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.cs +++ /dev/null @@ -1,367 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class Tickets : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "SubIds", - table: "TransferTicketOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketTransfers", - table: "TransferTicketOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketTransfers", - table: "TransactionOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "SubIds", - table: "SmartRollupExecuteOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketTransfers", - table: "SmartRollupExecuteOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketBalancesCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketTransfersCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "ActiveTicketsCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketBalancesCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketTransfersCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketsCount", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.CreateTable( - name: "TicketBalances", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - TicketerId = table.Column(type: "integer", nullable: false), - TicketId = table.Column(type: "bigint", nullable: false), - AccountId = table.Column(type: "integer", nullable: false), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false), - TransfersCount = table.Column(type: "integer", nullable: false), - Balance = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TicketBalances", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Tickets", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - TicketerId = table.Column(type: "integer", nullable: false), - FirstMinterId = table.Column(type: "integer", nullable: false), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false), - TransfersCount = table.Column(type: "integer", nullable: false), - BalancesCount = table.Column(type: "integer", nullable: false), - HoldersCount = table.Column(type: "integer", nullable: false), - TotalMinted = table.Column(type: "text", nullable: false), - TotalBurned = table.Column(type: "text", nullable: false), - TotalSupply = table.Column(type: "text", nullable: false), - TypeHash = table.Column(type: "integer", nullable: false), - ContentHash = table.Column(type: "integer", nullable: false), - RawType = table.Column(type: "bytea", nullable: true), - RawContent = table.Column(type: "bytea", nullable: true), - JsonContent = table.Column(type: "jsonb", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Tickets", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "TicketTransfers", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Level = table.Column(type: "integer", nullable: false), - TicketerId = table.Column(type: "integer", nullable: false), - TicketId = table.Column(type: "bigint", nullable: false), - Amount = table.Column(type: "text", nullable: false), - FromId = table.Column(type: "integer", nullable: true), - ToId = table.Column(type: "integer", nullable: true), - TransactionId = table.Column(type: "bigint", nullable: true), - TransferTicketId = table.Column(type: "bigint", nullable: true), - SmartRollupExecuteId = table.Column(type: "bigint", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_TicketTransfers", x => x.Id); - }); - - migrationBuilder.UpdateData( - table: "AppState", - keyColumn: "Id", - keyValue: -1, - columns: new[] { "TicketBalancesCount", "TicketTransfersCount", "TicketsCount" }, - values: new object[] { 0, 0, 0 }); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_AccountId", - table: "TicketBalances", - column: "AccountId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_AccountId_TicketerId", - table: "TicketBalances", - columns: new[] { "AccountId", "TicketerId" }); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_AccountId_TicketId", - table: "TicketBalances", - columns: new[] { "AccountId", "TicketId" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_FirstLevel", - table: "TicketBalances", - column: "FirstLevel"); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_Id", - table: "TicketBalances", - column: "Id", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_LastLevel", - table: "TicketBalances", - column: "LastLevel"); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_TicketerId", - table: "TicketBalances", - column: "TicketerId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_TicketId", - table: "TicketBalances", - column: "TicketId"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_ContentHash", - table: "Tickets", - column: "ContentHash"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_FirstLevel", - table: "Tickets", - column: "FirstLevel"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_FirstMinterId", - table: "Tickets", - column: "FirstMinterId"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_Id", - table: "Tickets", - column: "Id", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_JsonContent", - table: "Tickets", - column: "JsonContent") - .Annotation("Npgsql:IndexMethod", "gin") - .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_LastLevel", - table: "Tickets", - column: "LastLevel"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_TicketerId", - table: "Tickets", - column: "TicketerId"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_TicketerId_TypeHash_ContentHash", - table: "Tickets", - columns: new[] { "TicketerId", "TypeHash", "ContentHash" }); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_TypeHash", - table: "Tickets", - column: "TypeHash"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_FromId", - table: "TicketTransfers", - column: "FromId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_Id", - table: "TicketTransfers", - column: "Id", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_Level", - table: "TicketTransfers", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_SmartRollupExecuteId", - table: "TicketTransfers", - column: "SmartRollupExecuteId", - filter: "\"SmartRollupExecuteId\" is not null"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_TicketerId", - table: "TicketTransfers", - column: "TicketerId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_TicketId", - table: "TicketTransfers", - column: "TicketId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_ToId", - table: "TicketTransfers", - column: "ToId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_TransactionId", - table: "TicketTransfers", - column: "TransactionId", - filter: "\"TransactionId\" is not null"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_TransferTicketId", - table: "TicketTransfers", - column: "TransferTicketId", - filter: "\"TransferTicketId\" is not null"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TicketBalances"); - - migrationBuilder.DropTable( - name: "Tickets"); - - migrationBuilder.DropTable( - name: "TicketTransfers"); - - migrationBuilder.DropColumn( - name: "SubIds", - table: "TransferTicketOps"); - - migrationBuilder.DropColumn( - name: "TicketTransfers", - table: "TransferTicketOps"); - - migrationBuilder.DropColumn( - name: "TicketTransfers", - table: "TransactionOps"); - - migrationBuilder.DropColumn( - name: "SubIds", - table: "SmartRollupExecuteOps"); - - migrationBuilder.DropColumn( - name: "TicketTransfers", - table: "SmartRollupExecuteOps"); - - migrationBuilder.DropColumn( - name: "TicketBalancesCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "TicketTransfersCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "TicketsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "ActiveTicketsCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TicketBalancesCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TicketTransfersCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TicketsCount", - table: "Accounts"); - } - } -} diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs b/Tzkt.Data/Migrations/20231107184456_Initial.Designer.cs similarity index 92% rename from Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs rename to Tzkt.Data/Migrations/20231107184456_Initial.Designer.cs index 18b26e24e..8fc237f31 100644 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20231107184456_Initial.Designer.cs @@ -13,8 +13,8 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230823140932_Tickets")] - partial class Tickets + [Migration("20231107184456_Initial")] + partial class Initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -81,6 +81,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("LastLevel") .HasColumnType("integer"); + b.Property("LostBalance") + .HasColumnType("bigint"); + b.Property("Metadata") .HasColumnType("jsonb"); @@ -259,6 +262,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AIActivated") + .HasColumnType("boolean"); + + b.Property("AIActivationCycle") + .HasColumnType("integer"); + + b.Property("AIFinalUpvoteLevel") + .HasColumnType("integer"); + b.Property("AccountCounter") .HasColumnType("integer"); @@ -268,6 +280,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActivationOpsCount") .HasColumnType("integer"); + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + b.Property("BallotOpsCount") .HasColumnType("integer"); @@ -373,6 +388,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("OriginationOpsCount") .HasColumnType("integer"); + b.Property("PendingStakingParameters") + .HasColumnType("integer"); + b.Property("PreendorsementOpsCount") .HasColumnType("integer"); @@ -457,6 +475,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SmartRollupRefuteOpsCount") .HasColumnType("integer"); + b.Property("StakingOpsCount") + .HasColumnType("integer"); + b.Property("StorageCounter") .HasColumnType("integer"); @@ -531,9 +552,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) new { Id = -1, + AIActivated = false, + AIActivationCycle = 0, + AIFinalUpvoteLevel = 0, AccountCounter = 0, AccountsCount = 0, ActivationOpsCount = 0, + AutostakingOpsCount = 0, BallotOpsCount = 0, BigMapCounter = 0, BigMapKeyCounter = 0, @@ -565,6 +590,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NonceRevelationOpsCount = 0, OperationCounter = 0L, OriginationOpsCount = 0, + PendingStakingParameters = 0, PreendorsementOpsCount = 0, ProposalOpsCount = 0, ProposalsCount = 0, @@ -593,6 +619,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) SmartRollupPublishOpsCount = 0, SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, + StakingOpsCount = 0, StorageCounter = 0, TicketBalancesCount = 0, TicketTransfersCount = 0, @@ -618,6 +645,38 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) }); }); + 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("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("AutostakingOps"); + }); + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => { b.Property("Id") @@ -626,16 +685,22 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("ActiveStake") - .HasColumnType("bigint"); - b.Property("BakerId") .HasColumnType("integer"); + b.Property("BakingPower") + .HasColumnType("bigint"); + b.Property("BlockFees") .HasColumnType("bigint"); - b.Property("BlockRewards") + b.Property("BlockRewardsLiquid") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedShared") .HasColumnType("bigint"); b.Property("Blocks") @@ -644,31 +709,61 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Cycle") .HasColumnType("integer"); - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - b.Property("DelegatorsCount") .HasColumnType("integer"); - b.Property("DoubleBakingLosses") + 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("DoubleEndorsingLosses") + 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("DoublePreendorsingLosses") + 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("EndorsementRewards") + b.Property("EndorsementRewardsLiquid") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedShared") .HasColumnType("bigint"); b.Property("Endorsements") @@ -680,6 +775,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ExpectedEndorsements") .HasColumnType("double precision"); + b.Property("ExternalDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + b.Property("FutureBlockRewards") .HasColumnType("bigint"); @@ -707,29 +808,44 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MissedEndorsements") .HasColumnType("integer"); - b.Property("RevelationLosses") + b.Property("NonceRevelationLosses") .HasColumnType("bigint"); - b.Property("RevelationRewards") + b.Property("NonceRevelationRewardsLiquid") .HasColumnType("bigint"); - b.Property("SelectedStake") + b.Property("NonceRevelationRewardsStakedOwn") .HasColumnType("bigint"); - b.Property("StakingBalance") + b.Property("NonceRevelationRewardsStakedShared") .HasColumnType("bigint"); - b.HasKey("Id"); + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); - b.HasIndex("BakerId"); + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); - b.HasIndex("Cycle"); + b.Property("StakersCount") + .HasColumnType("integer"); - b.HasIndex("Id") - .IsUnique(); + b.Property("TotalBakingPower") + .HasColumnType("bigint"); - b.HasIndex("Cycle", "BakerId") - .IsUnique(); + b.Property("VdfRevelationRewardsLiquid") + .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"); }); @@ -1021,10 +1137,22 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AIToggle") + .HasColumnType("boolean"); + + b.Property("AIToggleEma") + .HasColumnType("integer"); + b.Property("BlockRound") .HasColumnType("integer"); - b.Property("Bonus") + b.Property("BonusLiquid") + .HasColumnType("bigint"); + + b.Property("BonusStakedOwn") + .HasColumnType("bigint"); + + b.Property("BonusStakedShared") .HasColumnType("bigint"); b.Property("Cycle") @@ -1081,7 +1209,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RevelationId") .HasColumnType("bigint"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("SoftwareId") @@ -1216,27 +1350,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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("LBSubsidy") + .HasColumnType("bigint"); + 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("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - b.Property("SnapshotIndex") .HasColumnType("integer"); @@ -1246,13 +1392,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TotalBakers") .HasColumnType("integer"); - b.Property("TotalDelegated") + b.Property("TotalBakingPower") .HasColumnType("bigint"); - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") + b.Property("VdfRevelationReward") .HasColumnType("bigint"); b.HasKey("Id"); @@ -1339,6 +1482,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Timestamp") .HasColumnType("timestamp with time zone"); + b.Property("UnstakedBalance") + .HasColumnType("bigint"); + + b.Property("UnstakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("UnstakedRewards") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("DelegateId"); @@ -1370,25 +1522,25 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BakerId") .HasColumnType("integer"); - b.Property("Balance") - .HasColumnType("bigint"); - b.Property("Cycle") .HasColumnType("integer"); + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + b.Property("DelegatorId") .HasColumnType("integer"); - b.HasKey("Id"); + b.Property("StakedBalance") + .HasColumnType("bigint"); - b.HasIndex("Cycle"); + b.HasKey("Id"); b.HasIndex("DelegatorId"); b.HasIndex("Cycle", "BakerId"); - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); + b.HasIndex("Cycle", "DelegatorId"); b.ToTable("DelegatorCycles"); }); @@ -1459,24 +1611,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1507,24 +1674,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1555,24 +1737,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1697,7 +1894,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Level") .HasColumnType("integer"); - b.Property("Received") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("Timestamp") @@ -1712,30 +1915,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("EndorsingRewardOps"); }); - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => { b.Property("Id") @@ -1929,7 +2108,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RevealedLevel") .HasColumnType("integer"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("SenderId") @@ -2231,6 +2416,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BallotQuorumMin") .HasColumnType("integer"); + b.Property("BaseIssuedPerMinute") + .HasColumnType("bigint"); + + b.Property("BlockBonusWeight") + .HasColumnType("integer"); + b.Property("BlockDeposit") .HasColumnType("bigint"); @@ -2240,6 +2431,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BlockReward1") .HasColumnType("bigint"); + b.Property("BlockRewardWeight") + .HasColumnType("integer"); + b.Property("BlocksPerCommitment") .HasColumnType("integer"); @@ -2264,13 +2458,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Dictator") .HasColumnType("text"); - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") + b.Property("DoubleBakingSlashedPercentage") .HasColumnType("integer"); - b.Property("DoubleEndorsingPunishmentNumerator") + b.Property("DoubleEndorsingSlashedPercentage") .HasColumnType("integer"); b.Property("EndorsementDeposit") @@ -2285,6 +2476,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("EndorsersPerBlock") .HasColumnType("integer"); + b.Property("EndorsingRewardWeight") + .HasColumnType("integer"); + b.Property("Extras") .HasColumnType("jsonb"); @@ -2297,9 +2491,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("FirstLevel") .HasColumnType("integer"); - b.Property("FrozenDepositsPercentage") - .HasColumnType("integer"); - b.Property("HardBlockGasLimit") .HasColumnType("integer"); @@ -2315,7 +2506,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("character(51)") .IsFixedLength(); - b.Property("LBSubsidy") + b.Property("LBSubsidyWeight") .HasColumnType("integer"); b.Property("LBToggleThreshold") @@ -2327,9 +2518,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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"); @@ -2339,9 +2536,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MinParticipationNumerator") .HasColumnType("integer"); + b.Property("MinimalFrozenStake") + .HasColumnType("bigint"); + + b.Property("MinimalStake") + .HasColumnType("bigint"); + b.Property("NoRewardCycles") .HasColumnType("integer"); + b.Property("NonceRevelationRewardWeight") + .HasColumnType("integer"); + b.Property("OriginationSize") .HasColumnType("integer"); @@ -2354,9 +2560,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RampUpCycles") .HasColumnType("integer"); - b.Property("RevelationReward") - .HasColumnType("bigint"); - b.Property("SmartRollupChallengeWindow") .HasColumnType("integer"); @@ -2372,16 +2575,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SmartRollupTimeoutPeriod") .HasColumnType("integer"); - b.Property("TimeBetweenBlocks") + b.Property("StakePowerMultiplier") .HasColumnType("integer"); - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); - b.Property("TxRollupOriginationSize") + b.Property("VdfRevelationRewardWeight") .HasColumnType("integer"); b.HasKey("Id"); @@ -3110,9 +3310,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("character(51)") .IsFixedLength(); - b.Property("OriginationProof") - .HasColumnType("bytea"); - b.Property("ParameterType") .HasColumnType("bytea"); @@ -3416,28 +3613,44 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccountId") .HasColumnType("integer"); - b.Property("Balance") - .HasColumnType("bigint"); + b.Property("BakerId") + .HasColumnType("integer"); - b.Property("DelegateId") + b.Property("DelegatorsCount") .HasColumnType("integer"); - b.Property("DelegatedBalance") + b.Property("ExternalDelegatedBalance") .HasColumnType("bigint"); - b.Property("DelegatorsCount") - .HasColumnType("integer"); + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("IssuedPseudotokens") + .HasColumnType("bigint"); b.Property("Level") .HasColumnType("integer"); - b.Property("StakingBalance") + b.Property("OwnDelegatedBalance") .HasColumnType("bigint"); + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); + + b.Property("StakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("StakersCount") + .HasColumnType("integer"); + b.HasKey("Id"); - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); + b.HasIndex("Level"); + + b.HasIndex("Level", "AccountId", "BakerId"); + + b.HasIndex(new[] { "Level" }, "IX_SnapshotBalance_Level_Partial") + .HasFilter("\"AccountId\" = \"BakerId\""); b.ToTable("SnapshotBalances"); }); @@ -3473,6 +3686,102 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("Software"); }); + modelBuilder.Entity("Tzkt.Data.Models.StakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .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("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("FirstCycleUnstaked") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastCycleUnstaked") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevStakedBalance") + .HasColumnType("bigint"); + + b.Property("Pseudotokens") + .HasColumnType("bigint"); + + 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("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("StakingOps"); + }); + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => { b.Property("Id") @@ -3511,6 +3820,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TotalFrozen") .HasColumnType("bigint"); + b.Property("TotalLost") + .HasColumnType("bigint"); + b.Property("TotalRollupBonds") .HasColumnType("bigint"); @@ -4897,7 +5209,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Proof") .HasColumnType("bytea"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("Solution") @@ -5179,6 +5497,24 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SetDepositsLimitsCount") .HasColumnType("integer"); + b.Property("StakedBalance") + .HasColumnType("bigint"); + + b.Property("StakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("StakingOpsCount") + .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); }); @@ -5189,6 +5525,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActivationLevel") .HasColumnType("integer"); + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + b.Property("BallotsCount") .HasColumnType("integer"); @@ -5213,18 +5552,30 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("DoublePreendorsingCount") .HasColumnType("integer"); + b.Property("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + b.Property("EndorsementsCount") .HasColumnType("integer"); b.Property("EndorsingRewardsCount") .HasColumnType("integer"); - b.Property("FrozenDeposit") + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalUnstakedBalance") .HasColumnType("bigint"); b.Property("FrozenDepositLimit") .HasColumnType("bigint"); + b.Property("IssuedPseudotokens") + .HasColumnType("bigint"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + b.Property("NonceRevelationsCount") .HasColumnType("integer"); @@ -5240,9 +5591,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SoftwareId") .HasColumnType("integer"); + b.Property("StakersCount") + .HasColumnType("integer"); + b.Property("StakingBalance") .HasColumnType("bigint"); + b.Property("TotalStakedBalance") + .HasColumnType("bigint"); + b.Property("VdfRevelationsCount") .HasColumnType("integer"); @@ -5908,6 +6265,26 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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") @@ -6250,6 +6627,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Navigation("SmartRollupRefuteOps"); + b.Navigation("StakingOps"); + b.Navigation("Transactions"); b.Navigation("TransferTicketOps"); diff --git a/Tzkt.Data/Migrations/20220911122259_Initial.cs b/Tzkt.Data/Migrations/20231107184456_Initial.cs similarity index 68% rename from Tzkt.Data/Migrations/20220911122259_Initial.cs rename to Tzkt.Data/Migrations/20231107184456_Initial.cs index 2484fcce4..1b274a2b8 100644 --- a/Tzkt.Data/Migrations/20220911122259_Initial.cs +++ b/Tzkt.Data/Migrations/20231107184456_Initial.cs @@ -1,11 +1,16 @@ using System; +using System.Text.Json; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +#nullable disable + namespace Tzkt.Data.Migrations { + /// public partial class Initial : Migration { + /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( @@ -17,15 +22,19 @@ protected override void Up(MigrationBuilder migrationBuilder) Chain = table.Column(type: "text", nullable: true), ChainId = table.Column(type: "text", nullable: true), KnownHead = table.Column(type: "integer", nullable: false), - LastSync = table.Column(type: "timestamp without time zone", nullable: false), + LastSync = table.Column(type: "timestamp with time zone", nullable: false), Cycle = table.Column(type: "integer", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), Protocol = table.Column(type: "text", nullable: true), NextProtocol = table.Column(type: "text", nullable: true), Hash = table.Column(type: "text", nullable: true), VotingEpoch = table.Column(type: "integer", nullable: false), VotingPeriod = table.Column(type: "integer", nullable: false), + AIActivated = table.Column(type: "boolean", nullable: false), + AIActivationCycle = table.Column(type: "integer", nullable: false), + AIFinalUpvoteLevel = table.Column(type: "integer", nullable: false), + PendingStakingParameters = table.Column(type: "integer", nullable: false), AccountCounter = table.Column(type: "integer", nullable: false), OperationCounter = table.Column(type: "bigint", nullable: false), ManagerCounter = table.Column(type: "integer", nullable: false), @@ -35,6 +44,9 @@ protected override void Up(MigrationBuilder migrationBuilder) StorageCounter = table.Column(type: "integer", nullable: false), ScriptCounter = table.Column(type: "integer", nullable: false), EventCounter = table.Column(type: "integer", nullable: false), + SmartRollupCommitmentCounter = table.Column(type: "integer", nullable: false), + RefutationGameCounter = table.Column(type: "integer", nullable: false), + InboxMessageCounter = table.Column(type: "integer", nullable: false), CommitmentsCount = table.Column(type: "integer", nullable: false), AccountsCount = table.Column(type: "integer", nullable: false), BlocksCount = table.Column(type: "integer", nullable: false), @@ -52,6 +64,7 @@ protected override void Up(MigrationBuilder migrationBuilder) OriginationOpsCount = table.Column(type: "integer", nullable: false), ProposalOpsCount = table.Column(type: "integer", nullable: false), RevealOpsCount = table.Column(type: "integer", nullable: false), + StakingOpsCount = table.Column(type: "integer", nullable: false), TransactionOpsCount = table.Column(type: "integer", nullable: false), RegisterConstantOpsCount = table.Column(type: "integer", nullable: false), EndorsingRewardOpsCount = table.Column(type: "integer", nullable: false), @@ -66,14 +79,27 @@ protected override void Up(MigrationBuilder migrationBuilder) TxRollupDispatchTicketsOpsCount = table.Column(type: "integer", nullable: false), TransferTicketOpsCount = table.Column(type: "integer", nullable: false), IncreasePaidStorageOpsCount = table.Column(type: "integer", nullable: false), + UpdateConsensusKeyOpsCount = table.Column(type: "integer", nullable: false), + DrainDelegateOpsCount = table.Column(type: "integer", nullable: false), MigrationOpsCount = table.Column(type: "integer", nullable: false), RevelationPenaltyOpsCount = table.Column(type: "integer", nullable: false), + AutostakingOpsCount = table.Column(type: "integer", nullable: false), + SmartRollupAddMessagesOpsCount = table.Column(type: "integer", nullable: false), + SmartRollupCementOpsCount = table.Column(type: "integer", nullable: false), + SmartRollupExecuteOpsCount = table.Column(type: "integer", nullable: false), + SmartRollupOriginateOpsCount = table.Column(type: "integer", nullable: false), + SmartRollupPublishOpsCount = table.Column(type: "integer", nullable: false), + SmartRollupRecoverBondOpsCount = table.Column(type: "integer", nullable: false), + SmartRollupRefuteOpsCount = table.Column(type: "integer", nullable: false), ProposalsCount = table.Column(type: "integer", nullable: false), CyclesCount = table.Column(type: "integer", nullable: false), ConstantsCount = table.Column(type: "integer", nullable: false), TokensCount = table.Column(type: "integer", nullable: false), TokenBalancesCount = table.Column(type: "integer", nullable: false), TokenTransfersCount = table.Column(type: "integer", nullable: false), + TicketsCount = table.Column(type: "integer", nullable: false), + TicketBalancesCount = table.Column(type: "integer", nullable: false), + TicketTransfersCount = table.Column(type: "integer", nullable: false), EventsCount = table.Column(type: "integer", nullable: false), QuoteLevel = table.Column(type: "integer", nullable: false), QuoteBtc = table.Column(type: "double precision", nullable: false), @@ -84,13 +110,32 @@ protected override void Up(MigrationBuilder migrationBuilder) QuoteKrw = table.Column(type: "double precision", nullable: false), QuoteEth = table.Column(type: "double precision", nullable: false), QuoteGbp = table.Column(type: "double precision", nullable: false), - Metadata = table.Column(type: "jsonb", nullable: true) + DomainsNameRegistry = table.Column(type: "text", nullable: true), + DomainsLevel = table.Column(type: "integer", nullable: false), + Extras = table.Column(type: "jsonb", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AppState", x => x.Id); }); + migrationBuilder.CreateTable( + name: "AutostakingOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Level = table.Column(type: "integer", nullable: false), + BakerId = table.Column(type: "integer", nullable: false), + Action = table.Column(type: "integer", nullable: false), + Cycle = table.Column(type: "integer", nullable: false), + Amount = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AutostakingOps", x => x.Id); + }); + migrationBuilder.CreateTable( name: "BakerCycles", columns: table => new @@ -99,11 +144,14 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Cycle = table.Column(type: "integer", nullable: false), BakerId = table.Column(type: "integer", nullable: false), + OwnDelegatedBalance = table.Column(type: "bigint", nullable: false), + ExternalDelegatedBalance = table.Column(type: "bigint", nullable: false), DelegatorsCount = table.Column(type: "integer", nullable: false), - DelegatedBalance = table.Column(type: "bigint", nullable: false), - StakingBalance = table.Column(type: "bigint", nullable: false), - ActiveStake = table.Column(type: "bigint", nullable: false), - SelectedStake = table.Column(type: "bigint", nullable: false), + OwnStakedBalance = table.Column(type: "bigint", nullable: false), + ExternalStakedBalance = table.Column(type: "bigint", nullable: false), + StakersCount = table.Column(type: "integer", nullable: false), + BakingPower = table.Column(type: "bigint", nullable: false), + TotalBakingPower = table.Column(type: "bigint", nullable: false), FutureBlocks = table.Column(type: "integer", nullable: false), Blocks = table.Column(type: "integer", nullable: false), MissedBlocks = table.Column(type: "integer", nullable: false), @@ -111,21 +159,39 @@ protected override void Up(MigrationBuilder migrationBuilder) Endorsements = table.Column(type: "integer", nullable: false), MissedEndorsements = table.Column(type: "integer", nullable: false), FutureBlockRewards = table.Column(type: "bigint", nullable: false), - BlockRewards = table.Column(type: "bigint", nullable: false), MissedBlockRewards = table.Column(type: "bigint", nullable: false), + BlockRewardsLiquid = table.Column(type: "bigint", nullable: false), + BlockRewardsStakedOwn = table.Column(type: "bigint", nullable: false), + BlockRewardsStakedShared = table.Column(type: "bigint", nullable: false), FutureEndorsementRewards = table.Column(type: "bigint", nullable: false), - EndorsementRewards = table.Column(type: "bigint", nullable: false), MissedEndorsementRewards = table.Column(type: "bigint", nullable: false), + EndorsementRewardsLiquid = table.Column(type: "bigint", nullable: false), + EndorsementRewardsStakedOwn = table.Column(type: "bigint", nullable: false), + EndorsementRewardsStakedShared = table.Column(type: "bigint", nullable: false), BlockFees = table.Column(type: "bigint", nullable: false), MissedBlockFees = table.Column(type: "bigint", nullable: false), DoubleBakingRewards = table.Column(type: "bigint", nullable: false), - DoubleBakingLosses = table.Column(type: "bigint", nullable: false), + DoubleBakingLostStaked = table.Column(type: "bigint", nullable: false), + DoubleBakingLostUnstaked = table.Column(type: "bigint", nullable: false), + DoubleBakingLostExternalStaked = table.Column(type: "bigint", nullable: false), + DoubleBakingLostExternalUnstaked = table.Column(type: "bigint", nullable: false), DoubleEndorsingRewards = table.Column(type: "bigint", nullable: false), - DoubleEndorsingLosses = table.Column(type: "bigint", nullable: false), + DoubleEndorsingLostStaked = table.Column(type: "bigint", nullable: false), + DoubleEndorsingLostUnstaked = table.Column(type: "bigint", nullable: false), + DoubleEndorsingLostExternalStaked = table.Column(type: "bigint", nullable: false), + DoubleEndorsingLostExternalUnstaked = table.Column(type: "bigint", nullable: false), DoublePreendorsingRewards = table.Column(type: "bigint", nullable: false), - DoublePreendorsingLosses = table.Column(type: "bigint", nullable: false), - RevelationRewards = table.Column(type: "bigint", nullable: false), - RevelationLosses = table.Column(type: "bigint", nullable: false), + DoublePreendorsingLostStaked = table.Column(type: "bigint", nullable: false), + DoublePreendorsingLostUnstaked = table.Column(type: "bigint", nullable: false), + DoublePreendorsingLostExternalStaked = table.Column(type: "bigint", nullable: false), + DoublePreendorsingLostExternalUnstaked = table.Column(type: "bigint", nullable: false), + VdfRevelationRewardsLiquid = table.Column(type: "bigint", nullable: false), + VdfRevelationRewardsStakedOwn = table.Column(type: "bigint", nullable: false), + VdfRevelationRewardsStakedShared = table.Column(type: "bigint", nullable: false), + NonceRevelationRewardsLiquid = table.Column(type: "bigint", nullable: false), + NonceRevelationRewardsStakedOwn = table.Column(type: "bigint", nullable: false), + NonceRevelationRewardsStakedShared = table.Column(type: "bigint", nullable: false), + NonceRevelationLosses = table.Column(type: "bigint", nullable: false), ExpectedBlocks = table.Column(type: "double precision", nullable: false), ExpectedEndorsements = table.Column(type: "double precision", nullable: false) }, @@ -248,13 +314,16 @@ protected override void Up(MigrationBuilder migrationBuilder) LastLevel = table.Column(type: "integer", nullable: false), SnapshotIndex = table.Column(type: "integer", nullable: false), SnapshotLevel = table.Column(type: "integer", nullable: false), - TotalStaking = table.Column(type: "bigint", nullable: false), - TotalDelegated = table.Column(type: "bigint", nullable: false), - TotalDelegators = table.Column(type: "integer", nullable: false), TotalBakers = table.Column(type: "integer", nullable: false), - SelectedBakers = table.Column(type: "integer", nullable: false), - SelectedStake = table.Column(type: "bigint", nullable: false), - Seed = table.Column(type: "bytea", fixedLength: true, maxLength: 32, nullable: false) + TotalBakingPower = table.Column(type: "bigint", nullable: false), + Seed = table.Column(type: "bytea", fixedLength: true, maxLength: 32, nullable: false), + BlockReward = table.Column(type: "bigint", nullable: false), + BlockBonusPerSlot = table.Column(type: "bigint", nullable: false), + MaxBlockReward = table.Column(type: "bigint", nullable: false), + EndorsementRewardPerSlot = table.Column(type: "bigint", nullable: false), + NonceRevelationReward = table.Column(type: "bigint", nullable: false), + VdfRevelationReward = table.Column(type: "bigint", nullable: false), + LBSubsidy = table.Column(type: "bigint", nullable: false) }, constraints: table => { @@ -271,13 +340,35 @@ protected override void Up(MigrationBuilder migrationBuilder) Cycle = table.Column(type: "integer", nullable: false), DelegatorId = table.Column(type: "integer", nullable: false), BakerId = table.Column(type: "integer", nullable: false), - Balance = table.Column(type: "bigint", nullable: false) + DelegatedBalance = table.Column(type: "bigint", nullable: false), + StakedBalance = table.Column(type: "bigint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DelegatorCycles", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Domains", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Level = table.Column(type: "integer", nullable: false), + Name = table.Column(type: "text", nullable: true), + Owner = table.Column(type: "text", nullable: true), + Address = table.Column(type: "text", nullable: true), + Reverse = table.Column(type: "boolean", nullable: false), + Expiration = table.Column(type: "timestamp with time zone", nullable: false), + Data = table.Column(type: "jsonb", nullable: true), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Domains", x => x.Id); + }); + migrationBuilder.CreateTable( name: "EndorsingRewardOps", columns: table => new @@ -285,10 +376,12 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), BakerId = table.Column(type: "integer", nullable: false), Expected = table.Column(type: "bigint", nullable: false), - Received = table.Column(type: "bigint", nullable: false) + RewardLiquid = table.Column(type: "bigint", nullable: false), + RewardStakedOwn = table.Column(type: "bigint", nullable: false), + RewardStakedShared = table.Column(type: "bigint", nullable: false) }, constraints: table => { @@ -316,18 +409,21 @@ protected override void Up(MigrationBuilder migrationBuilder) }); migrationBuilder.CreateTable( - name: "FreezerUpdates", + name: "InboxMessages", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Cycle = table.Column(type: "integer", nullable: false), - BakerId = table.Column(type: "integer", nullable: false), - Change = table.Column(type: "bigint", nullable: false) + Level = table.Column(type: "integer", nullable: false), + Type = table.Column(type: "integer", nullable: false), + PredecessorLevel = table.Column(type: "integer", nullable: true), + OperationId = table.Column(type: "bigint", nullable: true), + Payload = table.Column(type: "bytea", nullable: true), + Protocol = table.Column(type: "text", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_FreezerUpdates", x => x.Id); + table.PrimaryKey("PK_InboxMessages", x => x.Id); }); migrationBuilder.CreateTable( @@ -344,7 +440,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Upvotes = table.Column(type: "integer", nullable: false), VotingPower = table.Column(type: "bigint", nullable: false), Status = table.Column(type: "integer", nullable: false), - Metadata = table.Column(type: "jsonb", nullable: true) + Extras = table.Column(type: "jsonb", nullable: true) }, constraints: table => { @@ -375,36 +471,45 @@ protected override void Up(MigrationBuilder migrationBuilder) HardOperationGasLimit = table.Column(type: "integer", nullable: false), HardOperationStorageLimit = table.Column(type: "integer", nullable: false), HardBlockGasLimit = table.Column(type: "integer", nullable: false), - TokensPerRoll = table.Column(type: "bigint", nullable: false), - RevelationReward = table.Column(type: "bigint", nullable: false), + MinimalStake = table.Column(type: "bigint", nullable: false), + MinimalFrozenStake = table.Column(type: "bigint", nullable: false), BlockDeposit = table.Column(type: "bigint", nullable: false), BlockReward0 = table.Column(type: "bigint", nullable: false), BlockReward1 = table.Column(type: "bigint", nullable: false), + MaxBakingReward = table.Column(type: "bigint", nullable: false), EndorsementDeposit = table.Column(type: "bigint", nullable: false), EndorsementReward0 = table.Column(type: "bigint", nullable: false), EndorsementReward1 = table.Column(type: "bigint", nullable: false), + MaxEndorsingReward = table.Column(type: "bigint", nullable: false), OriginationSize = table.Column(type: "integer", nullable: false), ByteCost = table.Column(type: "integer", nullable: false), ProposalQuorum = table.Column(type: "integer", nullable: false), BallotQuorumMin = table.Column(type: "integer", nullable: false), BallotQuorumMax = table.Column(type: "integer", nullable: false), - LBSubsidy = table.Column(type: "integer", nullable: false), - LBSunsetLevel = table.Column(type: "integer", nullable: false), LBToggleThreshold = table.Column(type: "integer", nullable: false), ConsensusThreshold = table.Column(type: "integer", nullable: false), MinParticipationNumerator = table.Column(type: "integer", nullable: false), MinParticipationDenominator = table.Column(type: "integer", nullable: false), MaxSlashingPeriod = table.Column(type: "integer", nullable: false), - FrozenDepositsPercentage = table.Column(type: "integer", nullable: false), - DoubleBakingPunishment = table.Column(type: "bigint", nullable: false), - DoubleEndorsingPunishmentNumerator = table.Column(type: "integer", nullable: false), - DoubleEndorsingPunishmentDenominator = table.Column(type: "integer", nullable: false), - MaxBakingReward = table.Column(type: "bigint", nullable: false), - MaxEndorsingReward = table.Column(type: "bigint", nullable: false), - TxRollupOriginationSize = table.Column(type: "integer", nullable: false), - TxRollupCommitmentBond = table.Column(type: "bigint", nullable: false), + MaxDelegatedOverFrozenRatio = table.Column(type: "integer", nullable: false), + MaxExternalOverOwnStakeRatio = table.Column(type: "integer", nullable: false), + StakePowerMultiplier = table.Column(type: "integer", nullable: false), + SmartRollupOriginationSize = table.Column(type: "integer", nullable: false), + SmartRollupStakeAmount = table.Column(type: "bigint", nullable: false), + SmartRollupChallengeWindow = table.Column(type: "integer", nullable: false), + SmartRollupCommitmentPeriod = table.Column(type: "integer", nullable: false), + SmartRollupTimeoutPeriod = table.Column(type: "integer", nullable: false), Dictator = table.Column(type: "text", nullable: true), - Metadata = table.Column(type: "jsonb", nullable: true) + BaseIssuedPerMinute = table.Column(type: "bigint", nullable: false), + BlockRewardWeight = table.Column(type: "integer", nullable: false), + BlockBonusWeight = table.Column(type: "integer", nullable: false), + EndorsingRewardWeight = table.Column(type: "integer", nullable: false), + NonceRevelationRewardWeight = table.Column(type: "integer", nullable: false), + VdfRevelationRewardWeight = table.Column(type: "integer", nullable: false), + LBSubsidyWeight = table.Column(type: "integer", nullable: false), + DoubleBakingSlashedPercentage = table.Column(type: "integer", nullable: false), + DoubleEndorsingSlashedPercentage = table.Column(type: "integer", nullable: false), + Extras = table.Column(type: "jsonb", nullable: true) }, constraints: table => { @@ -419,7 +524,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), Btc = table.Column(type: "double precision", nullable: false), Eur = table.Column(type: "double precision", nullable: false), Usd = table.Column(type: "double precision", nullable: false), @@ -434,6 +539,30 @@ protected override void Up(MigrationBuilder migrationBuilder) table.PrimaryKey("PK_Quotes", x => x.Id); }); + migrationBuilder.CreateTable( + name: "RefutationGames", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SmartRollupId = table.Column(type: "integer", nullable: false), + InitiatorId = table.Column(type: "integer", nullable: false), + OpponentId = table.Column(type: "integer", nullable: false), + InitiatorCommitmentId = table.Column(type: "integer", nullable: false), + OpponentCommitmentId = table.Column(type: "integer", nullable: false), + LastMoveId = table.Column(type: "bigint", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + InitiatorReward = table.Column(type: "bigint", nullable: true), + InitiatorLoss = table.Column(type: "bigint", nullable: true), + OpponentReward = table.Column(type: "bigint", nullable: true), + OpponentLoss = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_RefutationGames", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Scripts", columns: table => new @@ -457,6 +586,31 @@ protected override void Up(MigrationBuilder migrationBuilder) table.PrimaryKey("PK_Scripts", x => x.Id); }); + migrationBuilder.CreateTable( + name: "SmartRollupCommitments", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + InitiatorId = table.Column(type: "integer", nullable: false), + SmartRollupId = table.Column(type: "integer", nullable: false), + PredecessorId = table.Column(type: "integer", nullable: true), + InboxLevel = table.Column(type: "integer", nullable: false), + State = table.Column(type: "text", nullable: true), + Hash = table.Column(type: "text", nullable: true), + Ticks = table.Column(type: "bigint", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + Stakers = table.Column(type: "integer", nullable: false), + ActiveStakers = table.Column(type: "integer", nullable: false), + Successors = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SmartRollupCommitments", x => x.Id); + }); + migrationBuilder.CreateTable( name: "SnapshotBalances", columns: table => new @@ -464,12 +618,16 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Level = table.Column(type: "integer", nullable: false), - Balance = table.Column(type: "bigint", nullable: false), AccountId = table.Column(type: "integer", nullable: false), - DelegateId = table.Column(type: "integer", nullable: true), - DelegatorsCount = table.Column(type: "integer", nullable: true), - DelegatedBalance = table.Column(type: "bigint", nullable: true), - StakingBalance = table.Column(type: "bigint", nullable: true) + BakerId = table.Column(type: "integer", nullable: false), + OwnDelegatedBalance = table.Column(type: "bigint", nullable: false), + ExternalDelegatedBalance = table.Column(type: "bigint", nullable: false), + DelegatorsCount = table.Column(type: "integer", nullable: false), + OwnStakedBalance = table.Column(type: "bigint", nullable: false), + ExternalStakedBalance = table.Column(type: "bigint", nullable: false), + StakersCount = table.Column(type: "integer", nullable: false), + StakedPseudotokens = table.Column(type: "bigint", nullable: false), + IssuedPseudotokens = table.Column(type: "bigint", nullable: false) }, constraints: table => { @@ -486,7 +644,7 @@ protected override void Up(MigrationBuilder migrationBuilder) FirstLevel = table.Column(type: "integer", nullable: false), LastLevel = table.Column(type: "integer", nullable: false), ShortHash = table.Column(type: "character(8)", fixedLength: true, maxLength: 8, nullable: false), - Metadata = table.Column(type: "jsonb", nullable: true) + Extras = table.Column(type: "jsonb", nullable: true) }, constraints: table => { @@ -501,15 +659,17 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Level = table.Column(type: "integer", nullable: false), Cycle = table.Column(type: "integer", nullable: true), - Date = table.Column(type: "timestamp without time zone", nullable: true), + Date = table.Column(type: "timestamp with time zone", nullable: true), TotalBootstrapped = table.Column(type: "bigint", nullable: false), TotalCommitments = table.Column(type: "bigint", nullable: false), TotalActivated = table.Column(type: "bigint", nullable: false), TotalCreated = table.Column(type: "bigint", nullable: false), TotalBurned = table.Column(type: "bigint", nullable: false), TotalBanished = table.Column(type: "bigint", nullable: false), + TotalLost = table.Column(type: "bigint", nullable: false), TotalFrozen = table.Column(type: "bigint", nullable: false), - TotalRollupBonds = table.Column(type: "bigint", nullable: false) + TotalRollupBonds = table.Column(type: "bigint", nullable: false), + TotalSmartRollupBonds = table.Column(type: "bigint", nullable: false) }, constraints: table => { @@ -536,6 +696,73 @@ protected override void Up(MigrationBuilder migrationBuilder) table.PrimaryKey("PK_Storages", x => x.Id); }); + migrationBuilder.CreateTable( + name: "TicketBalances", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TicketerId = table.Column(type: "integer", nullable: false), + TicketId = table.Column(type: "bigint", nullable: false), + AccountId = table.Column(type: "integer", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + TransfersCount = table.Column(type: "integer", nullable: false), + Balance = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketBalances", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Tickets", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TicketerId = table.Column(type: "integer", nullable: false), + FirstMinterId = table.Column(type: "integer", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + TransfersCount = table.Column(type: "integer", nullable: false), + BalancesCount = table.Column(type: "integer", nullable: false), + HoldersCount = table.Column(type: "integer", nullable: false), + TotalMinted = table.Column(type: "text", nullable: false), + TotalBurned = table.Column(type: "text", nullable: false), + TotalSupply = table.Column(type: "text", nullable: false), + TypeHash = table.Column(type: "integer", nullable: false), + ContentHash = table.Column(type: "integer", nullable: false), + RawType = table.Column(type: "bytea", nullable: true), + RawContent = table.Column(type: "bytea", nullable: true), + JsonContent = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tickets", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TicketTransfers", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Level = table.Column(type: "integer", nullable: false), + TicketerId = table.Column(type: "integer", nullable: false), + TicketId = table.Column(type: "bigint", nullable: false), + Amount = table.Column(type: "text", nullable: false), + FromId = table.Column(type: "integer", nullable: true), + ToId = table.Column(type: "integer", nullable: true), + TransactionId = table.Column(type: "bigint", nullable: true), + TransferTicketId = table.Column(type: "bigint", nullable: true), + SmartRollupExecuteId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketTransfers", x => x.Id); + }); + migrationBuilder.CreateTable( name: "TokenBalances", columns: table => new @@ -624,6 +851,7 @@ protected override void Up(MigrationBuilder migrationBuilder) ProposalsCount = table.Column(type: "integer", nullable: true), TopUpvotes = table.Column(type: "integer", nullable: true), TopVotingPower = table.Column(type: "bigint", nullable: true), + SingleWinner = table.Column(type: "boolean", nullable: true), ParticipationEma = table.Column(type: "integer", nullable: true), BallotsQuorum = table.Column(type: "integer", nullable: true), Supermajority = table.Column(type: "integer", nullable: true), @@ -657,98 +885,6 @@ protected override void Up(MigrationBuilder migrationBuilder) table.PrimaryKey("PK_VotingSnapshots", x => x.Id); }); - migrationBuilder.CreateTable( - name: "ActivationOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - AccountId = table.Column(type: "integer", nullable: false), - Balance = table.Column(type: "bigint", nullable: false), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ActivationOps", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "BallotOps", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Epoch = table.Column(type: "integer", nullable: false), - Period = table.Column(type: "integer", nullable: false), - ProposalId = table.Column(type: "integer", nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - VotingPower = table.Column(type: "bigint", nullable: false), - Vote = table.Column(type: "integer", nullable: false), - Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BallotOps", x => x.Id); - table.ForeignKey( - name: "FK_BallotOps_Proposals_ProposalId", - column: x => x.ProposalId, - principalTable: "Proposals", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Blocks", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Cycle = table.Column(type: "integer", nullable: false), - Level = table.Column(type: "integer", nullable: false), - Hash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), - ProtoCode = table.Column(type: "integer", nullable: false), - SoftwareId = table.Column(type: "integer", nullable: true), - PayloadRound = table.Column(type: "integer", nullable: false), - BlockRound = table.Column(type: "integer", nullable: false), - Validations = table.Column(type: "integer", nullable: false), - Events = table.Column(type: "integer", nullable: false), - Operations = table.Column(type: "integer", nullable: false), - Deposit = table.Column(type: "bigint", nullable: false), - Reward = table.Column(type: "bigint", nullable: false), - Bonus = table.Column(type: "bigint", nullable: false), - Fees = table.Column(type: "bigint", nullable: false), - ProposerId = table.Column(type: "integer", nullable: true), - ProducerId = table.Column(type: "integer", nullable: true), - RevelationId = table.Column(type: "bigint", nullable: true), - ResetBakerDeactivation = table.Column(type: "integer", nullable: true), - ResetProposerDeactivation = table.Column(type: "integer", nullable: true), - LBToggle = table.Column(type: "boolean", nullable: true), - LBToggleEma = table.Column(type: "integer", nullable: false), - Metadata = table.Column(type: "jsonb", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Blocks", x => x.Id); - table.UniqueConstraint("AK_Blocks_Level", x => x.Level); - table.ForeignKey( - name: "FK_Blocks_Protocols_ProtoCode", - column: x => x.ProtoCode, - principalTable: "Protocols", - principalColumn: "Code", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Blocks_Software_SoftwareId", - column: x => x.SoftwareId, - principalTable: "Software", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - migrationBuilder.CreateTable( name: "Accounts", columns: table => new @@ -761,12 +897,21 @@ protected override void Up(MigrationBuilder migrationBuilder) LastLevel = table.Column(type: "integer", nullable: false), Balance = table.Column(type: "bigint", nullable: false), RollupBonds = table.Column(type: "bigint", nullable: false), + SmartRollupBonds = table.Column(type: "bigint", nullable: false), Counter = table.Column(type: "integer", nullable: false), + LostBalance = table.Column(type: "bigint", nullable: false), + DelegateId = table.Column(type: "integer", nullable: true), + DelegationLevel = table.Column(type: "integer", nullable: true), + Staked = table.Column(type: "boolean", nullable: false), ContractsCount = table.Column(type: "integer", nullable: false), RollupsCount = table.Column(type: "integer", nullable: false), + SmartRollupsCount = table.Column(type: "integer", nullable: false), ActiveTokensCount = table.Column(type: "integer", nullable: false), TokenBalancesCount = table.Column(type: "integer", nullable: false), TokenTransfersCount = table.Column(type: "integer", nullable: false), + ActiveTicketsCount = table.Column(type: "integer", nullable: false), + TicketBalancesCount = table.Column(type: "integer", nullable: false), + TicketTransfersCount = table.Column(type: "integer", nullable: false), DelegationsCount = table.Column(type: "integer", nullable: false), OriginationsCount = table.Column(type: "integer", nullable: false), TransactionsCount = table.Column(type: "integer", nullable: false), @@ -781,10 +926,19 @@ protected override void Up(MigrationBuilder migrationBuilder) TxRollupDispatchTicketsCount = table.Column(type: "integer", nullable: false), TransferTicketCount = table.Column(type: "integer", nullable: false), IncreasePaidStorageCount = table.Column(type: "integer", nullable: false), + UpdateConsensusKeyCount = table.Column(type: "integer", nullable: false), + DrainDelegateCount = table.Column(type: "integer", nullable: false), MigrationsCount = table.Column(type: "integer", nullable: false), - DelegateId = table.Column(type: "integer", nullable: true), - DelegationLevel = table.Column(type: "integer", nullable: true), - Staked = table.Column(type: "boolean", nullable: false), + SmartRollupAddMessagesCount = table.Column(type: "integer", nullable: false), + SmartRollupCementCount = table.Column(type: "integer", nullable: false), + SmartRollupExecuteCount = table.Column(type: "integer", nullable: false), + SmartRollupOriginateCount = table.Column(type: "integer", nullable: false), + SmartRollupPublishCount = table.Column(type: "integer", nullable: false), + SmartRollupRecoverBondCount = table.Column(type: "integer", nullable: false), + SmartRollupRefuteCount = table.Column(type: "integer", nullable: false), + RefutationGamesCount = table.Column(type: "integer", nullable: false), + ActiveRefutationGamesCount = table.Column(type: "integer", nullable: false), + Extras = table.Column(type: "jsonb", nullable: true), Metadata = table.Column(type: "jsonb", nullable: true), Kind = table.Column(type: "smallint", nullable: true), TypeHash = table.Column(type: "integer", nullable: true), @@ -792,22 +946,45 @@ protected override void Up(MigrationBuilder migrationBuilder) Tags = table.Column(type: "integer", nullable: true), TokensCount = table.Column(type: "integer", nullable: true), EventsCount = table.Column(type: "integer", nullable: true), + TicketsCount = table.Column(type: "integer", nullable: true), Spendable = table.Column(type: "boolean", nullable: true), CreatorId = table.Column(type: "integer", nullable: true), ManagerId = table.Column(type: "integer", nullable: true), WeirdDelegateId = table.Column(type: "integer", nullable: true), - Activated = table.Column(type: "boolean", nullable: true), - PublicKey = table.Column(type: "character varying(55)", maxLength: 55, nullable: true), + PvmKind = table.Column(type: "integer", nullable: true), + GenesisCommitment = table.Column(type: "text", nullable: true), + LastCommitment = table.Column(type: "text", nullable: true), + InboxLevel = table.Column(type: "integer", nullable: true), + TotalStakers = table.Column(type: "integer", nullable: true), + ActiveStakers = table.Column(type: "integer", nullable: true), + ExecutedCommitments = table.Column(type: "integer", nullable: true), + CementedCommitments = table.Column(type: "integer", nullable: true), + PendingCommitments = table.Column(type: "integer", nullable: true), + RefutedCommitments = table.Column(type: "integer", nullable: true), + OrphanCommitments = table.Column(type: "integer", nullable: true), Revealed = table.Column(type: "boolean", nullable: true), + PublicKey = table.Column(type: "text", nullable: true), + StakedBalance = table.Column(type: "bigint", nullable: true), + StakedPseudotokens = table.Column(type: "bigint", nullable: true), + UnstakedBalance = table.Column(type: "bigint", nullable: true), + UnstakedBakerId = table.Column(type: "integer", nullable: true), + Activated = table.Column(type: "boolean", nullable: true), RegisterConstantsCount = table.Column(type: "integer", nullable: true), SetDepositsLimitsCount = table.Column(type: "integer", nullable: true), + StakingOpsCount = table.Column(type: "integer", nullable: true), ActivationLevel = table.Column(type: "integer", nullable: true), DeactivationLevel = table.Column(type: "integer", nullable: true), - FrozenDepositLimit = table.Column(type: "bigint", nullable: true), - FrozenDeposit = table.Column(type: "bigint", nullable: true), StakingBalance = table.Column(type: "bigint", nullable: true), DelegatedBalance = table.Column(type: "bigint", nullable: true), DelegatorsCount = table.Column(type: "integer", nullable: true), + TotalStakedBalance = table.Column(type: "bigint", nullable: true), + ExternalStakedBalance = table.Column(type: "bigint", nullable: true), + ExternalUnstakedBalance = table.Column(type: "bigint", nullable: true), + IssuedPseudotokens = table.Column(type: "bigint", nullable: true), + StakersCount = table.Column(type: "integer", nullable: true), + FrozenDepositLimit = table.Column(type: "bigint", nullable: true), + LimitOfStakingOverBaking = table.Column(type: "bigint", nullable: true), + EdgeOfBakingOverStaking = table.Column(type: "bigint", nullable: true), BlocksCount = table.Column(type: "integer", nullable: true), EndorsementsCount = table.Column(type: "integer", nullable: true), PreendorsementsCount = table.Column(type: "integer", nullable: true), @@ -820,6 +997,7 @@ protected override void Up(MigrationBuilder migrationBuilder) VdfRevelationsCount = table.Column(type: "integer", nullable: true), RevelationPenaltiesCount = table.Column(type: "integer", nullable: true), EndorsingRewardsCount = table.Column(type: "integer", nullable: true), + AutostakingOpsCount = table.Column(type: "integer", nullable: true), SoftwareId = table.Column(type: "integer", nullable: true) }, constraints: table => @@ -829,89 +1007,192 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_Accounts_Accounts_CreatorId", column: x => x.CreatorId, principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); table.ForeignKey( name: "FK_Accounts_Accounts_DelegateId", column: x => x.DelegateId, principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); table.ForeignKey( name: "FK_Accounts_Accounts_ManagerId", column: x => x.ManagerId, principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); table.ForeignKey( name: "FK_Accounts_Accounts_WeirdDelegateId", column: x => x.WeirdDelegateId, principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_Accounts_Blocks_FirstLevel", - column: x => x.FirstLevel, - principalTable: "Blocks", - principalColumn: "Level", - onDelete: ReferentialAction.Cascade); + principalColumn: "Id"); table.ForeignKey( name: "FK_Accounts_Software_SoftwareId", column: x => x.SoftwareId, principalTable: "Software", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); }); migrationBuilder.CreateTable( - name: "DelegationOps", + name: "ActivationOps", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - SenderCodeHash = table.Column(type: "integer", nullable: true), - DelegateId = table.Column(type: "integer", nullable: true), - PrevDelegateId = table.Column(type: "integer", nullable: true), - ResetDeactivation = table.Column(type: "integer", nullable: true), - Amount = table.Column(type: "bigint", nullable: false), + AccountId = table.Column(type: "integer", nullable: false), + Balance = table.Column(type: "bigint", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - Counter = table.Column(type: "integer", nullable: false), - BakerFee = table.Column(type: "bigint", nullable: false), - StorageFee = table.Column(type: "bigint", nullable: true), - AllocationFee = table.Column(type: "bigint", nullable: true), - GasLimit = table.Column(type: "integer", nullable: false), - GasUsed = table.Column(type: "integer", nullable: false), - StorageLimit = table.Column(type: "integer", nullable: false), - StorageUsed = table.Column(type: "integer", nullable: false), - Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true), - InitiatorId = table.Column(type: "integer", nullable: true), - Nonce = table.Column(type: "integer", nullable: true) + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) }, constraints: table => { - table.PrimaryKey("PK_DelegationOps", x => x.Id); + table.PrimaryKey("PK_ActivationOps", x => x.Id); + table.ForeignKey( + name: "FK_ActivationOps_Accounts_AccountId", + column: x => x.AccountId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "BallotOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Epoch = table.Column(type: "integer", nullable: false), + Period = table.Column(type: "integer", nullable: false), + ProposalId = table.Column(type: "integer", nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + VotingPower = table.Column(type: "bigint", nullable: false), + Vote = table.Column(type: "integer", nullable: false), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BallotOps", x => x.Id); + table.ForeignKey( + name: "FK_BallotOps_Accounts_SenderId", + column: x => x.SenderId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_BallotOps_Proposals_ProposalId", + column: x => x.ProposalId, + principalTable: "Proposals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Blocks", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Cycle = table.Column(type: "integer", nullable: false), + Level = table.Column(type: "integer", nullable: false), + Hash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + ProtoCode = table.Column(type: "integer", nullable: false), + SoftwareId = table.Column(type: "integer", nullable: true), + PayloadRound = table.Column(type: "integer", nullable: false), + BlockRound = table.Column(type: "integer", nullable: false), + Validations = table.Column(type: "integer", nullable: false), + Events = table.Column(type: "integer", nullable: false), + Operations = table.Column(type: "bigint", nullable: false), + Deposit = table.Column(type: "bigint", nullable: false), + RewardLiquid = table.Column(type: "bigint", nullable: false), + RewardStakedOwn = table.Column(type: "bigint", nullable: false), + RewardStakedShared = table.Column(type: "bigint", nullable: false), + BonusLiquid = table.Column(type: "bigint", nullable: false), + BonusStakedOwn = table.Column(type: "bigint", nullable: false), + BonusStakedShared = table.Column(type: "bigint", nullable: false), + Fees = table.Column(type: "bigint", nullable: false), + ProposerId = table.Column(type: "integer", nullable: true), + ProducerId = table.Column(type: "integer", nullable: true), + RevelationId = table.Column(type: "bigint", nullable: true), + ResetBakerDeactivation = table.Column(type: "integer", nullable: true), + ResetProposerDeactivation = table.Column(type: "integer", nullable: true), + LBToggle = table.Column(type: "boolean", nullable: true), + LBToggleEma = table.Column(type: "integer", nullable: false), + AIToggle = table.Column(type: "boolean", nullable: true), + AIToggleEma = table.Column(type: "integer", nullable: false), + Extras = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Blocks", x => x.Id); + table.UniqueConstraint("AK_Blocks_Level", x => x.Level); + table.ForeignKey( + name: "FK_Blocks_Accounts_ProposerId", + column: x => x.ProposerId, + principalTable: "Accounts", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Blocks_Protocols_ProtoCode", + column: x => x.ProtoCode, + principalTable: "Protocols", + principalColumn: "Code", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Blocks_Software_SoftwareId", + column: x => x.SoftwareId, + principalTable: "Software", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "DelegationOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SenderCodeHash = table.Column(type: "integer", nullable: true), + DelegateId = table.Column(type: "integer", nullable: true), + PrevDelegateId = table.Column(type: "integer", nullable: true), + ResetDeactivation = table.Column(type: "integer", nullable: true), + Amount = table.Column(type: "bigint", nullable: false), + UnstakedPseudotokens = table.Column(type: "bigint", nullable: true), + UnstakedBalance = table.Column(type: "bigint", nullable: true), + UnstakedRewards = table.Column(type: "bigint", nullable: true), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true), + InitiatorId = table.Column(type: "integer", nullable: true), + Nonce = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_DelegationOps", x => x.Id); table.ForeignKey( name: "FK_DelegationOps_Accounts_DelegateId", column: x => x.DelegateId, principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); table.ForeignKey( name: "FK_DelegationOps_Accounts_InitiatorId", column: x => x.InitiatorId, principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); table.ForeignKey( name: "FK_DelegationOps_Accounts_PrevDelegateId", column: x => x.PrevDelegateId, principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); table.ForeignKey( name: "FK_DelegationOps_Accounts_SenderId", column: x => x.SenderId, @@ -933,12 +1214,17 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), AccusedLevel = table.Column(type: "integer", nullable: false), + SlashedLevel = table.Column(type: "integer", nullable: false), AccuserId = table.Column(type: "integer", nullable: false), - AccuserReward = table.Column(type: "bigint", nullable: false), OffenderId = table.Column(type: "integer", nullable: false), - OffenderLoss = table.Column(type: "bigint", nullable: false), + Reward = table.Column(type: "bigint", nullable: false), + LostStaked = table.Column(type: "bigint", nullable: false), + LostUnstaked = table.Column(type: "bigint", nullable: false), + LostExternalStaked = table.Column(type: "bigint", nullable: false), + LostExternalUnstaked = table.Column(type: "bigint", nullable: false), + RoundingLoss = table.Column(type: "bigint", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) }, constraints: table => @@ -971,12 +1257,17 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), AccusedLevel = table.Column(type: "integer", nullable: false), + SlashedLevel = table.Column(type: "integer", nullable: false), AccuserId = table.Column(type: "integer", nullable: false), - AccuserReward = table.Column(type: "bigint", nullable: false), OffenderId = table.Column(type: "integer", nullable: false), - OffenderLoss = table.Column(type: "bigint", nullable: false), + Reward = table.Column(type: "bigint", nullable: false), + LostStaked = table.Column(type: "bigint", nullable: false), + LostUnstaked = table.Column(type: "bigint", nullable: false), + LostExternalStaked = table.Column(type: "bigint", nullable: false), + LostExternalUnstaked = table.Column(type: "bigint", nullable: false), + RoundingLoss = table.Column(type: "bigint", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) }, constraints: table => @@ -1009,12 +1300,17 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), AccusedLevel = table.Column(type: "integer", nullable: false), + SlashedLevel = table.Column(type: "integer", nullable: false), AccuserId = table.Column(type: "integer", nullable: false), - AccuserReward = table.Column(type: "bigint", nullable: false), OffenderId = table.Column(type: "integer", nullable: false), - OffenderLoss = table.Column(type: "bigint", nullable: false), + Reward = table.Column(type: "bigint", nullable: false), + LostStaked = table.Column(type: "bigint", nullable: false), + LostUnstaked = table.Column(type: "bigint", nullable: false), + LostExternalStaked = table.Column(type: "bigint", nullable: false), + LostExternalUnstaked = table.Column(type: "bigint", nullable: false), + RoundingLoss = table.Column(type: "bigint", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) }, constraints: table => @@ -1040,6 +1336,31 @@ protected override void Up(MigrationBuilder migrationBuilder) onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "DrainDelegateOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DelegateId = table.Column(type: "integer", nullable: false), + TargetId = table.Column(type: "integer", nullable: false), + Amount = table.Column(type: "bigint", nullable: false), + Fee = table.Column(type: "bigint", nullable: false), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DrainDelegateOps", x => x.Id); + table.ForeignKey( + name: "FK_DrainDelegateOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "EndorsementOps", columns: table => new @@ -1052,7 +1373,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Deposit = table.Column(type: "bigint", nullable: false), ResetDeactivation = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) }, constraints: table => @@ -1081,7 +1402,7 @@ protected override void Up(MigrationBuilder migrationBuilder) ContractId = table.Column(type: "integer", nullable: false), Amount = table.Column(type: "text", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1119,7 +1440,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), AccountId = table.Column(type: "integer", nullable: false), Kind = table.Column(type: "integer", nullable: false), BalanceChange = table.Column(type: "bigint", nullable: false), @@ -1148,14 +1469,12 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_MigrationOps_Scripts_ScriptId", column: x => x.ScriptId, principalTable: "Scripts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); table.ForeignKey( name: "FK_MigrationOps_Storages_StorageId", column: x => x.StorageId, principalTable: "Storages", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -1168,10 +1487,12 @@ protected override void Up(MigrationBuilder migrationBuilder) SenderId = table.Column(type: "integer", nullable: false), RevealedLevel = table.Column(type: "integer", nullable: false), RevealedCycle = table.Column(type: "integer", nullable: false), - Reward = table.Column(type: "bigint", nullable: false), + RewardLiquid = table.Column(type: "bigint", nullable: false), + RewardStakedOwn = table.Column(type: "bigint", nullable: false), + RewardStakedShared = table.Column(type: "bigint", nullable: false), Nonce = table.Column(type: "bytea", fixedLength: true, maxLength: 32, nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) }, constraints: table => @@ -1212,7 +1533,339 @@ protected override void Up(MigrationBuilder migrationBuilder) ScriptId = table.Column(type: "integer", nullable: true), Balance = table.Column(type: "bigint", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true), + InitiatorId = table.Column(type: "integer", nullable: true), + Nonce = table.Column(type: "integer", nullable: true), + StorageId = table.Column(type: "integer", nullable: true), + BigMapUpdates = table.Column(type: "integer", nullable: true), + TokenTransfers = table.Column(type: "integer", nullable: true), + SubIds = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_OriginationOps", x => x.Id); + table.ForeignKey( + name: "FK_OriginationOps_Accounts_ContractId", + column: x => x.ContractId, + principalTable: "Accounts", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_OriginationOps_Accounts_DelegateId", + column: x => x.DelegateId, + principalTable: "Accounts", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_OriginationOps_Accounts_InitiatorId", + column: x => x.InitiatorId, + principalTable: "Accounts", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_OriginationOps_Accounts_ManagerId", + column: x => x.ManagerId, + principalTable: "Accounts", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_OriginationOps_Accounts_SenderId", + column: x => x.SenderId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_OriginationOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_OriginationOps_Scripts_ScriptId", + column: x => x.ScriptId, + principalTable: "Scripts", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_OriginationOps_Storages_StorageId", + column: x => x.StorageId, + principalTable: "Storages", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "PreendorsementOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + DelegateId = table.Column(type: "integer", nullable: false), + Slots = table.Column(type: "integer", nullable: false), + ResetDeactivation = table.Column(type: "integer", nullable: true), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PreendorsementOps", x => x.Id); + table.ForeignKey( + name: "FK_PreendorsementOps_Accounts_DelegateId", + column: x => x.DelegateId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PreendorsementOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProposalOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Epoch = table.Column(type: "integer", nullable: false), + Period = table.Column(type: "integer", nullable: false), + ProposalId = table.Column(type: "integer", nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + VotingPower = table.Column(type: "bigint", nullable: false), + Duplicated = table.Column(type: "boolean", nullable: false), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProposalOps", x => x.Id); + table.ForeignKey( + name: "FK_ProposalOps_Accounts_SenderId", + column: x => x.SenderId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProposalOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProposalOps_Proposals_ProposalId", + column: x => x.ProposalId, + principalTable: "Proposals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RegisterConstantOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Address = table.Column(type: "character varying(54)", maxLength: 54, nullable: true), + Value = table.Column(type: "bytea", nullable: true), + Refs = table.Column(type: "integer", nullable: true), + Extras = table.Column(type: "jsonb", nullable: true), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "text", nullable: true), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_RegisterConstantOps", x => x.Id); + table.ForeignKey( + name: "FK_RegisterConstantOps_Accounts_SenderId", + column: x => x.SenderId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RegisterConstantOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RevealOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_RevealOps", x => x.Id); + table.ForeignKey( + name: "FK_RevealOps_Accounts_SenderId", + column: x => x.SenderId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RevealOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RevelationPenaltyOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + BakerId = table.Column(type: "integer", nullable: false), + MissedLevel = table.Column(type: "integer", nullable: false), + Loss = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RevelationPenaltyOps", x => x.Id); + table.ForeignKey( + name: "FK_RevelationPenaltyOps_Accounts_BakerId", + column: x => x.BakerId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RevelationPenaltyOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SetDepositsLimitOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Limit = table.Column(type: "text", nullable: true), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "text", nullable: true), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SetDepositsLimitOps", x => x.Id); + table.ForeignKey( + name: "FK_SetDepositsLimitOps_Accounts_SenderId", + column: x => x.SenderId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_SetDepositsLimitOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SmartRollupAddMessagesOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + MessagesCount = table.Column(type: "integer", nullable: false), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SmartRollupAddMessagesOps", x => x.Id); + table.ForeignKey( + name: "FK_SmartRollupAddMessagesOps_Accounts_SenderId", + column: x => x.SenderId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_SmartRollupAddMessagesOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "SmartRollupCementOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SmartRollupId = table.Column(type: "integer", nullable: true), + CommitmentId = table.Column(type: "integer", nullable: true), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1224,91 +1877,61 @@ protected override void Up(MigrationBuilder migrationBuilder) StorageLimit = table.Column(type: "integer", nullable: false), StorageUsed = table.Column(type: "integer", nullable: false), Status = table.Column(type: "smallint", nullable: false), - Errors = table.Column(type: "text", nullable: true), - InitiatorId = table.Column(type: "integer", nullable: true), - Nonce = table.Column(type: "integer", nullable: true), - StorageId = table.Column(type: "integer", nullable: true), - BigMapUpdates = table.Column(type: "integer", nullable: true), - TokenTransfers = table.Column(type: "integer", nullable: true), - SubIds = table.Column(type: "integer", nullable: true) + Errors = table.Column(type: "text", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_OriginationOps", x => x.Id); - table.ForeignKey( - name: "FK_OriginationOps_Accounts_ContractId", - column: x => x.ContractId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_OriginationOps_Accounts_DelegateId", - column: x => x.DelegateId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_OriginationOps_Accounts_InitiatorId", - column: x => x.InitiatorId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + table.PrimaryKey("PK_SmartRollupCementOps", x => x.Id); table.ForeignKey( - name: "FK_OriginationOps_Accounts_ManagerId", - column: x => x.ManagerId, - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_OriginationOps_Accounts_SenderId", + name: "FK_SmartRollupCementOps_Accounts_SenderId", column: x => x.SenderId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_OriginationOps_Blocks_Level", + name: "FK_SmartRollupCementOps_Blocks_Level", column: x => x.Level, principalTable: "Blocks", principalColumn: "Level", onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_OriginationOps_Scripts_ScriptId", - column: x => x.ScriptId, - principalTable: "Scripts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_OriginationOps_Storages_StorageId", - column: x => x.StorageId, - principalTable: "Storages", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( - name: "PreendorsementOps", + name: "SmartRollupExecuteOps", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DelegateId = table.Column(type: "integer", nullable: false), - Slots = table.Column(type: "integer", nullable: false), - ResetDeactivation = table.Column(type: "integer", nullable: true), + SmartRollupId = table.Column(type: "integer", nullable: true), + CommitmentId = table.Column(type: "integer", nullable: true), + TicketTransfers = table.Column(type: "integer", nullable: true), + SubIds = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_PreendorsementOps", x => x.Id); + table.PrimaryKey("PK_SmartRollupExecuteOps", x => x.Id); table.ForeignKey( - name: "FK_PreendorsementOps_Accounts_DelegateId", - column: x => x.DelegateId, + name: "FK_SmartRollupExecuteOps_Accounts_SenderId", + column: x => x.SenderId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_PreendorsementOps_Blocks_Level", + name: "FK_SmartRollupExecuteOps_Blocks_Level", column: x => x.Level, principalTable: "Blocks", principalColumn: "Level", @@ -1316,57 +1939,62 @@ protected override void Up(MigrationBuilder migrationBuilder) }); migrationBuilder.CreateTable( - name: "ProposalOps", + name: "SmartRollupOriginateOps", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Epoch = table.Column(type: "integer", nullable: false), - Period = table.Column(type: "integer", nullable: false), - ProposalId = table.Column(type: "integer", nullable: false), - SenderId = table.Column(type: "integer", nullable: false), - VotingPower = table.Column(type: "bigint", nullable: false), - Duplicated = table.Column(type: "boolean", nullable: false), + PvmKind = table.Column(type: "integer", nullable: false), + Kernel = table.Column(type: "bytea", nullable: true), + ParameterType = table.Column(type: "bytea", nullable: true), + GenesisCommitment = table.Column(type: "text", nullable: true), + SmartRollupId = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), - OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_ProposalOps", x => x.Id); + table.PrimaryKey("PK_SmartRollupOriginateOps", x => x.Id); table.ForeignKey( - name: "FK_ProposalOps_Accounts_SenderId", + name: "FK_SmartRollupOriginateOps_Accounts_SenderId", column: x => x.SenderId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_ProposalOps_Blocks_Level", + name: "FK_SmartRollupOriginateOps_Blocks_Level", column: x => x.Level, principalTable: "Blocks", principalColumn: "Level", onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ProposalOps_Proposals_ProposalId", - column: x => x.ProposalId, - principalTable: "Proposals", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( - name: "RegisterConstantOps", + name: "SmartRollupPublishOps", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Address = table.Column(type: "character varying(54)", maxLength: 54, nullable: true), - Value = table.Column(type: "bytea", nullable: true), - Refs = table.Column(type: "integer", nullable: true), - Metadata = table.Column(type: "jsonb", nullable: true), + SmartRollupId = table.Column(type: "integer", nullable: true), + CommitmentId = table.Column(type: "integer", nullable: true), + Bond = table.Column(type: "bigint", nullable: false), + BondStatus = table.Column(type: "integer", nullable: true), + Flags = table.Column(type: "integer", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), - OpHash = table.Column(type: "text", nullable: true), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), BakerFee = table.Column(type: "bigint", nullable: false), @@ -1381,15 +2009,15 @@ protected override void Up(MigrationBuilder migrationBuilder) }, constraints: table => { - table.PrimaryKey("PK_RegisterConstantOps", x => x.Id); + table.PrimaryKey("PK_SmartRollupPublishOps", x => x.Id); table.ForeignKey( - name: "FK_RegisterConstantOps_Accounts_SenderId", + name: "FK_SmartRollupPublishOps_Accounts_SenderId", column: x => x.SenderId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_RegisterConstantOps_Blocks_Level", + name: "FK_SmartRollupPublishOps_Blocks_Level", column: x => x.Level, principalTable: "Blocks", principalColumn: "Level", @@ -1397,13 +2025,16 @@ protected override void Up(MigrationBuilder migrationBuilder) }); migrationBuilder.CreateTable( - name: "RevealOps", + name: "SmartRollupRecoverBondOps", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SmartRollupId = table.Column(type: "integer", nullable: true), + StakerId = table.Column(type: "integer", nullable: true), + Bond = table.Column(type: "bigint", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1419,15 +2050,15 @@ protected override void Up(MigrationBuilder migrationBuilder) }, constraints: table => { - table.PrimaryKey("PK_RevealOps", x => x.Id); + table.PrimaryKey("PK_SmartRollupRecoverBondOps", x => x.Id); table.ForeignKey( - name: "FK_RevealOps_Accounts_SenderId", + name: "FK_SmartRollupRecoverBondOps_Accounts_SenderId", column: x => x.SenderId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_RevealOps_Blocks_Level", + name: "FK_SmartRollupRecoverBondOps_Blocks_Level", column: x => x.Level, principalTable: "Blocks", principalColumn: "Level", @@ -1435,28 +2066,44 @@ protected override void Up(MigrationBuilder migrationBuilder) }); migrationBuilder.CreateTable( - name: "RevelationPenaltyOps", + name: "SmartRollupRefuteOps", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SmartRollupId = table.Column(type: "integer", nullable: true), + GameId = table.Column(type: "integer", nullable: true), + Move = table.Column(type: "integer", nullable: false), + GameStatus = table.Column(type: "integer", nullable: false), + DissectionStart = table.Column(type: "bigint", nullable: true), + DissectionEnd = table.Column(type: "bigint", nullable: true), + DissectionSteps = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), - BakerId = table.Column(type: "integer", nullable: false), - MissedLevel = table.Column(type: "integer", nullable: false), - Loss = table.Column(type: "bigint", nullable: false) + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_RevelationPenaltyOps", x => x.Id); + table.PrimaryKey("PK_SmartRollupRefuteOps", x => x.Id); table.ForeignKey( - name: "FK_RevelationPenaltyOps_Accounts_BakerId", - column: x => x.BakerId, + name: "FK_SmartRollupRefuteOps_Accounts_SenderId", + column: x => x.SenderId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_RevelationPenaltyOps_Blocks_Level", + name: "FK_SmartRollupRefuteOps_Blocks_Level", column: x => x.Level, principalTable: "Blocks", principalColumn: "Level", @@ -1464,15 +2111,24 @@ protected override void Up(MigrationBuilder migrationBuilder) }); migrationBuilder.CreateTable( - name: "SetDepositsLimitOps", + name: "StakingOps", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Limit = table.Column(type: "text", nullable: true), + Kind = table.Column(type: "integer", nullable: false), + BakerId = table.Column(type: "integer", nullable: true), + Amount = table.Column(type: "bigint", nullable: true), + Pseudotokens = table.Column(type: "bigint", nullable: true), + PrevStakedBalance = table.Column(type: "bigint", nullable: true), + FirstCycleUnstaked = table.Column(type: "integer", nullable: true), + LastCycleUnstaked = table.Column(type: "integer", nullable: true), + LimitOfStakingOverBaking = table.Column(type: "bigint", nullable: true), + EdgeOfBakingOverStaking = table.Column(type: "bigint", nullable: true), + ActivationCycle = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), - OpHash = table.Column(type: "text", nullable: true), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), BakerFee = table.Column(type: "bigint", nullable: false), @@ -1487,15 +2143,15 @@ protected override void Up(MigrationBuilder migrationBuilder) }, constraints: table => { - table.PrimaryKey("PK_SetDepositsLimitOps", x => x.Id); + table.PrimaryKey("PK_StakingOps", x => x.Id); table.ForeignKey( - name: "FK_SetDepositsLimitOps_Accounts_SenderId", + name: "FK_StakingOps_Accounts_SenderId", column: x => x.SenderId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_SetDepositsLimitOps_Blocks_Level", + name: "FK_StakingOps_Blocks_Level", column: x => x.Level, principalTable: "Blocks", principalColumn: "Level", @@ -1521,8 +2177,9 @@ protected override void Up(MigrationBuilder migrationBuilder) InternalOriginations = table.Column(type: "smallint", nullable: true), InternalTransactions = table.Column(type: "smallint", nullable: true), EventsCount = table.Column(type: "integer", nullable: true), + TicketTransfers = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1549,8 +2206,7 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_TransactionOps_Accounts_InitiatorId", column: x => x.InitiatorId, principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); table.ForeignKey( name: "FK_TransactionOps_Accounts_SenderId", column: x => x.SenderId, @@ -1561,8 +2217,7 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_TransactionOps_Accounts_TargetId", column: x => x.TargetId, principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); table.ForeignKey( name: "FK_TransactionOps_Blocks_Level", column: x => x.Level, @@ -1573,8 +2228,7 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_TransactionOps_Storages_StorageId", column: x => x.StorageId, principalTable: "Storages", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -1590,8 +2244,10 @@ protected override void Up(MigrationBuilder migrationBuilder) RawContent = table.Column(type: "bytea", nullable: true), JsonContent = table.Column(type: "text", nullable: true), Entrypoint = table.Column(type: "text", nullable: true), + TicketTransfers = table.Column(type: "integer", nullable: true), + SubIds = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1631,7 +2287,7 @@ protected override void Up(MigrationBuilder migrationBuilder) RollupId = table.Column(type: "integer", nullable: true), Bond = table.Column(type: "bigint", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1670,7 +2326,7 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RollupId = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1709,7 +2365,7 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RollupId = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1748,7 +2404,7 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RollupId = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1790,7 +2446,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Reward = table.Column(type: "bigint", nullable: false), Loss = table.Column(type: "bigint", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1829,7 +2485,7 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RollupId = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1869,7 +2525,7 @@ protected override void Up(MigrationBuilder migrationBuilder) RollupId = table.Column(type: "integer", nullable: true), Bond = table.Column(type: "bigint", nullable: false), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1908,7 +2564,7 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RollupId = table.Column(type: "integer", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), SenderId = table.Column(type: "integer", nullable: false), Counter = table.Column(type: "integer", nullable: false), @@ -1939,6 +2595,47 @@ protected override void Up(MigrationBuilder migrationBuilder) onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "UpdateConsensusKeyOps", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ActivationCycle = table.Column(type: "integer", nullable: false), + PublicKey = table.Column(type: "text", nullable: true), + PublicKeyHash = table.Column(type: "text", nullable: true), + Level = table.Column(type: "integer", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false), + SenderId = table.Column(type: "integer", nullable: false), + Counter = table.Column(type: "integer", nullable: false), + BakerFee = table.Column(type: "bigint", nullable: false), + StorageFee = table.Column(type: "bigint", nullable: true), + AllocationFee = table.Column(type: "bigint", nullable: true), + GasLimit = table.Column(type: "integer", nullable: false), + GasUsed = table.Column(type: "integer", nullable: false), + StorageLimit = table.Column(type: "integer", nullable: false), + StorageUsed = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "smallint", nullable: false), + Errors = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UpdateConsensusKeyOps", x => x.Id); + table.ForeignKey( + name: "FK_UpdateConsensusKeyOps_Accounts_SenderId", + column: x => x.SenderId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_UpdateConsensusKeyOps_Blocks_Level", + column: x => x.Level, + principalTable: "Blocks", + principalColumn: "Level", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "VdfRevelationOps", columns: table => new @@ -1947,11 +2644,13 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Cycle = table.Column(type: "integer", nullable: false), BakerId = table.Column(type: "integer", nullable: false), - Reward = table.Column(type: "bigint", nullable: false), + RewardLiquid = table.Column(type: "bigint", nullable: false), + RewardStakedOwn = table.Column(type: "bigint", nullable: false), + RewardStakedShared = table.Column(type: "bigint", nullable: false), Solution = table.Column(type: "bytea", nullable: true), Proof = table.Column(type: "bytea", nullable: true), Level = table.Column(type: "integer", nullable: false), - Timestamp = table.Column(type: "timestamp without time zone", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), OpHash = table.Column(type: "character(51)", fixedLength: true, maxLength: 51, nullable: false) }, constraints: table => @@ -1973,8 +2672,8 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.InsertData( table: "AppState", - columns: new[] { "Id", "AccountCounter", "AccountsCount", "ActivationOpsCount", "BallotOpsCount", "BigMapCounter", "BigMapKeyCounter", "BigMapUpdateCounter", "BlocksCount", "Chain", "ChainId", "CommitmentsCount", "ConstantsCount", "Cycle", "CyclesCount", "DelegationOpsCount", "DoubleBakingOpsCount", "DoubleEndorsingOpsCount", "DoublePreendorsingOpsCount", "EndorsementOpsCount", "EndorsingRewardOpsCount", "EventCounter", "EventsCount", "Hash", "IncreasePaidStorageOpsCount", "KnownHead", "LastSync", "Level", "ManagerCounter", "Metadata", "MigrationOpsCount", "NextProtocol", "NonceRevelationOpsCount", "OperationCounter", "OriginationOpsCount", "PreendorsementOpsCount", "ProposalOpsCount", "ProposalsCount", "Protocol", "ProtocolsCount", "QuoteBtc", "QuoteCny", "QuoteEth", "QuoteEur", "QuoteGbp", "QuoteJpy", "QuoteKrw", "QuoteLevel", "QuoteUsd", "RegisterConstantOpsCount", "RevealOpsCount", "RevelationPenaltyOpsCount", "ScriptCounter", "SetDepositsLimitOpsCount", "StorageCounter", "Timestamp", "TokenBalancesCount", "TokenTransfersCount", "TokensCount", "TransactionOpsCount", "TransferTicketOpsCount", "TxRollupCommitOpsCount", "TxRollupDispatchTicketsOpsCount", "TxRollupFinalizeCommitmentOpsCount", "TxRollupOriginationOpsCount", "TxRollupRejectionOpsCount", "TxRollupRemoveCommitmentOpsCount", "TxRollupReturnBondOpsCount", "TxRollupSubmitBatchOpsCount", "VdfRevelationOpsCount", "VotingEpoch", "VotingPeriod" }, - values: new object[] { -1, 0, 0, 0, 0, 0, 0, 0, 0, null, null, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, 0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), -1, 0, null, 0, "", 0, 0L, 0, 0, 0, 0, "", 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, 0.0, 0, 0, 0, 0, 0, 0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1 }); + columns: new[] { "Id", "AIActivated", "AIActivationCycle", "AIFinalUpvoteLevel", "AccountCounter", "AccountsCount", "ActivationOpsCount", "AutostakingOpsCount", "BallotOpsCount", "BigMapCounter", "BigMapKeyCounter", "BigMapUpdateCounter", "BlocksCount", "Chain", "ChainId", "CommitmentsCount", "ConstantsCount", "Cycle", "CyclesCount", "DelegationOpsCount", "DomainsLevel", "DomainsNameRegistry", "DoubleBakingOpsCount", "DoubleEndorsingOpsCount", "DoublePreendorsingOpsCount", "DrainDelegateOpsCount", "EndorsementOpsCount", "EndorsingRewardOpsCount", "EventCounter", "EventsCount", "Extras", "Hash", "InboxMessageCounter", "IncreasePaidStorageOpsCount", "KnownHead", "LastSync", "Level", "ManagerCounter", "MigrationOpsCount", "NextProtocol", "NonceRevelationOpsCount", "OperationCounter", "OriginationOpsCount", "PendingStakingParameters", "PreendorsementOpsCount", "ProposalOpsCount", "ProposalsCount", "Protocol", "ProtocolsCount", "QuoteBtc", "QuoteCny", "QuoteEth", "QuoteEur", "QuoteGbp", "QuoteJpy", "QuoteKrw", "QuoteLevel", "QuoteUsd", "RefutationGameCounter", "RegisterConstantOpsCount", "RevealOpsCount", "RevelationPenaltyOpsCount", "ScriptCounter", "SetDepositsLimitOpsCount", "SmartRollupAddMessagesOpsCount", "SmartRollupCementOpsCount", "SmartRollupCommitmentCounter", "SmartRollupExecuteOpsCount", "SmartRollupOriginateOpsCount", "SmartRollupPublishOpsCount", "SmartRollupRecoverBondOpsCount", "SmartRollupRefuteOpsCount", "StakingOpsCount", "StorageCounter", "TicketBalancesCount", "TicketTransfersCount", "TicketsCount", "Timestamp", "TokenBalancesCount", "TokenTransfersCount", "TokensCount", "TransactionOpsCount", "TransferTicketOpsCount", "TxRollupCommitOpsCount", "TxRollupDispatchTicketsOpsCount", "TxRollupFinalizeCommitmentOpsCount", "TxRollupOriginationOpsCount", "TxRollupRejectionOpsCount", "TxRollupRemoveCommitmentOpsCount", "TxRollupReturnBondOpsCount", "TxRollupSubmitBatchOpsCount", "UpdateConsensusKeyOpsCount", "VdfRevelationOpsCount", "VotingEpoch", "VotingPeriod" }, + values: new object[] { -1, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, null, 0, 0, -1, 0, 0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, null, "", 0, 0, 0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), -1, 0, 0, "", 0, 0L, 0, 0, 0, 0, 0, "", 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, 0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1 }); migrationBuilder.CreateIndex( name: "IX_Accounts_Address", @@ -1997,6 +2696,13 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "Accounts", column: "DelegateId"); + migrationBuilder.CreateIndex( + name: "IX_Accounts_Extras", + table: "Accounts", + column: "Extras") + .Annotation("Npgsql:IndexMethod", "gin") + .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); + migrationBuilder.CreateIndex( name: "IX_Accounts_FirstLevel", table: "Accounts", @@ -2052,6 +2758,12 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "Accounts", column: "TypeHash"); + migrationBuilder.CreateIndex( + name: "IX_Accounts_UnstakedBakerId", + table: "Accounts", + column: "UnstakedBakerId", + filter: "\"UnstakedBakerId\" IS NOT NULL"); + migrationBuilder.CreateIndex( name: "IX_Accounts_WeirdDelegateId", table: "Accounts", @@ -2074,26 +2786,24 @@ protected override void Up(MigrationBuilder migrationBuilder) column: "OpHash"); migrationBuilder.CreateIndex( - name: "IX_BakerCycles_BakerId", - table: "BakerCycles", + name: "IX_AutostakingOps_BakerId", + table: "AutostakingOps", column: "BakerId"); migrationBuilder.CreateIndex( - name: "IX_BakerCycles_Cycle", - table: "BakerCycles", - column: "Cycle"); + name: "IX_AutostakingOps_Level", + table: "AutostakingOps", + column: "Level"); migrationBuilder.CreateIndex( - name: "IX_BakerCycles_Cycle_BakerId", + name: "IX_BakerCycles_BakerId", table: "BakerCycles", - columns: new[] { "Cycle", "BakerId" }, - unique: true); + column: "BakerId"); migrationBuilder.CreateIndex( - name: "IX_BakerCycles_Id", + name: "IX_BakerCycles_Cycle_BakerId", table: "BakerCycles", - column: "Id", - unique: true); + columns: new[] { "Cycle", "BakerId" }); migrationBuilder.CreateIndex( name: "IX_BakingRights_Cycle", @@ -2330,11 +3040,6 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "DelegationOps", column: "SenderId"); - migrationBuilder.CreateIndex( - name: "IX_DelegatorCycles_Cycle", - table: "DelegatorCycles", - column: "Cycle"); - migrationBuilder.CreateIndex( name: "IX_DelegatorCycles_Cycle_BakerId", table: "DelegatorCycles", @@ -2343,14 +3048,43 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.CreateIndex( name: "IX_DelegatorCycles_Cycle_DelegatorId", table: "DelegatorCycles", - columns: new[] { "Cycle", "DelegatorId" }, - unique: true); + columns: new[] { "Cycle", "DelegatorId" }); migrationBuilder.CreateIndex( name: "IX_DelegatorCycles_DelegatorId", table: "DelegatorCycles", column: "DelegatorId"); + migrationBuilder.CreateIndex( + name: "IX_Domains_Address", + table: "Domains", + column: "Address"); + + migrationBuilder.CreateIndex( + name: "IX_Domains_FirstLevel", + table: "Domains", + column: "FirstLevel"); + + migrationBuilder.CreateIndex( + name: "IX_Domains_LastLevel", + table: "Domains", + column: "LastLevel"); + + migrationBuilder.CreateIndex( + name: "IX_Domains_Level", + table: "Domains", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_Domains_Name", + table: "Domains", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_Domains_Owner", + table: "Domains", + column: "Owner"); + migrationBuilder.CreateIndex( name: "IX_DoubleBakingOps_AccuserId", table: "DoubleBakingOps", @@ -2411,6 +3145,26 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "DoublePreendorsingOps", column: "OpHash"); + migrationBuilder.CreateIndex( + name: "IX_DrainDelegateOps_DelegateId", + table: "DrainDelegateOps", + column: "DelegateId"); + + migrationBuilder.CreateIndex( + name: "IX_DrainDelegateOps_Level", + table: "DrainDelegateOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_DrainDelegateOps_OpHash", + table: "DrainDelegateOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_DrainDelegateOps_TargetId", + table: "DrainDelegateOps", + column: "TargetId"); + migrationBuilder.CreateIndex( name: "IX_EndorsementOps_DelegateId", table: "EndorsementOps", @@ -2485,9 +3239,19 @@ protected override void Up(MigrationBuilder migrationBuilder) column: "TransactionId"); migrationBuilder.CreateIndex( - name: "IX_FreezerUpdates_Cycle", - table: "FreezerUpdates", - column: "Cycle"); + name: "IX_InboxMessages_Level", + table: "InboxMessages", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_InboxMessages_OperationId", + table: "InboxMessages", + column: "OperationId"); + + migrationBuilder.CreateIndex( + name: "IX_InboxMessages_Type_Id", + table: "InboxMessages", + columns: new[] { "Type", "Id" }); migrationBuilder.CreateIndex( name: "IX_IncreasePaidStorageOps_ContractId", @@ -2662,15 +3426,50 @@ protected override void Up(MigrationBuilder migrationBuilder) column: "Epoch"); migrationBuilder.CreateIndex( - name: "IX_Proposals_Hash", - table: "Proposals", - column: "Hash"); + name: "IX_Proposals_Hash", + table: "Proposals", + column: "Hash"); + + migrationBuilder.CreateIndex( + name: "IX_Quotes_Level", + table: "Quotes", + column: "Level", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_RefutationGames_FirstLevel", + table: "RefutationGames", + column: "FirstLevel"); + + migrationBuilder.CreateIndex( + name: "IX_RefutationGames_InitiatorCommitmentId", + table: "RefutationGames", + column: "InitiatorCommitmentId"); + + migrationBuilder.CreateIndex( + name: "IX_RefutationGames_InitiatorId", + table: "RefutationGames", + column: "InitiatorId"); + + migrationBuilder.CreateIndex( + name: "IX_RefutationGames_LastLevel", + table: "RefutationGames", + column: "LastLevel"); + + migrationBuilder.CreateIndex( + name: "IX_RefutationGames_OpponentCommitmentId", + table: "RefutationGames", + column: "OpponentCommitmentId"); + + migrationBuilder.CreateIndex( + name: "IX_RefutationGames_OpponentId", + table: "RefutationGames", + column: "OpponentId"); migrationBuilder.CreateIndex( - name: "IX_Quotes_Level", - table: "Quotes", - column: "Level", - unique: true); + name: "IX_RefutationGames_SmartRollupId", + table: "RefutationGames", + column: "SmartRollupId"); migrationBuilder.CreateIndex( name: "IX_RegisterConstantOps_Address", @@ -2747,10 +3546,226 @@ protected override void Up(MigrationBuilder migrationBuilder) column: "SenderId"); migrationBuilder.CreateIndex( - name: "IX_SnapshotBalances_Level", + name: "IX_SmartRollupAddMessagesOps_Level", + table: "SmartRollupAddMessagesOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupAddMessagesOps_OpHash", + table: "SmartRollupAddMessagesOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupAddMessagesOps_SenderId", + table: "SmartRollupAddMessagesOps", + column: "SenderId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupCementOps_Level", + table: "SmartRollupCementOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupCementOps_OpHash", + table: "SmartRollupCementOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupCementOps_SenderId", + table: "SmartRollupCementOps", + column: "SenderId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupCommitments_Hash", + table: "SmartRollupCommitments", + column: "Hash"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupCommitments_Hash_SmartRollupId", + table: "SmartRollupCommitments", + columns: new[] { "Hash", "SmartRollupId" }); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupCommitments_InboxLevel", + table: "SmartRollupCommitments", + column: "InboxLevel"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupCommitments_LastLevel", + table: "SmartRollupCommitments", + column: "LastLevel"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupCommitments_PredecessorId", + table: "SmartRollupCommitments", + column: "PredecessorId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupCommitments_SmartRollupId", + table: "SmartRollupCommitments", + column: "SmartRollupId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupExecuteOps_CommitmentId", + table: "SmartRollupExecuteOps", + column: "CommitmentId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupExecuteOps_Level", + table: "SmartRollupExecuteOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupExecuteOps_OpHash", + table: "SmartRollupExecuteOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupExecuteOps_SenderId", + table: "SmartRollupExecuteOps", + column: "SenderId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupExecuteOps_SmartRollupId", + table: "SmartRollupExecuteOps", + column: "SmartRollupId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupOriginateOps_Level", + table: "SmartRollupOriginateOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupOriginateOps_OpHash", + table: "SmartRollupOriginateOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupOriginateOps_SenderId", + table: "SmartRollupOriginateOps", + column: "SenderId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupOriginateOps_SmartRollupId", + table: "SmartRollupOriginateOps", + column: "SmartRollupId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupPublishOps_CommitmentId", + table: "SmartRollupPublishOps", + column: "CommitmentId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupPublishOps_Level", + table: "SmartRollupPublishOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupPublishOps_OpHash", + table: "SmartRollupPublishOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupPublishOps_SenderId", + table: "SmartRollupPublishOps", + column: "SenderId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupPublishOps_SmartRollupId", + table: "SmartRollupPublishOps", + column: "SmartRollupId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupPublishOps_SmartRollupId_BondStatus_SenderId", + table: "SmartRollupPublishOps", + columns: new[] { "SmartRollupId", "BondStatus", "SenderId" }, + filter: "\"BondStatus\" IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRecoverBondOps_Level", + table: "SmartRollupRecoverBondOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRecoverBondOps_OpHash", + table: "SmartRollupRecoverBondOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRecoverBondOps_SenderId", + table: "SmartRollupRecoverBondOps", + column: "SenderId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRecoverBondOps_SmartRollupId", + table: "SmartRollupRecoverBondOps", + column: "SmartRollupId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRecoverBondOps_StakerId", + table: "SmartRollupRecoverBondOps", + column: "StakerId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRefuteOps_GameId", + table: "SmartRollupRefuteOps", + column: "GameId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRefuteOps_Level", + table: "SmartRollupRefuteOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRefuteOps_OpHash", + table: "SmartRollupRefuteOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRefuteOps_SenderId", + table: "SmartRollupRefuteOps", + column: "SenderId"); + + migrationBuilder.CreateIndex( + name: "IX_SmartRollupRefuteOps_SmartRollupId", + table: "SmartRollupRefuteOps", + column: "SmartRollupId"); + + migrationBuilder.CreateIndex( + name: "IX_SnapshotBalance_Level_Partial", table: "SnapshotBalances", column: "Level", - filter: "\"DelegateId\" IS NULL"); + filter: "\"AccountId\" = \"BakerId\""); + + migrationBuilder.CreateIndex( + name: "IX_SnapshotBalances_Level", + table: "SnapshotBalances", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_SnapshotBalances_Level_AccountId_BakerId", + table: "SnapshotBalances", + columns: new[] { "Level", "AccountId", "BakerId" }); + + migrationBuilder.CreateIndex( + name: "IX_StakingOps_BakerId", + table: "StakingOps", + column: "BakerId"); + + migrationBuilder.CreateIndex( + name: "IX_StakingOps_Level", + table: "StakingOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_StakingOps_OpHash", + table: "StakingOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_StakingOps_SenderId", + table: "StakingOps", + column: "SenderId"); migrationBuilder.CreateIndex( name: "IX_Statistics_Cycle", @@ -2794,6 +3809,145 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "Storages", column: "Level"); + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId", + table: "TicketBalances", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId_TicketerId", + table: "TicketBalances", + columns: new[] { "AccountId", "TicketerId" }); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId_TicketId", + table: "TicketBalances", + columns: new[] { "AccountId", "TicketId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_FirstLevel", + table: "TicketBalances", + column: "FirstLevel"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_Id", + table: "TicketBalances", + column: "Id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_LastLevel", + table: "TicketBalances", + column: "LastLevel"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_TicketerId", + table: "TicketBalances", + column: "TicketerId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_TicketId", + table: "TicketBalances", + column: "TicketId"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_ContentHash", + table: "Tickets", + column: "ContentHash"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_FirstLevel", + table: "Tickets", + column: "FirstLevel"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_FirstMinterId", + table: "Tickets", + column: "FirstMinterId"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_Id", + table: "Tickets", + column: "Id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_JsonContent", + table: "Tickets", + column: "JsonContent") + .Annotation("Npgsql:IndexMethod", "gin") + .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_LastLevel", + table: "Tickets", + column: "LastLevel"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_TicketerId", + table: "Tickets", + column: "TicketerId"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_TicketerId_TypeHash_ContentHash", + table: "Tickets", + columns: new[] { "TicketerId", "TypeHash", "ContentHash" }); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_TypeHash", + table: "Tickets", + column: "TypeHash"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_FromId", + table: "TicketTransfers", + column: "FromId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_Id", + table: "TicketTransfers", + column: "Id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_Level", + table: "TicketTransfers", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_SmartRollupExecuteId", + table: "TicketTransfers", + column: "SmartRollupExecuteId", + filter: "\"SmartRollupExecuteId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TicketerId", + table: "TicketTransfers", + column: "TicketerId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TicketId", + table: "TicketTransfers", + column: "TicketId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_ToId", + table: "TicketTransfers", + column: "ToId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TransactionId", + table: "TicketTransfers", + column: "TransactionId", + filter: "\"TransactionId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TransferTicketId", + table: "TicketTransfers", + column: "TransferTicketId", + filter: "\"TransferTicketId\" is not null"); + migrationBuilder.CreateIndex( name: "IX_TokenBalances_AccountId", table: "TokenBalances", @@ -3176,6 +4330,21 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "TxRollupSubmitBatchOps", column: "SenderId"); + migrationBuilder.CreateIndex( + name: "IX_UpdateConsensusKeyOps_Level", + table: "UpdateConsensusKeyOps", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_UpdateConsensusKeyOps_OpHash", + table: "UpdateConsensusKeyOps", + column: "OpHash"); + + migrationBuilder.CreateIndex( + name: "IX_UpdateConsensusKeyOps_SenderId", + table: "UpdateConsensusKeyOps", + column: "SenderId"); + migrationBuilder.CreateIndex( name: "IX_VdfRevelationOps_BakerId", table: "VdfRevelationOps", @@ -3225,11 +4394,11 @@ protected override void Up(MigrationBuilder migrationBuilder) unique: true); migrationBuilder.AddForeignKey( - name: "FK_ActivationOps_Accounts_AccountId", - table: "ActivationOps", - column: "AccountId", - principalTable: "Accounts", - principalColumn: "Id", + name: "FK_Accounts_Blocks_FirstLevel", + table: "Accounts", + column: "FirstLevel", + principalTable: "Blocks", + principalColumn: "Level", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( @@ -3240,14 +4409,6 @@ protected override void Up(MigrationBuilder migrationBuilder) principalColumn: "Level", onDelete: ReferentialAction.Cascade); - migrationBuilder.AddForeignKey( - name: "FK_BallotOps_Accounts_SenderId", - table: "BallotOps", - column: "SenderId", - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - migrationBuilder.AddForeignKey( name: "FK_BallotOps_Blocks_Level", table: "BallotOps", @@ -3256,23 +4417,15 @@ protected override void Up(MigrationBuilder migrationBuilder) principalColumn: "Level", onDelete: ReferentialAction.Cascade); - migrationBuilder.AddForeignKey( - name: "FK_Blocks_Accounts_ProposerId", - table: "Blocks", - column: "ProposerId", - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - migrationBuilder.AddForeignKey( name: "FK_Blocks_NonceRevelationOps_RevelationId", table: "Blocks", column: "RevelationId", principalTable: "NonceRevelationOps", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); } + /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( @@ -3289,6 +4442,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "AppState"); + migrationBuilder.DropTable( + name: "AutostakingOps"); + migrationBuilder.DropTable( name: "BakerCycles"); @@ -3319,6 +4475,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "DelegatorCycles"); + migrationBuilder.DropTable( + name: "Domains"); + migrationBuilder.DropTable( name: "DoubleBakingOps"); @@ -3328,6 +4487,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "DoublePreendorsingOps"); + migrationBuilder.DropTable( + name: "DrainDelegateOps"); + migrationBuilder.DropTable( name: "EndorsementOps"); @@ -3338,7 +4500,7 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "Events"); migrationBuilder.DropTable( - name: "FreezerUpdates"); + name: "InboxMessages"); migrationBuilder.DropTable( name: "IncreasePaidStorageOps"); @@ -3358,6 +4520,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "Quotes"); + migrationBuilder.DropTable( + name: "RefutationGames"); + migrationBuilder.DropTable( name: "RegisterConstantOps"); @@ -3370,12 +4535,48 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "SetDepositsLimitOps"); + migrationBuilder.DropTable( + name: "SmartRollupAddMessagesOps"); + + migrationBuilder.DropTable( + name: "SmartRollupCementOps"); + + migrationBuilder.DropTable( + name: "SmartRollupCommitments"); + + migrationBuilder.DropTable( + name: "SmartRollupExecuteOps"); + + migrationBuilder.DropTable( + name: "SmartRollupOriginateOps"); + + migrationBuilder.DropTable( + name: "SmartRollupPublishOps"); + + migrationBuilder.DropTable( + name: "SmartRollupRecoverBondOps"); + + migrationBuilder.DropTable( + name: "SmartRollupRefuteOps"); + migrationBuilder.DropTable( name: "SnapshotBalances"); + migrationBuilder.DropTable( + name: "StakingOps"); + migrationBuilder.DropTable( name: "Statistics"); + migrationBuilder.DropTable( + name: "TicketBalances"); + + migrationBuilder.DropTable( + name: "Tickets"); + + migrationBuilder.DropTable( + name: "TicketTransfers"); + migrationBuilder.DropTable( name: "TokenBalances"); @@ -3415,6 +4616,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "TxRollupSubmitBatchOps"); + migrationBuilder.DropTable( + name: "UpdateConsensusKeyOps"); + migrationBuilder.DropTable( name: "VdfRevelationOps"); diff --git a/Tzkt.Data/Migrations/20230809172912_TokensSupply.Designer.cs b/Tzkt.Data/Migrations/20240130133108_Triggers.Designer.cs similarity index 89% rename from Tzkt.Data/Migrations/20230809172912_TokensSupply.Designer.cs rename to Tzkt.Data/Migrations/20240130133108_Triggers.Designer.cs index e71d34de6..62a880b70 100644 --- a/Tzkt.Data/Migrations/20230809172912_TokensSupply.Designer.cs +++ b/Tzkt.Data/Migrations/20240130133108_Triggers.Designer.cs @@ -13,8 +13,8 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230809172912_TokensSupply")] - partial class TokensSupply + [Migration("20240130133108_Triggers")] + partial class Triggers { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -37,6 +37,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActiveRefutationGamesCount") .HasColumnType("integer"); + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + b.Property("ActiveTokensCount") .HasColumnType("integer"); @@ -78,6 +81,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("LastLevel") .HasColumnType("integer"); + b.Property("LostBalance") + .HasColumnType("bigint"); + b.Property("Metadata") .HasColumnType("jsonb"); @@ -129,6 +135,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Staked") .HasColumnType("boolean"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + b.Property("TokenBalancesCount") .HasColumnType("integer"); @@ -250,6 +262,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AIActivated") + .HasColumnType("boolean"); + + b.Property("AIActivationCycle") + .HasColumnType("integer"); + + b.Property("AIFinalUpvoteLevel") + .HasColumnType("integer"); + b.Property("AccountCounter") .HasColumnType("integer"); @@ -259,6 +280,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActivationOpsCount") .HasColumnType("integer"); + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + b.Property("BallotOpsCount") .HasColumnType("integer"); @@ -364,6 +388,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("OriginationOpsCount") .HasColumnType("integer"); + b.Property("PendingStakingParameters") + .HasColumnType("integer"); + b.Property("PreendorsementOpsCount") .HasColumnType("integer"); @@ -448,9 +475,21 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SmartRollupRefuteOpsCount") .HasColumnType("integer"); + b.Property("StakingOpsCount") + .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"); @@ -513,9 +552,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) new { Id = -1, + AIActivated = false, + AIActivationCycle = 0, + AIFinalUpvoteLevel = 0, AccountCounter = 0, AccountsCount = 0, ActivationOpsCount = 0, + AutostakingOpsCount = 0, BallotOpsCount = 0, BigMapCounter = 0, BigMapKeyCounter = 0, @@ -547,6 +590,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NonceRevelationOpsCount = 0, OperationCounter = 0L, OriginationOpsCount = 0, + PendingStakingParameters = 0, PreendorsementOpsCount = 0, ProposalOpsCount = 0, ProposalsCount = 0, @@ -575,7 +619,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) SmartRollupPublishOpsCount = 0, SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, + StakingOpsCount = 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, @@ -597,6 +645,38 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) }); }); + 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("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("AutostakingOps"); + }); + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => { b.Property("Id") @@ -605,16 +685,22 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("ActiveStake") - .HasColumnType("bigint"); - b.Property("BakerId") .HasColumnType("integer"); + b.Property("BakingPower") + .HasColumnType("bigint"); + b.Property("BlockFees") .HasColumnType("bigint"); - b.Property("BlockRewards") + b.Property("BlockRewardsLiquid") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedShared") .HasColumnType("bigint"); b.Property("Blocks") @@ -623,31 +709,61 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Cycle") .HasColumnType("integer"); - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - b.Property("DelegatorsCount") .HasColumnType("integer"); - b.Property("DoubleBakingLosses") + 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("DoubleEndorsingLosses") + 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("DoublePreendorsingLosses") + 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("EndorsementRewards") + b.Property("EndorsementRewardsLiquid") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedShared") .HasColumnType("bigint"); b.Property("Endorsements") @@ -659,6 +775,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ExpectedEndorsements") .HasColumnType("double precision"); + b.Property("ExternalDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + b.Property("FutureBlockRewards") .HasColumnType("bigint"); @@ -686,29 +808,44 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MissedEndorsements") .HasColumnType("integer"); - b.Property("RevelationLosses") + b.Property("NonceRevelationLosses") .HasColumnType("bigint"); - b.Property("RevelationRewards") + b.Property("NonceRevelationRewardsLiquid") .HasColumnType("bigint"); - b.Property("SelectedStake") + b.Property("NonceRevelationRewardsStakedOwn") .HasColumnType("bigint"); - b.Property("StakingBalance") + b.Property("NonceRevelationRewardsStakedShared") .HasColumnType("bigint"); - b.HasKey("Id"); + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); - b.HasIndex("BakerId"); + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); - b.HasIndex("Cycle"); + b.Property("StakersCount") + .HasColumnType("integer"); - b.HasIndex("Id") - .IsUnique(); + b.Property("TotalBakingPower") + .HasColumnType("bigint"); - b.HasIndex("Cycle", "BakerId") - .IsUnique(); + b.Property("VdfRevelationRewardsLiquid") + .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"); }); @@ -1000,10 +1137,22 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AIToggle") + .HasColumnType("boolean"); + + b.Property("AIToggleEma") + .HasColumnType("integer"); + b.Property("BlockRound") .HasColumnType("integer"); - b.Property("Bonus") + b.Property("BonusLiquid") + .HasColumnType("bigint"); + + b.Property("BonusStakedOwn") + .HasColumnType("bigint"); + + b.Property("BonusStakedShared") .HasColumnType("bigint"); b.Property("Cycle") @@ -1060,7 +1209,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RevelationId") .HasColumnType("bigint"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("SoftwareId") @@ -1195,27 +1350,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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("LBSubsidy") + .HasColumnType("bigint"); + 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("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - b.Property("SnapshotIndex") .HasColumnType("integer"); @@ -1225,13 +1392,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TotalBakers") .HasColumnType("integer"); - b.Property("TotalDelegated") + b.Property("TotalBakingPower") .HasColumnType("bigint"); - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") + b.Property("VdfRevelationReward") .HasColumnType("bigint"); b.HasKey("Id"); @@ -1318,6 +1482,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Timestamp") .HasColumnType("timestamp with time zone"); + b.Property("UnstakedBalance") + .HasColumnType("bigint"); + + b.Property("UnstakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("UnstakedRewards") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("DelegateId"); @@ -1349,25 +1522,25 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BakerId") .HasColumnType("integer"); - b.Property("Balance") - .HasColumnType("bigint"); - b.Property("Cycle") .HasColumnType("integer"); + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + b.Property("DelegatorId") .HasColumnType("integer"); - b.HasKey("Id"); + b.Property("StakedBalance") + .HasColumnType("bigint"); - b.HasIndex("Cycle"); + b.HasKey("Id"); b.HasIndex("DelegatorId"); b.HasIndex("Cycle", "BakerId"); - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); + b.HasIndex("Cycle", "DelegatorId"); b.ToTable("DelegatorCycles"); }); @@ -1438,24 +1611,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1486,24 +1674,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1534,24 +1737,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1676,7 +1894,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Level") .HasColumnType("integer"); - b.Property("Received") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("Timestamp") @@ -1691,30 +1915,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("EndorsingRewardOps"); }); - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => { b.Property("Id") @@ -1908,7 +2108,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RevealedLevel") .HasColumnType("integer"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("SenderId") @@ -2210,6 +2416,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BallotQuorumMin") .HasColumnType("integer"); + b.Property("BaseIssuedPerMinute") + .HasColumnType("bigint"); + + b.Property("BlockBonusWeight") + .HasColumnType("integer"); + b.Property("BlockDeposit") .HasColumnType("bigint"); @@ -2219,6 +2431,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BlockReward1") .HasColumnType("bigint"); + b.Property("BlockRewardWeight") + .HasColumnType("integer"); + b.Property("BlocksPerCommitment") .HasColumnType("integer"); @@ -2243,13 +2458,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Dictator") .HasColumnType("text"); - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") + b.Property("DoubleBakingSlashedPercentage") .HasColumnType("integer"); - b.Property("DoubleEndorsingPunishmentNumerator") + b.Property("DoubleEndorsingSlashedPercentage") .HasColumnType("integer"); b.Property("EndorsementDeposit") @@ -2264,6 +2476,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("EndorsersPerBlock") .HasColumnType("integer"); + b.Property("EndorsingRewardWeight") + .HasColumnType("integer"); + b.Property("Extras") .HasColumnType("jsonb"); @@ -2276,9 +2491,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("FirstLevel") .HasColumnType("integer"); - b.Property("FrozenDepositsPercentage") - .HasColumnType("integer"); - b.Property("HardBlockGasLimit") .HasColumnType("integer"); @@ -2294,7 +2506,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("character(51)") .IsFixedLength(); - b.Property("LBSubsidy") + b.Property("LBSubsidyWeight") .HasColumnType("integer"); b.Property("LBToggleThreshold") @@ -2306,9 +2518,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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"); @@ -2318,9 +2536,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MinParticipationNumerator") .HasColumnType("integer"); + b.Property("MinimalFrozenStake") + .HasColumnType("bigint"); + + b.Property("MinimalStake") + .HasColumnType("bigint"); + b.Property("NoRewardCycles") .HasColumnType("integer"); + b.Property("NonceRevelationRewardWeight") + .HasColumnType("integer"); + b.Property("OriginationSize") .HasColumnType("integer"); @@ -2333,9 +2560,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RampUpCycles") .HasColumnType("integer"); - b.Property("RevelationReward") - .HasColumnType("bigint"); - b.Property("SmartRollupChallengeWindow") .HasColumnType("integer"); @@ -2351,16 +2575,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SmartRollupTimeoutPeriod") .HasColumnType("integer"); - b.Property("TimeBetweenBlocks") + b.Property("StakePowerMultiplier") .HasColumnType("integer"); - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); - b.Property("TxRollupOriginationSize") + b.Property("VdfRevelationRewardWeight") .HasColumnType("integer"); b.HasKey("Id"); @@ -3024,6 +3245,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3083,9 +3310,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("character(51)") .IsFixedLength(); - b.Property("OriginationProof") - .HasColumnType("bytea"); - b.Property("ParameterType") .HasColumnType("bytea"); @@ -3389,28 +3613,44 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccountId") .HasColumnType("integer"); - b.Property("Balance") - .HasColumnType("bigint"); + b.Property("BakerId") + .HasColumnType("integer"); - b.Property("DelegateId") + b.Property("DelegatorsCount") .HasColumnType("integer"); - b.Property("DelegatedBalance") + b.Property("ExternalDelegatedBalance") .HasColumnType("bigint"); - b.Property("DelegatorsCount") - .HasColumnType("integer"); + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("IssuedPseudotokens") + .HasColumnType("bigint"); b.Property("Level") .HasColumnType("integer"); - b.Property("StakingBalance") + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("OwnStakedBalance") .HasColumnType("bigint"); + b.Property("StakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("StakersCount") + .HasColumnType("integer"); + b.HasKey("Id"); - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); + b.HasIndex("Level"); + + b.HasIndex("Level", "AccountId", "BakerId"); + + b.HasIndex(new[] { "Level" }, "IX_SnapshotBalance_Level_Partial") + .HasFilter("\"AccountId\" = \"BakerId\""); b.ToTable("SnapshotBalances"); }); @@ -3426,24 +3666,120 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BlocksCount") .HasColumnType("integer"); - b.Property("Extras") - .HasColumnType("jsonb"); + 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("ActivationCycle") + .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("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("FirstCycleUnstaked") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastCycleUnstaked") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevStakedBalance") + .HasColumnType("bigint"); + + b.Property("Pseudotokens") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); - b.Property("FirstLevel") + b.Property("StorageLimit") .HasColumnType("integer"); - b.Property("LastLevel") + b.Property("StorageUsed") .HasColumnType("integer"); - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(); + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); b.HasKey("Id"); - b.ToTable("Software"); + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("StakingOps"); }); modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => @@ -3484,6 +3820,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TotalFrozen") .HasColumnType("bigint"); + b.Property("TotalLost") + .HasColumnType("bigint"); + b.Property("TotalRollupBonds") .HasColumnType("bigint"); @@ -3553,6 +3892,205 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContentHash"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonContent"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonContent"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonContent"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("TicketerId"); + + 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") + .IsRequired() + .HasColumnType("text"); + + 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("AccountId"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Id") + .IsUnique(); + + 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") + .IsRequired() + .HasColumnType("text"); + + 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("Id") + .IsUnique(); + + b.HasIndex("Level"); + + 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.ToTable("TicketTransfers"); + }); + modelBuilder.Entity("Tzkt.Data.Models.Token", b => { b.Property("Id") @@ -3870,6 +4408,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3970,9 +4511,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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"); @@ -4662,7 +5209,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Proof") .HasColumnType("bytea"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("Solution") @@ -4836,6 +5389,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Tags") .HasColumnType("integer"); + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("TokensCount") .HasColumnType("integer"); @@ -4941,6 +5497,24 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SetDepositsLimitsCount") .HasColumnType("integer"); + b.Property("StakedBalance") + .HasColumnType("bigint"); + + b.Property("StakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("StakingOpsCount") + .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); }); @@ -4951,6 +5525,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActivationLevel") .HasColumnType("integer"); + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + b.Property("BallotsCount") .HasColumnType("integer"); @@ -4975,18 +5552,30 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("DoublePreendorsingCount") .HasColumnType("integer"); + b.Property("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + b.Property("EndorsementsCount") .HasColumnType("integer"); b.Property("EndorsingRewardsCount") .HasColumnType("integer"); - b.Property("FrozenDeposit") + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalUnstakedBalance") .HasColumnType("bigint"); b.Property("FrozenDepositLimit") .HasColumnType("bigint"); + b.Property("IssuedPseudotokens") + .HasColumnType("bigint"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + b.Property("NonceRevelationsCount") .HasColumnType("integer"); @@ -5002,9 +5591,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SoftwareId") .HasColumnType("integer"); + b.Property("StakersCount") + .HasColumnType("integer"); + b.Property("StakingBalance") .HasColumnType("bigint"); + b.Property("TotalStakedBalance") + .HasColumnType("bigint"); + b.Property("VdfRevelationsCount") .HasColumnType("integer"); @@ -5670,6 +6265,26 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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") @@ -6012,6 +6627,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Navigation("SmartRollupRefuteOps"); + b.Navigation("StakingOps"); + b.Navigation("Transactions"); b.Navigation("TransferTicketOps"); diff --git a/Tzkt.Data/Migrations/20220911122311_Triggers.cs b/Tzkt.Data/Migrations/20240130133108_Triggers.cs similarity index 66% rename from Tzkt.Data/Migrations/20220911122311_Triggers.cs rename to Tzkt.Data/Migrations/20240130133108_Triggers.cs index 7374bd7a4..31526a1a9 100644 --- a/Tzkt.Data/Migrations/20220911122311_Triggers.cs +++ b/Tzkt.Data/Migrations/20240130133108_Triggers.cs @@ -2,6 +2,7 @@ namespace Tzkt.Data.Migrations { + /// public partial class Triggers : Migration { #region static @@ -30,6 +31,7 @@ public static void RemoveNotificationTrigger(MigrationBuilder builder, string na } #endregion + /// protected override void Up(MigrationBuilder migrationBuilder) { AddNotificationTrigger(migrationBuilder, @@ -39,65 +41,73 @@ protected override void Up(MigrationBuilder migrationBuilder) @"NEW.""Level"" || ':' || NEW.""Hash"""); AddNotificationTrigger(migrationBuilder, - "state_metadata_changed", + name: "sync_state_changed", + table: "AppState", + column: "LastSync", + payload: @"NEW.""KnownHead"" || ':' || NEW.""LastSync"""); // ISO 8601 (1997-12-17 07:37:16) + + AddNotificationTrigger(migrationBuilder, + "state_extras_changed", "AppState", - "Metadata", - @"NEW.""Id"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); + "Extras", + @"NEW.""Id"" || ':' || COALESCE(NEW.""Extras""::text, '')"); + + AddNotificationTrigger(migrationBuilder, + "account_extras_changed", + "Accounts", + "Extras", + @"NEW.""Address"" || ':' || COALESCE(NEW.""Extras""::text, '')"); AddNotificationTrigger(migrationBuilder, "account_metadata_changed", "Accounts", "Metadata", - @"NEW.""Address"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); + @"NEW.""Address"" || ':'"); AddNotificationTrigger(migrationBuilder, - "proposal_metadata_changed", + "proposal_extras_changed", "Proposals", - "Metadata", - @"NEW.""Hash"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); + "Extras", + @"NEW.""Hash"" || ':' || COALESCE(NEW.""Extras""::text, '')"); AddNotificationTrigger(migrationBuilder, - "protocol_metadata_changed", + "protocol_extras_changed", "Protocols", - "Metadata", - @"NEW.""Hash"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); + "Extras", + @"NEW.""Hash"" || ':' || COALESCE(NEW.""Extras""::text, '')"); AddNotificationTrigger(migrationBuilder, - "software_metadata_changed", + "software_extras_changed", "Software", - "Metadata", - @"NEW.""ShortHash"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); + "Extras", + @"NEW.""ShortHash"" || ':' || COALESCE(NEW.""Extras""::text, '')"); AddNotificationTrigger(migrationBuilder, - "block_metadata_changed", + "block_extras_changed", "Blocks", - "Metadata", - @"NEW.""Level"" || ':' || COALESCE(NEW.""Metadata""::text, '')"); + "Extras", + @"NEW.""Level"" || ':' || COALESCE(NEW.""Extras""::text, '')"); AddNotificationTrigger(migrationBuilder, - "constant_metadata_changed", + "constant_extras_changed", "RegisterConstantOps", - "Metadata", - @"COALESCE(NEW.""Address"", '') || ':' || COALESCE(NEW.""Metadata""::text, '')"); - - AddNotificationTrigger(migrationBuilder, - name: "sync_state_changed", - table: "AppState", - column: "LastSync", - payload: @"NEW.""KnownHead"" || ':' || NEW.""LastSync"""); // ISO 8601 (1997-12-17 07:37:16) + "Extras", + @"COALESCE(NEW.""Address"", '') || ':' || COALESCE(NEW.""Extras""::text, '')"); } + /// protected override void Down(MigrationBuilder migrationBuilder) { RemoveNotificationTrigger(migrationBuilder, "state_hash_changed", "AppState"); - RemoveNotificationTrigger(migrationBuilder, "state_metadata_changed", "AppState"); - RemoveNotificationTrigger(migrationBuilder, "account_metadata_changed", "Accounts"); - RemoveNotificationTrigger(migrationBuilder, "proposal_metadata_changed", "Proposals"); - RemoveNotificationTrigger(migrationBuilder, "protocol_metadata_changed", "Protocols"); - RemoveNotificationTrigger(migrationBuilder, "software_metadata_changed", "Software"); - RemoveNotificationTrigger(migrationBuilder, "block_metadata_changed", "Blocks"); - RemoveNotificationTrigger(migrationBuilder, "constant_metadata_changed", "RegisterConstantOps"); RemoveNotificationTrigger(migrationBuilder, "sync_state_changed", "AppState"); + RemoveNotificationTrigger(migrationBuilder, "state_extras_changed", "AppState"); + RemoveNotificationTrigger(migrationBuilder, "account_extras_changed", "Accounts"); + RemoveNotificationTrigger(migrationBuilder, "account_metadata_changed", "Accounts"); + RemoveNotificationTrigger(migrationBuilder, "proposal_extras_changed", "Proposals"); + RemoveNotificationTrigger(migrationBuilder, "protocol_extras_changed", "Protocols"); + RemoveNotificationTrigger(migrationBuilder, "software_extras_changed", "Software"); + RemoveNotificationTrigger(migrationBuilder, "block_extras_changed", "Blocks"); + RemoveNotificationTrigger(migrationBuilder, "constant_extras_changed", "RegisterConstantOps"); } } -} +} \ No newline at end of file diff --git a/Tzkt.Data/Migrations/20230720080720_TokenValues.Designer.cs b/Tzkt.Data/Migrations/20240201122141_TokensValue.Designer.cs similarity index 89% rename from Tzkt.Data/Migrations/20230720080720_TokenValues.Designer.cs rename to Tzkt.Data/Migrations/20240201122141_TokensValue.Designer.cs index c21bd5806..9a562bb6b 100644 --- a/Tzkt.Data/Migrations/20230720080720_TokenValues.Designer.cs +++ b/Tzkt.Data/Migrations/20240201122141_TokensValue.Designer.cs @@ -13,8 +13,8 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230720080720_TokenValues")] - partial class TokenValues + [Migration("20240201122141_TokensValue")] + partial class TokensValue { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -37,6 +37,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActiveRefutationGamesCount") .HasColumnType("integer"); + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + b.Property("ActiveTokensCount") .HasColumnType("integer"); @@ -78,6 +81,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("LastLevel") .HasColumnType("integer"); + b.Property("LostBalance") + .HasColumnType("bigint"); + b.Property("Metadata") .HasColumnType("jsonb"); @@ -129,6 +135,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Staked") .HasColumnType("boolean"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + b.Property("TokenBalancesCount") .HasColumnType("integer"); @@ -250,6 +262,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AIActivated") + .HasColumnType("boolean"); + + b.Property("AIActivationCycle") + .HasColumnType("integer"); + + b.Property("AIFinalUpvoteLevel") + .HasColumnType("integer"); + b.Property("AccountCounter") .HasColumnType("integer"); @@ -259,6 +280,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActivationOpsCount") .HasColumnType("integer"); + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + b.Property("BallotOpsCount") .HasColumnType("integer"); @@ -364,6 +388,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("OriginationOpsCount") .HasColumnType("integer"); + b.Property("PendingStakingParameters") + .HasColumnType("integer"); + b.Property("PreendorsementOpsCount") .HasColumnType("integer"); @@ -448,9 +475,21 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SmartRollupRefuteOpsCount") .HasColumnType("integer"); + b.Property("StakingOpsCount") + .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"); @@ -513,9 +552,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) new { Id = -1, + AIActivated = false, + AIActivationCycle = 0, + AIFinalUpvoteLevel = 0, AccountCounter = 0, AccountsCount = 0, ActivationOpsCount = 0, + AutostakingOpsCount = 0, BallotOpsCount = 0, BigMapCounter = 0, BigMapKeyCounter = 0, @@ -547,6 +590,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NonceRevelationOpsCount = 0, OperationCounter = 0L, OriginationOpsCount = 0, + PendingStakingParameters = 0, PreendorsementOpsCount = 0, ProposalOpsCount = 0, ProposalsCount = 0, @@ -575,7 +619,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) SmartRollupPublishOpsCount = 0, SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, + StakingOpsCount = 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, @@ -597,6 +645,38 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) }); }); + 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("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("AutostakingOps"); + }); + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => { b.Property("Id") @@ -605,16 +685,22 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("ActiveStake") - .HasColumnType("bigint"); - b.Property("BakerId") .HasColumnType("integer"); + b.Property("BakingPower") + .HasColumnType("bigint"); + b.Property("BlockFees") .HasColumnType("bigint"); - b.Property("BlockRewards") + b.Property("BlockRewardsLiquid") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedShared") .HasColumnType("bigint"); b.Property("Blocks") @@ -623,31 +709,61 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Cycle") .HasColumnType("integer"); - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - b.Property("DelegatorsCount") .HasColumnType("integer"); - b.Property("DoubleBakingLosses") + 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("DoubleEndorsingLosses") + 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("DoublePreendorsingLosses") + 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("EndorsementRewards") + b.Property("EndorsementRewardsLiquid") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedShared") .HasColumnType("bigint"); b.Property("Endorsements") @@ -659,6 +775,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ExpectedEndorsements") .HasColumnType("double precision"); + b.Property("ExternalDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + b.Property("FutureBlockRewards") .HasColumnType("bigint"); @@ -686,29 +808,44 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MissedEndorsements") .HasColumnType("integer"); - b.Property("RevelationLosses") + b.Property("NonceRevelationLosses") .HasColumnType("bigint"); - b.Property("RevelationRewards") + b.Property("NonceRevelationRewardsLiquid") .HasColumnType("bigint"); - b.Property("SelectedStake") + b.Property("NonceRevelationRewardsStakedOwn") .HasColumnType("bigint"); - b.Property("StakingBalance") + b.Property("NonceRevelationRewardsStakedShared") .HasColumnType("bigint"); - b.HasKey("Id"); + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); - b.HasIndex("BakerId"); + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); - b.HasIndex("Cycle"); + b.Property("StakersCount") + .HasColumnType("integer"); - b.HasIndex("Id") - .IsUnique(); + b.Property("TotalBakingPower") + .HasColumnType("bigint"); - b.HasIndex("Cycle", "BakerId") - .IsUnique(); + b.Property("VdfRevelationRewardsLiquid") + .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"); }); @@ -1000,10 +1137,22 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AIToggle") + .HasColumnType("boolean"); + + b.Property("AIToggleEma") + .HasColumnType("integer"); + b.Property("BlockRound") .HasColumnType("integer"); - b.Property("Bonus") + b.Property("BonusLiquid") + .HasColumnType("bigint"); + + b.Property("BonusStakedOwn") + .HasColumnType("bigint"); + + b.Property("BonusStakedShared") .HasColumnType("bigint"); b.Property("Cycle") @@ -1060,7 +1209,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RevelationId") .HasColumnType("bigint"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("SoftwareId") @@ -1195,27 +1350,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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("LBSubsidy") + .HasColumnType("bigint"); + 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("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - b.Property("SnapshotIndex") .HasColumnType("integer"); @@ -1225,13 +1392,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TotalBakers") .HasColumnType("integer"); - b.Property("TotalDelegated") + b.Property("TotalBakingPower") .HasColumnType("bigint"); - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") + b.Property("VdfRevelationReward") .HasColumnType("bigint"); b.HasKey("Id"); @@ -1318,6 +1482,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Timestamp") .HasColumnType("timestamp with time zone"); + b.Property("UnstakedBalance") + .HasColumnType("bigint"); + + b.Property("UnstakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("UnstakedRewards") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("DelegateId"); @@ -1349,25 +1522,25 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BakerId") .HasColumnType("integer"); - b.Property("Balance") - .HasColumnType("bigint"); - b.Property("Cycle") .HasColumnType("integer"); + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + b.Property("DelegatorId") .HasColumnType("integer"); - b.HasKey("Id"); + b.Property("StakedBalance") + .HasColumnType("bigint"); - b.HasIndex("Cycle"); + b.HasKey("Id"); b.HasIndex("DelegatorId"); b.HasIndex("Cycle", "BakerId"); - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); + b.HasIndex("Cycle", "DelegatorId"); b.ToTable("DelegatorCycles"); }); @@ -1438,24 +1611,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1486,24 +1674,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1534,24 +1737,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1676,7 +1894,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Level") .HasColumnType("integer"); - b.Property("Received") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("Timestamp") @@ -1691,30 +1915,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("EndorsingRewardOps"); }); - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => { b.Property("Id") @@ -1908,7 +2108,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RevealedLevel") .HasColumnType("integer"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("SenderId") @@ -2210,6 +2416,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BallotQuorumMin") .HasColumnType("integer"); + b.Property("BaseIssuedPerMinute") + .HasColumnType("bigint"); + + b.Property("BlockBonusWeight") + .HasColumnType("integer"); + b.Property("BlockDeposit") .HasColumnType("bigint"); @@ -2219,6 +2431,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BlockReward1") .HasColumnType("bigint"); + b.Property("BlockRewardWeight") + .HasColumnType("integer"); + b.Property("BlocksPerCommitment") .HasColumnType("integer"); @@ -2243,13 +2458,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Dictator") .HasColumnType("text"); - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") + b.Property("DoubleBakingSlashedPercentage") .HasColumnType("integer"); - b.Property("DoubleEndorsingPunishmentNumerator") + b.Property("DoubleEndorsingSlashedPercentage") .HasColumnType("integer"); b.Property("EndorsementDeposit") @@ -2264,6 +2476,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("EndorsersPerBlock") .HasColumnType("integer"); + b.Property("EndorsingRewardWeight") + .HasColumnType("integer"); + b.Property("Extras") .HasColumnType("jsonb"); @@ -2276,9 +2491,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("FirstLevel") .HasColumnType("integer"); - b.Property("FrozenDepositsPercentage") - .HasColumnType("integer"); - b.Property("HardBlockGasLimit") .HasColumnType("integer"); @@ -2294,7 +2506,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("character(51)") .IsFixedLength(); - b.Property("LBSubsidy") + b.Property("LBSubsidyWeight") .HasColumnType("integer"); b.Property("LBToggleThreshold") @@ -2306,9 +2518,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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"); @@ -2318,9 +2536,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MinParticipationNumerator") .HasColumnType("integer"); + b.Property("MinimalFrozenStake") + .HasColumnType("bigint"); + + b.Property("MinimalStake") + .HasColumnType("bigint"); + b.Property("NoRewardCycles") .HasColumnType("integer"); + b.Property("NonceRevelationRewardWeight") + .HasColumnType("integer"); + b.Property("OriginationSize") .HasColumnType("integer"); @@ -2333,9 +2560,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("RampUpCycles") .HasColumnType("integer"); - b.Property("RevelationReward") - .HasColumnType("bigint"); - b.Property("SmartRollupChallengeWindow") .HasColumnType("integer"); @@ -2351,16 +2575,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SmartRollupTimeoutPeriod") .HasColumnType("integer"); - b.Property("TimeBetweenBlocks") + b.Property("StakePowerMultiplier") .HasColumnType("integer"); - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); - b.Property("TxRollupOriginationSize") + b.Property("VdfRevelationRewardWeight") .HasColumnType("integer"); b.HasKey("Id"); @@ -3024,6 +3245,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3083,9 +3310,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("character(51)") .IsFixedLength(); - b.Property("OriginationProof") - .HasColumnType("bytea"); - b.Property("ParameterType") .HasColumnType("bytea"); @@ -3389,28 +3613,44 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("AccountId") .HasColumnType("integer"); - b.Property("Balance") - .HasColumnType("bigint"); + b.Property("BakerId") + .HasColumnType("integer"); - b.Property("DelegateId") + b.Property("DelegatorsCount") .HasColumnType("integer"); - b.Property("DelegatedBalance") + b.Property("ExternalDelegatedBalance") .HasColumnType("bigint"); - b.Property("DelegatorsCount") - .HasColumnType("integer"); + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("IssuedPseudotokens") + .HasColumnType("bigint"); b.Property("Level") .HasColumnType("integer"); - b.Property("StakingBalance") + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("OwnStakedBalance") .HasColumnType("bigint"); + b.Property("StakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("StakersCount") + .HasColumnType("integer"); + b.HasKey("Id"); - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); + b.HasIndex("Level"); + + b.HasIndex("Level", "AccountId", "BakerId"); + + b.HasIndex(new[] { "Level" }, "IX_SnapshotBalance_Level_Partial") + .HasFilter("\"AccountId\" = \"BakerId\""); b.ToTable("SnapshotBalances"); }); @@ -3426,24 +3666,120 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BlocksCount") .HasColumnType("integer"); - b.Property("Extras") - .HasColumnType("jsonb"); + 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("ActivationCycle") + .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("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("FirstCycleUnstaked") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastCycleUnstaked") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevStakedBalance") + .HasColumnType("bigint"); + + b.Property("Pseudotokens") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); - b.Property("FirstLevel") + b.Property("StorageLimit") .HasColumnType("integer"); - b.Property("LastLevel") + b.Property("StorageUsed") .HasColumnType("integer"); - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(); + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); b.HasKey("Id"); - b.ToTable("Software"); + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("StakingOps"); }); modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => @@ -3484,6 +3820,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TotalFrozen") .HasColumnType("bigint"); + b.Property("TotalLost") + .HasColumnType("bigint"); + b.Property("TotalRollupBonds") .HasColumnType("bigint"); @@ -3553,6 +3892,205 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContentHash"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonContent"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonContent"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonContent"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("TicketerId"); + + 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") + .IsRequired() + .HasColumnType("text"); + + 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("AccountId"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Id") + .IsUnique(); + + 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") + .IsRequired() + .HasColumnType("text"); + + 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("Id") + .IsUnique(); + + b.HasIndex("Level"); + + 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.ToTable("TicketTransfers"); + }); + modelBuilder.Entity("Tzkt.Data.Models.Token", b => { b.Property("Id") @@ -3870,6 +4408,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3970,9 +4511,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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"); @@ -4662,7 +5209,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Proof") .HasColumnType("bytea"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("Solution") @@ -4836,6 +5389,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Tags") .HasColumnType("integer"); + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("TokensCount") .HasColumnType("integer"); @@ -4941,6 +5497,24 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SetDepositsLimitsCount") .HasColumnType("integer"); + b.Property("StakedBalance") + .HasColumnType("bigint"); + + b.Property("StakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("StakingOpsCount") + .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); }); @@ -4951,6 +5525,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActivationLevel") .HasColumnType("integer"); + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + b.Property("BallotsCount") .HasColumnType("integer"); @@ -4975,18 +5552,30 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("DoublePreendorsingCount") .HasColumnType("integer"); + b.Property("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + b.Property("EndorsementsCount") .HasColumnType("integer"); b.Property("EndorsingRewardsCount") .HasColumnType("integer"); - b.Property("FrozenDeposit") + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalUnstakedBalance") .HasColumnType("bigint"); b.Property("FrozenDepositLimit") .HasColumnType("bigint"); + b.Property("IssuedPseudotokens") + .HasColumnType("bigint"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + b.Property("NonceRevelationsCount") .HasColumnType("integer"); @@ -5002,9 +5591,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SoftwareId") .HasColumnType("integer"); + b.Property("StakersCount") + .HasColumnType("integer"); + b.Property("StakingBalance") .HasColumnType("bigint"); + b.Property("TotalStakedBalance") + .HasColumnType("bigint"); + b.Property("VdfRevelationsCount") .HasColumnType("integer"); @@ -5670,6 +6265,26 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) 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") @@ -6012,6 +6627,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Navigation("SmartRollupRefuteOps"); + b.Navigation("StakingOps"); + b.Navigation("Transactions"); b.Navigation("TransferTicketOps"); diff --git a/Tzkt.Data/Migrations/20230720080720_TokenValues.cs b/Tzkt.Data/Migrations/20240201122141_TokensValue.cs similarity index 93% rename from Tzkt.Data/Migrations/20230720080720_TokenValues.cs rename to Tzkt.Data/Migrations/20240201122141_TokensValue.cs index 4aced57f2..5b0ac2d8b 100644 --- a/Tzkt.Data/Migrations/20230720080720_TokenValues.cs +++ b/Tzkt.Data/Migrations/20240201122141_TokensValue.cs @@ -5,7 +5,7 @@ namespace Tzkt.Data.Migrations { /// - public partial class TokenValues : Migration + public partial class TokensValue : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index e59b72946..7d749071f 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -78,6 +78,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("LastLevel") .HasColumnType("integer"); + b.Property("LostBalance") + .HasColumnType("bigint"); + b.Property("Metadata") .HasColumnType("jsonb"); @@ -256,6 +259,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AIActivated") + .HasColumnType("boolean"); + + b.Property("AIActivationCycle") + .HasColumnType("integer"); + + b.Property("AIFinalUpvoteLevel") + .HasColumnType("integer"); + b.Property("AccountCounter") .HasColumnType("integer"); @@ -265,6 +277,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ActivationOpsCount") .HasColumnType("integer"); + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + b.Property("BallotOpsCount") .HasColumnType("integer"); @@ -370,6 +385,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("OriginationOpsCount") .HasColumnType("integer"); + b.Property("PendingStakingParameters") + .HasColumnType("integer"); + b.Property("PreendorsementOpsCount") .HasColumnType("integer"); @@ -454,6 +472,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SmartRollupRefuteOpsCount") .HasColumnType("integer"); + b.Property("StakingOpsCount") + .HasColumnType("integer"); + b.Property("StorageCounter") .HasColumnType("integer"); @@ -528,9 +549,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) new { Id = -1, + AIActivated = false, + AIActivationCycle = 0, + AIFinalUpvoteLevel = 0, AccountCounter = 0, AccountsCount = 0, ActivationOpsCount = 0, + AutostakingOpsCount = 0, BallotOpsCount = 0, BigMapCounter = 0, BigMapKeyCounter = 0, @@ -562,6 +587,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) NonceRevelationOpsCount = 0, OperationCounter = 0L, OriginationOpsCount = 0, + PendingStakingParameters = 0, PreendorsementOpsCount = 0, ProposalOpsCount = 0, ProposalsCount = 0, @@ -590,6 +616,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) SmartRollupPublishOpsCount = 0, SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, + StakingOpsCount = 0, StorageCounter = 0, TicketBalancesCount = 0, TicketTransfersCount = 0, @@ -615,6 +642,38 @@ protected override void BuildModel(ModelBuilder modelBuilder) }); }); + 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("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("AutostakingOps"); + }); + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => { b.Property("Id") @@ -623,16 +682,22 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("ActiveStake") - .HasColumnType("bigint"); - b.Property("BakerId") .HasColumnType("integer"); + b.Property("BakingPower") + .HasColumnType("bigint"); + b.Property("BlockFees") .HasColumnType("bigint"); - b.Property("BlockRewards") + b.Property("BlockRewardsLiquid") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedShared") .HasColumnType("bigint"); b.Property("Blocks") @@ -641,31 +706,61 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Cycle") .HasColumnType("integer"); - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - b.Property("DelegatorsCount") .HasColumnType("integer"); - b.Property("DoubleBakingLosses") + 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("DoubleEndorsingLosses") + 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("DoublePreendorsingLosses") + 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("EndorsementRewards") + b.Property("EndorsementRewardsLiquid") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedShared") .HasColumnType("bigint"); b.Property("Endorsements") @@ -677,6 +772,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ExpectedEndorsements") .HasColumnType("double precision"); + b.Property("ExternalDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + b.Property("FutureBlockRewards") .HasColumnType("bigint"); @@ -704,29 +805,44 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("MissedEndorsements") .HasColumnType("integer"); - b.Property("RevelationLosses") + b.Property("NonceRevelationLosses") .HasColumnType("bigint"); - b.Property("RevelationRewards") + b.Property("NonceRevelationRewardsLiquid") .HasColumnType("bigint"); - b.Property("SelectedStake") + b.Property("NonceRevelationRewardsStakedOwn") .HasColumnType("bigint"); - b.Property("StakingBalance") + b.Property("NonceRevelationRewardsStakedShared") .HasColumnType("bigint"); - b.HasKey("Id"); + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); - b.HasIndex("BakerId"); + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); - b.HasIndex("Cycle"); + b.Property("StakersCount") + .HasColumnType("integer"); - b.HasIndex("Id") - .IsUnique(); + b.Property("TotalBakingPower") + .HasColumnType("bigint"); - b.HasIndex("Cycle", "BakerId") - .IsUnique(); + b.Property("VdfRevelationRewardsLiquid") + .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"); }); @@ -1018,10 +1134,22 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AIToggle") + .HasColumnType("boolean"); + + b.Property("AIToggleEma") + .HasColumnType("integer"); + b.Property("BlockRound") .HasColumnType("integer"); - b.Property("Bonus") + b.Property("BonusLiquid") + .HasColumnType("bigint"); + + b.Property("BonusStakedOwn") + .HasColumnType("bigint"); + + b.Property("BonusStakedShared") .HasColumnType("bigint"); b.Property("Cycle") @@ -1078,7 +1206,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("RevelationId") .HasColumnType("bigint"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("SoftwareId") @@ -1213,27 +1347,39 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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("LBSubsidy") + .HasColumnType("bigint"); + 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("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - b.Property("SnapshotIndex") .HasColumnType("integer"); @@ -1243,13 +1389,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TotalBakers") .HasColumnType("integer"); - b.Property("TotalDelegated") + b.Property("TotalBakingPower") .HasColumnType("bigint"); - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") + b.Property("VdfRevelationReward") .HasColumnType("bigint"); b.HasKey("Id"); @@ -1336,6 +1479,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Timestamp") .HasColumnType("timestamp with time zone"); + b.Property("UnstakedBalance") + .HasColumnType("bigint"); + + b.Property("UnstakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("UnstakedRewards") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("DelegateId"); @@ -1367,25 +1519,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("BakerId") .HasColumnType("integer"); - b.Property("Balance") - .HasColumnType("bigint"); - b.Property("Cycle") .HasColumnType("integer"); + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + b.Property("DelegatorId") .HasColumnType("integer"); - b.HasKey("Id"); + b.Property("StakedBalance") + .HasColumnType("bigint"); - b.HasIndex("Cycle"); + b.HasKey("Id"); b.HasIndex("DelegatorId"); b.HasIndex("Cycle", "BakerId"); - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); + b.HasIndex("Cycle", "DelegatorId"); b.ToTable("DelegatorCycles"); }); @@ -1456,24 +1608,39 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1504,24 +1671,39 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1552,24 +1734,39 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("AccuserId") .HasColumnType("integer"); - b.Property("AccuserReward") - .HasColumnType("bigint"); - b.Property("Level") .HasColumnType("integer"); - b.Property("OffenderId") - .HasColumnType("integer"); + b.Property("LostExternalStaked") + .HasColumnType("bigint"); - b.Property("OffenderLoss") + 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("RoundingLoss") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -1694,7 +1891,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Level") .HasColumnType("integer"); - b.Property("Received") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("Timestamp") @@ -1709,30 +1912,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("EndorsingRewardOps"); }); - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => { b.Property("Id") @@ -1926,7 +2105,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("RevealedLevel") .HasColumnType("integer"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("SenderId") @@ -2228,6 +2413,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("BallotQuorumMin") .HasColumnType("integer"); + b.Property("BaseIssuedPerMinute") + .HasColumnType("bigint"); + + b.Property("BlockBonusWeight") + .HasColumnType("integer"); + b.Property("BlockDeposit") .HasColumnType("bigint"); @@ -2237,6 +2428,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("BlockReward1") .HasColumnType("bigint"); + b.Property("BlockRewardWeight") + .HasColumnType("integer"); + b.Property("BlocksPerCommitment") .HasColumnType("integer"); @@ -2261,13 +2455,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Dictator") .HasColumnType("text"); - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") + b.Property("DoubleBakingSlashedPercentage") .HasColumnType("integer"); - b.Property("DoubleEndorsingPunishmentNumerator") + b.Property("DoubleEndorsingSlashedPercentage") .HasColumnType("integer"); b.Property("EndorsementDeposit") @@ -2282,6 +2473,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("EndorsersPerBlock") .HasColumnType("integer"); + b.Property("EndorsingRewardWeight") + .HasColumnType("integer"); + b.Property("Extras") .HasColumnType("jsonb"); @@ -2294,9 +2488,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("FirstLevel") .HasColumnType("integer"); - b.Property("FrozenDepositsPercentage") - .HasColumnType("integer"); - b.Property("HardBlockGasLimit") .HasColumnType("integer"); @@ -2312,7 +2503,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("character(51)") .IsFixedLength(); - b.Property("LBSubsidy") + b.Property("LBSubsidyWeight") .HasColumnType("integer"); b.Property("LBToggleThreshold") @@ -2324,9 +2515,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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"); @@ -2336,9 +2533,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("MinParticipationNumerator") .HasColumnType("integer"); + b.Property("MinimalFrozenStake") + .HasColumnType("bigint"); + + b.Property("MinimalStake") + .HasColumnType("bigint"); + b.Property("NoRewardCycles") .HasColumnType("integer"); + b.Property("NonceRevelationRewardWeight") + .HasColumnType("integer"); + b.Property("OriginationSize") .HasColumnType("integer"); @@ -2351,9 +2557,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("RampUpCycles") .HasColumnType("integer"); - b.Property("RevelationReward") - .HasColumnType("bigint"); - b.Property("SmartRollupChallengeWindow") .HasColumnType("integer"); @@ -2369,16 +2572,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SmartRollupTimeoutPeriod") .HasColumnType("integer"); - b.Property("TimeBetweenBlocks") + b.Property("StakePowerMultiplier") .HasColumnType("integer"); - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); - b.Property("TxRollupOriginationSize") + b.Property("VdfRevelationRewardWeight") .HasColumnType("integer"); b.HasKey("Id"); @@ -3107,9 +3307,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("character(51)") .IsFixedLength(); - b.Property("OriginationProof") - .HasColumnType("bytea"); - b.Property("ParameterType") .HasColumnType("bytea"); @@ -3413,28 +3610,44 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("AccountId") .HasColumnType("integer"); - b.Property("Balance") - .HasColumnType("bigint"); + b.Property("BakerId") + .HasColumnType("integer"); - b.Property("DelegateId") + b.Property("DelegatorsCount") .HasColumnType("integer"); - b.Property("DelegatedBalance") + b.Property("ExternalDelegatedBalance") .HasColumnType("bigint"); - b.Property("DelegatorsCount") - .HasColumnType("integer"); + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("IssuedPseudotokens") + .HasColumnType("bigint"); b.Property("Level") .HasColumnType("integer"); - b.Property("StakingBalance") + b.Property("OwnDelegatedBalance") .HasColumnType("bigint"); + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); + + b.Property("StakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("StakersCount") + .HasColumnType("integer"); + b.HasKey("Id"); - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); + b.HasIndex("Level"); + + b.HasIndex("Level", "AccountId", "BakerId"); + + b.HasIndex(new[] { "Level" }, "IX_SnapshotBalance_Level_Partial") + .HasFilter("\"AccountId\" = \"BakerId\""); b.ToTable("SnapshotBalances"); }); @@ -3470,6 +3683,102 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Software"); }); + modelBuilder.Entity("Tzkt.Data.Models.StakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .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("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("FirstCycleUnstaked") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastCycleUnstaked") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevStakedBalance") + .HasColumnType("bigint"); + + b.Property("Pseudotokens") + .HasColumnType("bigint"); + + 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("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("StakingOps"); + }); + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => { b.Property("Id") @@ -3508,6 +3817,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TotalFrozen") .HasColumnType("bigint"); + b.Property("TotalLost") + .HasColumnType("bigint"); + b.Property("TotalRollupBonds") .HasColumnType("bigint"); @@ -4894,7 +5206,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Proof") .HasColumnType("bytea"); - b.Property("Reward") + b.Property("RewardLiquid") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") .HasColumnType("bigint"); b.Property("Solution") @@ -5176,6 +5494,24 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SetDepositsLimitsCount") .HasColumnType("integer"); + b.Property("StakedBalance") + .HasColumnType("bigint"); + + b.Property("StakedPseudotokens") + .HasColumnType("bigint"); + + b.Property("StakingOpsCount") + .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); }); @@ -5186,6 +5522,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ActivationLevel") .HasColumnType("integer"); + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + b.Property("BallotsCount") .HasColumnType("integer"); @@ -5210,18 +5549,30 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DoublePreendorsingCount") .HasColumnType("integer"); + b.Property("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + b.Property("EndorsementsCount") .HasColumnType("integer"); b.Property("EndorsingRewardsCount") .HasColumnType("integer"); - b.Property("FrozenDeposit") + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalUnstakedBalance") .HasColumnType("bigint"); b.Property("FrozenDepositLimit") .HasColumnType("bigint"); + b.Property("IssuedPseudotokens") + .HasColumnType("bigint"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + b.Property("NonceRevelationsCount") .HasColumnType("integer"); @@ -5237,9 +5588,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SoftwareId") .HasColumnType("integer"); + b.Property("StakersCount") + .HasColumnType("integer"); + b.Property("StakingBalance") .HasColumnType("bigint"); + b.Property("TotalStakedBalance") + .HasColumnType("bigint"); + b.Property("VdfRevelationsCount") .HasColumnType("integer"); @@ -5905,6 +6262,26 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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") @@ -6247,6 +6624,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("SmartRollupRefuteOps"); + b.Navigation("StakingOps"); + b.Navigation("Transactions"); b.Navigation("TransferTicketOps"); diff --git a/Tzkt.Data/Models/Accounts/Account.cs b/Tzkt.Data/Models/Accounts/Account.cs index 916424728..c653b8256 100644 --- a/Tzkt.Data/Models/Accounts/Account.cs +++ b/Tzkt.Data/Models/Accounts/Account.cs @@ -17,6 +17,14 @@ public class Account public long SmartRollupBonds { get; set; } public int Counter { get; set; } + // it's needed to handle negligent Oxford implementation + public long LostBalance { get; set; } + + public int? DelegateId { get; set; } + public int? DelegationLevel { get; set; } + public bool Staked { get; set; } + + #region counters public int ContractsCount { get; set; } public int RollupsCount { get; set; } public int SmartRollupsCount { get; set; } @@ -59,10 +67,7 @@ public class Account public int RefutationGamesCount { get; set; } public int ActiveRefutationGamesCount { get; set; } - - public int? DelegateId { get; set; } - public int? DelegationLevel { get; set; } - public bool Staked { get; set; } + #endregion #region relations [ForeignKey(nameof(DelegateId))] diff --git a/Tzkt.Data/Models/Accounts/Delegate.cs b/Tzkt.Data/Models/Accounts/Delegate.cs index 5ba6d3815..e6e284e7f 100644 --- a/Tzkt.Data/Models/Accounts/Delegate.cs +++ b/Tzkt.Data/Models/Accounts/Delegate.cs @@ -9,11 +9,19 @@ public class Delegate : User public int ActivationLevel { get; set; } public int DeactivationLevel { get; set; } - public long? FrozenDepositLimit { get; set; } - public long FrozenDeposit { get; set; } public long StakingBalance { get; set; } public long DelegatedBalance { get; set; } public int DelegatorsCount { get; set; } + + public long TotalStakedBalance { get; set; } + public long ExternalStakedBalance { get; set; } + public long ExternalUnstakedBalance { get; set; } + public long IssuedPseudotokens { get; set; } + public int StakersCount { get; set; } + + public long? FrozenDepositLimit { get; set; } + public long? LimitOfStakingOverBaking { get; set; } + public long? EdgeOfBakingOverStaking { get; set; } public int BlocksCount { get; set; } public int EndorsementsCount { get; set; } @@ -27,6 +35,7 @@ public class Delegate : User public int VdfRevelationsCount { get; set; } public int RevelationPenaltiesCount { get; set; } public int EndorsingRewardsCount { get; set; } + public int AutostakingOpsCount { get; set; } public int? SoftwareId { get; set; } diff --git a/Tzkt.Data/Models/Accounts/User.cs b/Tzkt.Data/Models/Accounts/User.cs index 830bab216..16ee03299 100644 --- a/Tzkt.Data/Models/Accounts/User.cs +++ b/Tzkt.Data/Models/Accounts/User.cs @@ -4,17 +4,29 @@ namespace Tzkt.Data.Models { public class User : Account { - public bool? Activated { get; set; } - public string PublicKey { get; set; } public bool Revealed { get; set; } + public string PublicKey { get; set; } + + public long StakedBalance { get; set; } + public long StakedPseudotokens { get; set; } + public long UnstakedBalance { get; set; } + public int? UnstakedBakerId { get; set; } + + public bool? Activated { get; set; } public int RegisterConstantsCount { get; set; } public int SetDepositsLimitsCount { get; set; } + public int StakingOpsCount { get; set; } } public static class UserModel { - public static void BuildUserModel(this ModelBuilder _) + public static void BuildUserModel(this ModelBuilder modelBuilder) { + #region indexes + modelBuilder.Entity() + .HasIndex(x => x.UnstakedBakerId) + .HasFilter($@"""{nameof(User.UnstakedBakerId)}"" IS NOT NULL"); + #endregion } } } diff --git a/Tzkt.Data/Models/AppState.cs b/Tzkt.Data/Models/AppState.cs index c78af5166..7c0d2304c 100644 --- a/Tzkt.Data/Models/AppState.cs +++ b/Tzkt.Data/Models/AppState.cs @@ -24,6 +24,13 @@ public class AppState public int VotingPeriod { get; set; } #endregion + #region state + public bool AIActivated { get; set; } + public int AIActivationCycle { get; set; } + public int AIFinalUpvoteLevel { get; set; } + public int PendingStakingParameters { get; set; } + #endregion + #region counters public int AccountCounter { get; set; } public long OperationCounter { get; set; } @@ -59,6 +66,7 @@ public class AppState public int OriginationOpsCount { get; set; } public int ProposalOpsCount { get; set; } public int RevealOpsCount { get; set; } + public int StakingOpsCount { get; set; } public int TransactionOpsCount { get; set; } public int RegisterConstantOpsCount { get; set; } public int EndorsingRewardOpsCount { get; set; } @@ -80,6 +88,7 @@ public class AppState public int MigrationOpsCount { get; set; } public int RevelationPenaltyOpsCount { get; set; } + public int AutostakingOpsCount { get; set; } public int SmartRollupAddMessagesOpsCount { get; set; } public int SmartRollupCementOpsCount { get; set; } diff --git a/Tzkt.Data/Models/Baking/BakerCycle.cs b/Tzkt.Data/Models/Baking/BakerCycle.cs index e7de4962f..b497657e0 100644 --- a/Tzkt.Data/Models/Baking/BakerCycle.cs +++ b/Tzkt.Data/Models/Baking/BakerCycle.cs @@ -8,11 +8,16 @@ public class BakerCycle public int Cycle { get; set; } public int BakerId { get; set; } + public long OwnDelegatedBalance { get; set; } + public long ExternalDelegatedBalance { get; set; } public int DelegatorsCount { get; set; } - public long DelegatedBalance { get; set; } - public long StakingBalance { get; set; } - public long ActiveStake { get; set; } - public long SelectedStake { get; set; } + + public long OwnStakedBalance { get; set; } + public long ExternalStakedBalance { get; set; } + public int StakersCount { get; set; } + + public long BakingPower { get; set; } + public long TotalBakingPower { get; set; } #region rights public int FutureBlocks { get; set; } @@ -26,27 +31,46 @@ public class BakerCycle #region rewards public long FutureBlockRewards { get; set; } - public long BlockRewards { get; set; } public long MissedBlockRewards { get; set; } + public long BlockRewardsLiquid { get; set; } + public long BlockRewardsStakedOwn { get; set; } + public long BlockRewardsStakedShared { get; set; } public long FutureEndorsementRewards { get; set; } - public long EndorsementRewards { get; set; } public long MissedEndorsementRewards { get; set; } + public long EndorsementRewardsLiquid { get; set; } + public long EndorsementRewardsStakedOwn { get; set; } + public long EndorsementRewardsStakedShared { get; set; } public long BlockFees { get; set; } public long MissedBlockFees { get; set; } public long DoubleBakingRewards { get; set; } - public long DoubleBakingLosses { get; set; } + public long DoubleBakingLostStaked { get; set; } + public long DoubleBakingLostUnstaked { get; set; } + public long DoubleBakingLostExternalStaked { get; set; } + public long DoubleBakingLostExternalUnstaked { get; set; } public long DoubleEndorsingRewards { get; set; } - public long DoubleEndorsingLosses { get; set; } + public long DoubleEndorsingLostStaked { get; set; } + public long DoubleEndorsingLostUnstaked { get; set; } + public long DoubleEndorsingLostExternalStaked { get; set; } + public long DoubleEndorsingLostExternalUnstaked { get; set; } public long DoublePreendorsingRewards { get; set; } - public long DoublePreendorsingLosses { get; set; } - - public long RevelationRewards { get; set; } - public long RevelationLosses { get; set; } + public long DoublePreendorsingLostStaked { get; set; } + public long DoublePreendorsingLostUnstaked { get; set; } + public long DoublePreendorsingLostExternalStaked { get; set; } + public long DoublePreendorsingLostExternalUnstaked { get; set; } + + public long VdfRevelationRewardsLiquid { get; set; } + public long VdfRevelationRewardsStakedOwn { get; set; } + public long VdfRevelationRewardsStakedShared { get; set; } + + public long NonceRevelationRewardsLiquid { get; set; } + public long NonceRevelationRewardsStakedOwn { get; set; } + public long NonceRevelationRewardsStakedShared { get; set; } + public long NonceRevelationLosses { get; set; } #endregion #region expected @@ -66,18 +90,10 @@ public static void BuildBakerCycleModel(this ModelBuilder modelBuilder) #region indexes modelBuilder.Entity() - .HasIndex(x => x.Id) - .IsUnique(true); - - modelBuilder.Entity() - .HasIndex(x => x.Cycle); + .HasIndex(x => new { x.Cycle, x.BakerId }); modelBuilder.Entity() .HasIndex(x => x.BakerId); - - modelBuilder.Entity() - .HasIndex(x => new { x.Cycle, x.BakerId }) - .IsUnique(true); #endregion } } diff --git a/Tzkt.Data/Models/Baking/Cycle.cs b/Tzkt.Data/Models/Baking/Cycle.cs index 25f964c12..87a5f2b7b 100644 --- a/Tzkt.Data/Models/Baking/Cycle.cs +++ b/Tzkt.Data/Models/Baking/Cycle.cs @@ -10,14 +10,19 @@ public class Cycle public int LastLevel { get; set; } public int SnapshotIndex { get; set; } public int SnapshotLevel { get; set; } - public long TotalStaking { get; set; } - public long TotalDelegated { get; set; } - public int TotalDelegators { get; set; } + public int TotalBakers { get; set; } - public int SelectedBakers { get; set; } - public long SelectedStake { get; set; } + public long TotalBakingPower { get; set; } public byte[] Seed { get; set; } + + public long BlockReward { get; set; } + public long BlockBonusPerSlot { get; set; } + public long MaxBlockReward { get; set; } + public long EndorsementRewardPerSlot { get; set; } + public long NonceRevelationReward { get; set; } + public long VdfRevelationReward { get; set; } + public long LBSubsidy { get; set; } } public static class CycleModel diff --git a/Tzkt.Data/Models/Baking/DelegatorCycle.cs b/Tzkt.Data/Models/Baking/DelegatorCycle.cs index 7f04f98d8..0e93c6341 100644 --- a/Tzkt.Data/Models/Baking/DelegatorCycle.cs +++ b/Tzkt.Data/Models/Baking/DelegatorCycle.cs @@ -9,7 +9,8 @@ public class DelegatorCycle public int DelegatorId { get; set; } public int BakerId { get; set; } - public long Balance { get; set; } + public long DelegatedBalance { get; set; } + public long StakedBalance { get; set; } } public static class DelegatorCycleModel @@ -23,17 +24,13 @@ public static void BuildDelegatorCycleModel(this ModelBuilder modelBuilder) #region indexes modelBuilder.Entity() - .HasIndex(x => x.Cycle); - - modelBuilder.Entity() - .HasIndex(x => x.DelegatorId); + .HasIndex(x => new { x.Cycle, x.BakerId }); modelBuilder.Entity() - .HasIndex(x => new { x.Cycle, x.DelegatorId }) - .IsUnique(true); + .HasIndex(x => new { x.Cycle, x.DelegatorId }); modelBuilder.Entity() - .HasIndex(x => new { x.Cycle, x.BakerId }); + .HasIndex(x => x.DelegatorId); #endregion } } diff --git a/Tzkt.Data/Models/Baking/FreezerUpdate.cs b/Tzkt.Data/Models/Baking/FreezerUpdate.cs deleted file mode 100644 index 3f3707c79..000000000 --- a/Tzkt.Data/Models/Baking/FreezerUpdate.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace Tzkt.Data.Models -{ - public class FreezerUpdate - { - public int Id { get; set; } - public int Cycle { get; set; } - public int BakerId { get; set; } - public long Change { get; set; } - } - - public static class FreezerUpdateModel - { - public static void BuildFreezerUpdateModel(this ModelBuilder modelBuilder) - { - #region keys - modelBuilder.Entity() - .HasKey(x => x.Id); - #endregion - - #region indexes - modelBuilder.Entity() - .HasIndex(x => x.Cycle); - #endregion - } - } -} diff --git a/Tzkt.Data/Models/Baking/SnapshotBalance.cs b/Tzkt.Data/Models/Baking/SnapshotBalance.cs index b4715e44e..ef1ece221 100644 --- a/Tzkt.Data/Models/Baking/SnapshotBalance.cs +++ b/Tzkt.Data/Models/Baking/SnapshotBalance.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; namespace Tzkt.Data.Models { @@ -6,12 +7,28 @@ public class SnapshotBalance { public int Id { get; set; } public int Level { get; set; } - public long Balance { get; set; } public int AccountId { get; set; } - public int? DelegateId { get; set; } - public int? DelegatorsCount { get; set; } - public long? DelegatedBalance { get; set; } - public long? StakingBalance { get; set; } + + public int BakerId { get; set; } + + public long OwnDelegatedBalance { get; set; } + public long ExternalDelegatedBalance { get; set; } + public int DelegatorsCount { get; set; } + + public long OwnStakedBalance { get; set; } + public long ExternalStakedBalance { get; set; } + public int StakersCount { get; set; } + + public long StakedPseudotokens { get; set; } + public long IssuedPseudotokens { get; set; } + + #region helpers + [NotMapped] + public long StakingBalance => OwnDelegatedBalance + ExternalDelegatedBalance + OwnStakedBalance + ExternalStakedBalance; + + [NotMapped] + public long TotalStakedBalance => OwnStakedBalance + ExternalStakedBalance; + #endregion } public static class SnapshotBalanceModel @@ -28,8 +45,11 @@ public static void BuildSnapshotBalanceModel(this ModelBuilder modelBuilder) .HasIndex(x => x.Level); modelBuilder.Entity() - .HasIndex(x => x.Level) - .HasFilter(@"""DelegateId"" IS NULL"); + .HasIndex(x => x.Level, "IX_SnapshotBalance_Level_Partial") + .HasFilter(@"""AccountId"" = ""BakerId"""); + + modelBuilder.Entity() + .HasIndex(x => new { x.Level, x.AccountId, x.BakerId }); #endregion } } diff --git a/Tzkt.Data/Models/Blocks/Block.cs b/Tzkt.Data/Models/Blocks/Block.cs index 03151f5ea..18980f6ce 100644 --- a/Tzkt.Data/Models/Blocks/Block.cs +++ b/Tzkt.Data/Models/Blocks/Block.cs @@ -22,8 +22,12 @@ public class Block public Operations Operations { get; set; } public long Deposit { get; set; } - public long Reward { get; set; } - public long Bonus { get; set; } + public long RewardLiquid { get; set; } + public long RewardStakedOwn { get; set; } + public long RewardStakedShared { get; set; } + public long BonusLiquid { get; set; } + public long BonusStakedOwn { get; set; } + public long BonusStakedShared { get; set; } public long Fees { get; set; } public int? ProposerId { get; set; } @@ -35,6 +39,9 @@ public class Block public bool? LBToggle { get; set; } public int LBToggleEma { get; set; } + public bool? AIToggle { get; set; } + public int AIToggleEma { get; set; } + #region relations [ForeignKey(nameof(ProtoCode))] public Protocol Protocol { get; set; } @@ -66,6 +73,7 @@ public class Block public List Delegations { get; set; } public List Originations { get; set; } + public List StakingOps { get; set; } public List Transactions { get; set; } public List Reveals { get; set; } public List RegisterConstants { get; set; } diff --git a/Tzkt.Data/Models/Blocks/BlockEvents.cs b/Tzkt.Data/Models/Blocks/BlockEvents.cs index 540471d48..988369d6c 100644 --- a/Tzkt.Data/Models/Blocks/BlockEvents.cs +++ b/Tzkt.Data/Models/Blocks/BlockEvents.cs @@ -5,19 +5,22 @@ namespace Tzkt.Data.Models [Flags] public enum BlockEvents { - None = 0b_0000_0000_0000_0000, - CycleBegin = 0b_0000_0000_0000_0001, - CycleEnd = 0b_0000_0000_0000_0010, - ProtocolBegin = 0b_0000_0000_0000_0100, - ProtocolEnd = 0b_0000_0000_0000_1000, - Deactivations = 0b_0000_0000_0001_0000, - NewAccounts = 0b_0000_0000_0010_0000, - BalanceSnapshot = 0b_0000_0000_0100_0000, - SmartContracts = 0b_0000_0000_1000_0000, - DelegatorContracts = 0b_0000_0001_0000_0000, - Bigmaps = 0b_0000_0010_0000_0000, - Tokens = 0b_0000_0100_0000_0000, - Events = 0b_0000_1000_0000_0000, - Tickets = 0b_0001_0000_0000_0000 + None = 0b_0000_0000_0000_0000, + CycleBegin = 0b_0000_0000_0000_0001, + CycleEnd = 0b_0000_0000_0000_0010, + ProtocolBegin = 0b_0000_0000_0000_0100, + ProtocolEnd = 0b_0000_0000_0000_1000, + Deactivations = 0b_0000_0000_0001_0000, + NewAccounts = 0b_0000_0000_0010_0000, + BalanceSnapshot = 0b_0000_0000_0100_0000, + SmartContracts = 0b_0000_0000_1000_0000, + DelegatorContracts = 0b_0000_0001_0000_0000, + Bigmaps = 0b_0000_0010_0000_0000, + Tokens = 0b_0000_0100_0000_0000, + Events = 0b_0000_1000_0000_0000, + Tickets = 0b_0001_0000_0000_0000, + DoubleBakingSlashing = 0b_0010_0000_0000_0000, + DoubleEndorsingSlashing = 0b_0100_0000_0000_0000, + DoublePreendorsingSlashing = 0b_1000_0000_0000_0000 } } diff --git a/Tzkt.Data/Models/Blocks/Protocol.cs b/Tzkt.Data/Models/Blocks/Protocol.cs index 7120c326f..f533bb7fe 100644 --- a/Tzkt.Data/Models/Blocks/Protocol.cs +++ b/Tzkt.Data/Models/Blocks/Protocol.cs @@ -32,16 +32,18 @@ public class Protocol public int HardOperationStorageLimit { get; set; } public int HardBlockGasLimit { get; set; } - public long TokensPerRoll { get; set; } - public long RevelationReward { get; set; } + public long MinimalStake { get; set; } + public long MinimalFrozenStake { get; set; } public long BlockDeposit { get; set; } public long BlockReward0 { get; set; } public long BlockReward1 { get; set; } + public long MaxBakingReward { get; set; } public long EndorsementDeposit { get; set; } public long EndorsementReward0 { get; set; } public long EndorsementReward1 { get; set; } + public long MaxEndorsingReward { get; set; } public int OriginationSize { get; set; } public int ByteCost { get; set; } @@ -50,10 +52,6 @@ public class Protocol public int BallotQuorumMin { get; set; } public int BallotQuorumMax { get; set; } - /// - /// Liquidity baking subsidy is 1/16th of total rewards for a block of priority 0 with all endorsements - /// - public int LBSubsidy { get; set; } /// /// 1/2 window size of 2000 blocks with precision of 1000000 for integer computation /// @@ -63,16 +61,9 @@ public class Protocol public int MinParticipationNumerator { get; set; } public int MinParticipationDenominator { get; set; } public int MaxSlashingPeriod { get; set; } - public int FrozenDepositsPercentage { get; set; } - public long DoubleBakingPunishment { get; set; } - public int DoubleEndorsingPunishmentNumerator { get; set; } - public int DoubleEndorsingPunishmentDenominator { get; set; } - - public long MaxBakingReward { get; set; } - public long MaxEndorsingReward { get; set; } - - public int TxRollupOriginationSize { get; set; } - public long TxRollupCommitmentBond { get; set; } + public int MaxDelegatedOverFrozenRatio { get; set; } + public int MaxExternalOverOwnStakeRatio { get; set; } + public int StakePowerMultiplier { get; set; } public int SmartRollupOriginationSize { get; set; } public long SmartRollupStakeAmount { get; set; } @@ -82,6 +73,17 @@ public class Protocol public string Dictator { get; set; } + public long BaseIssuedPerMinute { get; set; } + public int BlockRewardWeight { get; set; } + public int BlockBonusWeight { get; set; } + public int EndorsingRewardWeight { get; set; } + public int NonceRevelationRewardWeight { get; set; } + public int VdfRevelationRewardWeight { get; set; } + public int LBSubsidyWeight { get; set; } + + public int DoubleBakingSlashedPercentage { get; set; } + public int DoubleEndorsingSlashedPercentage { get; set; } + #region helpers public int GetCycleStart(int cycle) { diff --git a/Tzkt.Data/Models/Operations/Base/Operations.cs b/Tzkt.Data/Models/Operations/Base/Operations.cs index 673073cd5..c4c1a02b9 100644 --- a/Tzkt.Data/Models/Operations/Base/Operations.cs +++ b/Tzkt.Data/Models/Operations/Base/Operations.cs @@ -5,56 +5,59 @@ namespace Tzkt.Data.Models [Flags] public enum Operations : long { - None = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000, + None = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000, - Endorsements = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001, + Endorsements = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001, - Ballots = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0010, - Proposals = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0100, + Ballots = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0010, + Proposals = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0100, - Activations = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_1000, - DoubleBakings = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0001_0000, - DoubleEndorsings = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0010_0000, - Revelations = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0100_0000, + Activations = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_1000, + DoubleBakings = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001_0000, + DoubleEndorsings = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0010_0000, + Revelations = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0100_0000, - Transactions = 0b_0000_0000_0000_0000_0000_0000_0000_0000_1000_0000, - Delegations = 0b_0000_0000_0000_0000_0000_0000_0000_0001_0000_0000, - Originations = 0b_0000_0000_0000_0000_0000_0000_0000_0010_0000_0000, - Reveals = 0b_0000_0000_0000_0000_0000_0000_0000_0100_0000_0000, + Transactions = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_1000_0000, + Delegations = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0001_0000_0000, + Originations = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0010_0000_0000, + Reveals = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0100_0000_0000, - Migrations = 0b_0000_0000_0000_0000_0000_0000_0000_1000_0000_0000, - RevelationPenalty = 0b_0000_0000_0000_0000_0000_0000_0001_0000_0000_0000, - Baking = 0b_0000_0000_0000_0000_0000_0000_0010_0000_0000_0000, + Migrations = 0b_0000_0000_0000_0000_0000_0000_0000_0000_1000_0000_0000, + RevelationPenalty = 0b_0000_0000_0000_0000_0000_0000_0000_0001_0000_0000_0000, + Baking = 0b_0000_0000_0000_0000_0000_0000_0000_0010_0000_0000_0000, - RegisterConstant = 0b_0000_0000_0000_0000_0000_0000_0100_0000_0000_0000, + RegisterConstant = 0b_0000_0000_0000_0000_0000_0000_0000_0100_0000_0000_0000, - EndorsingRewards = 0b_0000_0000_0000_0000_0000_0000_1000_0000_0000_0000, - Preendorsements = 0b_0000_0000_0000_0000_0000_0001_0000_0000_0000_0000, - SetDepositsLimits = 0b_0000_0000_0000_0000_0000_0010_0000_0000_0000_0000, - DoublePreendorsings = 0b_0000_0000_0000_0000_0000_0100_0000_0000_0000_0000, + EndorsingRewards = 0b_0000_0000_0000_0000_0000_0000_0000_1000_0000_0000_0000, + Preendorsements = 0b_0000_0000_0000_0000_0000_0000_0001_0000_0000_0000_0000, + SetDepositsLimits = 0b_0000_0000_0000_0000_0000_0000_0010_0000_0000_0000_0000, + DoublePreendorsings = 0b_0000_0000_0000_0000_0000_0000_0100_0000_0000_0000_0000, - TxRollupOrigination = 0b_0000_0000_0000_0000_0000_1000_0000_0000_0000_0000, - TxRollupSubmitBatch = 0b_0000_0000_0000_0000_0001_0000_0000_0000_0000_0000, - TxRollupCommit = 0b_0000_0000_0000_0000_0010_0000_0000_0000_0000_0000, - TxRollupReturnBond = 0b_0000_0000_0000_0000_0100_0000_0000_0000_0000_0000, - TxRollupFinalizeCommitment = 0b_0000_0000_0000_0000_1000_0000_0000_0000_0000_0000, - TxRollupRemoveCommitment = 0b_0000_0000_0000_0001_0000_0000_0000_0000_0000_0000, - TxRollupRejection = 0b_0000_0000_0000_0010_0000_0000_0000_0000_0000_0000, - TxRollupDispatchTickets = 0b_0000_0000_0000_0100_0000_0000_0000_0000_0000_0000, - TransferTicket = 0b_0000_0000_0000_1000_0000_0000_0000_0000_0000_0000, - - IncreasePaidStorage = 0b_0000_0000_0001_0000_0000_0000_0000_0000_0000_0000, - VdfRevelation = 0b_0000_0000_0010_0000_0000_0000_0000_0000_0000_0000, + TxRollupOrigination = 0b_0000_0000_0000_0000_0000_0000_1000_0000_0000_0000_0000, + TxRollupSubmitBatch = 0b_0000_0000_0000_0000_0000_0001_0000_0000_0000_0000_0000, + TxRollupCommit = 0b_0000_0000_0000_0000_0000_0010_0000_0000_0000_0000_0000, + TxRollupReturnBond = 0b_0000_0000_0000_0000_0000_0100_0000_0000_0000_0000_0000, + TxRollupFinalizeCommitment = 0b_0000_0000_0000_0000_0000_1000_0000_0000_0000_0000_0000, + TxRollupRemoveCommitment = 0b_0000_0000_0000_0000_0001_0000_0000_0000_0000_0000_0000, + TxRollupRejection = 0b_0000_0000_0000_0000_0010_0000_0000_0000_0000_0000_0000, + TxRollupDispatchTickets = 0b_0000_0000_0000_0000_0100_0000_0000_0000_0000_0000_0000, + TransferTicket = 0b_0000_0000_0000_0000_1000_0000_0000_0000_0000_0000_0000, + + IncreasePaidStorage = 0b_0000_0000_0000_0001_0000_0000_0000_0000_0000_0000_0000, + VdfRevelation = 0b_0000_0000_0000_0010_0000_0000_0000_0000_0000_0000_0000, - UpdateConsensusKey = 0b_0000_0000_0100_0000_0000_0000_0000_0000_0000_0000, - DrainDelegate = 0b_0000_0000_1000_0000_0000_0000_0000_0000_0000_0000, - - SmartRollupAddMessages = 0b_0000_0001_0000_0000_0000_0000_0000_0000_0000_0000, - SmartRollupCement = 0b_0000_0010_0000_0000_0000_0000_0000_0000_0000_0000, - SmartRollupExecute = 0b_0000_0100_0000_0000_0000_0000_0000_0000_0000_0000, - SmartRollupOriginate = 0b_0000_1000_0000_0000_0000_0000_0000_0000_0000_0000, - SmartRollupPublish = 0b_0001_0000_0000_0000_0000_0000_0000_0000_0000_0000, - SmartRollupRecoverBond = 0b_0010_0000_0000_0000_0000_0000_0000_0000_0000_0000, - SmartRollupRefute = 0b_0100_0000_0000_0000_0000_0000_0000_0000_0000_0000 + UpdateConsensusKey = 0b_0000_0000_0000_0100_0000_0000_0000_0000_0000_0000_0000, + DrainDelegate = 0b_0000_0000_0000_1000_0000_0000_0000_0000_0000_0000_0000, + + SmartRollupAddMessages = 0b_0000_0000_0001_0000_0000_0000_0000_0000_0000_0000_0000, + SmartRollupCement = 0b_0000_0000_0010_0000_0000_0000_0000_0000_0000_0000_0000, + SmartRollupExecute = 0b_0000_0000_0100_0000_0000_0000_0000_0000_0000_0000_0000, + SmartRollupOriginate = 0b_0000_0000_1000_0000_0000_0000_0000_0000_0000_0000_0000, + SmartRollupPublish = 0b_0000_0001_0000_0000_0000_0000_0000_0000_0000_0000_0000, + SmartRollupRecoverBond = 0b_0000_0010_0000_0000_0000_0000_0000_0000_0000_0000_0000, + SmartRollupRefute = 0b_0000_0100_0000_0000_0000_0000_0000_0000_0000_0000_0000, + + Staking = 0b_0000_1000_0000_0000_0000_0000_0000_0000_0000_0000_0000, + Autostaking = 0b_0001_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 } } diff --git a/Tzkt.Data/Models/Operations/DelegationOperation.cs b/Tzkt.Data/Models/Operations/DelegationOperation.cs index d1e8bd0ef..f1c811e42 100644 --- a/Tzkt.Data/Models/Operations/DelegationOperation.cs +++ b/Tzkt.Data/Models/Operations/DelegationOperation.cs @@ -4,7 +4,6 @@ namespace Tzkt.Data.Models { - //TODO: add delegation amount public class DelegationOperation : InternalOperation { public int? SenderCodeHash { get; set; } @@ -14,6 +13,10 @@ public class DelegationOperation : InternalOperation public long Amount { get; set; } + public long? UnstakedPseudotokens { get; set; } + public long? UnstakedBalance { get; set; } + public long? UnstakedRewards { get; set; } + #region relations [ForeignKey(nameof(DelegateId))] public Delegate Delegate { get; set; } diff --git a/Tzkt.Data/Models/Operations/DoubleBakingOperation.cs b/Tzkt.Data/Models/Operations/DoubleBakingOperation.cs index 74f6ccede..50d1f3111 100644 --- a/Tzkt.Data/Models/Operations/DoubleBakingOperation.cs +++ b/Tzkt.Data/Models/Operations/DoubleBakingOperation.cs @@ -7,12 +7,19 @@ namespace Tzkt.Data.Models public class DoubleBakingOperation : BaseOperation { public int AccusedLevel { get; set; } + public int SlashedLevel { get; set; } public int AccuserId { get; set; } - public long AccuserReward { get; set; } - public int OffenderId { get; set; } - public long OffenderLoss { get; set; } + + public long Reward { get; set; } + public long LostStaked { get; set; } + public long LostUnstaked { get; set; } + public long LostExternalStaked { get; set; } + public long LostExternalUnstaked { get; set; } + + // it's needed to handle negligent Oxford implementation + public long RoundingLoss { get; set; } #region relations [ForeignKey(nameof(AccuserId))] diff --git a/Tzkt.Data/Models/Operations/DoubleEndorsingOperation.cs b/Tzkt.Data/Models/Operations/DoubleEndorsingOperation.cs index 8dd2329c4..7c507371e 100644 --- a/Tzkt.Data/Models/Operations/DoubleEndorsingOperation.cs +++ b/Tzkt.Data/Models/Operations/DoubleEndorsingOperation.cs @@ -7,12 +7,19 @@ namespace Tzkt.Data.Models public class DoubleEndorsingOperation : BaseOperation { public int AccusedLevel { get; set; } + public int SlashedLevel { get; set; } public int AccuserId { get; set; } - public long AccuserReward { get; set; } - public int OffenderId { get; set; } - public long OffenderLoss { get; set; } + + public long Reward { get; set; } + public long LostStaked { get; set; } + public long LostUnstaked { get; set; } + public long LostExternalStaked { get; set; } + public long LostExternalUnstaked { get; set; } + + // it's needed to handle negligent Oxford implementation + public long RoundingLoss { get; set; } #region relations [ForeignKey(nameof(AccuserId))] diff --git a/Tzkt.Data/Models/Operations/DoublePreendorsingOperation.cs b/Tzkt.Data/Models/Operations/DoublePreendorsingOperation.cs index 37c2c50ae..22e64edca 100644 --- a/Tzkt.Data/Models/Operations/DoublePreendorsingOperation.cs +++ b/Tzkt.Data/Models/Operations/DoublePreendorsingOperation.cs @@ -7,12 +7,19 @@ namespace Tzkt.Data.Models public class DoublePreendorsingOperation : BaseOperation { public int AccusedLevel { get; set; } + public int SlashedLevel { get; set; } public int AccuserId { get; set; } - public long AccuserReward { get; set; } - public int OffenderId { get; set; } - public long OffenderLoss { get; set; } + + public long Reward { get; set; } + public long LostStaked { get; set; } + public long LostUnstaked { get; set; } + public long LostExternalStaked { get; set; } + public long LostExternalUnstaked { get; set; } + + // it's needed to handle negligent Oxford implementation + public long RoundingLoss { get; set; } #region relations [ForeignKey(nameof(AccuserId))] diff --git a/Tzkt.Data/Models/Operations/Fictive/AutostakingOperation.cs b/Tzkt.Data/Models/Operations/Fictive/AutostakingOperation.cs new file mode 100644 index 000000000..ddb82b1a5 --- /dev/null +++ b/Tzkt.Data/Models/Operations/Fictive/AutostakingOperation.cs @@ -0,0 +1,41 @@ +using Microsoft.EntityFrameworkCore; + +namespace Tzkt.Data.Models +{ + public class AutostakingOperation + { + public long Id { get; set; } + public int Level { get; set; } + public int BakerId { get; set; } + public AutostakingAction Action { get; set; } + public int Cycle { get; set; } + public long Amount { get; set; } + } + + public enum AutostakingAction + { + Stake, + Unstake, + Finalize, + Restake + } + + public static class AutostakingOperationModel + { + public static void BuildAutostakingOperationModel(this ModelBuilder modelBuilder) + { + #region keys + modelBuilder.Entity() + .HasKey(x => x.Id); + #endregion + + #region indexes + modelBuilder.Entity() + .HasIndex(x => x.Level); + + modelBuilder.Entity() + .HasIndex(x => x.BakerId); + #endregion + } + } +} diff --git a/Tzkt.Data/Models/Operations/Fictive/EndorsingRewardOperation.cs b/Tzkt.Data/Models/Operations/Fictive/EndorsingRewardOperation.cs index 2d7989a6d..871abd7d6 100644 --- a/Tzkt.Data/Models/Operations/Fictive/EndorsingRewardOperation.cs +++ b/Tzkt.Data/Models/Operations/Fictive/EndorsingRewardOperation.cs @@ -11,7 +11,9 @@ public class EndorsingRewardOperation public int BakerId { get; set; } public long Expected { get; set; } - public long Received { get; set; } + public long RewardLiquid { get; set; } + public long RewardStakedOwn { get; set; } + public long RewardStakedShared { get; set; } } public static class EndorsingRewardOperationModel diff --git a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs index 04b10dbe4..1c69d7fb6 100644 --- a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs +++ b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs @@ -44,7 +44,8 @@ public enum MigrationKind ProposalInvoice, CodeChange, Origination, - Subsidy + Subsidy, + RemoveBigMapKey } public static class MigrationOperationModel diff --git a/Tzkt.Data/Models/Operations/NonceRevelationOperation.cs b/Tzkt.Data/Models/Operations/NonceRevelationOperation.cs index daf8d5b3d..863336acb 100644 --- a/Tzkt.Data/Models/Operations/NonceRevelationOperation.cs +++ b/Tzkt.Data/Models/Operations/NonceRevelationOperation.cs @@ -10,7 +10,9 @@ public class NonceRevelationOperation : BaseOperation public int SenderId { get; set; } public int RevealedLevel { get; set; } public int RevealedCycle { get; set; } - public long Reward { get; set; } + public long RewardLiquid { get; set; } + public long RewardStakedOwn { get; set; } + public long RewardStakedShared { get; set; } public byte[] Nonce { get; set; } #region relations diff --git a/Tzkt.Data/Models/Operations/SmartRollupOriginateOperation.cs b/Tzkt.Data/Models/Operations/SmartRollupOriginateOperation.cs index 23ddf2e7a..9105b3551 100644 --- a/Tzkt.Data/Models/Operations/SmartRollupOriginateOperation.cs +++ b/Tzkt.Data/Models/Operations/SmartRollupOriginateOperation.cs @@ -7,7 +7,6 @@ public class SmartRollupOriginateOperation : ManagerOperation { public PvmKind PvmKind { get; set; } public byte[] Kernel { get; set; } - public byte[] OriginationProof { get; set; } public byte[] ParameterType { get; set; } public string GenesisCommitment { get; set; } public int? SmartRollupId { get; set; } diff --git a/Tzkt.Data/Models/Operations/StakingOperation.cs b/Tzkt.Data/Models/Operations/StakingOperation.cs new file mode 100644 index 000000000..4e7b61891 --- /dev/null +++ b/Tzkt.Data/Models/Operations/StakingOperation.cs @@ -0,0 +1,72 @@ +using Microsoft.EntityFrameworkCore; +using Tzkt.Data.Models.Base; + +namespace Tzkt.Data.Models +{ + public class StakingOperation : ManagerOperation + { + public StakingOperationKind Kind { get; set; } + + public int? BakerId { get; set; } + public long? Amount { get; set; } + public long? Pseudotokens { get; set; } + + public long? PrevStakedBalance { get; set; } + + public int? FirstCycleUnstaked { get; set; } + public int? LastCycleUnstaked { get; set; } + + public long? LimitOfStakingOverBaking { get; set; } + public long? EdgeOfBakingOverStaking { get; set; } + public int? ActivationCycle { get; set; } + } + + public enum StakingOperationKind + { + Stake, + Unstake, + FinalizeUnstake, + SetDelegateParameter + } + + public static class StakingOperationModel + { + public static void BuildStakingOperationModel(this ModelBuilder modelBuilder) + { + #region keys + modelBuilder.Entity() + .HasKey(x => x.Id); + #endregion + + #region props + modelBuilder.Entity() + .Property(x => x.OpHash) + .IsFixedLength(true) + .HasMaxLength(51) + .IsRequired(); + #endregion + + #region indexes + modelBuilder.Entity() + .HasIndex(x => x.Level); + + modelBuilder.Entity() + .HasIndex(x => x.OpHash); + + modelBuilder.Entity() + .HasIndex(x => x.SenderId); + + modelBuilder.Entity() + .HasIndex(x => x.BakerId); + #endregion + + #region relations + modelBuilder.Entity() + .HasOne(x => x.Block) + .WithMany(x => x.StakingOps) + .HasForeignKey(x => x.Level) + .HasPrincipalKey(x => x.Level); + #endregion + } + } +} diff --git a/Tzkt.Data/Models/Operations/VdfRevelationOperation.cs b/Tzkt.Data/Models/Operations/VdfRevelationOperation.cs index 283566efb..9666c7fe1 100644 --- a/Tzkt.Data/Models/Operations/VdfRevelationOperation.cs +++ b/Tzkt.Data/Models/Operations/VdfRevelationOperation.cs @@ -8,7 +8,9 @@ public class VdfRevelationOperation : BaseOperation { public int Cycle { get; set; } public int BakerId { get; set; } - public long Reward { get; set; } + public long RewardLiquid { get; set; } + public long RewardStakedOwn { get; set; } + public long RewardStakedShared { get; set; } public byte[] Solution { get; set; } public byte[] Proof { get; set; } diff --git a/Tzkt.Data/Models/Statistics/Statistics.cs b/Tzkt.Data/Models/Statistics/Statistics.cs index 14bb55236..c6732bc3b 100644 --- a/Tzkt.Data/Models/Statistics/Statistics.cs +++ b/Tzkt.Data/Models/Statistics/Statistics.cs @@ -18,6 +18,7 @@ public class Statistics public long TotalCreated { get; set; } public long TotalBurned { get; set; } public long TotalBanished { get; set; } + public long TotalLost { get; set; } public long TotalFrozen { get; set; } public long TotalRollupBonds { get; set; } diff --git a/Tzkt.Data/Tzkt.Data.csproj b/Tzkt.Data/Tzkt.Data.csproj index cd8c52150..f910bde53 100644 --- a/Tzkt.Data/Tzkt.Data.csproj +++ b/Tzkt.Data/Tzkt.Data.csproj @@ -6,7 +6,7 @@ - + diff --git a/Tzkt.Data/TzktContext.cs b/Tzkt.Data/TzktContext.cs index e9c6db056..c70bd04c8 100644 --- a/Tzkt.Data/TzktContext.cs +++ b/Tzkt.Data/TzktContext.cs @@ -40,6 +40,7 @@ public class TzktContext : DbContext public DbSet OriginationOps { get; set; } public DbSet ProposalOps { get; set; } public DbSet RevealOps { get; set; } + public DbSet StakingOps { get; set; } public DbSet TransactionOps { get; set; } public DbSet RegisterConstantOps { get; set; } public DbSet SetDepositsLimitOps { get; set; } @@ -61,6 +62,7 @@ public class TzktContext : DbContext public DbSet EndorsingRewardOps { get; set; } public DbSet MigrationOps { get; set; } public DbSet RevelationPenaltyOps { get; set; } + public DbSet AutostakingOps { get; set; } public DbSet SmartRollupAddMessagesOps { get; set; } public DbSet SmartRollupCementOps { get; set; } @@ -85,7 +87,6 @@ public class TzktContext : DbContext public DbSet DelegatorCycles { get; set; } public DbSet BakingRights { get; set; } public DbSet SnapshotBalances { get; set; } - public DbSet FreezerUpdates { get; set; } #endregion #region statistics @@ -164,6 +165,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.BuildOriginationOperationModel(); modelBuilder.BuildProposalOperationModel(); modelBuilder.BuildRevealOperationModel(); + modelBuilder.BuildStakingOperationModel(); modelBuilder.BuildTransactionOperationModel(); modelBuilder.BuildRegisterConstantOperationModel(); modelBuilder.BuildSetDepositsLimitOperationModel(); @@ -185,6 +187,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.BuildEndorsingRewardOperationModel(); modelBuilder.BuildMigrationOperationModel(); modelBuilder.BuildRevelationPenaltyOperationModel(); + modelBuilder.BuildAutostakingOperationModel(); modelBuilder.BuildSmartRollupAddMessagesOperationModel(); modelBuilder.BuildSmartRollupCementOperationModel(); @@ -209,7 +212,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.BuildDelegatorCycleModel(); modelBuilder.BuildBakingRightModel(); modelBuilder.BuildSnapshotBalanceModel(); - modelBuilder.BuildFreezerUpdateModel(); #endregion #region statistics diff --git a/Tzkt.Sync.Tests/Database/AppStateTests.cs b/Tzkt.Sync.Tests/Database/AppStateTests.cs index 8497f3469..b6d072e4a 100644 --- a/Tzkt.Sync.Tests/Database/AppStateTests.cs +++ b/Tzkt.Sync.Tests/Database/AppStateTests.cs @@ -63,6 +63,7 @@ public static async Task RunAsync(TzktContext db, TezosRpc rpc) state.RevelationPenaltyOpsCount + state.SetDepositsLimitOpsCount + state.TransactionOpsCount + + state.StakingOpsCount + state.TransferTicketOpsCount + state.TxRollupCommitOpsCount + state.TxRollupDispatchTicketsOpsCount + @@ -74,13 +75,14 @@ public static async Task RunAsync(TzktContext db, TezosRpc rpc) state.TxRollupSubmitBatchOpsCount + state.UpdateConsensusKeyOpsCount + state.VdfRevelationOpsCount + - state.SmartRollupAddMessagesOpsCount + + state.SmartRollupAddMessagesOpsCount + state.SmartRollupCementOpsCount + state.SmartRollupExecuteOpsCount + state.SmartRollupOriginateOpsCount + state.SmartRollupPublishOpsCount + state.SmartRollupRecoverBondOpsCount + - state.SmartRollupRefuteOpsCount; + state.SmartRollupRefuteOpsCount + + state.AutostakingOpsCount; if (state.OperationCounter != opsCount) throw new Exception("Invalid AppState.OperationCounter"); @@ -88,6 +90,7 @@ public static async Task RunAsync(TzktContext db, TezosRpc rpc) var managerOpsCount = await db.DelegationOps.CountAsync(x => x.InitiatorId == null) + await db.OriginationOps.CountAsync(x => x.InitiatorId == null) + await db.TransactionOps.CountAsync(x => x.InitiatorId == null) + + state.StakingOpsCount + state.IncreasePaidStorageOpsCount + state.RegisterConstantOpsCount + state.RevealOpsCount + @@ -196,6 +199,9 @@ await db.TransactionOps.CountAsync(x => x.InitiatorId == null) + if (state.TransactionOpsCount != await db.TransactionOps.CountAsync()) throw new Exception("Invalid AppState.TransactionOpsCount"); + if (state.StakingOpsCount != await db.StakingOps.CountAsync()) + throw new Exception("Invalid AppState.StakingOpsCount"); + if (state.RegisterConstantOpsCount != await db.RegisterConstantOps.CountAsync()) throw new Exception("Invalid AppState.RegisterConstantOpsCount"); @@ -297,6 +303,9 @@ await db.TransactionOps.CountAsync(x => x.InitiatorId == null) + if (state.SmartRollupRefuteOpsCount != await db.SmartRollupRefuteOps.CountAsync()) throw new Exception("Invalid AppState.SmartRollupRefuteOpsCount"); + + if (state.AutostakingOpsCount != await db.AutostakingOps.CountAsync()) + throw new Exception("Invalid AppState.AutostakingOpsCount"); #endregion #region quotes diff --git a/Tzkt.Sync.Tests/Database/StatisticsTests.cs b/Tzkt.Sync.Tests/Database/StatisticsTests.cs index 814b8a911..983c3e350 100644 --- a/Tzkt.Sync.Tests/Database/StatisticsTests.cs +++ b/Tzkt.Sync.Tests/Database/StatisticsTests.cs @@ -21,19 +21,19 @@ public static async Task RunAsync(TzktContext db) if (stats.TotalActivated != totalActivated) throw new Exception("Invalid Statistics.TotalActivated"); - var totalCreated = await db.Blocks.SumAsync(x => x.Reward + x.Bonus); + var totalCreated = await db.Blocks.SumAsync(x => x.RewardLiquid + x.RewardStakedOwn + x.RewardStakedShared + x.BonusLiquid + x.BonusStakedOwn + x.BonusStakedShared); totalCreated += await db.EndorsementOps.SumAsync(x => x.Reward); - totalCreated += await db.EndorsingRewardOps.SumAsync(x => x.Received); - totalCreated += await db.NonceRevelationOps.SumAsync(x => x.Reward); - totalCreated += await db.VdfRevelationOps.SumAsync(x => x.Reward); + totalCreated += await db.EndorsingRewardOps.SumAsync(x => x.RewardLiquid + x.RewardStakedOwn + x.RewardStakedShared); + totalCreated += await db.NonceRevelationOps.SumAsync(x => x.RewardLiquid + x.RewardStakedOwn + x.RewardStakedShared); + totalCreated += await db.VdfRevelationOps.SumAsync(x => x.RewardLiquid + x.RewardStakedOwn + x.RewardStakedShared); totalCreated += await db.MigrationOps.Where(x => x.Kind != MigrationKind.Bootstrap).SumAsync(x => x.BalanceChange); if (stats.TotalCreated != totalCreated) throw new Exception("Invalid Statistics.TotalCreated"); - var totalBurned = await db.DoubleBakingOps.SumAsync(x => x.OffenderLoss - x.AccuserReward); - totalBurned += await db.DoubleEndorsingOps.SumAsync(x => x.OffenderLoss - x.AccuserReward); - totalBurned += await db.DoublePreendorsingOps.SumAsync(x => x.OffenderLoss - x.AccuserReward); + var totalBurned = await db.DoubleBakingOps.SumAsync(x => x.LostStaked + x.LostUnstaked + x.LostExternalStaked + x.LostExternalUnstaked - x.Reward); + totalBurned += await db.DoubleEndorsingOps.SumAsync(x => x.LostStaked + x.LostUnstaked + x.LostExternalStaked + x.LostExternalUnstaked - x.Reward); + totalBurned += await db.DoublePreendorsingOps.SumAsync(x => x.LostStaked + x.LostUnstaked + x.LostExternalStaked + x.LostExternalUnstaked - x.Reward); totalBurned += await db.RevelationPenaltyOps.SumAsync(x => x.Loss); totalBurned += await db.DelegationOps.Where(x => x.Status == OperationStatus.Applied).SumAsync(x => (x.StorageFee ?? 0) + (x.AllocationFee ?? 0)); totalBurned += await db.IncreasePaidStorageOps.Where(x => x.Status == OperationStatus.Applied).SumAsync(x => (x.StorageFee ?? 0) + (x.AllocationFee ?? 0)); @@ -64,12 +64,19 @@ public static async Task RunAsync(TzktContext db) if (stats.TotalBurned != totalBurned) throw new Exception("Invalid Statistics.TotalBurned"); + var totalLost = await db.DoubleBakingOps.SumAsync(x => x.RoundingLoss); + totalLost += await db.DoubleEndorsingOps.SumAsync(x => x.RoundingLoss); + totalLost += await db.DoublePreendorsingOps.SumAsync(x => x.RoundingLoss); + + if (stats.TotalLost != totalLost) + throw new Exception("Invalid Statistics.TotalLost"); + var totalBanished = await db.Accounts.Where(x => x.Id == 1).SumAsync(x => x.Balance); if (stats.TotalBanished != totalBanished) throw new Exception("Invalid Statistics.TotalBanished"); - var totalFrozen = await db.Delegates.SumAsync(x => x.FrozenDeposit); + var totalFrozen = await db.Delegates.SumAsync(x => x.StakedBalance + x.ExternalStakedBalance); if (stats.TotalFrozen != totalFrozen) throw new Exception("Invalid Statistics.TotalFrozen"); @@ -87,9 +94,10 @@ public static async Task RunAsync(TzktContext db) throw new Exception("Invalid Statistics.TotalSmartRollupBonds"); var totalBalances = await db.Accounts.SumAsync(x => x.Balance); + var pendingRewards = await db.Delegates.SumAsync(x => x.ExternalStakedBalance) - await db.Users.Where(x => x.Type == AccountType.User).SumAsync(x => x.StakedBalance); var totalBalancesStats = stats.TotalBootstrapped + stats.TotalActivated + stats.TotalCreated - stats.TotalBurned; - if (totalBalancesStats != totalBalances) + if (totalBalancesStats != totalBalances + pendingRewards) throw new Exception("Invalid Statistics.TotalBalances"); } } diff --git a/Tzkt.Sync/Extensions/BigIntegerExtension.cs b/Tzkt.Sync/Extensions/BigIntegerExtension.cs new file mode 100644 index 000000000..a7d44a743 --- /dev/null +++ b/Tzkt.Sync/Extensions/BigIntegerExtension.cs @@ -0,0 +1,12 @@ +using System.Numerics; + +namespace Tzkt.Sync +{ + static class BigIntegerExtension + { + public static long TrimToInt64(this BigInteger value) + { + return value > long.MaxValue ? long.MaxValue : value < long.MinValue ? long.MinValue : (long)value; + } + } +} diff --git a/Tzkt.Sync/Extensions/JsonElementExtension.cs b/Tzkt.Sync/Extensions/JsonElementExtension.cs index 6b32ed447..3d48bed89 100644 --- a/Tzkt.Sync/Extensions/JsonElementExtension.cs +++ b/Tzkt.Sync/Extensions/JsonElementExtension.cs @@ -141,6 +141,12 @@ public static BigInteger RequiredBigInteger(this JsonElement el, string name) : throw new SerializationException($"Missed required BigInteger {name}"); } + public static bool TryGetBigInteger(this JsonElement el, string name, out BigInteger res) + { + res = BigInteger.Zero; + return el.TryGetProperty(name, out var prop) && BigInteger.TryParse(prop.GetString(), out res); + } + public static int ParseInt32(this JsonElement el) { return el.ValueKind == JsonValueKind.String diff --git a/Tzkt.Sync/Protocols/Abstract/IDiagnostics.cs b/Tzkt.Sync/Protocols/Abstract/IDiagnostics.cs index fc4dab9b0..2d6c2bfd4 100644 --- a/Tzkt.Sync/Protocols/Abstract/IDiagnostics.cs +++ b/Tzkt.Sync/Protocols/Abstract/IDiagnostics.cs @@ -1,10 +1,10 @@ using System.Text.Json; -using System.Threading.Tasks; namespace Tzkt.Sync.Protocols { public interface IDiagnostics { + void TrackChanges(); Task Run(JsonElement block); Task Run(int level); } diff --git a/Tzkt.Sync/Protocols/Abstract/IRpc.cs b/Tzkt.Sync/Protocols/Abstract/IRpc.cs index 8710224b2..b924e10c9 100644 --- a/Tzkt.Sync/Protocols/Abstract/IRpc.cs +++ b/Tzkt.Sync/Protocols/Abstract/IRpc.cs @@ -1,5 +1,4 @@ using System.Text.Json; -using System.Threading.Tasks; namespace Tzkt.Sync.Protocols { @@ -14,8 +13,9 @@ public interface IRpc Task GetContractAsync(int level, string address); Task GetDelegateAsync(int level, string address); Task GetStakeDistribution(int block, int cycle); + Task GetExpectedIssuance(int level); #endregion - + #region diagnostics Task GetGlobalCounterAsync(int level); Task GetDelegatesAsync(int level); @@ -23,6 +23,8 @@ public interface IRpc Task GetDelegateParticipationAsync(int level, string address); Task GetCycleAsync(int level, int cycle); Task GetTicketBalance(int level, string address, string ticket); + Task GetCurrentStakingBalance(int level, string address); + Task GetStakingParameters(int level, string address); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Genesis/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Genesis/Diagnostics/Diagnostics.cs index 4786dd60f..56ca11367 100644 --- a/Tzkt.Sync/Protocols/Handlers/Genesis/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Genesis/Diagnostics/Diagnostics.cs @@ -5,6 +5,7 @@ namespace Tzkt.Sync.Protocols.Genesis { class Diagnostics : IDiagnostics { + public void TrackChanges() { } public Task Run(JsonElement block) => Task.CompletedTask; public Task Run(int level) => Task.CompletedTask; } diff --git a/Tzkt.Sync/Protocols/Handlers/Genesis/GenesisHandler.cs b/Tzkt.Sync/Protocols/Handlers/Genesis/GenesisHandler.cs index 5cf3eb18a..ee25ed991 100644 --- a/Tzkt.Sync/Protocols/Handlers/Genesis/GenesisHandler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Genesis/GenesisHandler.cs @@ -64,7 +64,7 @@ public override Task Commit(JsonElement rawBlock) #region add empty stats var stats = new Statistics(); Db.Statistics.Add(stats); - Cache.Statistics.Add(stats); + Cache.Statistics.SetCurrent(stats); #endregion #region update state @@ -91,7 +91,7 @@ await Db.Database.ExecuteSqlRawAsync(@" DELETE FROM ""Protocols""; DELETE FROM ""Blocks"";"); - Cache.Statistics.Reset(); + await Cache.Statistics.ResetAsync(); Cache.Protocols.Reset(); Cache.Blocks.Reset(); diff --git a/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs index 6c07449bb..c8c33b5af 100644 --- a/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs @@ -1,6 +1,4 @@ -using System; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Tzkt.Sync.Services; namespace Tzkt.Sync.Protocols.Genesis @@ -35,6 +33,9 @@ public Task GetDelegateAsync(int level, string address) public Task GetStakeDistribution(int block, int cycle) => throw new InvalidOperationException(); + + public Task GetExpectedIssuance(int level) + => throw new InvalidOperationException(); #endregion #region diagnostics @@ -55,6 +56,12 @@ public Task GetDelegateParticipationAsync(int level, string address public Task GetTicketBalance(int level, string address, string ticket) => throw new InvalidOperationException(); + + public Task GetCurrentStakingBalance(int level, string address) + => throw new InvalidOperationException(); + + public Task GetStakingParameters(int level, string address) + => throw new InvalidOperationException(); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Initiator/InitiatorHandler.cs b/Tzkt.Sync/Protocols/Handlers/Initiator/InitiatorHandler.cs index 6140aef2e..4d9d510e1 100644 --- a/Tzkt.Sync/Protocols/Handlers/Initiator/InitiatorHandler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Initiator/InitiatorHandler.cs @@ -70,7 +70,7 @@ public override Task Commit(JsonElement rawBlock) #region add empty stats var stats = new Statistics { Level = block.Level }; Db.Statistics.Add(stats); - Cache.Statistics.Add(stats); + Cache.Statistics.SetCurrent(stats); #endregion #region update state @@ -103,7 +103,7 @@ await Db.Database.ExecuteSqlRawAsync($@" DELETE FROM ""Protocols"" WHERE ""FirstLevel"" = {curr.Level}; DELETE FROM ""Blocks"" WHERE ""Level"" = {curr.Level};"); - Cache.Statistics.Reset(); + await Cache.Statistics.ResetAsync(); Cache.Protocols.Reset(); Cache.Blocks.Reset(); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Accounts.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Accounts.cs index 0184ee0f8..32d0f7523 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Accounts.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Accounts.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Netezos.Contracts; using Netezos.Encoding; using Netezos.Keys; @@ -25,11 +21,20 @@ protected virtual async Task> BootstrapAccounts(Protocol protocol, x["amount"].Value(), x["delegate"]?.Value() ?? null, x["script"]["code"].ToString(), - x["script"]["storage"].ToString()) - ) + x["script"]["storage"].ToString(), + x["hash"]?.Value() ?? null + )) .ToList() ?? new(0); - var accounts = new List(bootstrapAccounts.Count + bootstrapContracts.Count); + var bootstrapSmartRollups = parameters["bootstrap_smart_rollups"]? + .Select(x => + ( + x["address"].Value(), + x["pvm_kind"].Value() + )) + .ToList() ?? new(0); + + var accounts = new List(bootstrapAccounts.Count + bootstrapContracts.Count + bootstrapSmartRollups.Count); #region allocate null-address var nullAddress = (User)await Cache.Accounts.GetAsync(NullAddress.Address); @@ -48,8 +53,6 @@ protected virtual async Task> BootstrapAccounts(Protocol protocol, Address = PubKey.FromBase58(pubKey).Address, Balance = balance, StakingBalance = balance, - DelegatedBalance = 0, - Counter = 0, PublicKey = pubKey, FirstLevel = 1, LastLevel = 1, @@ -74,15 +77,15 @@ protected virtual async Task> BootstrapAccounts(Protocol protocol, Id = Cache.AppState.NextAccountId(), Address = PubKey.FromBase58(pubKey).Address, Balance = balance, - Counter = 0, FirstLevel = 1, LastLevel = 1, Type = AccountType.User, PublicKey = pubKey, - Revealed = true, + Revealed = true, Staked = true, DelegationLevel = 1, - Delegate = delegat + Delegate = delegat, + DelegateId = delegat.Id }; delegat.DelegatorsCount++; @@ -102,7 +105,6 @@ protected virtual async Task> BootstrapAccounts(Protocol protocol, Id = Cache.AppState.NextAccountId(), Address = pkh, Balance = balance, - Counter = 0, FirstLevel = 1, LastLevel = 1, Type = AccountType.User @@ -114,7 +116,7 @@ protected virtual async Task> BootstrapAccounts(Protocol protocol, #region bootstrap contracts var index = 0; - foreach (var (balance, delegatePkh, codeStr, storageStr) in bootstrapContracts) + foreach (var (balance, delegatePkh, codeStr, storageStr, hash) in bootstrapContracts) { #region contract var delegat = Cache.Accounts.GetDelegate(delegatePkh); @@ -123,9 +125,8 @@ protected virtual async Task> BootstrapAccounts(Protocol protocol, var contract = new Contract { Id = Cache.AppState.NextAccountId(), - Address = OriginationNonce.GetContractAddress(index++), + Address = hash ?? OriginationNonce.GetContractAddress(index++), Balance = balance, - Counter = 0, FirstLevel = 1, LastLevel = 1, Spendable = false, @@ -216,6 +217,45 @@ protected virtual async Task> BootstrapAccounts(Protocol protocol, } #endregion + #region bootstrap smart rollups + foreach (var (address, pvmKind) in bootstrapSmartRollups) + { + var creator = nullAddress; + var rollup = new SmartRollup() + { + Id = Cache.AppState.NextAccountId(), + FirstLevel = 1, + LastLevel = 1, + Address = address, + Balance = 0, + CreatorId = creator.Id, + Staked = false, + Type = AccountType.SmartRollup, + PvmKind = pvmKind switch + { + "arith" => PvmKind.Arith, + "wasm_2_0_0" => PvmKind.Wasm, + _ => throw new NotImplementedException() + }, + GenesisCommitment = "genesis_commitment_hash", // this should be calculated from Machine.install_boot_sector and Machine.state_hash, + LastCommitment = "genesis_commitment_hash", // but that cannot be done on the indexer side, so we set a random string + InboxLevel = 2, + TotalStakers = 0, + ActiveStakers = 0, + ExecutedCommitments = 0, + CementedCommitments = 0, + PendingCommitments = 0, + RefutedCommitments = 0, + OrphanCommitments = 0, + SmartRollupBonds = 0 + }; + Cache.Accounts.Add(rollup); + accounts.Add(rollup); + + creator.SmartRollupsCount++; + } + #endregion + Db.Accounts.AddRange(accounts); #region migration ops @@ -260,8 +300,7 @@ protected virtual async Task> BootstrapAccounts(Protocol protocol, #endregion #region statistics - var stats = await Cache.Statistics.GetAsync(1); - stats.TotalBootstrapped = accounts.Sum(x => x.Balance); + Cache.Statistics.Current.TotalBootstrapped = accounts.Sum(x => x.Balance); #endregion return accounts; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.BakerCycles.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.BakerCycles.cs index 45655f91b..d3b55669e 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.BakerCycles.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.BakerCycles.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto1 @@ -20,30 +16,33 @@ public virtual void BootstrapBakerCycles( .Where(x => x.Type == AccountType.Delegate) .Select(x => x as Data.Models.Delegate); - var selectedStake = bakers.Sum(x => x.StakingBalance - x.StakingBalance % protocol.TokensPerRoll); + var totalPower = bakers.Sum(x => x.StakingBalance - x.StakingBalance % protocol.MinimalStake); - for (int cycle = 0; cycle <= protocol.PreservedCycles; cycle++) + foreach (var cycle in cycles) { var bakerCycles = bakers.ToDictionary(x => x.Id, x => { - var activeStake = x.StakingBalance - x.StakingBalance % protocol.TokensPerRoll; - var share = (double)activeStake / selectedStake; + var bakingPower = x.StakingBalance - x.StakingBalance % protocol.MinimalStake; + var share = (double)bakingPower / totalPower; return new BakerCycle { - Cycle = cycle, + Cycle = cycle.Index, BakerId = x.Id, - StakingBalance = x.StakingBalance, - ActiveStake = activeStake, - SelectedStake = selectedStake, - DelegatedBalance = x.DelegatedBalance, + OwnDelegatedBalance = x.Balance, + ExternalDelegatedBalance = x.DelegatedBalance, DelegatorsCount = x.DelegatorsCount, + OwnStakedBalance = x.StakedBalance, + ExternalStakedBalance = x.ExternalStakedBalance, + StakersCount = x.StakersCount, + BakingPower = bakingPower, + TotalBakingPower = totalPower, ExpectedBlocks = protocol.BlocksPerCycle * share, ExpectedEndorsements = protocol.EndorsersPerBlock * protocol.BlocksPerCycle * share }; }); #region future baking rights - foreach (var br in bakingRights[cycle].SkipWhile(x => x.Level == 1)) // skip bootstrap block rights + foreach (var br in bakingRights[cycle.Index].SkipWhile(x => x.Level == 1)) // skip bootstrap block rights { if (br.Round > 0) continue; @@ -52,33 +51,32 @@ public virtual void BootstrapBakerCycles( throw new Exception("Unknown baking right recipient"); bakerCycle.FutureBlocks++; - bakerCycle.FutureBlockRewards += GetFutureBlockReward(protocol, cycle); + bakerCycle.FutureBlockRewards += GetFutureBlockReward(protocol, cycle.Index); } #endregion #region future endorsing rights - var skipLevel = endorsingRights[cycle].Last().Level; // skip shifted rights - foreach (var er in endorsingRights[cycle].TakeWhile(x => x.Level < skipLevel)) + var skipLevel = endorsingRights[cycle.Index].Last().Level; // skip shifted rights + foreach (var er in endorsingRights[cycle.Index].TakeWhile(x => x.Level < skipLevel)) { if (!bakerCycles.TryGetValue(er.Baker, out var bakerCycle)) throw new Exception("Unknown endorsing right recipient"); bakerCycle.FutureEndorsements += er.Slots; - bakerCycle.FutureEndorsementRewards += GetFutureEndorsementReward(protocol, cycle, er.Slots); + bakerCycle.FutureEndorsementRewards += GetFutureEndorsementReward(protocol, cycle.Index, er.Slots); } #endregion #region shifted future endirsing rights - if (cycle > 0) + if (cycle.Index > 0) { - var shiftedLevel = endorsingRights[cycle - 1].Last().Level; - foreach (var er in endorsingRights[cycle - 1].Reverse().TakeWhile(x => x.Level == shiftedLevel)) + foreach (var er in endorsingRights[cycle.Index - 1].Reverse().TakeWhile(x => x.Level == cycle.FirstLevel - 1)) { if (!bakerCycles.TryGetValue(er.Baker, out var bakerCycle)) throw new Exception("Unknown endorsing right recipient"); bakerCycle.FutureEndorsements += er.Slots; - bakerCycle.FutureEndorsementRewards += GetFutureEndorsementReward(protocol, cycle, er.Slots); + bakerCycle.FutureEndorsementRewards += GetFutureEndorsementReward(protocol, cycle.Index, er.Slots); } } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Commitments.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Commitments.cs index a01b8526a..93d9f4bbf 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Commitments.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Commitments.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Newtonsoft.Json.Linq; using Npgsql; using Tzkt.Data.Models; @@ -10,7 +7,7 @@ namespace Tzkt.Sync.Protocols.Proto1 { partial class ProtoActivator : ProtocolCommit { - async Task BootstrapCommitments(JToken parameters) + void BootstrapCommitments(JToken parameters) { var commitments = parameters["commitments"]?.Select(x => new Commitment { @@ -21,7 +18,7 @@ async Task BootstrapCommitments(JToken parameters) if (commitments != null) { var state = Cache.AppState.Get(); - var statistics = await Cache.Statistics.GetAsync(1); + var statistics = Cache.Statistics.Current; var conn = Db.Database.GetDbConnection() as NpgsqlConnection; using var writer = conn.BeginBinaryImport(@"COPY ""Commitments"" (""Balance"", ""Address"") FROM STDIN (FORMAT BINARY)"); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Cycles.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Cycles.cs index 477e410f4..aa0aac789 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Cycles.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Cycles.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Netezos.Encoding; using Newtonsoft.Json.Linq; using Tzkt.Data.Models; @@ -17,13 +13,9 @@ public virtual List BootstrapCycles(Protocol protocol, List acco var delegates = accounts .Where(x => x.Type == AccountType.Delegate) .Select(x => x as Data.Models.Delegate); - - var totalStake = delegates.Sum(x => x.StakingBalance); - var totalDelegated = delegates.Sum(x => x.DelegatedBalance); - var totalDelegators = delegates.Sum(x => x.DelegatorsCount); - var totalBakers = delegates.Count(); - var selectedStake = delegates.Sum(x => x.StakingBalance - x.StakingBalance % protocol.TokensPerRoll); - var selectedBakers = delegates.Count(x => x.StakingBalance >= protocol.TokensPerRoll); + var selected = delegates.Where(x => x.StakingBalance >= protocol.MinimalStake); + var selectedBakers = selected.Count(); + var selectedStaking = selected.Sum(x => x.StakingBalance - x.StakingBalance % protocol.MinimalStake); var base58Seed = parameters["initial_seed"]?.Value(); if (!Base58.TryParse(base58Seed, new byte[3], out var initialSeed) || initialSeed.Length != 32) @@ -39,12 +31,8 @@ public virtual List BootstrapCycles(Protocol protocol, List acco LastLevel = protocol.GetCycleEnd(index), SnapshotIndex = 0, SnapshotLevel = 1, - TotalStaking = totalStake, - TotalDelegated = totalDelegated, - TotalDelegators = totalDelegators, - TotalBakers = totalBakers, - SelectedStake = selectedStake, - SelectedBakers = selectedBakers, + TotalBakers = selectedBakers, + TotalBakingPower = selectedStaking, Seed = seeds[index] }; Db.Cycles.Add(cycle); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.DelegatorCycles.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.DelegatorCycles.cs index 1101db4b3..33beee679 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.DelegatorCycles.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.DelegatorCycles.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto1 @@ -16,9 +13,10 @@ public void BootstrapDelegatorCycles(Protocol protocol, List accounts) .Select(x => new DelegatorCycle { Cycle = cycle, + DelegatorId = x.Id, BakerId = (int)x.DelegateId, - Balance = x.Balance, - DelegatorId = x.Id + DelegatedBalance = x.Balance, + StakedBalance = (x as User)?.StakedBalance ?? 0 })); } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Protocol.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Protocol.cs index cc1980ebf..8a5f67fcf 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Protocol.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Protocol.cs @@ -59,9 +59,8 @@ protected virtual void SetParameters(Protocol protocol, JToken parameters) protocol.HardOperationStorageLimit = parameters["hard_storage_limit_per_operation"]?.Value() ?? 60_000; protocol.OriginationSize = (parameters["origination_burn"]?.Value() ?? 257_000) / protocol.ByteCost; protocol.PreservedCycles = parameters["preserved_cycles"]?.Value() ?? 5; - protocol.RevelationReward = parameters["seed_nonce_revelation_tip"]?.Value() ?? 125_000; protocol.TimeBetweenBlocks = parameters["time_between_blocks"]?[0].Value() ?? 60; - protocol.TokensPerRoll = parameters["tokens_per_roll"]?.Value() ?? 10_000_000_000; + protocol.MinimalStake = parameters["tokens_per_roll"]?.Value() ?? 10_000_000_000; protocol.BallotQuorumMin = 0; protocol.BallotQuorumMax = 10000; protocol.ProposalQuorum = 0; @@ -100,26 +99,19 @@ public async Task UpgradeProtocol(AppState state) HardOperationStorageLimit = prev.HardOperationStorageLimit, OriginationSize = prev.OriginationSize, PreservedCycles = prev.PreservedCycles, - RevelationReward = prev.RevelationReward, TimeBetweenBlocks = prev.TimeBetweenBlocks, - TokensPerRoll = prev.TokensPerRoll, + MinimalStake = prev.MinimalStake, BallotQuorumMin = prev.BallotQuorumMin, BallotQuorumMax = prev.BallotQuorumMax, ProposalQuorum = prev.ProposalQuorum, - LBSubsidy = prev.LBSubsidy, LBToggleThreshold = prev.LBToggleThreshold, ConsensusThreshold = prev.ConsensusThreshold, - DoubleBakingPunishment = prev.DoubleBakingPunishment, - DoubleEndorsingPunishmentDenominator = prev.DoubleEndorsingPunishmentDenominator, - DoubleEndorsingPunishmentNumerator = prev.DoubleEndorsingPunishmentNumerator, - FrozenDepositsPercentage = prev.FrozenDepositsPercentage, + MaxDelegatedOverFrozenRatio = prev.MaxDelegatedOverFrozenRatio, MaxBakingReward = prev.MaxBakingReward, MaxEndorsingReward = prev.MaxEndorsingReward, MaxSlashingPeriod = prev.MaxSlashingPeriod, MinParticipationDenominator = prev.MinParticipationDenominator, MinParticipationNumerator = prev.MinParticipationNumerator, - TxRollupCommitmentBond = prev.TxRollupCommitmentBond, - TxRollupOriginationSize = prev.TxRollupOriginationSize, Dictator = prev.Dictator, SmartRollupChallengeWindow = prev.SmartRollupChallengeWindow, SmartRollupCommitmentPeriod = prev.SmartRollupCommitmentPeriod, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.SnapshotBalances.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.SnapshotBalances.cs index 321b5f172..18e4e19d5 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.SnapshotBalances.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.SnapshotBalances.cs @@ -1,28 +1,38 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Tzkt.Data; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto1 { partial class ProtoActivator : ProtocolCommit { - public virtual void BootstrapSnapshotBalances(List accounts) + public void BootstrapSnapshotBalances(List accounts) { - Db.SnapshotBalances.AddRange(accounts.Where(x => x.Staked) + Db.SnapshotBalances.AddRange(accounts + .Where(x => x.Staked) .Select(x => new SnapshotBalance { - AccountId = x.Id, - Balance = x.Balance, - DelegateId = x.DelegateId, - Level = 1 + Level = 1, + AccountId = x.Id, + + BakerId = x.DelegateId ?? x.Id, + + OwnDelegatedBalance = x.Balance, + ExternalDelegatedBalance = (x as Data.Models.Delegate)?.DelegatedBalance ?? 0, + DelegatorsCount = (x as Data.Models.Delegate)?.DelegatorsCount ?? 0, + + OwnStakedBalance = (x as User)?.StakedBalance ?? 0, + ExternalStakedBalance = (x as Data.Models.Delegate)?.ExternalStakedBalance ?? 0, + StakersCount = (x as Data.Models.Delegate)?.StakersCount ?? 0, + + StakedPseudotokens = (x as User)?.StakedPseudotokens ?? 0, + IssuedPseudotokens = (x as Data.Models.Delegate)?.IssuedPseudotokens ?? 0 })); } public async Task ClearSnapshotBalances() { - await Db.Database.ExecuteSqlRawAsync(@"DELETE FROM ""SnapshotBalances"""); + await Db.Database.ExecuteSqlRawAsync($@"DELETE FROM ""{nameof(TzktContext.SnapshotBalances)}"""); } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Voting.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Voting.cs index f3e53c28a..991165600 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Voting.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.Voting.cs @@ -54,7 +54,7 @@ await Db.Database.ExecuteSqlRawAsync(@" protected virtual long GetVotingPower(Data.Models.Delegate baker, Protocol protocol) { - return baker.StakingBalance - baker.StakingBalance % protocol.TokensPerRoll; + return baker.StakingBalance - baker.StakingBalance % protocol.MinimalStake; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.cs index 13b51ee72..13ed9edf2 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Activation/ProtoActivator.cs @@ -1,5 +1,4 @@ using System.Text.Json; -using System.Threading.Tasks; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto1 @@ -17,11 +16,11 @@ public async Task Activate(AppState state, JsonElement rawBlock) var accounts = await BootstrapAccounts(protocol, parameters); var cycles = BootstrapCycles(protocol, accounts, parameters); var (bakingRights, endorsingRights) = await BootstrapBakingRights(protocol, accounts, cycles); - BootstrapDelegatorCycles(protocol, accounts); - BootstrapBakerCycles(protocol, accounts, cycles, bakingRights, endorsingRights); BootstrapSnapshotBalances(accounts); + BootstrapBakerCycles(protocol, accounts, cycles, bakingRights, endorsingRights); + BootstrapDelegatorCycles(protocol, accounts); BootstrapVoting(protocol, accounts); - await BootstrapCommitments(parameters); + BootstrapCommitments(parameters); await ActivateContext(state); } else // upgrade diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/BakerCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/BakerCycleCommit.cs index 6301f7d8f..c9e306c52 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/BakerCycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/BakerCycleCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -17,7 +13,7 @@ public virtual async Task Apply( Cycle futureCycle, IEnumerable futureBakingRights, IEnumerable futureEndorsingRights, - Dictionary snapshots, + List snapshots, List currentRights) { #region current rights @@ -100,7 +96,7 @@ public virtual async Task Apply( : successReward; if (endorsingRight.Status == BakingRightStatus.Realized) - bakerCycle.EndorsementRewards += successReward; + bakerCycle.EndorsementRewardsLiquid += successReward; else if (endorsingRight.Status == BakingRightStatus.Missed) bakerCycle.MissedEndorsementRewards += successReward; else @@ -134,7 +130,7 @@ public virtual async Task Apply( if (actualReward > 0) { - bakerCycle.BlockRewards += actualReward; + bakerCycle.BlockRewardsLiquid += actualReward; } if (successReward != actualReward) @@ -176,12 +172,12 @@ public virtual async Task Apply( var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.Offender.Id); Db.TryAttach(offenderCycle); - offenderCycle.DoubleBakingLosses += op.OffenderLoss; + offenderCycle.DoubleBakingLostStaked += op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Accuser.Id); Db.TryAttach(accuserCycle); - accuserCycle.DoubleBakingRewards += op.AccuserReward; + accuserCycle.DoubleBakingRewards += op.Reward; } } @@ -193,12 +189,12 @@ public virtual async Task Apply( var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.Offender.Id); Db.TryAttach(offenderCycle); - offenderCycle.DoubleEndorsingLosses += op.OffenderLoss; + offenderCycle.DoubleEndorsingLostStaked += op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Accuser.Id); Db.TryAttach(accuserCycle); - accuserCycle.DoubleEndorsingRewards += op.AccuserReward; + accuserCycle.DoubleEndorsingRewards += op.Reward; } } @@ -209,7 +205,7 @@ public virtual async Task Apply( var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Baker.Id); Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards += op.Reward; + bakerCycle.NonceRevelationRewardsLiquid += op.RewardLiquid; } } @@ -221,7 +217,7 @@ public virtual async Task Apply( var penaltyCycle = await Cache.BakerCycles.GetAsync(penaltyBlock.Cycle, op.Baker.Id); Db.TryAttach(penaltyCycle); - penaltyCycle.RevelationLosses += op.Loss; + penaltyCycle.NonceRevelationLosses += op.Loss; } } #endregion @@ -230,23 +226,25 @@ public virtual async Task Apply( if (block.Events.HasFlag(BlockEvents.CycleBegin)) { var bakerCycles = new Dictionary(snapshots.Count); - foreach (var kv in snapshots) + foreach (var snapshot in snapshots) { - var baker = await Cache.Accounts.GetAsync(kv.Key); // WTF: rights were given to non-baker accounts - var snapshot = snapshots[kv.Key]; + var baker = await Cache.Accounts.GetAsync(snapshot.AccountId); // WTF: rights were given to non-baker accounts - var activeStake = snapshot.StakingBalance - snapshot.StakingBalance % block.Protocol.TokensPerRoll; - var share = (double)activeStake / futureCycle.SelectedStake; + var bakingPower = snapshot.StakingBalance - snapshot.StakingBalance % block.Protocol.MinimalStake; + var share = (double)bakingPower / futureCycle.TotalBakingPower; var bakerCycle = new BakerCycle { Cycle = futureCycle.Index, - BakerId = kv.Key, - StakingBalance = snapshot.StakingBalance, - ActiveStake = activeStake, - SelectedStake = futureCycle.SelectedStake, - DelegatedBalance = snapshot.DelegatedBalance, + BakerId = snapshot.AccountId, + OwnDelegatedBalance = snapshot.OwnDelegatedBalance, + ExternalDelegatedBalance = snapshot.ExternalDelegatedBalance, DelegatorsCount = snapshot.DelegatorsCount, + OwnStakedBalance = snapshot.OwnStakedBalance, + ExternalStakedBalance = snapshot.ExternalStakedBalance, + StakersCount = snapshot.StakersCount, + BakingPower = bakingPower, + TotalBakingPower = futureCycle.TotalBakingPower, ExpectedBlocks = block.Protocol.BlocksPerCycle * share, ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share }; @@ -316,18 +314,22 @@ public virtual async Task Apply( throw new Exception("Deactivated baker got baking rights"); var stakingBalance = snapshottedBaker.RequiredInt64("staking_balance"); - var activeStake = stakingBalance - stakingBalance % block.Protocol.TokensPerRoll; - var share = (double)activeStake / futureCycle.SelectedStake; + var delegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"); + var bakingPower = stakingBalance - stakingBalance % block.Protocol.MinimalStake; + var share = (double)bakingPower / futureCycle.TotalBakingPower; bakerCycle = new BakerCycle { Cycle = futureCycle.Index, BakerId = baker.Id, - StakingBalance = stakingBalance, - ActiveStake = activeStake, - SelectedStake = futureCycle.SelectedStake, - DelegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"), + OwnDelegatedBalance = stakingBalance - delegatedBalance, + ExternalDelegatedBalance = delegatedBalance, DelegatorsCount = delegators.Count(), + OwnStakedBalance = 0, + ExternalStakedBalance = 0, + StakersCount = 0, + BakingPower = bakingPower, + TotalBakingPower = futureCycle.TotalBakingPower, ExpectedBlocks = block.Protocol.BlocksPerCycle * share, ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share }; @@ -338,10 +340,11 @@ public virtual async Task Apply( var snapshottedDelegator = await Proto.Rpc.GetContractAsync(futureCycle.SnapshotLevel, delegatorAddress); Db.DelegatorCycles.Add(new DelegatorCycle { - BakerId = baker.Id, - Balance = snapshottedDelegator.RequiredInt64("balance"), Cycle = futureCycle.Index, - DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id + DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id, + BakerId = baker.Id, + DelegatedBalance = snapshottedDelegator.RequiredInt64("balance"), + StakedBalance = 0 }); } #endregion @@ -358,12 +361,13 @@ public virtual async Task Apply( if (block.Cycle > 0) { //one-way change... - await Db.Database.ExecuteSqlRawAsync($@" - DELETE FROM ""BakerCycles"" as bc - USING ""Accounts"" as acc - WHERE acc.""Id"" = bc.""BakerId"" - AND bc.""Cycle"" = {block.Cycle - 1} - AND acc.""Type"" != {(int)AccountType.Delegate}"); + await Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "BakerCycles" as bc + USING "Accounts" as acc + WHERE acc."Id" = bc."BakerId" + AND bc."Cycle" = {block.Cycle - 1} + AND acc."Type" != {(int)AccountType.Delegate} + """); } #endregion } @@ -459,7 +463,7 @@ public virtual async Task Revert(Block block) : successReward; if (endorsingRight.Status == BakingRightStatus.Realized) - bakerCycle.EndorsementRewards -= successReward; + bakerCycle.EndorsementRewardsLiquid -= successReward; else if (endorsingRight.Status == BakingRightStatus.Missed) bakerCycle.MissedEndorsementRewards -= successReward; else @@ -493,7 +497,7 @@ public virtual async Task Revert(Block block) if (actualReward > 0) { - bakerCycle.BlockRewards -= actualReward; + bakerCycle.BlockRewardsLiquid -= actualReward; } if (successReward != actualReward) @@ -535,12 +539,12 @@ public virtual async Task Revert(Block block) var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.OffenderId); Db.TryAttach(offenderCycle); - offenderCycle.DoubleBakingLosses -= op.OffenderLoss; + offenderCycle.DoubleBakingLostStaked -= op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.AccuserId); Db.TryAttach(accuserCycle); - accuserCycle.DoubleBakingRewards -= op.AccuserReward; + accuserCycle.DoubleBakingRewards -= op.Reward; } } @@ -552,12 +556,12 @@ public virtual async Task Revert(Block block) var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.OffenderId); Db.TryAttach(offenderCycle); - offenderCycle.DoubleEndorsingLosses -= op.OffenderLoss; + offenderCycle.DoubleEndorsingLostStaked -= op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.AccuserId); Db.TryAttach(accuserCycle); - accuserCycle.DoubleEndorsingRewards -= op.AccuserReward; + accuserCycle.DoubleEndorsingRewards -= op.Reward; } } @@ -568,7 +572,7 @@ public virtual async Task Revert(Block block) var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.BakerId); Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards -= op.Reward; + bakerCycle.NonceRevelationRewardsLiquid -= op.RewardLiquid; } } @@ -580,7 +584,7 @@ public virtual async Task Revert(Block block) var penaltyCycle = await Cache.BakerCycles.GetAsync(penaltyBlock.Cycle, op.BakerId); Db.TryAttach(penaltyCycle); - penaltyCycle.RevelationLosses -= op.Loss; + penaltyCycle.NonceRevelationLosses -= op.Loss; } } #endregion @@ -588,9 +592,10 @@ public virtual async Task Revert(Block block) #region new cycle if (block.Events.HasFlag(BlockEvents.CycleBegin)) { - await Db.Database.ExecuteSqlRawAsync($@" - DELETE FROM ""BakerCycles"" - WHERE ""Cycle"" = {block.Cycle + block.Protocol.PreservedCycles}"); + await Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "BakerCycles" + WHERE "Cycle" = {block.Cycle + block.Protocol.PreservedCycles} + """); } #endregion } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/BlockCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/BlockCommit.cs index ab335d705..b1cff5ccc 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/BlockCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/BlockCommit.cs @@ -1,6 +1,4 @@ -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto1 @@ -52,7 +50,7 @@ public virtual async Task Apply(JsonElement rawBlock) ProposerId = baker.Id, ProducerId = baker.Id, Events = events, - Reward = reward, + RewardLiquid = reward, Deposit = deposit, LBToggle = GetLBToggleVote(rawBlock), LBToggleEma = GetLBToggleEma(rawBlock) @@ -64,7 +62,7 @@ public virtual async Task Apply(JsonElement rawBlock) Db.TryAttach(baker); #endregion - baker.Balance += Block.Reward; + baker.Balance += Block.RewardLiquid; baker.BlocksCount++; var newDeactivationLevel = baker.Staked ? GracePeriod.Reset(Block) : GracePeriod.Init(Block); @@ -80,6 +78,9 @@ public virtual async Task Apply(JsonElement rawBlock) if (Block.Events.HasFlag(BlockEvents.ProtocolEnd)) proto.LastLevel = Block.Level; + Cache.Statistics.Current.TotalCreated += Block.RewardLiquid; + Cache.Statistics.Current.TotalFrozen += Block.RewardLiquid + Block.Deposit + Block.Fees; + Db.Blocks.Add(Block); Cache.Blocks.Add(Block); } @@ -98,7 +99,7 @@ public virtual async Task Revert(Block block) Db.TryAttach(baker); #endregion - baker.Balance -= Block.Reward; + baker.Balance -= Block.RewardLiquid; baker.BlocksCount--; if (Block.ResetBakerDeactivation != null) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/CycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/CycleCommit.cs index b4925b6a2..c4f2b0a34 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/CycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/CycleCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto1 @@ -10,7 +6,7 @@ namespace Tzkt.Sync.Protocols.Proto1 class CycleCommit : ProtocolCommit { public Cycle FutureCycle { get; protected set; } - public Dictionary Snapshots { get; protected set; } + public List BakerSnapshots { get; protected set; } public CycleCommit(ProtocolHandler protocol) : base(protocol) { } @@ -45,38 +41,11 @@ public virtual async Task Apply(Block block) snapshotLevel = snapshotProto.GetCycleStart(block.Cycle - 2) - 1 + (snapshotIndex + 1) * snapshotProto.BlocksPerSnapshot; } - var snapshotBalances = await Db.SnapshotBalances + BakerSnapshots = await Db.SnapshotBalances .AsNoTracking() - .Where(x => x.Level == snapshotLevel) + .Where(x => x.Level == snapshotLevel && x.AccountId == x.BakerId) .ToListAsync(); - Snapshots = new Dictionary(512); - foreach (var s in snapshotBalances) - { - if (s.DelegateId == null) - { - if (!Snapshots.TryGetValue(s.AccountId, out var snapshot)) - { - snapshot = new DelegateSnapshot(); - Snapshots.Add(s.AccountId, snapshot); - } - - snapshot.StakingBalance += s.Balance; - } - else - { - if (!Snapshots.TryGetValue((int)s.DelegateId, out var snapshot)) - { - snapshot = new DelegateSnapshot(); - Snapshots.Add((int)s.DelegateId, snapshot); - } - - snapshot.StakingBalance += s.Balance; - snapshot.DelegatedBalance += s.Balance; - snapshot.DelegatorsCount++; - } - } - FutureCycle = new Cycle { Index = futureCycle, @@ -84,12 +53,8 @@ public virtual async Task Apply(Block block) LastLevel = block.Protocol.GetCycleEnd(futureCycle), SnapshotIndex = snapshotIndex, SnapshotLevel = snapshotLevel, - TotalStaking = Snapshots.Values.Sum(x => x.StakingBalance), - TotalDelegated = Snapshots.Values.Sum(x => x.DelegatedBalance), - TotalDelegators = Snapshots.Values.Sum(x => x.DelegatorsCount), - TotalBakers = Snapshots.Count, - SelectedStake = Snapshots.Values.Sum(x => x.StakingBalance - x.StakingBalance % snapshotProto.TokensPerRoll), - SelectedBakers = Snapshots.Values.Count(x => x.StakingBalance >= snapshotProto.TokensPerRoll), + TotalBakers = BakerSnapshots.Count(x => x.StakingBalance >= snapshotProto.MinimalStake), + TotalBakingPower = BakerSnapshots.Sum(x => x.StakingBalance - x.StakingBalance % snapshotProto.MinimalStake), Seed = futureSeed }; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/DelegatorCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/DelegatorCycleCommit.cs index cad5ab5fd..fee746620 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/DelegatorCycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/DelegatorCycleCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto1 @@ -13,28 +9,24 @@ public DelegatorCycleCommit(ProtocolHandler protocol) : base(protocol) { } public virtual async Task Apply(Block block, Cycle futureCycle) { - if (block.Events.HasFlag(BlockEvents.CycleBegin)) - { - await Db.Database.ExecuteSqlRawAsync($@" - INSERT INTO ""DelegatorCycles"" (""Cycle"", ""DelegatorId"", ""BakerId"", ""Balance"") - SELECT {futureCycle.Index}, ""AccountId"", ""DelegateId"", ""Balance"" - FROM ""SnapshotBalances"" - WHERE ""Level"" = {futureCycle.SnapshotLevel} - AND ""DelegateId"" IS NOT NULL"); + if (!block.Events.HasFlag(BlockEvents.CycleBegin)) + return; - #region weird delegators - if (block.Cycle > 0) - { - //one-way change... - await Db.Database.ExecuteSqlRawAsync($@" - DELETE FROM ""DelegatorCycles"" as dc - USING ""Accounts"" as acc - WHERE acc.""Id"" = dc.""BakerId"" - AND dc.""Cycle"" = {block.Cycle - 1} - AND acc.""Type"" != {(int)AccountType.Delegate}"); - } - #endregion + await CreateFromSnapshots(futureCycle); + + #region weird delegators + if (block.Cycle > 0) + { + //one-way change... + await Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "DelegatorCycles" as dc + USING "Accounts" as acc + WHERE acc."Id" = dc."BakerId" + AND dc."Cycle" = {block.Cycle - 1} + AND acc."Type" != {(int)AccountType.Delegate} + """); } + #endregion } public virtual async Task Revert(Block block) @@ -44,10 +36,33 @@ public virtual async Task Revert(Block block) block.Protocol ??= await Cache.Protocols.GetAsync(block.ProtoCode); var futureCycle = block.Cycle + block.Protocol.PreservedCycles; - await Db.Database.ExecuteSqlRawAsync($@" - DELETE FROM ""DelegatorCycles"" - WHERE ""Cycle"" = {futureCycle}"); + await Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "DelegatorCycles" + WHERE "Cycle" = {futureCycle} + """); } } + + protected virtual Task CreateFromSnapshots(Cycle futureCycle) + { + return Db.Database.ExecuteSqlRawAsync($""" + INSERT INTO "DelegatorCycles" ( + "Cycle", + "DelegatorId", + "BakerId", + "DelegatedBalance", + "StakedBalance" + ) + SELECT + {futureCycle.Index}, + "AccountId", + "BakerId", + "OwnDelegatedBalance", + "OwnStakedBalance" + FROM "SnapshotBalances" + WHERE "Level" = {futureCycle.SnapshotLevel} + AND "AccountId" != "BakerId" + """); + } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/FreezerCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/FreezerCommit.cs index 1d1e18970..83d93022d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/FreezerCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/FreezerCommit.cs @@ -1,41 +1,27 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto1 { class FreezerCommit : ProtocolCommit { - public IEnumerable FreezerUpdates { get; private set; } - public FreezerCommit(ProtocolHandler protocol) : base(protocol) { } - public virtual Task Apply(Block block, JsonElement rawBlock) + public void Apply(Block block, JsonElement rawBlock) { - if (block.Events.HasFlag(BlockEvents.CycleEnd)) - { - FreezerUpdates = GetFreezerUpdates(block, rawBlock); - } + if (!block.Events.HasFlag(BlockEvents.CycleEnd)) + return; - if (FreezerUpdates == null) return Task.CompletedTask; - - foreach (var update in FreezerUpdates) + foreach (var update in GetFreezerUpdates(block, rawBlock)) { - #region entities - var delegat = Cache.Accounts.GetDelegate(update.RequiredString("delegate")); - - Db.TryAttach(delegat); - #endregion - var change = update.RequiredInt64("change"); switch (update.RequiredString("category")[0]) { case 'd': break; case 'r': + var delegat = Cache.Accounts.GetDelegate(update.RequiredString("delegate")); + Db.TryAttach(delegat); delegat.StakingBalance -= change; break; case 'f': @@ -43,35 +29,30 @@ public virtual Task Apply(Block block, JsonElement rawBlock) default: throw new Exception("unexpected freezer balance update type"); } + + Cache.Statistics.Current.TotalFrozen += change; } - return Task.CompletedTask; + return; } - public virtual async Task Revert(Block block) + public async Task Revert(Block block) { - if (block.Events.HasFlag(BlockEvents.CycleEnd)) - { - var rawBlock = await Proto.Rpc.GetBlockAsync(block.Level); - FreezerUpdates = GetFreezerUpdates(block, rawBlock); - } + if (!block.Events.HasFlag(BlockEvents.CycleEnd)) + return; - if (FreezerUpdates == null) return; + var rawBlock = await Proto.Rpc.GetBlockAsync(block.Level); - foreach (var update in FreezerUpdates) + foreach (var update in GetFreezerUpdates(block, rawBlock)) { - #region entities - var delegat = Cache.Accounts.GetDelegate(update.RequiredString("delegate")); - - Db.TryAttach(delegat); - #endregion - var change = update.RequiredInt64("change"); switch (update.RequiredString("category")[0]) { case 'd': break; case 'r': + var delegat = Cache.Accounts.GetDelegate(update.RequiredString("delegate")); + Db.TryAttach(delegat); delegat.StakingBalance += change; break; case 'f': diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/ActivationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/ActivationsCommit.cs index 0dc887bb6..2ff4bc6e0 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/ActivationsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/ActivationsCommit.cs @@ -1,5 +1,4 @@ using System.Text.Json; -using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -42,6 +41,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content commitment.AccountId = sender.Id; commitment.Level = block.Level; + + Cache.Statistics.Current.TotalActivated += activation.Balance; #endregion Db.ActivationOps.Add(activation); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/DelegationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/DelegationsCommit.cs index 28b48ba7f..e51eae966 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/DelegationsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/DelegationsCommit.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; - using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -69,7 +64,7 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content if (prevDelegate != null) { prevDelegate.StakingBalance -= delegation.BakerFee; - if (prevDelegate.Id != sender.Id) + if (prevDelegate.Id != sender.Id) prevDelegate.DelegatedBalance -= delegation.BakerFee; } blockBaker.Balance += delegation.BakerFee; @@ -92,6 +87,7 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content { if (sender.Type == AccountType.User) { + Unstake(sender, prevDelegate, delegation); ResetDelegate(sender, prevDelegate); UpgradeUser(delegation); @@ -127,6 +123,7 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content } else { + Unstake(sender, prevDelegate, delegation); ResetDelegate(sender, prevDelegate); if (newDelegate != null) SetDelegate(sender, newDelegate, block.Level); @@ -312,7 +309,10 @@ public virtual async Task Revert(Block block, DelegationOperation delegation) sender = delegation.Sender; if (prevDelegate != null && prevDelegate.Id != sender.Id) + { SetDelegate(sender, prevDelegate, (int)prevDelegationLevel); + RevertUnstake(sender, prevDelegate, delegation); + } } else { @@ -323,7 +323,10 @@ public virtual async Task Revert(Block block, DelegationOperation delegation) { ResetDelegate(sender, senderDelegate); if (prevDelegate != null && prevDelegate.Id != sender.Id) + { SetDelegate(sender, prevDelegate, (int)prevDelegationLevel); + RevertUnstake(sender, prevDelegate, delegation); + } } } #endregion @@ -440,6 +443,7 @@ void UpgradeUser(DelegationOperation delegation) FirstLevel = user.FirstLevel, LastLevel = user.LastLevel, Balance = user.Balance, + LostBalance = user.LostBalance, Counter = user.Counter, DeactivationLevel = GracePeriod.Init(delegation.Block), Delegate = null, @@ -458,7 +462,13 @@ void UpgradeUser(DelegationOperation delegation) PublicKey = user.PublicKey, Revealed = user.Revealed, Staked = true, - StakingBalance = user.Balance, + StakingBalance = user.Balance - user.UnstakedBalance, + StakedBalance = user.StakedBalance, + StakedPseudotokens = user.StakedPseudotokens, + UnstakedBalance = user.UnstakedBalance, + UnstakedBakerId = user.UnstakedBakerId, + StakingOpsCount = user.StakingOpsCount, + TotalStakedBalance = user.StakedBalance, DelegatedBalance = 0, Type = AccountType.Delegate, ActiveTokensCount = user.ActiveTokensCount, @@ -703,10 +713,16 @@ void DowngradeDelegate(DelegationOperation delegation) FirstLevel = delegat.FirstLevel, LastLevel = delegat.LastLevel, Balance = delegat.Balance, + LostBalance = delegat.LostBalance, Counter = delegat.Counter, Delegate = null, DelegateId = null, DelegationLevel = null, + StakedBalance = delegat.StakedBalance, + StakedPseudotokens = delegat.StakedPseudotokens, + UnstakedBalance = delegat.UnstakedBalance, + UnstakedBakerId = delegat.UnstakedBakerId, + StakingOpsCount = delegat.StakingOpsCount, Id = delegat.Id, Activated = delegat.Activated, DelegationsCount = delegat.DelegationsCount, @@ -1001,8 +1017,8 @@ void SetDelegate(Account sender, Data.Models.Delegate newDelegate, int level) sender.Staked = newDelegate.Staked; newDelegate.DelegatorsCount++; - newDelegate.StakingBalance += sender.Balance; - newDelegate.DelegatedBalance += sender.Balance; + newDelegate.StakingBalance += sender.Balance - ((sender as User)?.UnstakedBalance ?? 0); + newDelegate.DelegatedBalance += sender.Balance - ((sender as User)?.UnstakedBalance ?? 0); } void ResetDelegate(Account sender, Data.Models.Delegate prevDelegate) @@ -1012,10 +1028,10 @@ void ResetDelegate(Account sender, Data.Models.Delegate prevDelegate) if (sender.Address != prevDelegate.Address) { prevDelegate.DelegatorsCount--; - prevDelegate.DelegatedBalance -= sender.Balance; + prevDelegate.DelegatedBalance -= sender.Balance - ((sender as User)?.UnstakedBalance ?? 0); } - - prevDelegate.StakingBalance -= sender.Balance; + + prevDelegate.StakingBalance -= sender.Balance - ((sender as User)?.UnstakedBalance ?? 0); } sender.Delegate = null; @@ -1024,6 +1040,10 @@ void ResetDelegate(Account sender, Data.Models.Delegate prevDelegate) sender.Staked = false; } + protected virtual void Unstake(Account sender, Data.Models.Delegate baker, DelegationOperation op) { } + + protected virtual void RevertUnstake(Account sender, Data.Models.Delegate baker, DelegationOperation op) { } + async Task GetOriginationAsync(Contract contract) { var result = await Db.OriginationOps diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/EndorsementsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/EndorsementsCommit.cs index 848592111..8b37f4bec 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/EndorsementsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/EndorsementsCommit.cs @@ -1,7 +1,4 @@ -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto1 @@ -62,6 +59,9 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content endorsement.ResetDeactivation = sender.DeactivationLevel; sender.DeactivationLevel = newDeactivationLevel; } + + Cache.Statistics.Current.TotalCreated += endorsement.Reward; + Cache.Statistics.Current.TotalFrozen += endorsement.Reward + endorsement.Deposit; #endregion Db.EndorsementOps.Add(endorsement); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/NonceRevelationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/NonceRevelationsCommit.cs index 1ce26712b..af32f69a2 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/NonceRevelationsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/NonceRevelationsCommit.cs @@ -1,5 +1,4 @@ using System.Text.Json; -using System.Threading.Tasks; using Netezos.Encoding; using Tzkt.Data.Models; @@ -12,6 +11,13 @@ public NonceRevelationsCommit(ProtocolHandler protocol) : base(protocol) { } public virtual async Task Apply(Block block, JsonElement op, JsonElement content) { #region init + var balanceUpdate = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray() + .FirstOrDefault(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "rewards"); + + var reward = balanceUpdate.ValueKind != JsonValueKind.Undefined + ? balanceUpdate.RequiredInt64("change") + : 0; + var revealedBlock = await Cache.Blocks.GetAsync(content.RequiredInt32("level")); var revelation = new NonceRevelationOperation { @@ -26,7 +32,9 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content RevealedLevel = revealedBlock.Level, RevealedCycle = revealedBlock.Cycle, Nonce = Hex.Parse(content.RequiredString("nonce")), - Reward = block.Protocol.RevelationReward + RewardLiquid = reward, + RewardStakedOwn = 0, + RewardStakedShared = 0 }; #endregion @@ -40,7 +48,7 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content #endregion #region apply operation - blockBaker.Balance += revelation.Reward; + blockBaker.Balance += revelation.RewardLiquid; sender.NonceRevelationsCount++; if (blockBaker != sender) blockBaker.NonceRevelationsCount++; @@ -48,6 +56,9 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content block.Operations |= Operations.Revelations; revealedBlock.Revelation = revelation; + + Cache.Statistics.Current.TotalCreated += revelation.RewardLiquid; + Cache.Statistics.Current.TotalFrozen += revelation.RewardLiquid; #endregion Db.NonceRevelationOps.Add(revelation); @@ -76,7 +87,7 @@ public virtual async Task Revert(Block block, NonceRevelationOperation revelatio #endregion #region apply operation - blockBaker.Balance -= revelation.Reward; + blockBaker.Balance -= revelation.RewardLiquid; sender.NonceRevelationsCount--; if (blockBaker != sender) blockBaker.NonceRevelationsCount--; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/OriginationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/OriginationsCommit.cs index 055c03b88..24d7bffeb 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/OriginationsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/OriginationsCommit.cs @@ -210,6 +210,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content origination.ContractCodeHash = contract.CodeHash; } + + Cache.Statistics.Current.TotalBurned += burned; } #endregion @@ -414,6 +416,8 @@ public virtual async Task ApplyInternal(Block block, ManagerOperation parent, Js origination.ContractCodeHash = contract.CodeHash; } + + Cache.Statistics.Current.TotalBurned += burned; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index f75dc8297..bd4a09540 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -145,6 +145,10 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content if (transaction.Target is SmartRollup) Proto.Inbox.Push(transaction.Id); + + Cache.Statistics.Current.TotalBurned += burned; + if (transaction.Target.Id == NullAddress.Id) + Cache.Statistics.Current.TotalBanished += transaction.Amount; } #endregion @@ -291,6 +295,10 @@ public virtual async Task ApplyInternal(Block block, ManagerOperation parent, Js if (transaction.Target is SmartRollup) Proto.Inbox.Push(transaction.Id); + + Cache.Statistics.Current.TotalBurned += burned; + if (transaction.Target.Id == NullAddress.Id) + Cache.Statistics.Current.TotalBanished += transaction.Amount; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/SnapshotBalanceCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/SnapshotBalanceCommit.cs index a0dc9a9f0..9b4cc4ef7 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/SnapshotBalanceCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/SnapshotBalanceCommit.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -11,64 +8,189 @@ class SnapshotBalanceCommit : ProtocolCommit { public SnapshotBalanceCommit(ProtocolHandler protocol) : base(protocol) { } - public virtual async Task Apply(Block block) + public virtual async Task Apply(JsonElement rawBlock, Block block) { - if (block.Events.HasFlag(BlockEvents.BalanceSnapshot)) - { - await Db.Database.ExecuteSqlRawAsync($@" - INSERT INTO ""SnapshotBalances"" (""Level"", ""Balance"", ""AccountId"", ""DelegateId"") - SELECT {block.Level}, (COALESCE(""StakingBalance"", ""Balance"") - COALESCE(""DelegatedBalance"", 0)), ""Id"", ""DelegateId"" - FROM ""Accounts"" - WHERE ""Staked"" = true"); - - #region weird snapshots - var weirdDelegators = (await Db.Contracts - .AsNoTracking() - .Include(x => x.WeirdDelegate) - .Where(x => - x.DelegateId == null && - x.WeirdDelegateId != null && - x.WeirdDelegate.Type != AccountType.Delegate) - .ToListAsync()) - .GroupBy(x => x.WeirdDelegateId); - - if (weirdDelegators.Any()) - { - var sql = @" - INSERT INTO ""SnapshotBalances"" (""Level"", ""Balance"", ""AccountId"", ""DelegateId"") VALUES "; + if (!block.Events.HasFlag(BlockEvents.BalanceSnapshot)) + return; - var inserted = false; - foreach (var weirds in weirdDelegators) - { - if (weirds.Sum(x => x.Balance) < block.Protocol.TokensPerRoll) - continue; + await TakeSnapshot(block); + await TakeWeirdsSnapshot(block); + } - sql += $@" - ({block.Level}, 0, {weirds.First().WeirdDelegate.Id}, NULL),"; + public virtual async Task Revert(Block block) + { + if (!block.Events.HasFlag(BlockEvents.BalanceSnapshot)) + return; - foreach (var weird in weirds) - { - sql += $@" - ({block.Level}, {weird.Balance}, {weird.Id}, {weird.WeirdDelegateId}),"; - } + await Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "SnapshotBalances" + WHERE "Level" = {block.Level} + """); + } - inserted = true; - } + protected virtual Task TakeSnapshot(Block block) + { + return Db.Database.ExecuteSqlRawAsync($""" + INSERT INTO "SnapshotBalances" ( + "Level", + "AccountId", + "BakerId", + "OwnDelegatedBalance", + "ExternalDelegatedBalance", + "DelegatorsCount", + "OwnStakedBalance", + "ExternalStakedBalance", + "StakersCount", + "StakedPseudotokens", + "IssuedPseudotokens" + ) + SELECT + {block.Level}, + "Id", + COALESCE("DelegateId", "Id"), + COALESCE("StakingBalance", "Balance") - COALESCE("DelegatedBalance", 0), + COALESCE("DelegatedBalance", 0), + COALESCE("DelegatorsCount", 0), + 0, + 0, + 0, + 0, + 0 + FROM "Accounts" + WHERE "Staked" = true + """); + } - if (inserted) - await Db.Database.ExecuteSqlRawAsync(sql[..^1]); + protected Task RemoveOutdated(Block block, Protocol protocol) + { + var level = block.Level - (protocol.PreservedCycles + 3) * protocol.BlocksPerCycle; + return Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "SnapshotBalances" + WHERE "Level" <= {level} + """); + } + + protected virtual async Task TakeDeactivatedSnapshot(Block block) + { + var deactivated = await Db.Delegates + .AsNoTracking() + .Include(x => x.DelegatedAccounts) + .Where(x => x.DeactivationLevel == block.Level) + .ToListAsync(); + + if (deactivated.Any()) + { + var values = string.Join(",\n", deactivated + .SelectMany(baker => + new[] { $"({block.Level}, {baker.Id}, {baker.Id}, {baker.StakingBalance - baker.DelegatedBalance}, {baker.DelegatedBalance}, {baker.DelegatorsCount}, 0, 0, 0, 0, 0)" } + .Concat(baker.DelegatedAccounts.Select(delegator => $"({block.Level}, {delegator.Id}, {delegator.DelegateId}, {delegator.Balance}, 0, 0, 0, 0, 0, 0, 0)")))); + + if (values.Length > 0) + { + await Db.Database.ExecuteSqlRawAsync($""" + INSERT INTO "SnapshotBalances" ( + "Level", + "AccountId", + "BakerId", + "OwnDelegatedBalance", + "ExternalDelegatedBalance", + "DelegatorsCount", + "OwnStakedBalance", + "ExternalStakedBalance", + "StakersCount", + "StakedPseudotokens", + "IssuedPseudotokens" + ) + VALUES + {values} + """); } - #endregion } } - public virtual async Task Revert(Block block) + protected virtual async Task SubtractCycleRewards(JsonElement rawBlock, Block block) { - if (block.Events.HasFlag(BlockEvents.BalanceSnapshot)) + if (!block.Events.HasFlag(BlockEvents.CycleEnd)) + return; + + var rewards = string.Join(",\n", GetBalanceUpdates(rawBlock) + .Where(x => x.RequiredString("kind")[0] == 'f' && + x.RequiredString("category")[0] == 'r' && + x.RequiredInt64("change") < 0 && + GetFreezerCycle(x) != block.Cycle) + .Select(x => (x.RequiredString("delegate"), x.RequiredInt64("change"))) + .GroupBy(x => x.Item1) + .Select(updates => $"({Cache.Accounts.GetDelegate(updates.Key).Id}, {updates.Sum(x => -x.Item2)}::bigint)")); + + if (rewards.Length > 0) { - await Db.Database.ExecuteSqlRawAsync($@" - DELETE FROM ""SnapshotBalances"" - WHERE ""Level"" = {block.Level}"); + await Db.Database.ExecuteSqlRawAsync($""" + UPDATE "SnapshotBalances" as sb + SET "OwnDelegatedBalance" = "OwnDelegatedBalance" - reward.value + FROM ( + VALUES + {rewards} + ) as reward(baker, value) + WHERE sb."Level" = {block.Level} + AND sb."AccountId" = reward.baker + AND sb."BakerId" = reward.baker + """); + } + } + + protected virtual int GetFreezerCycle(JsonElement el) + { + return el.RequiredInt32("level"); + } + + protected virtual IEnumerable GetBalanceUpdates(JsonElement rawBlock) + { + return rawBlock + .GetProperty("metadata") + .GetProperty("balance_updates") + .EnumerateArray(); + } + + async Task TakeWeirdsSnapshot(Block block) + { + var weirdDelegators = (await Db.Contracts + .AsNoTracking() + .Include(x => x.WeirdDelegate) + .Where(x => + x.DelegateId == null && + x.WeirdDelegateId != null && + x.WeirdDelegate.Type != AccountType.Delegate) + .ToListAsync()) + .GroupBy(x => x.WeirdDelegateId); + + if (weirdDelegators.Any()) + { + var values = string.Join(",\n", weirdDelegators + .Where(weirds => weirds.Sum(x => x.Balance) >= block.Protocol.MinimalStake) + .SelectMany(weirds => + new[] { $"({block.Level}, {weirds.First().WeirdDelegateId}, {weirds.First().WeirdDelegateId}, 0, {weirds.Sum(x => x.Balance)}, {weirds.Count()}, 0, 0, 0, 0, 0)" } + .Concat(weirds.Select(x => $"({block.Level}, {x.Id}, {x.WeirdDelegateId}, {x.Balance}, 0, 0, 0, 0, 0, 0, 0)")))); + + if (values.Length > 0) + { + await Db.Database.ExecuteSqlRawAsync($""" + INSERT INTO "SnapshotBalances" ( + "Level", + "AccountId", + "BakerId", + "OwnDelegatedBalance", + "ExternalDelegatedBalance", + "DelegatorsCount", + "OwnStakedBalance", + "ExternalStakedBalance", + "StakersCount", + "StakedPseudotokens", + "IssuedPseudotokens" + ) + VALUES + {values} + """); + } } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/StatisticsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/StatisticsCommit.cs index d23c3f326..11fd4b38e 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/StatisticsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/StatisticsCommit.cs @@ -1,10 +1,6 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; -using Tzkt.Data.Models.Base; namespace Tzkt.Sync.Protocols.Proto1 { @@ -12,16 +8,17 @@ class StatisticsCommit : ProtocolCommit { public StatisticsCommit(ProtocolHandler protocol) : base(protocol) { } - public virtual async Task Apply(Block block, IEnumerable freezerUpdates) + public virtual async Task Apply(JsonElement rawBlock) { - var prev = await Cache.Statistics.GetAsync(block.Level - 1); + var prev = Cache.Statistics.Current; var statistics = new Statistics { - Level = block.Level, + Level = prev.Level + 1, TotalActivated = prev.TotalActivated, TotalBootstrapped = prev.TotalBootstrapped, TotalBurned = prev.TotalBurned, TotalBanished = prev.TotalBanished, + TotalLost = prev.TotalLost, TotalCommitments = prev.TotalCommitments, TotalCreated = prev.TotalCreated, TotalFrozen = prev.TotalFrozen, @@ -29,112 +26,26 @@ public virtual async Task Apply(Block block, IEnumerable freezerUpd TotalSmartRollupBonds = prev.TotalSmartRollupBonds }; - if (block.Activations != null) - statistics.TotalActivated += block.Activations.Sum(x => x.Balance); + var protocol = await Cache.Protocols.GetAsync(rawBlock.RequiredString("protocol")); + if (protocol.IsCycleEnd(statistics.Level)) + statistics.Cycle = protocol.GetCycle(statistics.Level); - if (block.DoubleBakings != null) + var timestamp = rawBlock.Required("header").RequiredDateTime("timestamp"); + var prevTimestamp = (await Cache.Blocks.GetAsync(prev.Level)).Timestamp; + if (timestamp.Ticks / (10_000_000L * 3600 * 24) != prevTimestamp.Ticks / (10_000_000L * 3600 * 24)) { - var lost = block.DoubleBakings.Sum(x => x.OffenderLoss - x.AccuserReward); - statistics.TotalBurned += lost; - statistics.TotalFrozen -= lost; - } - - if (block.DoubleEndorsings != null) - { - var lost = block.DoubleEndorsings.Sum(x => x.OffenderLoss - x.AccuserReward); - statistics.TotalBurned += lost; - statistics.TotalFrozen -= lost; - } - - if (block.Originations != null) - { - var originations = block.Originations.Where(x => x.Status == OperationStatus.Applied); - if (originations.Any()) - statistics.TotalBurned += originations.Sum(x => (x.StorageFee ?? 0) + (x.AllocationFee ?? 0)); - } - - if (block.RegisterConstants != null) - { - var registerConstants = block.RegisterConstants.Where(x => x.Status == OperationStatus.Applied); - if (registerConstants.Any()) - statistics.TotalBurned += registerConstants.Sum(x => x.StorageFee ?? 0); - } - - if (block.Transactions != null) - { - var transactions = block.Transactions.Where(x => x.Status == OperationStatus.Applied); - - if (transactions.Any()) - statistics.TotalBurned += transactions.Sum(x => (x.StorageFee ?? 0) + (x.AllocationFee ?? 0)); - - foreach (var tx in transactions.Where(x => x.Target?.Id == NullAddress.Id)) - statistics.TotalBanished += tx.Amount; - } - - if (block.RevelationPenalties != null) - { - var lost = block.RevelationPenalties.Sum(x => x.Loss); - statistics.TotalBurned += lost; - statistics.TotalFrozen -= lost; - } - - if (block.Endorsements != null) - { - var rewards = block.Endorsements.Sum(x => x.Reward); - var deposits = block.Endorsements.Sum(x => x.Deposit); - statistics.TotalCreated += rewards; - statistics.TotalFrozen += deposits; - statistics.TotalFrozen += rewards; - } - - if (block.Revelations != null) - { - var rewards = block.Revelations.Sum(x => x.Reward); - statistics.TotalCreated += rewards; - statistics.TotalFrozen += rewards; - } - - if (block.Migrations != null && block.Migrations.Any(x => x.Kind == MigrationKind.Subsidy)) - { - var subsidy = block.Migrations.Where(x => x.Kind == MigrationKind.Subsidy).Sum(x => x.BalanceChange); - statistics.TotalCreated += subsidy; - } - - statistics.TotalCreated += block.Reward; - statistics.TotalFrozen += block.Deposit; - statistics.TotalFrozen += block.Reward; - statistics.TotalFrozen += block.Fees; - - if (freezerUpdates != null && freezerUpdates.Any()) - statistics.TotalFrozen += freezerUpdates.Sum(x => x.RequiredInt64("change")); - - if (block.Events.HasFlag(BlockEvents.CycleEnd)) - statistics.Cycle = block.Cycle; - - if (block.Timestamp.AddSeconds(block.Protocol.TimeBetweenBlocks).Ticks / (10_000_000L * 3600 * 24) != block.Timestamp.Ticks / (10_000_000L * 3600 * 24)) - statistics.Date = block.Timestamp.Date; - else - { - var prevStats = await Cache.Statistics.GetAsync(block.Level - 1); - if (prevStats.Date == null) - { - var prevBlock = await Cache.Blocks.CurrentAsync(); - if (prevBlock.Timestamp.Ticks / (10_000_000L * 3600 * 24) != block.Timestamp.Ticks / (10_000_000L * 3600 * 24)) - { - Db.TryAttach(prevStats); - prevStats.Date = prevBlock.Timestamp.Date; - } - } + Db.TryAttach(prev); + prev.Date = prevTimestamp.Date; } Db.Statistics.Add(statistics); - Cache.Statistics.Add(statistics); + Cache.Statistics.SetCurrent(statistics); } public virtual async Task Revert(Block block) { - await Db.Database.ExecuteSqlRawAsync($@"DELETE FROM ""Statistics"" WHERE ""Level"" = {block.Level}"); - Cache.Statistics.Reset(); + await Db.Database.ExecuteSqlRawAsync($"""DELETE FROM "Statistics" WHERE "Level" = {block.Level}"""); + await Cache.Statistics.ResetAsync(); } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/VotingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/VotingCommit.cs index 0494d90e2..4a637a173 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/VotingCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/VotingCommit.cs @@ -1,7 +1,4 @@ -using System; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -169,13 +166,13 @@ protected VotingPeriod StartProposalPeriod(Block block, VotingPeriod current) #region snapshot var snapshots = Cache.Accounts.GetDelegates() - .Where(x => x.Staked && x.StakingBalance >= proto.TokensPerRoll) + .Where(x => BakerIsListed(x, block, block.Protocol)) .Select(x => new VotingSnapshot { Level = block.Level, Period = period.Index, BakerId = x.Id, - VotingPower = GetVotingPower(x, proto), + VotingPower = GetVotingPower(x, block, proto), Status = VoterStatus.None }); @@ -183,6 +180,19 @@ protected VotingPeriod StartProposalPeriod(Block block, VotingPeriod current) period.TotalVotingPower = snapshots.Sum(x => x.VotingPower); #endregion + //#region temporary diagnostics + //var listing = Proto.Node.GetAsync($"chains/main/blocks/{block.Level}/context/raw/json/votes/listings?depth=1").Result + // .EnumerateArray() + // .ToDictionary(x => x[0].RequiredString(), x => x[1].RequiredInt64()); + + //if (snapshots.Count() != listing.Count) + // throw new Exception("Wrong voting snapshots"); + + //foreach (var snapshot in snapshots) + // if (!listing.TryGetValue(Cache.Accounts.GetDelegate(snapshot.BakerId).Address, out var votingPower) || snapshot.VotingPower != votingPower) + // throw new Exception("Wrong voting snapshot"); + //#endregion + #region quorum period.UpvotesQuorum = proto.ProposalQuorum; period.ProposalsCount = 0; @@ -212,13 +222,13 @@ protected VotingPeriod StartBallotPeriod(Block block, VotingPeriod current, Peri #region snapshot var snapshots = Cache.Accounts.GetDelegates() - .Where(x => x.Staked && x.StakingBalance >= proto.TokensPerRoll) + .Where(x => BakerIsListed(x, block, block.Protocol)) .Select(x => new VotingSnapshot { Level = block.Level, Period = period.Index, BakerId = x.Id, - VotingPower = GetVotingPower(x, proto), + VotingPower = GetVotingPower(x, block, proto), Status = VoterStatus.None }); @@ -226,6 +236,19 @@ protected VotingPeriod StartBallotPeriod(Block block, VotingPeriod current, Peri period.TotalVotingPower = snapshots.Sum(x => x.VotingPower); #endregion + //#region temporary diagnostics + //var listing = Proto.Node.GetAsync($"chains/main/blocks/{block.Level}/context/raw/json/votes/listings?depth=1").Result + // .EnumerateArray() + // .ToDictionary(x => x[0].RequiredString(), x => x[1].RequiredInt64()); + + //if (snapshots.Count() != listing.Count) + // throw new Exception("Wrong voting snapshots"); + + //foreach (var snapshot in snapshots) + // if (!listing.TryGetValue(Cache.Accounts.GetDelegate(snapshot.BakerId).Address, out var votingPower) || snapshot.VotingPower != votingPower) + // throw new Exception("Wrong voting snapshot"); + //#endregion + #region quorum period.ParticipationEma = GetParticipationEma(period, proto); period.BallotsQuorum = GetBallotQuorum(period, proto); @@ -262,16 +285,40 @@ protected VotingPeriod StartWaitingPeriod(Block block, VotingPeriod current, Per { #region snapshot Db.VotingSnapshots.AddRange(Cache.Accounts.GetDelegates() - .Where(x => x.Staked && x.StakingBalance >= proto.TokensPerRoll) + .Where(x => BakerIsListed(x, block, block.Protocol)) .Select(x => new VotingSnapshot { Level = block.Level, Period = period.Index, BakerId = x.Id, - VotingPower = GetVotingPower(x, proto), + VotingPower = GetVotingPower(x, block, proto), Status = VoterStatus.None })); #endregion + + //#region temporary diagnostics + //var snapshots = Cache.Accounts.GetDelegates() + // .Where(x => BakerIsListed(x, block, block.Protocol)) + // .Select(x => new VotingSnapshot + // { + // Level = block.Level, + // Period = period.Index, + // BakerId = x.Id, + // VotingPower = GetVotingPower(x, block, proto), + // Status = VoterStatus.None + // }); + + //var listing = Proto.Node.GetAsync($"chains/main/blocks/{block.Level}/context/raw/json/votes/listings?depth=1").Result + // .EnumerateArray() + // .ToDictionary(x => x[0].RequiredString(), x => x[1].RequiredInt64()); + + //if (snapshots.Count() != listing.Count) + // throw new Exception("Wrong voting snapshots"); + + //foreach (var snapshot in snapshots) + // if (!listing.TryGetValue(Cache.Accounts.GetDelegate(snapshot.BakerId).Address, out var votingPower) || snapshot.VotingPower != votingPower) + // throw new Exception("Wrong voting snapshot"); + //#endregion } Db.VotingPeriods.Add(period); @@ -311,9 +358,14 @@ protected virtual int GetBallotQuorum(VotingPeriod period, Protocol proto) return 8000; } - protected virtual long GetVotingPower(Data.Models.Delegate baker, Protocol protocol) + protected virtual long GetVotingPower(Data.Models.Delegate baker, Block block, Protocol protocol) + { + return baker.StakingBalance - baker.StakingBalance % protocol.MinimalStake; + } + + protected virtual bool BakerIsListed(Data.Models.Delegate baker, Block block, Protocol protocol) { - return baker.StakingBalance - baker.StakingBalance % protocol.TokensPerRoll; + return baker.Staked && baker.StakingBalance >= protocol.MinimalStake; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs index 3f09b060c..79dbfc8b0 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs @@ -13,6 +13,10 @@ class Diagnostics : IDiagnostics protected readonly CacheService Cache; protected readonly IRpc Rpc; + int AddedOperations = 0; + readonly Dictionary ChangedAccounts = new(); + readonly Dictionary ChangedTicketBalances = new(); + public Diagnostics(ProtocolHandler handler) { Db = handler.Db; @@ -20,6 +24,22 @@ public Diagnostics(ProtocolHandler handler) Rpc = handler.Rpc; } + public void TrackChanges() + { + var entries = Db.ChangeTracker.Entries(); + AddedOperations += entries.Count(x => x.Entity is BaseOperation or ContractEvent && x.State == EntityState.Added); + + foreach (var account in entries.Where(x => + x.Entity is Account && (x.State == EntityState.Modified || x.State == EntityState.Added)) + .Select(x => x.Entity as Account)) + ChangedAccounts[account.Id] = account; + + foreach (var ticket in entries.Where(x => + x.Entity is TicketBalance && (x.State == EntityState.Modified || x.State == EntityState.Added)) + .Select(x => x.Entity as TicketBalance)) + ChangedTicketBalances[ticket.Id] = ticket; + } + public virtual Task Run(JsonElement block) { var ops = block.GetProperty("operations"); @@ -59,28 +79,20 @@ protected virtual async Task RunDiagnostics(int level, int ops = -1) { var entries = Db.ChangeTracker.Entries(); - if (ops != -1 && ops != entries.Count(x => x.Entity is BaseOperation or ContractEvent && x.State == EntityState.Added)) + if (ops != -1 && ops != AddedOperations) throw new Exception($"Diagnostics failed: wrong operations count"); var state = Cache.AppState.Get(); var proto = await Cache.Protocols.GetAsync(state.NextProtocol); - var accounts = entries.Where(x => - x.Entity is Account && (x.State == EntityState.Modified || x.State == EntityState.Added)) - .Select(x => x.Entity as Account); - - var ticketBalances = entries.Where(x => - x.Entity is TicketBalance && (x.State == EntityState.Modified || x.State == EntityState.Added)) - .Select(x => x.Entity as TicketBalance); - - foreach (var ticketBalance in ticketBalances) + foreach (var ticketBalance in ChangedTicketBalances.Values) { await TestTicketBalance(level, ticketBalance); } await TestGlobalCounter(level, state); - foreach (var account in accounts) + foreach (var account in ChangedAccounts.Values) { if (account is Data.Models.Delegate delegat) await TestDelegate(level, delegat, proto); @@ -172,7 +184,8 @@ protected virtual async Task TestAccount(int level, Account account) { var remote = await Rpc.GetContractAsync(level, account.Address); - if (account is not Data.Models.Delegate && remote.RequiredInt64("balance") != account.Balance - account.RollupBonds - account.SmartRollupBonds) + if (account is not Data.Models.Delegate && remote.RequiredInt64("balance") != account.Balance - account.RollupBonds + - account.SmartRollupBonds - ((account as User)?.StakedBalance ?? 0) - ((account as User)?.UnstakedBalance ?? 0)) throw new Exception($"Diagnostics failed: wrong balance {account.Address}"); TestAccountDelegate(remote, account); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Proto1Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Proto1Handler.cs index 995ad7a5c..121522567 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Proto1Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Proto1Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,11 +29,12 @@ public Proto1Handler(TezosNode node, TzktContext db, CacheService cache, QuotesS public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); - var freezerCommit = new FreezerCommit(this); - await freezerCommit.Apply(blockCommit.Block, block); + new FreezerCommit(this).Apply(blockCommit.Block, block); var operations = block.RequiredArray("operations", 4); @@ -154,10 +148,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -165,7 +158,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs index 23fe88835..1b8ad39f2 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs @@ -33,6 +33,9 @@ public virtual Task GetDelegateAsync(int level, string address) public virtual Task GetStakeDistribution(int block, int cycle) => throw new InvalidOperationException(); + + public virtual Task GetExpectedIssuance(int block) + => throw new InvalidOperationException(); #endregion #region diagnostics @@ -53,6 +56,12 @@ public virtual Task GetDelegateParticipationAsync(int level, string public virtual Task GetTicketBalance(int level, string address, string ticket) => throw new InvalidOperationException(); + + public virtual Task GetCurrentStakingBalance(int level, string address) + => throw new InvalidOperationException(); + + public virtual Task GetStakingParameters(int level, string address) + => throw new InvalidOperationException(); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto10/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto10/Activation/ProtoActivator.cs index 52e2a28e2..4a5183dbd 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto10/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto10/Activation/ProtoActivator.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Netezos.Contracts; using Netezos.Encoding; @@ -31,8 +27,7 @@ protected override void SetParameters(Protocol protocol, JToken parameters) protocol.HardOperationStorageLimit = parameters["hard_storage_limit_per_operation"]?.Value() ?? 60_000; protocol.OriginationSize = parameters["origination_size"]?.Value() ?? 257; protocol.PreservedCycles = parameters["preserved_cycles"]?.Value() ?? 5; - protocol.RevelationReward = parameters["seed_nonce_revelation_tip"]?.Value() ?? 125_000; - protocol.TokensPerRoll = parameters["tokens_per_roll"]?.Value() ?? 8_000_000_000; + protocol.MinimalStake = parameters["tokens_per_roll"]?.Value() ?? 8_000_000_000; protocol.BallotQuorumMin = parameters["quorum_min"]?.Value() ?? 2000; protocol.BallotQuorumMax = parameters["quorum_max"]?.Value() ?? 7000; protocol.ProposalQuorum = parameters["min_proposal_quorum"]?.Value() ?? 500; @@ -57,7 +52,6 @@ protected override void SetParameters(Protocol protocol, JToken parameters) protocol.HardBlockGasLimit = parameters["hard_gas_limit_per_block"]?.Value() ?? 5_200_000; protocol.TimeBetweenBlocks = parameters["minimal_block_delay"]?.Value() ?? 30; - protocol.LBSubsidy = parameters["liquidity_baking_subsidy"]?.Value() ?? 2_500_000; protocol.LBToggleThreshold = (parameters["liquidity_baking_escape_ema_threshold"]?.Value() ?? 1_000_000) * 1000; } @@ -79,7 +73,6 @@ protected override void UpgradeParameters(Protocol protocol, Protocol prev) protocol.HardBlockGasLimit = 5_200_000; protocol.TimeBetweenBlocks /= 2; - protocol.LBSubsidy = 2_500_000; protocol.LBToggleThreshold = 1_000_000_000; } @@ -273,7 +266,7 @@ await Db.Database.ExecuteSqlRawAsync($@" foreach (var bc in bakerCycles.Values) { - var share = (double)bc.StakingBalance / cycle.TotalStaking; + var share = (double)bc.BakingPower / cycle.TotalBakingPower; bc.ExpectedBlocks = nextProto.BlocksPerCycle * share; bc.ExpectedEndorsements = nextProto.EndorsersPerBlock * nextProto.BlocksPerCycle * share; bc.FutureBlockRewards = 0; @@ -394,18 +387,22 @@ async Task> FetchEndorsingRights(Protocol protocol, int block, .Where(x => x != baker.Address); var stakingBalance = snapshottedBaker.RequiredInt64("staking_balance"); - var activeStake = stakingBalance - stakingBalance % protocol.TokensPerRoll; - var share = (double)activeStake / cycle.SelectedStake; + var delegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"); + var bakingPower = stakingBalance - stakingBalance % protocol.MinimalStake; + var share = (double)bakingPower / cycle.TotalBakingPower; bakerCycle = new BakerCycle { Cycle = cycle.Index, BakerId = baker.Id, - StakingBalance = stakingBalance, - ActiveStake = activeStake, - SelectedStake = cycle.SelectedStake, - DelegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"), + OwnDelegatedBalance = stakingBalance - delegatedBalance, + ExternalDelegatedBalance = delegatedBalance, DelegatorsCount = delegators.Count(), + OwnStakedBalance = 0, + ExternalStakedBalance = 0, + StakersCount = 0, + BakingPower = bakingPower, + TotalBakingPower = cycle.TotalBakingPower, ExpectedBlocks = protocol.BlocksPerCycle * share, ExpectedEndorsements = protocol.EndorsersPerBlock * protocol.BlocksPerCycle * share }; @@ -417,10 +414,11 @@ async Task> FetchEndorsingRights(Protocol protocol, int block, var snapshottedDelegator = await Proto.Rpc.GetContractAsync(cycle.SnapshotLevel, delegatorAddress); Db.DelegatorCycles.Add(new DelegatorCycle { - BakerId = baker.Id, - Balance = snapshottedDelegator.RequiredInt64("balance"), Cycle = cycle.Index, - DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id + DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id, + BakerId = baker.Id, + DelegatedBalance = snapshottedDelegator.RequiredInt64("balance"), + StakedBalance = 0 }); } #endregion @@ -576,8 +574,7 @@ async Task OriginateContract(Block block, string address) var state = Cache.AppState.Get(); state.MigrationOpsCount++; - var statistics = await Cache.Statistics.GetAsync(state.Level); - statistics.TotalCreated += contract.Balance; + Cache.Statistics.Current.TotalCreated += contract.Balance; Db.MigrationOps.Add(migration); #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto10/Commits/SubsidyCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto10/Commits/SubsidyCommit.cs index 20dc205b3..a77f88cf7 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto10/Commits/SubsidyCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto10/Commits/SubsidyCommit.cs @@ -30,6 +30,8 @@ public virtual async Task Apply(Block block, JsonElement content) Db.MigrationOps.Add(op); Cache.AppState.Get().MigrationOpsCount++; + Cache.Statistics.Current.TotalCreated += op.BalanceChange; + contract.MigrationsCount++; contract.Balance += op.BalanceChange; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto10/Proto10Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto10/Proto10Handler.cs index 573c280e0..eb8744c47 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto10/Proto10Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto10/Proto10Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,14 +29,13 @@ public Proto10Handler(TezosNode node, TzktContext db, CacheService cache, Quotes public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(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); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -200,10 +192,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -211,7 +202,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/RegisterConstantsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/RegisterConstantsCommit.cs index eb9b6b165..f11d41b63 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/RegisterConstantsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Commits/Operations/RegisterConstantsCommit.cs @@ -96,6 +96,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content registerConstant.Refs = 0; Cache.AppState.Get().ConstantsCount++; + + Cache.Statistics.Current.TotalBurned += burned; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto11/Proto11Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto11/Proto11Handler.cs index d77d4a765..7249d1f3d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto11/Proto11Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto11/Proto11Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,14 +29,13 @@ public Proto11Handler(TezosNode node, TzktContext db, CacheService cache, Quotes public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(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); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -203,10 +195,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -214,7 +205,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.Accounts.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.Accounts.cs index c236900a2..f5bea3085 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.Accounts.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.Accounts.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto12 @@ -12,16 +9,9 @@ protected override async Task> BootstrapAccounts(Protocol protocol { var accounts = await base.BootstrapAccounts(protocol, parameters); - foreach (var account in accounts.Where(x => x.Type == AccountType.Delegate)) - { - var baker = account as Data.Models.Delegate; - baker.FrozenDeposit = baker.StakingBalance >= protocol.TokensPerRoll - ? baker.StakingBalance * protocol.FrozenDepositsPercentage / 100 - : 0; - } - - var stats = await Cache.Statistics.GetAsync(1); - stats.TotalFrozen = accounts.Sum(x => (x as Data.Models.Delegate)?.FrozenDeposit ?? 0); + Cache.Statistics.Current.TotalFrozen = accounts + .Where(x => x is Data.Models.Delegate baker && baker.StakingBalance >= protocol.MinimalStake) + .Sum(x => (x as Data.Models.Delegate).StakingBalance / (protocol.MaxDelegatedOverFrozenRatio + 1)); return accounts; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.BakerCycles.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.BakerCycles.cs index 1cfdd3671..6bbe0db4b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.BakerCycles.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.BakerCycles.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; +using System.Numerics; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -26,22 +23,25 @@ public override void BootstrapBakerCycles( { var bakerCycle = new BakerCycle { - BakerId = x.Id, Cycle = cycle.Index, - DelegatedBalance = x.DelegatedBalance, + BakerId = x.Id, + OwnDelegatedBalance = x.Balance, + ExternalDelegatedBalance = x.DelegatedBalance, DelegatorsCount = x.DelegatorsCount, - StakingBalance = x.StakingBalance, - ActiveStake = 0, - SelectedStake = cycle.SelectedStake + OwnStakedBalance = x.StakedBalance, + ExternalStakedBalance = x.ExternalStakedBalance, + StakersCount = x.StakersCount, + BakingPower = 0, + TotalBakingPower = cycle.TotalBakingPower }; - if (x.StakingBalance >= protocol.TokensPerRoll) + if (x.StakingBalance >= protocol.MinimalStake) { - var activeStake = Math.Min(x.StakingBalance, x.Balance * 100 / protocol.FrozenDepositsPercentage); - var expectedEndorsements = (int)(new BigInteger(protocol.BlocksPerCycle) * protocol.EndorsersPerBlock * activeStake / cycle.SelectedStake); - bakerCycle.ExpectedBlocks = protocol.BlocksPerCycle * activeStake / cycle.SelectedStake; + var bakingPower = Math.Min(x.StakingBalance, x.Balance * (protocol.MaxDelegatedOverFrozenRatio + 1)); + var expectedEndorsements = (int)(new BigInteger(protocol.BlocksPerCycle) * protocol.EndorsersPerBlock * bakingPower / cycle.TotalBakingPower); + bakerCycle.BakingPower = bakingPower; + bakerCycle.ExpectedBlocks = protocol.BlocksPerCycle * bakingPower / cycle.TotalBakingPower; bakerCycle.ExpectedEndorsements = expectedEndorsements; bakerCycle.FutureEndorsementRewards = expectedEndorsements * protocol.EndorsementReward0; - bakerCycle.ActiveStake = activeStake; } return bakerCycle; }); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.BakingRights.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.BakingRights.cs index c47ae5df9..35889cb11 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.BakingRights.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.BakingRights.cs @@ -14,11 +14,11 @@ partial class ProtoActivator : Proto11.ProtoActivator Cycle cycle) { var bakers = accounts - .Where(x => x is Data.Models.Delegate d && d.Balance > 0 && d.StakingBalance >= protocol.TokensPerRoll) + .Where(x => x is Data.Models.Delegate d && d.Balance > 0 && d.StakingBalance >= protocol.MinimalStake) .Select(x => x as Data.Models.Delegate); var sampler = GetSampler(bakers.Select(x => - (x.Id, Math.Min(x.StakingBalance, x.Balance * 100 / protocol.FrozenDepositsPercentage)))); + (x.Id, Math.Min(x.StakingBalance, x.Balance * (protocol.MaxDelegatedOverFrozenRatio + 1))))); #region temporary diagnostics await sampler.Validate(Proto, 1, cycle.Index); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.Cycles.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.Cycles.cs index 9fc2162c7..d436f6599 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.Cycles.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.Cycles.cs @@ -13,13 +13,13 @@ public override List BootstrapCycles(Protocol protocol, List acc var cycles = base.BootstrapCycles(protocol, accounts, parameters); var delegates = accounts - .Where(x => x is Data.Models.Delegate d && d.StakingBalance >= protocol.TokensPerRoll) + .Where(x => x is Data.Models.Delegate d && d.StakingBalance >= protocol.MinimalStake) .Select(x => x as Data.Models.Delegate); foreach (var cycle in cycles) { - cycle.SelectedStake = delegates.Sum(x => Math.Min(x.StakingBalance, x.Balance * 100 / protocol.FrozenDepositsPercentage)); - cycle.SelectedBakers = delegates.Count(); + cycle.TotalBakingPower = delegates.Sum(x => Math.Min(x.StakingBalance, x.Balance * (protocol.MaxDelegatedOverFrozenRatio + 1))); + cycle.TotalBakers = delegates.Count(); } return cycles; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.SnapshotBalances.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.SnapshotBalances.cs deleted file mode 100644 index 4b1405514..000000000 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.SnapshotBalances.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Tzkt.Data.Models; - -namespace Tzkt.Sync.Protocols.Proto12 -{ - partial class ProtoActivator : Proto11.ProtoActivator - { - public override void BootstrapSnapshotBalances(List accounts) - { - Db.SnapshotBalances.AddRange(accounts.Where(x => x.Staked) - .Select(x => new SnapshotBalance - { - AccountId = x.Id, - Balance = x.Balance, - DelegateId = x.DelegateId, - DelegatedBalance = (x as Data.Models.Delegate)?.DelegatedBalance, - DelegatorsCount = (x as Data.Models.Delegate)?.DelegatorsCount, - StakingBalance = (x as Data.Models.Delegate)?.StakingBalance, - Level = 1 - })); - } - } -} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.cs index 0ffe2b110..687479054 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Activation/ProtoActivator.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Threading.Tasks; +using System.Numerics; using Microsoft.EntityFrameworkCore; using Netezos.Encoding; using Newtonsoft.Json.Linq; @@ -20,7 +16,7 @@ protected override void SetParameters(Protocol protocol, JToken parameters) base.SetParameters(protocol, parameters); protocol.BlocksPerSnapshot = parameters["blocks_per_stake_snapshot"]?.Value() ?? 512; protocol.EndorsersPerBlock = parameters["consensus_committee_size"]?.Value() ?? 7000; - protocol.TokensPerRoll = parameters["tokens_per_roll"]?.Value() ?? 6_000_000_000; + protocol.MinimalStake = parameters["tokens_per_roll"]?.Value() ?? 6_000_000_000; protocol.BlockDeposit = 0; protocol.EndorsementDeposit = 0; @@ -36,10 +32,7 @@ protected override void SetParameters(Protocol protocol, JToken parameters) protocol.MinParticipationNumerator = parameters["minimal_participation_ratio"]?["numerator"]?.Value() ?? 2; protocol.MinParticipationDenominator = parameters["minimal_participation_ratio"]?["denominator"]?.Value() ?? 3; protocol.MaxSlashingPeriod = parameters["max_slashing_period"]?.Value() ?? 2; - protocol.FrozenDepositsPercentage = parameters["frozen_deposits_percentage"]?.Value() ?? 10; - protocol.DoubleBakingPunishment = parameters["double_baking_punishment"]?.Value() ?? 640_000_000; - protocol.DoubleEndorsingPunishmentNumerator = parameters["ratio_of_frozen_deposits_slashed_per_double_endorsement"]?["numerator"]?.Value() ?? 1; - protocol.DoubleEndorsingPunishmentDenominator = parameters["ratio_of_frozen_deposits_slashed_per_double_endorsement"]?["denominator"]?.Value() ?? 2; + protocol.MaxDelegatedOverFrozenRatio = 100 / (parameters["frozen_deposits_percentage"]?.Value() ?? 10) - 1; protocol.MaxBakingReward = protocol.BlockReward0 + protocol.EndorsersPerBlock / 3 * protocol.BlockReward1; protocol.MaxEndorsingReward = protocol.EndorsersPerBlock * protocol.EndorsementReward0; @@ -48,7 +41,7 @@ protected override void SetParameters(Protocol protocol, JToken parameters) protected override void UpgradeParameters(Protocol protocol, Protocol prev) { protocol.EndorsersPerBlock = 7000; - protocol.TokensPerRoll = 6_000_000_000; + protocol.MinimalStake = 6_000_000_000; protocol.BlockDeposit = 0; protocol.EndorsementDeposit = 0; @@ -64,10 +57,7 @@ protected override void UpgradeParameters(Protocol protocol, Protocol prev) protocol.MinParticipationNumerator = 2; protocol.MinParticipationDenominator = 3; protocol.MaxSlashingPeriod = 2; - protocol.FrozenDepositsPercentage = 10; - protocol.DoubleBakingPunishment = 640_000_000; - protocol.DoubleEndorsingPunishmentNumerator = 1; - protocol.DoubleEndorsingPunishmentDenominator = 2; + protocol.MaxDelegatedOverFrozenRatio = 9; protocol.MaxBakingReward = protocol.BlockReward0 + protocol.EndorsersPerBlock / 3 * protocol.BlockReward1; protocol.MaxEndorsingReward = protocol.EndorsersPerBlock * protocol.EndorsementReward0; @@ -79,7 +69,7 @@ protected override async Task MigrateContext(AppState state) var bakers = await MigrateBakers(nextProto); await MigrateCycles(state, bakers, nextProto); - await MigrateStatistics(state, bakers); + MigrateStatistics(bakers, nextProto); } public async Task PostActivation(AppState state) @@ -115,15 +105,6 @@ protected override Task RevertContext(AppState state) { Cache.Accounts.Add(baker); baker.StakingBalance = baker.Balance + baker.DelegatedBalance; - if (baker.Staked && baker.StakingBalance >= nextProto.TokensPerRoll) - { - var activeStake = Math.Min(baker.StakingBalance, baker.Balance * 100 / nextProto.FrozenDepositsPercentage); - baker.FrozenDeposit = activeStake * nextProto.FrozenDepositsPercentage / 100; - } - else - { - baker.FrozenDeposit = 0; - } } return bakers.Where(x => x.Staked).ToList(); } @@ -131,13 +112,9 @@ protected override Task RevertContext(AppState state) async Task MigrateCycles(AppState state, List bakers, Protocol nextProto) { var selectedStakes = bakers - .Where(x => x.StakingBalance >= nextProto.TokensPerRoll) - .Select(x => Math.Min(x.StakingBalance, x.Balance * 100 / nextProto.FrozenDepositsPercentage)); + .Where(x => x.StakingBalance >= nextProto.MinimalStake) + .Select(x => Math.Min(x.StakingBalance, x.Balance * (nextProto.MaxDelegatedOverFrozenRatio + 1))); - var totalStaking = bakers.Sum(x => x.StakingBalance); - var totalDelegated = bakers.Sum(x => x.DelegatedBalance); - var totalDelegators = bakers.Sum(x => x.DelegatorsCount); - var totalBakers = bakers.Count; var selectedBakers = selectedStakes.Count(); var selectedStake = selectedStakes.Sum(); @@ -145,30 +122,55 @@ async Task MigrateCycles(AppState state, List bakers, Prot { cycle.SnapshotIndex = 0; cycle.SnapshotLevel = state.Level; - cycle.TotalStaking = totalStaking; - cycle.TotalDelegated = totalDelegated; - cycle.TotalDelegators = totalDelegators; - cycle.TotalBakers = totalBakers; - cycle.SelectedBakers = selectedBakers; - cycle.SelectedStake = selectedStake; + cycle.TotalBakers = selectedBakers; + cycle.TotalBakingPower = selectedStake; } } - async Task MigrateStatistics(AppState state, List bakers) + void MigrateStatistics(List bakers, Protocol nextProto) { - var stats = await Cache.Statistics.GetAsync(state.Level); - Db.TryAttach(stats); - stats.TotalFrozen = bakers.Sum(x => x.FrozenDeposit); + Cache.Statistics.Current.TotalFrozen = bakers + .Where(x => x.Staked && x.StakingBalance >= nextProto.MinimalStake) + .Sum(x => { + var activeStake = Math.Min(x.StakingBalance, x.Balance * (nextProto.MaxDelegatedOverFrozenRatio + 1)); + return activeStake / (nextProto.MaxDelegatedOverFrozenRatio + 1); + }); } - async Task MigrateSnapshots(AppState state) + Task MigrateSnapshots(AppState state) { - await Db.Database.ExecuteSqlRawAsync($@" - DELETE FROM ""SnapshotBalances"" WHERE ""Level"" = {state.Level}; - INSERT INTO ""SnapshotBalances"" (""Level"", ""Balance"", ""AccountId"", ""DelegateId"", ""DelegatorsCount"", ""DelegatedBalance"", ""StakingBalance"") - SELECT {state.Level}, ""Balance"", ""Id"", ""DelegateId"", ""DelegatorsCount"", ""DelegatedBalance"", ""StakingBalance"" - FROM ""Accounts"" - WHERE ""Staked"" = true;"); + return Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "SnapshotBalances" + WHERE "Level" = {state.Level}; + + INSERT INTO "SnapshotBalances" ( + "Level", + "AccountId", + "BakerId", + "OwnDelegatedBalance", + "ExternalDelegatedBalance", + "DelegatorsCount", + "OwnStakedBalance", + "ExternalStakedBalance", + "StakersCount", + "StakedPseudotokens", + "IssuedPseudotokens" + ) + SELECT + {state.Level}, + "Id", + COALESCE("DelegateId", "Id"), + COALESCE("StakingBalance", "Balance") - COALESCE("DelegatedBalance", 0), + COALESCE("DelegatedBalance", 0), + COALESCE("DelegatorsCount", 0), + 0, + 0, + 0, + 0, + 0 + FROM "Accounts" + WHERE "Staked" = true; + """); } async Task MigrateCurrentRights(AppState state, Protocol prevProto, Protocol nextProto) @@ -178,7 +180,7 @@ async Task MigrateCurrentRights(AppState state, Protocol prevProto, Protocol nex var bakerCycles = await Cache.BakerCycles.GetAsync(state.Cycle); var selectedBakers = await Db.Delegates.AsNoTracking() - .Where(x => x.Staked && x.StakingBalance >= nextProto.TokensPerRoll) + .Where(x => x.Staked && x.StakingBalance >= nextProto.MinimalStake) .ToListAsync(); #region revert current rights @@ -215,20 +217,33 @@ async Task MigrateCurrentRights(AppState state, Protocol prevProto, Protocol nex { bc = new() { - BakerId = baker.Id, - Cycle = state.Cycle + Cycle = state.Cycle, + BakerId = baker.Id }; Db.BakerCycles.Add(bc); Cache.BakerCycles.Add(bc); if (baker.DelegatorsCount > 0) { - await Db.Database.ExecuteSqlRawAsync($@" - INSERT INTO ""DelegatorCycles"" (""Cycle"", ""DelegatorId"", ""BakerId"", ""Balance"") - SELECT {state.Cycle}, ""AccountId"", ""DelegateId"", ""Balance"" - FROM ""SnapshotBalances"" - WHERE ""Level"" = {state.Level} - AND ""DelegateId"" = {baker.Id}"); + await Db.Database.ExecuteSqlRawAsync($""" + INSERT INTO "DelegatorCycles" ( + "Cycle", + "DelegatorId", + "BakerId", + "DelegatedBalance", + "StakedBalance" + ) + SELECT + {state.Cycle}, + "AccountId", + "BakerId", + "OwnDelegatedBalance", + "OwnStakedBalance" + FROM "SnapshotBalances" + WHERE "Level" = {state.Level} + AND "AccountId" != "BakerId" + AND "BakerId" = {baker.Id} + """); } } } @@ -240,18 +255,21 @@ await Db.Database.ExecuteSqlRawAsync($@" var baker = Cache.Accounts.GetDelegate(bakerId); Db.TryAttach(bc); - bc.DelegatedBalance = baker.DelegatedBalance; + bc.OwnDelegatedBalance = baker.StakingBalance - baker.DelegatedBalance; + bc.ExternalDelegatedBalance = baker.DelegatedBalance; bc.DelegatorsCount = baker.DelegatorsCount; - bc.StakingBalance = baker.StakingBalance; - bc.ActiveStake = 0; - bc.SelectedStake = cycle.SelectedStake; + bc.OwnStakedBalance = baker.StakedBalance; + bc.ExternalStakedBalance = baker.ExternalStakedBalance; + bc.StakersCount = baker.StakersCount; + bc.BakingPower = 0; + bc.TotalBakingPower = cycle.TotalBakingPower; - if (baker.StakingBalance >= nextProto.TokensPerRoll) + if (baker.StakingBalance >= nextProto.MinimalStake) { - var activeStake = Math.Min(baker.StakingBalance, baker.Balance * 100 / nextProto.FrozenDepositsPercentage); - var expectedEndorsements = (int)(new BigInteger(nextProto.BlocksPerCycle) * nextProto.EndorsersPerBlock * activeStake / cycle.SelectedStake); + var bakingPower = Math.Min(baker.StakingBalance, baker.Balance * (nextProto.MaxDelegatedOverFrozenRatio + 1)); + var expectedEndorsements = (int)(new BigInteger(nextProto.BlocksPerCycle) * nextProto.EndorsersPerBlock * bakingPower / cycle.TotalBakingPower); + bakerCycles[baker.Id].BakingPower = bakingPower; bakerCycles[baker.Id].FutureEndorsementRewards += expectedEndorsements * nextProto.EndorsementReward0; - bakerCycles[baker.Id].ActiveStake = activeStake; } } #endregion @@ -259,7 +277,7 @@ await Db.Database.ExecuteSqlRawAsync($@" #region apply new rights var sampler = GetSampler(selectedBakers .Where(x => x.Balance > 0) - .Select(x => (x.Id, Math.Min(x.StakingBalance, x.Balance * 100 / nextProto.FrozenDepositsPercentage)))); + .Select(x => (x.Id, Math.Min(x.StakingBalance, x.Balance * (nextProto.MaxDelegatedOverFrozenRatio + 1))))); #region temporary diagnostics await sampler.Validate(Proto, state.Level, cycle.Index); @@ -330,8 +348,8 @@ async Task MigrateFutureRights(AppState state, Protocol nextProto) var bakers = await Db.Delegates.AsNoTracking().Where(x => x.Staked).ToListAsync(); var sampler = GetSampler(bakers - .Where(x => x.StakingBalance >= nextProto.TokensPerRoll && x.Balance > 0) - .Select(x => (x.Id, Math.Min(x.StakingBalance, x.Balance * 100 / nextProto.FrozenDepositsPercentage)))); + .Where(x => x.StakingBalance >= nextProto.MinimalStake && x.Balance > 0) + .Select(x => (x.Id, Math.Min(x.StakingBalance, x.Balance * (nextProto.MaxDelegatedOverFrozenRatio + 1))))); #region temporary diagnostics await sampler.Validate(Proto, state.Level, state.Cycle); @@ -404,12 +422,24 @@ FROM STDIN (FORMAT BINARY)")) #endregion #region save delegator cycles - await Db.Database.ExecuteSqlRawAsync($@" - INSERT INTO ""DelegatorCycles"" (""Cycle"", ""DelegatorId"", ""BakerId"", ""Balance"") - SELECT {cycle.Index}, ""AccountId"", ""DelegateId"", ""Balance"" - FROM ""SnapshotBalances"" - WHERE ""Level"" = {cycle.SnapshotLevel} - AND ""DelegateId"" IS NOT NULL"); + await Db.Database.ExecuteSqlRawAsync($""" + INSERT INTO "DelegatorCycles" ( + "Cycle", + "DelegatorId", + "BakerId", + "DelegatedBalance", + "StakedBalance" + ) + SELECT + {cycle.Index}, + "AccountId", + "BakerId", + "OwnDelegatedBalance", + "OwnStakedBalance" + FROM "SnapshotBalances" + WHERE "Level" = {cycle.SnapshotLevel} + AND "AccountId" != "BakerId" + """); #endregion #region save baker cycles @@ -419,20 +449,23 @@ await Db.Database.ExecuteSqlRawAsync($@" { BakerId = x.Id, Cycle = cycle.Index, - DelegatedBalance = x.DelegatedBalance, - DelegatorsCount = x.DelegatorsCount, - StakingBalance = x.StakingBalance, - ActiveStake = 0, - SelectedStake = cycle.SelectedStake + OwnDelegatedBalance = x.StakingBalance - x.DelegatedBalance, + ExternalDelegatedBalance = x.DelegatedBalance, + DelegatorsCount = x.DelegatorsCount, + OwnStakedBalance = x.StakedBalance, + ExternalStakedBalance = x.ExternalStakedBalance, + StakersCount = x.StakersCount, + BakingPower = 0, + TotalBakingPower = cycle.TotalBakingPower }; - if (x.StakingBalance >= nextProto.TokensPerRoll && x.Balance > 0) + if (x.StakingBalance >= nextProto.MinimalStake && x.Balance > 0) { - var activeStake = Math.Min(x.StakingBalance, x.Balance * 100 / nextProto.FrozenDepositsPercentage); - var expectedEndorsements = (int)(new BigInteger(nextProto.BlocksPerCycle) * nextProto.EndorsersPerBlock * activeStake / cycle.SelectedStake); - bc.ExpectedBlocks = nextProto.BlocksPerCycle * activeStake / cycle.SelectedStake; + var bakingPower = Math.Min(x.StakingBalance, x.Balance * (nextProto.MaxDelegatedOverFrozenRatio + 1)); + var expectedEndorsements = (int)(new BigInteger(nextProto.BlocksPerCycle) * nextProto.EndorsersPerBlock * bakingPower / cycle.TotalBakingPower); + bc.BakingPower = bakingPower; + bc.ExpectedBlocks = nextProto.BlocksPerCycle * bakingPower / cycle.TotalBakingPower; bc.ExpectedEndorsements = expectedEndorsements; bc.FutureEndorsementRewards = expectedEndorsements * nextProto.EndorsementReward0; - bc.ActiveStake = activeStake; } return bc; }); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BakerCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BakerCycleCommit.cs index 793426a11..f20223ce8 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BakerCycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BakerCycleCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Threading.Tasks; +using System.Numerics; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -30,7 +26,7 @@ public virtual async Task Apply( bakerCycle.FutureBlocks--; bakerCycle.FutureBlockRewards -= block.Protocol.MaxBakingReward; bakerCycle.Blocks++; - bakerCycle.BlockRewards += block.Reward + block.Bonus; + bakerCycle.BlockRewardsLiquid += block.RewardLiquid + block.BonusLiquid; bakerCycle.BlockFees += block.Fees; } else @@ -60,22 +56,22 @@ public virtual async Task Apply( if (br.BakerId == block.ProposerId) { - bakerCycle.BlockRewards += block.Reward; + bakerCycle.BlockRewardsLiquid += block.RewardLiquid; bakerCycle.BlockFees += block.Fees; } else if (br.Round < block.PayloadRound) { - bakerCycle.MissedBlockRewards += block.Reward; + bakerCycle.MissedBlockRewards += block.RewardLiquid; bakerCycle.MissedBlockFees += block.Fees; } if (br.BakerId == block.ProducerId) { - bakerCycle.BlockRewards += block.Bonus; + bakerCycle.BlockRewardsLiquid += block.BonusLiquid; } else { - bakerCycle.MissedBlockRewards += block.Bonus; + bakerCycle.MissedBlockRewards += block.BonusLiquid; } } } @@ -104,14 +100,14 @@ public virtual async Task Apply( if (offenderCycle != null) { Db.TryAttach(offenderCycle); - offenderCycle.DoubleBakingLosses += op.OffenderLoss; + offenderCycle.DoubleBakingLostStaked += op.LostStaked; } var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, op.Accuser.Id); if (accuserCycle != null) { Db.TryAttach(accuserCycle); - accuserCycle.DoubleBakingRewards += op.AccuserReward; + accuserCycle.DoubleBakingRewards += op.Reward; } } } @@ -124,14 +120,14 @@ public virtual async Task Apply( if (offenderCycle != null) { Db.TryAttach(offenderCycle); - offenderCycle.DoubleEndorsingLosses += op.OffenderLoss; + offenderCycle.DoubleEndorsingLostStaked += op.LostStaked; } var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, op.Accuser.Id); if (accuserCycle != null) { Db.TryAttach(accuserCycle); - accuserCycle.DoubleEndorsingRewards += op.AccuserReward; + accuserCycle.DoubleEndorsingRewards += op.Reward; } } } @@ -144,14 +140,14 @@ public virtual async Task Apply( if (offenderCycle != null) { Db.TryAttach(offenderCycle); - offenderCycle.DoublePreendorsingLosses += op.OffenderLoss; + offenderCycle.DoublePreendorsingLostStaked += op.LostStaked; } var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, op.Accuser.Id); if (accuserCycle != null) { Db.TryAttach(accuserCycle); - accuserCycle.DoublePreendorsingRewards += op.AccuserReward; + accuserCycle.DoublePreendorsingRewards += op.Reward; } } } @@ -164,7 +160,7 @@ public virtual async Task Apply( if (bakerCycle != null) { Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards += op.Reward; + bakerCycle.NonceRevelationRewardsLiquid += op.RewardLiquid; } } } @@ -176,7 +172,7 @@ public virtual async Task Apply( var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Baker.Id); Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards += op.Reward; + bakerCycle.VdfRevelationRewardsLiquid += op.RewardLiquid; } } #endregion @@ -190,19 +186,22 @@ public virtual async Task Apply( { BakerId = snapshot.AccountId, Cycle = futureCycle.Index, - DelegatedBalance = (long)snapshot.DelegatedBalance, - DelegatorsCount = (int)snapshot.DelegatorsCount, - StakingBalance = (long)snapshot.StakingBalance, - ActiveStake = 0, - SelectedStake = futureCycle.SelectedStake + OwnDelegatedBalance = snapshot.OwnDelegatedBalance, + ExternalDelegatedBalance = snapshot.ExternalDelegatedBalance, + DelegatorsCount = snapshot.DelegatorsCount, + OwnStakedBalance = snapshot.OwnStakedBalance, + ExternalStakedBalance = snapshot.ExternalStakedBalance, + StakersCount = snapshot.StakersCount, + BakingPower = 0, + TotalBakingPower = futureCycle.TotalBakingPower }; - if (selectedStakes.TryGetValue(bakerCycle.BakerId, out var activeStake)) + if (selectedStakes.TryGetValue(bakerCycle.BakerId, out var bakingPower)) { - var expectedEndorsements = (int)(new BigInteger(block.Protocol.BlocksPerCycle) * block.Protocol.EndorsersPerBlock * activeStake / futureCycle.SelectedStake); - bakerCycle.ExpectedBlocks = block.Protocol.BlocksPerCycle * activeStake / futureCycle.SelectedStake; + var expectedEndorsements = (int)(new BigInteger(block.Protocol.BlocksPerCycle) * block.Protocol.EndorsersPerBlock * bakingPower / futureCycle.TotalBakingPower); + bakerCycle.BakingPower = bakingPower; + bakerCycle.ExpectedBlocks = block.Protocol.BlocksPerCycle * bakingPower / futureCycle.TotalBakingPower; bakerCycle.ExpectedEndorsements = expectedEndorsements; bakerCycle.FutureEndorsementRewards = expectedEndorsements * block.Protocol.EndorsementReward0; - bakerCycle.ActiveStake = activeStake; } return bakerCycle; }); @@ -263,7 +262,7 @@ public virtual async Task Revert(Block block) bakerCycle.FutureBlocks++; bakerCycle.FutureBlockRewards += block.Protocol.MaxBakingReward; bakerCycle.Blocks--; - bakerCycle.BlockRewards -= block.Reward + block.Bonus; + bakerCycle.BlockRewardsLiquid -= block.RewardLiquid + block.BonusLiquid; bakerCycle.BlockFees -= block.Fees; } else @@ -299,22 +298,22 @@ public virtual async Task Revert(Block block) if (br.BakerId == block.ProposerId) { - bakerCycle.BlockRewards -= block.Reward; + bakerCycle.BlockRewardsLiquid -= block.RewardLiquid; bakerCycle.BlockFees -= block.Fees; } else if (br.Round < bakerRound) { - bakerCycle.MissedBlockRewards -= block.Reward; + bakerCycle.MissedBlockRewards -= block.RewardLiquid; bakerCycle.MissedBlockFees -= block.Fees; } if (br.BakerId == block.ProducerId) { - bakerCycle.BlockRewards -= block.Bonus; + bakerCycle.BlockRewardsLiquid -= block.BonusLiquid; } else { - bakerCycle.MissedBlockRewards -= block.Bonus; + bakerCycle.MissedBlockRewards -= block.BonusLiquid; } } } @@ -343,14 +342,14 @@ public virtual async Task Revert(Block block) if (offenderCycle != null) { Db.TryAttach(offenderCycle); - offenderCycle.DoubleBakingLosses -= op.OffenderLoss; + offenderCycle.DoubleBakingLostStaked -= op.LostStaked; } var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, op.AccuserId); if (accuserCycle != null) { Db.TryAttach(accuserCycle); - accuserCycle.DoubleBakingRewards -= op.AccuserReward; + accuserCycle.DoubleBakingRewards -= op.Reward; } } } @@ -363,14 +362,14 @@ public virtual async Task Revert(Block block) if (offenderCycle != null) { Db.TryAttach(offenderCycle); - offenderCycle.DoubleEndorsingLosses -= op.OffenderLoss; + offenderCycle.DoubleEndorsingLostStaked -= op.LostStaked; } var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, op.AccuserId); if (accuserCycle != null) { Db.TryAttach(accuserCycle); - accuserCycle.DoubleEndorsingRewards -= op.AccuserReward; + accuserCycle.DoubleEndorsingRewards -= op.Reward; } } } @@ -383,14 +382,14 @@ public virtual async Task Revert(Block block) if (offenderCycle != null) { Db.TryAttach(offenderCycle); - offenderCycle.DoublePreendorsingLosses -= op.OffenderLoss; + offenderCycle.DoublePreendorsingLostStaked -= op.LostStaked; } var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, op.AccuserId); if (accuserCycle != null) { Db.TryAttach(accuserCycle); - accuserCycle.DoublePreendorsingRewards -= op.AccuserReward; + accuserCycle.DoublePreendorsingRewards -= op.Reward; } } } @@ -403,7 +402,7 @@ public virtual async Task Revert(Block block) if (bakerCycle != null) { Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards -= op.Reward; + bakerCycle.NonceRevelationRewardsLiquid -= op.RewardLiquid; } } } @@ -415,7 +414,7 @@ public virtual async Task Revert(Block block) var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.BakerId); Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards -= op.Reward; + bakerCycle.VdfRevelationRewardsLiquid -= op.RewardLiquid; } } #endregion @@ -423,9 +422,10 @@ public virtual async Task Revert(Block block) #region new cycle if (block.Events.HasFlag(BlockEvents.CycleBegin)) { - await Db.Database.ExecuteSqlRawAsync($@" - DELETE FROM ""BakerCycles"" - WHERE ""Cycle"" = {block.Cycle + block.Protocol.PreservedCycles}"); + await Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "BakerCycles" + WHERE "Cycle" = {block.Cycle + block.Protocol.PreservedCycles} + """); } #endregion } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BakingRightsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BakingRightsCommit.cs index 6977da8ce..353c1c3d0 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BakingRightsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BakingRightsCommit.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Netezos.Encoding; using Npgsql; using Tzkt.Data.Models; @@ -50,7 +47,7 @@ DELETE FROM ""BakingRights"" var cycle = await Db.Cycles.FirstAsync(x => x.Index == block.Cycle); var bakerCycles = await Cache.BakerCycles.GetAsync(block.Cycle); var sampler = GetSampler( - bakerCycles.Values.Where(x => x.ActiveStake > 0).Select(x => (x.BakerId, x.ActiveStake)), + bakerCycles.Values.Where(x => x.BakingPower > 0).Select(x => (x.BakerId, x.BakingPower)), block.ProtoCode > 1 && block.Cycle <= block.Protocol.FirstCycle + block.Protocol.PreservedCycles); //TODO: remove this crutch after ithaca is gone #region temporary diagnostics await sampler.Validate(Proto, block.Level, block.Cycle); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BlockCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BlockCommit.cs index dbe053eae..d96bff6ab 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BlockCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/BlockCommit.cs @@ -1,6 +1,4 @@ -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Netezos.Encoding; using Tzkt.Data.Models; @@ -60,15 +58,15 @@ public virtual async Task Apply(JsonElement rawBlock) ProposerId = proposer.Id, ProducerId = producer.Id, Events = events, - Reward = rewardUpdate.ValueKind == JsonValueKind.Undefined ? 0 : -rewardUpdate.RequiredInt64("change"), - Bonus = bonusUpdate.ValueKind == JsonValueKind.Undefined ? 0 : -bonusUpdate.RequiredInt64("change"), + RewardLiquid = rewardUpdate.ValueKind == JsonValueKind.Undefined ? 0 : -rewardUpdate.RequiredInt64("change"), + BonusLiquid = bonusUpdate.ValueKind == JsonValueKind.Undefined ? 0 : -bonusUpdate.RequiredInt64("change"), LBToggle = GetLBToggleVote(rawBlock), LBToggleEma = GetLBToggleEma(rawBlock) }; Db.TryAttach(proposer); - proposer.Balance += Block.Reward; - proposer.StakingBalance += Block.Reward; + proposer.Balance += Block.RewardLiquid; + proposer.StakingBalance += Block.RewardLiquid; proposer.BlocksCount++; #region set baker active @@ -84,8 +82,8 @@ public virtual async Task Apply(JsonElement rawBlock) #endregion Db.TryAttach(producer); - producer.Balance += Block.Bonus; - producer.StakingBalance += Block.Bonus; + producer.Balance += Block.BonusLiquid; + producer.StakingBalance += Block.BonusLiquid; if (producer.Id != proposer.Id) { producer.BlocksCount++; @@ -107,6 +105,8 @@ public virtual async Task Apply(JsonElement rawBlock) if (Block.Events.HasFlag(BlockEvents.ProtocolEnd)) protocol.LastLevel = Block.Level; + Cache.Statistics.Current.TotalCreated += Block.RewardLiquid + Block.BonusLiquid; + Db.Blocks.Add(Block); Cache.Blocks.Add(Block); } @@ -119,8 +119,8 @@ public virtual async Task Revert(Block block) var proposer = Block.Proposer; Db.TryAttach(proposer); - proposer.Balance -= Block.Reward; - proposer.StakingBalance -= Block.Reward; + proposer.Balance -= Block.RewardLiquid; + proposer.StakingBalance -= Block.RewardLiquid; proposer.BlocksCount--; #region reset baker activity @@ -135,8 +135,8 @@ public virtual async Task Revert(Block block) var producer = Cache.Accounts.GetDelegate(block.ProducerId); Db.TryAttach(producer); - producer.Balance -= Block.Bonus; - producer.StakingBalance -= Block.Bonus; + producer.Balance -= Block.BonusLiquid; + producer.StakingBalance -= Block.BonusLiquid; if (producer.Id != proposer.Id) { producer.BlocksCount--; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/CycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/CycleCommit.cs index 3eb36fff9..2d0265a11 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/CycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/CycleCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto12 @@ -64,16 +60,16 @@ public virtual async Task Apply(Block block) Snapshots = await Db.SnapshotBalances .AsNoTracking() - .Where(x => x.Level == snapshotLevel && x.DelegateId == null) + .Where(x => x.Level == snapshotLevel && x.AccountId == x.BakerId) .ToListAsync(); var endorsingRewards = activation ? new() : await Db.BakerCycles .AsNoTracking() - .Where(x => x.Cycle == block.Cycle - 1 && x.EndorsementRewards > 0) - .ToDictionaryAsync(x => x.BakerId, x => x.EndorsementRewards); + .Where(x => x.Cycle == block.Cycle - 1 && x.EndorsementRewardsLiquid > 0) + .ToDictionaryAsync(x => x.BakerId, x => x.EndorsementRewardsLiquid); SelectedStakes = Snapshots - .Where(x => x.StakingBalance >= block.Protocol.TokensPerRoll) + .Where(x => x.StakingBalance >= block.Protocol.MinimalStake) .ToDictionary(x => x.AccountId, x => { var baker = Cache.Accounts.GetDelegate(x.AccountId); @@ -82,12 +78,12 @@ public virtual async Task Apply(Block block) if (endorsingRewards.TryGetValue(baker.Id, out var reward)) lastBalance -= reward; if (block.ProposerId == baker.Id) - lastBalance -= block.Reward; + lastBalance -= block.RewardLiquid; if (block.ProducerId == baker.Id) - lastBalance -= block.Bonus; + lastBalance -= block.BonusLiquid; var depositCap = Math.Min(lastBalance, baker.FrozenDepositLimit ?? (long.MaxValue / 100)); - return Math.Min((long)x.StakingBalance, depositCap * 100 / block.Protocol.FrozenDepositsPercentage); + return Math.Min((long)x.StakingBalance, depositCap * (block.Protocol.MaxDelegatedOverFrozenRatio + 1)); }); FutureCycle = new Cycle @@ -97,12 +93,8 @@ public virtual async Task Apply(Block block) LastLevel = block.Protocol.GetCycleEnd(futureCycle), SnapshotIndex = snapshotIndex, SnapshotLevel = snapshotLevel, - TotalStaking = Snapshots.Sum(x => (long)x.StakingBalance), - TotalDelegated = Snapshots.Sum(x => (long)x.DelegatedBalance), - TotalDelegators = Snapshots.Sum(x => (int)x.DelegatorsCount), - SelectedBakers = SelectedStakes.Count, - SelectedStake = SelectedStakes.Values.Sum(), - TotalBakers = Snapshots.Count, + TotalBakers = SelectedStakes.Count, + TotalBakingPower = SelectedStakes.Values.Sum(), Seed = futureSeed }; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/EndorsingRewardCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/EndorsingRewardCommit.cs index 35d1ddb90..45ac0302a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/EndorsingRewardCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/EndorsingRewardCommit.cs @@ -37,7 +37,7 @@ public virtual async Task Apply(Block block, JsonElement rawBlock) Level = block.Level, Timestamp = block.Timestamp, Expected = bakerCycle.FutureEndorsementRewards, - Received = bakerCycle.FutureEndorsementRewards + RewardLiquid = bakerCycle.FutureEndorsementRewards }); Db.TryAttach(bakerCycle); @@ -46,13 +46,13 @@ public virtual async Task Apply(Block block, JsonElement rawBlock) if (bakerCycle.FutureEndorsementRewards != loss) throw new Exception("FutureEndorsementRewards != loss"); - Ops[^1].Received = 0; + Ops[^1].RewardLiquid = 0; bakerCycle.MissedEndorsementRewards += bakerCycle.FutureEndorsementRewards; bakerCycle.FutureEndorsementRewards = 0; } else { - bakerCycle.EndorsementRewards += bakerCycle.FutureEndorsementRewards; + bakerCycle.EndorsementRewardsLiquid += bakerCycle.FutureEndorsementRewards; bakerCycle.FutureEndorsementRewards = 0; } } @@ -62,11 +62,13 @@ public virtual async Task Apply(Block block, JsonElement rawBlock) var baker = Cache.Accounts.GetDelegate(op.BakerId); Db.TryAttach(baker); - baker.Balance += op.Received; - baker.StakingBalance += op.Received; + baker.Balance += op.RewardLiquid; + baker.StakingBalance += op.RewardLiquid; baker.EndorsingRewardsCount++; block.Operations |= Operations.EndorsingRewards; + + Cache.Statistics.Current.TotalCreated += op.RewardLiquid; } Cache.AppState.Get().EndorsingRewardOpsCount += Ops.Count; @@ -86,16 +88,16 @@ public virtual async Task Revert(Block block) var baker = Cache.Accounts.GetDelegate(op.BakerId); Db.TryAttach(baker); - baker.Balance -= op.Received; - baker.StakingBalance -= op.Received; + baker.Balance -= op.RewardLiquid; + baker.StakingBalance -= op.RewardLiquid; baker.EndorsingRewardsCount--; var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, baker.Id); Db.TryAttach(bakerCycle); bakerCycle.FutureEndorsementRewards = op.Expected; - if (op.Expected == op.Received) - bakerCycle.EndorsementRewards -= op.Expected; + if (op.Expected == op.RewardLiquid) + bakerCycle.EndorsementRewardsLiquid -= op.Expected; else bakerCycle.MissedEndorsementRewards -= op.Expected; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/FreezerCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/FreezerCommit.cs index e774b8250..c32355f22 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/FreezerCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/FreezerCommit.cs @@ -1,18 +1,13 @@ -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto12 { class FreezerCommit : ProtocolCommit { - public long FreezerChange { get; private set; } - public FreezerCommit(ProtocolHandler protocol) : base(protocol) { } - public virtual void Apply(Block block, JsonElement rawBlock) + public void Apply(Block block, JsonElement rawBlock) { if (!block.Events.HasFlag(BlockEvents.CycleEnd)) return; @@ -22,38 +17,13 @@ public virtual void Apply(Block block, JsonElement rawBlock) x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits")) { - var baker = Cache.Accounts.GetDelegate(update.RequiredString("delegate")); - var freezerUpdate = new FreezerUpdate - { - BakerId = baker.Id, - Cycle = block.Cycle, - Change = update.RequiredInt64("change") - }; - - Db.TryAttach(baker); - baker.FrozenDeposit += freezerUpdate.Change; - - FreezerChange += freezerUpdate.Change; - - Db.FreezerUpdates.Add(freezerUpdate); + Cache.Statistics.Current.TotalFrozen += update.RequiredInt64("change"); } } - public virtual async Task Revert(Block block) + public void Revert() { - if (!block.Events.HasFlag(BlockEvents.CycleEnd)) - return; - - foreach (var freezerUpdate in await Db.FreezerUpdates.Where(x => x.Cycle == block.Cycle).ToListAsync()) - { - var baker = Cache.Accounts.GetDelegate(freezerUpdate.BakerId); - Db.TryAttach(baker); - baker.FrozenDeposit -= freezerUpdate.Change; - - FreezerChange -= freezerUpdate.Change; - - Db.FreezerUpdates.Remove(freezerUpdate); - } + // there is nothing to revert } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoubleBakingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoubleBakingCommit.cs index ba1a6eb56..e3b80e798 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoubleBakingCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoubleBakingCommit.cs @@ -1,5 +1,4 @@ -using System.Linq; -using System.Text.Json; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto12 @@ -12,19 +11,19 @@ public virtual void Apply(Block block, JsonElement op, JsonElement content) { #region init var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); - var freezerUpdate = balanceUpdates.FirstOrDefault(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits"); - var contractUpdate = balanceUpdates.FirstOrDefault(x => x.RequiredString("kind") == "contract"); + var freezerUpdates = balanceUpdates.Where(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits"); + var contractUpdates = balanceUpdates.Where(x => x.RequiredString("kind") == "contract"); - var offenderAddr = freezerUpdate.ValueKind != JsonValueKind.Undefined - ? freezerUpdate.RequiredString("delegate") + var offenderAddr = freezerUpdates.Any() + ? freezerUpdates.First().RequiredString("delegate") : block.Proposer.Address; // this is wrong, but no big deal - var offenderLoss = freezerUpdate.ValueKind != JsonValueKind.Undefined - ? -freezerUpdate.RequiredInt64("change") + var offenderLoss = freezerUpdates.Any() + ? -freezerUpdates.Sum(x => x.RequiredInt64("change")) : 0; - var accuserReward = contractUpdate.ValueKind != JsonValueKind.Undefined - ? contractUpdate.RequiredInt64("change") + var accuserReward = contractUpdates.Any() + ? contractUpdates.Sum(x => x.RequiredInt64("change")) : 0; var doubleBaking = new DoubleBakingOperation @@ -35,12 +34,18 @@ public virtual void Apply(Block block, JsonElement op, JsonElement content) Timestamp = block.Timestamp, OpHash = op.RequiredString("hash"), + SlashedLevel = block.Level, AccusedLevel = content.Required("bh1").RequiredInt32("level"), Accuser = block.Proposer, Offender = Cache.Accounts.GetDelegate(offenderAddr), - AccuserReward = accuserReward, - OffenderLoss = offenderLoss + Reward = accuserReward, + LostStaked = offenderLoss, + LostUnstaked = 0, + LostExternalStaked = 0, + LostExternalUnstaked = 0, + + RoundingLoss = 0 }; #endregion @@ -52,17 +57,19 @@ public virtual void Apply(Block block, JsonElement op, JsonElement content) #endregion #region apply operation - accuser.Balance += doubleBaking.AccuserReward; - accuser.StakingBalance += doubleBaking.AccuserReward; + accuser.Balance += doubleBaking.Reward; + accuser.StakingBalance += doubleBaking.Reward; - offender.Balance -= doubleBaking.OffenderLoss; - offender.FrozenDeposit -= doubleBaking.OffenderLoss; - offender.StakingBalance -= doubleBaking.OffenderLoss; + offender.Balance -= doubleBaking.LostStaked; + offender.StakingBalance -= doubleBaking.LostStaked; accuser.DoubleBakingCount++; if (offender != accuser) offender.DoubleBakingCount++; block.Operations |= Operations.DoubleBakings; + + Cache.Statistics.Current.TotalBurned += doubleBaking.LostStaked - doubleBaking.Reward; + Cache.Statistics.Current.TotalFrozen -= doubleBaking.LostStaked; #endregion Db.DoubleBakingOps.Add(doubleBaking); @@ -86,12 +93,11 @@ public virtual void Revert(Block block, DoubleBakingOperation doubleBaking) #endregion #region apply operation - accuser.Balance -= doubleBaking.AccuserReward; - accuser.StakingBalance -= doubleBaking.AccuserReward; + accuser.Balance -= doubleBaking.Reward; + accuser.StakingBalance -= doubleBaking.Reward; - offender.Balance += doubleBaking.OffenderLoss; - offender.FrozenDeposit += doubleBaking.OffenderLoss; - offender.StakingBalance += doubleBaking.OffenderLoss; + offender.Balance += doubleBaking.LostStaked; + offender.StakingBalance += doubleBaking.LostStaked; accuser.DoubleBakingCount--; if (offender != accuser) offender.DoubleBakingCount--; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoubleEndorsingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoubleEndorsingCommit.cs index c15c753d4..a924a46f0 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoubleEndorsingCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoubleEndorsingCommit.cs @@ -1,5 +1,4 @@ -using System.Linq; -using System.Text.Json; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto12 @@ -12,19 +11,19 @@ public virtual void Apply(Block block, JsonElement op, JsonElement content) { #region init var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); - var freezerUpdate = balanceUpdates.FirstOrDefault(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits"); - var contractUpdate = balanceUpdates.FirstOrDefault(x => x.RequiredString("kind") == "contract"); + var freezerUpdates = balanceUpdates.Where(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits"); + var contractUpdates = balanceUpdates.Where(x => x.RequiredString("kind") == "contract"); - var offenderAddr = freezerUpdate.ValueKind != JsonValueKind.Undefined - ? freezerUpdate.RequiredString("delegate") + var offenderAddr = freezerUpdates.Any() + ? freezerUpdates.First().RequiredString("delegate") : block.Proposer.Address; // this is wrong, but no big deal - var offenderLoss = freezerUpdate.ValueKind != JsonValueKind.Undefined - ? -freezerUpdate.RequiredInt64("change") + var offenderLoss = freezerUpdates.Any() + ? -freezerUpdates.Sum(x => x.RequiredInt64("change")) : 0; - var accuserReward = contractUpdate.ValueKind != JsonValueKind.Undefined - ? contractUpdate.RequiredInt64("change") + var accuserReward = contractUpdates.Any() + ? contractUpdates.Sum(x => x.RequiredInt64("change")) : 0; var doubleEndorsing = new DoubleEndorsingOperation @@ -35,12 +34,18 @@ public virtual void Apply(Block block, JsonElement op, JsonElement content) Timestamp = block.Timestamp, OpHash = op.RequiredString("hash"), + SlashedLevel = block.Level, AccusedLevel = content.Required("op1").Required("operations").RequiredInt32("level") + 1, Accuser = block.Proposer, Offender = Cache.Accounts.GetDelegate(offenderAddr), - AccuserReward = accuserReward, - OffenderLoss = offenderLoss + Reward = accuserReward, + LostStaked = offenderLoss, + LostUnstaked = 0, + LostExternalStaked = 0, + LostExternalUnstaked = 0, + + RoundingLoss = 0 }; #endregion @@ -52,17 +57,19 @@ public virtual void Apply(Block block, JsonElement op, JsonElement content) #endregion #region apply operation - accuser.Balance += doubleEndorsing.AccuserReward; - accuser.StakingBalance += doubleEndorsing.AccuserReward; + accuser.Balance += doubleEndorsing.Reward; + accuser.StakingBalance += doubleEndorsing.Reward; - offender.Balance -= doubleEndorsing.OffenderLoss; - offender.FrozenDeposit -= doubleEndorsing.OffenderLoss; - offender.StakingBalance -= doubleEndorsing.OffenderLoss; + offender.Balance -= doubleEndorsing.LostStaked; + offender.StakingBalance -= doubleEndorsing.LostStaked; accuser.DoubleEndorsingCount++; if (offender != accuser) offender.DoubleEndorsingCount++; block.Operations |= Operations.DoubleEndorsings; + + Cache.Statistics.Current.TotalBurned += doubleEndorsing.LostStaked - doubleEndorsing.Reward; + Cache.Statistics.Current.TotalFrozen -= doubleEndorsing.LostStaked; #endregion Db.DoubleEndorsingOps.Add(doubleEndorsing); @@ -86,12 +93,11 @@ public virtual void Revert(Block block, DoubleEndorsingOperation doubleEndorsing #endregion #region apply operation - accuser.Balance -= doubleEndorsing.AccuserReward; - accuser.StakingBalance -= doubleEndorsing.AccuserReward; + accuser.Balance -= doubleEndorsing.Reward; + accuser.StakingBalance -= doubleEndorsing.Reward; - offender.Balance += doubleEndorsing.OffenderLoss; - offender.FrozenDeposit += doubleEndorsing.OffenderLoss; - offender.StakingBalance += doubleEndorsing.OffenderLoss; + offender.Balance += doubleEndorsing.LostStaked; + offender.StakingBalance += doubleEndorsing.LostStaked; accuser.DoubleEndorsingCount--; if (offender != accuser) offender.DoubleEndorsingCount--; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoublePreendorsingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoublePreendorsingCommit.cs index 5c571d681..08da58fa3 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoublePreendorsingCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/DoublePreendorsingCommit.cs @@ -1,5 +1,4 @@ -using System.Linq; -using System.Text.Json; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto12 @@ -12,19 +11,19 @@ public virtual void Apply(Block block, JsonElement op, JsonElement content) { #region init var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); - var freezerUpdate = balanceUpdates.FirstOrDefault(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits"); - var contractUpdate = balanceUpdates.FirstOrDefault(x => x.RequiredString("kind") == "contract"); + var freezerUpdates = balanceUpdates.Where(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits"); + var contractUpdates = balanceUpdates.Where(x => x.RequiredString("kind") == "contract"); - var offenderAddr = freezerUpdate.ValueKind != JsonValueKind.Undefined - ? freezerUpdate.RequiredString("delegate") + var offenderAddr = freezerUpdates.Any() + ? freezerUpdates.First().RequiredString("delegate") : block.Proposer.Address; // this is wrong, but no big deal - var offenderLoss = freezerUpdate.ValueKind != JsonValueKind.Undefined - ? -freezerUpdate.RequiredInt64("change") + var offenderLoss = freezerUpdates.Any() + ? -freezerUpdates.Sum(x => x.RequiredInt64("change")) : 0; - var accuserReward = contractUpdate.ValueKind != JsonValueKind.Undefined - ? contractUpdate.RequiredInt64("change") + var accuserReward = contractUpdates.Any() + ? contractUpdates.Sum(x => x.RequiredInt64("change")) : 0; var doublePreendorsing = new DoublePreendorsingOperation @@ -35,12 +34,18 @@ public virtual void Apply(Block block, JsonElement op, JsonElement content) Timestamp = block.Timestamp, OpHash = op.RequiredString("hash"), + SlashedLevel = block.Level, AccusedLevel = content.Required("op1").Required("operations").RequiredInt32("level"), Accuser = block.Proposer, Offender = Cache.Accounts.GetDelegate(offenderAddr), - AccuserReward = accuserReward, - OffenderLoss = offenderLoss + Reward = accuserReward, + LostStaked = offenderLoss, + LostUnstaked = 0, + LostExternalStaked = 0, + LostExternalUnstaked = 0, + + RoundingLoss = 0 }; #endregion @@ -52,17 +57,19 @@ public virtual void Apply(Block block, JsonElement op, JsonElement content) #endregion #region apply operation - accuser.Balance += doublePreendorsing.AccuserReward; - accuser.StakingBalance += doublePreendorsing.AccuserReward; + accuser.Balance += doublePreendorsing.Reward; + accuser.StakingBalance += doublePreendorsing.Reward; - offender.Balance -= doublePreendorsing.OffenderLoss; - offender.FrozenDeposit -= doublePreendorsing.OffenderLoss; - offender.StakingBalance -= doublePreendorsing.OffenderLoss; + offender.Balance -= doublePreendorsing.LostStaked; + offender.StakingBalance -= doublePreendorsing.LostStaked; accuser.DoublePreendorsingCount++; if (offender != accuser) offender.DoublePreendorsingCount++; block.Operations |= Operations.DoublePreendorsings; + + Cache.Statistics.Current.TotalBurned += doublePreendorsing.LostStaked - doublePreendorsing.Reward; + Cache.Statistics.Current.TotalFrozen -= doublePreendorsing.LostStaked; #endregion Db.DoublePreendorsingOps.Add(doublePreendorsing); @@ -86,12 +93,11 @@ public virtual void Revert(Block block, DoublePreendorsingOperation doublePreend #endregion #region apply operation - accuser.Balance -= doublePreendorsing.AccuserReward; - accuser.StakingBalance -= doublePreendorsing.AccuserReward; + accuser.Balance -= doublePreendorsing.Reward; + accuser.StakingBalance -= doublePreendorsing.Reward; - offender.Balance += doublePreendorsing.OffenderLoss; - offender.FrozenDeposit += doublePreendorsing.OffenderLoss; - offender.StakingBalance += doublePreendorsing.OffenderLoss; + offender.Balance += doublePreendorsing.LostStaked; + offender.StakingBalance += doublePreendorsing.LostStaked; accuser.DoublePreendorsingCount--; if (offender != accuser) offender.DoublePreendorsingCount--; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/NonceRevelationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/NonceRevelationsCommit.cs index 678704347..baecf1427 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/NonceRevelationsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/Operations/NonceRevelationsCommit.cs @@ -1,5 +1,4 @@ using System.Text.Json; -using System.Threading.Tasks; using Netezos.Encoding; using Tzkt.Data.Models; @@ -12,6 +11,13 @@ public NonceRevelationsCommit(ProtocolHandler protocol) : base(protocol) { } public virtual async Task Apply(Block block, JsonElement op, JsonElement content) { #region init + var balanceUpdate = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray() + .FirstOrDefault(x => x.RequiredString("kind") == "contract"); + + var reward = balanceUpdate.ValueKind != JsonValueKind.Undefined + ? balanceUpdate.RequiredInt64("change") + : 0; + var revealedBlock = await Cache.Blocks.GetAsync(content.RequiredInt32("level")); var revelation = new NonceRevelationOperation { @@ -26,7 +32,7 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content RevealedLevel = revealedBlock.Level, RevealedCycle = revealedBlock.Cycle, Nonce = Hex.Parse(content.RequiredString("nonce")), - Reward = block.Protocol.RevelationReward + RewardLiquid = reward }; #endregion @@ -40,8 +46,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content #endregion #region apply operation - blockBaker.Balance += revelation.Reward; - blockBaker.StakingBalance += revelation.Reward; + blockBaker.Balance += revelation.RewardLiquid; + blockBaker.StakingBalance += revelation.RewardLiquid; sender.NonceRevelationsCount++; if (blockBaker != sender) blockBaker.NonceRevelationsCount++; @@ -49,6 +55,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content block.Operations |= Operations.Revelations; revealedBlock.Revelation = revelation; + + Cache.Statistics.Current.TotalCreated += revelation.RewardLiquid; #endregion Db.NonceRevelationOps.Add(revelation); @@ -77,8 +85,8 @@ public virtual async Task Revert(Block block, NonceRevelationOperation revelatio #endregion #region apply operation - blockBaker.Balance -= revelation.Reward; - blockBaker.StakingBalance -= revelation.Reward; + blockBaker.Balance -= revelation.RewardLiquid; + blockBaker.StakingBalance -= revelation.RewardLiquid; sender.NonceRevelationsCount--; if (blockBaker != sender) blockBaker.NonceRevelationsCount--; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/SnapshotBalanceCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/SnapshotBalanceCommit.cs index 0a0cc94c2..75d9e8f51 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/SnapshotBalanceCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/SnapshotBalanceCommit.cs @@ -1,97 +1,31 @@ -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto12 { - class SnapshotBalanceCommit : ProtocolCommit + class SnapshotBalanceCommit : Proto9.SnapshotBalanceCommit { public SnapshotBalanceCommit(ProtocolHandler protocol) : base(protocol) { } - public async Task Apply(Block block, JsonElement rawBlock) + protected override async Task SubtractCycleRewards(JsonElement rawBlock, Block block) { - if (block.Events.HasFlag(BlockEvents.BalanceSnapshot)) - { - #region remove outdated - var delete = string.Empty; - var outdatedLevel = block.Level - (block.Protocol.PreservedCycles + 3) * block.Protocol.BlocksPerCycle; - if (outdatedLevel > 0) - { - delete += block.Cycle <= block.Protocol.FirstCycle + block.Protocol.PreservedCycles + 4 - ? $@"DELETE FROM ""SnapshotBalances"" WHERE ""Level"" <= {outdatedLevel};" - : $@"DELETE FROM ""SnapshotBalances"" WHERE ""Level"" = {outdatedLevel};"; - } - #endregion - - #region make snapshot - await Db.Database.ExecuteSqlRawAsync($@" - {delete} - INSERT INTO ""SnapshotBalances"" (""Level"", ""Balance"", ""AccountId"", ""DelegateId"", ""DelegatorsCount"", ""DelegatedBalance"", ""StakingBalance"") - SELECT {block.Level}, ""Balance"", ""Id"", ""DelegateId"", ""DelegatorsCount"", ""DelegatedBalance"", ""StakingBalance"" - FROM ""Accounts"" - WHERE ""Staked"" = true"); - #endregion - - #region ignore just deactivated - if (block.Events.HasFlag(BlockEvents.Deactivations)) - { - var deactivated = await Db.Delegates - .AsNoTracking() - .Include(x => x.DelegatedAccounts) - .Where(x => x.DeactivationLevel == block.Level) - .ToListAsync(); - - if (deactivated.Any()) - { - var sql = @" - INSERT INTO ""SnapshotBalances"" (""Level"", ""Balance"", ""AccountId"", ""DelegateId"", ""DelegatorsCount"", ""DelegatedBalance"", ""StakingBalance"") VALUES "; - - foreach (var baker in deactivated) - { - sql += $@" - ({block.Level}, {baker.Balance}, {baker.Id}, NULL, {baker.DelegatorsCount}, {baker.DelegatedBalance}, {baker.StakingBalance}),"; - - foreach (var delegator in baker.DelegatedAccounts) - sql += $@" - ({block.Level}, {delegator.Balance}, {delegator.Id}, {delegator.DelegateId}, NULL, NULL, NULL),"; - } - - await Db.Database.ExecuteSqlRawAsync(sql[..^1]); - } - } - #endregion - - #region revert endorsing rewards - if (block.Events.HasFlag(BlockEvents.CycleEnd)) - { - await Db.Database.ExecuteSqlRawAsync($@" - UPDATE ""SnapshotBalances"" as sb - SET ""Balance"" = ""Balance"" - bc.""EndorsementRewards"", - ""StakingBalance"" = ""StakingBalance"" - bc.""EndorsementRewards"" - FROM ( - SELECT ""BakerId"", ""EndorsementRewards"" - FROM ""BakerCycles"" - WHERE ""Cycle"" = {block.Cycle} - AND ""EndorsementRewards"" != 0 - ) as bc - WHERE sb.""Level"" = {block.Level} - AND sb.""DelegateId"" IS NULL - AND sb.""AccountId"" = bc.""BakerId"""); - } - #endregion - } - } - - public async Task Revert(Block block) - { - if (block.Events.HasFlag(BlockEvents.BalanceSnapshot)) - { - await Db.Database.ExecuteSqlRawAsync($@" - DELETE FROM ""SnapshotBalances"" - WHERE ""Level"" = {block.Level}"); - } + if (!block.Events.HasFlag(BlockEvents.CycleEnd)) + return; + + await Db.Database.ExecuteSqlRawAsync($""" + UPDATE "SnapshotBalances" as sb + SET "OwnDelegatedBalance" = "OwnDelegatedBalance" - bc."EndorsementRewardsLiquid" + FROM ( + SELECT "BakerId", "EndorsementRewardsLiquid" + FROM "BakerCycles" + WHERE "Cycle" = {block.Cycle} + AND "EndorsementRewardsLiquid" != 0 + ) as bc + WHERE sb."Level" = {block.Level} + AND sb."AccountId" = bc."BakerId" + AND sb."BakerId" = bc."BakerId" + """); } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/StatisticsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/StatisticsCommit.cs index 4e8a47bc1..cdc521a4e 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/StatisticsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Commits/StatisticsCommit.cs @@ -1,264 +1,7 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Tzkt.Data.Models; -using Tzkt.Data.Models.Base; - -namespace Tzkt.Sync.Protocols.Proto12 +namespace Tzkt.Sync.Protocols.Proto12 { - class StatisticsCommit : ProtocolCommit + class StatisticsCommit : Proto1.StatisticsCommit { public StatisticsCommit(ProtocolHandler protocol) : base(protocol) { } - - public virtual async Task Apply(Block block, List endorsingRewards, long freezerChange) - { - var prev = await Cache.Statistics.GetAsync(block.Level - 1); - var statistics = new Statistics - { - Level = block.Level, - TotalActivated = prev.TotalActivated, - TotalBootstrapped = prev.TotalBootstrapped, - TotalBurned = prev.TotalBurned, - TotalBanished = prev.TotalBanished, - TotalCommitments = prev.TotalCommitments, - TotalCreated = prev.TotalCreated, - TotalFrozen = prev.TotalFrozen, - TotalRollupBonds = prev.TotalRollupBonds, - TotalSmartRollupBonds = prev.TotalSmartRollupBonds - }; - - statistics.TotalFrozen += freezerChange; - - statistics.TotalCreated += block.Reward; - statistics.TotalCreated += block.Bonus; - - if (endorsingRewards?.Count > 0) - statistics.TotalCreated += endorsingRewards.Sum(x => x.Received); - - if (block.Activations != null) - statistics.TotalActivated += block.Activations.Sum(x => x.Balance); - - if (block.DoubleBakings != null) - { - statistics.TotalBurned += block.DoubleBakings.Sum(x => x.OffenderLoss - x.AccuserReward); - statistics.TotalFrozen -= block.DoubleBakings.Sum(x => x.OffenderLoss); - } - - if (block.DoubleEndorsings != null) - { - statistics.TotalBurned += block.DoubleEndorsings.Sum(x => x.OffenderLoss - x.AccuserReward); - statistics.TotalFrozen -= block.DoubleEndorsings.Sum(x => x.OffenderLoss); - } - - if (block.DoublePreendorsings != null) - { - statistics.TotalBurned += block.DoublePreendorsings.Sum(x => x.OffenderLoss - x.AccuserReward); - statistics.TotalFrozen -= block.DoublePreendorsings.Sum(x => x.OffenderLoss); - } - - if (block.Originations != null) - { - var originations = block.Originations.Where(x => x.Status == OperationStatus.Applied); - if (originations.Any()) - statistics.TotalBurned += originations.Sum(x => (x.StorageFee ?? 0) + (x.AllocationFee ?? 0)); - } - - if (block.RegisterConstants != null) - { - var registerConstants = block.RegisterConstants.Where(x => x.Status == OperationStatus.Applied); - if (registerConstants.Any()) - statistics.TotalBurned += registerConstants.Sum(x => x.StorageFee ?? 0); - } - - if (block.Transactions != null) - { - var transactions = block.Transactions.Where(x => x.Status == OperationStatus.Applied); - - if (transactions.Any()) - statistics.TotalBurned += transactions.Sum(x => (x.StorageFee ?? 0) + (x.AllocationFee ?? 0)); - - foreach (var tx in transactions.Where(x => x.Target?.Id == NullAddress.Id)) - statistics.TotalBanished += tx.Amount; - } - - if (block.Revelations != null) - { - var rewards = block.Revelations.Sum(x => x.Reward); - statistics.TotalCreated += rewards; - } - - if (block.VdfRevelationOps != null) - { - var rewards = block.VdfRevelationOps.Sum(x => x.Reward); - statistics.TotalCreated += rewards; - } - - if (block.Migrations != null && block.Migrations.Any(x => x.Kind == MigrationKind.Subsidy)) - { - var subsidy = block.Migrations.Where(x => x.Kind == MigrationKind.Subsidy).Sum(x => x.BalanceChange); - statistics.TotalCreated += subsidy; - } - - if (block.TransferTicketOps != null) - { - var ops = block.TransferTicketOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - } - - if (block.TxRollupCommitOps != null) - { - var ops = block.TxRollupCommitOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - { - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - statistics.TotalRollupBonds += ops.Sum(x => x.Bond); - } - } - - if (block.TxRollupDispatchTicketsOps != null) - { - var ops = block.TxRollupDispatchTicketsOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - } - - if (block.TxRollupFinalizeCommitmentOps != null) - { - var ops = block.TxRollupFinalizeCommitmentOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - } - - if (block.TxRollupOriginationOps != null) - { - var ops = block.TxRollupOriginationOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.AllocationFee ?? 0); - } - - if (block.TxRollupRejectionOps != null) - { - var ops = block.TxRollupRejectionOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - { - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - statistics.TotalBurned += block.TxRollupRejectionOps.Sum(x => x.Loss - x.Reward); - statistics.TotalRollupBonds -= block.TxRollupRejectionOps.Sum(x => x.Loss); - } - } - - if (block.TxRollupRemoveCommitmentOps != null) - { - var ops = block.TxRollupRemoveCommitmentOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - } - - if (block.TxRollupReturnBondOps != null) - { - var ops = block.TxRollupReturnBondOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - { - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - statistics.TotalRollupBonds -= ops.Sum(x => x.Bond); - } - } - - if (block.TxRollupSubmitBatchOps != null) - { - var ops = block.TxRollupSubmitBatchOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - } - - if (block.IncreasePaidStorageOps != null) - { - var ops = block.IncreasePaidStorageOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - } - - if (block.UpdateConsensusKeyOps != null) - { - var ops = block.UpdateConsensusKeyOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - } - - //if (block.SmartRollupCementOps != null) - //{ - //} - - if (block.SmartRollupExecuteOps != null) - { - var ops = block.SmartRollupExecuteOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - } - - if (block.SmartRollupOriginateOps != null) - { - var ops = block.SmartRollupOriginateOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalBurned += ops.Sum(x => x.StorageFee ?? 0); - } - - if (block.SmartRollupPublishOps != null) - { - var ops = block.SmartRollupPublishOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalSmartRollupBonds += ops.Sum(x => x.Bond); - } - - if (block.SmartRollupRecoverBondOps != null) - { - var ops = block.SmartRollupRecoverBondOps.Where(x => x.Status == OperationStatus.Applied); - if (ops.Any()) - statistics.TotalSmartRollupBonds -= ops.Sum(x => x.Bond); - } - - if (block.SmartRollupRefuteOps != null) - { - var ops = block.SmartRollupRefuteOps.Where(x => x.Status == OperationStatus.Applied && x.GameStatus != RefutationGameStatus.Ongoing); - foreach (var op in ops) - { - var game = await Cache.RefutationGames.GetAsync((int)op.GameId); - var totalLoss = game.InitiatorLoss ?? 0 + game.OpponentLoss ?? 0; - var totalReward = game.InitiatorReward ?? 0 + game.OpponentReward ?? 0; - statistics.TotalSmartRollupBonds -= totalLoss; - statistics.TotalBurned += totalLoss - totalReward; - } - } - - if (block.Events.HasFlag(BlockEvents.CycleEnd)) - statistics.Cycle = block.Cycle; - - if (block.Timestamp.AddSeconds(block.Protocol.TimeBetweenBlocks).Ticks / (10_000_000L * 3600 * 24) != block.Timestamp.Ticks / (10_000_000L * 3600 * 24)) - statistics.Date = block.Timestamp.Date; - else - { - var prevStats = await Cache.Statistics.GetAsync(block.Level - 1); - if (prevStats.Date == null) - { - var prevBlock = await Cache.Blocks.CurrentAsync(); - if (prevBlock.Timestamp.Ticks / (10_000_000L * 3600 * 24) != block.Timestamp.Ticks / (10_000_000L * 3600 * 24)) - { - Db.TryAttach(prevStats); - prevStats.Date = prevBlock.Timestamp.Date; - } - } - } - - Db.Statistics.Add(statistics); - Cache.Statistics.Add(statistics); - } - - public virtual async Task Revert(Block block) - { - await Db.Database.ExecuteSqlRawAsync($@"DELETE FROM ""Statistics"" WHERE ""Level"" = {block.Level}"); - Cache.Statistics.Reset(); - } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Diagnostics/Diagnostics.cs index 213173869..3e3a72495 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Diagnostics/Diagnostics.cs @@ -1,7 +1,4 @@ -using System; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Tzkt.Data.Models; using Tzkt.Sync.Utils; @@ -15,12 +12,9 @@ protected override async Task TestDelegate(int level, Data.Models.Delegate deleg { var remote = await Rpc.GetDelegateAsync(level, delegat.Address); - if (remote.RequiredInt64("full_balance") != delegat.Balance) + if (remote.RequiredInt64("full_balance") != delegat.Balance - delegat.LostBalance) throw new Exception($"Diagnostics failed: wrong balance {delegat.Address}"); - if (remote.RequiredInt64("current_frozen_deposits") != delegat.FrozenDeposit) - throw new Exception($"Diagnostics failed: wrong frozen deposits {delegat.Address}"); - if (remote.RequiredInt64("staking_balance") != delegat.StakingBalance) throw new Exception($"Diagnostics failed: wrong staking balance {delegat.Address}"); @@ -92,11 +86,11 @@ protected override async Task TestCycle(AppState state, Cycle cycle) if (remote.RequiredString("random_seed") != Hex.Convert(cycle.Seed)) throw new Exception($"Invalid cycle {cycle.Index} seed {Hex.Convert(cycle.Seed)}"); - if (remote.RequiredInt64("total_active_stake") != cycle.SelectedStake) - throw new Exception($"Invalid cycle {cycle.Index} selected stake {cycle.SelectedStake}"); + if (remote.RequiredInt64("total_active_stake") != cycle.TotalBakingPower) + throw new Exception($"Invalid cycle {cycle.Index} selected stake {cycle.TotalBakingPower}"); - if (remote.RequiredArray("selected_stake_distribution").Count() != cycle.SelectedBakers) - throw new Exception($"Invalid cycle {cycle.Index} selected bakers {cycle.SelectedBakers}"); + if (remote.RequiredArray("selected_stake_distribution").Count() != cycle.TotalBakers) + throw new Exception($"Invalid cycle {cycle.Index} selected bakers {cycle.TotalBakers}"); } protected virtual bool CheckDelegatedBalance(JsonElement remote, Data.Models.Delegate delegat) => diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Proto12Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Proto12Handler.cs index c478dcdda..0c21675f9 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Proto12Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Proto12Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -38,6 +31,8 @@ public Proto12Handler(TezosNode node, TzktContext db, CacheService cache, Quotes public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); @@ -213,13 +208,8 @@ public override async Task Commit(JsonElement block) cycleCommit.SelectedStakes, brCommit.CurrentRights); - var freezerCommit = new FreezerCommit(this); - freezerCommit.Apply(blockCommit.Block, block); - - var endorsingRewardCommit = new EndorsingRewardCommit(this); - await endorsingRewardCommit.Apply(blockCommit.Block, block); - - await new StatisticsCommit(this).Apply(blockCommit.Block, endorsingRewardCommit.Ops, freezerCommit.FreezerChange); + new FreezerCommit(this).Apply(blockCommit.Block, block); + await new EndorsingRewardCommit(this).Apply(blockCommit.Block, block); await new VotingCommit(this).Apply(blockCommit.Block, block); await new StateCommit(this).Apply(blockCommit.Block, block); } @@ -227,7 +217,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() @@ -307,7 +297,7 @@ public override async Task Revert() await new StatisticsCommit(this).Revert(currBlock); await new EndorsingRewardCommit(this).Revert(currBlock); - await new FreezerCommit(this).Revert(currBlock); + new FreezerCommit(this).Revert(); await new BakerCycleCommit(this).Revert(currBlock); await new DelegatorCycleCommit(this).Revert(currBlock); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto12/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto12/Rpc/Rpc.cs index 1fd63b5d1..7a1291273 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto12/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto12/Rpc/Rpc.cs @@ -1,5 +1,4 @@ using System.Text.Json; -using System.Threading.Tasks; using Tzkt.Sync.Services; namespace Tzkt.Sync.Protocols.Proto12 diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Activation/ProtoActivator.cs index 7f225b5c3..897c57e97 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Activation/ProtoActivator.cs @@ -20,15 +20,11 @@ protected override void SetParameters(Protocol protocol, JToken parameters) base.SetParameters(protocol, parameters); protocol.LBToggleThreshold = parameters["liquidity_baking_toggle_ema_threshold"]?.Value() ?? 1_000_000_000; protocol.BlocksPerVoting = (parameters["cycles_per_voting_period"]?.Value() ?? 5) * protocol.BlocksPerCycle; - protocol.TxRollupOriginationSize = parameters["tx_rollup_origination_size"]?.Value() ?? 4_000; - protocol.TxRollupCommitmentBond = long.Parse((parameters["tx_rollup_commitment_bond"]?.Value() ?? "10000000000").Replace("_", "")); } protected override void UpgradeParameters(Protocol protocol, Protocol prev) { protocol.LBToggleThreshold = 1_000_000_000; - protocol.TxRollupOriginationSize = 4_000; - protocol.TxRollupCommitmentBond = 10_000_000_000; } protected override long GetVotingPower(Data.Models.Delegate baker, Protocol protocol) @@ -58,7 +54,7 @@ await Db.Database.ExecuteSqlRawAsync($@" .Select(x => x.Entity as VotingSnapshot)); var snapshots = Cache.Accounts.GetDelegates() - .Where(x => x.Staked && x.StakingBalance >= nextProto.TokensPerRoll) + .Where(x => x.Staked && x.StakingBalance >= nextProto.MinimalStake) .Select(x => new VotingSnapshot { Level = state.Level, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/CycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/CycleCommit.cs index 790e80c97..e0f1c064b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/CycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/CycleCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto13 @@ -51,31 +47,10 @@ public virtual async Task Apply(Block block) Snapshots = await Db.SnapshotBalances .AsNoTracking() - .Where(x => x.Level == snapshotLevel && x.DelegateId == null) + .Where(x => x.Level == snapshotLevel && x.AccountId == x.BakerId) .ToListAsync(); - var endorsingRewards = await Db.BakerCycles - .AsNoTracking() - .Where(x => x.Cycle == block.Cycle - 1 && x.EndorsementRewards > 0) - .ToDictionaryAsync(x => x.BakerId, x => x.EndorsementRewards); - - SelectedStakes = Snapshots - .Where(x => x.StakingBalance >= block.Protocol.TokensPerRoll) - .ToDictionary(x => x.AccountId, x => - { - var baker = Cache.Accounts.GetDelegate(x.AccountId); - - var lastBalance = baker.Balance; - if (endorsingRewards.TryGetValue(baker.Id, out var reward)) - lastBalance -= reward; - if (block.ProposerId == baker.Id) - lastBalance -= block.Reward; - if (block.ProducerId == baker.Id) - lastBalance -= block.Bonus; - - var depositCap = Math.Min(lastBalance, baker.FrozenDepositLimit ?? (long.MaxValue / 100)); - return Math.Min((long)x.StakingBalance, depositCap * 100 / block.Protocol.FrozenDepositsPercentage); - }); + SelectedStakes = await GetSelectedStakes(block); FutureCycle = new Cycle { @@ -84,12 +59,8 @@ public virtual async Task Apply(Block block) LastLevel = block.Protocol.GetCycleEnd(futureCycle), SnapshotIndex = snapshotIndex, SnapshotLevel = snapshotLevel, - TotalStaking = Snapshots.Sum(x => (long)x.StakingBalance), - TotalDelegated = Snapshots.Sum(x => (long)x.DelegatedBalance), - TotalDelegators = Snapshots.Sum(x => (int)x.DelegatorsCount), - SelectedBakers = SelectedStakes.Count, - SelectedStake = SelectedStakes.Values.Sum(), - TotalBakers = Snapshots.Count, + TotalBakers = SelectedStakes.Count, + TotalBakingPower = SelectedStakes.Values.Sum(), Seed = futureSeed }; @@ -110,5 +81,31 @@ DELETE FROM ""Cycles"" } protected virtual Task GetVdfSolution(Block block) => Task.FromResult(null); + + protected virtual async Task> GetSelectedStakes(Block block) + { + var endorsingRewards = await Db.BakerCycles + .AsNoTracking() + .Where(x => x.Cycle == block.Cycle - 1 && x.EndorsementRewardsLiquid > 0) + .ToDictionaryAsync(x => x.BakerId, x => x.EndorsementRewardsLiquid); + + return Snapshots + .Where(x => x.StakingBalance >= block.Protocol.MinimalStake) + .ToDictionary(x => x.AccountId, x => + { + var baker = Cache.Accounts.GetDelegate(x.AccountId); + + var lastBalance = baker.Balance; + if (endorsingRewards.TryGetValue(baker.Id, out var reward)) + lastBalance -= reward; + if (block.ProposerId == baker.Id) + lastBalance -= block.RewardLiquid; + if (block.ProducerId == baker.Id) + lastBalance -= block.BonusLiquid; + + var depositCap = Math.Min(lastBalance, baker.FrozenDepositLimit ?? (long.MaxValue / 100)); + return Math.Min((long)x.StakingBalance, depositCap * (block.Protocol.MaxDelegatedOverFrozenRatio + 1)); + }); + } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 3a8e0d61a..aba3e51a4 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -121,6 +121,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content } TicketUpdates = ParseTicketUpdates(result); + + Cache.Statistics.Current.TotalBurned += burned; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupCommitCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupCommitCommit.cs index 9855f9910..a8a8a0650 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupCommitCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupCommitCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; - +using System.Text.Json; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -90,6 +86,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content { sender.RollupBonds += operation.Bond; rollup.RollupBonds += operation.Bond; + + Cache.Statistics.Current.TotalRollupBonds += operation.Bond; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupDispatchTicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupDispatchTicketsCommit.cs index c5189cb2a..05eaba835 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupDispatchTicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupDispatchTicketsCommit.cs @@ -1,7 +1,4 @@ -using System; -using System.Text.Json; -using System.Threading.Tasks; - +using System.Text.Json; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -100,6 +97,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content senderDelegate.DelegatedBalance -= burned; } } + + Cache.Statistics.Current.TotalBurned += burned; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupOriginationCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupOriginationCommit.cs index 01bcc06f7..80f7d1352 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupOriginationCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupOriginationCommit.cs @@ -1,6 +1,4 @@ -using System; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -97,7 +95,7 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content ? OperationErrors.Parse(content, errors) : null, GasUsed = (int)(((result.OptionalInt64("consumed_milligas") ?? 0) + 999) / 1000), - AllocationFee = block.Protocol.TxRollupOriginationSize * block.Protocol.ByteCost + AllocationFee = 4_000 * block.Protocol.ByteCost }; #endregion @@ -143,6 +141,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content } sender.RollupsCount++; + + Cache.Statistics.Current.TotalBurned += burned; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupRejectionCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupRejectionCommit.cs index 893ab7c9d..5b815bf2f 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupRejectionCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupRejectionCommit.cs @@ -129,6 +129,9 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content committer.RollupBonds -= operation.Loss; rollup.RollupBonds -= operation.Loss; + + Cache.Statistics.Current.TotalBurned += operation.Loss - operation.Reward; + Cache.Statistics.Current.TotalRollupBonds -= operation.Loss; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupReturnBondCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupReturnBondCommit.cs index ad1fa2794..d3100865a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupReturnBondCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupReturnBondCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; - +using System.Text.Json; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -90,6 +86,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content { sender.RollupBonds -= operation.Bond; rollup.RollupBonds -= operation.Bond; + + Cache.Statistics.Current.TotalRollupBonds -= operation.Bond; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupSubmitBatchCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupSubmitBatchCommit.cs index 83cd7c2d9..8aac7001a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupSubmitBatchCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupSubmitBatchCommit.cs @@ -1,7 +1,4 @@ -using System; -using System.Text.Json; -using System.Threading.Tasks; - +using System.Text.Json; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -98,6 +95,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content if (senderDelegate.Id != sender.Id) senderDelegate.DelegatedBalance -= burned; } + + Cache.Statistics.Current.TotalBurned += burned; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/StatisticsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/StatisticsCommit.cs index 96c690b38..8e74489b1 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/StatisticsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/StatisticsCommit.cs @@ -1,6 +1,6 @@ namespace Tzkt.Sync.Protocols.Proto13 { - class StatisticsCommit : Proto12.StatisticsCommit + class StatisticsCommit : Proto1.StatisticsCommit { public StatisticsCommit(ProtocolHandler protocol) : base(protocol) { } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/VotingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/VotingCommit.cs index dfa1f9132..08ce4f305 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/VotingCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/VotingCommit.cs @@ -6,7 +6,7 @@ class VotingCommit : Proto8.VotingCommit { public VotingCommit(ProtocolHandler protocol) : base(protocol) { } - protected override long GetVotingPower(Data.Models.Delegate baker, Protocol protocol) + protected override long GetVotingPower(Data.Models.Delegate baker, Block block, Protocol protocol) { return baker.StakingBalance; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Proto13Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Proto13Handler.cs index 20c393df9..f736cff78 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Proto13Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Proto13Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -38,6 +31,8 @@ public Proto13Handler(TezosNode node, TzktContext db, CacheService cache, Quotes public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); @@ -258,13 +253,8 @@ public override async Task Commit(JsonElement block) cycleCommit.SelectedStakes, brCommit.CurrentRights); - var freezerCommit = new FreezerCommit(this); - freezerCommit.Apply(blockCommit.Block, block); - - var endorsingRewardCommit = new EndorsingRewardCommit(this); - await endorsingRewardCommit.Apply(blockCommit.Block, block); - - await new StatisticsCommit(this).Apply(blockCommit.Block, endorsingRewardCommit.Ops, freezerCommit.FreezerChange); + new FreezerCommit(this).Apply(blockCommit.Block, block); + await new EndorsingRewardCommit(this).Apply(blockCommit.Block, block); await new VotingCommit(this).Apply(blockCommit.Block, block); await new StateCommit(this).Apply(blockCommit.Block, block); } @@ -272,7 +262,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() @@ -379,7 +369,7 @@ public override async Task Revert() await new StatisticsCommit(this).Revert(currBlock); await new EndorsingRewardCommit(this).Revert(currBlock); - await new FreezerCommit(this).Revert(currBlock); + new FreezerCommit(this).Revert(); await new BakerCycleCommit(this).Revert(currBlock); await new DelegatorCycleCommit(this).Revert(currBlock); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto14/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto14/Activation/ProtoActivator.cs index 7bdd930c5..84575a49c 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto14/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto14/Activation/ProtoActivator.cs @@ -50,8 +50,7 @@ protected override async Task MigrateContext(AppState state) state.MigrationOpsCount++; - var stats = await Cache.Statistics.GetAsync(state.Level); - stats.TotalCreated += 3_000_000_000L; + Cache.Statistics.Current.TotalCreated += 3_000_000_000L; if (state.ChainId == "NetXnHfVqm9iesp") // ghostnet { diff --git a/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/Operations/IncreasePaidStorageCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/Operations/IncreasePaidStorageCommit.cs index 2ba405ca8..5041603ac 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/Operations/IncreasePaidStorageCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/Operations/IncreasePaidStorageCommit.cs @@ -1,9 +1,5 @@ -using System; -using System.Linq; -using System.Numerics; +using System.Numerics; using System.Text.Json; -using System.Threading.Tasks; - using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -104,6 +100,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content if (senderDelegate.Id != sender.Id) senderDelegate.DelegatedBalance -= burned; } + + Cache.Statistics.Current.TotalBurned += burned; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/Operations/VdfRevelationCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/Operations/VdfRevelationCommit.cs index 40027c8ec..653bde4c9 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/Operations/VdfRevelationCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/Operations/VdfRevelationCommit.cs @@ -1,6 +1,4 @@ -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Netezos.Encoding; using Tzkt.Data.Models; @@ -28,7 +26,7 @@ public virtual Task Apply(Block block, JsonElement op, JsonElement content) OpHash = op.RequiredString("hash"), Baker = block.Proposer, Cycle = block.Cycle, - Reward = reward, + RewardLiquid = reward, Solution = Hex.Parse(content.RequiredArray("solution", 2)[0].RequiredString()), Proof = Hex.Parse(content.RequiredArray("solution", 2)[1].RequiredString()) }; @@ -40,13 +38,15 @@ public virtual Task Apply(Block block, JsonElement op, JsonElement content) #endregion #region apply operation - blockBaker.Balance += revelation.Reward; - blockBaker.StakingBalance += revelation.Reward; + blockBaker.Balance += revelation.RewardLiquid; + blockBaker.StakingBalance += revelation.RewardLiquid; blockBaker.VdfRevelationsCount++; Cache.AppState.Get().VdfRevelationOpsCount++; block.Operations |= Operations.VdfRevelation; + + Cache.Statistics.Current.TotalCreated += revelation.RewardLiquid; #endregion Db.VdfRevelationOps.Add(revelation); @@ -65,8 +65,8 @@ public virtual Task Revert(Block block, VdfRevelationOperation revelation) #endregion #region apply operation - blockBaker.Balance -= revelation.Reward; - blockBaker.StakingBalance -= revelation.Reward; + blockBaker.Balance -= revelation.RewardLiquid; + blockBaker.StakingBalance -= revelation.RewardLiquid; blockBaker.VdfRevelationsCount--; Cache.AppState.Get().VdfRevelationOpsCount--; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/StatisticsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/StatisticsCommit.cs index f8e0915fc..5177261a2 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/StatisticsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto14/Commits/StatisticsCommit.cs @@ -1,6 +1,6 @@ namespace Tzkt.Sync.Protocols.Proto14 { - class StatisticsCommit : Proto12.StatisticsCommit + class StatisticsCommit : Proto1.StatisticsCommit { public StatisticsCommit(ProtocolHandler protocol) : base(protocol) { } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto14/Proto14Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto14/Proto14Handler.cs index af5b6711d..c08c44ccd 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto14/Proto14Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto14/Proto14Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -38,6 +31,8 @@ public Proto14Handler(TezosNode node, TzktContext db, CacheService cache, Quotes public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); @@ -267,13 +262,8 @@ public override async Task Commit(JsonElement block) cycleCommit.SelectedStakes, brCommit.CurrentRights); - var freezerCommit = new FreezerCommit(this); - freezerCommit.Apply(blockCommit.Block, block); - - var endorsingRewardCommit = new EndorsingRewardCommit(this); - await endorsingRewardCommit.Apply(blockCommit.Block, block); - - await new StatisticsCommit(this).Apply(blockCommit.Block, endorsingRewardCommit.Ops, freezerCommit.FreezerChange); + new FreezerCommit(this).Apply(blockCommit.Block, block); + await new EndorsingRewardCommit(this).Apply(blockCommit.Block, block); await new VotingCommit(this).Apply(blockCommit.Block, block); await new StateCommit(this).Apply(blockCommit.Block, block); } @@ -281,7 +271,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() @@ -394,7 +384,7 @@ public override async Task Revert() await new StatisticsCommit(this).Revert(currBlock); await new EndorsingRewardCommit(this).Revert(currBlock); - await new FreezerCommit(this).Revert(currBlock); + new FreezerCommit(this).Revert(); await new BakerCycleCommit(this).Revert(currBlock); await new DelegatorCycleCommit(this).Revert(currBlock); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto15/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto15/Activation/ProtoActivator.cs index ff4a6faf4..22a3004f4 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto15/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto15/Activation/ProtoActivator.cs @@ -14,7 +14,7 @@ public ProtoActivator(ProtocolHandler proto) : base(proto) { } protected override void SetParameters(Protocol protocol, JToken parameters) { base.SetParameters(protocol, parameters); - protocol.TokensPerRoll = parameters["minimal_stake"]?.Value() ?? 6_000_000L; + protocol.MinimalStake = parameters["minimal_stake"]?.Value() ?? 6_000_000L; } protected override void UpgradeParameters(Protocol protocol, Protocol prev) { } @@ -148,8 +148,7 @@ async Task AddInvoice(AppState state, string address, long amount) state.MigrationOpsCount++; - var stats = await Cache.Statistics.GetAsync(state.Level); - stats.TotalCreated += amount; + Cache.Statistics.Current.TotalCreated += amount; } async Task MigrateCurrentRights(AppState state, Protocol prevProto, Protocol nextProto) @@ -187,8 +186,8 @@ async Task MigrateCurrentRights(AppState state, Protocol prevProto, Protocol nex #region apply new rights var sampler = GetOldSampler(bakerCycles.Values - .Where(x => x.ActiveStake > 0) - .Select(x => (x.BakerId, x.ActiveStake)) + .Where(x => x.BakingPower > 0) + .Select(x => (x.BakerId, x.BakingPower)) .ToList()); #region temporary diagnostics @@ -269,8 +268,8 @@ async Task MigrateFutureRights(AppState state, Protocol nextProto) { var bakerCycles = await Cache.BakerCycles.GetAsync(cycle.Index); var sampler = GetOldSampler(bakerCycles.Values - .Where(x => x.ActiveStake > 0) - .Select(x => (x.BakerId, x.ActiveStake)) + .Where(x => x.BakingPower > 0) + .Select(x => (x.BakerId, x.BakingPower)) .ToList()); #region temporary diagnostics diff --git a/Tzkt.Sync/Protocols/Handlers/Proto15/Commits/StatisticsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto15/Commits/StatisticsCommit.cs index 0b488b15b..0b92b0e28 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto15/Commits/StatisticsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto15/Commits/StatisticsCommit.cs @@ -1,6 +1,6 @@ namespace Tzkt.Sync.Protocols.Proto15 { - class StatisticsCommit : Proto12.StatisticsCommit + class StatisticsCommit : Proto1.StatisticsCommit { public StatisticsCommit(ProtocolHandler protocol) : base(protocol) { } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto15/Proto15Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto15/Proto15Handler.cs index 8fa954b40..8c0b46c7b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto15/Proto15Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto15/Proto15Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -38,6 +31,8 @@ public Proto15Handler(TezosNode node, TzktContext db, CacheService cache, Quotes public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); @@ -277,13 +272,8 @@ public override async Task Commit(JsonElement block) cycleCommit.SelectedStakes, brCommit.CurrentRights); - var freezerCommit = new FreezerCommit(this); - freezerCommit.Apply(blockCommit.Block, block); - - var endorsingRewardCommit = new EndorsingRewardCommit(this); - await endorsingRewardCommit.Apply(blockCommit.Block, block); - - await new StatisticsCommit(this).Apply(blockCommit.Block, endorsingRewardCommit.Ops, freezerCommit.FreezerChange); + new FreezerCommit(this).Apply(blockCommit.Block, block); + await new EndorsingRewardCommit(this).Apply(blockCommit.Block, block); await new VotingCommit(this).Apply(blockCommit.Block, block); await new StateCommit(this).Apply(blockCommit.Block, block); } @@ -291,7 +281,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() @@ -410,7 +400,7 @@ public override async Task Revert() await new StatisticsCommit(this).Revert(currBlock); await new EndorsingRewardCommit(this).Revert(currBlock); - await new FreezerCommit(this).Revert(currBlock); + new FreezerCommit(this).Revert(); await new BakerCycleCommit(this).Revert(currBlock); await new DelegatorCycleCommit(this).Revert(currBlock); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Activation/ProtoActivator.cs index 5006ac86e..7e1cc56af 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Activation/ProtoActivator.cs @@ -35,7 +35,6 @@ protected override void UpgradeParameters(Protocol protocol, Protocol prev) protocol.BlockReward1 = totalReward / 4 / (protocol.EndorsersPerBlock / 3); protocol.EndorsementReward0 = totalReward / 2 / protocol.EndorsersPerBlock; protocol.EndorsementReward1 = 0; - protocol.LBSubsidy = totalReward / 16; protocol.SmartRollupOriginationSize = 6_314; protocol.SmartRollupStakeAmount = 10_000_000_000; @@ -130,8 +129,8 @@ DELETE FROM "BakingRights" { var bakerCycles = await Cache.BakerCycles.GetAsync(cycle.Index); var sampler = GetOldSampler(bakerCycles.Values - .Where(x => x.ActiveStake > 0) - .Select(x => (x.BakerId, x.ActiveStake)) + .Where(x => x.BakingPower > 0) + .Select(x => (x.BakerId, x.BakingPower)) .ToList()); #region temporary diagnostics @@ -210,8 +209,8 @@ FROM STDIN (FORMAT BINARY) bakerCycle.FutureBlockRewards = 0; bakerCycle.FutureEndorsements = 0; - var expectedEndorsements = (int)(new BigInteger(nextProto.BlocksPerCycle) * nextProto.EndorsersPerBlock * bakerCycle.ActiveStake / cycle.SelectedStake); - bakerCycle.ExpectedBlocks = nextProto.BlocksPerCycle * bakerCycle.ActiveStake / cycle.SelectedStake; + var expectedEndorsements = (int)(new BigInteger(nextProto.BlocksPerCycle) * nextProto.EndorsersPerBlock * bakerCycle.BakingPower / cycle.TotalBakingPower); + bakerCycle.ExpectedBlocks = nextProto.BlocksPerCycle * bakerCycle.BakingPower / cycle.TotalBakingPower; bakerCycle.ExpectedEndorsements = expectedEndorsements; bakerCycle.FutureEndorsementRewards = expectedEndorsements * nextProto.EndorsementReward0; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index bfd4c6f6a..bcf5ee1fa 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -114,6 +114,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content rollup.ExecutedCommitments++; commitment.Status = SmartRollupCommitmentStatus.Executed; + + Cache.Statistics.Current.TotalBurned += burned; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupOriginateCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupOriginateCommit.cs index da9381079..64f228078 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupOriginateCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupOriginateCommit.cs @@ -114,7 +114,6 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content Sender = sender, PvmKind = pvmKind, Kernel = Hex.Parse(content.RequiredString("kernel")), - OriginationProof = Hex.Parse(content.RequiredString("origination_proof")), GenesisCommitment = result.OptionalString("genesis_commitment_hash"), SmartRollupId = rollup?.Id, Status = result.RequiredString("status") switch @@ -188,6 +187,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content } sender.SmartRollupsCount++; + + Cache.Statistics.Current.TotalBurned += burned; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupPublishCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupPublishCommit.cs index 410cf0063..1e52bd2ac 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupPublishCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupPublishCommit.cs @@ -120,6 +120,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content rollup.ActiveStakers++; operation.BondStatus = SmartRollupBondStatus.Active; + + Cache.Statistics.Current.TotalSmartRollupBonds += operation.Bond; } if (commitment == null) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupRecoverBondCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupRecoverBondCommit.cs index ad2450e0e..3e1adbd78 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupRecoverBondCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupRecoverBondCommit.cs @@ -100,6 +100,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content .FirstOrDefault(x => x.SmartRollupId == operation.SmartRollupId && x.BondStatus == SmartRollupBondStatus.Active && x.SenderId == operation.StakerId) ?? await Db.SmartRollupPublishOps.FirstAsync(x => x.SmartRollupId == operation.SmartRollupId && x.BondStatus == SmartRollupBondStatus.Active && x.SenderId == operation.StakerId); bondOp.BondStatus = SmartRollupBondStatus.Returned; + + Cache.Statistics.Current.TotalSmartRollupBonds -= operation.Bond; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupRefuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupRefuteCommit.cs index 751a3afe3..a2d2a700e 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupRefuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupRefuteCommit.cs @@ -204,11 +204,18 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content { game.InitiatorReward = initiatorChange; } + else if (initiatorChange == 0) + { + if (operation.GameStatus == RefutationGameStatus.Draw || result.Required("game_status").Required("result").RequiredString("player") == initiator.Address) + game.InitiatorLoss = 0; + else + game.InitiatorReward = 0; + } else { game.InitiatorLoss = -initiatorChange; - initiator.SmartRollupBonds += initiatorChange; - rollup.SmartRollupBonds += initiatorChange; + initiator.SmartRollupBonds -= game.InitiatorLoss.Value; + rollup.SmartRollupBonds -= game.InitiatorLoss.Value; rollup.ActiveStakers--; var bondOp = await GetBondOperation(rollup, initiator, block); @@ -242,11 +249,18 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content { game.OpponentReward = opponentChange; } + else if (opponentChange == 0) + { + if (operation.GameStatus == RefutationGameStatus.Draw || result.Required("game_status").Required("result").RequiredString("player") == opponent.Address) + game.OpponentLoss = 0; + else + game.OpponentReward = 0; + } else { game.OpponentLoss = -opponentChange; - opponent.SmartRollupBonds += opponentChange; - rollup.SmartRollupBonds += opponentChange; + opponent.SmartRollupBonds -= game.OpponentLoss.Value; + rollup.SmartRollupBonds -= game.OpponentLoss.Value; rollup.ActiveStakers--; var bondOp = await GetBondOperation(rollup, opponent, block); @@ -295,6 +309,11 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content initiator.ActiveRefutationGamesCount--; opponent.ActiveRefutationGamesCount--; rollup.ActiveRefutationGamesCount--; + + var totalLoss = (game.InitiatorLoss ?? 0) + (game.OpponentLoss ?? 0); + var totalReward = (game.InitiatorReward ?? 0) + (game.OpponentReward ?? 0); + Cache.Statistics.Current.TotalBurned += totalLoss - totalReward; + Cache.Statistics.Current.TotalSmartRollupBonds -= totalLoss; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupTimeoutCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupTimeoutCommit.cs index 90921d307..78376571e 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupTimeoutCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupTimeoutCommit.cs @@ -142,11 +142,18 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content { game.InitiatorReward = initiatorChange; } + else if (initiatorChange == 0) + { + if (operation.GameStatus == RefutationGameStatus.Draw || result.Required("game_status").Required("result").RequiredString("player") == initiator.Address) + game.InitiatorLoss = 0; + else + game.InitiatorReward = 0; + } else { game.InitiatorLoss = -initiatorChange; - initiator.SmartRollupBonds += initiatorChange; - rollup.SmartRollupBonds += initiatorChange; + initiator.SmartRollupBonds -= game.InitiatorLoss.Value; + rollup.SmartRollupBonds -= game.InitiatorLoss.Value; rollup.ActiveStakers--; var bondOp = await GetBondOperation(rollup, initiator, block); @@ -180,11 +187,18 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content { game.OpponentReward = opponentChange; } + else if (opponentChange == 0) + { + if (operation.GameStatus == RefutationGameStatus.Draw || result.Required("game_status").Required("result").RequiredString("player") == opponent.Address) + game.OpponentLoss = 0; + else + game.OpponentReward = 0; + } else { game.OpponentLoss = -opponentChange; - opponent.SmartRollupBonds += opponentChange; - rollup.SmartRollupBonds += opponentChange; + opponent.SmartRollupBonds -= game.OpponentLoss.Value; + rollup.SmartRollupBonds -= game.OpponentLoss.Value; rollup.ActiveStakers--; var bondOp = await GetBondOperation(rollup, opponent, block); @@ -233,6 +247,11 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content initiator.ActiveRefutationGamesCount--; opponent.ActiveRefutationGamesCount--; rollup.ActiveRefutationGamesCount--; + + var totalLoss = (game.InitiatorLoss ?? 0) + (game.OpponentLoss ?? 0); + var totalReward = (game.InitiatorReward ?? 0) + (game.OpponentReward ?? 0); + Cache.Statistics.Current.TotalBurned += totalLoss - totalReward; + Cache.Statistics.Current.TotalSmartRollupBonds -= totalLoss; } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/StatisticsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/StatisticsCommit.cs index b91be28cf..630560d3d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/StatisticsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/StatisticsCommit.cs @@ -1,6 +1,6 @@ namespace Tzkt.Sync.Protocols.Proto16 { - class StatisticsCommit : Proto12.StatisticsCommit + class StatisticsCommit : Proto1.StatisticsCommit { public StatisticsCommit(ProtocolHandler protocol) : base(protocol) { } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs index 8ab151828..d49932d0c 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs @@ -31,6 +31,8 @@ public Proto16Handler(TezosNode node, TzktContext db, CacheService cache, Quotes public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); @@ -340,13 +342,8 @@ public override async Task Commit(JsonElement block) cycleCommit.SelectedStakes, brCommit.CurrentRights); - var freezerCommit = new FreezerCommit(this); - freezerCommit.Apply(blockCommit.Block, block); - - var endorsingRewardCommit = new EndorsingRewardCommit(this); - await endorsingRewardCommit.Apply(blockCommit.Block, block); - - await new StatisticsCommit(this).Apply(blockCommit.Block, endorsingRewardCommit.Ops, freezerCommit.FreezerChange); + new FreezerCommit(this).Apply(blockCommit.Block, block); + await new EndorsingRewardCommit(this).Apply(blockCommit.Block, block); await new VotingCommit(this).Apply(blockCommit.Block, block); await new StateCommit(this).Apply(blockCommit.Block, block); } @@ -354,7 +351,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() @@ -494,7 +491,7 @@ public override async Task Revert() await new StatisticsCommit(this).Revert(currBlock); await new EndorsingRewardCommit(this).Revert(currBlock); - await new FreezerCommit(this).Revert(currBlock); + new FreezerCommit(this).Revert(); await new BakerCycleCommit(this).Revert(currBlock); await new DelegatorCycleCommit(this).Revert(currBlock); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Validation/Validator.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Validation/Validator.cs index ac6d1a336..4051e3f98 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Validation/Validator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Validation/Validator.cs @@ -1,1010 +1,7 @@ -using System.Text.Json; -using Tzkt.Data.Models; -using Tzkt.Sync.Services; - -namespace Tzkt.Sync.Protocols.Proto16 +namespace Tzkt.Sync.Protocols.Proto16 { - class Validator : IValidator + class Validator : Proto1.Validator { - readonly CacheService Cache; - Protocol Protocol; - string Proposer; - string Producer; - int Level; - int Cycle; - - public Validator(ProtocolHandler protocol) => Cache = protocol.Cache; - - public virtual async Task ValidateBlock(JsonElement block) - { - Protocol = await Cache.Protocols.GetAsync(Cache.AppState.GetNextProtocol()); - - if (block.RequiredString("chain_id") != Cache.AppState.GetChainId()) - throw new ValidationException("invalid chain"); - - if (block.RequiredString("protocol") != Cache.AppState.GetNextProtocol()) - throw new ValidationException("invalid block protocol", true); - - ValidateBlockHeader(block.Required("header")); - await ValidateBlockMetadata(block.Required("metadata")); - await ValidateOperations(block.RequiredArray("operations", 4)); - } - - void ValidateBlockHeader(JsonElement header) - { - Level = header.RequiredInt32("level"); - if (Level != Cache.AppState.GetNextLevel()) - throw new ValidationException($"invalid block level", true); - - if (header.RequiredString("predecessor") != Cache.AppState.GetHead()) - throw new ValidationException($"invalid block predecessor", true); - } - - async Task ValidateBlockMetadata(JsonElement metadata) - { - #region baking - Proposer = metadata.RequiredString("proposer"); - if (!Cache.Accounts.DelegateExists(Proposer)) - throw new ValidationException($"non-existent block proposer"); - - Producer = metadata.RequiredString("baker"); - if (!Cache.Accounts.DelegateExists(Producer)) - throw new ValidationException($"non-existent block baker"); - #endregion - - #region level info - Cycle = metadata.Required("level_info").RequiredInt32("cycle"); - if (Cycle != Protocol.GetCycle(Level)) - throw new ValidationException($"invalid block cycle", true); - #endregion - - #region voting info - var periodInfo = metadata.Required("voting_period_info").Required("voting_period"); - var periodIndex = periodInfo.RequiredInt32("index"); - var periodKind = periodInfo.RequiredString("kind") switch - { - "proposal" => PeriodKind.Proposal, - "exploration" => PeriodKind.Exploration, - "cooldown" => PeriodKind.Testing, - "promotion" => PeriodKind.Promotion, - "adoption" => PeriodKind.Adoption, - _ => throw new ValidationException("invalid voting period kind") - }; - - var period = await Cache.Periods.GetAsync(Cache.AppState.Get().VotingPeriod); - if (Level > period.FirstLevel && Level < period.LastLevel) - { - if (periodIndex != period.Index) - throw new ValidationException("invalid voting period index"); - - if (!Protocol.HasDictator && periodKind != period.Kind) - throw new ValidationException("unexpected voting period"); - } - #endregion - - #region deactivation - foreach (var baker in metadata.RequiredArray("deactivated").EnumerateArray()) - if (!Cache.Accounts.DelegateExists(baker.GetString())) - throw new ValidationException($"non-existent deactivated baker {baker}"); - #endregion - - #region balance updates - var balanceUpdates = metadata.RequiredArray("balance_updates").EnumerateArray(); - if (balanceUpdates.Any(x => x.RequiredString("kind") == "contract" && x.RequiredString("origin") == "block" && !Cache.Accounts.DelegateExists(x.RequiredString("contract")))) - throw new ValidationException("non-existent delegate in block balance updates"); - - if (Cycle < Protocol.NoRewardCycles) - { - if (balanceUpdates.Any(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking rewards")) - throw new ValidationException("unexpected block reward"); - - if (balanceUpdates.Any(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking bonuses")) - throw new ValidationException("unexpected block bonus"); - } - else - { - if (balanceUpdates.Count(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking rewards") != 1) - throw new ValidationException("invalid block reward"); - - if (balanceUpdates.Count(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking bonuses") > 1) - throw new ValidationException("invalid block bonus"); - - if (balanceUpdates.Count(x => x.RequiredString("origin") == "block") > 5 && !Protocol.IsCycleEnd(Level)) - throw new ValidationException("unexpected cycle rewards"); - } - #endregion - - #region implicit operations - foreach (var op in metadata.RequiredArray("implicit_operations_results").EnumerateArray()) - { - var kind = op.RequiredString("kind"); - if (kind == "transaction") - { - var subsidy = op.RequiredArray("balance_updates", 2).EnumerateArray() - .Where(x => x.RequiredString("kind") == "contract"); - - if (subsidy.Count() > 1) - throw new ValidationException("invalid subsidy"); - - if (subsidy.Any(x => x.RequiredString("origin") != "subsidy")) - throw new ValidationException("invalid subsidy origin"); - - if (subsidy.Any(x => x.RequiredString("contract") != Proto10.ProtoActivator.CpmmContract)) - throw new ValidationException("invalid subsidy recepient"); - } - else if (kind == "origination" && Level == Protocol.FirstLevel) - { - var contract = op.RequiredArray("originated_contracts", 1)[0].RequiredString(); - if (!await Cache.Accounts.ExistsAsync(contract, AccountType.Contract)) - throw new ValidationException("unexpected implicit origination"); - } - else - { - throw new ValidationException("unexpected implicit operation kind"); - } - } - #endregion - } - - protected virtual async Task ValidateOperations(JsonElement operations) - { - foreach (var opg in operations.EnumerateArray()) - { - foreach (var op in opg.RequiredArray().EnumerateArray()) - { - foreach (var content in op.RequiredArray("contents").EnumerateArray()) - { - switch (content.RequiredString("kind")) - { - case "endorsement": ValidateEndorsement(content); break; - case "preendorsement": ValidatePreendorsement(content); break; - case "ballot": await ValidateBallot(content); break; - case "proposals": ValidateProposal(content); break; - case "activate_account": await ValidateActivation(content); break; - case "double_baking_evidence": ValidateDoubleBaking(content); break; - case "double_endorsement_evidence": ValidateDoubleBaking(content); break; - case "double_preendorsement_evidence": ValidateDoubleBaking(content); break; - case "seed_nonce_revelation": await ValidateSeedNonceRevelation(content); break; - case "vdf_revelation": ValidateVdfRevelation(content); break; - case "drain_delegate": ValidateDrainDelegate(content); break; - case "delegation": await ValidateDelegation(content); break; - case "origination": await ValidateOrigination(content); break; - case "transaction": await ValidateTransaction(content); break; - case "reveal": await ValidateReveal(content); break; - case "register_global_constant": await ValidateRegisterConstant(content); break; - case "set_deposits_limit": await ValidateSetDepositsLimit(content); break; - case "increase_paid_storage": await ValidateIncreasePaidStorage(content); break; - case "update_consensus_key": await ValidateUpdateConsensusKey(content); break; - case "tx_rollup_origination": await ValidateTxRollupOrigination(content); break; - case "tx_rollup_submit_batch": await ValidateTxRollupSubmitBatch(content); break; - case "tx_rollup_commit": await ValidateTxRollupCommit(content); break; - case "tx_rollup_finalize_commitment": await ValidateTxRollupFinalizeCommitment(content); break; - case "tx_rollup_remove_commitment": await ValidateTxRollupRemoveCommitment(content); break; - case "tx_rollup_return_bond": await ValidateTxRollupReturnBond(content); break; - case "tx_rollup_rejection": await ValidateTxRollupRejection(content); break; - case "tx_rollup_dispatch_tickets": await ValidateTxRollupDispatchTickets(content); break; - case "transfer_ticket": await ValidateTransferTicket(content); break; - case "smart_rollup_add_messages": await ValidateSmartRollupAddMessages(content); break; - case "smart_rollup_cement": await ValidateSmartRollupCement(content); break; - case "smart_rollup_execute_outbox_message": await ValidateSmartRollupExecute(content); break; - case "smart_rollup_originate": await ValidateSmartRollupOriginate(content); break; - case "smart_rollup_publish": await ValidateSmartRollupPublish(content); break; - case "smart_rollup_recover_bond": await ValidateSmartRollupRecoverBond(content); break; - case "smart_rollup_refute": await ValidateSmartRollupRefute(content); break; - case "smart_rollup_timeout": await ValidateSmartRollupTimeout(content); break; - default: - throw new ValidationException("invalid operation content kind"); - } - } - } - } - } - - protected virtual void ValidateEndorsement(JsonElement content) - { - if (content.RequiredInt32("level") != Cache.AppState.GetLevel()) - throw new ValidationException("invalid endorsement level"); - - if (!Cache.Accounts.DelegateExists(content.Required("metadata").RequiredString("delegate"))) - throw new ValidationException("unknown endorsement delegate"); - } - - protected virtual void ValidatePreendorsement(JsonElement content) - { - if (content.RequiredInt32("level") != Cache.AppState.GetLevel() + 1) - throw new ValidationException("invalid preendorsement level"); - - if (!Cache.Accounts.DelegateExists(content.Required("metadata").RequiredString("delegate"))) - throw new ValidationException("unknown endorsement delegate"); - } - - protected virtual async Task ValidateBallot(JsonElement content) - { - var periodIndex = content.RequiredInt32("period"); - - if (Cache.AppState.Get().VotingPeriod != periodIndex) - throw new ValidationException("invalid ballot voting period"); - - var proposal = await Cache.Proposals.GetOrDefaultAsync(Cache.AppState.Get().VotingEpoch, content.RequiredString("proposal")); - if (proposal?.Status != ProposalStatus.Active) - throw new ValidationException("invalid ballot proposal"); - - if (!Cache.Accounts.DelegateExists(content.RequiredString("source"))) - throw new ValidationException("invalid ballot sender"); - } - - protected virtual void ValidateProposal(JsonElement content) - { - var periodIndex = content.RequiredInt32("period"); - - if (Cache.AppState.Get().VotingPeriod != periodIndex) - throw new ValidationException("invalid proposal voting period"); - - var source = content.RequiredString("source"); - if (Protocol.Dictator != source && !Cache.Accounts.DelegateExists(source)) - throw new ValidationException("invalid proposal sender"); - } - - protected virtual async Task ValidateActivation(JsonElement content) - { - var account = content.RequiredString("pkh"); - - if (await Cache.Accounts.ExistsAsync(account, AccountType.User) && - ((await Cache.Accounts.GetAsync(account)) as User).Activated == true) - throw new ValidationException("account is already activated"); - - if (content.Required("metadata").RequiredArray("balance_updates", 2)[1].RequiredString("contract") != account) - throw new ValidationException("invalid activation balance updates"); - } - - protected virtual void ValidateDoubleBaking(JsonElement content) - { - var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); - - var offenders = balanceUpdates.Where(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits"); - if (offenders.Any()) - { - if (offenders.Count() > 1) - throw new ValidationException("invalid double baking offender updates"); - - if (!Cache.Accounts.DelegateExists(offenders.First().RequiredString("delegate"))) - throw new ValidationException("invalid double baking offender"); - } - - var accusers = balanceUpdates.Where(x => x.RequiredString("kind") == "contract"); - if (accusers.Any()) - { - if (accusers.Count() > 1) - throw new ValidationException("invalid double baking accuser updates"); - - var accuserAddress = accusers.First().RequiredString("contract"); - if (!Cache.Accounts.DelegateExists(accuserAddress) || accuserAddress != Proposer) - throw new ValidationException("invalid double baking accuser"); - } - } - - protected virtual async Task ValidateSeedNonceRevelation(JsonElement content) - { - var level = content.RequiredInt32("level"); - var proto = await Cache.Protocols.FindByLevelAsync(level); - - if (level % proto.BlocksPerCommitment != 0) - throw new ValidationException("invalid seed nonce revelation level"); - - var balanceUpdate = content.Required("metadata").RequiredArray("balance_updates", 2)[1]; - - if (balanceUpdate.RequiredString("kind") != "contract") - throw new ValidationException("invalid seed nonce revelation balance update kind"); - - if (balanceUpdate.RequiredString("contract") != Proposer) - throw new ValidationException("invalid seed nonce revelation baker"); - - if (balanceUpdate.RequiredInt64("change") != Protocol.RevelationReward) - throw new ValidationException("invalid seed nonce revelation balance update amount"); - } - - protected virtual void ValidateVdfRevelation(JsonElement content) - { - var balanceUpdate = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray() - .SingleOrDefault(x => x.RequiredString("kind") == "contract"); - - if (balanceUpdate.RequiredString("kind") != "contract") - throw new ValidationException("invalid vdf revelation balance update kind"); - - if (balanceUpdate.ValueKind != JsonValueKind.Undefined && balanceUpdate.RequiredString("contract") != Proposer) - throw new ValidationException("invalid vdf revelation baker"); - } - - protected virtual void ValidateDrainDelegate(JsonElement content) - { - var drainedBaker = content.RequiredString("delegate"); - var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); - - if (!Cache.Accounts.DelegateExists(drainedBaker)) - throw new ValidationException("unknown drained delegate"); - - if (balanceUpdates.Count() % 2 != 0) - throw new ValidationException("invalid drain balance updates count"); - - if (balanceUpdates.Where(x => x.RequiredInt64("change") < 0).Any(x => x.RequiredString("contract") != drainedBaker)) - throw new ValidationException("invalid drain balance updates"); - } - - protected virtual async Task ValidateDelegation(JsonElement content) - { - var source = content.RequiredString("source"); - var delegat = content.OptionalString("delegate"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - if (content.Required("metadata").Required("operation_result").RequiredString("status") == "applied" && delegat != null) - if (source != delegat && !Cache.Accounts.DelegateExists(delegat)) - throw new ValidationException("unknown delegate account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual void ValidateInternalDelegation(JsonElement content, string initiator) - { - //var delegat = content.OptionalString("delegate"); - - //if (content.Required("result").RequiredString("status") == "applied" && delegat != null) - // if (!Cache.Accounts.DelegateExists(delegat)) - // throw new ValidationException("unknown delegate account"); - } - - protected virtual async Task ValidateOrigination(JsonElement content) - { - var source = content.RequiredString("source"); - var delegat = content.OptionalString("delegate"); - var metadata = content.Required("metadata"); - var result = metadata.Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - if (applied && delegat != null) - if (!Cache.Accounts.DelegateExists(delegat)) - throw new ValidationException("unknown delegate account"); - - ValidateFeeBalanceUpdates( - metadata.OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - result.RequiredArray("originated_contracts", 1)[0].RequiredString(), - content.RequiredInt64("balance"), - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - Protocol.OriginationSize * Protocol.ByteCost); - } - - protected virtual void ValidateInternalOrigination(JsonElement content, string initiator) - { - //var delegat = content.OptionalString("delegate"); - var result = content.Required("result"); - var applied = result.RequiredString("status") == "applied"; - - //if (applied && delegat != null) - // if (!Cache.Accounts.DelegateExists(delegat)) - // throw new ValidationException("unknown delegate account"); - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.RequiredArray().EnumerateArray(), - content.RequiredString("source"), - result.RequiredArray("originated_contracts", 1)[0].RequiredString(), - content.RequiredInt64("balance"), - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - Protocol.OriginationSize * Protocol.ByteCost, - initiator); - } - - protected virtual async Task ValidateTransaction(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - var metadata = content.Required("metadata"); - - ValidateFeeBalanceUpdates( - metadata.OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = metadata.Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.RequiredArray().EnumerateArray(), - source, - content.RequiredString("destination"), - content.RequiredInt64("amount"), - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - (result.OptionalBool("allocated_destination_contract") ?? false) ? Protocol.OriginationSize * Protocol.ByteCost : 0); - - if (metadata.TryGetProperty("internal_operation_results", out var internalResults)) - { - foreach (var internalContent in internalResults.RequiredArray().EnumerateArray()) - { - switch (internalContent.RequiredString("kind")) - { - case "delegation": ValidateInternalDelegation(internalContent, source); break; - case "origination": ValidateInternalOrigination(internalContent, source); break; - case "transaction": ValidateInternalTransaction(internalContent, source); break; - case "event": break; - default: - throw new ValidationException("invalid internal operation kind"); - } - } - } - } - - protected virtual void ValidateInternalTransaction(JsonElement content, string initiator) - { - var result = content.Required("result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.RequiredArray().EnumerateArray(), - content.RequiredString("source"), - content.RequiredString("destination"), - content.RequiredInt64("amount"), - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - (result.OptionalBool("allocated_destination_contract") ?? false) ? Protocol.OriginationSize * Protocol.ByteCost : 0, - initiator); - } - - protected virtual async Task ValidateReveal(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateRegisterConstant(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateSetDepositsLimit(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateIncreasePaidStorage(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateUpdateConsensusKey(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateTxRollupOrigination(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - null, - 0, - 0, - Protocol.TxRollupOriginationSize * Protocol.ByteCost); - } - - protected virtual async Task ValidateTxRollupSubmitBatch(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - null, - 0, - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - 0); - } - - protected virtual async Task ValidateTxRollupCommit(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - { - if (updates.Count() != 2) - throw new ValidationException("unexpected number of rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid transfer balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "freezer" && - x.RequiredString("category") == "bonds" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid transfer balance updates"); - - if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) - throw new ValidationException("inconsistent change of rollup bonds balance updates"); - } - } - - protected virtual async Task ValidateTxRollupFinalizeCommitment(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - throw new ValidationException("unexpected balance updates"); - } - - protected virtual async Task ValidateTxRollupRemoveCommitment(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - throw new ValidationException("unexpected balance updates"); - } - - protected virtual async Task ValidateTxRollupReturnBond(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - { - if (updates.Count() != 2) - throw new ValidationException("unexpected number of rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid transfer balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "freezer" && - x.RequiredString("category") == "bonds" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid transfer balance updates"); - - if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) - throw new ValidationException("inconsistent change of rollup bonds balance updates"); - } - } - - protected virtual async Task ValidateTxRollupRejection(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateTxRollupDispatchTickets(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateTransferTicket(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateSmartRollupAddMessages(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - null, - 0, - 0, - 0); - } - - protected virtual async Task ValidateSmartRollupCement(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.RequiredString("status") == "applied" && - result.TryGetProperty("balance_updates", out var updates) && updates.Count() > 0) - throw new ValidationException("unexpected balnce updates"); - } - - protected virtual async Task ValidateSmartRollupExecute(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - var metadata = content.Required("metadata"); - - ValidateFeeBalanceUpdates( - metadata.OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = metadata.Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.RequiredArray().EnumerateArray(), - source, - null, - 0, - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - 0); - - if (metadata.TryGetProperty("internal_operation_results", out var internalResults)) - { - foreach (var internalContent in internalResults.RequiredArray().EnumerateArray()) - { - switch (internalContent.RequiredString("kind")) - { - case "delegation": ValidateInternalDelegation(internalContent, source); break; - case "origination": ValidateInternalOrigination(internalContent, source); break; - case "transaction": ValidateInternalTransaction(internalContent, source); break; - case "event": break; - default: - throw new ValidationException("invalid internal operation kind"); - } - } - } - } - - protected virtual async Task ValidateSmartRollupOriginate(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - null, - 0, - (result.OptionalInt32("size") ?? 0) * Protocol.ByteCost, - 0); - } - - protected virtual async Task ValidateSmartRollupPublish(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - { - if (updates.Count() != 2) - throw new ValidationException("unexpected number of smart rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid smart rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "freezer" && - x.RequiredString("category") == "bonds" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid smart rollup bonds balance updates"); - - if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) - throw new ValidationException("inconsistent change of smart rollup bonds balance updates"); - } - } - - protected virtual async Task ValidateSmartRollupRecoverBond(JsonElement content) - { - var source = content.RequiredString("source"); - var staker = content.RequiredString("staker"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - { - if (updates.Count() != 2) - throw new ValidationException("unexpected number of smart rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredString("contract") == staker)) - throw new ValidationException("invalid smart rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "freezer" && - x.RequiredString("category") == "bonds" && - x.RequiredString("contract") == staker)) - throw new ValidationException("invalid smart rollup bonds balance updates"); - - if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) - throw new ValidationException("inconsistent change of smart rollup bonds balance updates"); - } - } - - protected virtual async Task ValidateSmartRollupRefute(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateSmartRollupTimeout(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual void ValidateFeeBalanceUpdates(IEnumerable balanceUpdates, string sender, long fee) - { - if (fee != 0) - { - if (balanceUpdates.Count() != 2) - throw new ValidationException("invalid fee balance updates count"); - - var first = balanceUpdates.First(); - var last = balanceUpdates.Last(); - - if (first.RequiredString("kind") != "contract" || - first.RequiredString("contract") != sender || - first.RequiredInt64("change") != -fee) - throw new ValidationException("invalid fee contract update"); - - if (last.RequiredString("kind") != "accumulator" || - last.RequiredString("category") != "block fees" || - last.RequiredInt64("change") != fee) - throw new ValidationException("invalid fee accumulator update"); - } - else - { - if (balanceUpdates.Any()) - throw new ValidationException("invalid fee balance updates count"); - } - } - - protected virtual void ValidateTransferBalanceUpdates(IEnumerable balanceUpdates, string sender, string target, long amount, long storageFee, long allocationFee, string initiator = null) - { - if (balanceUpdates.Count() != (amount != 0 ? 2 : 0) + (storageFee != 0 ? 2 : 0) + (allocationFee != 0 ? 2 : 0)) - throw new ValidationException("invalid transfer balance updates count"); - - if (amount > 0) - { - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredInt64("change") == -amount && - x.RequiredString("contract") == sender)) - throw new ValidationException("invalid transfer balance updates"); - - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredInt64("change") == amount && - x.RequiredString("contract") == target)) - throw new ValidationException("invalid transfer balance updates"); - } - - if (storageFee > 0) - { - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredInt64("change") == -storageFee && - x.RequiredString("contract") == (initiator ?? sender))) - throw new ValidationException("invalid storage fee balance updates"); - - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "burned" && - x.RequiredString("category") == "storage fees" && - x.RequiredInt64("change") == storageFee)) - throw new ValidationException("invalid storage fee balance updates"); - } - - if (allocationFee > 0) - { - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredInt64("change") == -allocationFee && - x.RequiredString("contract") == (initiator ?? sender))) - throw new ValidationException("invalid allocation fee balance updates"); - - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "burned" && - x.RequiredString("category") == "storage fees" && - x.RequiredInt64("change") == allocationFee)) - throw new ValidationException("invalid allocation fee balance updates"); - } - } + public Validator(ProtocolHandler protocol) : base(protocol) { } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/StatisticsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/StatisticsCommit.cs index 25e1419f2..44c24dd17 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/StatisticsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/StatisticsCommit.cs @@ -1,6 +1,6 @@ namespace Tzkt.Sync.Protocols.Proto17 { - class StatisticsCommit : Proto12.StatisticsCommit + class StatisticsCommit : Proto1.StatisticsCommit { public StatisticsCommit(ProtocolHandler protocol) : base(protocol) { } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index f5c23e376..489a5b397 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -31,6 +31,8 @@ public Proto17Handler(TezosNode node, TzktContext db, CacheService cache, Quotes public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); @@ -340,13 +342,8 @@ public override async Task Commit(JsonElement block) cycleCommit.SelectedStakes, brCommit.CurrentRights); - var freezerCommit = new FreezerCommit(this); - freezerCommit.Apply(blockCommit.Block, block); - - var endorsingRewardCommit = new EndorsingRewardCommit(this); - await endorsingRewardCommit.Apply(blockCommit.Block, block); - - await new StatisticsCommit(this).Apply(blockCommit.Block, endorsingRewardCommit.Ops, freezerCommit.FreezerChange); + new FreezerCommit(this).Apply(blockCommit.Block, block); + await new EndorsingRewardCommit(this).Apply(blockCommit.Block, block); await new VotingCommit(this).Apply(blockCommit.Block, block); await new StateCommit(this).Apply(blockCommit.Block, block); } @@ -354,7 +351,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() @@ -494,7 +491,7 @@ public override async Task Revert() await new StatisticsCommit(this).Revert(currBlock); await new EndorsingRewardCommit(this).Revert(currBlock); - await new FreezerCommit(this).Revert(currBlock); + new FreezerCommit(this).Revert(); await new BakerCycleCommit(this).Revert(currBlock); await new DelegatorCycleCommit(this).Revert(currBlock); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Validation/Validator.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Validation/Validator.cs index f49088747..f8be97516 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Validation/Validator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Validation/Validator.cs @@ -1,1010 +1,7 @@ -using System.Text.Json; -using Tzkt.Data.Models; -using Tzkt.Sync.Services; - -namespace Tzkt.Sync.Protocols.Proto17 +namespace Tzkt.Sync.Protocols.Proto17 { - class Validator : IValidator + class Validator : Proto1.Validator { - readonly CacheService Cache; - Protocol Protocol; - string Proposer; - string Producer; - int Level; - int Cycle; - - public Validator(ProtocolHandler protocol) => Cache = protocol.Cache; - - public virtual async Task ValidateBlock(JsonElement block) - { - Protocol = await Cache.Protocols.GetAsync(Cache.AppState.GetNextProtocol()); - - if (block.RequiredString("chain_id") != Cache.AppState.GetChainId()) - throw new ValidationException("invalid chain"); - - if (block.RequiredString("protocol") != Cache.AppState.GetNextProtocol()) - throw new ValidationException("invalid block protocol", true); - - ValidateBlockHeader(block.Required("header")); - await ValidateBlockMetadata(block.Required("metadata")); - await ValidateOperations(block.RequiredArray("operations", 4)); - } - - void ValidateBlockHeader(JsonElement header) - { - Level = header.RequiredInt32("level"); - if (Level != Cache.AppState.GetNextLevel()) - throw new ValidationException($"invalid block level", true); - - if (header.RequiredString("predecessor") != Cache.AppState.GetHead()) - throw new ValidationException($"invalid block predecessor", true); - } - - async Task ValidateBlockMetadata(JsonElement metadata) - { - #region baking - Proposer = metadata.RequiredString("proposer"); - if (!Cache.Accounts.DelegateExists(Proposer)) - throw new ValidationException($"non-existent block proposer"); - - Producer = metadata.RequiredString("baker"); - if (!Cache.Accounts.DelegateExists(Producer)) - throw new ValidationException($"non-existent block baker"); - #endregion - - #region level info - Cycle = metadata.Required("level_info").RequiredInt32("cycle"); - if (Cycle != Protocol.GetCycle(Level)) - throw new ValidationException($"invalid block cycle", true); - #endregion - - #region voting info - var periodInfo = metadata.Required("voting_period_info").Required("voting_period"); - var periodIndex = periodInfo.RequiredInt32("index"); - var periodKind = periodInfo.RequiredString("kind") switch - { - "proposal" => PeriodKind.Proposal, - "exploration" => PeriodKind.Exploration, - "cooldown" => PeriodKind.Testing, - "promotion" => PeriodKind.Promotion, - "adoption" => PeriodKind.Adoption, - _ => throw new ValidationException("invalid voting period kind") - }; - - var period = await Cache.Periods.GetAsync(Cache.AppState.Get().VotingPeriod); - if (Level > period.FirstLevel && Level < period.LastLevel) - { - if (periodIndex != period.Index) - throw new ValidationException("invalid voting period index"); - - if (!Protocol.HasDictator && periodKind != period.Kind) - throw new ValidationException("unexpected voting period"); - } - #endregion - - #region deactivation - foreach (var baker in metadata.RequiredArray("deactivated").EnumerateArray()) - if (!Cache.Accounts.DelegateExists(baker.GetString())) - throw new ValidationException($"non-existent deactivated baker {baker}"); - #endregion - - #region balance updates - var balanceUpdates = metadata.RequiredArray("balance_updates").EnumerateArray(); - if (balanceUpdates.Any(x => x.RequiredString("kind") == "contract" && x.RequiredString("origin") == "block" && !Cache.Accounts.DelegateExists(x.RequiredString("contract")))) - throw new ValidationException("non-existent delegate in block balance updates"); - - if (Cycle < Protocol.NoRewardCycles) - { - if (balanceUpdates.Any(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking rewards")) - throw new ValidationException("unexpected block reward"); - - if (balanceUpdates.Any(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking bonuses")) - throw new ValidationException("unexpected block bonus"); - } - else - { - if (balanceUpdates.Count(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking rewards") != 1) - throw new ValidationException("invalid block reward"); - - if (balanceUpdates.Count(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking bonuses") > 1) - throw new ValidationException("invalid block bonus"); - - if (balanceUpdates.Count(x => x.RequiredString("origin") == "block") > 5 && !Protocol.IsCycleEnd(Level)) - throw new ValidationException("unexpected cycle rewards"); - } - #endregion - - #region implicit operations - foreach (var op in metadata.RequiredArray("implicit_operations_results").EnumerateArray()) - { - var kind = op.RequiredString("kind"); - if (kind == "transaction") - { - var subsidy = op.RequiredArray("balance_updates", 2).EnumerateArray() - .Where(x => x.RequiredString("kind") == "contract"); - - if (subsidy.Count() > 1) - throw new ValidationException("invalid subsidy"); - - if (subsidy.Any(x => x.RequiredString("origin") != "subsidy")) - throw new ValidationException("invalid subsidy origin"); - - if (subsidy.Any(x => x.RequiredString("contract") != Proto10.ProtoActivator.CpmmContract)) - throw new ValidationException("invalid subsidy recepient"); - } - else if (kind == "origination" && Level == Protocol.FirstLevel) - { - var contract = op.RequiredArray("originated_contracts", 1)[0].RequiredString(); - if (!await Cache.Accounts.ExistsAsync(contract, AccountType.Contract)) - throw new ValidationException("unexpected implicit origination"); - } - else - { - throw new ValidationException("unexpected implicit operation kind"); - } - } - #endregion - } - - protected virtual async Task ValidateOperations(JsonElement operations) - { - foreach (var opg in operations.EnumerateArray()) - { - foreach (var op in opg.RequiredArray().EnumerateArray()) - { - foreach (var content in op.RequiredArray("contents").EnumerateArray()) - { - switch (content.RequiredString("kind")) - { - case "endorsement": ValidateEndorsement(content); break; - case "preendorsement": ValidatePreendorsement(content); break; - case "ballot": await ValidateBallot(content); break; - case "proposals": ValidateProposal(content); break; - case "activate_account": await ValidateActivation(content); break; - case "double_baking_evidence": ValidateDoubleBaking(content); break; - case "double_endorsement_evidence": ValidateDoubleBaking(content); break; - case "double_preendorsement_evidence": ValidateDoubleBaking(content); break; - case "seed_nonce_revelation": await ValidateSeedNonceRevelation(content); break; - case "vdf_revelation": ValidateVdfRevelation(content); break; - case "drain_delegate": ValidateDrainDelegate(content); break; - case "delegation": await ValidateDelegation(content); break; - case "origination": await ValidateOrigination(content); break; - case "transaction": await ValidateTransaction(content); break; - case "reveal": await ValidateReveal(content); break; - case "register_global_constant": await ValidateRegisterConstant(content); break; - case "set_deposits_limit": await ValidateSetDepositsLimit(content); break; - case "increase_paid_storage": await ValidateIncreasePaidStorage(content); break; - case "update_consensus_key": await ValidateUpdateConsensusKey(content); break; - case "tx_rollup_origination": await ValidateTxRollupOrigination(content); break; - case "tx_rollup_submit_batch": await ValidateTxRollupSubmitBatch(content); break; - case "tx_rollup_commit": await ValidateTxRollupCommit(content); break; - case "tx_rollup_finalize_commitment": await ValidateTxRollupFinalizeCommitment(content); break; - case "tx_rollup_remove_commitment": await ValidateTxRollupRemoveCommitment(content); break; - case "tx_rollup_return_bond": await ValidateTxRollupReturnBond(content); break; - case "tx_rollup_rejection": await ValidateTxRollupRejection(content); break; - case "tx_rollup_dispatch_tickets": await ValidateTxRollupDispatchTickets(content); break; - case "transfer_ticket": await ValidateTransferTicket(content); break; - case "smart_rollup_add_messages": await ValidateSmartRollupAddMessages(content); break; - case "smart_rollup_cement": await ValidateSmartRollupCement(content); break; - case "smart_rollup_execute_outbox_message": await ValidateSmartRollupExecute(content); break; - case "smart_rollup_originate": await ValidateSmartRollupOriginate(content); break; - case "smart_rollup_publish": await ValidateSmartRollupPublish(content); break; - case "smart_rollup_recover_bond": await ValidateSmartRollupRecoverBond(content); break; - case "smart_rollup_refute": await ValidateSmartRollupRefute(content); break; - case "smart_rollup_timeout": await ValidateSmartRollupTimeout(content); break; - default: - throw new ValidationException("invalid operation content kind"); - } - } - } - } - } - - protected virtual void ValidateEndorsement(JsonElement content) - { - if (content.RequiredInt32("level") != Cache.AppState.GetLevel()) - throw new ValidationException("invalid endorsement level"); - - if (!Cache.Accounts.DelegateExists(content.Required("metadata").RequiredString("delegate"))) - throw new ValidationException("unknown endorsement delegate"); - } - - protected virtual void ValidatePreendorsement(JsonElement content) - { - if (content.RequiredInt32("level") != Cache.AppState.GetLevel() + 1) - throw new ValidationException("invalid preendorsement level"); - - if (!Cache.Accounts.DelegateExists(content.Required("metadata").RequiredString("delegate"))) - throw new ValidationException("unknown endorsement delegate"); - } - - protected virtual async Task ValidateBallot(JsonElement content) - { - var periodIndex = content.RequiredInt32("period"); - - if (Cache.AppState.Get().VotingPeriod != periodIndex) - throw new ValidationException("invalid ballot voting period"); - - var proposal = await Cache.Proposals.GetOrDefaultAsync(Cache.AppState.Get().VotingEpoch, content.RequiredString("proposal")); - if (proposal?.Status != ProposalStatus.Active) - throw new ValidationException("invalid ballot proposal"); - - if (!Cache.Accounts.DelegateExists(content.RequiredString("source"))) - throw new ValidationException("invalid ballot sender"); - } - - protected virtual void ValidateProposal(JsonElement content) - { - var periodIndex = content.RequiredInt32("period"); - - if (Cache.AppState.Get().VotingPeriod != periodIndex) - throw new ValidationException("invalid proposal voting period"); - - var source = content.RequiredString("source"); - if (Protocol.Dictator != source && !Cache.Accounts.DelegateExists(source)) - throw new ValidationException("invalid proposal sender"); - } - - protected virtual async Task ValidateActivation(JsonElement content) - { - var account = content.RequiredString("pkh"); - - if (await Cache.Accounts.ExistsAsync(account, AccountType.User) && - ((await Cache.Accounts.GetAsync(account)) as User).Activated == true) - throw new ValidationException("account is already activated"); - - if (content.Required("metadata").RequiredArray("balance_updates", 2)[1].RequiredString("contract") != account) - throw new ValidationException("invalid activation balance updates"); - } - - protected virtual void ValidateDoubleBaking(JsonElement content) - { - var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); - - var offenders = balanceUpdates.Where(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits"); - if (offenders.Any()) - { - if (offenders.Count() > 1) - throw new ValidationException("invalid double baking offender updates"); - - if (!Cache.Accounts.DelegateExists(offenders.First().RequiredString("delegate"))) - throw new ValidationException("invalid double baking offender"); - } - - var accusers = balanceUpdates.Where(x => x.RequiredString("kind") == "contract"); - if (accusers.Any()) - { - if (accusers.Count() > 1) - throw new ValidationException("invalid double baking accuser updates"); - - var accuserAddress = accusers.First().RequiredString("contract"); - if (!Cache.Accounts.DelegateExists(accuserAddress) || accuserAddress != Proposer) - throw new ValidationException("invalid double baking accuser"); - } - } - - protected virtual async Task ValidateSeedNonceRevelation(JsonElement content) - { - var level = content.RequiredInt32("level"); - var proto = await Cache.Protocols.FindByLevelAsync(level); - - if (level % proto.BlocksPerCommitment != 0) - throw new ValidationException("invalid seed nonce revelation level"); - - var balanceUpdate = content.Required("metadata").RequiredArray("balance_updates", 2)[1]; - - if (balanceUpdate.RequiredString("kind") != "contract") - throw new ValidationException("invalid seed nonce revelation balance update kind"); - - if (balanceUpdate.RequiredString("contract") != Proposer) - throw new ValidationException("invalid seed nonce revelation baker"); - - if (balanceUpdate.RequiredInt64("change") != Protocol.RevelationReward) - throw new ValidationException("invalid seed nonce revelation balance update amount"); - } - - protected virtual void ValidateVdfRevelation(JsonElement content) - { - var balanceUpdate = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray() - .SingleOrDefault(x => x.RequiredString("kind") == "contract"); - - if (balanceUpdate.RequiredString("kind") != "contract") - throw new ValidationException("invalid vdf revelation balance update kind"); - - if (balanceUpdate.ValueKind != JsonValueKind.Undefined && balanceUpdate.RequiredString("contract") != Proposer) - throw new ValidationException("invalid vdf revelation baker"); - } - - protected virtual void ValidateDrainDelegate(JsonElement content) - { - var drainedBaker = content.RequiredString("delegate"); - var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); - - if (!Cache.Accounts.DelegateExists(drainedBaker)) - throw new ValidationException("unknown drained delegate"); - - if (balanceUpdates.Count() % 2 != 0) - throw new ValidationException("invalid drain balance updates count"); - - if (balanceUpdates.Where(x => x.RequiredInt64("change") < 0).Any(x => x.RequiredString("contract") != drainedBaker)) - throw new ValidationException("invalid drain balance updates"); - } - - protected virtual async Task ValidateDelegation(JsonElement content) - { - var source = content.RequiredString("source"); - var delegat = content.OptionalString("delegate"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - if (content.Required("metadata").Required("operation_result").RequiredString("status") == "applied" && delegat != null) - if (source != delegat && !Cache.Accounts.DelegateExists(delegat)) - throw new ValidationException("unknown delegate account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual void ValidateInternalDelegation(JsonElement content, string initiator) - { - //var delegat = content.OptionalString("delegate"); - - //if (content.Required("result").RequiredString("status") == "applied" && delegat != null) - // if (!Cache.Accounts.DelegateExists(delegat)) - // throw new ValidationException("unknown delegate account"); - } - - protected virtual async Task ValidateOrigination(JsonElement content) - { - var source = content.RequiredString("source"); - var delegat = content.OptionalString("delegate"); - var metadata = content.Required("metadata"); - var result = metadata.Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - if (applied && delegat != null) - if (!Cache.Accounts.DelegateExists(delegat)) - throw new ValidationException("unknown delegate account"); - - ValidateFeeBalanceUpdates( - metadata.OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - result.RequiredArray("originated_contracts", 1)[0].RequiredString(), - content.RequiredInt64("balance"), - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - Protocol.OriginationSize * Protocol.ByteCost); - } - - protected virtual void ValidateInternalOrigination(JsonElement content, string initiator) - { - //var delegat = content.OptionalString("delegate"); - var result = content.Required("result"); - var applied = result.RequiredString("status") == "applied"; - - //if (applied && delegat != null) - // if (!Cache.Accounts.DelegateExists(delegat)) - // throw new ValidationException("unknown delegate account"); - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.RequiredArray().EnumerateArray(), - content.RequiredString("source"), - result.RequiredArray("originated_contracts", 1)[0].RequiredString(), - content.RequiredInt64("balance"), - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - Protocol.OriginationSize * Protocol.ByteCost, - initiator); - } - - protected virtual async Task ValidateTransaction(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - var metadata = content.Required("metadata"); - - ValidateFeeBalanceUpdates( - metadata.OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = metadata.Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.RequiredArray().EnumerateArray(), - source, - content.RequiredString("destination"), - content.RequiredInt64("amount"), - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - (result.OptionalBool("allocated_destination_contract") ?? false) ? Protocol.OriginationSize * Protocol.ByteCost : 0); - - if (metadata.TryGetProperty("internal_operation_results", out var internalResults)) - { - foreach (var internalContent in internalResults.RequiredArray().EnumerateArray()) - { - switch (internalContent.RequiredString("kind")) - { - case "delegation": ValidateInternalDelegation(internalContent, source); break; - case "origination": ValidateInternalOrigination(internalContent, source); break; - case "transaction": ValidateInternalTransaction(internalContent, source); break; - case "event": break; - default: - throw new ValidationException("invalid internal operation kind"); - } - } - } - } - - protected virtual void ValidateInternalTransaction(JsonElement content, string initiator) - { - var result = content.Required("result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.RequiredArray().EnumerateArray(), - content.RequiredString("source"), - content.RequiredString("destination"), - content.RequiredInt64("amount"), - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - (result.OptionalBool("allocated_destination_contract") ?? false) ? Protocol.OriginationSize * Protocol.ByteCost : 0, - initiator); - } - - protected virtual async Task ValidateReveal(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateRegisterConstant(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateSetDepositsLimit(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateIncreasePaidStorage(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateUpdateConsensusKey(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateTxRollupOrigination(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - null, - 0, - 0, - Protocol.TxRollupOriginationSize * Protocol.ByteCost); - } - - protected virtual async Task ValidateTxRollupSubmitBatch(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - null, - 0, - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - 0); - } - - protected virtual async Task ValidateTxRollupCommit(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - { - if (updates.Count() != 2) - throw new ValidationException("unexpected number of rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid transfer balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "freezer" && - x.RequiredString("category") == "bonds" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid transfer balance updates"); - - if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) - throw new ValidationException("inconsistent change of rollup bonds balance updates"); - } - } - - protected virtual async Task ValidateTxRollupFinalizeCommitment(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - throw new ValidationException("unexpected balance updates"); - } - - protected virtual async Task ValidateTxRollupRemoveCommitment(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - throw new ValidationException("unexpected balance updates"); - } - - protected virtual async Task ValidateTxRollupReturnBond(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - { - if (updates.Count() != 2) - throw new ValidationException("unexpected number of rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid transfer balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "freezer" && - x.RequiredString("category") == "bonds" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid transfer balance updates"); - - if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) - throw new ValidationException("inconsistent change of rollup bonds balance updates"); - } - } - - protected virtual async Task ValidateTxRollupRejection(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateTxRollupDispatchTickets(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateTransferTicket(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateSmartRollupAddMessages(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - null, - 0, - 0, - 0); - } - - protected virtual async Task ValidateSmartRollupCement(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.RequiredString("status") == "applied" && - result.TryGetProperty("balance_updates", out var updates) && updates.Count() > 0) - throw new ValidationException("unexpected balnce updates"); - } - - protected virtual async Task ValidateSmartRollupExecute(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - var metadata = content.Required("metadata"); - - ValidateFeeBalanceUpdates( - metadata.OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = metadata.Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.RequiredArray().EnumerateArray(), - source, - null, - 0, - (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, - 0); - - if (metadata.TryGetProperty("internal_operation_results", out var internalResults)) - { - foreach (var internalContent in internalResults.RequiredArray().EnumerateArray()) - { - switch (internalContent.RequiredString("kind")) - { - case "delegation": ValidateInternalDelegation(internalContent, source); break; - case "origination": ValidateInternalOrigination(internalContent, source); break; - case "transaction": ValidateInternalTransaction(internalContent, source); break; - case "event": break; - default: - throw new ValidationException("invalid internal operation kind"); - } - } - } - } - - protected virtual async Task ValidateSmartRollupOriginate(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - var applied = result.RequiredString("status") == "applied"; - - if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) - ValidateTransferBalanceUpdates( - resultUpdates.EnumerateArray(), - source, - null, - 0, - (result.OptionalInt32("size") ?? 0) * Protocol.ByteCost, - 0); - } - - protected virtual async Task ValidateSmartRollupPublish(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - { - if (updates.Count() != 2) - throw new ValidationException("unexpected number of smart rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid smart rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "freezer" && - x.RequiredString("category") == "bonds" && - x.RequiredString("contract") == source)) - throw new ValidationException("invalid smart rollup bonds balance updates"); - - if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) - throw new ValidationException("inconsistent change of smart rollup bonds balance updates"); - } - } - - protected virtual async Task ValidateSmartRollupRecoverBond(JsonElement content) - { - var source = content.RequiredString("source"); - var staker = content.RequiredString("staker"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - - var result = content.Required("metadata").Required("operation_result"); - if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) - { - if (updates.Count() != 2) - throw new ValidationException("unexpected number of smart rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredString("contract") == staker)) - throw new ValidationException("invalid smart rollup bonds balance updates"); - - if (!updates.EnumerateArray().Any(x => - x.RequiredString("kind") == "freezer" && - x.RequiredString("category") == "bonds" && - x.RequiredString("contract") == staker)) - throw new ValidationException("invalid smart rollup bonds balance updates"); - - if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) - throw new ValidationException("inconsistent change of smart rollup bonds balance updates"); - } - } - - protected virtual async Task ValidateSmartRollupRefute(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual async Task ValidateSmartRollupTimeout(JsonElement content) - { - var source = content.RequiredString("source"); - - if (!await Cache.Accounts.ExistsAsync(source)) - throw new ValidationException("unknown source account"); - - ValidateFeeBalanceUpdates( - content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), - source, - content.RequiredInt64("fee")); - } - - protected virtual void ValidateFeeBalanceUpdates(IEnumerable balanceUpdates, string sender, long fee) - { - if (fee != 0) - { - if (balanceUpdates.Count() != 2) - throw new ValidationException("invalid fee balance updates count"); - - var first = balanceUpdates.First(); - var last = balanceUpdates.Last(); - - if (first.RequiredString("kind") != "contract" || - first.RequiredString("contract") != sender || - first.RequiredInt64("change") != -fee) - throw new ValidationException("invalid fee contract update"); - - if (last.RequiredString("kind") != "accumulator" || - last.RequiredString("category") != "block fees" || - last.RequiredInt64("change") != fee) - throw new ValidationException("invalid fee accumulator update"); - } - else - { - if (balanceUpdates.Any()) - throw new ValidationException("invalid fee balance updates count"); - } - } - - protected virtual void ValidateTransferBalanceUpdates(IEnumerable balanceUpdates, string sender, string target, long amount, long storageFee, long allocationFee, string initiator = null) - { - if (balanceUpdates.Count() != (amount != 0 ? 2 : 0) + (storageFee != 0 ? 2 : 0) + (allocationFee != 0 ? 2 : 0)) - throw new ValidationException("invalid transfer balance updates count"); - - if (amount > 0) - { - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredInt64("change") == -amount && - x.RequiredString("contract") == sender)) - throw new ValidationException("invalid transfer balance updates"); - - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredInt64("change") == amount && - x.RequiredString("contract") == target)) - throw new ValidationException("invalid transfer balance updates"); - } - - if (storageFee > 0) - { - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredInt64("change") == -storageFee && - x.RequiredString("contract") == (initiator ?? sender))) - throw new ValidationException("invalid storage fee balance updates"); - - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "burned" && - x.RequiredString("category") == "storage fees" && - x.RequiredInt64("change") == storageFee)) - throw new ValidationException("invalid storage fee balance updates"); - } - - if (allocationFee > 0) - { - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "contract" && - x.RequiredInt64("change") == -allocationFee && - x.RequiredString("contract") == (initiator ?? sender))) - throw new ValidationException("invalid allocation fee balance updates"); - - if (!balanceUpdates.Any(x => - x.RequiredString("kind") == "burned" && - x.RequiredString("category") == "storage fees" && - x.RequiredInt64("change") == allocationFee)) - throw new ValidationException("invalid allocation fee balance updates"); - } - } + public Validator(ProtocolHandler protocol) : base(protocol) { } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Activation/ProtoActivator.cs new file mode 100644 index 000000000..ea6fcd2b4 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Activation/ProtoActivator.cs @@ -0,0 +1,389 @@ +using System.Numerics; +using Microsoft.EntityFrameworkCore; +using Netezos.Encoding; +using Newtonsoft.Json.Linq; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + partial class ProtoActivator : Proto17.ProtoActivator + { + public ProtoActivator(ProtocolHandler proto) : base(proto) { } + + protected override async Task> BootstrapAccounts(Protocol protocol, JToken parameters) + { + var accounts = await base.BootstrapAccounts(protocol, parameters); + + var bakers = accounts + .Where(x => x is Data.Models.Delegate d && d.StakingBalance >= protocol.MinimalStake) + .Select(x => x as Data.Models.Delegate); + + Cache.Statistics.Current.TotalFrozen = 0; + foreach (var baker in bakers) + { + baker.StakedBalance = baker.StakingBalance / (protocol.MaxDelegatedOverFrozenRatio + 1); + baker.TotalStakedBalance = baker.StakedBalance; + Cache.Statistics.Current.TotalFrozen += baker.StakedBalance; + } + + return accounts; + } + + public override List BootstrapCycles(Protocol protocol, List accounts, JToken parameters) + { + var cycles = base.BootstrapCycles(protocol, accounts, parameters); + + var bakers = accounts + .Where(x => x is Data.Models.Delegate d && d.StakingBalance >= protocol.MinimalStake) + .Select(x => x as Data.Models.Delegate); + + var issuances = Proto.Rpc.GetExpectedIssuance(1).Result; + + foreach (var cycle in cycles) + { + cycle.TotalBakingPower = bakers.Sum(x => Math.Min(x.StakingBalance, x.TotalStakedBalance * (protocol.MaxDelegatedOverFrozenRatio + 1))); + cycle.TotalBakers = bakers.Count(); + + var issuance = issuances.EnumerateArray().First(x => x.RequiredInt32("cycle") == cycle.Index); + + cycle.BlockReward = issuance.RequiredInt64("baking_reward_fixed_portion"); + cycle.BlockBonusPerSlot = issuance.RequiredInt64("baking_reward_bonus_per_slot"); + cycle.MaxBlockReward = cycle.BlockReward + cycle.BlockBonusPerSlot * (protocol.EndorsersPerBlock - protocol.ConsensusThreshold); + cycle.EndorsementRewardPerSlot = issuance.RequiredInt64("attesting_reward_per_slot"); + cycle.NonceRevelationReward = issuance.RequiredInt64("seed_nonce_revelation_tip"); + cycle.VdfRevelationReward = issuance.RequiredInt64("vdf_revelation_tip"); + cycle.LBSubsidy = issuance.RequiredInt64("liquidity_baking_subsidy"); + } + + return cycles; + } + + public override void BootstrapBakerCycles( + Protocol protocol, + List accounts, + List cycles, + List> bakingRights, + List> endorsingRights) + { + var bakers = accounts + .Where(x => x.Type == AccountType.Delegate) + .Select(x => x as Data.Models.Delegate); + + foreach (var cycle in cycles) + { + var bakerCycles = bakers.ToDictionary(x => x.Id, x => + { + var bakerCycle = new BakerCycle + { + Cycle = cycle.Index, + BakerId = x.Id, + OwnDelegatedBalance = x.Balance - x.StakedBalance, + ExternalDelegatedBalance = x.DelegatedBalance, + DelegatorsCount = x.DelegatorsCount, + OwnStakedBalance = x.StakedBalance, + ExternalStakedBalance = x.ExternalStakedBalance, + StakersCount = x.StakersCount, + BakingPower = 0, + TotalBakingPower = cycle.TotalBakingPower + }; + if (x.StakingBalance >= protocol.MinimalStake) + { + var bakingPower = Math.Min(x.StakingBalance, x.TotalStakedBalance * (protocol.MaxDelegatedOverFrozenRatio + 1)); + var expectedEndorsements = (int)(new BigInteger(protocol.BlocksPerCycle) * protocol.EndorsersPerBlock * bakingPower / cycle.TotalBakingPower); + bakerCycle.BakingPower = bakingPower; + bakerCycle.ExpectedBlocks = protocol.BlocksPerCycle * bakingPower / cycle.TotalBakingPower; + bakerCycle.ExpectedEndorsements = expectedEndorsements; + bakerCycle.FutureEndorsementRewards = expectedEndorsements * cycle.EndorsementRewardPerSlot; + } + return bakerCycle; + }); + + #region future baking rights + foreach (var br in bakingRights[cycle.Index].SkipWhile(x => x.Level == 1).Where(x => x.Round == 0)) + { + if (!bakerCycles.TryGetValue(br.Baker, out var bakerCycle)) + throw new Exception("Unknown baking right recipient"); + + bakerCycle.FutureBlocks++; + bakerCycle.FutureBlockRewards += cycle.MaxBlockReward; + } + #endregion + + #region future endorsing rights + foreach (var er in endorsingRights[cycle.Index].TakeWhile(x => x.Level < cycle.LastLevel)) + { + if (!bakerCycles.TryGetValue(er.Baker, out var bakerCycle)) + throw new Exception("Unknown endorsing right recipient"); + + bakerCycle.FutureEndorsements += er.Slots; + } + #endregion + + #region shifted future endirsing rights + if (cycle.Index > 0) + { + foreach (var er in endorsingRights[cycle.Index - 1].Reverse().TakeWhile(x => x.Level == cycle.FirstLevel - 1)) + { + if (!bakerCycles.TryGetValue(er.Baker, out var bakerCycle)) + throw new Exception("Unknown endorsing right recipient"); + + bakerCycle.FutureEndorsements += er.Slots; + } + } + #endregion + + Db.BakerCycles.AddRange(bakerCycles.Values); + } + } + + protected override void SetParameters(Protocol protocol, JToken parameters) + { + base.SetParameters(protocol, parameters); + protocol.MinimalFrozenStake = parameters["minimal_frozen_stake"]?.Value() ?? 600_000_000; + protocol.MaxDelegatedOverFrozenRatio = parameters["limit_of_delegation_over_baking"]?.Value() ?? 9; + protocol.MaxExternalOverOwnStakeRatio = parameters["global_limit_of_staking_over_baking"]?.Value() ?? 5; + protocol.StakePowerMultiplier = parameters["edge_of_staking_over_delegation"]?.Value() ?? 2; + + protocol.BaseIssuedPerMinute = parameters["issuance_weights"]?["base_total_issued_per_minute"]?.Value() ?? 85_007_812; + protocol.BlockRewardWeight = parameters["issuance_weights"]?["baking_reward_fixed_portion_weight"]?.Value() ?? 5120; + protocol.BlockBonusWeight = parameters["issuance_weights"]?["baking_reward_bonus_weight"]?.Value() ?? 5120; + protocol.EndorsingRewardWeight = parameters["issuance_weights"]?["attesting_reward_weight"]?.Value() ?? 10240; + protocol.NonceRevelationRewardWeight = parameters["issuance_weights"]?["seed_nonce_revelation_tip_weight"]?.Value() ?? 1; + protocol.VdfRevelationRewardWeight = parameters["issuance_weights"]?["vdf_revelation_tip_weight"]?.Value() ?? 1; + protocol.LBSubsidyWeight = parameters["issuance_weights"]?["liquidity_baking_subsidy_weight"]?.Value() ?? 1280; + + protocol.DoubleBakingSlashedPercentage = parameters["percentage_of_frozen_deposits_slashed_per_double_baking"]?.Value() ?? 5; + protocol.DoubleEndorsingSlashedPercentage = parameters["percentage_of_frozen_deposits_slashed_per_double_attestation"]?.Value() ?? 50; + + protocol.BlockDeposit = 0; + protocol.BlockReward0 = 0; + protocol.BlockReward1 = 0; + protocol.MaxBakingReward = 0; + protocol.EndorsementDeposit = 0; + protocol.EndorsementReward0 = 0; + protocol.EndorsementReward1 = 0; + protocol.MaxEndorsingReward = 0; + } + + protected override void UpgradeParameters(Protocol protocol, Protocol prev) + { + protocol.MinimalFrozenStake = 600_000_000; + protocol.MaxDelegatedOverFrozenRatio = 9; + protocol.MaxExternalOverOwnStakeRatio = 5; + protocol.StakePowerMultiplier = 2; + + protocol.BaseIssuedPerMinute = 85_007_812; + protocol.BlockRewardWeight = 5120; + protocol.BlockBonusWeight = 5120; + protocol.EndorsingRewardWeight = 10240; + protocol.NonceRevelationRewardWeight = 1; + protocol.VdfRevelationRewardWeight = 1; + protocol.LBSubsidyWeight = 1280; + + protocol.DoubleBakingSlashedPercentage = 5; + protocol.DoubleEndorsingSlashedPercentage = 50; + + protocol.BlockDeposit = 0; + protocol.BlockReward0 = 0; + protocol.BlockReward1 = 0; + protocol.MaxBakingReward = 0; + protocol.EndorsementDeposit = 0; + protocol.EndorsementReward0 = 0; + protocol.EndorsementReward1 = 0; + protocol.MaxEndorsingReward = 0; + } + + protected override async Task MigrateContext(AppState state) + { + await RemoveDeadRefutationGames(state); + await RemoveBigmapKeys(state); + await MigrateBakers(state); + } + + protected async Task RemoveDeadRefutationGames(AppState state) + { + var activeGames = await Db.RefutationGames + .AsNoTracking() + .Where(x => + x.InitiatorReward == null && + x.InitiatorLoss == null && + x.OpponentReward == null && + x.OpponentLoss == null) + .ToListAsync(); + + foreach (var game in activeGames) + { + var initiatorBond = await Db.SmartRollupPublishOps + .AsNoTracking() + .Where(x => + x.SmartRollupId == game.SmartRollupId && + x.BondStatus == SmartRollupBondStatus.Active && + x.SenderId == game.InitiatorId) + .FirstOrDefaultAsync(); + + if (initiatorBond != null) + continue; + + var opponentBond = await Db.SmartRollupPublishOps + .AsNoTracking() + .Where(x => + x.SmartRollupId == game.SmartRollupId && + x.BondStatus == SmartRollupBondStatus.Active && + x.SenderId == game.OpponentId) + .FirstOrDefaultAsync(); + + if (opponentBond != null) + continue; + + Db.TryAttach(game); + game.LastLevel = state.Level; + game.InitiatorReward = 0; + game.InitiatorLoss = 0; + game.OpponentReward = 0; + game.OpponentLoss = 0; + + var initiator = await Cache.Accounts.GetAsync(game.InitiatorId); + Db.TryAttach(initiator); + initiator.ActiveRefutationGamesCount--; + + var opponent = await Cache.Accounts.GetAsync(game.OpponentId); + Db.TryAttach(opponent); + opponent.ActiveRefutationGamesCount--; + + var rollup = await Cache.Accounts.GetAsync(game.SmartRollupId); + Db.TryAttach(rollup); + rollup.ActiveRefutationGamesCount--; + } + } + + async Task RemoveBigmapKeys(AppState state) + { + var keyHashes = new HashSet + { + "exprtXBtxJxCDEDETueKAFLL7r7vZtNEo1MHajpHba1djtGKqJzWd3", + "exprtbuRhaGDS942BgZ1qFdD7HAKeBjPEqzRxgLQyWQ6HWxcaiLC2c", + "exprtePxSLgrhJmTPZEePyFBmESLhaBUN1WodvLYy9xYhEYE6dKPLe", + "exprtx9GaYz5Fy5ytiuYgSfJqeYqkxGgobust8U6dpCLaeZUMiitmg", + "expru28t4XoyB61WuRQnExk3Kq8ssGv1ejgdo9XHxpTXoQjXTGw1Dg", + "expru2fZALknjB4vJjmQBPkrs3dJZ5ytuzfmE9A7ScUk5opJiZQyiJ", + "expru2riAFKURjHJ1vNpvsZGGw6z4wtTvbstXVuwQPj1MaTqKPeQ6z", + "expruHoZDr8ioVhaAs495crYTprAYyC87CruEJ6HaS7diYV6qLARqQ", + "expruMie2gfy5smMd81NtcvvWm4jD7ThUebw9hpF3N3apKVtxkVG9M", + "expruc3QW7cdxrGurDJQa6k9QqMZjGkRDJahy2XNtBt9WQzC1yavJK", + "exprud86wYL7inFCVHkF1Jcz8uMXVY7dnbzxVupyyknZjtDVmwoQTJ", + "exprufYzeBTGn9733Ga8xEEmU4SsrSyDrzEip8V8hTBAG253T5zZQx", + "exprum9tuHNvisMa3c372AFmCa27rmkbCGrhzMSprrxgJjzXhrKAag", + "expruokt7oQ6dDHRvL4sURKUzfwJirR8FPHvpXwjgUD4KHhPWhDGbv", + "expruom5ds2hVgjdTB877Fx3ZuWT5WUnw1H6kUZavVHcJFbCkcgo3x", + "exprv2DPd1pV3GVSN2CgW7PPrAQUTuZAdeJphwToQrTNrxiJcWzvtX", + "exprv65Czv5TnKyEWgBHjDztkCkc1FAVEPxZ3V3ocgvGjfXwjPLo8M", + "exprv6S2KAvqAC18jDLYjaj1w9oc4ESdDGJkUZ63EpkqSTAz88cSYB", + "exprvNg3VDBnhtTHvc75krAEYzz6vUMr3iU5jtLdxs83FbgTbZ9nFT", + "exprvS7wNDHYKYZ19nj3ZUo7AAVMCDpTK3NNERFhqe5SJGCBL4pwFA" + }; + + var valueType = new MichelinePrim + { + Prim = PrimType.pair, + Args = new(2) + { + new MichelinePrim + { + Prim = PrimType.timestamp + }, + new MichelinePrim + { + Prim = PrimType.ticket, + Args = new(1) + { + new MichelinePrim + { + Prim = PrimType.@string, + Annots = new(1) + { + new FieldAnnotation("data") + } + } + } + } + } + }; + + var bigmap = await Db.BigMaps + .FirstOrDefaultAsync(x => x.Ptr == 5696); + + if (bigmap?.ValueType.IsEqual(valueType.ToBytes()) != true) + return; + + var block = await Cache.Blocks.CurrentAsync(); + + var contract = await Cache.Accounts.GetAsync(bigmap.ContractId); + Db.TryAttach(contract); + + var keys = await Db.BigMapKeys + .Where(x => x.BigMapPtr == bigmap.Ptr && x.Active && keyHashes.Contains(x.KeyHash)) + .ToListAsync(); + + foreach (var key in keys) + { + var value = Micheline.FromBytes(key.RawValue); + if (((((value as MichelinePrim).Args[1] as MichelinePrim).Args[1] as MichelinePrim).Args[1] as MichelineInt).Value == BigInteger.Zero) + { + var migration = new MigrationOperation + { + Id = Cache.AppState.NextOperationId(), + Block = block, + Account = contract, + AccountId = contract.Id, + BigMapUpdates = 1, + Kind = MigrationKind.RemoveBigMapKey, + Level = block.Level, + Timestamp = block.Timestamp + }; + Db.MigrationOps.Add(migration); + + block.Operations |= Operations.Migrations; + contract.MigrationsCount++; + state.MigrationOpsCount++; + + var update = new BigMapUpdate + { + Id = Cache.AppState.NextBigMapUpdateId(), + Action = BigMapAction.RemoveKey, + BigMapKeyId = key.Id, + BigMapPtr = bigmap.Ptr, + JsonValue = key.JsonValue, + Level = block.Level, + MigrationId = migration.Id, + RawValue = key.RawValue + }; + Db.BigMapUpdates.Add(update); + + key.Active = false; + key.LastLevel = block.Level; + key.Updates++; + + bigmap.ActiveKeys--; + bigmap.LastLevel = block.Level; + bigmap.Updates++; + } + } + } + + async Task MigrateBakers(AppState state) + { + var stakes = (await Proto.Node.GetAsync($"chains/main/blocks/{state.Level}/context/raw/json/staking_balance/current?depth=1")) + .EnumerateArray() + .ToDictionary( + x => x.EnumerateArray().First().RequiredString(), + x => x.EnumerateArray().Last().RequiredInt64("own_frozen")); + + foreach (var baker in Cache.Accounts.GetDelegates()) + { + Db.TryAttach(baker); + baker.StakedBalance = stakes.GetValueOrDefault(baker.Address); + baker.TotalStakedBalance = stakes.GetValueOrDefault(baker.Address); + } + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/AutostakingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/AutostakingCommit.cs new file mode 100644 index 000000000..e0311d5c9 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/AutostakingCommit.cs @@ -0,0 +1,227 @@ +using Microsoft.EntityFrameworkCore; +using System.Text.Json; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class AutostakingCommit : ProtocolCommit + { + public AutostakingCommit(ProtocolHandler protocol) : base(protocol) { } + + public virtual void Apply(Block block, JsonElement rawBlock) + { + if (!block.Events.HasFlag(BlockEvents.CycleEnd)) + return; + + var ops = new List(); + + #region parse updates + var balanceUpdates = rawBlock + .Required("metadata") + .RequiredArray("balance_updates") + .EnumerateArray() + .Where(x => x.RequiredString("origin") == "block") + .ToList(); + + for (int i = 0; i < balanceUpdates.Count; i++) + { + switch (balanceUpdates[i].RequiredString("kind")) + { + case "accumulator": + case "minted": + i++; + break; + case "contract": + if (i == balanceUpdates.Count - 1 || + balanceUpdates[i + 1].RequiredString("kind") != "freezer" || + balanceUpdates[i + 1].RequiredString("category") != "deposits" || + balanceUpdates[i].RequiredInt64("change") != -balanceUpdates[i + 1].RequiredInt64("change") || + balanceUpdates[i].RequiredString("contract") != balanceUpdates[i + 1].Required("staker").RequiredString("baker")) + throw new Exception("Unexpected contract->deposits balance update behavior"); + + ops.Add(new AutostakingOperation + { + Id = Cache.AppState.NextOperationId(), + Level = block.Level, + BakerId = Cache.Accounts.GetDelegate(balanceUpdates[i].RequiredString("contract")).Id, + Action = AutostakingAction.Stake, + Cycle = block.Cycle + 1, + Amount = balanceUpdates[i + 1].RequiredInt64("change") + }); + + i++; + break; + case "freezer" when balanceUpdates[i].RequiredString("category") == "deposits": + if (i == balanceUpdates.Count - 1 || + balanceUpdates[i + 1].RequiredString("kind") != "freezer" || + balanceUpdates[i + 1].RequiredString("category") != "unstaked_deposits" || + balanceUpdates[i].RequiredInt64("change") != -balanceUpdates[i + 1].RequiredInt64("change") || + balanceUpdates[i].Required("staker").RequiredString("baker") != balanceUpdates[i + 1].Required("staker").RequiredString("contract") || + balanceUpdates[i].Required("staker").RequiredString("baker") != balanceUpdates[i + 1].Required("staker").RequiredString("delegate")) + throw new Exception("Unexpected deposits->unstaked_deposits balance updates behavior"); + + ops.Add(new AutostakingOperation + { + Id = Cache.AppState.NextOperationId(), + Level = block.Level, + BakerId = Cache.Accounts.GetDelegate(balanceUpdates[i].Required("staker").RequiredString("baker")).Id, + Action = AutostakingAction.Unstake, + Cycle = balanceUpdates[i + 1].RequiredInt32("cycle"), + Amount = balanceUpdates[i + 1].RequiredInt64("change") + }); + + i++; + break; + case "freezer" when balanceUpdates[i].RequiredString("category") == "unstaked_deposits": + if (i < balanceUpdates.Count - 1 && + balanceUpdates[i + 1].RequiredString("kind") == "contract" && + balanceUpdates[i].RequiredInt64("change") == -balanceUpdates[i + 1].RequiredInt64("change") && + balanceUpdates[i].Required("staker").RequiredString("contract") == balanceUpdates[i + 1].RequiredString("contract") && + balanceUpdates[i].Required("staker").RequiredString("delegate") == balanceUpdates[i + 1].RequiredString("contract")) + { + ops.Add(new AutostakingOperation + { + Id = Cache.AppState.NextOperationId(), + Level = block.Level, + BakerId = Cache.Accounts.GetDelegate(balanceUpdates[i].Required("staker").RequiredString("delegate")).Id, + Action = AutostakingAction.Finalize, + Cycle = balanceUpdates[i].RequiredInt32("cycle"), + Amount = balanceUpdates[i + 1].RequiredInt64("change") + }); + } + else if (i < balanceUpdates.Count - 1 && + balanceUpdates[i + 1].RequiredString("kind") == "freezer" && + balanceUpdates[i + 1].RequiredString("category") == "deposits" && + balanceUpdates[i].RequiredInt64("change") == -balanceUpdates[i + 1].RequiredInt64("change") && + balanceUpdates[i].Required("staker").RequiredString("contract") == balanceUpdates[i + 1].Required("staker").RequiredString("baker") && + balanceUpdates[i].Required("staker").RequiredString("delegate") == balanceUpdates[i + 1].Required("staker").RequiredString("baker")) + { + ops.Add(new AutostakingOperation + { + Id = Cache.AppState.NextOperationId(), + Level = block.Level, + BakerId = Cache.Accounts.GetDelegate(balanceUpdates[i].Required("staker").RequiredString("delegate")).Id, + Action = AutostakingAction.Restake, + Cycle = balanceUpdates[i].RequiredInt32("cycle"), + Amount = balanceUpdates[i + 1].RequiredInt64("change") + }); + } + else + { + throw new Exception("Unexpected unstaked_deposits->* balance updates behavior"); + } + i++; + break; + default: + throw new Exception("Unexpected block balance update kind"); + + } + } + #endregion + + Db.TryAttach(block); + + var state = Cache.AppState.Get(); + Db.TryAttach(state); + + var stats = Cache.Statistics.Current; + Db.TryAttach(stats); + + foreach (var op in ops) + { + var baker = Cache.Accounts.GetDelegate(op.BakerId); + Db.TryAttach(baker); + baker.AutostakingOpsCount++; + + switch (op.Action) + { + case AutostakingAction.Stake: + baker.StakedBalance += op.Amount; + baker.TotalStakedBalance += op.Amount; + stats.TotalFrozen += op.Amount; + break; + case AutostakingAction.Unstake: + baker.UnstakedBalance += op.Amount; + if (baker.UnstakedBalance > 0) + { + if (baker.UnstakedBakerId == null) + baker.UnstakedBakerId = baker.Id; + else if (baker.UnstakedBakerId != baker.Id) + throw new Exception("Multiple unstaked bakers are not expected"); + } + baker.StakedBalance -= op.Amount; + baker.TotalStakedBalance -= op.Amount; + stats.TotalFrozen -= op.Amount; + break; + case AutostakingAction.Finalize: + baker.UnstakedBalance -= op.Amount; + if (baker.UnstakedBalance == 0) + baker.UnstakedBakerId = null; + break; + case AutostakingAction.Restake: + baker.UnstakedBalance -= op.Amount; + if (baker.UnstakedBalance == 0) + baker.UnstakedBakerId = null; + baker.StakedBalance += op.Amount; + baker.TotalStakedBalance += op.Amount; + stats.TotalFrozen += op.Amount; + break; + default: + throw new InvalidOperationException($"Invalid AutostakingAction: {op.Action}"); + } + + block.Operations |= Operations.Autostaking; + state.AutostakingOpsCount++; + + Db.AutostakingOps.Add(op); + } + } + + public virtual async Task Revert(Block block) + { + if (!block.Operations.HasFlag(Operations.Autostaking)) + return; + + foreach (var op in await Db.AutostakingOps.Where(x => x.Level == block.Level).ToListAsync()) + { + var baker = Cache.Accounts.GetDelegate(op.BakerId); + Db.TryAttach(baker); + baker.AutostakingOpsCount++; + + switch (op.Action) + { + case AutostakingAction.Stake: + baker.StakedBalance -= op.Amount; + baker.TotalStakedBalance -= op.Amount; + break; + case AutostakingAction.Unstake: + baker.UnstakedBalance -= op.Amount; + if (baker.UnstakedBalance == 0) + baker.UnstakedBakerId = null; + baker.StakedBalance += op.Amount; + baker.TotalStakedBalance += op.Amount; + break; + case AutostakingAction.Finalize: + baker.UnstakedBalance += op.Amount; + if (baker.UnstakedBalance == op.Amount) + baker.UnstakedBakerId = baker.Id; + break; + case AutostakingAction.Restake: + baker.UnstakedBalance += op.Amount; + if (baker.UnstakedBalance == op.Amount) + baker.UnstakedBakerId = baker.Id; + baker.StakedBalance -= op.Amount; + baker.TotalStakedBalance -= op.Amount; + break; + default: + throw new InvalidOperationException($"Invalid AutostakingAction: {op.Action}"); + } + + Cache.AppState.Get().AutostakingOpsCount--; + + Db.AutostakingOps.Remove(op); + Cache.AppState.ReleaseOperationId(); + } + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BakerCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BakerCycleCommit.cs new file mode 100644 index 000000000..537ad715d --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BakerCycleCommit.cs @@ -0,0 +1,334 @@ +using System.Numerics; +using Microsoft.EntityFrameworkCore; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class BakerCycleCommit : ProtocolCommit + { + public BakerCycleCommit(ProtocolHandler protocol) : base(protocol) { } + + public virtual async Task Apply( + Block block, + Cycle futureCycle, + IEnumerable futureBakingRights, + IEnumerable futureEndorsingRights, + List snapshots, + Dictionary selectedStakes, + List currentRights) + { + #region current rights + if (block.BlockRound == 0) + { + var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, (int)block.ProposerId); + Db.TryAttach(bakerCycle); + + bakerCycle.FutureBlockRewards -= bakerCycle.FutureBlockRewards / bakerCycle.FutureBlocks; + bakerCycle.FutureBlocks--; + bakerCycle.Blocks++; + bakerCycle.BlockRewardsLiquid += block.RewardLiquid + block.BonusLiquid; + bakerCycle.BlockRewardsStakedOwn += block.RewardStakedOwn + block.BonusStakedOwn; + bakerCycle.BlockRewardsStakedShared += block.RewardStakedShared + block.BonusStakedShared; + bakerCycle.BlockFees += block.Fees; + } + else + { + var set = new HashSet(); + foreach (var br in currentRights.Where(x => x.Type == BakingRightType.Baking).OrderBy(x => x.Round)) + { + if (set.Add(br.BakerId)) + { + var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, br.BakerId); + Db.TryAttach(bakerCycle); + + if (br.Round == 0) + { + bakerCycle.FutureBlockRewards -= bakerCycle.FutureBlockRewards / bakerCycle.FutureBlocks; + bakerCycle.FutureBlocks--; + } + + if (br.BakerId == block.ProposerId || br.BakerId == block.ProducerId) + { + bakerCycle.Blocks++; + } + else + { + bakerCycle.MissedBlocks++; + } + + if (br.BakerId == block.ProposerId) + { + bakerCycle.BlockRewardsLiquid += block.RewardLiquid; + bakerCycle.BlockRewardsStakedOwn += block.RewardStakedOwn; + bakerCycle.BlockRewardsStakedShared += block.RewardStakedShared; + bakerCycle.BlockFees += block.Fees; + } + else if (br.Round < block.PayloadRound) + { + bakerCycle.MissedBlockRewards += block.RewardLiquid + block.RewardStakedOwn + block.RewardStakedShared; + bakerCycle.MissedBlockFees += block.Fees; + } + + if (br.BakerId == block.ProducerId) + { + bakerCycle.BlockRewardsLiquid += block.BonusLiquid; + bakerCycle.BlockRewardsStakedOwn += block.BonusStakedOwn; + bakerCycle.BlockRewardsStakedShared += block.BonusStakedShared; + } + else + { + bakerCycle.MissedBlockRewards += block.BonusLiquid + block.BonusStakedOwn + block.BonusStakedShared; + } + } + } + } + + foreach (var er in currentRights.Where(x => x.Type == BakingRightType.Endorsing)) + { + var bakerCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, er.BakerId); + if (bakerCycle == null) continue; + + Db.TryAttach(bakerCycle); + bakerCycle.FutureEndorsements -= (int)er.Slots; + if (er.Status == BakingRightStatus.Realized) + bakerCycle.Endorsements += (int)er.Slots; + else if (er.Status == BakingRightStatus.Missed) + bakerCycle.MissedEndorsements += (int)er.Slots; + else + throw new Exception("Unexpected future rights"); + } + + if (block.Revelations != null) + { + foreach (var op in block.Revelations) + { + var bakerCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, op.Baker.Id); + if (bakerCycle != null) + { + Db.TryAttach(bakerCycle); + bakerCycle.NonceRevelationRewardsLiquid += op.RewardLiquid; + bakerCycle.NonceRevelationRewardsStakedOwn += op.RewardStakedOwn; + bakerCycle.NonceRevelationRewardsStakedShared += op.RewardStakedShared; + } + } + } + + if (block.VdfRevelationOps != null) + { + foreach (var op in block.VdfRevelationOps) + { + var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Baker.Id); + Db.TryAttach(bakerCycle); + + bakerCycle.VdfRevelationRewardsLiquid += op.RewardLiquid; + bakerCycle.VdfRevelationRewardsStakedOwn += op.RewardStakedOwn; + bakerCycle.VdfRevelationRewardsStakedShared += op.RewardStakedShared; + } + } + #endregion + + #region new cycle + if (block.Events.HasFlag(BlockEvents.CycleBegin)) + { + var bakerCycles = snapshots.ToDictionary(x => x.AccountId, snapshot => + { + var bakerCycle = new BakerCycle + { + Cycle = futureCycle.Index, + BakerId = snapshot.AccountId, + OwnDelegatedBalance = snapshot.OwnDelegatedBalance, + ExternalDelegatedBalance = snapshot.ExternalDelegatedBalance, + DelegatorsCount = snapshot.DelegatorsCount, + OwnStakedBalance = snapshot.OwnStakedBalance, + ExternalStakedBalance = snapshot.ExternalStakedBalance, + StakersCount = snapshot.StakersCount, + BakingPower = 0, + TotalBakingPower = futureCycle.TotalBakingPower + }; + if (selectedStakes.TryGetValue(bakerCycle.BakerId, out var bakingPower)) + { + var expectedEndorsements = (int)(new BigInteger(block.Protocol.BlocksPerCycle) * block.Protocol.EndorsersPerBlock * bakingPower / futureCycle.TotalBakingPower); + bakerCycle.BakingPower = bakingPower; + bakerCycle.ExpectedBlocks = block.Protocol.BlocksPerCycle * bakingPower / futureCycle.TotalBakingPower; + bakerCycle.ExpectedEndorsements = expectedEndorsements; + bakerCycle.FutureEndorsementRewards = expectedEndorsements * futureCycle.EndorsementRewardPerSlot; + } + return bakerCycle; + }); + + #region future baking rights + foreach (var br in futureBakingRights.Where(x => x.Round == 0)) + { + if (!bakerCycles.TryGetValue(br.Baker, out var bakerCycle)) + throw new Exception("Nonexistent baker cycle"); + + bakerCycle.FutureBlocks++; + bakerCycle.FutureBlockRewards += futureCycle.MaxBlockReward; + } + #endregion + + #region future endorsing rights + var skipLevel = futureEndorsingRights.Last().Level; + foreach (var er in futureEndorsingRights.TakeWhile(x => x.Level < skipLevel)) + { + if (!bakerCycles.TryGetValue(er.Baker, out var bakerCycle)) + throw new Exception("Nonexistent baker cycle"); + + bakerCycle.FutureEndorsements += er.Slots; + } + #endregion + + #region shifted future endorsing rights + var shifted = await Db.BakingRights.AsNoTracking() + .Where(x => x.Level == futureCycle.FirstLevel && x.Type == BakingRightType.Endorsing) + .ToListAsync(); + + foreach (var er in shifted) + { + if (bakerCycles.TryGetValue(er.BakerId, out var bakerCycle)) + { + bakerCycle.FutureEndorsements += (int)er.Slots; + } + } + #endregion + + Db.BakerCycles.AddRange(bakerCycles.Values); + } + #endregion + } + + public virtual async Task Revert(Block block) + { + block.Protocol ??= await Cache.Protocols.GetAsync(block.ProtoCode); + + #region current rights + var currentRights = await Cache.BakingRights.GetAsync(block.Cycle, block.Level); + var currentCycle = await Db.Cycles.SingleAsync(x => x.Index == block.Cycle); + + if (block.BlockRound == 0) + { + var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, (int)block.ProposerId); + Db.TryAttach(bakerCycle); + + bakerCycle.FutureBlockRewards += currentCycle.MaxBlockReward; + bakerCycle.FutureBlocks++; + bakerCycle.Blocks--; + bakerCycle.BlockRewardsLiquid -= block.RewardLiquid + block.BonusLiquid; + bakerCycle.BlockRewardsStakedOwn -= block.RewardStakedOwn + block.BonusStakedOwn; + bakerCycle.BlockRewardsStakedShared -= block.RewardStakedShared + block.BonusStakedShared; + bakerCycle.BlockFees -= block.Fees; + } + else + { + var set = new HashSet(); + var bakerRound = currentRights + .Where(x => x.Type == BakingRightType.Baking) + .OrderBy(x => x.Round) + .First(x => x.Status == BakingRightStatus.Realized) + .Round; + + foreach (var br in currentRights.Where(x => x.Type == BakingRightType.Baking).OrderBy(x => x.Round)) + { + if (set.Add(br.BakerId)) + { + var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, br.BakerId); + Db.TryAttach(bakerCycle); + + if (br.Round == 0) + { + bakerCycle.FutureBlockRewards += currentCycle.MaxBlockReward; + bakerCycle.FutureBlocks++; + } + + if (br.BakerId == block.ProposerId || br.BakerId == block.ProducerId) + { + bakerCycle.Blocks--; + } + else + { + bakerCycle.MissedBlocks--; + } + + if (br.BakerId == block.ProposerId) + { + bakerCycle.BlockRewardsLiquid -= block.RewardLiquid; + bakerCycle.BlockRewardsStakedOwn -= block.RewardStakedOwn; + bakerCycle.BlockRewardsStakedShared -= block.RewardStakedShared; + bakerCycle.BlockFees -= block.Fees; + } + else if (br.Round < bakerRound) + { + bakerCycle.MissedBlockRewards -= block.RewardLiquid + block.RewardStakedOwn + block.RewardStakedShared; + bakerCycle.MissedBlockFees -= block.Fees; + } + + if (br.BakerId == block.ProducerId) + { + bakerCycle.BlockRewardsLiquid -= block.BonusLiquid; + bakerCycle.BlockRewardsStakedOwn -= block.BonusStakedOwn; + bakerCycle.BlockRewardsStakedShared -= block.BonusStakedShared; + } + else + { + bakerCycle.MissedBlockRewards -= block.BonusLiquid + block.BonusStakedOwn + block.BonusStakedShared; + } + } + } + } + + foreach (var er in currentRights.Where(x => x.Type == BakingRightType.Endorsing)) + { + var bakerCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, er.BakerId); + if (bakerCycle == null) continue; + + Db.TryAttach(bakerCycle); + bakerCycle.FutureEndorsements += (int)er.Slots; + if (er.Status == BakingRightStatus.Realized) + bakerCycle.Endorsements -= (int)er.Slots; + else if (er.Status == BakingRightStatus.Missed) + bakerCycle.MissedEndorsements -= (int)er.Slots; + else + throw new Exception("Unexpected future rights"); + } + + if (block.Revelations != null) + { + foreach (var op in block.Revelations) + { + var bakerCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, op.BakerId); + if (bakerCycle != null) + { + Db.TryAttach(bakerCycle); + bakerCycle.NonceRevelationRewardsLiquid -= op.RewardLiquid; + bakerCycle.NonceRevelationRewardsStakedOwn -= op.RewardStakedOwn; + bakerCycle.NonceRevelationRewardsStakedShared -= op.RewardStakedShared; + } + } + } + + if (block.VdfRevelationOps != null) + { + foreach (var op in block.VdfRevelationOps) + { + var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.BakerId); + Db.TryAttach(bakerCycle); + + bakerCycle.VdfRevelationRewardsLiquid -= op.RewardLiquid; + bakerCycle.VdfRevelationRewardsStakedOwn -= op.RewardStakedOwn; + bakerCycle.VdfRevelationRewardsStakedShared -= op.RewardStakedShared; + } + } + #endregion + + #region new cycle + if (block.Events.HasFlag(BlockEvents.CycleBegin)) + { + await Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "BakerCycles" + WHERE "Cycle" = {block.Cycle + block.Protocol.PreservedCycles} + """); + } + #endregion + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BakingRightsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BakingRightsCommit.cs new file mode 100644 index 000000000..1a2a89c6b --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BakingRightsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class BakingRightsCommit : Proto16.BakingRightsCommit + { + public BakingRightsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BigMapCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BigMapCommit.cs new file mode 100644 index 000000000..612987e54 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BigMapCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class BigMapCommit : Proto1.BigMapCommit + { + public BigMapCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BlockCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BlockCommit.cs new file mode 100644 index 000000000..67b184bc7 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/BlockCommit.cs @@ -0,0 +1,287 @@ +using System.Numerics; +using System.Text.Json; +using Netezos.Encoding; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class BlockCommit : ProtocolCommit + { + public Block Block { get; private set; } + + public BlockCommit(ProtocolHandler protocol) : base(protocol) { } + + public virtual async Task Apply(JsonElement rawBlock) + { + var header = rawBlock.Required("header"); + var metadata = rawBlock.Required("metadata"); + + var level = header.RequiredInt32("level"); + var proposer = Cache.Accounts.GetDelegate(metadata.RequiredString("proposer")); + var producer = Cache.Accounts.GetDelegate(metadata.RequiredString("baker")); + var protocol = await Cache.Protocols.GetAsync(rawBlock.RequiredString("protocol")); + var events = BlockEvents.None; + + if (protocol.IsCycleStart(level)) + events |= BlockEvents.CycleBegin; + else if (protocol.IsCycleEnd(level)) + events |= BlockEvents.CycleEnd; + + if (protocol.FirstLevel == level) + events |= BlockEvents.ProtocolBegin; + else if (protocol.Hash != metadata.RequiredString("next_protocol")) + events |= BlockEvents.ProtocolEnd; + + if (metadata.RequiredArray("deactivated").Count() > 0) + events |= BlockEvents.Deactivations; + + if (level % protocol.BlocksPerSnapshot == 0) + events |= BlockEvents.BalanceSnapshot; + + var payloadRound = header.RequiredInt32("payload_round"); + var blockRound = Hex.Parse(header.RequiredArray("fitness", 5)[4].RequiredString()).ToInt32(); + var lbVote = header.RequiredString("liquidity_baking_toggle_vote"); + var aiVote = header.RequiredString("adaptive_issuance_vote"); + + Block = new Block + { + Id = Cache.AppState.NextOperationId(), + Hash = rawBlock.RequiredString("hash"), + Cycle = protocol.GetCycle(level), + Level = level, + ProtoCode = protocol.Code, + Protocol = protocol, + Timestamp = header.RequiredDateTime("timestamp"), + PayloadRound = payloadRound, + BlockRound = blockRound, + Proposer = proposer, + ProposerId = proposer.Id, + ProducerId = producer.Id, + Events = events, + LBToggle = lbVote == "on" ? true : lbVote == "off" ? false : null, + LBToggleEma = metadata.RequiredInt32("liquidity_baking_toggle_ema"), + AIToggle = aiVote == "on" ? true : aiVote == "off" ? false : null, + AIToggleEma = metadata.RequiredInt32("adaptive_issuance_vote_ema") + }; + + Db.TryAttach(protocol); // if we don't attach it, ef will recognize it as 'added' + if (Block.Events.HasFlag(BlockEvents.ProtocolEnd)) + protocol.LastLevel = Block.Level; + + var state = Cache.AppState.Get(); + if (!state.AIActivated && metadata.OptionalInt32("adaptive_issuance_activation_cycle") is int aiActivationCycle) + { + state.AIActivated = true; + state.AIActivationCycle = aiActivationCycle; + state.AIFinalUpvoteLevel = Block.Level; + } + + Db.TryAttach(proposer); // if we don't attach it, ef will recognize it as 'added' + Db.TryAttach(producer); // if we don't attach it, ef will recognize it as 'added' + + Db.Blocks.Add(Block); + Cache.Blocks.Add(Block); + } + + public async Task ApplyRewards(JsonElement rawBlock) + { + var proposer = Cache.Accounts.GetDelegate(Block.ProposerId); + var producer = Cache.Accounts.GetDelegate(Block.ProducerId); + + var balanceUpdates = rawBlock + .Required("metadata") + .RequiredArray("balance_updates") + .EnumerateArray() + .Where(x => x.RequiredString("origin") == "block") + .ToList(); + + #region parse rewards + var rewardLiquid = 0L; + var rewardStakedOwn = 0L; + var rewardStakedShared = 0L; + var bonusLiquid = 0L; + var bonusStakedOwn = 0L; + var bonusStakedShared = 0L; + + for (int i = 0; i < balanceUpdates.Count; i++) + { + var update = balanceUpdates[i]; + if (update.RequiredString("kind") == "minted" && update.RequiredString("category") == "baking rewards") + { + if (i == balanceUpdates.Count - 1) + throw new Exception("Unexpected baking rewards balance updates behavior"); + + var change = -update.RequiredInt64("change"); + + var nextUpdate = balanceUpdates[i + 1]; + if (nextUpdate.RequiredString("kind") == "freezer" && + nextUpdate.RequiredString("category") == "deposits" && + nextUpdate.Required("staker").RequiredString("baker") == proposer.Address && + nextUpdate.RequiredInt64("change") == change) + { + var changeOwn = proposer.TotalStakedBalance == 0 ? change : (long)((BigInteger)change * proposer.StakedBalance / proposer.TotalStakedBalance); + var changeShared = change - changeOwn; + rewardStakedOwn += changeOwn; + rewardStakedShared += changeShared; + } + else if (nextUpdate.RequiredString("kind") == "contract" && + nextUpdate.RequiredString("contract") == proposer.Address && + nextUpdate.RequiredInt64("change") == change) + { + rewardLiquid += change; + } + else + { + throw new Exception("Unexpected baking rewards balance updates behavior"); + } + } + else if (update.RequiredString("kind") == "minted" && update.RequiredString("category") == "baking bonuses") + { + if (i == balanceUpdates.Count - 1) + throw new Exception("Unexpected baking bonuses balance updates behavior"); + + var change = -update.RequiredInt64("change"); + + var nextUpdate = balanceUpdates[i + 1]; + if (nextUpdate.RequiredString("kind") == "freezer" && + nextUpdate.RequiredString("category") == "deposits" && + nextUpdate.Required("staker").RequiredString("baker") == producer.Address && + nextUpdate.RequiredInt64("change") == change) + { + var changeOwn = producer.TotalStakedBalance == 0 ? change : (long)((BigInteger)change * producer.StakedBalance / producer.TotalStakedBalance); + var changeShared = change - changeOwn; + bonusStakedOwn += changeOwn; + bonusStakedShared += changeShared; + } + else if (nextUpdate.RequiredString("kind") == "contract" && + nextUpdate.RequiredString("contract") == producer.Address && + nextUpdate.RequiredInt64("change") == change) + { + bonusLiquid += change; + } + else + { + throw new Exception("Unexpected baking bonuses balance updates behavior"); + } + } + } + #endregion + + Block.RewardLiquid = rewardLiquid; + Block.RewardStakedOwn = rewardStakedOwn; + Block.RewardStakedShared = rewardStakedShared; + Block.BonusLiquid = bonusLiquid; + Block.BonusStakedOwn = bonusStakedOwn; + Block.BonusStakedShared = bonusStakedShared; + + Db.TryAttach(proposer); + proposer.Balance += Block.RewardLiquid + Block.RewardStakedOwn; + proposer.StakingBalance += Block.RewardLiquid + Block.RewardStakedOwn + Block.RewardStakedShared; + proposer.StakedBalance += Block.RewardStakedOwn; + proposer.ExternalStakedBalance += Block.RewardStakedShared; + proposer.TotalStakedBalance += Block.RewardStakedOwn + Block.RewardStakedShared; + proposer.BlocksCount++; + + #region set baker active + var newDeactivationLevel = proposer.Staked ? GracePeriod.Reset(Block) : GracePeriod.Init(Block); + if (proposer.DeactivationLevel < newDeactivationLevel) + { + if (proposer.DeactivationLevel <= Block.Level) + await UpdateDelegate(proposer, true); + + Block.ResetBakerDeactivation = proposer.DeactivationLevel; + proposer.DeactivationLevel = newDeactivationLevel; + } + #endregion + + Db.TryAttach(producer); + producer.Balance += Block.BonusLiquid + Block.BonusStakedOwn; + producer.StakingBalance += Block.BonusLiquid + Block.BonusStakedOwn + Block.BonusStakedShared; + producer.StakedBalance += Block.BonusStakedOwn; + producer.ExternalStakedBalance += Block.BonusStakedShared; + producer.TotalStakedBalance += Block.BonusStakedOwn + Block.BonusStakedShared; + if (producer != proposer) + { + producer.BlocksCount++; + + #region set proposer active + newDeactivationLevel = producer.Staked ? GracePeriod.Reset(Block) : GracePeriod.Init(Block); + if (producer.DeactivationLevel < newDeactivationLevel) + { + if (producer.DeactivationLevel <= Block.Level) + await UpdateDelegate(producer, true); + + Block.ResetProposerDeactivation = producer.DeactivationLevel; + producer.DeactivationLevel = newDeactivationLevel; + } + #endregion + } + + Cache.Statistics.Current.TotalCreated += + Block.RewardLiquid + Block.RewardStakedOwn + Block.RewardStakedShared + + Block.BonusLiquid + Block.BonusStakedOwn + Block.BonusStakedShared; + + Cache.Statistics.Current.TotalFrozen += + Block.RewardStakedOwn + Block.RewardStakedShared + + Block.BonusStakedOwn + Block.BonusStakedShared; + } + + public virtual void Revert(Block block) + { + var state = Cache.AppState.Get(); + if (state.AIFinalUpvoteLevel == block.Level) + { + state.AIActivated = false; + state.AIActivationCycle = 0; + state.AIFinalUpvoteLevel = 0; + } + + Db.Blocks.Remove(block); + Cache.AppState.ReleaseOperationId(); + } + + public async Task RevertRewards(Block block) + { + var proposer = Cache.Accounts.GetDelegate(block.ProposerId); + Db.TryAttach(proposer); + proposer.Balance -= block.RewardLiquid + block.RewardStakedOwn; + proposer.StakingBalance -= block.RewardLiquid + block.RewardStakedOwn + block.RewardStakedShared; + proposer.StakedBalance -= block.RewardStakedOwn; + proposer.ExternalStakedBalance -= block.RewardStakedShared; + proposer.TotalStakedBalance -= block.RewardStakedOwn + block.RewardStakedShared; + proposer.BlocksCount--; + + #region reset baker activity + if (block.ResetBakerDeactivation != null) + { + if (block.ResetBakerDeactivation <= block.Level) + await UpdateDelegate(proposer, false); + + proposer.DeactivationLevel = (int)block.ResetBakerDeactivation; + } + #endregion + + var producer = Cache.Accounts.GetDelegate(block.ProducerId); + Db.TryAttach(producer); + producer.Balance -= block.BonusLiquid + block.BonusStakedOwn; + producer.StakingBalance -= block.BonusLiquid + block.BonusStakedOwn + block.BonusStakedShared; + producer.StakedBalance -= block.BonusStakedOwn; + producer.ExternalStakedBalance -= block.BonusStakedShared; + producer.TotalStakedBalance -= block.BonusStakedOwn + block.BonusStakedShared; + if (producer != proposer) + { + producer.BlocksCount--; + + #region reset proposer activity + if (block.ResetProposerDeactivation != null) + { + if (block.ResetProposerDeactivation <= block.Level) + await UpdateDelegate(producer, false); + + producer.DeactivationLevel = (int)block.ResetProposerDeactivation; + } + #endregion + } + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/ContractEventCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/ContractEventCommit.cs new file mode 100644 index 000000000..5025adb69 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/ContractEventCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class ContractEventCommit : Proto14.ContractEventCommit + { + public ContractEventCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/CycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/CycleCommit.cs new file mode 100644 index 000000000..1cb7bc46c --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/CycleCommit.cs @@ -0,0 +1,88 @@ +using System.Numerics; +using Microsoft.EntityFrameworkCore; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class CycleCommit : Proto14.CycleCommit + { + public CycleCommit(ProtocolHandler protocol) : base(protocol) { } + + public override async Task Apply(Block block) + { + if (!block.Events.HasFlag(BlockEvents.CycleBegin)) + return; + + await base.Apply(block); + + var res = await Proto.Rpc.GetExpectedIssuance(block.Level); + var issuance = res.EnumerateArray().First(x => x.RequiredInt32("cycle") == FutureCycle.Index); + + FutureCycle.BlockReward = issuance.RequiredInt64("baking_reward_fixed_portion"); + FutureCycle.BlockBonusPerSlot = issuance.RequiredInt64("baking_reward_bonus_per_slot"); + FutureCycle.MaxBlockReward = FutureCycle.BlockReward + FutureCycle.BlockBonusPerSlot * (block.Protocol.EndorsersPerBlock - block.Protocol.ConsensusThreshold); + FutureCycle.EndorsementRewardPerSlot = issuance.RequiredInt64("attesting_reward_per_slot"); + FutureCycle.NonceRevelationReward = issuance.RequiredInt64("seed_nonce_revelation_tip"); + FutureCycle.VdfRevelationReward = issuance.RequiredInt64("vdf_revelation_tip"); + FutureCycle.LBSubsidy = issuance.RequiredInt64("liquidity_baking_subsidy"); + } + + protected override async Task> GetSelectedStakes(Block block) + { + if (block.Cycle == block.Protocol.FirstCycle) + return await base.GetSelectedStakes(block); + + //if (block.Cycle <= Cache.AppState.Get().AIActivationCycle) + // return Task.FromResult(Snapshots + // .Where(x => x.StakingBalance >= block.Protocol.MinimalStake) + // .ToDictionary(x => x.AccountId, x => Math.Min(x.StakingBalance, x.TotalStakedBalance * (block.Protocol.MaxDelegatedOverFrozenRatio + 1)))); + + var slashings = new Dictionary(); + var prevBlock = Cache.Blocks.Get(block.Level - 1); + if (prevBlock.Events.HasFlag(BlockEvents.DoubleBakingSlashing)) + { + var prevBlockProto = await Cache.Protocols.GetAsync(prevBlock.ProtoCode); + foreach (var op in await Db.DoubleBakingOps.AsNoTracking().Where(x => x.SlashedLevel == block.Level - 1).ToListAsync()) + slashings[op.OffenderId] = slashings.GetValueOrDefault(op.OffenderId) + prevBlockProto.DoubleBakingSlashedPercentage; + } + if (prevBlock.Events.HasFlag(BlockEvents.DoubleEndorsingSlashing)) + { + var prevBlockProto = await Cache.Protocols.GetAsync(prevBlock.ProtoCode); + foreach (var op in await Db.DoubleEndorsingOps.AsNoTracking().Where(x => x.SlashedLevel == block.Level - 1).ToListAsync()) + slashings[op.OffenderId] = slashings.GetValueOrDefault(op.OffenderId) + prevBlockProto.DoubleEndorsingSlashedPercentage; + } + if (prevBlock.Events.HasFlag(BlockEvents.DoublePreendorsingSlashing)) + { + var prevBlockProto = await Cache.Protocols.GetAsync(prevBlock.ProtoCode); + foreach (var op in await Db.DoublePreendorsingOps.AsNoTracking().Where(x => x.SlashedLevel == block.Level - 1).ToListAsync()) + slashings[op.OffenderId] = slashings.GetValueOrDefault(op.OffenderId) + prevBlockProto.DoubleEndorsingSlashedPercentage; + } + + return Snapshots.Select(x => + { + var ownStaked = x.OwnStakedBalance; + var externalStaked = x.ExternalStakedBalance; + if (slashings.TryGetValue(x.AccountId, out var percentage)) + { + ownStaked = ownStaked * Math.Max(0, 100 - percentage) / 100; + externalStaked = externalStaked * Math.Max(0, 100 - percentage) / 100; + } + var totalStaked = ownStaked + externalStaked; + + var stakingOverBaking = Math.Min( + block.Protocol.MaxExternalOverOwnStakeRatio * 1_000_000, + Cache.Accounts.GetDelegate(x.AccountId).LimitOfStakingOverBaking ?? long.MaxValue); + + var frozen = Math.Min(totalStaked, ownStaked + (long)((BigInteger)ownStaked * stakingOverBaking / 1_000_000)); + var delegated = Math.Min(x.StakingBalance - frozen, ownStaked * block.Protocol.MaxDelegatedOverFrozenRatio); + + return (x.AccountId, frozen, delegated); + }) + .Where(x => x.frozen >= block.Protocol.MinimalFrozenStake && x.frozen + x.delegated >= block.Protocol.MinimalStake) + .ToDictionary(x => x.AccountId, x => + { + return x.frozen + x.delegated; + }); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/DeactivationCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/DeactivationCommit.cs new file mode 100644 index 000000000..4fe280b25 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/DeactivationCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class DeactivationCommit : Proto2.DeactivationCommit + { + public DeactivationCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/DelegatorCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/DelegatorCycleCommit.cs new file mode 100644 index 000000000..fe343b302 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/DelegatorCycleCommit.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class DelegatorCycleCommit : Proto3.DelegatorCycleCommit + { + public DelegatorCycleCommit(ProtocolHandler protocol) : base(protocol) { } + + protected override Task CreateFromSnapshots(Cycle futureCycle) + { + return Db.Database.ExecuteSqlRawAsync($""" + INSERT INTO "DelegatorCycles" ( + "Cycle", + "DelegatorId", + "BakerId", + "DelegatedBalance", + "StakedBalance" + ) + SELECT + {futureCycle.Index}, + snapshot."AccountId", + snapshot."BakerId", + snapshot."OwnDelegatedBalance", + (baker."ExternalStakedBalance"::numeric * snapshot."StakedPseudotokens" / GREATEST(baker."IssuedPseudotokens", 1))::bigint + FROM "SnapshotBalances" as snapshot + INNER JOIN "SnapshotBalances" as baker + ON baker."AccountId" = snapshot."BakerId" AND baker."BakerId" = snapshot."BakerId" and baker."Level" = snapshot."Level" + WHERE snapshot."Level" = {futureCycle.SnapshotLevel} + AND snapshot."AccountId" != snapshot."BakerId" + """); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/EndorsingRewardCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/EndorsingRewardCommit.cs new file mode 100644 index 000000000..239860ee5 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/EndorsingRewardCommit.cs @@ -0,0 +1,169 @@ +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class EndorsingRewardCommit : ProtocolCommit + { + public EndorsingRewardCommit(ProtocolHandler protocol) : base(protocol) { } + + public virtual async Task Apply(Block block, JsonElement rawBlock) + { + if (!block.Events.HasFlag(BlockEvents.CycleEnd)) + return; + + var state = Cache.AppState.Get(); + var bakerCycles = await Cache.BakerCycles.GetAsync(block.Cycle); + var ops = bakerCycles.Where(x => x.Value.FutureEndorsementRewards > 0).ToDictionary(x => x.Key, bakerCycle => new EndorsingRewardOperation + { + Id = Cache.AppState.NextOperationId(), + BakerId = bakerCycle.Key, + Level = block.Level, + Timestamp = block.Timestamp, + Expected = bakerCycle.Value.FutureEndorsementRewards + }); + + var balanceUpdates = rawBlock.Required("metadata").RequiredArray("balance_updates").EnumerateArray().Where(x => x.RequiredString("origin") == "block").ToList(); + for (int i = 0; i < balanceUpdates.Count; i++) + { + var update = balanceUpdates[i]; + if (update.RequiredString("kind") == "minted" && update.RequiredString("category") == "endorsing rewards") + { + if (i == balanceUpdates.Count - 1) + throw new Exception("Unexpected endorsing rewards balance updates behavior"); + + var change = -update.RequiredInt64("change"); + + var nextUpdate = balanceUpdates[i + 1]; + if (nextUpdate.RequiredString("kind") == "freezer" && + nextUpdate.RequiredString("category") == "deposits" && + nextUpdate.RequiredInt64("change") == change) + { + var baker = Cache.Accounts.GetDelegate(nextUpdate.Required("staker").RequiredString("baker")); + if (!ops.TryGetValue(baker.Id, out var op)) + throw new Exception("Unexpected endorsing rewards balance update"); + + var changeOwn = baker.TotalStakedBalance == 0 ? change : (long)((BigInteger)change * baker.StakedBalance / baker.TotalStakedBalance); + var changeShared = change - changeOwn; + op.RewardStakedOwn = changeOwn; + op.RewardStakedShared = changeShared; + } + else if (nextUpdate.RequiredString("kind") == "contract" && + nextUpdate.RequiredInt64("change") == change) + { + var baker = Cache.Accounts.GetDelegate(nextUpdate.RequiredString("contract")); + if (!ops.TryGetValue(baker.Id, out var op)) + throw new Exception("Unexpected endorsing rewards balance update"); + + op.RewardLiquid = change; + } + else if (nextUpdate.RequiredString("kind") == "burned" && + nextUpdate.RequiredString("category") == "lost endorsing rewards" && + nextUpdate.RequiredInt64("change") == change) + { + var baker = Cache.Accounts.GetDelegate(nextUpdate.RequiredString("delegate")); + if (!ops.TryGetValue(baker.Id, out var op)) + throw new Exception("Unexpected endorsing rewards balance update"); + + // Endorsing rewards are wrong for the first preserved+1 cycles after AI activation + if (state.AIActivated && block.Cycle >= state.AIActivationCycle && block.Cycle <= state.AIActivationCycle + block.Protocol.PreservedCycles) + op.Expected = change; + + if (op.Expected != change) + throw new Exception("FutureEndorsementRewards != loss"); + + op.RewardLiquid = 0; + op.RewardStakedOwn = 0; + op.RewardStakedShared = 0; + } + else + { + throw new Exception("Unexpected endorsing rewards balance updates behavior"); + } + } + } + + foreach (var op in ops.Values) + { + var bakerCycle = bakerCycles[op.BakerId]; + Db.TryAttach(bakerCycle); + + bakerCycle.FutureEndorsementRewards = 0; + if (op.RewardLiquid != 0 || op.RewardStakedOwn != 0 || op.RewardStakedShared != 0) + { + // Endorsing rewards are wrong for the first preserved+1 cycles after AI activation + if (state.AIActivated && block.Cycle >= state.AIActivationCycle && block.Cycle <= state.AIActivationCycle + block.Protocol.PreservedCycles) + op.Expected = op.RewardLiquid + op.RewardStakedOwn + op.RewardStakedShared; + + if (op.Expected != op.RewardLiquid + op.RewardStakedOwn + op.RewardStakedShared) + throw new Exception("ExpectedReward != RewardFrozen + RewardLiquid"); + + bakerCycle.EndorsementRewardsLiquid = op.RewardLiquid; + bakerCycle.EndorsementRewardsStakedOwn = op.RewardStakedOwn; + bakerCycle.EndorsementRewardsStakedShared = op.RewardStakedShared; + } + else + { + bakerCycle.MissedEndorsementRewards = op.Expected; + } + + + var baker = Cache.Accounts.GetDelegate(op.BakerId); + Db.TryAttach(baker); + + baker.Balance += op.RewardLiquid + op.RewardStakedOwn; + baker.StakingBalance += op.RewardLiquid + op.RewardStakedOwn + op.RewardStakedShared; + baker.StakedBalance += op.RewardStakedOwn; + baker.ExternalStakedBalance += op.RewardStakedShared; + baker.TotalStakedBalance += op.RewardStakedOwn + op.RewardStakedShared; + baker.EndorsingRewardsCount++; + + block.Operations |= Operations.EndorsingRewards; + + Cache.Statistics.Current.TotalCreated += op.RewardLiquid + op.RewardStakedOwn + op.RewardStakedShared; + Cache.Statistics.Current.TotalFrozen += op.RewardStakedOwn + op.RewardStakedShared; + } + + Cache.AppState.Get().EndorsingRewardOpsCount += ops.Count; + + Db.EndorsingRewardOps.AddRange(ops.Values); + } + + public virtual async Task Revert(Block block) + { + if (!block.Operations.HasFlag(Operations.EndorsingRewards)) + return; + + var ops = await Db.EndorsingRewardOps.Where(x => x.Level == block.Level).ToListAsync(); + + foreach (var op in ops) + { + var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.BakerId); + Db.TryAttach(bakerCycle); + + bakerCycle.FutureEndorsementRewards = op.Expected; + bakerCycle.MissedEndorsementRewards = 0; + bakerCycle.EndorsementRewardsLiquid = 0; + bakerCycle.EndorsementRewardsStakedOwn = 0; + bakerCycle.EndorsementRewardsStakedShared = 0; + + var baker = Cache.Accounts.GetDelegate(op.BakerId); + Db.TryAttach(baker); + + baker.Balance -= op.RewardLiquid + op.RewardStakedOwn; + baker.StakingBalance -= op.RewardLiquid + op.RewardStakedOwn + op.RewardStakedShared; + baker.StakedBalance -= op.RewardStakedOwn; + baker.ExternalStakedBalance -= op.RewardStakedShared; + baker.TotalStakedBalance -= op.RewardStakedOwn + op.RewardStakedShared; + baker.EndorsingRewardsCount--; + } + + Cache.AppState.Get().EndorsingRewardOpsCount -= ops.Count; + + Db.EndorsingRewardOps.RemoveRange(ops); + Cache.AppState.ReleaseOperationId(ops.Count); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/InboxCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/InboxCommit.cs new file mode 100644 index 000000000..b823ecf33 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/InboxCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + public class InboxCommit : Proto17.InboxCommit + { + public InboxCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/ActivationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/ActivationsCommit.cs new file mode 100644 index 000000000..d8bd78d1a --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/ActivationsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class ActivationsCommit : Proto12.ActivationsCommit + { + public ActivationsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/BallotsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/BallotsCommit.cs new file mode 100644 index 000000000..9c0376352 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/BallotsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class BallotsCommit : Proto3.BallotsCommit + { + public BallotsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DelegationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DelegationsCommit.cs new file mode 100644 index 000000000..ad0a5500d --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DelegationsCommit.cs @@ -0,0 +1,89 @@ +using System.Numerics; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class DelegationsCommit : Proto14.DelegationsCommit + { + public DelegationsCommit(ProtocolHandler protocol) : base(protocol) { } + + protected override void Unstake(Account sender, Data.Models.Delegate baker, DelegationOperation op) + { + if (baker == null || sender is not User user || user.StakedBalance == 0) + return; + + var unstakedAmount = (long)((BigInteger)baker.ExternalStakedBalance * user.StakedPseudotokens / baker.IssuedPseudotokens); + op.UnstakedPseudotokens = user.StakedPseudotokens; + op.UnstakedBalance = user.StakedBalance; + op.UnstakedRewards = unstakedAmount - user.StakedBalance; // rewards withdrawn + + user.Balance += op.UnstakedRewards.Value; + + baker.IssuedPseudotokens -= user.StakedPseudotokens; + baker.TotalStakedBalance -= unstakedAmount; + baker.ExternalStakedBalance -= unstakedAmount; + baker.ExternalUnstakedBalance += unstakedAmount; + baker.DelegatedBalance += unstakedAmount; + + user.StakedPseudotokens = 0; + user.StakedBalance = 0; + user.UnstakedBalance += unstakedAmount; + + if (user.UnstakedBalance > 0) + { + if (user.UnstakedBakerId == null) + user.UnstakedBakerId = baker.Id; + else if (user.UnstakedBakerId != baker.Id) + throw new Exception("Multiple unstaked bakers are not expected"); + } + + Cache.Statistics.Current.TotalFrozen -= unstakedAmount; + + //#region temporary diagnostics + //var remoteSender = Proto.Node.GetAsync($"chains/main/blocks/{op.Level}/context/raw/json/contracts/index/{user.Address}").Result; + + //if ((remoteSender.OptionalInt64("staking_pseudotokens") ?? 0) != user.StakedPseudotokens) + // throw new Exception("Wrong sender.StakedPseudotokens"); + + //var remoteDelegate = Proto.Node.GetAsync($"chains/main/blocks/{op.Level}/context/raw/json/contracts/index/{baker.Address}").Result; + + //if ((remoteDelegate.OptionalInt64("frozen_deposits_pseudotokens") ?? 0) != baker.IssuedPseudotokens) + // throw new Exception("Wrong senderDelegate.IssuedPseudotokens"); + //#endregion + } + + protected override void RevertUnstake(Account sender, Data.Models.Delegate baker, DelegationOperation op) + { + if (op.UnstakedPseudotokens == null) + return; + + var user = sender as User; + user.Balance -= op.UnstakedRewards.Value; + + baker.IssuedPseudotokens += op.UnstakedPseudotokens.Value; + baker.TotalStakedBalance += op.UnstakedBalance.Value + op.UnstakedRewards.Value; + baker.ExternalStakedBalance += op.UnstakedBalance.Value + op.UnstakedRewards.Value; + baker.ExternalUnstakedBalance -= op.UnstakedBalance.Value + op.UnstakedRewards.Value; + baker.DelegatedBalance -= op.UnstakedBalance.Value + op.UnstakedRewards.Value; + + user.StakedPseudotokens = op.UnstakedPseudotokens.Value; + user.StakedBalance = op.UnstakedBalance.Value; + user.UnstakedBalance -= op.UnstakedBalance.Value + op.UnstakedRewards.Value; + + if (user.UnstakedBalance == 0) + user.UnstakedBakerId = null; + + //#region temporary diagnostics + //var remoteSender = Proto.Node.GetAsync($"chains/main/blocks/{op.Level - 1}/context/raw/json/contracts/index/{user.Address}").Result; + + //if ((remoteSender.OptionalInt64("staking_pseudotokens") ?? 0) != user.StakedPseudotokens) + // throw new Exception("Wrong sender.StakedPseudotokens"); + + //var remoteDelegate = Proto.Node.GetAsync($"chains/main/blocks/{op.Level - 1}/context/raw/json/contracts/index/{baker.Address}").Result; + + //if ((remoteDelegate.OptionalInt64("frozen_deposits_pseudotokens") ?? 0) != baker.IssuedPseudotokens) + // throw new Exception("Wrong senderDelegate.IssuedPseudotokens"); + //#endregion + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DoubleBakingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DoubleBakingCommit.cs new file mode 100644 index 000000000..6ced5fc0f --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DoubleBakingCommit.cs @@ -0,0 +1,84 @@ +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Netezos.Encoding; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class DoubleBakingCommit : ProtocolCommit + { + public DoubleBakingCommit(ProtocolHandler protocol) : base(protocol) { } + + public async Task Apply(Block block, JsonElement op, JsonElement content) + { + #region init + var accusedLevel = content.Required("bh1").RequiredInt32("level"); + var accusedRound = Hex.Parse(content.Required("bh1").RequiredArray("fitness", 5)[4].RequiredString()).ToInt32(); + var accusedRight = await Db.BakingRights.FirstAsync(x => x.Level == accusedLevel && x.Round == accusedRound); + + var accuser = block.Proposer; + var offender = Cache.Accounts.GetDelegate(accusedRight.BakerId); + + var operation = new DoubleBakingOperation + { + Id = Cache.AppState.NextOperationId(), + Block = block, + Level = block.Level, + Timestamp = block.Timestamp, + OpHash = op.RequiredString("hash"), + + AccusedLevel = accusedLevel, + SlashedLevel = block.Protocol.GetCycleEnd(block.Cycle), + + Accuser = accuser, + Offender = offender, + + Reward = 0, + LostStaked = 0, + LostUnstaked = 0, + LostExternalStaked = 0, + LostExternalUnstaked = 0, + + RoundingLoss = 0 + }; + #endregion + + #region apply operation + Db.TryAttach(accuser); + accuser.DoubleBakingCount++; + + if (offender != accuser) + { + Db.TryAttach(offender); + offender.DoubleBakingCount++; + } + + block.Operations |= Operations.DoubleBakings; + #endregion + + Db.DoubleBakingOps.Add(operation); + } + + public void Revert(DoubleBakingOperation operation) + { + #region init + var accuser = Cache.Accounts.GetDelegate(operation.AccuserId); + var offender = Cache.Accounts.GetDelegate(operation.OffenderId); + #endregion + + #region revert operation + Db.TryAttach(accuser); + accuser.DoubleBakingCount--; + + if (offender != accuser) + { + Db.TryAttach(offender); + offender.DoubleBakingCount--; + } + #endregion + + Db.DoubleBakingOps.Remove(operation); + Cache.AppState.ReleaseOperationId(); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DoubleEndorsingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DoubleEndorsingCommit.cs new file mode 100644 index 000000000..fffa14fba --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DoubleEndorsingCommit.cs @@ -0,0 +1,109 @@ +using System.Text.Json; +using Netezos.Encoding; +using Netezos.Forging; +using Netezos.Forging.Models; +using Netezos.Keys; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class DoubleEndorsingCommit : ProtocolCommit + { + public DoubleEndorsingCommit(ProtocolHandler protocol) : base(protocol) { } + + public async Task Apply(Block block, JsonElement op, JsonElement content) + { + #region init + var accusedLevel = content.Required("op1").Required("operations").RequiredInt32("level"); + + var accuser = block.Proposer; + var offender = await GetEndorser(op.RequiredString("chain_id"), content.Required("op1")); + + var operation = new DoubleEndorsingOperation + { + Id = Cache.AppState.NextOperationId(), + Block = block, + Level = block.Level, + Timestamp = block.Timestamp, + OpHash = op.RequiredString("hash"), + + AccusedLevel = accusedLevel, + SlashedLevel = block.Protocol.GetCycleEnd(block.Cycle), + + Accuser = accuser, + Offender = offender, + + Reward = 0, + LostStaked = 0, + LostUnstaked = 0, + LostExternalStaked = 0, + LostExternalUnstaked = 0, + + RoundingLoss = 0 + }; + #endregion + + #region apply operation + Db.TryAttach(accuser); + accuser.DoubleEndorsingCount++; + + if (offender != accuser) + { + Db.TryAttach(offender); + offender.DoubleEndorsingCount++; + } + + block.Operations |= Operations.DoubleEndorsings; + #endregion + + Db.DoubleEndorsingOps.Add(operation); + } + + public void Revert(DoubleEndorsingOperation operation) + { + #region init + var accuser = Cache.Accounts.GetDelegate(operation.AccuserId); + var offender = Cache.Accounts.GetDelegate(operation.OffenderId); + #endregion + + #region revert operation + Db.TryAttach(accuser); + accuser.DoubleEndorsingCount--; + + if (offender != accuser) + { + Db.TryAttach(offender); + offender.DoubleEndorsingCount--; + } + #endregion + + Db.DoubleEndorsingOps.Remove(operation); + Cache.AppState.ReleaseOperationId(); + } + + protected async Task GetEndorser(string chainId, JsonElement op) + { + var branch = op.RequiredString("branch"); + var content = op.Required("operations"); + var endorsement = new EndorsementContent + { + Level = content.RequiredInt32("level"), + Round = content.RequiredInt32("round"), + Slot = content.RequiredInt32("slot"), + PayloadHash = content.RequiredString("block_payload_hash") + }; + var signature = Base58.Parse(op.RequiredString("signature"), 3); + + var bytes = new byte[1] { 19 } + .Concat(Base58.Parse(chainId, 3)) + .Concat(await new LocalForge().ForgeOperationAsync(branch, endorsement)) + .ToArray(); + + foreach (var baker in Cache.Accounts.GetDelegates().OrderByDescending(x => x.LastLevel)) + if (PubKey.FromBase58(baker.PublicKey).Verify(bytes, signature)) + return baker; + + throw new Exception("Failed to determine double endorser"); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DoublePreendorsingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DoublePreendorsingCommit.cs new file mode 100644 index 000000000..172549254 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DoublePreendorsingCommit.cs @@ -0,0 +1,109 @@ +using System.Text.Json; +using Netezos.Encoding; +using Netezos.Forging; +using Netezos.Forging.Models; +using Netezos.Keys; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class DoublePreendorsingCommit : ProtocolCommit + { + public DoublePreendorsingCommit(ProtocolHandler protocol) : base(protocol) { } + + public async Task Apply(Block block, JsonElement op, JsonElement content) + { + #region init + var accusedLevel = content.Required("op1").Required("operations").RequiredInt32("level"); + + var accuser = block.Proposer; + var offender = await GetPreendorser(op.RequiredString("chain_id"), content.Required("op1")); + + var operation = new DoublePreendorsingOperation + { + Id = Cache.AppState.NextOperationId(), + Block = block, + Level = block.Level, + Timestamp = block.Timestamp, + OpHash = op.RequiredString("hash"), + + AccusedLevel = accusedLevel, + SlashedLevel = block.Protocol.GetCycleEnd(block.Cycle), + + Accuser = accuser, + Offender = offender, + + Reward = 0, + LostStaked = 0, + LostUnstaked = 0, + LostExternalStaked = 0, + LostExternalUnstaked = 0, + + RoundingLoss = 0 + }; + #endregion + + #region apply operation + Db.TryAttach(accuser); + accuser.DoublePreendorsingCount++; + + if (offender != accuser) + { + Db.TryAttach(offender); + offender.DoublePreendorsingCount++; + } + + block.Operations |= Operations.DoublePreendorsings; + #endregion + + Db.DoublePreendorsingOps.Add(operation); + } + + public void Revert(DoublePreendorsingOperation operation) + { + #region init + var accuser = Cache.Accounts.GetDelegate(operation.AccuserId); + var offender = Cache.Accounts.GetDelegate(operation.OffenderId); + #endregion + + #region revert operation + Db.TryAttach(accuser); + accuser.DoublePreendorsingCount--; + + if (offender != accuser) + { + Db.TryAttach(offender); + offender.DoublePreendorsingCount--; + } + #endregion + + Db.DoublePreendorsingOps.Remove(operation); + Cache.AppState.ReleaseOperationId(); + } + + protected async Task GetPreendorser(string chainId, JsonElement op) + { + var branch = op.RequiredString("branch"); + var content = op.Required("operations"); + var preendorsement = new PreendorsementContent + { + Level = content.RequiredInt32("level"), + Round = content.RequiredInt32("round"), + Slot = content.RequiredInt32("slot"), + PayloadHash = content.RequiredString("block_payload_hash") + }; + var signature = Base58.Parse(op.RequiredString("signature"), 3); + + var bytes = new byte[1] { 18 } + .Concat(Base58.Parse(chainId, 3)) + .Concat(await new LocalForge().ForgeOperationAsync(branch, preendorsement)) + .ToArray(); + + foreach (var baker in Cache.Accounts.GetDelegates().OrderByDescending(x => x.LastLevel)) + if (PubKey.FromBase58(baker.PublicKey).Verify(bytes, signature)) + return baker; + + throw new Exception("Failed to determine double preendorser"); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DrainDelegateCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DrainDelegateCommit.cs new file mode 100644 index 000000000..83020dd99 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/DrainDelegateCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class DrainDelegateCommit : Proto15.DrainDelegateCommit + { + public DrainDelegateCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/EndorsementsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/EndorsementsCommit.cs new file mode 100644 index 000000000..519b2cd13 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/EndorsementsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class EndorsementsCommit : Proto12.EndorsementsCommit + { + public EndorsementsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/IncreasePaidStorageCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/IncreasePaidStorageCommit.cs new file mode 100644 index 000000000..76a82be3f --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/IncreasePaidStorageCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class IncreasePaidStorageCommit : Proto14.IncreasePaidStorageCommit + { + public IncreasePaidStorageCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/NonceRevelationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/NonceRevelationsCommit.cs new file mode 100644 index 000000000..f11f19c11 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/NonceRevelationsCommit.cs @@ -0,0 +1,112 @@ +using System.Numerics; +using System.Text.Json; +using Netezos.Encoding; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class NonceRevelationsCommit : ProtocolCommit + { + public NonceRevelationsCommit(ProtocolHandler protocol) : base(protocol) { } + + public virtual async Task Apply(Block block, JsonElement op, JsonElement content) + { + #region init + var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); + var freezerUpdate = balanceUpdates.SingleOrDefault(x => x.RequiredString("kind") == "freezer"); + var contractUpdate = balanceUpdates.SingleOrDefault(x => x.RequiredString("kind") == "contract"); + + var rewardLiquid = contractUpdate.ValueKind != JsonValueKind.Undefined + ? contractUpdate.RequiredInt64("change") + : 0; + var rewardStaked = freezerUpdate.ValueKind != JsonValueKind.Undefined + ? freezerUpdate.RequiredInt64("change") + : 0; + var rewardStakedOwn = block.Proposer.TotalStakedBalance == 0 ? rewardStaked : (long)((BigInteger)rewardStaked * block.Proposer.StakedBalance / block.Proposer.TotalStakedBalance); + var rewardStakedShared = rewardStaked - rewardStakedOwn; + + var revealedBlock = await Cache.Blocks.GetAsync(content.RequiredInt32("level")); + + var revelation = new NonceRevelationOperation + { + Id = Cache.AppState.NextOperationId(), + Block = block, + Level = block.Level, + Timestamp = block.Timestamp, + OpHash = op.RequiredString("hash"), + Baker = block.Proposer, + Sender = Cache.Accounts.GetDelegate(revealedBlock.ProposerId), + RevealedBlock = revealedBlock, + RevealedLevel = revealedBlock.Level, + RevealedCycle = revealedBlock.Cycle, + Nonce = Hex.Parse(content.RequiredString("nonce")), + RewardLiquid = rewardLiquid, + RewardStakedOwn = rewardStakedOwn, + RewardStakedShared = rewardStakedShared + }; + #endregion + + #region apply operation + block.Proposer.Balance += revelation.RewardLiquid + revelation.RewardStakedOwn; + block.Proposer.StakingBalance += revelation.RewardLiquid + revelation.RewardStakedOwn + revelation.RewardStakedShared; + block.Proposer.StakedBalance += revelation.RewardStakedOwn; + block.Proposer.ExternalStakedBalance += revelation.RewardStakedShared; + block.Proposer.TotalStakedBalance += revelation.RewardStakedOwn + revelation.RewardStakedShared; + block.Proposer.NonceRevelationsCount++; + + if (revelation.Sender != block.Proposer) + { + Db.TryAttach(revelation.Sender); + revelation.Sender.NonceRevelationsCount++; + } + + Db.TryAttach(revelation.RevealedBlock); + revelation.RevealedBlock.Revelation = revelation; + revelation.RevealedBlock.RevelationId = revelation.Id; + + block.Operations |= Operations.Revelations; + + Cache.Statistics.Current.TotalCreated += revelation.RewardLiquid + revelation.RewardStakedOwn + revelation.RewardStakedShared; + Cache.Statistics.Current.TotalFrozen += revelation.RewardStakedOwn + revelation.RewardStakedShared; + #endregion + + Db.NonceRevelationOps.Add(revelation); + } + + public virtual async Task Revert(Block block, NonceRevelationOperation revelation) + { + #region init + revelation.Block ??= block; + revelation.Block.Protocol ??= await Cache.Protocols.GetAsync(block.ProtoCode); + revelation.Block.Proposer ??= Cache.Accounts.GetDelegate(block.ProposerId); + + revelation.Baker ??= Cache.Accounts.GetDelegate(revelation.BakerId); + revelation.Sender ??= Cache.Accounts.GetDelegate(revelation.SenderId); + revelation.RevealedBlock = await Cache.Blocks.GetAsync(revelation.RevealedLevel); + #endregion + + #region apply operation + Db.TryAttach(block.Proposer); + block.Proposer.Balance -= revelation.RewardLiquid + revelation.RewardStakedOwn; + block.Proposer.StakingBalance -= revelation.RewardLiquid + revelation.RewardStakedOwn + revelation.RewardStakedShared; + block.Proposer.StakedBalance -= revelation.RewardStakedOwn; + block.Proposer.ExternalStakedBalance -= revelation.RewardStakedShared; + block.Proposer.TotalStakedBalance -= revelation.RewardStakedOwn + revelation.RewardStakedShared; + block.Proposer.NonceRevelationsCount--; + + if (revelation.Sender != block.Proposer) + { + Db.TryAttach(revelation.Sender); + revelation.Sender.NonceRevelationsCount--; + } + + Db.TryAttach(revelation.RevealedBlock); + revelation.RevealedBlock.Revelation = null; + revelation.RevealedBlock.RevelationId = null; + #endregion + + Db.NonceRevelationOps.Remove(revelation); + Cache.AppState.ReleaseOperationId(); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/OriginationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/OriginationsCommit.cs new file mode 100644 index 000000000..f08e816de --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/OriginationsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class OriginationsCommit : Proto14.OriginationsCommit + { + public OriginationsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/PreendorsementsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/PreendorsementsCommit.cs new file mode 100644 index 000000000..cf0fe3121 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/PreendorsementsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class PreendorsementsCommit : Proto12.PreendorsementsCommit + { + public PreendorsementsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/ProposalsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/ProposalsCommit.cs new file mode 100644 index 000000000..7b6617b5b --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/ProposalsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class ProposalsCommit : Proto14.ProposalsCommit + { + public ProposalsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/RegisterConstantsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/RegisterConstantsCommit.cs new file mode 100644 index 000000000..7ae50c102 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/RegisterConstantsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class RegisterConstantsCommit : Proto14.RegisterConstantsCommit + { + public RegisterConstantsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/RevealsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/RevealsCommit.cs new file mode 100644 index 000000000..bf9cc231d --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/RevealsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class RevealsCommit : Proto14.RevealsCommit + { + public RevealsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SetDepositsLimitCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SetDepositsLimitCommit.cs new file mode 100644 index 000000000..cf2143d4e --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SetDepositsLimitCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SetDepositsLimitCommit : Proto12.SetDepositsLimitCommit + { + public SetDepositsLimitCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupAddMessagesCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupAddMessagesCommit.cs new file mode 100644 index 000000000..3c707b479 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupAddMessagesCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SmartRollupAddMessagesCommit : Proto16.SmartRollupAddMessagesCommit + { + public SmartRollupAddMessagesCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupCementCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupCementCommit.cs new file mode 100644 index 000000000..903512ddb --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupCementCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SmartRollupCementCommit : Proto17.SmartRollupCementCommit + { + public SmartRollupCementCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupExecuteCommit.cs new file mode 100644 index 000000000..16ca1449b --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupExecuteCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SmartRollupExecuteCommit : Proto16.SmartRollupExecuteCommit + { + public SmartRollupExecuteCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupOriginateCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupOriginateCommit.cs new file mode 100644 index 000000000..1b3cc7016 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupOriginateCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SmartRollupOriginateCommit : Proto16.SmartRollupOriginateCommit + { + public SmartRollupOriginateCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupPublishCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupPublishCommit.cs new file mode 100644 index 000000000..919c5d09f --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupPublishCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SmartRollupPublishCommit : Proto16.SmartRollupPublishCommit + { + public SmartRollupPublishCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupRecoverBondCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupRecoverBondCommit.cs new file mode 100644 index 000000000..7cb3d3164 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupRecoverBondCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SmartRollupRecoverBondCommit : Proto16.SmartRollupRecoverBondCommit + { + public SmartRollupRecoverBondCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupRefuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupRefuteCommit.cs new file mode 100644 index 000000000..b3de2cd5b --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupRefuteCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SmartRollupRefuteCommit : Proto16.SmartRollupRefuteCommit + { + public SmartRollupRefuteCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupTimeoutCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupTimeoutCommit.cs new file mode 100644 index 000000000..ad637947d --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/SmartRollupTimeoutCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SmartRollupTimeoutCommit : Proto16.SmartRollupTimeoutCommit + { + public SmartRollupTimeoutCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/StakingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/StakingCommit.cs new file mode 100644 index 000000000..7f63bd2fc --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/StakingCommit.cs @@ -0,0 +1,537 @@ +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Netezos.Contracts; +using Netezos.Encoding; +using Tzkt.Data.Models; +using Tzkt.Data.Models.Base; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class StakingCommit : ProtocolCommit + { + #region static + public static readonly HashSet Entrypoints = new() { "stake", "unstake", "finalize_unstake", "set_delegate_parameters" }; + static readonly Schema DelegateParametersSchema = Schema.Create(Micheline.FromJson(""" + { + "prim": "pair", + "args": [ + { + "prim": "int" + }, + { + "prim": "int" + }, + { + "prim": "unit" + } + ] + } + """) as MichelinePrim); + #endregion + + public StakingCommit(ProtocolHandler protocol) : base(protocol) { } + + public async Task Apply(Block block, JsonElement op, JsonElement content) + { + #region init + var sender = await Cache.Accounts.GetAsync(content.RequiredString("source")) as User; + var senderDelegate = sender as Data.Models.Delegate ?? Cache.Accounts.GetDelegate(sender.DelegateId); + + var result = content.Required("metadata").Required("operation_result"); + var operation = new StakingOperation + { + Id = Cache.AppState.NextOperationId(), + OpHash = op.RequiredString("hash"), + Block = block, + Level = block.Level, + Timestamp = block.Timestamp, + BakerFee = content.RequiredInt64("fee"), + Counter = content.RequiredInt32("counter"), + GasLimit = content.RequiredInt32("gas_limit"), + StorageLimit = content.RequiredInt32("storage_limit"), + Sender = sender, + SenderId = sender.Id, + Status = result.RequiredString("status") switch + { + "applied" => OperationStatus.Applied, + "backtracked" => OperationStatus.Backtracked, + "failed" => OperationStatus.Failed, + "skipped" => OperationStatus.Skipped, + _ => throw new NotImplementedException() + }, + Errors = result.TryGetProperty("errors", out var errors) + ? OperationErrors.Parse(content, errors) + : null, + GasUsed = (int)(((result.OptionalInt64("consumed_milligas") ?? 0) + 999) / 1000) + }; + + switch (content.Required("parameters").RequiredString("entrypoint")) + { + case "stake": + operation.Kind = StakingOperationKind.Stake; + operation.Amount = content.RequiredInt64("amount"); + operation.BakerId = senderDelegate?.Id; + operation.Pseudotokens = null; + break; + case "unstake": + var unstakedAmount = 0L; + if (operation.Status == OperationStatus.Applied) + { + if (result.TryGetProperty("balance_updates", out var unstakeUpdates)) + { + var unstakeUpdate = unstakeUpdates + .EnumerateArray() + .FirstOrDefault(x => x.RequiredString("category") == "unstaked_deposits"); + + if (unstakeUpdate.ValueKind != JsonValueKind.Undefined) + unstakedAmount = unstakeUpdate.RequiredInt64("change"); + } + } + else + { + if (content.Required("parameters").Required("value").TryGetBigInteger("int", out var amount)) + unstakedAmount = amount.TrimToInt64(); + } + operation.Kind = StakingOperationKind.Unstake; + operation.Amount = unstakedAmount; + operation.BakerId = senderDelegate?.Id; + operation.Pseudotokens = null; + operation.PrevStakedBalance = null; + break; + case "finalize_unstake": + var finalizedAmount = 0L; + var firstCycle = (int?)null; + var lastCycle = (int?)null; + if (result.TryGetProperty("balance_updates", out var updates)) + { + var freezerUpdates = updates.EnumerateArray().Where(x => x.RequiredString("kind") == "freezer"); + if (freezerUpdates.Any()) + { + finalizedAmount = freezerUpdates.Sum(x => -x.RequiredInt64("change")); + firstCycle = freezerUpdates.Min(x => x.RequiredInt32("cycle")); + lastCycle = freezerUpdates.Max(x => x.RequiredInt32("cycle")); + } + } + operation.Kind = StakingOperationKind.FinalizeUnstake; + operation.Amount = finalizedAmount; + operation.FirstCycleUnstaked = firstCycle; + operation.LastCycleUnstaked = lastCycle; + break; + case "set_delegate_parameters": + var limit = BigInteger.Zero; + var edge = BigInteger.Zero; + try + { + var param = DelegateParametersSchema.Optimize(Micheline.FromJson(content.Required("parameters").Required("value"))); + limit = ((param as MichelinePrim).Args[0] as MichelineInt).Value; + edge = (((param as MichelinePrim).Args[1] as MichelinePrim).Args[0] as MichelineInt).Value; + } + catch when (operation.Status != OperationStatus.Applied) { } + operation.Kind = StakingOperationKind.SetDelegateParameter; + operation.LimitOfStakingOverBaking = limit.TrimToInt64(); + operation.EdgeOfBakingOverStaking = (long)edge; + operation.ActivationCycle = block.Cycle + block.Protocol.PreservedCycles + 1; + break; + default: + throw new NotImplementedException(); + } + #endregion + + #region apply operation + Db.TryAttach(sender); + sender.Balance -= operation.BakerFee; + sender.Counter = operation.Counter; + sender.StakingOpsCount++; + + if (senderDelegate != null) + { + Db.TryAttach(senderDelegate); + senderDelegate.StakingBalance -= operation.BakerFee; + if (senderDelegate != sender) + { + senderDelegate.DelegatedBalance -= operation.BakerFee; + senderDelegate.StakingOpsCount++; + } + } + + block.Proposer.Balance += operation.BakerFee; + block.Proposer.StakingBalance += operation.BakerFee; + + block.Operations |= Operations.Staking; + block.Fees += operation.BakerFee; + + Cache.AppState.Get().StakingOpsCount++; + #endregion + + #region apply result + if (operation.Status == OperationStatus.Applied) + { + if (operation.Kind == StakingOperationKind.Stake) + { + if (operation.Amount > 0) + { + if (sender != senderDelegate) + { + operation.Pseudotokens = senderDelegate.IssuedPseudotokens == 0 + ? operation.Amount.Value + : (long)((BigInteger)senderDelegate.IssuedPseudotokens * operation.Amount.Value / senderDelegate.ExternalStakedBalance); + + sender.StakedPseudotokens += operation.Pseudotokens.Value; + senderDelegate.IssuedPseudotokens += operation.Pseudotokens.Value; + senderDelegate.ExternalStakedBalance += operation.Amount.Value; + senderDelegate.DelegatedBalance -= operation.Amount.Value; + if (sender.StakedPseudotokens == operation.Pseudotokens.Value) + senderDelegate.StakersCount++; + } + sender.StakedBalance += operation.Amount.Value; + senderDelegate.TotalStakedBalance += operation.Amount.Value; + + Cache.Statistics.Current.TotalFrozen += operation.Amount.Value; + } + } + else if (operation.Kind == StakingOperationKind.Unstake) + { + if (operation.Amount > 0) + { + if (sender != senderDelegate) + { + var newStakedBalance = (long)((BigInteger)senderDelegate.ExternalStakedBalance * sender.StakedPseudotokens / senderDelegate.IssuedPseudotokens); + operation.PrevStakedBalance = sender.StakedBalance; + + var rewards = newStakedBalance - sender.StakedBalance; + sender.StakedBalance = newStakedBalance; + sender.Balance += rewards; + + if (operation.Amount > sender.StakedBalance) + throw new Exception("Unstaked amount exceeds staked balance"); + + operation.Pseudotokens = operation.Amount < sender.StakedBalance + ? (long)((BigInteger)senderDelegate.IssuedPseudotokens * operation.Amount.Value / senderDelegate.ExternalStakedBalance) + : sender.StakedPseudotokens; + + sender.StakedPseudotokens -= operation.Pseudotokens.Value; + senderDelegate.IssuedPseudotokens -= operation.Pseudotokens.Value; + senderDelegate.ExternalStakedBalance -= operation.Amount.Value; + senderDelegate.ExternalUnstakedBalance += operation.Amount.Value; + senderDelegate.DelegatedBalance += operation.Amount.Value; + if (sender.StakedPseudotokens == 0) + senderDelegate.StakersCount--; + } + sender.UnstakedBalance += operation.Amount.Value; + sender.StakedBalance -= operation.Amount.Value; + senderDelegate.TotalStakedBalance -= operation.Amount.Value; + + if (sender.UnstakedBalance > 0) + { + if (sender.UnstakedBakerId == null) + sender.UnstakedBakerId = senderDelegate.Id; + else if (sender.UnstakedBakerId != senderDelegate.Id) + throw new Exception("Multiple unstaked bakers are not expected"); + } + + Cache.Statistics.Current.TotalFrozen -= operation.Amount.Value; + } + } + else if (operation.Kind == StakingOperationKind.FinalizeUnstake) + { + if (operation.Amount > 0) + { + var startCycleProto = await Cache.Protocols.FindByCycleAsync(operation.FirstCycleUnstaked.Value); + var startLevel = startCycleProto.GetCycleStart(operation.FirstCycleUnstaked.Value); + + var endCycleProto = await Cache.Protocols.FindByCycleAsync(operation.LastCycleUnstaked.Value); + var endLevel = block.Protocol.GetCycleEnd(operation.LastCycleUnstaked.Value); + + var requestedAmount = await Db.StakingOps + .Where(x => + x.SenderId == sender.Id && + x.Kind == StakingOperationKind.Unstake && + x.Status == OperationStatus.Applied && + x.Level >= startLevel && + x.Level <= endLevel) + .SumAsync(x => x.Amount); + + requestedAmount += await Db.DelegationOps + .Where(x => + x.SenderId == sender.Id && + x.UnstakedBalance != null && + x.Status == OperationStatus.Applied && + x.Level >= startLevel && + x.Level <= endLevel) + .SumAsync(x => x.UnstakedBalance + x.UnstakedRewards); + + if (operation.Amount != requestedAmount) + throw new NotImplementedException("Slashing of unstaked deposits cannot be implemented due to bugs in Oxford. Let's wait for fixes..."); + + var unstakedBaker = Cache.Accounts.GetDelegate(sender.UnstakedBakerId); + if (unstakedBaker != sender) + { + Db.TryAttach(unstakedBaker); + unstakedBaker.ExternalUnstakedBalance -= operation.Amount.Value; + unstakedBaker.StakingBalance -= operation.Amount.Value; + unstakedBaker.DelegatedBalance -= operation.Amount.Value; + + if (senderDelegate != null) + { + senderDelegate.StakingBalance += operation.Amount.Value; + if (senderDelegate != sender) + senderDelegate.DelegatedBalance += operation.Amount.Value; + } + } + + sender.UnstakedBalance -= operation.Amount.Value; + + if (sender.UnstakedBalance == 0) + sender.UnstakedBakerId = null; + + } + } + else if (operation.Kind == StakingOperationKind.SetDelegateParameter) + { + Cache.AppState.Get().PendingStakingParameters++; + } + + //#region temporary diagnostics + //if (sender.Type == AccountType.User) + //{ + // var remoteSender = await Proto.Node.GetAsync($"chains/main/blocks/{block.Level}/context/raw/json/contracts/index/{sender.Address}"); + + // if ((remoteSender.OptionalInt64("staking_pseudotokens") ?? 0) != sender.StakedPseudotokens) + // throw new Exception("Wrong sender.StakedPseudotokens"); + //} + + //var remoteDelegate = await Proto.Node.GetAsync($"chains/main/blocks/{block.Level}/context/raw/json/contracts/index/{senderDelegate.Address}"); + + //if ((remoteDelegate.OptionalInt64("frozen_deposits_pseudotokens") ?? 0) != senderDelegate.IssuedPseudotokens) + // throw new Exception("Wrong senderDelegate.IssuedPseudotokens"); + //#endregion + } + #endregion + + Proto.Manager.Set(operation.Sender); + Db.StakingOps.Add(operation); + } + + public async Task Revert(Block block, StakingOperation operation) + { + var sender = await Cache.Accounts.GetAsync(operation.SenderId) as User; + var senderDelegate = sender as Data.Models.Delegate ?? Cache.Accounts.GetDelegate(sender.DelegateId); + + Db.TryAttach(sender); + Db.TryAttach(senderDelegate); + + #region revert result + if (operation.Status == OperationStatus.Applied) + { + if (operation.Kind == StakingOperationKind.Stake) + { + if (operation.Amount > 0) + { + sender.StakedBalance -= operation.Amount.Value; + senderDelegate.TotalStakedBalance -= operation.Amount.Value; + if (sender != senderDelegate) + { + sender.StakedPseudotokens -= operation.Pseudotokens.Value; + senderDelegate.IssuedPseudotokens -= operation.Pseudotokens.Value; + senderDelegate.ExternalStakedBalance -= operation.Amount.Value; + senderDelegate.DelegatedBalance += operation.Amount.Value; + if (sender.StakedPseudotokens == 0) + senderDelegate.StakersCount--; + } + } + } + else if (operation.Kind == StakingOperationKind.Unstake) + { + if (operation.Amount > 0) + { + if (sender.UnstakedBalance == operation.Amount.Value) + sender.UnstakedBakerId = null; + + sender.UnstakedBalance -= operation.Amount.Value; + sender.StakedBalance += operation.Amount.Value; + senderDelegate.TotalStakedBalance += operation.Amount.Value; + if (sender != senderDelegate) + { + var rewards = sender.StakedBalance - operation.PrevStakedBalance.Value; + sender.StakedBalance = operation.PrevStakedBalance.Value; + sender.Balance -= rewards; + + sender.StakedPseudotokens += operation.Pseudotokens.Value; + senderDelegate.IssuedPseudotokens += operation.Pseudotokens.Value; + senderDelegate.ExternalStakedBalance += operation.Amount.Value; + senderDelegate.ExternalUnstakedBalance -= operation.Amount.Value; + senderDelegate.DelegatedBalance -= operation.Amount.Value; + if (sender.StakedPseudotokens == operation.Pseudotokens.Value) + senderDelegate.StakersCount++; + } + } + } + else if (operation.Kind == StakingOperationKind.FinalizeUnstake) + { + if (operation.Amount > 0) + { + var startCycleProto = await Cache.Protocols.FindByCycleAsync(operation.FirstCycleUnstaked.Value); + var startLevel = startCycleProto.GetCycleStart(operation.FirstCycleUnstaked.Value); + + var endCycleProto = await Cache.Protocols.FindByCycleAsync(operation.LastCycleUnstaked.Value); + var endLevel = block.Protocol.GetCycleEnd(operation.LastCycleUnstaked.Value); + + var stakingOps = await Db.StakingOps + .AsNoTracking() + .Where(x => + x.SenderId == sender.Id && + x.Kind == StakingOperationKind.Unstake && + x.Status == OperationStatus.Applied && + x.Level >= startLevel && + x.Level <= endLevel) + .OrderBy(x => x.Level) + .ThenBy(x => x.Id) + .ToListAsync(); + + var delegationOps = await Db.DelegationOps + .AsNoTracking() + .Where(x => + x.SenderId == sender.Id && + x.UnstakedBalance != null && + x.Status == OperationStatus.Applied && + x.Level >= startLevel && + x.Level <= endLevel) + .OrderBy(x => x.Level) + .ThenBy(x => x.Id) + .ToListAsync(); + + var unstakeOps = stakingOps.Select(x => (x.BakerId, x.Amount.Value)) + .Concat(delegationOps.Select(x => (x.PrevDelegateId, x.UnstakedBalance.Value + x.UnstakedRewards.Value))); + + foreach (var (prevBakerId, unstakedAmount) in unstakeOps) + { + if (sender.UnstakedBalance == 0 && unstakedAmount > 0) + sender.UnstakedBakerId = prevBakerId; + + sender.UnstakedBalance += unstakedAmount; + + var prevBaker = Cache.Accounts.GetDelegate(prevBakerId); + if (prevBaker != sender) + { + Db.TryAttach(prevBaker); + prevBaker.ExternalUnstakedBalance += unstakedAmount; + prevBaker.StakingBalance += unstakedAmount; + prevBaker.DelegatedBalance += unstakedAmount; + + if (senderDelegate != null) + { + senderDelegate.StakingBalance -= unstakedAmount; + if (senderDelegate != sender) + senderDelegate.DelegatedBalance -= unstakedAmount; + } + } + } + } + } + else if (operation.Kind == StakingOperationKind.SetDelegateParameter) + { + Cache.AppState.Get().PendingStakingParameters--; + } + + //#region temporary diagnostics + //if (sender.Type == AccountType.User) + //{ + // var remoteSender = await Proto.Node.GetAsync($"chains/main/blocks/{block.Level - 1}/context/raw/json/contracts/index/{sender.Address}"); + + // if ((remoteSender.OptionalInt64("staking_pseudotokens") ?? 0) != sender.StakedPseudotokens) + // throw new Exception("Wrong sender.StakedPseudotokens"); + //} + + //var remoteDelegate = await Proto.Node.GetAsync($"chains/main/blocks/{block.Level - 1}/context/raw/json/contracts/index/{senderDelegate.Address}"); + + //if ((remoteDelegate.OptionalInt64("frozen_deposits_pseudotokens") ?? 0) != senderDelegate.IssuedPseudotokens) + // throw new Exception("Wrong senderDelegate.IssuedPseudotokens"); + //#endregion + } + #endregion + + #region revert operation + sender.Balance += operation.BakerFee; + sender.Counter = operation.Counter - 1; + sender.StakingOpsCount--; + + if (senderDelegate != null) + { + senderDelegate.StakingBalance += operation.BakerFee; + if (senderDelegate != sender) + { + senderDelegate.DelegatedBalance += operation.BakerFee; + senderDelegate.StakingOpsCount--; + } + } + + block.Proposer.Balance -= operation.BakerFee; + block.Proposer.StakingBalance -= operation.BakerFee; + + Cache.AppState.Get().StakingOpsCount--; + #endregion + + Db.StakingOps.Remove(operation); + Cache.AppState.ReleaseManagerCounter(); + Cache.AppState.ReleaseOperationId(); + } + + public async Task ActivateStakingParameters(Block block) + { + if (!block.Events.HasFlag(BlockEvents.CycleBegin) || Cache.AppState.Get().PendingStakingParameters == 0) + return; + + var ops = await Db.StakingOps + .AsNoTracking() + .Where(x => + x.Kind == StakingOperationKind.SetDelegateParameter && + x.Status == OperationStatus.Applied && + x.ActivationCycle == block.Cycle) + .ToListAsync(); + + foreach (var op in ops) + { + var baker = Cache.Accounts.GetDelegate(op.SenderId); + Db.TryAttach(baker); + baker.EdgeOfBakingOverStaking = op.EdgeOfBakingOverStaking; + baker.LimitOfStakingOverBaking = op.LimitOfStakingOverBaking; + Cache.AppState.Get().PendingStakingParameters--; + } + } + + public async Task DeactivateStakingParameters(Block block) + { + if (!block.Events.HasFlag(BlockEvents.CycleBegin)) + return; + + var ops = await Db.StakingOps + .AsNoTracking() + .Where(x => + x.Kind == StakingOperationKind.SetDelegateParameter && + x.Status == OperationStatus.Applied && + x.ActivationCycle == block.Cycle) + .ToListAsync(); + + foreach (var op in ops) + { + var baker = Cache.Accounts.GetDelegate(op.SenderId); + + var prevOp = await Db.StakingOps + .AsNoTracking() + .Where(x => + x.SenderId == baker.Id && + x.Kind == StakingOperationKind.SetDelegateParameter && + x.Status == OperationStatus.Applied && + x.ActivationCycle < op.ActivationCycle) + .OrderByDescending(x => x.Id) + .FirstOrDefaultAsync(); + + Db.TryAttach(baker); + baker.EdgeOfBakingOverStaking = prevOp?.EdgeOfBakingOverStaking; + baker.LimitOfStakingOverBaking = prevOp?.LimitOfStakingOverBaking; + Cache.AppState.Get().PendingStakingParameters++; + } + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/TransactionsCommit.cs new file mode 100644 index 000000000..a5365c139 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/TransactionsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class TransactionsCommit : Proto14.TransactionsCommit + { + public TransactionsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/TransferTicketCommit.cs new file mode 100644 index 000000000..c27e00840 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/TransferTicketCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class TransferTicketCommit : Proto13.TransferTicketCommit + { + public TransferTicketCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/UpdateConsensusKeyCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/UpdateConsensusKeyCommit.cs new file mode 100644 index 000000000..2daff8bf4 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/UpdateConsensusKeyCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class UpdateConsensusKeyCommit : Proto15.UpdateConsensusKeyCommit + { + public UpdateConsensusKeyCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/VdfRevelationCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/VdfRevelationCommit.cs new file mode 100644 index 000000000..6dd2920ce --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/Operations/VdfRevelationCommit.cs @@ -0,0 +1,92 @@ +using System.Numerics; +using System.Text.Json; +using Netezos.Encoding; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class VdfRevelationCommit : ProtocolCommit + { + public VdfRevelationCommit(ProtocolHandler protocol) : base(protocol) { } + + public virtual Task Apply(Block block, JsonElement op, JsonElement content) + { + #region init + var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); + var freezerUpdate = balanceUpdates.SingleOrDefault(x => x.RequiredString("kind") == "freezer"); + var contractUpdate = balanceUpdates.SingleOrDefault(x => x.RequiredString("kind") == "contract"); + + var rewardLiquid = contractUpdate.ValueKind != JsonValueKind.Undefined + ? contractUpdate.RequiredInt64("change") + : 0; + var rewardStaked = freezerUpdate.ValueKind != JsonValueKind.Undefined + ? freezerUpdate.RequiredInt64("change") + : 0; + var rewardStakedOwn = block.Proposer.TotalStakedBalance == 0 ? rewardStaked : (long)((BigInteger)rewardStaked * block.Proposer.StakedBalance / block.Proposer.TotalStakedBalance); + var rewardStakedShared = rewardStaked - rewardStakedOwn; + + var revelation = new VdfRevelationOperation + { + Id = Cache.AppState.NextOperationId(), + Block = block, + Level = block.Level, + Timestamp = block.Timestamp, + OpHash = op.RequiredString("hash"), + Baker = block.Proposer, + Cycle = block.Cycle, + Solution = Hex.Parse(content.RequiredArray("solution", 2)[0].RequiredString()), + Proof = Hex.Parse(content.RequiredArray("solution", 2)[1].RequiredString()), + RewardLiquid = rewardLiquid, + RewardStakedOwn = rewardStakedOwn, + RewardStakedShared = rewardStakedShared + }; + #endregion + + #region apply operation + block.Proposer.Balance += revelation.RewardLiquid + revelation.RewardStakedOwn; + block.Proposer.StakingBalance += revelation.RewardLiquid + revelation.RewardStakedOwn + revelation.RewardStakedShared; + block.Proposer.StakedBalance += revelation.RewardStakedOwn; + block.Proposer.ExternalStakedBalance += revelation.RewardStakedShared; + block.Proposer.TotalStakedBalance += revelation.RewardStakedOwn + revelation.RewardStakedShared; + block.Proposer.VdfRevelationsCount++; + + Cache.AppState.Get().VdfRevelationOpsCount++; + + block.Operations |= Operations.VdfRevelation; + + Cache.Statistics.Current.TotalCreated += revelation.RewardLiquid + revelation.RewardStakedOwn + revelation.RewardStakedShared; + Cache.Statistics.Current.TotalFrozen += revelation.RewardStakedOwn + revelation.RewardStakedShared; + #endregion + + Db.VdfRevelationOps.Add(revelation); + return Task.CompletedTask; + } + + public virtual Task Revert(Block block, VdfRevelationOperation revelation) + { + #region init + revelation.Baker ??= Cache.Accounts.GetDelegate(revelation.BakerId); + #endregion + + #region entities + var blockBaker = revelation.Baker; + Db.TryAttach(blockBaker); + #endregion + + #region apply operation + block.Proposer.Balance -= revelation.RewardLiquid + revelation.RewardStakedOwn; + block.Proposer.StakingBalance -= revelation.RewardLiquid + revelation.RewardStakedOwn + revelation.RewardStakedShared; + block.Proposer.StakedBalance -= revelation.RewardStakedOwn; + block.Proposer.ExternalStakedBalance -= revelation.RewardStakedShared; + block.Proposer.TotalStakedBalance -= revelation.RewardStakedOwn + revelation.RewardStakedShared; + block.Proposer.VdfRevelationsCount--; + + Cache.AppState.Get().VdfRevelationOpsCount--; + #endregion + + Db.VdfRevelationOps.Remove(revelation); + Cache.AppState.ReleaseOperationId(); + return Task.CompletedTask; + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SlashingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SlashingCommit.cs new file mode 100644 index 000000000..134cc9e3c --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SlashingCommit.cs @@ -0,0 +1,378 @@ +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Tzkt.Data.Models; +using Tzkt.Data.Models.Base; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SlashingCommit : ProtocolCommit + { + public SlashingCommit(ProtocolHandler protocol) : base(protocol) { } + + public async Task Apply(Block block, JsonElement rawBlock) + { + if (!block.Events.HasFlag(BlockEvents.CycleEnd)) + return; + + var slashings = rawBlock + .Required("metadata") + .RequiredArray("balance_updates") + .EnumerateArray() + .Where(x => x.RequiredString("origin") == "delayed_operation") + .GroupBy(x => x.RequiredString("delayed_operation_hash")) + .Reverse(); // slashings are reversed in block balance updates for some reason ¯\_(ツ)_/¯ + + foreach (var slashing in slashings) + { + var opHash = slashing.Key; + var accusation = block.DoubleBakings?.FirstOrDefault(x => x.OpHash == opHash) + ?? block.DoubleEndorsings?.FirstOrDefault(x => x.OpHash == opHash) + ?? block.DoublePreendorsings?.FirstOrDefault(x => x.OpHash == opHash) + ?? Db.DoubleBakingOps.FirstOrDefault(x => x.OpHash == opHash) + ?? Db.DoubleEndorsingOps.FirstOrDefault(x => x.OpHash == opHash) + ?? (BaseOperation)Db.DoublePreendorsingOps.FirstOrDefault(x => x.OpHash == opHash) + ?? throw new Exception($"Cannot find delayed operation '{opHash}'"); + + var (accusedLevel, accuserId, offenderId) = accusation switch + { + DoubleBakingOperation op => (op.AccusedLevel, op.AccuserId, op.OffenderId), + DoubleEndorsingOperation op => (op.AccusedLevel, op.AccuserId, op.OffenderId), + DoublePreendorsingOperation op => (op.AccusedLevel, op.AccuserId, op.OffenderId), + _ => throw new InvalidOperationException() + }; + var accuser = Cache.Accounts.GetDelegate(accuserId); + var offender = Cache.Accounts.GetDelegate(offenderId); + + var contractUpdates = slashing.Where(x => x.RequiredString("kind") == "contract"); + var reward = contractUpdates.Any() + ? contractUpdates.Sum(x => x.RequiredInt64("change")) + : 0; + + Db.TryAttach(accuser); + accuser.Balance += reward; + accuser.StakingBalance += reward; + + var depositsUpdates = slashing.Where(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "deposits"); + var lostStaked = depositsUpdates.Any() + ? depositsUpdates.Sum(x => -x.RequiredInt64("change")) + : 0; + var lostOwnStaked = offender.TotalStakedBalance == 0 ? lostStaked : (long)((BigInteger)lostStaked * offender.StakedBalance / offender.TotalStakedBalance); + var lostExternalStaked = lostStaked - lostOwnStaked; + + var unstakedDepositsUpdates = slashing.Where(x => x.RequiredString("kind") == "freezer" && x.RequiredString("category") == "unstaked_deposits"); + var lostUnstaked = unstakedDepositsUpdates.Any() + ? unstakedDepositsUpdates.Sum(x => -x.RequiredInt64("change")) + : 0; + var lostOwnUnstaked = offender.TotalStakedBalance == 0 ? lostUnstaked : (long)((BigInteger)lostUnstaked * offender.StakedBalance / offender.TotalStakedBalance); + var lostExternalUnstaked = lostUnstaked - lostOwnUnstaked; + + var preservedCycle = Math.Max(0, block.Cycle - block.Protocol.PreservedCycles); + var accusedCycle = await Cache.Protocols.GetCycle(accusedLevel); + var autostakingOps = await Db.AutostakingOps + .AsNoTracking() + .Where(x => x.BakerId == offender.Id && + x.Cycle >= preservedCycle && + x.Cycle <= accusedCycle) + .ToListAsync(); + + var unstakeRequests = new Dictionary(); + foreach (var op in autostakingOps) + { + if (op.Action == AutostakingAction.Unstake) + unstakeRequests.Add(op.Cycle, op.Amount); + else if (op.Action == AutostakingAction.Restake) + if (unstakeRequests.ContainsKey(op.Cycle)) + unstakeRequests[op.Cycle] -= op.Amount; + } + + var roundingLoss = 0L; + foreach (var (cycle, deposits) in unstakeRequests) + { + var cycleStart = (await Cache.Protocols.FindByCycleAsync(cycle)).GetCycleStart(cycle); + var unstakedDeposits = deposits; + + var prevSlashings = (await Db.DoubleBakingOps + .AsNoTracking() + .Where(x => x.OffenderId == offender.Id && x.AccusedLevel >= cycleStart && x.Id < accusation.Id) + .Select(x => new { x.Id, x.Level, Type = 0 }) + .ToListAsync()) + .Concat(await Db.DoubleEndorsingOps + .AsNoTracking() + .Where(x => x.OffenderId == offender.Id && x.AccusedLevel >= cycleStart && x.Id < accusation.Id) + .Select(x => new { x.Id, x.Level, Type = 1 }) + .ToListAsync()) + .Concat(await Db.DoublePreendorsingOps + .AsNoTracking() + .Where(x => x.OffenderId == offender.Id && x.AccusedLevel >= cycleStart && x.Id < accusation.Id) + .Select(x => new { x.Id, x.Level, Type = 2 }) + .ToListAsync()) + .OrderBy(x => x.Id); + + foreach (var prevSlashing in prevSlashings) + { + var protocol = await Cache.Protocols.FindByLevelAsync(prevSlashing.Level); + var percentage = prevSlashing.Type switch + { + 0 => protocol.DoubleBakingSlashedPercentage, + _ => protocol.DoubleEndorsingSlashedPercentage + }; + unstakedDeposits -= (deposits * percentage + 99) / 100; + } + + if (unstakedDeposits > 0) + { + var slashedPercentage = accusation switch + { + DoubleBakingOperation => block.Protocol.DoubleBakingSlashedPercentage, + _ => block.Protocol.DoubleEndorsingSlashedPercentage + }; + roundingLoss += (deposits * slashedPercentage + 99) / 100 - deposits * slashedPercentage / 100; + } + } + + Db.TryAttach(offender); + offender.Balance -= lostOwnStaked + lostOwnUnstaked; + offender.StakingBalance -= lostOwnStaked + lostOwnUnstaked + lostExternalStaked + lostExternalUnstaked; + offender.StakedBalance -= lostOwnStaked; + offender.UnstakedBalance -= lostOwnUnstaked; + offender.ExternalStakedBalance -= lostExternalStaked; + offender.ExternalUnstakedBalance -= lostExternalUnstaked; + offender.TotalStakedBalance -= lostOwnStaked + lostExternalStaked; + offender.DelegatedBalance -= lostExternalUnstaked; + offender.LostBalance += roundingLoss; + + var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, accuser.Id); + var offenderCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, offender.Id); + + switch (accusation) + { + case DoubleBakingOperation op: + op.SlashedLevel = block.Level; + op.Reward = reward; + op.LostStaked = lostOwnStaked; + op.LostUnstaked = lostOwnUnstaked; + op.LostExternalStaked = lostExternalStaked; + op.LostExternalUnstaked = lostExternalUnstaked; + op.RoundingLoss = roundingLoss; + if (accuserCycle != null) + { + Db.TryAttach(accuserCycle); + accuserCycle.DoubleBakingRewards += reward; + } + if (offenderCycle != null) + { + Db.TryAttach(offenderCycle); + offenderCycle.DoubleBakingLostStaked += lostOwnStaked; + offenderCycle.DoubleBakingLostUnstaked += lostOwnUnstaked; + offenderCycle.DoubleBakingLostExternalStaked += lostExternalStaked; + offenderCycle.DoubleBakingLostExternalUnstaked += lostExternalUnstaked; + } + Db.TryAttach(block); + block.Events |= BlockEvents.DoubleBakingSlashing; + break; + case DoubleEndorsingOperation op: + op.SlashedLevel = block.Level; + op.Reward = reward; + op.LostStaked = lostOwnStaked; + op.LostUnstaked = lostOwnUnstaked; + op.LostExternalStaked = lostExternalStaked; + op.LostExternalUnstaked = lostExternalUnstaked; + op.RoundingLoss = roundingLoss; + if (accuserCycle != null) + { + Db.TryAttach(accuserCycle); + accuserCycle.DoubleEndorsingRewards += reward; + } + if (offenderCycle != null) + { + Db.TryAttach(offenderCycle); + offenderCycle.DoubleEndorsingLostStaked += lostOwnStaked; + offenderCycle.DoubleEndorsingLostUnstaked += lostOwnUnstaked; + offenderCycle.DoubleEndorsingLostExternalStaked += lostExternalStaked; + offenderCycle.DoubleEndorsingLostExternalUnstaked += lostExternalUnstaked; + } + Db.TryAttach(block); + block.Events |= BlockEvents.DoubleEndorsingSlashing; + break; + case DoublePreendorsingOperation op: + op.SlashedLevel = block.Level; + op.Reward = reward; + op.LostStaked = lostOwnStaked; + op.LostUnstaked = lostOwnUnstaked; + op.LostExternalStaked = lostExternalStaked; + op.LostExternalUnstaked = lostExternalUnstaked; + op.RoundingLoss = roundingLoss; + if (accuserCycle != null) + { + Db.TryAttach(accuserCycle); + accuserCycle.DoublePreendorsingRewards += reward; + } + if (offenderCycle != null) + { + Db.TryAttach(offenderCycle); + offenderCycle.DoublePreendorsingLostStaked += lostOwnStaked; + offenderCycle.DoublePreendorsingLostUnstaked += lostOwnUnstaked; + offenderCycle.DoublePreendorsingLostExternalStaked += lostExternalStaked; + offenderCycle.DoublePreendorsingLostExternalUnstaked += lostExternalUnstaked; + } + Db.TryAttach(block); + block.Events |= BlockEvents.DoublePreendorsingSlashing; + break; + default: + throw new InvalidOperationException(); + } + + var stats = Cache.Statistics.Current; + Db.TryAttach(stats); + stats.TotalBurned += lostOwnStaked + lostExternalStaked + lostOwnUnstaked + lostExternalUnstaked - reward; + stats.TotalFrozen -= lostOwnStaked + lostExternalStaked; + stats.TotalLost += roundingLoss; + } + } + + public async Task Revert(Block block) + { + if (block.Events.HasFlag(BlockEvents.DoubleBakingSlashing)) + { + foreach (var op in await Db.DoubleBakingOps.Where(x => x.SlashedLevel == block.Level).ToListAsync()) + { + var accuser = Cache.Accounts.GetDelegate(op.AccuserId); + Db.TryAttach(accuser); + accuser.Balance -= op.Reward; + accuser.StakingBalance -= op.Reward; + + var offender = Cache.Accounts.GetDelegate(op.OffenderId); + Db.TryAttach(offender); + offender.Balance += op.LostStaked + op.LostUnstaked; + offender.StakingBalance += op.LostStaked + op.LostUnstaked + op.LostExternalStaked + op.LostExternalUnstaked; + offender.StakedBalance += op.LostStaked; + offender.UnstakedBalance += op.LostUnstaked; + offender.ExternalStakedBalance += op.LostExternalStaked; + offender.ExternalUnstakedBalance += op.LostExternalUnstaked; + offender.TotalStakedBalance += op.LostStaked + op.LostExternalStaked; + offender.DelegatedBalance += op.LostExternalUnstaked; + offender.LostBalance -= op.RoundingLoss; + + var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, accuser.Id); + if (accuserCycle != null) + { + Db.TryAttach(accuserCycle); + accuserCycle.DoubleBakingRewards -= op.Reward; + } + + var offenderCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, offender.Id); + if (offenderCycle != null) + { + Db.TryAttach(offenderCycle); + offenderCycle.DoubleBakingLostStaked -= op.LostStaked; + offenderCycle.DoubleBakingLostUnstaked -= op.LostUnstaked; + offenderCycle.DoubleBakingLostExternalStaked -= op.LostExternalStaked; + offenderCycle.DoubleBakingLostExternalUnstaked -= op.LostExternalUnstaked; + } + + op.Reward = 0; + op.LostStaked = 0; + op.LostUnstaked = 0; + op.LostExternalStaked = 0; + op.LostExternalUnstaked = 0; + op.RoundingLoss = 0; + } + } + + if (block.Events.HasFlag(BlockEvents.DoubleEndorsingSlashing)) + { + foreach (var op in await Db.DoubleEndorsingOps.Where(x => x.SlashedLevel == block.Level).ToListAsync()) + { + var accuser = Cache.Accounts.GetDelegate(op.AccuserId); + Db.TryAttach(accuser); + accuser.Balance -= op.Reward; + accuser.StakingBalance -= op.Reward; + + var offender = Cache.Accounts.GetDelegate(op.OffenderId); + Db.TryAttach(offender); + offender.Balance += op.LostStaked + op.LostUnstaked; + offender.StakingBalance += op.LostStaked + op.LostUnstaked + op.LostExternalStaked + op.LostExternalUnstaked; + offender.StakedBalance += op.LostStaked; + offender.UnstakedBalance += op.LostUnstaked; + offender.ExternalStakedBalance += op.LostExternalStaked; + offender.ExternalUnstakedBalance += op.LostExternalUnstaked; + offender.TotalStakedBalance += op.LostStaked + op.LostExternalStaked; + offender.DelegatedBalance += op.LostExternalUnstaked; + offender.LostBalance -= op.RoundingLoss; + + var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, accuser.Id); + if (accuserCycle != null) + { + Db.TryAttach(accuserCycle); + accuserCycle.DoubleEndorsingRewards -= op.Reward; + } + + var offenderCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, offender.Id); + if (offenderCycle != null) + { + Db.TryAttach(offenderCycle); + offenderCycle.DoubleEndorsingLostStaked -= op.LostStaked; + offenderCycle.DoubleEndorsingLostUnstaked -= op.LostUnstaked; + offenderCycle.DoubleEndorsingLostExternalStaked -= op.LostExternalStaked; + offenderCycle.DoubleEndorsingLostExternalUnstaked -= op.LostExternalUnstaked; + } + + op.Reward = 0; + op.LostStaked = 0; + op.LostUnstaked = 0; + op.LostExternalStaked = 0; + op.LostExternalUnstaked = 0; + op.RoundingLoss = 0; + } + } + + if (block.Events.HasFlag(BlockEvents.DoublePreendorsingSlashing)) + { + foreach (var op in await Db.DoublePreendorsingOps.Where(x => x.SlashedLevel == block.Level).ToListAsync()) + { + var accuser = Cache.Accounts.GetDelegate(op.AccuserId); + Db.TryAttach(accuser); + accuser.Balance -= op.Reward; + accuser.StakingBalance -= op.Reward; + + var offender = Cache.Accounts.GetDelegate(op.OffenderId); + Db.TryAttach(offender); + offender.Balance += op.LostStaked + op.LostUnstaked; + offender.StakingBalance += op.LostStaked + op.LostUnstaked + op.LostExternalStaked + op.LostExternalUnstaked; + offender.StakedBalance += op.LostStaked; + offender.UnstakedBalance += op.LostUnstaked; + offender.ExternalStakedBalance += op.LostExternalStaked; + offender.ExternalUnstakedBalance += op.LostExternalUnstaked; + offender.TotalStakedBalance += op.LostStaked + op.LostExternalStaked; + offender.DelegatedBalance += op.LostExternalUnstaked; + offender.LostBalance -= op.RoundingLoss; + + var accuserCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, accuser.Id); + if (accuserCycle != null) + { + Db.TryAttach(accuserCycle); + accuserCycle.DoublePreendorsingRewards -= op.Reward; + } + + var offenderCycle = await Cache.BakerCycles.GetOrDefaultAsync(block.Cycle, offender.Id); + if (offenderCycle != null) + { + Db.TryAttach(offenderCycle); + offenderCycle.DoublePreendorsingLostStaked -= op.LostStaked; + offenderCycle.DoublePreendorsingLostUnstaked -= op.LostUnstaked; + offenderCycle.DoublePreendorsingLostExternalStaked -= op.LostExternalStaked; + offenderCycle.DoublePreendorsingLostExternalUnstaked -= op.LostExternalUnstaked; + } + + op.Reward = 0; + op.LostStaked = 0; + op.LostUnstaked = 0; + op.LostExternalStaked = 0; + op.LostExternalUnstaked = 0; + op.RoundingLoss = 0; + } + } + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SnapshotBalanceCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SnapshotBalanceCommit.cs new file mode 100644 index 000000000..1b3794235 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SnapshotBalanceCommit.cs @@ -0,0 +1,182 @@ +using Microsoft.EntityFrameworkCore; +using System.Text.Json; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SnapshotBalanceCommit : Proto12.SnapshotBalanceCommit + { + public SnapshotBalanceCommit(ProtocolHandler protocol) : base(protocol) { } + + protected override Task TakeSnapshot(Block block) + { + return Db.Database.ExecuteSqlRawAsync($""" + INSERT INTO "SnapshotBalances" ( + "Level", + "AccountId", + "BakerId", + "OwnDelegatedBalance", + "ExternalDelegatedBalance", + "DelegatorsCount", + "OwnStakedBalance", + "ExternalStakedBalance", + "StakersCount", + "StakedPseudotokens", + "IssuedPseudotokens" + ) + + SELECT + {block.Level}, + "Id", + COALESCE("DelegateId", "Id"), + "Balance" - COALESCE("StakedBalance", 0) - (CASE + WHEN "UnstakedBakerId" IS NOT NULL + AND "UnstakedBakerId" != "DelegateId" + AND "UnstakedBakerId" != "Id" + THEN "UnstakedBalance" + ELSE 0 + END), + COALESCE("DelegatedBalance", 0), + COALESCE("DelegatorsCount", 0), + COALESCE("StakedBalance", 0), + COALESCE("ExternalStakedBalance", 0), + COALESCE("StakersCount", 0), + COALESCE("StakedPseudotokens", 0), + COALESCE("IssuedPseudotokens", 0) + FROM "Accounts" + WHERE "Staked" = true + + UNION ALL + + SELECT + {block.Level}, + account."Id", + account."UnstakedBakerId", + account."UnstakedBalance", + 0, + 0, + 0, + 0, + 0, + 0, + 0 + FROM "Accounts" as account + INNER JOIN "Accounts" as unstakedBaker + ON unstakedBaker."Id" = account."UnstakedBakerId" + WHERE unstakedBaker."Staked" = true + AND account."UnstakedBakerId" != account."DelegateId" + AND account."UnstakedBakerId" != account."Id" + """); + } + + protected override async Task TakeDeactivatedSnapshot(Block block) + { + var deactivated = await Db.Delegates + .AsNoTracking() + .Where(x => x.DeactivationLevel == block.Level) + .ToListAsync(); + + if (deactivated.Count > 0) + { + var values = new List(); + foreach (var baker in deactivated) + { + var delegators = await Db.Accounts.Where(x => x.DelegateId == baker.Id).ToListAsync(); + var unstakers = baker.ExternalUnstakedBalance > 0 + ? await Db.Users.Where(x => x.UnstakedBakerId == baker.Id).ToListAsync() + : new(0); + + values.Add("(" + string.Join(',', + block.Level, + baker.Id, + baker.Id, + baker.Balance - baker.StakedBalance - (baker.UnstakedBakerId != null && baker.UnstakedBakerId != baker.Id ? baker.UnstakedBalance : 0), + baker.DelegatedBalance, + baker.DelegatorsCount, + baker.StakedBalance, + baker.ExternalStakedBalance, + baker.StakersCount, + baker.StakedPseudotokens, + baker.IssuedPseudotokens) + ")"); + + foreach (var delegator in delegators) + { + values.Add("(" + string.Join(',', + block.Level, + delegator.Id, + delegator.DelegateId, + delegator.Balance - (delegator is User user + ? (user.StakedBalance - (user.UnstakedBakerId != null && user.UnstakedBakerId != user.DelegateId ? user.UnstakedBalance : 0)) + : 0), + 0, + 0, + (delegator as User)?.StakedBalance, + 0, + 0, + (delegator as User)?.StakedPseudotokens ?? 0, + (delegator as Data.Models.Delegate)?.IssuedPseudotokens ?? 0) + ")"); + } + + foreach (var unstaker in unstakers) + { + values.Add("(" + string.Join(',', + block.Level, + unstaker.Id, + unstaker.UnstakedBakerId, + unstaker.UnstakedBalance, + 0, + 0, + 0, + 0, + 0, + 0, + 0) + ")"); + } + } + if (values.Count > 0) + { + await Db.Database.ExecuteSqlRawAsync($""" + INSERT INTO "SnapshotBalances" ( + "Level", + "AccountId", + "BakerId", + "OwnDelegatedBalance", + "ExternalDelegatedBalance", + "DelegatorsCount", + "OwnStakedBalance", + "ExternalStakedBalance", + "StakersCount", + "StakedPseudotokens", + "IssuedPseudotokens" + ) + VALUES + {string.Join(",\n", values)} + """); + } + } + } + + protected override async Task SubtractCycleRewards(JsonElement rawBlock, Block block) + { + if (!block.Events.HasFlag(BlockEvents.CycleEnd)) + return; + + await Db.Database.ExecuteSqlRawAsync($""" + UPDATE "SnapshotBalances" as sb + SET + "OwnDelegatedBalance" = "OwnDelegatedBalance" - bc."EndorsementRewardsLiquid", + "OwnStakedBalance" = "OwnStakedBalance" - bc."EndorsementRewardsStakedOwn", + "ExternalStakedBalance" = "ExternalStakedBalance" - bc."EndorsementRewardsStakedShared" + FROM ( + SELECT "BakerId", "EndorsementRewardsLiquid", "EndorsementRewardsStakedOwn", "EndorsementRewardsStakedShared" + FROM "BakerCycles" + WHERE "Cycle" = {block.Cycle} + AND ("EndorsementRewardsLiquid" != 0 OR "EndorsementRewardsStakedOwn" != 0 OR "EndorsementRewardsStakedShared" != 0) + ) as bc + WHERE sb."Level" = {block.Level} + AND sb."AccountId" = bc."BakerId" + AND sb."BakerId" = bc."BakerId" + """); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SoftwareCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SoftwareCommit.cs new file mode 100644 index 000000000..b84fb3e07 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SoftwareCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SoftwareCommit : Proto5.SoftwareCommit + { + public SoftwareCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/StateCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/StateCommit.cs new file mode 100644 index 000000000..e9e471fa0 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/StateCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class StateCommit : Proto1.StateCommit + { + public StateCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/StatisticsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/StatisticsCommit.cs new file mode 100644 index 000000000..ca175efac --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/StatisticsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class StatisticsCommit : Proto1.StatisticsCommit + { + public StatisticsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SubsidyCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SubsidyCommit.cs new file mode 100644 index 000000000..ccc4c745f --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/SubsidyCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class SubsidyCommit : Proto10.SubsidyCommit + { + public SubsidyCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/TicketsCommit.cs new file mode 100644 index 000000000..347460351 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/TicketsCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class TicketsCommit : Proto16.TicketsCommit + { + public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } + } +} \ No newline at end of file diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/TokensCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/TokensCommit.cs new file mode 100644 index 000000000..8f3b2848e --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/TokensCommit.cs @@ -0,0 +1,7 @@ +namespace Tzkt.Sync.Protocols.Proto18 +{ + class TokensCommit : Proto5.TokensCommit + { + public TokensCommit(ProtocolHandler protocol) : base(protocol) { } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/VotingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/VotingCommit.cs new file mode 100644 index 000000000..476bb4ffb --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Commits/VotingCommit.cs @@ -0,0 +1,34 @@ +using System.Numerics; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class VotingCommit : Proto13.VotingCommit + { + public VotingCommit(ProtocolHandler protocol) : base(protocol) { } + + protected override long GetVotingPower(Data.Models.Delegate baker, Block block, Protocol protocol) + { + if (!Cache.AppState.Get().AIActivated || block.Cycle < Cache.AppState.Get().AIActivationCycle) + return base.GetVotingPower(baker, block, protocol); + + return baker.TotalStakedBalance + (baker.StakingBalance - baker.TotalStakedBalance) / 2; + } + + protected override bool BakerIsListed(Data.Models.Delegate baker, Block block, Protocol protocol) + { + if (!Cache.AppState.Get().AIActivated || block.Cycle < Cache.AppState.Get().AIActivationCycle) + return base.BakerIsListed(baker, block, protocol); + + if (!baker.Staked) + return false; + + var stakingOverBaking = Math.Min(protocol.MaxExternalOverOwnStakeRatio * 1_000_000, baker.LimitOfStakingOverBaking ?? long.MaxValue); + + var frozen = Math.Min(baker.TotalStakedBalance, baker.StakedBalance + (long)((BigInteger)baker.StakedBalance * stakingOverBaking / 1_000_000)); + var delegated = Math.Min(baker.StakingBalance - frozen, baker.StakedBalance * protocol.MaxDelegatedOverFrozenRatio); + + return frozen >= protocol.MinimalFrozenStake && frozen + delegated >= protocol.MinimalStake; + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Diagnostics/Diagnostics.cs new file mode 100644 index 000000000..6ed57cfbf --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Diagnostics/Diagnostics.cs @@ -0,0 +1,135 @@ +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Netezos.Encoding; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class Diagnostics : Proto16.Diagnostics + { + public Diagnostics(ProtocolHandler handler) : base(handler) { } + + protected override bool CheckDelegatedBalance(JsonElement remote, Data.Models.Delegate delegat) + { + return remote.RequiredInt64("delegated_balance") == delegat.DelegatedBalance + delegat.ExternalStakedBalance + delegat.LostBalance; + } + + protected override async Task TestDelegate(int level, Data.Models.Delegate delegat, Protocol proto) + { + await base.TestDelegate(level, delegat, proto); + + var stakingBalance = await Rpc.GetCurrentStakingBalance(level, delegat.Address); + + if (stakingBalance.RequiredInt64("own_frozen") != delegat.StakedBalance) + throw new Exception($"Diagnostics failed: wrong own_frozen balance for {delegat.Address}"); + + if (stakingBalance.RequiredInt64("staked_frozen") != delegat.ExternalStakedBalance) + throw new Exception($"Diagnostics failed: wrong staked_frozen balance for {delegat.Address}"); + + if (stakingBalance.RequiredInt64("delegated") != delegat.StakingBalance - delegat.TotalStakedBalance) + throw new Exception($"Diagnostics failed: wrong delegated balance for {delegat.Address}"); + + if (level > proto.FirstLevel) + { + var stakingParameters = await Rpc.GetStakingParameters(level - 1, delegat.Address); + + if (stakingParameters.TryGetProperty("active", out var active)) + { + if (active.RequiredInt64("limit_of_staking_over_baking_millionth") != delegat.LimitOfStakingOverBaking) + throw new Exception($"Diagnostics failed: wrong limit_of_staking_over_baking_millionth for {delegat.Address}"); + + if (active.RequiredInt64("edge_of_baking_over_staking_billionth") != delegat.EdgeOfBakingOverStaking) + throw new Exception($"Diagnostics failed: wrong edge_of_baking_over_staking_billionth for {delegat.Address}"); + } + else + { + if (delegat.LimitOfStakingOverBaking != null || delegat.EdgeOfBakingOverStaking != null) + throw new Exception($"Diagnostics failed: wrong staking parameters for {delegat.Address}"); + } + } + } + + protected override async Task TestParticipation(AppState state) + { + var bakers = Cache.Accounts.GetDelegates().ToList(); + var bakerCycles = Db.ChangeTracker.Entries() + .Where(x => x.Entity is BakerCycle bc && bc.Cycle == state.Cycle) + .Select(x => x.Entity as BakerCycle) + .ToDictionary(x => x.BakerId); + + foreach (var baker in bakers) + { + var remote = await Rpc.GetDelegateParticipationAsync(state.Level, baker.Address); + + if (!bakerCycles.TryGetValue(baker.Id, out var bakerCycle)) + bakerCycle = await Db.BakerCycles.FirstOrDefaultAsync(x => x.Cycle == state.Cycle && x.BakerId == baker.Id); + + if (bakerCycle != null) + { + // Endorsing rewards are wrong for the first preserved+1 cycles after AI activation + if (state.Cycle >= state.AIActivationCycle && state.Cycle <= state.AIActivationCycle + 6) + continue; + + if ((long)bakerCycle.ExpectedEndorsements != remote.RequiredInt64("expected_cycle_activity")) + throw new Exception($"Invalid baker ExpectedEndorsements {baker.Address}"); + + if (bakerCycle.FutureEndorsementRewards != remote.RequiredInt64("expected_attesting_rewards")) + { + if (remote.RequiredInt64("expected_attesting_rewards") != 0 || remote.RequiredInt32("expected_cycle_activity") - remote.RequiredInt32("missed_slots") >= remote.RequiredInt32("minimal_cycle_activity")) + throw new Exception($"Invalid baker FutureEndorsementRewards {baker.Address}"); + } + + if (bakerCycle.MissedEndorsements != remote.RequiredInt64("missed_slots")) + { + var proto = await Cache.Protocols.GetAsync(state.Protocol); + if (bakerCycle.Cycle != proto.FirstCycle && bakerCycle.BakingPower > 0) + throw new Exception($"Invalid baker MissedEndorsements {baker.Address}"); + } + } + else + { + if (remote.RequiredInt64("expected_cycle_activity") != 0) + throw new Exception($"Invalid baker ExpectedEndorsements {baker.Address}"); + + if (remote.RequiredInt64("expected_attesting_rewards") != 0) + throw new Exception($"Invalid baker FutureEndorsementRewards {baker.Address}"); + + if (remote.RequiredInt64("missed_slots") != 0) + throw new Exception($"Invalid baker MissedEndorsements {baker.Address}"); + } + } + } + + protected override async Task TestCycle(AppState state, Cycle cycle) + { + var proto = await Cache.Protocols.GetAsync(state.Protocol); + + var level = Math.Min(state.Level, cycle.FirstLevel); + var remote = await Rpc.GetCycleAsync(level, cycle.Index); + + if (remote.RequiredString("random_seed") != Hex.Convert(cycle.Seed)) + throw new Exception($"Invalid cycle {cycle.Index} seed {Hex.Convert(cycle.Seed)}"); + + if (remote.RequiredArray("selected_stake_distribution").Count() != cycle.TotalBakers) + throw new Exception($"Invalid cycle {cycle.Index} selected bakers {cycle.TotalBakers}"); + + if (state.AIActivated && cycle.Index > state.AIActivationCycle + proto.PreservedCycles) + { + var totalPower = remote.RequiredArray("selected_stake_distribution").EnumerateArray().Sum(x => + { + var frozen = x.Required("active_stake").RequiredInt64("frozen"); + var delegated = x.Required("active_stake").RequiredInt64("delegated"); + return frozen + delegated / 2; + }); + + if (totalPower != cycle.TotalBakingPower) + throw new Exception($"Invalid cycle {cycle.Index} selected stake {cycle.TotalBakingPower}"); + } + else + { + if (remote.Required("total_active_stake").RequiredInt64("frozen") + remote.Required("total_active_stake").RequiredInt64("delegated") != cycle.TotalBakingPower) + throw new Exception($"Invalid cycle {cycle.Index} selected stake {cycle.TotalBakingPower}"); + } + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Proto18Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Proto18Handler.cs new file mode 100644 index 000000000..8bb459e0c --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Proto18Handler.cs @@ -0,0 +1,592 @@ +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using App.Metrics; +using Tzkt.Data; +using Tzkt.Data.Models; +using Tzkt.Data.Models.Base; +using Tzkt.Sync.Services; +using Tzkt.Sync.Protocols.Proto18; + +namespace Tzkt.Sync.Protocols +{ + class Proto18Handler : ProtocolHandler + { + public override IDiagnostics Diagnostics { get; } + public override IValidator Validator { get; } + public override IRpc Rpc { get; } + public override string Version => "oxford_018"; + + public Proto18Handler(TezosNode node, TzktContext db, CacheService cache, QuotesService quotes, IServiceProvider services, IConfiguration config, ILogger logger, IMetrics metrics) + : base(node, db, cache, quotes, services, config, logger, metrics) + { + 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 PostActivation(AppState state) => Task.CompletedTask; + public override Task PreDeactivation(AppState state) => Task.CompletedTask; + public override Task Deactivate(AppState state) => new ProtoActivator(this).Deactivate(state); + + public override async Task Commit(JsonElement block) + { + await new StatisticsCommit(this).Apply(block); + + var blockCommit = new BlockCommit(this); + await blockCommit.Apply(block); + + var cycleCommit = new CycleCommit(this); + await cycleCommit.Apply(blockCommit.Block); + + await new StakingCommit(this).ActivateStakingParameters(blockCommit.Block); + + await new SoftwareCommit(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": + await new EndorsementsCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "preendorsement": + new PreendorsementsCommit(this).Apply(blockCommit.Block, operation, content); + break; + default: + throw new NotImplementedException($"'{content.RequiredString("kind")}' is not allowed in operations[0]"); + } + } + } + #endregion + + #region operations 1 + var dictatorSeen = false; + foreach (var operation in operations[1].EnumerateArray()) + { + foreach (var content in operation.RequiredArray("contents", 1).EnumerateArray()) + { + switch (content.RequiredString("kind")) + { + case "proposals": + var proposalsCommit = new ProposalsCommit(this); + await proposalsCommit.Apply(blockCommit.Block, operation, content); + dictatorSeen = proposalsCommit.DictatorSeen; + 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]"); + } + } + if (dictatorSeen) break; + } + #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 "double_preendorsement_evidence": + await new DoublePreendorsingCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "seed_nonce_revelation": + await new NonceRevelationsCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "vdf_revelation": + await new VdfRevelationCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "drain_delegate": + await new DrainDelegateCommit(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); + var ticketsCommit = new TicketsCommit(this); + + #region operations 3 + foreach (var operation in operations[3].EnumerateArray()) + { + Manager.Init(operation); + foreach (var content in operation.RequiredArray("contents").EnumerateArray()) + { + switch (content.RequiredString("kind")) + { + case "set_deposits_limit": + await new SetDepositsLimitCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "increase_paid_storage": + await new IncreasePaidStorageCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "update_consensus_key": + await new UpdateConsensusKeyCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "reveal": + await new RevealsCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "register_global_constant": + await new RegisterConstantsCommit(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 src = content.RequiredString("source"); + var dst = content.RequiredString("destination"); + if (src == dst && + src.StartsWith("tz") && + content.Optional("parameters")?.RequiredString("entrypoint") is string entrypoint && + StakingCommit.Entrypoints.Contains(entrypoint)) + { + await new StakingCommit(this).Apply(blockCommit.Block, operation, content); + break; + } + + 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 (parent.TicketUpdates != null) + ticketsCommit.Append(parent.Transaction, parent.Transaction, parent.TicketUpdates); + + 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); + if (internalTx.TicketUpdates != null) + ticketsCommit.Append(parent.Transaction, internalTx.Transaction, internalTx.TicketUpdates); + break; + case "event": + await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); + break; + default: + throw new NotImplementedException($"internal '{content.RequiredString("kind")}' is not implemented"); + } + } + } + break; + case "transfer_ticket": + var parent1 = new TransferTicketCommit(this); + await parent1.Apply(blockCommit.Block, operation, content); + if (parent1.TicketUpdates != null) + ticketsCommit.Append(parent1.Operation, parent1.Operation, parent1.TicketUpdates); + if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) + { + foreach (var internalContent in internalResult1.EnumerateArray()) + { + switch (internalContent.RequiredString("kind")) + { + case "transaction": + var internalTx = new TransactionsCommit(this); + await internalTx.ApplyInternal(blockCommit.Block, parent1.Operation, internalContent); + if (internalTx.BigMapDiffs != null) + bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); + if (internalTx.TicketUpdates != null) + ticketsCommit.Append(parent1.Operation, internalTx.Transaction, internalTx.TicketUpdates); + break; + default: + throw new NotImplementedException($"internal '{content.RequiredString("kind")}' inside 'transfer_ticket' is not expected"); + } + } + } + break; + case "smart_rollup_add_messages": + await new SmartRollupAddMessagesCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "smart_rollup_cement": + await new SmartRollupCementCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "smart_rollup_execute_outbox_message": + var parent2 = new SmartRollupExecuteCommit(this); + await parent2.Apply(blockCommit.Block, operation, content); + if (parent2.TicketUpdates != null) + ticketsCommit.Append(parent2.Operation, parent2.Operation, parent2.TicketUpdates); + if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult2)) + { + foreach (var internalContent in internalResult2.EnumerateArray()) + { + switch (internalContent.RequiredString("kind")) + { + case "delegation": + await new DelegationsCommit(this).ApplyInternal(blockCommit.Block, parent2.Operation, internalContent); + break; + case "origination": + var internalOrig = new OriginationsCommit(this); + await internalOrig.ApplyInternal(blockCommit.Block, parent2.Operation, 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, parent2.Operation, internalContent); + if (internalTx.BigMapDiffs != null) + bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); + if (internalTx.TicketUpdates != null) + ticketsCommit.Append(parent2.Operation, internalTx.Transaction, internalTx.TicketUpdates); + break; + case "event": + await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); + break; + default: + throw new NotImplementedException($"internal '{content.RequiredString("kind")}' is not implemented"); + } + } + } + break; + case "smart_rollup_originate": + await new SmartRollupOriginateCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "smart_rollup_publish": + await new SmartRollupPublishCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "smart_rollup_recover_bond": + await new SmartRollupRecoverBondCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "smart_rollup_refute": + await new SmartRollupRefuteCommit(this).Apply(blockCommit.Block, operation, content); + break; + case "smart_rollup_timeout": + await new SmartRollupTimeoutCommit(this).Apply(blockCommit.Block, operation, content); + break; + default: + throw new NotImplementedException($"'{content.RequiredString("kind")}' is not expected in operations[3]"); + } + } + Manager.Reset(); + } + #endregion + + await blockCommit.ApplyRewards(block); + + new InboxCommit(this).Apply(blockCommit.Block); + + await bigMapCommit.Apply(); + await ticketsCommit.Apply(); + await new TokensCommit(this).Apply(blockCommit.Block, bigMapCommit.Updates); + + var brCommit = new BakingRightsCommit(this); + await brCommit.Apply(blockCommit.Block, cycleCommit.FutureCycle, cycleCommit.SelectedStakes); + + await new DelegatorCycleCommit(this).Apply(blockCommit.Block, cycleCommit.FutureCycle); + + await new BakerCycleCommit(this).Apply( + blockCommit.Block, + cycleCommit.FutureCycle, + brCommit.FutureBakingRights, + brCommit.FutureEndorsingRights, + cycleCommit.Snapshots, + cycleCommit.SelectedStakes, + brCommit.CurrentRights); + + await new EndorsingRewardCommit(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(rawBlock, block); + await new SlashingCommit(this).Apply(block, rawBlock); + await new VotingCommit(this).Apply(block, rawBlock); + new AutostakingCommit(this).Apply(block, rawBlock); + } + + public override async Task BeforeRevert() + { + var block = await Cache.Blocks.CurrentAsync(); + await new AutostakingCommit(this).Revert(block); + await new VotingCommit(this).Revert(block); + await new SlashingCommit(this).Revert(block); + 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.Preendorsements)) + operations.AddRange(await Db.PreendorsementOps.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.SetDepositsLimits)) + operations.AddRange(await Db.SetDepositsLimitOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.RegisterConstant)) + operations.AddRange(await Db.RegisterConstantOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.IncreasePaidStorage)) + operations.AddRange(await Db.IncreasePaidStorageOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.UpdateConsensusKey)) + operations.AddRange(await Db.UpdateConsensusKeyOps.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.VdfRevelation)) + operations.AddRange(await Db.VdfRevelationOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.Staking)) + operations.AddRange(await Db.StakingOps.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.TransferTicket)) + operations.AddRange(await Db.TransferTicketOps.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.DoublePreendorsings)) + operations.AddRange(await Db.DoublePreendorsingOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.DrainDelegate)) + operations.AddRange(await Db.DrainDelegateOps.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.Operations.HasFlag(Operations.SmartRollupAddMessages)) + operations.AddRange(await Db.SmartRollupAddMessagesOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.SmartRollupCement)) + operations.AddRange(await Db.SmartRollupCementOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.SmartRollupExecute)) + operations.AddRange(await Db.SmartRollupExecuteOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.SmartRollupOriginate)) + operations.AddRange(await Db.SmartRollupOriginateOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.SmartRollupPublish)) + operations.AddRange(await Db.SmartRollupPublishOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.SmartRollupRecoverBond)) + operations.AddRange(await Db.SmartRollupRecoverBondOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + if (currBlock.Operations.HasFlag(Operations.SmartRollupRefute)) + operations.AddRange(await Db.SmartRollupRefuteOps.Where(x => x.Level == currBlock.Level).ToListAsync()); + + 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 StakingCommit(this).DeactivateStakingParameters(currBlock); + + await new StatisticsCommit(this).Revert(currBlock); + + await new EndorsingRewardCommit(this).Revert(currBlock); + + await new BakerCycleCommit(this).Revert(currBlock); + await new DelegatorCycleCommit(this).Revert(currBlock); + await new BakingRightsCommit(this).Revert(currBlock); + await new TokensCommit(this).Revert(currBlock); + await new TicketsCommit(this).Revert(currBlock); + await new BigMapCommit(this).Revert(currBlock); + await new ContractEventCommit(this).Revert(currBlock); + await new InboxCommit(this).Revert(currBlock); + await new BlockCommit(this).RevertRewards(currBlock); + + foreach (var operation in operations.OrderByDescending(x => x.Id)) + { + switch (operation) + { + case EndorsementOperation op: + await new EndorsementsCommit(this).Revert(currBlock, op); + break; + case PreendorsementOperation op: + await new PreendorsementsCommit(this).Revert(currBlock, op); + break; + case ProposalOperation op: + await new ProposalsCommit(this).Revert(currBlock, op); + break; + case BallotOperation op: + await new BallotsCommit(this).Revert(currBlock, op); + break; + case ActivationOperation op: + await new ActivationsCommit(this).Revert(currBlock, op); + break; + case DoubleBakingOperation op: + new DoubleBakingCommit(this).Revert(op); + break; + case DoubleEndorsingOperation op: + new DoubleEndorsingCommit(this).Revert(op); + break; + case DoublePreendorsingOperation op: + new DoublePreendorsingCommit(this).Revert(op); + break; + case NonceRevelationOperation op: + await new NonceRevelationsCommit(this).Revert(currBlock, op); + break; + case VdfRevelationOperation op: + await new VdfRevelationCommit(this).Revert(currBlock, op); + break; + case DrainDelegateOperation op: + await new DrainDelegateCommit(this).Revert(currBlock, op); + break; + case RevealOperation op: + await new RevealsCommit(this).Revert(currBlock, op); + break; + case IncreasePaidStorageOperation op: + await new IncreasePaidStorageCommit(this).Revert(currBlock, op); + break; + case UpdateConsensusKeyOperation op: + await new UpdateConsensusKeyCommit(this).Revert(currBlock, op); + break; + case RegisterConstantOperation registerConstant: + await new RegisterConstantsCommit(this).Revert(currBlock, registerConstant); + break; + case SetDepositsLimitOperation setDepositsLimit: + await new SetDepositsLimitCommit(this).Revert(currBlock, setDepositsLimit); + break; + case DelegationOperation op: + if (op.InitiatorId == null) + await new DelegationsCommit(this).Revert(currBlock, op); + else + await new DelegationsCommit(this).RevertInternal(currBlock, op); + break; + case OriginationOperation op: + if (op.InitiatorId == null) + await new OriginationsCommit(this).Revert(currBlock, op); + else + await new OriginationsCommit(this).RevertInternal(currBlock, op); + break; + case StakingOperation op: + await new StakingCommit(this).Revert(currBlock, op); + break; + case TransactionOperation op: + if (op.InitiatorId == null) + await new TransactionsCommit(this).Revert(currBlock, op); + else + await new TransactionsCommit(this).RevertInternal(currBlock, op); + break; + case TransferTicketOperation op: + await new TransferTicketCommit(this).Revert(currBlock, op); + break; + case SmartRollupAddMessagesOperation op: + await new SmartRollupAddMessagesCommit(this).Revert(currBlock, op); + break; + case SmartRollupCementOperation op: + await new SmartRollupCementCommit(this).Revert(currBlock, op); + break; + case SmartRollupExecuteOperation op: + await new SmartRollupExecuteCommit(this).Revert(currBlock, op); + break; + case SmartRollupOriginateOperation op: + await new SmartRollupOriginateCommit(this).Revert(currBlock, op); + break; + case SmartRollupPublishOperation op: + await new SmartRollupPublishCommit(this).Revert(currBlock, op); + break; + case SmartRollupRecoverBondOperation op: + await new SmartRollupRecoverBondCommit(this).Revert(currBlock, op); + break; + case SmartRollupRefuteOperation op: + await new SmartRollupRefuteCommit(this).Revert(currBlock, op); + break; + default: + throw new NotImplementedException($"'{operation.GetType()}' is not implemented"); + } + } + + await new SubsidyCommit(this).Revert(currBlock); + + await new DeactivationCommit(this).Revert(currBlock); + await new SoftwareCommit(this).Revert(currBlock); + await new CycleCommit(this).Revert(currBlock); + new BlockCommit(this).Revert(currBlock); + + await new StateCommit(this).Revert(currBlock); + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Rpc/Rpc.cs new file mode 100644 index 000000000..8901b9591 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Rpc/Rpc.cs @@ -0,0 +1,19 @@ +using System.Text.Json; +using Tzkt.Sync.Services; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class Rpc : Proto16.Rpc + { + public Rpc(TezosNode node) : base(node) { } + + public override Task GetExpectedIssuance(int level) + => Node.GetAsync($"chains/main/blocks/{level}/context/issuance/expected_issuance"); + + public override Task GetCurrentStakingBalance(int level, string address) + => Node.GetAsync($"chains/main/blocks/{level}/context/raw/json/staking_balance/current/{address}"); + + public override Task GetStakingParameters(int level, string address) + => Node.GetAsync($"chains/main/blocks/{level}/context/raw/json/contracts/index/{address}/staking_parameters"); + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto18/Validation/Validator.cs b/Tzkt.Sync/Protocols/Handlers/Proto18/Validation/Validator.cs new file mode 100644 index 000000000..f3c476c75 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto18/Validation/Validator.cs @@ -0,0 +1,1088 @@ +using System.Text.Json; +using Tzkt.Data.Models; +using Tzkt.Sync.Services; + +namespace Tzkt.Sync.Protocols.Proto18 +{ + class Validator : IValidator + { + readonly CacheService Cache; + Protocol Protocol; + string Proposer; + string Producer; + int Level; + int Cycle; + + public Validator(ProtocolHandler protocol) => Cache = protocol.Cache; + + public virtual async Task ValidateBlock(JsonElement block) + { + Protocol = await Cache.Protocols.GetAsync(Cache.AppState.GetNextProtocol()); + + if (block.RequiredString("chain_id") != Cache.AppState.GetChainId()) + throw new ValidationException("invalid chain"); + + if (block.RequiredString("protocol") != Cache.AppState.GetNextProtocol()) + throw new ValidationException("invalid block protocol", true); + + ValidateBlockHeader(block.Required("header")); + await ValidateBlockMetadata(block.Required("metadata")); + await ValidateOperations(block.RequiredArray("operations", 4)); + } + + void ValidateBlockHeader(JsonElement header) + { + Level = header.RequiredInt32("level"); + if (Level != Cache.AppState.GetNextLevel()) + throw new ValidationException($"invalid block level", true); + + if (header.RequiredString("predecessor") != Cache.AppState.GetHead()) + throw new ValidationException($"invalid block predecessor", true); + } + + async Task ValidateBlockMetadata(JsonElement metadata) + { + #region baking + Proposer = metadata.RequiredString("proposer"); + if (!Cache.Accounts.DelegateExists(Proposer)) + throw new ValidationException($"non-existent block proposer"); + + Producer = metadata.RequiredString("baker"); + if (!Cache.Accounts.DelegateExists(Producer)) + throw new ValidationException($"non-existent block baker"); + #endregion + + #region level info + Cycle = metadata.Required("level_info").RequiredInt32("cycle"); + if (Cycle != Protocol.GetCycle(Level)) + throw new ValidationException($"invalid block cycle", true); + #endregion + + #region voting info + var periodInfo = metadata.Required("voting_period_info").Required("voting_period"); + var periodIndex = periodInfo.RequiredInt32("index"); + var periodKind = periodInfo.RequiredString("kind") switch + { + "proposal" => PeriodKind.Proposal, + "exploration" => PeriodKind.Exploration, + "cooldown" => PeriodKind.Testing, + "promotion" => PeriodKind.Promotion, + "adoption" => PeriodKind.Adoption, + _ => throw new ValidationException("invalid voting period kind") + }; + + var period = await Cache.Periods.GetAsync(Cache.AppState.Get().VotingPeriod); + if (Level > period.FirstLevel && Level < period.LastLevel) + { + if (periodIndex != period.Index) + throw new ValidationException("invalid voting period index"); + + if (!Protocol.HasDictator && periodKind != period.Kind) + throw new ValidationException("unexpected voting period"); + } + #endregion + + #region deactivation + foreach (var baker in metadata.RequiredArray("deactivated").EnumerateArray()) + if (!Cache.Accounts.DelegateExists(baker.GetString())) + throw new ValidationException($"non-existent deactivated baker {baker}"); + #endregion + + #region balance updates + var balanceUpdates = metadata.RequiredArray("balance_updates").EnumerateArray(); + if (balanceUpdates.Any(x => x.RequiredString("kind") == "contract" && x.RequiredString("origin") == "block" && !Cache.Accounts.DelegateExists(x.RequiredString("contract")))) + throw new ValidationException("non-existent delegate in block balance updates"); + + if (Cycle < Protocol.NoRewardCycles) + { + if (balanceUpdates.Any(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking rewards")) + throw new ValidationException("unexpected block reward"); + + if (balanceUpdates.Any(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking bonuses")) + throw new ValidationException("unexpected block bonus"); + } + else + { + if (balanceUpdates.Count(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking rewards") > 2) + throw new ValidationException("invalid block reward"); + + if (balanceUpdates.Count(x => x.RequiredString("kind") == "minted" && x.RequiredString("category") == "baking bonuses") > 2) + throw new ValidationException("invalid block bonus"); + } + #endregion + + #region implicit operations + foreach (var op in metadata.RequiredArray("implicit_operations_results").EnumerateArray()) + { + var kind = op.RequiredString("kind"); + if (kind == "transaction") + { + var subsidy = op.RequiredArray("balance_updates", 2).EnumerateArray() + .Where(x => x.RequiredString("kind") == "contract"); + + if (subsidy.Count() > 1) + throw new ValidationException("invalid subsidy"); + + if (subsidy.Any(x => x.RequiredString("origin") != "subsidy")) + throw new ValidationException("invalid subsidy origin"); + + if (subsidy.Any(x => x.RequiredString("contract") != Proto10.ProtoActivator.CpmmContract)) + throw new ValidationException("invalid subsidy recepient"); + } + else if (kind == "origination" && Level == Protocol.FirstLevel) + { + var contract = op.RequiredArray("originated_contracts", 1)[0].RequiredString(); + if (!await Cache.Accounts.ExistsAsync(contract, AccountType.Contract)) + throw new ValidationException("unexpected implicit origination"); + } + else + { + throw new ValidationException("unexpected implicit operation kind"); + } + } + #endregion + } + + protected virtual async Task ValidateOperations(JsonElement operations) + { + foreach (var opg in operations.EnumerateArray()) + { + foreach (var op in opg.RequiredArray().EnumerateArray()) + { + foreach (var content in op.RequiredArray("contents").EnumerateArray()) + { + switch (content.RequiredString("kind")) + { + case "endorsement": ValidateEndorsement(content); break; + case "preendorsement": ValidatePreendorsement(content); break; + case "ballot": await ValidateBallot(content); break; + case "proposals": ValidateProposal(content); break; + case "activate_account": await ValidateActivation(content); break; + case "double_baking_evidence": ValidateDoubleBaking(content); break; + case "double_endorsement_evidence": ValidateDoubleBaking(content); break; + case "double_preendorsement_evidence": ValidateDoubleBaking(content); break; + case "seed_nonce_revelation": await ValidateSeedNonceRevelation(content); break; + case "vdf_revelation": ValidateVdfRevelation(content); break; + case "drain_delegate": ValidateDrainDelegate(content); break; + case "delegation": await ValidateDelegation(content); break; + case "origination": await ValidateOrigination(content); break; + case "transaction": await ValidateTransaction(content); break; + case "reveal": await ValidateReveal(content); break; + case "register_global_constant": await ValidateRegisterConstant(content); break; + case "set_deposits_limit": await ValidateSetDepositsLimit(content); break; + case "increase_paid_storage": await ValidateIncreasePaidStorage(content); break; + case "update_consensus_key": await ValidateUpdateConsensusKey(content); break; + case "tx_rollup_origination": await ValidateTxRollupOrigination(content); break; + case "tx_rollup_submit_batch": await ValidateTxRollupSubmitBatch(content); break; + case "tx_rollup_commit": await ValidateTxRollupCommit(content); break; + case "tx_rollup_finalize_commitment": await ValidateTxRollupFinalizeCommitment(content); break; + case "tx_rollup_remove_commitment": await ValidateTxRollupRemoveCommitment(content); break; + case "tx_rollup_return_bond": await ValidateTxRollupReturnBond(content); break; + case "tx_rollup_rejection": await ValidateTxRollupRejection(content); break; + case "tx_rollup_dispatch_tickets": await ValidateTxRollupDispatchTickets(content); break; + case "transfer_ticket": await ValidateTransferTicket(content); break; + case "smart_rollup_add_messages": await ValidateSmartRollupAddMessages(content); break; + case "smart_rollup_cement": await ValidateSmartRollupCement(content); break; + case "smart_rollup_execute_outbox_message": await ValidateSmartRollupExecute(content); break; + case "smart_rollup_originate": await ValidateSmartRollupOriginate(content); break; + case "smart_rollup_publish": await ValidateSmartRollupPublish(content); break; + case "smart_rollup_recover_bond": await ValidateSmartRollupRecoverBond(content); break; + case "smart_rollup_refute": await ValidateSmartRollupRefute(content); break; + case "smart_rollup_timeout": await ValidateSmartRollupTimeout(content); break; + default: + throw new ValidationException("invalid operation content kind"); + } + } + } + } + } + + protected virtual void ValidateEndorsement(JsonElement content) + { + if (content.RequiredInt32("level") != Cache.AppState.GetLevel()) + throw new ValidationException("invalid endorsement level"); + + if (!Cache.Accounts.DelegateExists(content.Required("metadata").RequiredString("delegate"))) + throw new ValidationException("unknown endorsement delegate"); + } + + protected virtual void ValidatePreendorsement(JsonElement content) + { + if (content.RequiredInt32("level") != Cache.AppState.GetLevel() + 1) + throw new ValidationException("invalid preendorsement level"); + + if (!Cache.Accounts.DelegateExists(content.Required("metadata").RequiredString("delegate"))) + throw new ValidationException("unknown endorsement delegate"); + } + + protected virtual async Task ValidateBallot(JsonElement content) + { + var periodIndex = content.RequiredInt32("period"); + + if (Cache.AppState.Get().VotingPeriod != periodIndex) + throw new ValidationException("invalid ballot voting period"); + + var proposal = await Cache.Proposals.GetOrDefaultAsync(Cache.AppState.Get().VotingEpoch, content.RequiredString("proposal")); + if (proposal?.Status != ProposalStatus.Active) + throw new ValidationException("invalid ballot proposal"); + + if (!Cache.Accounts.DelegateExists(content.RequiredString("source"))) + throw new ValidationException("invalid ballot sender"); + } + + protected virtual void ValidateProposal(JsonElement content) + { + var periodIndex = content.RequiredInt32("period"); + + if (Cache.AppState.Get().VotingPeriod != periodIndex) + throw new ValidationException("invalid proposal voting period"); + + var source = content.RequiredString("source"); + if (Protocol.Dictator != source && !Cache.Accounts.DelegateExists(source)) + throw new ValidationException("invalid proposal sender"); + } + + protected virtual async Task ValidateActivation(JsonElement content) + { + var account = content.RequiredString("pkh"); + + if (await Cache.Accounts.ExistsAsync(account, AccountType.User) && + ((await Cache.Accounts.GetAsync(account)) as User).Activated == true) + throw new ValidationException("account is already activated"); + + if (content.Required("metadata").RequiredArray("balance_updates", 2)[1].RequiredString("contract") != account) + throw new ValidationException("invalid activation balance updates"); + } + + protected virtual void ValidateDoubleBaking(JsonElement content) + { + } + + protected virtual async Task ValidateSeedNonceRevelation(JsonElement content) + { + var level = content.RequiredInt32("level"); + var proto = await Cache.Protocols.FindByLevelAsync(level); + + if (level % proto.BlocksPerCommitment != 0) + throw new ValidationException("invalid seed nonce revelation level"); + + var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); + + if (balanceUpdates.Count() > 4 || balanceUpdates.Count() % 2 != 0) + throw new ValidationException("invalid seed nonce revelation balance updates count"); + + if (balanceUpdates.Any(x => x.RequiredString("kind") == "freezer" && x.Required("staker").RequiredString("baker") != Proposer || + x.RequiredString("kind") == "contract" && x.RequiredString("contract") != Proposer)) + throw new ValidationException("invalid seed nonce revelation baker"); + } + + protected virtual void ValidateVdfRevelation(JsonElement content) + { + var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); + + if (balanceUpdates.Count() > 4 || balanceUpdates.Count() % 2 != 0) + throw new ValidationException("invalid vdf revelation balance updates count"); + + if (balanceUpdates.Any(x => x.RequiredString("kind") == "freezer" && x.Required("staker").RequiredString("baker") != Proposer || + x.RequiredString("kind") == "contract" && x.RequiredString("contract") != Proposer)) + throw new ValidationException("invalid vdf revelation baker"); + + var balanceUpdate = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray() + .SingleOrDefault(x => x.RequiredString("kind") == "contract"); + } + + protected virtual void ValidateDrainDelegate(JsonElement content) + { + var drainedBaker = content.RequiredString("delegate"); + var balanceUpdates = content.Required("metadata").RequiredArray("balance_updates").EnumerateArray(); + + if (!Cache.Accounts.DelegateExists(drainedBaker)) + throw new ValidationException("unknown drained delegate"); + + if (balanceUpdates.Count() % 2 != 0) + throw new ValidationException("invalid drain balance updates count"); + + if (balanceUpdates.Where(x => x.RequiredInt64("change") < 0).Any(x => x.RequiredString("contract") != drainedBaker)) + throw new ValidationException("invalid drain balance updates"); + } + + protected virtual async Task ValidateDelegation(JsonElement content) + { + var source = content.RequiredString("source"); + var delegat = content.OptionalString("delegate"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + if (content.Required("metadata").Required("operation_result").RequiredString("status") == "applied" && delegat != null) + if (source != delegat && !Cache.Accounts.DelegateExists(delegat)) + throw new ValidationException("unknown delegate account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual void ValidateInternalDelegation(JsonElement content, string initiator) + { + //var delegat = content.OptionalString("delegate"); + + //if (content.Required("result").RequiredString("status") == "applied" && delegat != null) + // if (!Cache.Accounts.DelegateExists(delegat)) + // throw new ValidationException("unknown delegate account"); + } + + protected virtual async Task ValidateOrigination(JsonElement content) + { + var source = content.RequiredString("source"); + var delegat = content.OptionalString("delegate"); + var metadata = content.Required("metadata"); + var result = metadata.Required("operation_result"); + var applied = result.RequiredString("status") == "applied"; + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + if (applied && delegat != null) + if (!Cache.Accounts.DelegateExists(delegat)) + throw new ValidationException("unknown delegate account"); + + ValidateFeeBalanceUpdates( + metadata.OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) + ValidateTransferBalanceUpdates( + resultUpdates.EnumerateArray(), + source, + result.RequiredArray("originated_contracts", 1)[0].RequiredString(), + content.RequiredInt64("balance"), + (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, + Protocol.OriginationSize * Protocol.ByteCost); + } + + protected virtual void ValidateInternalOrigination(JsonElement content, string initiator) + { + //var delegat = content.OptionalString("delegate"); + var result = content.Required("result"); + var applied = result.RequiredString("status") == "applied"; + + //if (applied && delegat != null) + // if (!Cache.Accounts.DelegateExists(delegat)) + // throw new ValidationException("unknown delegate account"); + + if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) + ValidateTransferBalanceUpdates( + resultUpdates.RequiredArray().EnumerateArray(), + content.RequiredString("source"), + result.RequiredArray("originated_contracts", 1)[0].RequiredString(), + content.RequiredInt64("balance"), + (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, + Protocol.OriginationSize * Protocol.ByteCost, + initiator); + } + + protected virtual Task ValidateStakeTransaction(string source, JsonElement content) + { + throw new NotImplementedException("Staking operations are disabled ix Oxford2"); + //var sender = await Cache.Accounts.GetAsync(source); + //var baker = sender as Data.Models.Delegate ?? Cache.Accounts.GetDelegate(sender.DelegateId) + // ?? throw new ValidationException("sender account is not delegated"); + + //var result = content.Required("metadata").Required("operation_result"); + //var amount = content.RequiredInt64("amount"); + //if (amount > 0) + //{ + // var updates = result.RequiredArray("balance_updates", 2).EnumerateArray(); + // var contractUpdate = updates.First(x => x.RequiredString("kind") == "contract"); + // var freezerUpdate = updates.First(x => x.RequiredString("kind") == "freezer"); + + // if (contractUpdate.RequiredInt64("change") != -freezerUpdate.RequiredInt64("change") || freezerUpdate.RequiredInt64("change") != amount) + // throw new ValidationException("inconsistent contract and freezer updates"); + + // if (freezerUpdate.Required("staker").RequiredString("contract") != sender.Address) + // throw new ValidationException("invalid staker.contract"); + + // if (freezerUpdate.Required("staker").RequiredString("delegate") != baker.Address) + // throw new ValidationException("invalid staker.delegate"); + //} + //else + //{ + // if (result.OptionalArray("balance_updates")?.EnumerateArray().Any() == true) + // throw new ValidationException("unexpected balance updates"); + //} + } + + protected virtual Task ValidateUntakeTransaction(string source, JsonElement content) + { + throw new NotImplementedException("Staking operations are disabled ix Oxford2"); + //var sender = await Cache.Accounts.GetAsync(source); + //var baker = sender as Data.Models.Delegate ?? Cache.Accounts.GetDelegate(sender.DelegateId) + // ?? throw new ValidationException("sender account is not delegated"); + + //var result = content.Required("metadata").Required("operation_result"); + //var amount = content.Required("parameters").Required("value").RequiredBigInteger("int"); + //if (amount > 0) + //{ + // if (result.TryGetProperty("balance_updates", out var balanceUpdates)) + // { + // var updates = balanceUpdates.EnumerateArray(); + + // if (!updates.Any()) + // return; + + // if (updates.Count() != 2) + // throw new ValidationException("unexpected number of unstake balance updates"); + + // var depositsUpdate = updates.First(x => x.RequiredString("category") == "deposits"); + // var unstakedUpdate = updates.First(x => x.RequiredString("category") == "unstaked_deposits"); + + // if (depositsUpdate.RequiredInt64("change") != -unstakedUpdate.RequiredInt64("change") || unstakedUpdate.RequiredInt64("change") > amount) + // throw new ValidationException("inconsistent deposits and unstaked_deposits updates"); + + // if (depositsUpdate.Required("staker").RequiredString("contract") != sender.Address) + // throw new ValidationException("invalid staker.contract for deposits update"); + + // if (depositsUpdate.Required("staker").RequiredString("delegate") != baker.Address) + // throw new ValidationException("invalid staker.delegate for deposits update"); + + // if (unstakedUpdate.Required("staker").RequiredString("contract") != sender.Address) + // throw new ValidationException("invalid staker.contract for unstaked_deposits update"); + + // if (unstakedUpdate.Required("staker").RequiredString("delegate") != baker.Address) + // throw new ValidationException("invalid staker.delegate for unstaked_deposits update"); + // } + //} + //else + //{ + // if (result.OptionalArray("balance_updates")?.EnumerateArray().Any() == true) + // throw new ValidationException("unexpected balance updates"); + //} + } + + protected virtual async Task ValidateTransaction(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + var metadata = content.Required("metadata"); + + ValidateFeeBalanceUpdates( + metadata.OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = metadata.Required("operation_result"); + var applied = result.RequiredString("status") == "applied"; + + if (applied) + { + var target = content.RequiredString("destination"); + + if (source == target && source.StartsWith("tz") && content.Optional("parameters")?.RequiredString("entrypoint") is string entrypoint) + { + switch (entrypoint) + { + case "stake": + await ValidateStakeTransaction(source, content); + return; + case "unstake": + await ValidateUntakeTransaction(source, content); + return; + case "finalize_unstake": + return; + case "set_delegate_parameters": + return; + default: + throw new ValidationException("unsupported staking operation"); + } + } + + if (result.TryGetProperty("balance_updates", out var resultUpdates)) + ValidateTransferBalanceUpdates( + resultUpdates.RequiredArray().EnumerateArray(), + source, + target, + content.RequiredInt64("amount"), + (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, + (result.OptionalBool("allocated_destination_contract") ?? false) ? Protocol.OriginationSize * Protocol.ByteCost : 0); + } + + if (metadata.TryGetProperty("internal_operation_results", out var internalResults)) + { + foreach (var internalContent in internalResults.RequiredArray().EnumerateArray()) + { + switch (internalContent.RequiredString("kind")) + { + case "delegation": ValidateInternalDelegation(internalContent, source); break; + case "origination": ValidateInternalOrigination(internalContent, source); break; + case "transaction": ValidateInternalTransaction(internalContent, source); break; + case "event": break; + default: + throw new ValidationException("invalid internal operation kind"); + } + } + } + } + + protected virtual void ValidateInternalTransaction(JsonElement content, string initiator) + { + var result = content.Required("result"); + var applied = result.RequiredString("status") == "applied"; + + if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) + ValidateTransferBalanceUpdates( + resultUpdates.RequiredArray().EnumerateArray(), + content.RequiredString("source"), + content.RequiredString("destination"), + content.RequiredInt64("amount"), + (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, + (result.OptionalBool("allocated_destination_contract") ?? false) ? Protocol.OriginationSize * Protocol.ByteCost : 0, + initiator); + } + + protected virtual async Task ValidateReveal(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual async Task ValidateRegisterConstant(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual async Task ValidateSetDepositsLimit(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual async Task ValidateIncreasePaidStorage(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual async Task ValidateUpdateConsensusKey(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual async Task ValidateTxRollupOrigination(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + var applied = result.RequiredString("status") == "applied"; + + if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) + ValidateTransferBalanceUpdates( + resultUpdates.EnumerateArray(), + source, + null, + 0, + 0, + 4_000 * Protocol.ByteCost); + } + + protected virtual async Task ValidateTxRollupSubmitBatch(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + var applied = result.RequiredString("status") == "applied"; + + if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) + ValidateTransferBalanceUpdates( + resultUpdates.EnumerateArray(), + source, + null, + 0, + (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, + 0); + } + + protected virtual async Task ValidateTxRollupCommit(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) + { + if (updates.Count() != 2) + throw new ValidationException("unexpected number of rollup bonds balance updates"); + + if (!updates.EnumerateArray().Any(x => + x.RequiredString("kind") == "contract" && + x.RequiredString("contract") == source)) + throw new ValidationException("invalid transfer balance updates"); + + if (!updates.EnumerateArray().Any(x => + x.RequiredString("kind") == "freezer" && + x.RequiredString("category") == "bonds" && + x.RequiredString("contract") == source)) + throw new ValidationException("invalid transfer balance updates"); + + if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) + throw new ValidationException("inconsistent change of rollup bonds balance updates"); + } + } + + protected virtual async Task ValidateTxRollupFinalizeCommitment(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) + throw new ValidationException("unexpected balance updates"); + } + + protected virtual async Task ValidateTxRollupRemoveCommitment(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) + throw new ValidationException("unexpected balance updates"); + } + + protected virtual async Task ValidateTxRollupReturnBond(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) + { + if (updates.Count() != 2) + throw new ValidationException("unexpected number of rollup bonds balance updates"); + + if (!updates.EnumerateArray().Any(x => + x.RequiredString("kind") == "contract" && + x.RequiredString("contract") == source)) + throw new ValidationException("invalid transfer balance updates"); + + if (!updates.EnumerateArray().Any(x => + x.RequiredString("kind") == "freezer" && + x.RequiredString("category") == "bonds" && + x.RequiredString("contract") == source)) + throw new ValidationException("invalid transfer balance updates"); + + if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) + throw new ValidationException("inconsistent change of rollup bonds balance updates"); + } + } + + protected virtual async Task ValidateTxRollupRejection(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual async Task ValidateTxRollupDispatchTickets(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual async Task ValidateTransferTicket(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual async Task ValidateSmartRollupAddMessages(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + var applied = result.RequiredString("status") == "applied"; + + if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) + ValidateTransferBalanceUpdates( + resultUpdates.EnumerateArray(), + source, + null, + 0, + 0, + 0); + } + + protected virtual async Task ValidateSmartRollupCement(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + if (result.RequiredString("status") == "applied" && + result.TryGetProperty("balance_updates", out var updates) && updates.Count() > 0) + throw new ValidationException("unexpected balnce updates"); + } + + protected virtual async Task ValidateSmartRollupExecute(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + var metadata = content.Required("metadata"); + + ValidateFeeBalanceUpdates( + metadata.OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = metadata.Required("operation_result"); + var applied = result.RequiredString("status") == "applied"; + + if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) + ValidateTransferBalanceUpdates( + resultUpdates.RequiredArray().EnumerateArray(), + source, + null, + 0, + (result.OptionalInt32("paid_storage_size_diff") ?? 0) * Protocol.ByteCost, + 0); + + if (metadata.TryGetProperty("internal_operation_results", out var internalResults)) + { + foreach (var internalContent in internalResults.RequiredArray().EnumerateArray()) + { + switch (internalContent.RequiredString("kind")) + { + case "delegation": ValidateInternalDelegation(internalContent, source); break; + case "origination": ValidateInternalOrigination(internalContent, source); break; + case "transaction": ValidateInternalTransaction(internalContent, source); break; + case "event": break; + default: + throw new ValidationException("invalid internal operation kind"); + } + } + } + } + + protected virtual async Task ValidateSmartRollupOriginate(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + var applied = result.RequiredString("status") == "applied"; + + if (applied && result.TryGetProperty("balance_updates", out var resultUpdates)) + ValidateTransferBalanceUpdates( + resultUpdates.EnumerateArray(), + source, + null, + 0, + (result.OptionalInt32("size") ?? 0) * Protocol.ByteCost, + 0); + } + + protected virtual async Task ValidateSmartRollupPublish(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) + { + if (updates.Count() != 2) + throw new ValidationException("unexpected number of smart rollup bonds balance updates"); + + if (!updates.EnumerateArray().Any(x => + x.RequiredString("kind") == "contract" && + x.RequiredString("contract") == source)) + throw new ValidationException("invalid smart rollup bonds balance updates"); + + if (!updates.EnumerateArray().Any(x => + x.RequiredString("kind") == "freezer" && + x.RequiredString("category") == "bonds" && + x.RequiredString("contract") == source)) + throw new ValidationException("invalid smart rollup bonds balance updates"); + + if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) + throw new ValidationException("inconsistent change of smart rollup bonds balance updates"); + } + } + + protected virtual async Task ValidateSmartRollupRecoverBond(JsonElement content) + { + var source = content.RequiredString("source"); + var staker = content.RequiredString("staker"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + + var result = content.Required("metadata").Required("operation_result"); + if (result.TryGetProperty("balance_updates", out var updates) && updates.Count() != 0) + { + if (updates.Count() != 2) + throw new ValidationException("unexpected number of smart rollup bonds balance updates"); + + if (!updates.EnumerateArray().Any(x => + x.RequiredString("kind") == "contract" && + x.RequiredString("contract") == staker)) + throw new ValidationException("invalid smart rollup bonds balance updates"); + + if (!updates.EnumerateArray().Any(x => + x.RequiredString("kind") == "freezer" && + x.RequiredString("category") == "bonds" && + x.RequiredString("contract") == staker)) + throw new ValidationException("invalid smart rollup bonds balance updates"); + + if (updates[0].RequiredInt64("change") != -updates[1].RequiredInt64("change")) + throw new ValidationException("inconsistent change of smart rollup bonds balance updates"); + } + } + + protected virtual async Task ValidateSmartRollupRefute(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual async Task ValidateSmartRollupTimeout(JsonElement content) + { + var source = content.RequiredString("source"); + + if (!await Cache.Accounts.ExistsAsync(source)) + throw new ValidationException("unknown source account"); + + ValidateFeeBalanceUpdates( + content.Required("metadata").OptionalArray("balance_updates")?.EnumerateArray() ?? Enumerable.Empty(), + source, + content.RequiredInt64("fee")); + } + + protected virtual void ValidateFeeBalanceUpdates(IEnumerable balanceUpdates, string sender, long fee) + { + if (fee != 0) + { + if (balanceUpdates.Count() != 2) + throw new ValidationException("invalid fee balance updates count"); + + var first = balanceUpdates.First(); + var last = balanceUpdates.Last(); + + if (first.RequiredString("kind") != "contract" || + first.RequiredString("contract") != sender || + first.RequiredInt64("change") != -fee) + throw new ValidationException("invalid fee contract update"); + + if (last.RequiredString("kind") != "accumulator" || + last.RequiredString("category") != "block fees" || + last.RequiredInt64("change") != fee) + throw new ValidationException("invalid fee accumulator update"); + } + else + { + if (balanceUpdates.Any()) + throw new ValidationException("invalid fee balance updates count"); + } + } + + protected virtual void ValidateTransferBalanceUpdates(IEnumerable balanceUpdates, string sender, string target, long amount, long storageFee, long allocationFee, string initiator = null) + { + if (balanceUpdates.Count() != (amount != 0 ? 2 : 0) + (storageFee != 0 ? 2 : 0) + (allocationFee != 0 ? 2 : 0)) + throw new ValidationException("invalid transfer balance updates count"); + + if (amount > 0) + { + if (!balanceUpdates.Any(x => + x.RequiredString("kind") == "contract" && + x.RequiredInt64("change") == -amount && + x.RequiredString("contract") == sender)) + throw new ValidationException("invalid transfer balance updates"); + + if (!balanceUpdates.Any(x => + x.RequiredString("kind") == "contract" && + x.RequiredInt64("change") == amount && + x.RequiredString("contract") == target)) + throw new ValidationException("invalid transfer balance updates"); + } + + if (storageFee > 0) + { + if (!balanceUpdates.Any(x => + x.RequiredString("kind") == "contract" && + x.RequiredInt64("change") == -storageFee && + x.RequiredString("contract") == (initiator ?? sender))) + throw new ValidationException("invalid storage fee balance updates"); + + if (!balanceUpdates.Any(x => + x.RequiredString("kind") == "burned" && + x.RequiredString("category") == "storage fees" && + x.RequiredInt64("change") == storageFee)) + throw new ValidationException("invalid storage fee balance updates"); + } + + if (allocationFee > 0) + { + if (!balanceUpdates.Any(x => + x.RequiredString("kind") == "contract" && + x.RequiredInt64("change") == -allocationFee && + x.RequiredString("contract") == (initiator ?? sender))) + throw new ValidationException("invalid allocation fee balance updates"); + + if (!balanceUpdates.Any(x => + x.RequiredString("kind") == "burned" && + x.RequiredString("category") == "storage fees" && + x.RequiredInt64("change") == allocationFee)) + throw new ValidationException("invalid allocation fee balance updates"); + } + } + } +} diff --git a/Tzkt.Sync/Protocols/Handlers/Proto2/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto2/Activation/ProtoActivator.cs index c999ec274..3b6b30d88 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto2/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto2/Activation/ProtoActivator.cs @@ -194,9 +194,15 @@ protected override async Task RevertContext(AppState state) PublicKey = user.PublicKey, Revealed = user.Revealed, Staked = true, - StakingBalance = user.Balance, + StakingBalance = user.Balance - user.UnstakedBalance, DelegatedBalance = 0, Type = AccountType.Delegate, + StakedBalance = user.StakedBalance, + StakedPseudotokens = user.StakedPseudotokens, + UnstakedBalance = user.UnstakedBalance, + UnstakedBakerId = user.UnstakedBakerId, + StakingOpsCount = user.StakingOpsCount, + TotalStakedBalance = user.StakedBalance, ActiveTokensCount = user.ActiveTokensCount, TokenBalancesCount = user.TokenBalancesCount, TokenTransfersCount = user.TokenTransfersCount, @@ -249,6 +255,11 @@ User DowngradeDelegate(Data.Models.Delegate delegat) Delegate = null, DelegateId = null, DelegationLevel = null, + StakedBalance = delegat.StakedBalance, + StakedPseudotokens = delegat.StakedPseudotokens, + UnstakedBalance = delegat.UnstakedBalance, + UnstakedBakerId = delegat.UnstakedBakerId, + StakingOpsCount = delegat.StakingOpsCount, Id = delegat.Id, Activated = delegat.Activated, DelegationsCount = delegat.DelegationsCount, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/Operations/DoubleBakingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/Operations/DoubleBakingCommit.cs index b7ebb5fb1..a1b4e4d55 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/Operations/DoubleBakingCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/Operations/DoubleBakingCommit.cs @@ -40,12 +40,18 @@ public virtual Task Apply(Block block, JsonElement op, JsonElement content) Timestamp = block.Timestamp, OpHash = op.RequiredString("hash"), + SlashedLevel = block.Level, AccusedLevel = content.Required("bh1").RequiredInt32("level"), Accuser = block.Proposer, Offender = Cache.Accounts.GetDelegate(offenderAddr), - AccuserReward = rewards.ValueKind != JsonValueKind.Undefined ? rewards.RequiredInt64("change") : 0, - OffenderLoss = lostDepositsValue + lostRewardsValue + lostFeesValue + Reward = rewards.ValueKind != JsonValueKind.Undefined ? rewards.RequiredInt64("change") : 0, + LostStaked = lostDepositsValue + lostRewardsValue + lostFeesValue, + LostUnstaked = 0, + LostExternalStaked = 0, + LostExternalUnstaked = 0, + + RoundingLoss = 0 }; #endregion @@ -60,8 +66,8 @@ public virtual Task Apply(Block block, JsonElement op, JsonElement content) #endregion #region apply operation - accuser.Balance += doubleBaking.AccuserReward; - offender.Balance -= doubleBaking.OffenderLoss; + accuser.Balance += doubleBaking.Reward; + offender.Balance -= doubleBaking.LostStaked; offender.StakingBalance -= lostDepositsValue; offender.StakingBalance -= lostFeesValue; @@ -69,6 +75,9 @@ public virtual Task Apply(Block block, JsonElement op, JsonElement content) if (offender != accuser) offender.DoubleBakingCount++; block.Operations |= Operations.DoubleBakings; + + Cache.Statistics.Current.TotalBurned += doubleBaking.LostStaked - doubleBaking.Reward; + Cache.Statistics.Current.TotalFrozen -= doubleBaking.LostStaked - doubleBaking.Reward; #endregion Db.DoubleBakingOps.Add(doubleBaking); @@ -96,9 +105,9 @@ public virtual Task Revert(Block block, DoubleBakingOperation doubleBaking) #endregion #region apply operation - accuser.Balance -= doubleBaking.AccuserReward; - offender.Balance += doubleBaking.OffenderLoss; - offender.StakingBalance += doubleBaking.AccuserReward * 2; + accuser.Balance -= doubleBaking.Reward; + offender.Balance += doubleBaking.LostStaked; + offender.StakingBalance += doubleBaking.Reward * 2; // here we can miss 1 mutez, but this may happen only in legacy protocols // TODO: replace it with NotImplementedException after Ithaca diff --git a/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/RevelationPenaltyCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/RevelationPenaltyCommit.cs index d38fc241e..28997569d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/RevelationPenaltyCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/RevelationPenaltyCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -40,7 +36,7 @@ public virtual async Task Apply(Block block, JsonElement rawBlock) .ToListAsync(); var slashedBakers = bakerCycles - .Where(x => x.DoubleBakingLosses > 0 || x.DoubleEndorsingLosses > 0) + .Where(x => x.DoubleBakingLostStaked > 0 || x.DoubleEndorsingLostStaked > 0) .Select(x => x.BakerId) .ToHashSet(); @@ -56,7 +52,7 @@ public virtual async Task Apply(Block block, JsonElement rawBlock) Level = block.Level, Timestamp = block.Timestamp, MissedLevel = missedBlock.Level, - Loss = slashed ? 0 : missedBlock.Reward + missedBlock.Fees + Loss = slashed ? 0 : missedBlock.RewardLiquid + missedBlock.Fees }); } } @@ -82,6 +78,9 @@ public virtual async Task Apply(Block block, JsonElement rawBlock) delegat.RevelationPenaltiesCount++; block.Operations |= Operations.RevelationPenalty; + Cache.Statistics.Current.TotalBurned += penalty.Loss; + Cache.Statistics.Current.TotalFrozen -= penalty.Loss; + Db.RevelationPenaltyOps.Add(penalty); } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/SnapshotBalanceCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/SnapshotBalanceCommit.cs index da3f8bc01..79afc072d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/SnapshotBalanceCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto2/Commits/SnapshotBalanceCommit.cs @@ -1,115 +1,21 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto2 { - class SnapshotBalanceCommit : ProtocolCommit + class SnapshotBalanceCommit : Proto1.SnapshotBalanceCommit { public SnapshotBalanceCommit(ProtocolHandler protocol) : base(protocol) { } - public async Task Apply(Block block, JsonElement rawBlock) + public override async Task Apply(JsonElement rawBlock, Block block) { - if (block.Events.HasFlag(BlockEvents.BalanceSnapshot)) - { - #region remove outdated - var delete = string.Empty; - var outdatedLevel = block.Level - (block.Protocol.PreservedCycles + 3) * block.Protocol.BlocksPerCycle; - if (outdatedLevel > 0) - { - delete += block.Cycle <= block.Protocol.FirstCycle + block.Protocol.PreservedCycles + 4 - ? $@"DELETE FROM ""SnapshotBalances"" WHERE ""Level"" <= {outdatedLevel};" - : $@"DELETE FROM ""SnapshotBalances"" WHERE ""Level"" = {outdatedLevel};"; - } - #endregion + if (!block.Events.HasFlag(BlockEvents.BalanceSnapshot)) + return; - #region make snapshot - await Db.Database.ExecuteSqlRawAsync($@" - {delete} - INSERT INTO ""SnapshotBalances"" (""Level"", ""Balance"", ""AccountId"", ""DelegateId"") - SELECT {block.Level}, (COALESCE(""StakingBalance"", ""Balance"") - COALESCE(""DelegatedBalance"", 0)), ""Id"", ""DelegateId"" - FROM ""Accounts"" - WHERE ""Staked"" = true;"); - #endregion - - #region ignore just deactivated - if (block.Events.HasFlag(BlockEvents.Deactivations)) - { - var deactivated = await Db.Delegates - .AsNoTracking() - .Include(x => x.DelegatedAccounts) - .Where(x => x.DeactivationLevel == block.Level) - .ToListAsync(); - - if (deactivated.Any()) - { - var sql = @" - INSERT INTO ""SnapshotBalances"" (""Level"", ""Balance"", ""AccountId"", ""DelegateId"") VALUES "; - - foreach (var baker in deactivated) - { - sql += $@" - ({block.Level}, {baker.StakingBalance - baker.DelegatedBalance}, {baker.Id}, NULL),"; - - foreach (var delegator in baker.DelegatedAccounts) - sql += $@" - ({block.Level}, {delegator.Balance}, {delegator.Id}, {delegator.DelegateId}),"; - } - - await Db.Database.ExecuteSqlRawAsync(sql[..^1]); - } - } - #endregion - - #region revert unfrozen rewards - if (block.Events.HasFlag(BlockEvents.CycleEnd)) - { - var values = string.Empty; - foreach (var rewardUpdates in GetBalanceUpdates(rawBlock) - .Where(x => x.RequiredString("kind")[0] == 'f' && - x.RequiredString("category")[0] == 'r' && - x.RequiredInt64("change") < 0 && - GetFreezerCycle(x) != block.Cycle) - .Select(x => (x.RequiredString("delegate"), x.RequiredInt64("change"))) - .GroupBy(x => x.Item1)) - values += $@" - ({Cache.Accounts.GetDelegate(rewardUpdates.Key).Id}, {rewardUpdates.Sum(x => -x.Item2)}::bigint),"; - - if (values.Length > 0) - { - await Db.Database.ExecuteSqlRawAsync($@" - UPDATE ""SnapshotBalances"" as sb - SET ""Balance"" = ""Balance"" - rw.value - FROM (VALUES {values[..^1]}) as rw(delegate, value) - WHERE sb.""Level"" = {block.Level} - AND sb.""AccountId"" = rw.delegate;"); - } - } - #endregion - } - } - - public async Task Revert(Block block) - { - if (block.Events.HasFlag(BlockEvents.BalanceSnapshot)) - { - await Db.Database.ExecuteSqlRawAsync($@" - DELETE FROM ""SnapshotBalances"" - WHERE ""Level"" = {block.Level}"); - } - } - - protected virtual int GetFreezerCycle(JsonElement el) => el.RequiredInt32("level"); - - protected virtual IEnumerable GetBalanceUpdates(JsonElement rawBlock) - { - return rawBlock - .GetProperty("metadata") - .GetProperty("balance_updates") - .EnumerateArray(); + await RemoveOutdated(block, block.Protocol); + await TakeSnapshot(block); + await TakeDeactivatedSnapshot(block); + await SubtractCycleRewards(rawBlock, block); } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto2/Proto2Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto2/Proto2Handler.cs index 7f012b0be..148d01b6f 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto2/Proto2Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto2/Proto2Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,12 +29,12 @@ public Proto2Handler(TezosNode node, TzktContext db, CacheService cache, QuotesS public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); - var freezerCommit = new FreezerCommit(this); - await freezerCommit.Apply(blockCommit.Block, block); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -160,10 +153,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -171,7 +163,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto3/Commits/BakerCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto3/Commits/BakerCycleCommit.cs index 88e63f0b9..5743b810b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto3/Commits/BakerCycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto3/Commits/BakerCycleCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -17,7 +13,7 @@ public override async Task Apply( Cycle futureCycle, IEnumerable futureBakingRights, IEnumerable futureEndorsingRights, - Dictionary snapshots, + List snapshots, List currentRights) { #region current rights @@ -96,7 +92,7 @@ public override async Task Apply( : successReward; if (endorsingRight.Status == BakingRightStatus.Realized) - bakerCycle.EndorsementRewards += successReward; + bakerCycle.EndorsementRewardsLiquid += successReward; else if (endorsingRight.Status == BakingRightStatus.Missed) bakerCycle.MissedEndorsementRewards += successReward; else @@ -130,7 +126,7 @@ public override async Task Apply( if (actualReward > 0) { - bakerCycle.BlockRewards += actualReward; + bakerCycle.BlockRewardsLiquid += actualReward; } if (successReward != actualReward) @@ -172,12 +168,12 @@ public override async Task Apply( var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.Offender.Id); Db.TryAttach(offenderCycle); - offenderCycle.DoubleBakingLosses += op.OffenderLoss; + offenderCycle.DoubleBakingLostStaked += op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Accuser.Id); Db.TryAttach(accuserCycle); - accuserCycle.DoubleBakingRewards += op.AccuserReward; + accuserCycle.DoubleBakingRewards += op.Reward; } } @@ -189,12 +185,12 @@ public override async Task Apply( var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.Offender.Id); Db.TryAttach(offenderCycle); - offenderCycle.DoubleEndorsingLosses += op.OffenderLoss; + offenderCycle.DoubleEndorsingLostStaked += op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Accuser.Id); Db.TryAttach(accuserCycle); - accuserCycle.DoubleEndorsingRewards += op.AccuserReward; + accuserCycle.DoubleEndorsingRewards += op.Reward; } } @@ -205,7 +201,7 @@ public override async Task Apply( var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Baker.Id); Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards += op.Reward; + bakerCycle.NonceRevelationRewardsLiquid += op.RewardLiquid; } } @@ -217,7 +213,7 @@ public override async Task Apply( var penaltyCycle = await Cache.BakerCycles.GetAsync(penaltyBlock.Cycle, op.Baker.Id); Db.TryAttach(penaltyCycle); - penaltyCycle.RevelationLosses += op.Loss; + penaltyCycle.NonceRevelationLosses += op.Loss; } } #endregion @@ -225,28 +221,31 @@ public override async Task Apply( #region new cycle if (block.Events.HasFlag(BlockEvents.CycleBegin)) { - var bakerCycles = snapshots.Keys.ToDictionary(id => Cache.Accounts.GetDelegate(id).Address, id => - { - var snapshot = snapshots[id]; + var bakerCycles = snapshots.ToDictionary( + snapshot => Cache.Accounts.GetDelegate(snapshot.AccountId).Address, + snapshot => + { + var bakingPower = snapshot.StakingBalance - snapshot.StakingBalance % block.Protocol.MinimalStake; + var share = (double)bakingPower / futureCycle.TotalBakingPower; - var activeStake = snapshot.StakingBalance - snapshot.StakingBalance % block.Protocol.TokensPerRoll; - var share = (double)activeStake / futureCycle.SelectedStake; + var bakerCycle = new BakerCycle + { + Cycle = futureCycle.Index, + BakerId = snapshot.AccountId, + OwnDelegatedBalance = snapshot.OwnDelegatedBalance, + ExternalDelegatedBalance = snapshot.ExternalDelegatedBalance, + DelegatorsCount = snapshot.DelegatorsCount, + OwnStakedBalance = snapshot.OwnStakedBalance, + ExternalStakedBalance = snapshot.ExternalStakedBalance, + StakersCount = snapshot.StakersCount, + BakingPower = bakingPower, + TotalBakingPower = futureCycle.TotalBakingPower, + ExpectedBlocks = block.Protocol.BlocksPerCycle * share, + ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share + }; - var bakerCycle = new BakerCycle - { - Cycle = futureCycle.Index, - BakerId = id, - StakingBalance = snapshot.StakingBalance, - ActiveStake = activeStake, - SelectedStake = futureCycle.SelectedStake, - DelegatedBalance = snapshot.DelegatedBalance, - DelegatorsCount = snapshot.DelegatorsCount, - ExpectedBlocks = block.Protocol.BlocksPerCycle * share, - ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share - }; - - return bakerCycle; - }); + return bakerCycle; + }); #region future baking rights foreach (var br in futureBakingRights) @@ -301,18 +300,22 @@ public override async Task Apply( throw new Exception("Deactivated baker got baking rights"); var stakingBalance = snapshottedBaker.RequiredInt64("staking_balance"); - var activeStake = stakingBalance - stakingBalance % block.Protocol.TokensPerRoll; - var share = (double)activeStake / futureCycle.SelectedStake; + var delegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"); + var bakingPower = stakingBalance - stakingBalance % block.Protocol.MinimalStake; + var share = (double)bakingPower / futureCycle.TotalBakingPower; bakerCycle = new BakerCycle { Cycle = futureCycle.Index, BakerId = baker.Id, - StakingBalance = stakingBalance, - ActiveStake = activeStake, - SelectedStake = futureCycle.SelectedStake, - DelegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"), + OwnDelegatedBalance = stakingBalance - delegatedBalance, + ExternalDelegatedBalance = delegatedBalance, DelegatorsCount = delegators.Count(), + OwnStakedBalance = 0, + ExternalStakedBalance = 0, + StakersCount = 0, + BakingPower = bakingPower, + TotalBakingPower = futureCycle.TotalBakingPower, ExpectedBlocks = block.Protocol.BlocksPerCycle * share, ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share }; @@ -323,10 +326,11 @@ public override async Task Apply( var snapshottedDelegator = await Proto.Rpc.GetContractAsync(futureCycle.SnapshotLevel, delegatorAddress); Db.DelegatorCycles.Add(new DelegatorCycle { - BakerId = baker.Id, - Balance = snapshottedDelegator.RequiredInt64("balance"), Cycle = futureCycle.Index, - DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id + DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id, + BakerId = baker.Id, + DelegatedBalance = snapshottedDelegator.RequiredInt64("balance"), + StakedBalance = 0 }); } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto3/Commits/DelegatorCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto3/Commits/DelegatorCycleCommit.cs index cf3ff0021..536de9da9 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto3/Commits/DelegatorCycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto3/Commits/DelegatorCycleCommit.cs @@ -1,6 +1,4 @@ -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Tzkt.Data.Models; +using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto3 { @@ -10,15 +8,10 @@ public DelegatorCycleCommit(ProtocolHandler protocol) : base(protocol) { } public override async Task Apply(Block block, Cycle futureCycle) { - if (block.Events.HasFlag(BlockEvents.CycleBegin)) - { - await Db.Database.ExecuteSqlRawAsync($@" - INSERT INTO ""DelegatorCycles"" (""Cycle"", ""DelegatorId"", ""BakerId"", ""Balance"") - SELECT {futureCycle.Index}, ""AccountId"", ""DelegateId"", ""Balance"" - FROM ""SnapshotBalances"" - WHERE ""Level"" = {futureCycle.SnapshotLevel} - AND ""DelegateId"" IS NOT NULL"); - } + if (!block.Events.HasFlag(BlockEvents.CycleBegin)) + return; + + await CreateFromSnapshots(futureCycle); } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto3/Proto3Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto3/Proto3Handler.cs index bfade6576..35b5b7525 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto3/Proto3Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto3/Proto3Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,12 +29,12 @@ public Proto3Handler(TezosNode node, TzktContext db, CacheService cache, QuotesS public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); - var freezerCommit = new FreezerCommit(this); - await freezerCommit.Apply(blockCommit.Block, block); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -176,10 +169,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -187,7 +179,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto4/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto4/Activation/ProtoActivator.cs index ed05958a5..1fbe4d900 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto4/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto4/Activation/ProtoActivator.cs @@ -1,5 +1,4 @@ -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Newtonsoft.Json.Linq; using Tzkt.Data.Models; @@ -14,14 +13,14 @@ protected override void SetParameters(Protocol protocol, JToken parameters) base.SetParameters(protocol, parameters); protocol.HardBlockGasLimit = parameters["hard_gas_limit_per_block"]?.Value() ?? 8_000_000; protocol.HardOperationGasLimit = parameters["hard_gas_limit_per_operation"]?.Value() ?? 800_000; - protocol.TokensPerRoll = parameters["tokens_per_roll"]?.Value() ?? 8_000_000_000; + protocol.MinimalStake = parameters["tokens_per_roll"]?.Value() ?? 8_000_000_000; } protected override void UpgradeParameters(Protocol protocol, Protocol prev) { protocol.HardBlockGasLimit = 8_000_000; protocol.HardOperationGasLimit = 800_000; - protocol.TokensPerRoll = 8_000_000_000; + protocol.MinimalStake = 8_000_000_000; } // Proposal invoice @@ -50,8 +49,7 @@ protected override async Task MigrateContext(AppState state) state.MigrationOpsCount++; - var stats = await Cache.Statistics.GetAsync(state.Level); - stats.TotalCreated += 100_000_000; + Cache.Statistics.Current.TotalCreated += 100_000_000; } protected override async Task RevertContext(AppState state) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto4/Commits/BakerCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto4/Commits/BakerCycleCommit.cs index 9bc070e7e..3b689d27f 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto4/Commits/BakerCycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto4/Commits/BakerCycleCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -17,7 +13,7 @@ public override async Task Apply( Cycle futureCycle, IEnumerable futureBakingRights, IEnumerable futureEndorsingRights, - Dictionary snapshots, + List snapshots, List currentRights) { #region current rights @@ -96,7 +92,7 @@ public override async Task Apply( : successReward; if (endorsingRight.Status == BakingRightStatus.Realized) - bakerCycle.EndorsementRewards += successReward; + bakerCycle.EndorsementRewardsLiquid += successReward; else if (endorsingRight.Status == BakingRightStatus.Missed) bakerCycle.MissedEndorsementRewards += successReward; else @@ -130,7 +126,7 @@ public override async Task Apply( if (actualReward > 0) { - bakerCycle.BlockRewards += actualReward; + bakerCycle.BlockRewardsLiquid += actualReward; } if (successReward != actualReward) @@ -172,12 +168,12 @@ public override async Task Apply( var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.Offender.Id); Db.TryAttach(offenderCycle); - offenderCycle.DoubleBakingLosses += op.OffenderLoss; + offenderCycle.DoubleBakingLostStaked += op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Accuser.Id); Db.TryAttach(accuserCycle); - accuserCycle.DoubleBakingRewards += op.AccuserReward; + accuserCycle.DoubleBakingRewards += op.Reward; } } @@ -189,12 +185,12 @@ public override async Task Apply( var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.Offender.Id); Db.TryAttach(offenderCycle); - offenderCycle.DoubleEndorsingLosses += op.OffenderLoss; + offenderCycle.DoubleEndorsingLostStaked += op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Accuser.Id); Db.TryAttach(accuserCycle); - accuserCycle.DoubleEndorsingRewards += op.AccuserReward; + accuserCycle.DoubleEndorsingRewards += op.Reward; } } @@ -205,7 +201,7 @@ public override async Task Apply( var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Baker.Id); Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards += op.Reward; + bakerCycle.NonceRevelationRewardsLiquid += op.RewardLiquid; } } @@ -217,7 +213,7 @@ public override async Task Apply( var penaltyCycle = await Cache.BakerCycles.GetAsync(penaltyBlock.Cycle, op.Baker.Id); Db.TryAttach(penaltyCycle); - penaltyCycle.RevelationLosses += op.Loss; + penaltyCycle.NonceRevelationLosses += op.Loss; } } #endregion @@ -230,28 +226,31 @@ public override async Task Apply( var snapshotProtocol = await Cache.Protocols.GetAsync(snapshotBlock.ProtoCode); //--------------------------------------------- - var bakerCycles = snapshots.Keys.ToDictionary(id => Cache.Accounts.GetDelegate(id).Address, id => - { - var snapshot = snapshots[id]; + var bakerCycles = snapshots.ToDictionary( + snapshot => Cache.Accounts.GetDelegate(snapshot.AccountId).Address, + snapshot => + { + var bakingPower = snapshot.StakingBalance - snapshot.StakingBalance % snapshotProtocol.MinimalStake; + var share = (double)bakingPower / futureCycle.TotalBakingPower; - var activeStake = snapshot.StakingBalance - snapshot.StakingBalance % snapshotProtocol.TokensPerRoll; - var share = (double)activeStake / futureCycle.SelectedStake; + var bakerCycle = new BakerCycle + { + Cycle = futureCycle.Index, + BakerId = snapshot.AccountId, + OwnDelegatedBalance = snapshot.OwnDelegatedBalance, + ExternalDelegatedBalance = snapshot.ExternalDelegatedBalance, + DelegatorsCount = snapshot.DelegatorsCount, + OwnStakedBalance = snapshot.OwnStakedBalance, + ExternalStakedBalance = snapshot.ExternalStakedBalance, + StakersCount = snapshot.StakersCount, + BakingPower = bakingPower, + TotalBakingPower = futureCycle.TotalBakingPower, + ExpectedBlocks = block.Protocol.BlocksPerCycle * share, + ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share + }; - var bakerCycle = new BakerCycle - { - Cycle = futureCycle.Index, - BakerId = id, - StakingBalance = snapshot.StakingBalance, - ActiveStake = activeStake, - SelectedStake = futureCycle.SelectedStake, - DelegatedBalance = snapshot.DelegatedBalance, - DelegatorsCount = snapshot.DelegatorsCount, - ExpectedBlocks = block.Protocol.BlocksPerCycle * share, - ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share - }; - - return bakerCycle; - }); + return bakerCycle; + }); #region future baking rights foreach (var br in futureBakingRights) @@ -306,18 +305,22 @@ public override async Task Apply( throw new Exception("Deactivated baker got baking rights"); var stakingBalance = snapshottedBaker.RequiredInt64("staking_balance"); - var activeStake = stakingBalance - stakingBalance % snapshotProtocol.TokensPerRoll; - var share = (double)activeStake / futureCycle.SelectedStake; + var delegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"); + var bakingPower = stakingBalance - stakingBalance % snapshotProtocol.MinimalStake; + var share = (double)bakingPower / futureCycle.TotalBakingPower; bakerCycle = new BakerCycle { Cycle = futureCycle.Index, BakerId = baker.Id, - StakingBalance = stakingBalance, - ActiveStake = activeStake, - SelectedStake = futureCycle.SelectedStake, - DelegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"), + OwnDelegatedBalance = stakingBalance - delegatedBalance, + ExternalDelegatedBalance = delegatedBalance, DelegatorsCount = delegators.Count(), + OwnStakedBalance = 0, + ExternalStakedBalance = 0, + StakersCount = 0, + BakingPower = bakingPower, + TotalBakingPower = futureCycle.TotalBakingPower, ExpectedBlocks = block.Protocol.BlocksPerCycle * share, ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share }; @@ -328,10 +331,11 @@ public override async Task Apply( var snapshottedDelegator = await Proto.Rpc.GetContractAsync(futureCycle.SnapshotLevel, delegatorAddress); Db.DelegatorCycles.Add(new DelegatorCycle { - BakerId = baker.Id, - Balance = snapshottedDelegator.RequiredInt64("balance"), Cycle = futureCycle.Index, - DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id + DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id, + BakerId = baker.Id, + DelegatedBalance = snapshottedDelegator.RequiredInt64("balance"), + StakedBalance = 0 }); } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto4/Commits/Operations/DoubleEndorsingCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto4/Commits/Operations/DoubleEndorsingCommit.cs index b310a5dff..b181ea9b0 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto4/Commits/Operations/DoubleEndorsingCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto4/Commits/Operations/DoubleEndorsingCommit.cs @@ -40,12 +40,18 @@ public virtual Task Apply(Block block, JsonElement op, JsonElement content) Timestamp = block.Timestamp, OpHash = op.RequiredString("hash"), + SlashedLevel = block.Level, AccusedLevel = content.Required("op1").Required("operations").RequiredInt32("level"), Accuser = block.Proposer, Offender = Cache.Accounts.GetDelegate(offenderAddr), - AccuserReward = rewards.ValueKind != JsonValueKind.Undefined ? rewards.RequiredInt64("change") : 0, - OffenderLoss = lostDepositsValue + lostRewardsValue + lostFeesValue + Reward = rewards.ValueKind != JsonValueKind.Undefined ? rewards.RequiredInt64("change") : 0, + LostStaked = lostDepositsValue + lostRewardsValue + lostFeesValue, + LostUnstaked = 0, + LostExternalStaked = 0, + LostExternalUnstaked = 0, + + RoundingLoss = 0 }; #endregion @@ -60,8 +66,8 @@ public virtual Task Apply(Block block, JsonElement op, JsonElement content) #endregion #region apply operation - accuser.Balance += doubleEndorsing.AccuserReward; - offender.Balance -= doubleEndorsing.OffenderLoss; + accuser.Balance += doubleEndorsing.Reward; + offender.Balance -= doubleEndorsing.LostStaked; offender.StakingBalance -= lostDepositsValue; offender.StakingBalance -= lostFeesValue; @@ -69,6 +75,9 @@ public virtual Task Apply(Block block, JsonElement op, JsonElement content) if (offender != accuser) offender.DoubleEndorsingCount++; block.Operations |= Operations.DoubleEndorsings; + + Cache.Statistics.Current.TotalBurned += doubleEndorsing.LostStaked - doubleEndorsing.Reward; + Cache.Statistics.Current.TotalFrozen -= doubleEndorsing.LostStaked - doubleEndorsing.Reward; #endregion Db.DoubleEndorsingOps.Add(doubleEndorsing); @@ -96,9 +105,9 @@ public virtual Task Revert(Block block, DoubleEndorsingOperation doubleEndorsing #endregion #region apply operation - accuser.Balance -= doubleEndorsing.AccuserReward; - offender.Balance += doubleEndorsing.OffenderLoss; - offender.StakingBalance += doubleEndorsing.AccuserReward * 2; + accuser.Balance -= doubleEndorsing.Reward; + offender.Balance += doubleEndorsing.LostStaked; + offender.StakingBalance += doubleEndorsing.Reward * 2; // here we can miss 1 mutez, but this may happen only in legacy protocols, so let's ignore // TODO: replace it with NotImplementedException after Ithaca diff --git a/Tzkt.Sync/Protocols/Handlers/Proto4/Proto4Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto4/Proto4Handler.cs index 47b988d3b..48af14089 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto4/Proto4Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto4/Proto4Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,12 +29,12 @@ public Proto4Handler(TezosNode node, TzktContext db, CacheService cache, QuotesS public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(block); + var blockCommit = new BlockCommit(this); await blockCommit.Apply(block); - var freezerCommit = new FreezerCommit(this); - await freezerCommit.Apply(blockCommit.Block, block); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -179,10 +172,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -190,7 +182,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto5/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto5/Activation/ProtoActivator.cs index 65fffa2b5..89b3d49e1 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto5/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto5/Activation/ProtoActivator.cs @@ -35,7 +35,7 @@ protected override void UpgradeParameters(Protocol protocol, Protocol prev) protected override async Task MigrateContext(AppState state) { var block = await Cache.Blocks.CurrentAsync(); - var statistics = await Cache.Statistics.GetAsync(state.Level); + var statistics = Cache.Statistics.Current; #region airdrop var emptiedManagers = await Db.Contracts diff --git a/Tzkt.Sync/Protocols/Handlers/Proto5/Commits/BakerCycleCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto5/Commits/BakerCycleCommit.cs index 9184cd02d..60f0f6524 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto5/Commits/BakerCycleCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto5/Commits/BakerCycleCommit.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; using Tzkt.Data.Models; @@ -17,7 +13,7 @@ public virtual async Task Apply( Cycle futureCycle, IEnumerable futureBakingRights, IEnumerable futureEndorsingRights, - Dictionary snapshots, + List snapshots, List currentRights) { #region current rights @@ -87,7 +83,7 @@ public virtual async Task Apply( : successReward; if (endorsingRight.Status == BakingRightStatus.Realized) - bakerCycle.EndorsementRewards += successReward; + bakerCycle.EndorsementRewardsLiquid += successReward; else if (endorsingRight.Status == BakingRightStatus.Missed) bakerCycle.MissedEndorsementRewards += successReward; else @@ -118,7 +114,7 @@ public virtual async Task Apply( if (actualReward > 0) { - bakerCycle.BlockRewards += actualReward; + bakerCycle.BlockRewardsLiquid += actualReward; } if (successReward != actualReward) @@ -160,12 +156,12 @@ public virtual async Task Apply( var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.Offender.Id); Db.TryAttach(offenderCycle); - offenderCycle.DoubleBakingLosses += op.OffenderLoss; + offenderCycle.DoubleBakingLostStaked += op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Accuser.Id); Db.TryAttach(accuserCycle); - accuserCycle.DoubleBakingRewards += op.AccuserReward; + accuserCycle.DoubleBakingRewards += op.Reward; } } @@ -177,12 +173,12 @@ public virtual async Task Apply( var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.Offender.Id); Db.TryAttach(offenderCycle); - offenderCycle.DoubleEndorsingLosses += op.OffenderLoss; + offenderCycle.DoubleEndorsingLostStaked += op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Accuser.Id); Db.TryAttach(accuserCycle); - accuserCycle.DoubleEndorsingRewards += op.AccuserReward; + accuserCycle.DoubleEndorsingRewards += op.Reward; } } @@ -193,7 +189,7 @@ public virtual async Task Apply( var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.Baker.Id); Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards += op.Reward; + bakerCycle.NonceRevelationRewardsLiquid += op.RewardLiquid; } } @@ -205,7 +201,7 @@ public virtual async Task Apply( var penaltyCycle = await Cache.BakerCycles.GetAsync(penaltyBlock.Cycle, op.Baker.Id); Db.TryAttach(penaltyCycle); - penaltyCycle.RevelationLosses += op.Loss; + penaltyCycle.NonceRevelationLosses += op.Loss; } } #endregion @@ -213,28 +209,31 @@ public virtual async Task Apply( #region new cycle if (block.Events.HasFlag(BlockEvents.CycleBegin)) { - var bakerCycles = snapshots.Keys.ToDictionary(id => Cache.Accounts.GetDelegate(id).Address, id => - { - var snapshot = snapshots[id]; + var bakerCycles = snapshots.ToDictionary( + snapshot => Cache.Accounts.GetDelegate(snapshot.AccountId).Address, + snapshot => + { + var bakingPower = snapshot.StakingBalance - snapshot.StakingBalance % block.Protocol.MinimalStake; + var share = (double)bakingPower / futureCycle.TotalBakingPower; - var activeStake = snapshot.StakingBalance - snapshot.StakingBalance % block.Protocol.TokensPerRoll; - var share = (double)activeStake / futureCycle.SelectedStake; + var bakerCycle = new BakerCycle + { + Cycle = futureCycle.Index, + BakerId = snapshot.AccountId, + OwnDelegatedBalance = snapshot.OwnDelegatedBalance, + ExternalDelegatedBalance = snapshot.ExternalDelegatedBalance, + DelegatorsCount = snapshot.DelegatorsCount, + OwnStakedBalance = snapshot.OwnStakedBalance, + ExternalStakedBalance = snapshot.ExternalStakedBalance, + StakersCount = snapshot.StakersCount, + BakingPower = bakingPower, + TotalBakingPower = futureCycle.TotalBakingPower, + ExpectedBlocks = block.Protocol.BlocksPerCycle * share, + ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share + }; - var bakerCycle = new BakerCycle - { - Cycle = futureCycle.Index, - BakerId = id, - StakingBalance = snapshot.StakingBalance, - ActiveStake = activeStake, - SelectedStake = futureCycle.SelectedStake, - DelegatedBalance = snapshot.DelegatedBalance, - DelegatorsCount = snapshot.DelegatorsCount, - ExpectedBlocks = block.Protocol.BlocksPerCycle * share, - ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share - }; - - return bakerCycle; - }); + return bakerCycle; + }); #region future baking rights foreach (var br in futureBakingRights) @@ -290,18 +289,22 @@ public virtual async Task Apply( throw new Exception("Deactivated baker got baking rights"); var stakingBalance = snapshottedBaker.RequiredInt64("staking_balance"); - var activeStake = stakingBalance - stakingBalance % block.Protocol.TokensPerRoll; - var share = (double)activeStake / futureCycle.SelectedStake; + var delegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"); + var bakingPower = stakingBalance - stakingBalance % block.Protocol.MinimalStake; + var share = (double)bakingPower / futureCycle.TotalBakingPower; bakerCycle = new BakerCycle { Cycle = futureCycle.Index, BakerId = baker.Id, - StakingBalance = stakingBalance, - ActiveStake = activeStake, - SelectedStake = futureCycle.SelectedStake, - DelegatedBalance = snapshottedBaker.RequiredInt64("delegated_balance"), + OwnDelegatedBalance = stakingBalance - delegatedBalance, + ExternalDelegatedBalance = delegatedBalance, DelegatorsCount = delegators.Count(), + OwnStakedBalance = 0, + ExternalStakedBalance = 0, + StakersCount = 0, + BakingPower = bakingPower, + TotalBakingPower = futureCycle.TotalBakingPower, ExpectedBlocks = block.Protocol.BlocksPerCycle * share, ExpectedEndorsements = block.Protocol.EndorsersPerBlock * block.Protocol.BlocksPerCycle * share }; @@ -312,10 +315,11 @@ public virtual async Task Apply( var snapshottedDelegator = await Proto.Rpc.GetContractAsync(futureCycle.SnapshotLevel, delegatorAddress); Db.DelegatorCycles.Add(new DelegatorCycle { - BakerId = baker.Id, - Balance = snapshottedDelegator.RequiredInt64("balance"), Cycle = futureCycle.Index, - DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id + DelegatorId = (await Cache.Accounts.GetAsync(delegatorAddress)).Id, + BakerId = baker.Id, + DelegatedBalance = snapshottedDelegator.RequiredInt64("balance"), + StakedBalance = 0 }); } #endregion @@ -411,7 +415,7 @@ public virtual async Task Revert(Block block) : successReward; if (endorsingRight.Status == BakingRightStatus.Realized) - bakerCycle.EndorsementRewards -= successReward; + bakerCycle.EndorsementRewardsLiquid -= successReward; else if (endorsingRight.Status == BakingRightStatus.Missed) bakerCycle.MissedEndorsementRewards -= successReward; else @@ -442,7 +446,7 @@ public virtual async Task Revert(Block block) if (actualReward > 0) { - bakerCycle.BlockRewards -= actualReward; + bakerCycle.BlockRewardsLiquid -= actualReward; } if (successReward != actualReward) @@ -484,12 +488,12 @@ public virtual async Task Revert(Block block) var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.OffenderId); Db.TryAttach(offenderCycle); - offenderCycle.DoubleBakingLosses -= op.OffenderLoss; + offenderCycle.DoubleBakingLostStaked -= op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.AccuserId); Db.TryAttach(accuserCycle); - accuserCycle.DoubleBakingRewards -= op.AccuserReward; + accuserCycle.DoubleBakingRewards -= op.Reward; } } @@ -501,12 +505,12 @@ public virtual async Task Revert(Block block) var offenderCycle = await Cache.BakerCycles.GetAsync(accusedBlock.Cycle, op.OffenderId); Db.TryAttach(offenderCycle); - offenderCycle.DoubleEndorsingLosses -= op.OffenderLoss; + offenderCycle.DoubleEndorsingLostStaked -= op.LostStaked; var accuserCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.AccuserId); Db.TryAttach(accuserCycle); - accuserCycle.DoubleEndorsingRewards -= op.AccuserReward; + accuserCycle.DoubleEndorsingRewards -= op.Reward; } } @@ -517,7 +521,7 @@ public virtual async Task Revert(Block block) var bakerCycle = await Cache.BakerCycles.GetAsync(block.Cycle, op.BakerId); Db.TryAttach(bakerCycle); - bakerCycle.RevelationRewards -= op.Reward; + bakerCycle.NonceRevelationRewardsLiquid -= op.RewardLiquid; } } @@ -529,7 +533,7 @@ public virtual async Task Revert(Block block) var penaltyCycle = await Cache.BakerCycles.GetAsync(penaltyBlock.Cycle, op.BakerId); Db.TryAttach(penaltyCycle); - penaltyCycle.RevelationLosses -= op.Loss; + penaltyCycle.NonceRevelationLosses -= op.Loss; } } #endregion diff --git a/Tzkt.Sync/Protocols/Handlers/Proto5/Commits/Operations/ActivationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto5/Commits/Operations/ActivationsCommit.cs index 4ada4bf9c..b02df8d81 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto5/Commits/Operations/ActivationsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto5/Commits/Operations/ActivationsCommit.cs @@ -1,5 +1,4 @@ using System.Text.Json; -using System.Threading.Tasks; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto5 diff --git a/Tzkt.Sync/Protocols/Handlers/Proto5/Proto5Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto5/Proto5Handler.cs index acac7a488..38cd2a950 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto5/Proto5Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto5/Proto5Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,14 +29,13 @@ public Proto5Handler(TezosNode node, TzktContext db, CacheService cache, QuotesS public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(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); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -191,10 +183,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -202,7 +193,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto6/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto6/Activation/ProtoActivator.cs index fbf3603bd..c496b8f01 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto6/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto6/Activation/ProtoActivator.cs @@ -33,9 +33,8 @@ protected override void SetParameters(Protocol protocol, JToken parameters) protocol.HardOperationStorageLimit = parameters["hard_storage_limit_per_operation"]?.Value() ?? 60_000; protocol.OriginationSize = parameters["origination_size"]?.Value() ?? 257; protocol.PreservedCycles = parameters["preserved_cycles"]?.Value() ?? 5; - protocol.RevelationReward = parameters["seed_nonce_revelation_tip"]?.Value() ?? 125_000; protocol.TimeBetweenBlocks = parameters["time_between_blocks"]?[0].Value() ?? 60; - protocol.TokensPerRoll = parameters["tokens_per_roll"]?.Value() ?? 8_000_000_000; + protocol.MinimalStake = parameters["tokens_per_roll"]?.Value() ?? 8_000_000_000; protocol.BallotQuorumMin = parameters["quorum_min"]?.Value() ?? 2000; protocol.BallotQuorumMax = parameters["quorum_max"]?.Value() ?? 7000; protocol.ProposalQuorum = parameters["min_proposal_quorum"]?.Value() ?? 500; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto6/Commits/FreezerCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto6/Commits/FreezerCommit.cs index 260b01f80..97c48a412 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto6/Commits/FreezerCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto6/Commits/FreezerCommit.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto6 diff --git a/Tzkt.Sync/Protocols/Handlers/Proto6/Proto6Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto6/Proto6Handler.cs index aa01a6240..82ca133ec 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto6/Proto6Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto6/Proto6Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,14 +29,13 @@ public Proto6Handler(TezosNode node, TzktContext db, CacheService cache, QuotesS public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(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); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -191,10 +183,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -202,7 +193,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto6/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto6/Rpc/Rpc.cs index 203d76796..604a0bb3a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto6/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto6/Rpc/Rpc.cs @@ -1,5 +1,4 @@ using System.Text.Json; -using System.Threading.Tasks; using Tzkt.Sync.Services; namespace Tzkt.Sync.Protocols.Proto6 diff --git a/Tzkt.Sync/Protocols/Handlers/Proto7/Proto7Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto7/Proto7Handler.cs index 49b6000ef..a6b559c9c 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto7/Proto7Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto7/Proto7Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,14 +29,13 @@ public Proto7Handler(TezosNode node, TzktContext db, CacheService cache, QuotesS public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(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); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -191,10 +183,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -202,7 +193,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto8/Proto8Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto8/Proto8Handler.cs index 3657d5869..178ad6eec 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto8/Proto8Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto8/Proto8Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,14 +29,13 @@ public Proto8Handler(TezosNode node, TzktContext db, CacheService cache, QuotesS public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(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); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -191,10 +183,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -202,7 +193,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto9/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto9/Activation/ProtoActivator.cs index 71138b442..f5f08732c 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto9/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto9/Activation/ProtoActivator.cs @@ -35,8 +35,7 @@ protected override async Task MigrateContext(AppState state) state.MigrationOpsCount++; - var stats = await Cache.Statistics.GetAsync(state.Level); - stats.TotalCreated += 100_000_000; + Cache.Statistics.Current.TotalCreated += 100_000_000; } protected override async Task RevertContext(AppState state) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto9/Commits/FreezerCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto9/Commits/FreezerCommit.cs index 8ef14d45a..c7c044d0d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto9/Commits/FreezerCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto9/Commits/FreezerCommit.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; +using System.Text.Json; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto9 diff --git a/Tzkt.Sync/Protocols/Handlers/Proto9/Commits/SnapshotBalanceCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto9/Commits/SnapshotBalanceCommit.cs index fb803fcfa..867d3ab5d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto9/Commits/SnapshotBalanceCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto9/Commits/SnapshotBalanceCommit.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; +using System.Text.Json; namespace Tzkt.Sync.Protocols.Proto9 { diff --git a/Tzkt.Sync/Protocols/Handlers/Proto9/Proto9Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto9/Proto9Handler.cs index 7aedca6b3..b36c1a390 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto9/Proto9Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto9/Proto9Handler.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using App.Metrics; - using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -36,14 +29,13 @@ public Proto9Handler(TezosNode node, TzktContext db, CacheService cache, QuotesS public override async Task Commit(JsonElement block) { + await new StatisticsCommit(this).Apply(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); - + new FreezerCommit(this).Apply(blockCommit.Block, block); await new RevelationPenaltyCommit(this).Apply(blockCommit.Block, block); await new DeactivationCommit(this).Apply(blockCommit.Block, block); @@ -191,10 +183,9 @@ public override async Task Commit(JsonElement block) cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, - cycleCommit.Snapshots, + cycleCommit.BakerSnapshots, 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); } @@ -202,7 +193,7 @@ public override async Task Commit(JsonElement block) public override async Task AfterCommit(JsonElement rawBlock) { var block = await Cache.Blocks.CurrentAsync(); - await new SnapshotBalanceCommit(this).Apply(block, rawBlock); + await new SnapshotBalanceCommit(this).Apply(rawBlock, block); } public override async Task BeforeRevert() diff --git a/Tzkt.Sync/Protocols/Helpers/Chains.cs b/Tzkt.Sync/Protocols/Helpers/Chains.cs index c3df600e6..eae3a2052 100644 --- a/Tzkt.Sync/Protocols/Helpers/Chains.cs +++ b/Tzkt.Sync/Protocols/Helpers/Chains.cs @@ -16,6 +16,7 @@ static class Chains "NetXizpkH94bocH" => "limanet", "NetXgbcrNtXD2yA" => "mumbainet", "NetXyuzvDo2Ugzb" => "nairobinet", + "NetXxWsskGahzQB" => "oxfordnet", _ => "private" }; } diff --git a/Tzkt.Sync/Protocols/ProtocolHandler.cs b/Tzkt.Sync/Protocols/ProtocolHandler.cs index 44a1f69e3..2ef783fca 100644 --- a/Tzkt.Sync/Protocols/ProtocolHandler.cs +++ b/Tzkt.Sync/Protocols/ProtocolHandler.cs @@ -88,18 +88,12 @@ public virtual async Task CommitBlock(int head) Logger.LogDebug("Touch accounts"); TouchAccounts(); - if (Config.Diagnostics) - { - Logger.LogDebug("Diagnostics"); - using (Metrics.Measure.Timer.Time(MetricsRegistry.DiagnosticsTime)) - { - await nextProtocol.Diagnostics.Run(block); - } - } - Logger.LogDebug("Save changes"); using (Metrics.Measure.Timer.Time(MetricsRegistry.SaveChangesTime)) { + if (Config.Diagnostics) + nextProtocol.Diagnostics.TrackChanges(); + await Db.SaveChangesAsync(); } @@ -107,6 +101,11 @@ public virtual async Task CommitBlock(int head) using (Metrics.Measure.Timer.Time(MetricsRegistry.PostProcessingTime)) { await AfterCommit(block); + + if (Config.Diagnostics) + nextProtocol.Diagnostics.TrackChanges(); + + await Db.SaveChangesAsync(); } Logger.LogDebug("Process quotes"); @@ -121,6 +120,15 @@ public virtual async Task CommitBlock(int head) await nextProtocol.PostActivation(state); } + if (Config.Diagnostics) + { + Logger.LogDebug("Diagnostics"); + using (Metrics.Measure.Timer.Time(MetricsRegistry.DiagnosticsTime)) + { + await nextProtocol.Diagnostics.Run(block); + } + } + Logger.LogDebug("Commit DB transaction"); await tx.CommitAsync(); } @@ -184,6 +192,7 @@ public virtual async Task RevertLastBlock(string predecessor) Logger.LogDebug("Diagnostics"); using (Metrics.Measure.Timer.Time(MetricsRegistry.RevertDiagnosticsTime)) { + Diagnostics.TrackChanges(); await Diagnostics.Run(state.Level); } } @@ -361,6 +370,7 @@ void ClearCachedRelations() b.SetDepositsLimits = null; b.Revelation = null; b.Revelations = null; + b.StakingOps = null; b.Transactions = null; b.Migrations = null; b.RevelationPenalties = null; diff --git a/Tzkt.Sync/Protocols/TezosProtocols.cs b/Tzkt.Sync/Protocols/TezosProtocols.cs index d90484069..69602e0cf 100644 --- a/Tzkt.Sync/Protocols/TezosProtocols.cs +++ b/Tzkt.Sync/Protocols/TezosProtocols.cs @@ -32,6 +32,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) @@ -86,6 +87,7 @@ private static ProtocolHandler GetProtocolHandler(IServiceProvider services, str "PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc" => services.GetRequiredService(), "PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1" => services.GetRequiredService(), "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf" => services.GetRequiredService(), + "ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH" => services.GetRequiredService(), _ => null, }; } diff --git a/Tzkt.Sync/Services/Cache/CacheService.cs b/Tzkt.Sync/Services/Cache/CacheService.cs index d6371a23d..97cb3db8e 100644 --- a/Tzkt.Sync/Services/Cache/CacheService.cs +++ b/Tzkt.Sync/Services/Cache/CacheService.cs @@ -60,7 +60,6 @@ public async Task ResetAsync() Protocols.Reset(); Proposals.Reset(); Periods.Reset(); - Statistics.Reset(); Software.Reset(); Schemas.Reset(); Storages.Reset(); @@ -76,6 +75,7 @@ public async Task ResetAsync() await AppState.ResetAsync(); await Accounts.ResetAsync(); + await Statistics.ResetAsync(); } public void Trim() diff --git a/Tzkt.Sync/Services/Cache/ProtocolsCache.cs b/Tzkt.Sync/Services/Cache/ProtocolsCache.cs index cb03a6755..90edae1be 100644 --- a/Tzkt.Sync/Services/Cache/ProtocolsCache.cs +++ b/Tzkt.Sync/Services/Cache/ProtocolsCache.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; - +using Microsoft.EntityFrameworkCore; using Tzkt.Data; using Tzkt.Data.Models; @@ -100,6 +95,12 @@ public async Task FindByLevelAsync(int level) return protocol; } + public async Task GetCycle(int level) + { + var protocol = await FindByLevelAsync(level); + return protocol.GetCycle(level); + } + public void Remove(Protocol protocol) { CachedByCode.Remove(protocol.Code); diff --git a/Tzkt.Sync/Services/Cache/StatisticsCache.cs b/Tzkt.Sync/Services/Cache/StatisticsCache.cs index df2f3d51b..3681fa0c7 100644 --- a/Tzkt.Sync/Services/Cache/StatisticsCache.cs +++ b/Tzkt.Sync/Services/Cache/StatisticsCache.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; - +using Microsoft.EntityFrameworkCore; using Tzkt.Data; using Tzkt.Data.Models; @@ -11,7 +6,9 @@ namespace Tzkt.Sync.Services.Cache { public class StatisticsCache { - static Statistics CachedStatistics; + static Statistics _Current; + + public Statistics Current => _Current; readonly TzktContext Db; @@ -20,22 +17,14 @@ public StatisticsCache(TzktContext db) Db = db; } - public void Reset() - { - CachedStatistics = null; - } - - public void Add(Statistics stats) + public async Task ResetAsync() { - CachedStatistics = stats; + _Current = await Db.Statistics.OrderByDescending(x => x.Id).FirstOrDefaultAsync(); } - public async Task GetAsync(int level) + public void SetCurrent(Statistics stats) { - if (CachedStatistics?.Level != level) - CachedStatistics = await Db.Statistics.FirstAsync(x => x.Level == level); - - return CachedStatistics; + _Current = stats; } } } diff --git a/Tzkt.Sync/Tzkt.Sync.csproj b/Tzkt.Sync/Tzkt.Sync.csproj index a23d22930..131afad15 100644 --- a/Tzkt.Sync/Tzkt.Sync.csproj +++ b/Tzkt.Sync/Tzkt.Sync.csproj @@ -19,7 +19,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/docker-compose.ghost.yml b/docker-compose.ghost.yml index 814cdcd42..bb3bb8ffd 100644 --- a/docker-compose.ghost.yml +++ b/docker-compose.ghost.yml @@ -4,7 +4,7 @@ services: ghost-db: container_name: ghost-db restart: always - image: postgres:13 + image: postgres:16 environment: POSTGRES_USER: ${POSTGRES_USER:-tzkt} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-qwerty} diff --git a/docker-compose.nairobi.yml b/docker-compose.nairobi.yml deleted file mode 100644 index 2b4d693c7..000000000 --- a/docker-compose.nairobi.yml +++ /dev/null @@ -1,44 +0,0 @@ -version: '3' - -services: - nairobi-db: - container_name: nairobi-db - restart: always - image: postgres:13 - environment: - POSTGRES_USER: ${POSTGRES_USER:-tzkt} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-qwerty} - POSTGRES_DB: ${POSTGRES_DB:-tzkt_db} - volumes: - - nairobi-postgres:/var/lib/postgresql/data - ports: - - 127.0.0.1:5434:5432 - - nairobi-api: - container_name: nairobi-api - restart: always - image: bakingbad/tzkt-api:latest - depends_on: - - nairobi-db - environment: - ConnectionStrings__DefaultConnection: host=nairobi-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; - Kestrel__Endpoints__Http__Url: http://0.0.0.0:5000 - ports: - - 0.0.0.0:5020:5000 - - nairobi-sync: - container_name: nairobi-sync - restart: always - image: bakingbad/tzkt-sync:latest - environment: - ConnectionStrings__DefaultConnection: host=nairobi-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; - Kestrel__Endpoints__Http__Url: http://0.0.0.0:5001 - TezosNode__Endpoint: https://rpc.tzkt.io/nairobinet/ - Protocols__Diagnostics: false - depends_on: - - nairobi-db - ports: - - 0.0.0.0:5021:5001 - -volumes: - nairobi-postgres: diff --git a/docker-compose.mumbai.yml b/docker-compose.oxford.yml similarity index 67% rename from docker-compose.mumbai.yml rename to docker-compose.oxford.yml index 23e5435a1..27d60f3b6 100644 --- a/docker-compose.mumbai.yml +++ b/docker-compose.oxford.yml @@ -1,43 +1,43 @@ version: '3' services: - mumbai-db: - container_name: mumbai-db + oxford-db: + container_name: oxford-db restart: always - image: postgres:13 + image: postgres:16 environment: POSTGRES_USER: ${POSTGRES_USER:-tzkt} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-qwerty} POSTGRES_DB: ${POSTGRES_DB:-tzkt_db} volumes: - - mumbai-postgres:/var/lib/postgresql/data + - oxford-postgres:/var/lib/postgresql/data ports: - 127.0.0.1:5435:5432 - mumbai-api: - container_name: mumbai-api + oxford-api: + container_name: oxford-api restart: always image: bakingbad/tzkt-api:latest depends_on: - - mumbai-db + - oxford-db environment: - ConnectionStrings__DefaultConnection: host=mumbai-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; + ConnectionStrings__DefaultConnection: host=oxford-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; Kestrel__Endpoints__Http__Url: http://0.0.0.0:5000 ports: - 0.0.0.0:5030:5000 - mumbai-sync: - container_name: mumbai-sync + oxford-sync: + container_name: oxford-sync restart: always image: bakingbad/tzkt-sync:latest environment: - ConnectionStrings__DefaultConnection: host=mumbai-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; + ConnectionStrings__DefaultConnection: host=oxford-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; Kestrel__Endpoints__Http__Url: http://0.0.0.0:5001 - TezosNode__Endpoint: https://rpc.tzkt.io/mumbainet/ + TezosNode__Endpoint: https://rpc.tzkt.io/oxfordnet/ depends_on: - - mumbai-db + - oxford-db ports: - 0.0.0.0:5031:5001 volumes: - mumbai-postgres: + oxford-postgres: diff --git a/docker-compose.yml b/docker-compose.yml index f66326117..4caed2a33 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: db: container_name: tzkt-db restart: always - image: postgres:13 + image: postgres:16 environment: POSTGRES_USER: ${POSTGRES_USER:-tzkt} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-qwerty}