Skip to content

Commit fdfc9e2

Browse files
committed
Merge branch 'main' into feature/COR1958-rustsdk-update-web3id
2 parents 39bf6c5 + 200e3d2 commit fdfc9e2

15 files changed

+2978
-865
lines changed

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,40 @@
8484
- Type `Event`/`BakerPoolInfo` field `open_status` is now wrapped in `Upward`.
8585
- Bubble `Upward` from new variants of `VerifyKey` to `Upward<AccountCredentialWithoutProofs<...>>` in `AccountInfo::account_credentials`.
8686

87+
- BREAKING: Remove types associated with discontinued V1 API:
88+
- `types::BlockSummary`;
89+
- `types::UpdateKeysCollectionSkeleton` and `types::UpdateKeysCollection`;
90+
- `types::ChainParametersV0`, `types::ChainParametersV1`, `types::ChainParametersV2`, `types::ChainParametersV3`, `types::ChainParametersFamily` and `types::ChainParameters`.
91+
- `types::RewardParametersSkeleton` and `types::RewardParameters`;
92+
- `types::ScheduledUpdate`;
93+
- `types::UpdateQueue`;
94+
- `types::PendingUpdatesV0`, `types::PendingUpdatesV1`, `types::PendingUpdatesFamily`, and `types::PendingUpdates`;
95+
- `types::UpdatesSkeleton` and `types::Updates`;
96+
- removed from `concordium_base`:
97+
- `ChainParametersVersion0`, `ChainParametersVersion1`, `ChainParametersVersion2`, `ChainParametersVersion3`;
98+
- `MintDistributionFamily`, `MintDistribution` (use `MintDistributionV0` or `MintDistributionV1` directly instead where needed);
99+
- `GASRewardsFamily` and `GASRewardsFor` (use `GASRewards` and `GASRewardsV1` directly where needed);
100+
- `AuthorizationsFamily` and `Authorizations` (use `AuthorizationsV0` and `AuthorizationsV1` directly where needed).
101+
102+
- BREAKING: Remove `v2::ChainParameters`, `v2::ChainParametersV0`, `v2::ChainParametersV1`, `v2::ChainParametersV2` and `v2::ChainParametersV3`. These are replaced by `types::chain_parameters::ChainParameters`.
103+
- A number of supporting types for `ChainParameters` are introduced. These have conversions that can be used to construct the payload types for updating the corresponding parameter sets.
104+
- `types::chain_parameters::MintDistribution` (convertible to `types::MintDistributionV1`);
105+
- `types::chain_parameters::TransactionFeeDistribution` (convertible to `types::TransactionFeeDistribution`);
106+
- `types::chain_parameters::GasRewards` (convertible to `types::GASRewards` and `types::GASRewardsV1`);
107+
- `types::chain_parameters::StakingParameters` (convertible to `types::PoolParameters`);
108+
- `types::chain_parameters::Level2Keys` (provides `construct_update_signer`, convertible to `types::AuthorizationsV0` and `types::AuthorizationsV1`);
109+
- `types::chain_parameters::UpdateKeys`;
110+
- `types::chain_parameters::TimeoutParameters` (convertible to `types::TimeParameters`);
111+
- `types::chain_parameters::CooldownParameters` (convertible to `types::CooldownParameters`);
112+
- `types::chain_parameters::FinalizationCommitteeParameters` (convertible to `types::FinalizationCommitteeParameters`).
113+
- `types::chain_parameters::EnergyRate` with `ccd_cost` for computing Energy costs in CCD.
114+
- Compared to the former `v2::ChainParameters`, `types::chain_parameters::ChainParameters`:
115+
- no longer provides `micro_cd_per_energy`, which is replaced by `energy_rate`;
116+
- `ccd_cost` is removed, which should be replaced by calling `ccd_cost` on the energy rate instead;
117+
- the `foundation_account` getter function is removed, and should be replaced by direct access to the `foundation_account` field;
118+
- `common_update_keys` is removed, and instead `keys.level_2_keys` should be used, which can be used to construct an `UpdateSigner`, or converted to `types::AuthorizationsV0`.
119+
- BREAKING: The parameter of `PendingUpdateEffect::AddAnonymityRevoker` is now `Box`ed.
120+
87121
## 7.0.0
88122

89123
Adds support for integrating with Concordium nodes running protocol version 9.

examples/create-initial-accounts.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,22 @@ async fn main() -> anyhow::Result<()> {
9393
created_at,
9494
max_accounts: 100,
9595
alist: vec![
96-
(AttributeTag(0), AttributeKind("A".into())),
97-
(AttributeTag(1), AttributeKind("B".into())),
98-
(AttributeTag(2), AttributeKind("C".into())),
99-
(AttributeTag(3), AttributeKind("D".into())),
100-
(AttributeTag(4), AttributeKind("EE".into())),
101-
(AttributeTag(5), AttributeKind("FFF".into())),
102-
(AttributeTag(6), AttributeKind("GGGG".into())),
96+
(AttributeTag(0), AttributeKind::try_new("A".into()).unwrap()),
97+
(AttributeTag(1), AttributeKind::try_new("B".into()).unwrap()),
98+
(AttributeTag(2), AttributeKind::try_new("C".into()).unwrap()),
99+
(AttributeTag(3), AttributeKind::try_new("D".into()).unwrap()),
100+
(
101+
AttributeTag(4),
102+
AttributeKind::try_new("EE".into()).unwrap(),
103+
),
104+
(
105+
AttributeTag(5),
106+
AttributeKind::try_new("FFF".into()).unwrap(),
107+
),
108+
(
109+
AttributeTag(6),
110+
AttributeKind::try_new("GGGG".into()).unwrap(),
111+
),
103112
]
104113
.into_iter()
105114
.collect(),

examples/protocol-updates.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,19 @@ async fn main() -> anyhow::Result<()> {
9999
.context("Could not obtain chain parameters.")?
100100
.response;
101101

102+
let keys = summary
103+
.keys
104+
.level_2_keys
105+
.context("No level 2 keys in chain parameters.")?;
106+
102107
// find the key indices to sign with
103-
let signer = summary
104-
.common_update_keys()
105-
.construct_update_signer(&summary.common_update_keys().protocol, kps)
108+
let signer = keys
109+
.construct_update_signer(
110+
keys.protocol
111+
.as_ref()
112+
.context("Missing protocol update keys")?,
113+
kps,
114+
)
106115
.context("Could not construct signer.")?;
107116

108117
let mut seq_number = client
@@ -134,21 +143,17 @@ async fn main() -> anyhow::Result<()> {
134143
specification_auxiliary_data: Vec::new(),
135144
};
136145

146+
let pool_parameters_keys = keys.pool_parameters.context("Missing pool parameters")?;
147+
137148
let params_p4 = ProtocolUpdateDataP4 {
138149
update_default_commission_rate: CommissionRates {
139150
finalization: "1".parse().unwrap(),
140151
baking: "0.1".parse().unwrap(),
141152
transaction: "0.1".parse().unwrap(),
142153
},
143154
update_default_pool_state: OpenStatus::OpenForAll,
144-
update_cooldown_parameters_access_structure: summary
145-
.common_update_keys()
146-
.pool_parameters
147-
.clone(),
148-
update_time_parameters_access_structure: summary
149-
.common_update_keys()
150-
.pool_parameters
151-
.clone(),
155+
update_cooldown_parameters_access_structure: pool_parameters_keys.clone(),
156+
update_time_parameters_access_structure: pool_parameters_keys.clone(),
152157
update_cooldown_parameters: CooldownParameters {
153158
pool_owner_cooldown: 1800.into(),
154159
delegator_cooldown: 900.into(),

examples/update-exchange-rate.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use clap::AppSettings;
55
use concordium_rust_sdk::{
66
common::types::TransactionTime,
77
types::{
8+
chain_parameters::ChainParameters,
89
transactions::{update, BlockItem, Payload},
910
ExchangeRate, TransactionStatus, UpdateKeyPair, UpdatePayload,
1011
},
11-
v2::{self, BlockIdentifier, ChainParameters},
12+
v2::{self, BlockIdentifier},
1213
};
1314
use std::path::PathBuf;
1415
use structopt::StructOpt;
@@ -52,10 +53,19 @@ async fn main() -> anyhow::Result<()> {
5253
.context("Could not obtain last finalized block's chain parameters")?
5354
.response;
5455

56+
let keys = summary
57+
.keys
58+
.level_2_keys
59+
.context("No level 2 keys in chain parameters.")?;
60+
5561
// find the key indices to sign with
56-
let signer = summary
57-
.common_update_keys()
58-
.construct_update_signer(&summary.common_update_keys().micro_gtu_per_euro, kps)
62+
let signer = keys
63+
.construct_update_signer(
64+
keys.micro_ccd_per_euro
65+
.as_ref()
66+
.context("Missing micro CCD per Euro update keys.")?,
67+
kps,
68+
)
5969
.context("Invalid keys supplied.")?;
6070

6171
let seq_number = client

examples/update-validator-score-param.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ use concordium_base::updates::ValidatorScoreParameters;
66
use concordium_rust_sdk::{
77
common::types::TransactionTime,
88
types::{
9+
chain_parameters::ChainParameters,
910
transactions::{update, BlockItem, Payload},
1011
TransactionStatus, UpdateKeyPair, UpdatePayload,
1112
},
12-
v2::{self, BlockIdentifier, ChainParameters},
13+
v2::{self, BlockIdentifier},
1314
};
1415
use std::path::PathBuf;
1516
use structopt::StructOpt;
@@ -54,10 +55,19 @@ async fn main() -> anyhow::Result<()> {
5455
.context("Could not obtain last finalized block's chain parameters")?
5556
.response;
5657

58+
let keys = summary
59+
.keys
60+
.level_2_keys
61+
.context("No level 2 keys in chain parameters.")?;
62+
5763
// find the key indices to sign with
58-
let signer = summary
59-
.common_update_keys()
60-
.construct_update_signer(&summary.common_update_keys().micro_gtu_per_euro, kps)
64+
let signer = keys
65+
.construct_update_signer(
66+
keys.micro_ccd_per_euro
67+
.as_ref()
68+
.context("Missing micro CCD per Euro update keys.")?,
69+
kps,
70+
)
6171
.context("Invalid keys supplied.")?;
6272

6373
let seq_number = client

examples/v2_create_initial_accounts.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,22 @@ async fn main() -> anyhow::Result<()> {
9494
created_at,
9595
max_accounts: 100,
9696
alist: vec![
97-
(AttributeTag(0), AttributeKind("A".into())),
98-
(AttributeTag(1), AttributeKind("B".into())),
99-
(AttributeTag(2), AttributeKind("C".into())),
100-
(AttributeTag(3), AttributeKind("D".into())),
101-
(AttributeTag(4), AttributeKind("EE".into())),
102-
(AttributeTag(5), AttributeKind("FFF".into())),
103-
(AttributeTag(6), AttributeKind("GGGG".into())),
97+
(AttributeTag(0), AttributeKind::try_new("A".into()).unwrap()),
98+
(AttributeTag(1), AttributeKind::try_new("B".into()).unwrap()),
99+
(AttributeTag(2), AttributeKind::try_new("C".into()).unwrap()),
100+
(AttributeTag(3), AttributeKind::try_new("D".into()).unwrap()),
101+
(
102+
AttributeTag(4),
103+
AttributeKind::try_new("EE".into()).unwrap(),
104+
),
105+
(
106+
AttributeTag(5),
107+
AttributeKind::try_new("FFF".into()).unwrap(),
108+
),
109+
(
110+
AttributeTag(6),
111+
AttributeKind::try_new("GGGG".into()).unwrap(),
112+
),
104113
]
105114
.into_iter()
106115
.collect(),

examples/v2_update_exchange_rate.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,18 @@ async fn main() -> anyhow::Result<()> {
5353
.await
5454
.context("Could not obtain chain parameters")?;
5555

56-
// find the key indices to sign with
57-
let signer = params
56+
let keys = params
5857
.response
59-
.common_update_keys()
58+
.keys
59+
.level_2_keys
60+
.context("No level 2 keys in chain parameters.")?;
61+
62+
// find the key indices to sign with
63+
let signer = keys
6064
.construct_update_signer(
61-
&params.response.common_update_keys().micro_gtu_per_euro,
65+
keys.micro_ccd_per_euro
66+
.as_ref()
67+
.context("Missing uCCD:EUR exchange rate update keys.")?,
6268
kps,
6369
)
6470
.context("Invalid keys supplied.")?;
@@ -69,12 +75,10 @@ async fn main() -> anyhow::Result<()> {
6975
.response
7076
.micro_ccd_per_euro;
7177

72-
let exchange_rate = match &params.response {
73-
v2::ChainParameters::V0(v0) => v0.micro_ccd_per_euro,
74-
v2::ChainParameters::V1(v1) => v1.micro_ccd_per_euro,
75-
v2::ChainParameters::V2(v2) => v2.micro_ccd_per_euro,
76-
v2::ChainParameters::V3(v3) => v3.micro_ccd_per_euro,
77-
};
78+
let exchange_rate = params
79+
.response
80+
.micro_ccd_per_euro
81+
.context("No exchange rate in chain parameters.")?;
7882

7983
let effective_time = 0.into(); // immediate effect
8084
let timeout =

src/lib.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,21 @@ For the quick proof of concept application the value can be unwrapped using [`un
6464
[`known_or_err`]: v2::Upward::known_or_err
6565
[`known_or`]: v2::Upward::known_or
6666
[`unwrap`]: v2::Upward::unwrap
67+
68+
#### `ChainParameters`
69+
70+
The `v2::ChainParameters` `enum` has been replaced by [`types::chain_parameters::ChainParameters`], which is a single `struct` with optional fields.
71+
Applications should no longer case on the version of the chain parameters, but can directly access the relevant parameters.
72+
Since parameters are added and removed across different protocol versions, each parameter is optional, even if it is present in all current protocol versions, in case it may be removed in a future protocol version.
73+
The prior functions on `ChainParameters` have been removed, and should be migrated as set out below.
74+
75+
The `ChainParameters::common_update_keys()` function was removed.
76+
Instead `keys.level_2_keys : Option<Level2Keys>` should be used.
77+
The [`Level2Keys`](types::chain_parameters::Level2Keys) `struct` provides the level 2 keys and access structures.
78+
For signing chain updates, use [`construct_update_signer()`](types::chain_parameters::Level2Keys::construct_update_signer).
79+
80+
The `ChainParameters::micro_ccd_per_energy()` and `ChainParameters::ccd_cost()` functions were removed.
81+
Instead, use [`energy_rate()`](types::chain_parameters::ChainParameters::energy_rate) to obtain an [`EnergyRate`](types::chain_parameters::EnergyRate), which encapsulates the [`micro_ccd_per_energy`](types::chain_parameters::EnergyRate::micro_ccd_per_energy) exchange rate.
82+
`EnergyRate` also provides [`ccd_cost()`](types::chain_parameters::EnergyRate::ccd_cost), which should be used in place of the former `ChainParameters::ccd_cost()`.
83+
84+
Finally, the `ChainParameters::foundation_account()` getter function was removed, and should be replaced by directly accessing [`ChainParameters::foundation_account`](types::chain_parameters::ChainParameters::foundation_account).

0 commit comments

Comments
 (0)