Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cooldown changes #1175

Merged
merged 101 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
894f055
Bump base.
eb-concordium Apr 2, 2024
cdb52ac
Work on covering new account version.
eb-concordium Apr 2, 2024
ec3a173
Delete .dat file.
eb-concordium Apr 2, 2024
4cb3a69
Fix some warnings.
eb-concordium Apr 2, 2024
35a64f0
A bit of work on the blockstate.
eb-concordium Apr 9, 2024
e1e2316
Merge remote-tracking branch 'remotes/origin/main' into cooldown-changes
td202 Apr 9, 2024
412d253
Stake cooldown migration.
td202 Apr 12, 2024
392d687
CooldownQueue definitions an integration with account structure.
td202 Apr 26, 2024
cb060d1
Restructuring cooldown implementation. Towards migration.
td202 May 2, 2024
c3c8b01
Migrate cooldowns on accounts.
td202 May 6, 2024
1271bdf
Make sure migrated active baker stake is computed correctly.
td202 May 6, 2024
cde34d5
Migration testing. Renaming some stake related functions and exposing…
td202 May 23, 2024
d8f5ce6
Changes to GetBakerPoolStatus GRPC.
td202 May 27, 2024
fdcaf70
Fix handling of GetPoolInfo.
td202 May 28, 2024
fcf2bf2
Support cooldown and available balance in account info query.
td202 Jun 4, 2024
2882853
Handle pre-pre-cooldown -> pre-cooldown -> cooldown -> available tran…
td202 Jun 10, 2024
953d070
Update base
td202 Jun 10, 2024
f335fd1
Work on configure baker and delegator in P7.
eb-concordium Jun 24, 2024
98acd46
Merge branch 'cooldown-changes' into configure-baker-delegator
eb-concordium Jun 24, 2024
732daf6
Fix compilation after merge.
eb-concordium Jun 24, 2024
96cc0cb
Release cooldowns on the account when increasing stake.
eb-concordium Jun 26, 2024
3b2da8a
Merge remote-tracking branch 'remotes/origin/main' into cooldown-changes
td202 Jun 26, 2024
c4f864e
Clean-up
td202 Jun 26, 2024
3a900f2
Tests and account storage.
td202 Jun 27, 2024
bb4dfb1
Update base, fix tests.
td202 Jun 28, 2024
7f873d5
Fix state hashes in tests.
td202 Jun 28, 2024
8e9b6f7
Fix hashes in tests.
td202 Jul 9, 2024
73d1c26
More work on configure baker and delegator
eb-concordium Jul 9, 2024
b747b48
Testing for cooldown processing in block state.
td202 Jul 9, 2024
16b5b74
Also release cooldown when adding baker or delegator.
eb-concordium Jul 16, 2024
2ae417e
Add testing for epoch transitions.
td202 Jul 17, 2024
0cad46a
Allow immediate switch from delegator to baker.
eb-concordium Jul 18, 2024
01bc102
Merge branch 'cooldown-changes' into configure-baker-delegator
td202 Jul 19, 2024
e920c09
Refactoring and simplifying reactivation of cooldown stake.
td202 Jul 19, 2024
69b465d
Start of refactoring for configure baker.
td202 Jul 19, 2024
416e94f
New configure baker.
td202 Jul 20, 2024
dc1407e
Delegation
td202 Jul 22, 2024
6ad3320
Add delegator.
td202 Jul 22, 2024
057d85a
Configure delegators.
td202 Jul 23, 2024
3883c94
Scheduler changes to configure baker/delegator in progress.
td202 Jul 24, 2024
c59d5f0
Scheduler handling for configure baker and delegator.
td202 Jul 25, 2024
442ef3c
Tests and fixes.
td202 Jul 25, 2024
861cccc
Remove bsoConfigureBaker, bsoConfigureDelegation. Update tests.
td202 Jul 26, 2024
fafa769
Simplify the basic blockstate representation of account cooldown queues.
td202 Jul 26, 2024
a07db0f
Commit missing test file.
td202 Jul 26, 2024
2cebf76
Refine account migration.
td202 Jul 29, 2024
5970cf9
Reject adding a delegator with stake 0.
eb-concordium Jul 30, 2024
6eae174
Add more delegation tests.
eb-concordium Jul 30, 2024
7fef710
Revert move of migratePersistentActiveBakers.
td202 Jul 30, 2024
a4419d1
Require non-zero stake for baker, even if minimum threshold is set at 0.
td202 Jul 30, 2024
b4adefb
Documentation.
td202 Jul 31, 2024
ddb8509
Merge remote-tracking branch 'remotes/origin/revise-get-pool-status' …
td202 Aug 1, 2024
823a0ab
Merge remote-tracking branch 'remotes/origin/revise-get-pool-status' …
td202 Aug 1, 2024
42efdd5
Enable P7 testing.
td202 Aug 1, 2024
06b029d
Add more tests.
eb-concordium Aug 2, 2024
48a0b38
Simplify instance
td202 Aug 2, 2024
cb5df8a
Merge remote-tracking branch 'remotes/origin/basic-cooldown-type' int…
td202 Aug 2, 2024
705f724
Merge remote-tracking branch 'remotes/origin/cooldowns-account-defs' …
td202 Aug 2, 2024
2a5fa4d
Add global cooldown index. Support P6->P7 migration.
td202 Aug 2, 2024
2595f88
Merge remote-tracking branch 'remotes/origin/cooldown-migration' into…
td202 Aug 2, 2024
dba06fc
Merge remote-tracking branch 'remotes/origin/cooldown-migration' into…
td202 Aug 5, 2024
aa77fad
Cooldown processing and epoch transitions.
td202 Aug 5, 2024
57bae02
Documentation
td202 Aug 5, 2024
32e4710
Merge remote-tracking branch 'remotes/origin/cooldown-processing' int…
td202 Aug 5, 2024
6d5f08c
Tests for bsoAddValidator and bsoUpdateValidator. Bugfixes.
td202 Aug 8, 2024
d72ce77
Configure delegator tests
td202 Aug 9, 2024
c82c6e7
Update delegator: fix corner case behaviours, tests and documentation.
td202 Aug 12, 2024
9cda84d
Documentation
td202 Aug 12, 2024
9822357
Revert version bump
td202 Aug 13, 2024
c809975
Merge remote-tracking branch 'remotes/origin/cooldown-processing' int…
td202 Aug 14, 2024
c559771
Update base. Documentation changes.
td202 Aug 15, 2024
4f9b853
Fix behaviour when transitioning from baker to delegator or vice-vers…
td202 Aug 23, 2024
0740444
Addressing review comments.
td202 Aug 26, 2024
63fcde8
Set protocol update hash. Bump version.
td202 Aug 26, 2024
b53dfb0
Bump base.
td202 Aug 26, 2024
a506466
Merge pull request #1227 from Concordium/release-7.0
td202 Aug 26, 2024
e9b98bb
Update submodule
td202 Aug 27, 2024
ddf852e
Fix consensus not recognizing P7 update
Sep 5, 2024
8fbfba0
Modify test to exercise account migration bug.
td202 Sep 6, 2024
e3519c2
Fix account migration.
td202 Sep 6, 2024
e5ccc6c
Merge remote-tracking branch 'remotes/origin/cooldown-changes' into a…
td202 Sep 9, 2024
5038994
Update changelog. Bump version for release.
td202 Sep 9, 2024
4ea2288
Merge pull request #1229 from Concordium/account-migration-fix
td202 Sep 9, 2024
29b43bb
Fix handling of consensus exceptions.
td202 Sep 11, 2024
747a3c6
Update changelog.
td202 Sep 11, 2024
e04ea03
Address review comments.
eb-concordium Sep 11, 2024
24f1f99
Address one more review comment.
eb-concordium Sep 11, 2024
b66f741
Address comments from code review.
eb-concordium Sep 11, 2024
72d5f73
Address more comments from code review.
eb-concordium Sep 11, 2024
0b29e1e
Fix the payday timing at the P6->P7 protocol update.
td202 Sep 11, 2024
b352765
Address review comment
td202 Sep 11, 2024
55e442b
Merge pull request #1234 from Concordium/consensus-exception
td202 Sep 11, 2024
256fc66
Merge pull request #1235 from Concordium/payday-timing
td202 Sep 11, 2024
772be2a
7.0.2 release.
td202 Sep 11, 2024
01b7ea1
Merge remote-tracking branch 'remotes/origin/main' into cooldown-changes
td202 Sep 11, 2024
0799547
Merge branch 'cooldown-changes' into 7.0/branch
td202 Sep 11, 2024
b1fd2f3
Fix issue where an error is thrown when the last finalized block is t…
td202 Sep 12, 2024
f15c014
Fix computation of regenesis block heights.
td202 Sep 12, 2024
f2fae8f
Update changelog. Bump version.
td202 Sep 12, 2024
fb000d1
Merge pull request #1238 from Concordium/7.0-fixes
td202 Sep 12, 2024
0b33407
Fix base ref
td202 Sep 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased changes

## 7.0.0

- Fix a bug where `GetBakersRewardPeriod` returns incorrect data (#1176).
- Fix a bug where `GetPoolInfo` returns incorrect data (#1177).
- Change the severity of logs for failed gRPC API requests to DEBUG level.
Expand All @@ -20,6 +22,16 @@
`TransferToPublic` remains enabled, allowing existing encrypted balances to be
decrypted.
- Improve logging around protocol update events.
- Changes to stake cooldown behavior in protocol version 7:
- When stake is reduced or removed from a validator or delegator, it becomes
inactive, and is not counted for future stake calculations. The inactive
stake is not spendable, but is released after a cooldown period elapses.
- Changes to validators and delegators can be made while stake is in cooldown,
including changing the stake, or changing directly between validator and
delegator.
- Fix a bug where a configure-validator transaction that is rejected for having
a duplicate aggregation key would report the old key for the validator,
rather than the key that is a duplicate.
eb-concordium marked this conversation as resolved.
Show resolved Hide resolved

## 6.3.1

Expand Down
209 changes: 123 additions & 86 deletions concordium-consensus/src/Concordium/GlobalState/BakerInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ data BakerKeyUpdate = BakerKeyUpdate
}
deriving (Eq, Ord, Show)

-- | Extract the 'BakerKeyUpdate' from a 'BakerKeysWithProofs'.
bakerKeysWithoutProofs :: BakerKeysWithProofs -> BakerKeyUpdate
bakerKeysWithoutProofs BakerKeysWithProofs{..} =
BakerKeyUpdate
{ bkuSignKey = bkwpSignatureVerifyKey,
bkuAggregationKey = bkwpAggregationVerifyKey,
bkuElectionKey = bkwpElectionVerifyKey
}

data BakerKeyUpdateResult
= -- | The keys were updated successfully
BKUSuccess !BakerId
Expand Down Expand Up @@ -174,32 +183,83 @@ data BakerAddResult
BAStakeUnderThreshold
deriving (Eq, Ord, Show)

-- | Data structure used to add/remove/update baker.
data BakerConfigure
= -- | Add a baker, all fields are required.
BakerConfigureAdd
{ bcaKeys :: !BakerKeyUpdate,
bcaCapital :: !Amount,
bcaRestakeEarnings :: !Bool,
bcaOpenForDelegation :: !OpenStatus,
bcaMetadataURL :: !UrlText,
bcaTransactionFeeCommission :: !AmountFraction,
bcaBakingRewardCommission :: !AmountFraction,
bcaFinalizationRewardCommission :: !AmountFraction
}
| -- | Update baker with optional fields.
BakerConfigureUpdate
{ -- | The timestamp of the current slot (slot time).
bcuSlotTimestamp :: !Timestamp,
bcuKeys :: !(Maybe BakerKeyUpdate),
bcuCapital :: !(Maybe Amount),
bcuRestakeEarnings :: !(Maybe Bool),
bcuOpenForDelegation :: !(Maybe OpenStatus),
bcuMetadataURL :: !(Maybe UrlText),
bcuTransactionFeeCommission :: !(Maybe AmountFraction),
bcuBakingRewardCommission :: !(Maybe AmountFraction),
bcuFinalizationRewardCommission :: !(Maybe AmountFraction)
-- | Result of remove baker.
data BakerRemoveResult
= -- | The baker was removed, effective from the given epoch.
BRRemoved !BakerId !Epoch
| -- | This is not a valid baker.
BRInvalidBaker
| -- | A change is already pending on this baker.
BRChangePending !BakerId
deriving (Eq, Ord, Show)

-- | Parameters for adding a validator.
data ValidatorAdd = ValidatorAdd
{ -- | The keys for the validator.
vaKeys :: !BakerKeyUpdate,
-- | The initial stake.
vaCapital :: !Amount,
-- | Whether to restake earned rewards
vaRestakeEarnings :: !Bool,
-- | Whether the validator pool is open for delegation.
vaOpenForDelegation :: !OpenStatus,
-- | The metadata URL for the validator.
vaMetadataURL :: !UrlText,
-- | The commission rates for the validator.
vaCommissionRates :: !CommissionRates
}
deriving (Eq, Show)

-- | Parameters for updating an existing validator. Where a field is 'Nothing', the field is not
-- updated.
data ValidatorUpdate = ValidatorUpdate
{ -- | The new keys for the validator.
vuKeys :: !(Maybe BakerKeyUpdate),
-- | The new capital for the validator. If this is @Just 0@, the validator is removed.
vuCapital :: !(Maybe Amount),
-- | Whether to restake earned rewards.
vuRestakeEarnings :: !(Maybe Bool),
-- | Whether the validator pool is open for delegation.
vuOpenForDelegation :: !(Maybe OpenStatus),
-- | The new metadata URL for the validator.
vuMetadataURL :: !(Maybe UrlText),
-- | The new transaction fee commission for the validator.
vuTransactionFeeCommission :: !(Maybe AmountFraction),
-- | The new baking reward commission for the validator.
vuBakingRewardCommission :: !(Maybe AmountFraction),
-- | The new finalization reward commission for the validator.
vuFinalizationRewardCommission :: !(Maybe AmountFraction)
}
deriving (Eq, Show)

-- | A 'ValidatorUpdate' that removes the validator.
validatorRemove :: ValidatorUpdate
validatorRemove =
ValidatorUpdate
{ vuKeys = Nothing,
vuCapital = Just 0,
vuRestakeEarnings = Nothing,
vuOpenForDelegation = Nothing,
vuMetadataURL = Nothing,
vuTransactionFeeCommission = Nothing,
vuBakingRewardCommission = Nothing,
vuFinalizationRewardCommission = Nothing
}

-- | Failure modes when configuring a validator.
data ValidatorConfigureFailure
= -- | The stake is below the required threshold dictated by current chain parameters.
VCFStakeUnderThreshold
| -- | The transaction fee commission is not in the allowed range.
VCFTransactionFeeCommissionNotInRange
| -- | The baking reward commission is not in the allowed range.
VCFBakingRewardCommissionNotInRange
| -- | The finalization reward commission is not in the allowed range.
VCFFinalizationRewardCommissionNotInRange
| -- | The aggregation key is already in use by another validator.
VCFDuplicateAggregationKey !BakerAggregationVerifyKey
| -- | A change is already pending on this validator.
VCFChangePending
deriving (Eq, Show)

-- | A baker update change result from configure baker. Used to indicate whether the configure will cause
Expand All @@ -216,55 +276,37 @@ data BakerConfigureUpdateChange
| BakerConfigureFinalizationRewardCommission !AmountFraction
deriving (Eq, Show)

-- | Result of configure baker.
data BakerConfigureResult
= -- | Configure baker successful.
BCSuccess ![BakerConfigureUpdateChange] !BakerId
| -- | Account unknown.
BCInvalidAccount
| -- | The aggregation key already exists.
BCDuplicateAggregationKey !BakerAggregationVerifyKey
| -- | The stake is below the required threshold dictated by current chain parameters.
BCStakeUnderThreshold
| -- | The finalization reward commission is not in the allowed range.
BCFinalizationRewardCommissionNotInRange
| -- | The baking reward commission is not in the allowed range.
BCBakingRewardCommissionNotInRange
| -- | The transaction fee commission is not in the allowed range.
BCTransactionFeeCommissionNotInRange
| -- | A change is already pending on this baker.
BCChangePending
| -- | This is not a valid baker.
BCInvalidBaker
-- | Parameters for adding a delegator.
data DelegatorAdd = DelegatorAdd
{ -- | The initial staked capital for the delegator.
daCapital :: !Amount,
-- | Whether to restake earnings.
daRestakeEarnings :: !Bool,
-- | The delegation target for the delegator.
daDelegationTarget :: !DelegationTarget
}
deriving (Eq, Show)

-- | Result of remove baker.
data BakerRemoveResult
= -- | The baker was removed, effective from the given epoch.
BRRemoved !BakerId !Epoch
| -- | This is not a valid baker.
BRInvalidBaker
| -- | A change is already pending on this baker.
BRChangePending !BakerId
deriving (Eq, Ord, Show)
-- | Parameters for updating an existing delegator. Where a field is 'Nothing', the field is not
-- updated.
data DelegatorUpdate = DelegatorUpdate
{ -- | The new capital for the delegator. If this is @Just 0@, the delegator is removed.
duCapital :: !(Maybe Amount),
-- | Whether to restake earnings.
duRestakeEarnings :: !(Maybe Bool),
-- | The new delegation target for the delegator.
duDelegationTarget :: !(Maybe DelegationTarget)
}
deriving (Eq, Show)

-- | Data structure used to add/remove/update delegator.
data DelegationConfigure
= -- | Add a delegator, all fields are required.
DelegationConfigureAdd
{ dcaCapital :: !Amount,
dcaRestakeEarnings :: !Bool,
dcaDelegationTarget :: !DelegationTarget
}
| -- | Update delegator with optional fields.
DelegationConfigureUpdate
{ -- | The timestamp of the current slot (slot time of the block in which the update occurs).
dcuSlotTimestamp :: !Timestamp,
dcuCapital :: !(Maybe Amount),
dcuRestakeEarnings :: !(Maybe Bool),
dcuDelegationTarget :: !(Maybe DelegationTarget)
-- | A 'DelegatorUpdate' that removes the delegator.
delegatorRemove :: DelegatorUpdate
delegatorRemove =
DelegatorUpdate
{ duCapital = Just 0,
duRestakeEarnings = Nothing,
duDelegationTarget = Nothing
}
deriving (Eq, Show)

-- | A delegation update change result from configure delegation. Used to indicate whether the
-- configure will cause any changes to the delegator's stake, restake earnings flag, etc.
Expand All @@ -275,24 +317,19 @@ data DelegationConfigureUpdateChange
| DelegationConfigureDelegationTarget !DelegationTarget
deriving (Eq, Show)

-- | Result of configure delegator.
data DelegationConfigureResult
= -- | Configure delegation successful.
DCSuccess ![DelegationConfigureUpdateChange] !DelegatorId
| -- | Account unknown.
DCInvalidAccount
| -- | A change is already pending on this delegator.
DCChangePending
| -- | This is not a valid delegator.
DCInvalidDelegator
| -- | Delegation target is not a valid baker.
DCInvalidDelegationTarget !BakerId
-- | Failure modes for configuring a delegator.
data DelegatorConfigureFailure
= -- | The delegation target is not a valid baker.
DCFInvalidDelegationTarget !BakerId
| -- | The pool is not open for delegators.
DCPoolClosed
DCFPoolClosed
| -- | The pool's total capital would become too large.
DCPoolStakeOverThreshold
| -- | The delegated capital would become too large in comparison with pool owner's equity capital.
DCPoolOverDelegated
DCFPoolStakeOverThreshold
| -- | The delegated capital would become too large in comparison with pool owner's equity
-- capital.
DCFPoolOverDelegated
| -- | A change is already pending on this delegator.
DCFChangePending
deriving (Eq, Show)

-- | Construct an 'AccountBaker' from a 'GenesisBaker'.
Expand Down
Loading