-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Add common types used by storage provider #44
Conversation
Add `common` lib for types used by different pallets. The `common` library will be extended when needed. This commit adds types that the storage provider pallet needs. All types have been documented in the code. Types added: - `ActorID` -> Identifier for Actors. - `Cid` -> Identifier for a CID. - `MinerId` -> Tuple struct holding u32 identifying a miner. - `Address` -> Defines the protocol and data payload conversion from either a public key or a value. - `Payload` -> The data of the `Address`. - `DelegatedAddress` -> A "delegated" (f4) address. The `AccountIdConversion` trait has been added to implement conversion between `AccountId` and other types. This trait has been implemented for `MinerID`.
…ommon-types-library
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 just don't understand a lot about this PR, honestly :(
/// f0: ID protocol address. | ||
ID(u64), | ||
/// f1: SECP256K1 key address, 20 byte hash of PublicKey. | ||
Secp256k1([u8; PAYLOAD_HASH_LEN]), |
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.
Why do we need those addresses, payloads etc?
I thought that in Substrate, we only utilize like AccountId
address which identifies an account and is the basis of the interaction with blockchain and is enough.
Those abstractions seem like a Filecoin only stuff which we don't need in our implementation.
pub mod registered_proof; | ||
|
||
/// Identifier for Actors, includes builtin and initialized actors | ||
pub type ActorID = u64; |
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 are no actors in substrate, are we trying to introduce them?
// Code modified from https://github.com/paritytech/polkadot/blob/rococo-v1/parachain/src/primitives.rs | ||
/// Format is b"miner" ++ encode(minerId) ++ 00.... where 00... is indefinite trailing | ||
/// zeroes to fill AccountId. | ||
impl<T: Encode + Decode> AccountIdConversion<T> for MinerId { |
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.
How can we from the (conceptual point of view) create an AccountId from MinerId?
AccountId in Substrate is something like this.
While I can see a way, where we could convert an AccountId to a Miner, and the other way round using a Pallet and some state on a blockchain, I don't think it's possible doing it 'raw'.
pub type ActorID = u64; | ||
|
||
/// Identifier for a CID | ||
pub type Cid = String; |
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.
In storage we are currently using Cid from the rust-cid crate. Maybe it could also be used here
struct TrailingZeroInput<'a>(&'a [u8]); | ||
|
||
impl<'a> codec::Input for TrailingZeroInput<'a> { | ||
fn remaining_len(&mut self) -> Result<Option<usize>, CodecError> { |
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.
This always returns Ok(None). If implementation needs to yet be done. It might be better to leave the todo!() macro
I will close this PR because during pallet implementation we will identify the common types used and place them in |
Description
Add
common
lib for types used by different pallets. Thecommon
library will be extended when needed. This commit adds types that the storage provider pallet needs.Implementation
All types have been documented in the code.
Types added:
ActorID
-> Identifier for Actors.Cid
-> Identifier for a CID.MinerId
-> Tuple struct holding u32 identifying a miner.Address
-> Defines the protocol and data payload conversion from either a public key or a value.Payload
-> The data of theAddress
.DelegatedAddress
-> A "delegated" (f4) address.The
AccountIdConversion
trait has been added to implement conversion betweenAccountId
and other types. This trait has been implemented forMinerID
.Fixes #42