Skip to content

Commit

Permalink
Update rewards for existing future cycles during migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed Feb 13, 2024
1 parent d7823cb commit f1353e2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Tzkt.Sync/Protocols/Handlers/Proto18/Activation/ProtoActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ protected override async Task MigrateContext(AppState state)
await RemoveDeadRefutationGames(state);
await RemoveBigmapKeys(state);
await MigrateBakers(state);
await MigrateCycles(state);
}

protected async Task RemoveDeadRefutationGames(AppState state)
Expand Down Expand Up @@ -385,5 +386,25 @@ async Task MigrateBakers(AppState state)
baker.TotalStakedBalance = stakes.GetValueOrDefault(baker.Address);
}
}

async Task MigrateCycles(AppState state)
{
var issuances = await Proto.Rpc.GetExpectedIssuance(state.Level);
var protocol = await Cache.Protocols.GetAsync(state.NextProtocol);
var cycles = await Db.Cycles.Where(x => x.Index > state.Cycle).ToListAsync();
foreach (var cycle in cycles)
{
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");
}

}
}
}

0 comments on commit f1353e2

Please sign in to comment.