From af6d3c716108728234b7c2cf92c87035439f905f Mon Sep 17 00:00:00 2001 From: Thomas Dinsdale-Young Date: Thu, 15 Aug 2024 17:12:45 +0200 Subject: [PATCH 1/2] Support `DelegationRemoved` and `BakerRemoved` case for `BakerEvent` and `DelegatorEvent`. --- CHANGELOG.md | 4 ++++ concordium-base | 2 +- src/types/mod.rs | 9 +++++++++ src/types/summary_helper.rs | 20 ++++++++++++++++++++ src/v2/conversions.rs | 6 ++++++ src/v2/generated/concordium.v2.rs | 25 +++++++++++++++++++++++-- src/v2/proto_schema_version.rs | 2 +- 7 files changed, 64 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35a7316c6..6fcf8e17e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ and `baker_stake_pending_change` fields are moved into a new type, `ActiveBakerPoolStatus`. A new field is added to `BakerPoolStatus` which includes these fields, namely `active_baker_pool_status: Option`. This field is `Some(..)` iff `pool_info` is included in the node's `PoolInfoResponse`. +- `DelegationEvent` adds a `BakerRemoved` case, as `ConfigureDelegation` can replace a + baker with delegation from protocol 7. +- `BakerEvent` adds a `DelegationRemove` case, as `ConfigureBaker` can replace a delegator + with a baker from protocol 7. ## 4.3.0 diff --git a/concordium-base b/concordium-base index 469c82720..fd2beed7f 160000 --- a/concordium-base +++ b/concordium-base @@ -1 +1 @@ -Subproject commit 469c82720cdc66a6a7ab8c38f08a30aa0e0ccdb8 +Subproject commit fd2beed7fbcde7adf37e9cf0607b606605bd1c94 diff --git a/src/types/mod.rs b/src/types/mod.rs index 699cfa050..e9bad0d02 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -2031,6 +2031,10 @@ pub enum DelegationEvent { /// Delegator's id delegator_id: DelegatorId, }, + BakerRemoved { + /// Baker's id + baker_id: BakerId, + }, } /// Events that may result from the [TransactionType::ConfigureBaker] @@ -2095,6 +2099,11 @@ pub enum BakerEvent { /// The finalization reward commission finalization_reward_commission: AmountFraction, }, + /// Removed an existing delegator + DelegationRemoved { + /// Delegator's id + delegator_id: DelegatorId, + }, } #[derive(Debug, Clone)] diff --git a/src/types/summary_helper.rs b/src/types/summary_helper.rs index 0249c555e..9e830d280 100644 --- a/src/types/summary_helper.rs +++ b/src/types/summary_helper.rs @@ -687,6 +687,12 @@ impl From for BlockItemSummary { super::BakerEvent::BakerKeysUpdated { data } => { Event::BakerKeysUpdated { data } } + super::BakerEvent::DelegationRemoved { delegator_id } => { + Event::DelegationRemoved { + delegator_id, + account: sender, + } + } }) .collect(); (Some(ty), BlockItemResult::Success { events }) @@ -740,6 +746,12 @@ impl From for BlockItemSummary { account: sender, } } + super::DelegationEvent::BakerRemoved { baker_id } => { + Event::BakerRemoved { + baker_id, + account: sender, + } + } }) .collect(); (Some(ty), BlockItemResult::Success { events }) @@ -1187,6 +1199,10 @@ fn convert_account_transaction( baker_id, finalization_reward_commission, }), + Event::DelegationRemoved { + delegator_id, + account: _, + } => Ok(super::BakerEvent::DelegationRemoved { delegator_id }), _ => Err(ConversionError::InvalidTransactionResult), }) .collect::>()?; @@ -1236,6 +1252,10 @@ fn convert_account_transaction( delegator_id, account: _, } => Ok(super::DelegationEvent::DelegationRemoved { delegator_id }), + Event::BakerRemoved { + baker_id, + account: _, + } => Ok(super::DelegationEvent::BakerRemoved { baker_id }), _ => Err(ConversionError::InvalidTransactionResult), }) .collect::>()?; diff --git a/src/v2/conversions.rs b/src/v2/conversions.rs index fe3c71ad9..5933fbe21 100644 --- a/src/v2/conversions.rs +++ b/src/v2/conversions.rs @@ -1857,6 +1857,9 @@ impl TryFrom for super::types::DelegationEvent { delegation_event::Event::DelegationRemoved(v) => Self::DelegationRemoved { delegator_id: v.try_into()?, }, + delegation_event::Event::BakerRemoved(v) => Self::BakerRemoved { + baker_id: v.baker_id.require()?.into(), + }, }) } } @@ -1935,6 +1938,9 @@ impl TryFrom for super::types::BakerEvent { .into(), } } + baker_event::Event::DelegationRemoved(v) => Self::DelegationRemoved { + delegator_id: v.delegator_id.require()?.try_into()?, + }, }) } } diff --git a/src/v2/generated/concordium.v2.rs b/src/v2/generated/concordium.v2.rs index f02f771c1..ec1b9269c 100644 --- a/src/v2/generated/concordium.v2.rs +++ b/src/v2/generated/concordium.v2.rs @@ -1668,7 +1668,7 @@ pub struct RegisteredData { pub struct BakerEvent { #[prost( oneof = "baker_event::Event", - tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11" + tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12" )] pub event: ::core::option::Option, } @@ -1776,6 +1776,14 @@ pub mod baker_event { #[prost(message, optional, tag = "2")] pub finalization_reward_commission: ::core::option::Option, } + /// Removed an existing delegator. + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct DelegationRemoved { + /// Delegator's id. + #[prost(message, optional, tag = "1")] + pub delegator_id: ::core::option::Option, + } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Event { @@ -1812,6 +1820,9 @@ pub mod baker_event { /// The baker's finalization reward commission was updated. #[prost(message, tag = "11")] BakerSetFinalizationRewardCommission(BakerSetFinalizationRewardCommission), + /// An existing delegator was removed. + #[prost(message, tag = "12")] + DelegationRemoved(DelegationRemoved), } } /// The identifier for a delegator. @@ -1824,7 +1835,7 @@ pub struct DelegatorId { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DelegationEvent { - #[prost(oneof = "delegation_event::Event", tags = "1, 2, 3, 4, 5, 6")] + #[prost(oneof = "delegation_event::Event", tags = "1, 2, 3, 4, 5, 6, 7")] pub event: ::core::option::Option, } /// Nested message and enum types in `DelegationEvent`. @@ -1870,6 +1881,13 @@ pub mod delegation_event { pub delegation_target: ::core::option::Option, } #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct BakerRemoved { + /// Baker's id + #[prost(message, optional, tag = "1")] + pub baker_id: ::core::option::Option, + } + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Event { /// The delegator's stake increased. @@ -1890,6 +1908,9 @@ pub mod delegation_event { /// A delegator was removed. #[prost(message, tag = "6")] DelegationRemoved(super::DelegatorId), + /// An existing baker was removed. + #[prost(message, tag = "7")] + BakerRemoved(BakerRemoved), } } /// Effects of an account transaction. All variants except `None` diff --git a/src/v2/proto_schema_version.rs b/src/v2/proto_schema_version.rs index 34ca3ef59..a65f80b87 100644 --- a/src/v2/proto_schema_version.rs +++ b/src/v2/proto_schema_version.rs @@ -1 +1 @@ -pub const PROTO_SCHEMA_VERSION: &str = "7f9899b3a27fc2b0132a058a46f953e13d59f739"; +pub const PROTO_SCHEMA_VERSION: &str = "066a8514c1e89bbaa7989c708ae737fc466b0737"; From b1d3844626b9c37dfd8fdcb0da95f08ead75b87d Mon Sep 17 00:00:00 2001 From: Thomas Dinsdale-Young Date: Fri, 16 Aug 2024 13:14:18 +0200 Subject: [PATCH 2/2] Address review comments. --- src/types/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/types/mod.rs b/src/types/mod.rs index e9bad0d02..ca2840b48 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -2032,7 +2032,10 @@ pub enum DelegationEvent { delegator_id: DelegatorId, }, BakerRemoved { - /// Baker's id + /// The id of the baker that was removed. If the account is a baker in + /// the current payday, it will remain so until the next payday, + /// although the baker record will be removed from the account + /// immediately. baker_id: BakerId, }, } @@ -2101,7 +2104,10 @@ pub enum BakerEvent { }, /// Removed an existing delegator DelegationRemoved { - /// Delegator's id + /// The id of the delegator that was removed. If the account is a + /// delegator in the current payday, it will remain so until the + /// next payday, although the delegation record will be removed + /// from the account immediately. delegator_id: DelegatorId, }, }