-
Notifications
You must be signed in to change notification settings - Fork 17
Revise chain parameters #343
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
base: main
Are you sure you want to change the base?
Conversation
| - Type `Event`/`BakerPoolInfo` field `open_status` is now wrapped in `Upward`. | ||
| - Bubble `Upward` from new variants of `VerifyKey` to `Upward<AccountCredentialWithoutProofs<...>>` in `AccountInfo::account_credentials`. | ||
|
|
||
| - BREAKING: Remove types associated with discontinued V1 API: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does V1 and V2 API mean in the current codebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't V2 the gPRC/protobuf API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the types used by the gRPC/protobuf API (the non-protobuf types that we convert to from the generated protobuf types) are also located in types and not necessarility in v2? (just to align on where we put types)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
V2 is the current gRPC/protobuf API, yes. V1 was the old API that was often JSON inside protobuf (it was removed in Node version 6.2.1). It could make sense to move ChainParameters from v2 to types (and the associated definitions), since that's largely where the types belong. It's a little bit confused because there were two ChainParameters types (one in types and one in v2).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we put all the new types in types and not in v2 then? It seems a bit confusing to add types in v2 module?
…rdium-rust-sdk into revise-chain-parameters
…in only optional items).
| - Bubble `Upward` from new variants of `VerifyKey` to `Upward<AccountCredentialWithoutProofs<...>>` in `AccountInfo::account_credentials`. | ||
|
|
||
| - BREAKING: Remove types associated with discontinued V1 API: | ||
| - `types::BlockSummary`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the removal of BlockSummary and the related types in UpdateQueue unrelated to the other changes? It seems it could have been a separate PR (just for another time)
| impl TryFrom<MintDistribution> for types::MintDistributionV1 { | ||
| type Error = MintDistributionConversionError; | ||
| fn try_from(value: MintDistribution) -> Result<Self, Self::Error> { | ||
| let baking_reward = | ||
| value | ||
| .baking_reward | ||
| .ok_or(MintDistributionConversionError::MissingField( | ||
| "baking_reward", | ||
| ))?; | ||
| let finalization_reward = | ||
| value | ||
| .finalization_reward | ||
| .ok_or(MintDistributionConversionError::MissingField( | ||
| "finalization_reward", | ||
| ))?; | ||
| Ok(Self { | ||
| baking_reward, | ||
| finalization_reward, | ||
| }) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the conversions into base types needed? I mean is it justified that we maintain this code and these conversions? Or do we want a general policy that you can convert SDK types into base types and just always implement the conversions?
| For signing chain updates, use [`construct_update_signer()`](v2::Level2Keys::construct_update_signer), for instance as: | ||
|
|
||
| ```rust,no_compile | ||
| let params = client | ||
| .get_block_chain_parameters(&BlockIdentifier::LastFinal) | ||
| .await | ||
| .context("Could not obtain chain parameters")?; | ||
| let keys = params | ||
| .response | ||
| .keys | ||
| .level_2_keys | ||
| .context("No level 2 keys in chain parameters.")?; | ||
| let signer = keys | ||
| .construct_update_signer( | ||
| keys.micro_ccd_per_euro | ||
| .as_ref() | ||
| .context("Missing uCCD:EUR exchange rate update keys.")?, | ||
| kps, | ||
| ) | ||
| .context("Invalid keys supplied.")?; | ||
| let block_item: BlockItem<Payload> = | ||
| update::update(&signer, seq_number, effective_time, timeout, payload).into(); | ||
| ``` | ||
|
|
||
| Constructing updates to the level 2 keys requires an [`AuthorizationsV1`](types::AuthorizationsV1) (or for old protocol versions, [`AuthorizationsV0`](types::AuthorizationsV0)) which can be obtained with `Level2Keys::try_into()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the instructions could be more targeted on what usages we actually expect of the SDK (too much information can make the instructions less clear or just seem overwhelming). This usage of posting an update instruction, we likely have 0 users doing that? So we could write it shorter and just say there are changes to these types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also an unexplained variable kps in the example (holds the private keys).
|
|
||
| /// Timeout parameters for the new consensus protocol introduced in protocol | ||
| /// version 6. | ||
| #[derive(Debug, Clone, Default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also just add Eq, PartialEq, Hash` to the types (https://rust-lang.github.io/api-guidelines/interoperability.html#c-common-traits)
| } | ||
|
|
||
| #[derive(Debug, Clone, Default)] | ||
| pub struct ChainParameters { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation on this and a few other types is missing
Purpose
Closes COR-775
Revise the
ChainParameterstype to expose all fields as optional, rather than through multiple variants.Changes
ChainParameterswith a new struct, and introduced helpers and conversions.Checklist
hard-to-understand areas.