Skip to content

Commit

Permalink
Merge pull request #283 from Concordium/p7-migration-delegators
Browse files Browse the repository at this point in the history
Run P7 delegator migrations at every P7 block instead of only payday
  • Loading branch information
limemloh authored Oct 30, 2024
2 parents 2e1fc4a + f274858 commit caed5d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
28 changes: 14 additions & 14 deletions backend/Application/Api/GraphQL/Import/DelegationImportHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ public async Task<DelegationUpdateResults> HandleDelegationUpdates(BlockDataPayl
// meaning we can just return for blocks from a protocol version prior to that.
if (payload.BlockInfo.ProtocolVersion < ProtocolVersion.P4) return resultBuilder.Build();

// Handle effective pending changes for delegators and update the resultBuilder.
if (importPaydayStatus is FirstBlockAfterPayday firstBlockAfterPayday) {
if (payload.BlockInfo.ProtocolVersion < ProtocolVersion.P7) {
// Stake changes only take effect from the first block in each payday.
await _writer.UpdateAccountsWithPendingDelegationChange(firstBlockAfterPayday.PaydayTimestamp,
account => ApplyPendingChange(account, resultBuilder));
} else if (payload.BlockInfo.ProtocolVersion == ProtocolVersion.P7) {
// Starting from Concordium Protocol Version 7 stake changes are immediate,
// meaning no delegators are expected to have pending changes from this point.
// Only the first reward day in P7 should this do anything, afterwards it is a
// no-op, since no accounts with pending changes are expected.
await _writer.UpdateAccountsWithPendingDelegationChange(DateTimeOffset.MaxValue,
account => ApplyPendingChange(account, resultBuilder));
}
if (payload.BlockInfo.ProtocolVersion < ProtocolVersion.P7 && importPaydayStatus is FirstBlockAfterPayday firstBlockAfterPayday) {
// Handle effective pending changes for delegators and update the resultBuilder.
// Stake changes only take effect from the first block in each payday.
await _writer.UpdateAccountsWithPendingDelegationChange(firstBlockAfterPayday.PaydayTimestamp,
account => ApplyPendingChange(account, resultBuilder));

} else if (payload.BlockInfo.ProtocolVersion == ProtocolVersion.P7) {
// Starting from Concordium Protocol Version 7 stake changes are immediate,
// meaning no delegators are expected to have pending changes from this point.
// Only the block in P7 should this do anything, afterwards it is a
// no-op, since no accounts with pending changes are expected.
await _writer.UpdateAccountsWithPendingDelegationChange(DateTimeOffset.MaxValue,
account => ApplyPendingChange(account, resultBuilder));

}

// Handle delegation state changes due to pools that are either removed or closed for delegation.
Expand Down
2 changes: 1 addition & 1 deletion backend/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<Version>1.9.1</Version>
<Version>1.9.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Unreleased changes

## 1.9.2

- Bugfix
- Run P6-P7 migration logic for pending changes of delegators in every P7 blocks instead of only at paydays.

## 1.9.1

- Bugfix
Expand Down

0 comments on commit caed5d8

Please sign in to comment.