Expand description
Message Source Account Management
§Quick Links
- Configuration:
Config - Extrinsics:
Call - Runtime API:
MsaRuntimeApi - Custom RPC API:
MsaApiServer - Event Enum:
Event - Error Enum:
Error
§MSA Pallet
The MSA Pallet provides functionality for handling Message Source Accounts.
§Summary
The Message Source Account (MSA) is the primary user account system on Frequency for Messages and Stateful Storage. All users on Frequency must have an MSA in order to:
- Acquire a User Handle
- Delegate tasks to Providers (defining specific tasks for specific providers)
- Become a Provider so they may do Provider level tasks on their own behalf
- Have Message or Stateful Storage data
§MSA Id and Keys
Once a user creates an MSA, they are assigned an MSA Id, a unique number the time of creation with one or more keys attached for control. (A control key may only be attached to ONE MSA at any single point in time.)
§MSA Id and Addresses
Each MSA Id has a unique 20-byte address associated with it. This address can be queried using an MSA pallet runtime call, or computed using the following algorithm:
Address = keccak256(0xD9 + <MSA Id as 8-byte big-endian bytes> + keccak256(b"MSA Generated"))[12..]§Recovery System
MSA ownership is able to be recovered via a previously set Recovery Commitment. This recovery requires the user have access to the Recovery Secret as well as the contact method used which together are able to derive the hash tree that builds the Recovery Commitment hash. The user must use an governance authorized Recovery Provider to perform the recovery.
No PII is exposed to the chain in the adding of a Recovery Commitment or the Recovery of an MSA.
§Actions
The MSA pallet provides for:
- Creating, reading, updating, and deleting operations for MSAs.
- Managing delegation relationships for MSAs.
- Managing keys associated with MSAs.
- Managing the recovery system for MSAs.
§Interactions
§Extrinsics
| Name/Description | Caller | Payment | Key Events | Runtime Added |
|---|---|---|---|---|
add_public_key_to_msaAdd MSA control key | MSA Control Key or Provider with Signature | Capacity or Tokens | PublicKeyAdded | 1 |
add_recovery_commitmentAdd a new Recovery Commitment to an existing MSA | Provider | Capacity or Tokens | RecoveryCommitmentAdded | 168 |
approve_recovery_providerApprove a Recovery Provider via governance for MSA recovery | Frequency Council | Tokens | RecoveryProviderApproved | 169 |
createCreate new MSA | Token Account | Tokens | MsaCreated | 1 |
create_applicationCreate a new application for a provider | Provider | Capacity or Tokens | ApplicationCreated | 177 |
create_application_via_governanceCreate a new application via governance | Frequency Council | Tokens | ApplicationCreated | 177 |
create_providerConvert an MSA into a Provider | Testnet: Provider or Mainnet: Governance | Tokens | ProviderCreated | 177 |
create_provider_via_governanceConvert an MSA into a Provider | Frequency Council | Tokens | ProviderCreated | 12 |
create_provider_via_governance_v2Convert an MSA into a Provider with enhanced metadata via governance | Frequency Council | Tokens | ProviderCreated | 177 |
create_sponsored_account_with_delegationCreate new MSA via Provider with a Delegation | Provider | Capacity or Tokens | MsaCreated, DelegationGranted | 1 |
delete_msa_public_keyRemove MSA control key | Delegator | Free | PublicKeyDeleted | 1 |
grant_delegationCreate or alter a delegation | Provider with Signature | Capacity | DelegationGranted | 1 |
propose_to_add_applicationPropose to add a new application | Provider | Tokens | Proposed | 177 |
propose_to_be_providerRequest the council to convert an MSA to a Provider | Token Account | Tokens | Proposed | 12 |
propose_to_be_provider_v2Request the council to convert an MSA to a Provider with enhanced metadata | Token Account | Tokens | Proposed | 177 |
propose_to_update_applicationPropose to update an application’s metadata | Provider | Tokens | Proposed | 177 |
propose_to_update_providerPropose to update a provider’s metadata | Provider | Tokens | Proposed | 177 |
recover_accountRecover MSA with new control key | Recovery Provider | Capacity or Tokens | AccountRecovered, RecoveryCommitmentInvalidated | 170 |
remove_recovery_providerRemove a Recovery Provider via governance for MSA recovery | Frequency Council | Tokens | RecoveryProviderRemoved | 169 |
retire_msaRemove all keys and mark the MSA as retired | Delegator | Free | PublicKeyDeleted, MsaRetired | 18 |
revoke_delegation_by_delegatorRemove delegation | Delegator | Free | DelegationRevoked | 1 |
revoke_delegation_by_providerRemove delegation | Provider | Free | DelegationRevoked | 1 |
update_application_via_governanceUpdate an application’s metadata via governance | Frequency Council | Tokens | ApplicationContextUpdated | 177 |
update_provider_via_governanceUpdate a provider’s metadata via governance | Frequency Council | Tokens | ProviderUpdated | 177 |
withdraw_tokensWithdraw all tokens from an MSA | Token Account | Tokens | Transfer | 158 |
See Rust Docs for more details.
§State Queries
| Name | Description | Query | Runtime Added |
|---|---|---|---|
| Get MSA Id | Returns the MSA Id connected to the given control key | publicKeyToMsaId | 1 |
| Get Current Maximum MSA Id | Returns the maximum MSA Id in existence | currentMsaIdentifierMaximum | 1 |
| Get Current Delegator to Provider | Returns the current relationship between the specified Delegator and specified Provider at the given block number | delegatorAndProviderToDelegation | 1 |
| Get Public Key Count for MSA Id | Returns the number of public keys for the given MSA Id | publicKeyCountforMsaId | 1 |
| Get Recovery Commitment | Returns the Recovery Commitment for a given MSA Id | MsaIdToRecoveryCommitment | 168 |
| Get Approved Recovery Providers | Returns the Approved Recovery Provider Status (bool) for a given ProviderId | RecoveryProviders | 169 |
| Get Provider Application Context | Returns the provider or application context for a given provider and application ID | getProviderApplicationContext | 177 |
See the Rust Docs for additional state queries and details.
§RPCs
Note: May be restricted based on node settings and configuration.
| Name | Description | Call | Node Version |
|---|---|---|---|
| Check Delegations | Test a list of MSAs to see if they have delegated to the provider MSA | checkDelegations | v1.0.0+ |
| Delegation Schema Grants | Fetch the list of Schema Ids that a delegator has granted to a provider | grantedSchemaIdsByMsaId | v1.0.0+ |
| Get Control Keys by MSA Id* | Fetch the list of current control keys for an MSA from the off-chain index | getKeysByMsaId | v1.10.0+ |
| Get All Delegations by MSA Id | Retrieves all delegations and schemas, active and inactive, for an MSA ID | ‘getAllGrantedDelegationsByMsaId’ | v1.13.0+ |
* Must be enabled with off-chain indexing
See Rust Docs for more details.
§Runtime API
| Name | Description | Call | Runtime Added | MSA Runtime API Version Added |
|---|---|---|---|---|
| Has Delegation | Check to see if a delegation existed between the given delegator and provider at a given block | ‘hasDelegation’ | 1 | 1 |
| Get Granted Schemas by MSA ID | Get the list of schema permission grants (if any) that exist in any delegation between the delegator and provider. | ‘getGrantedSchemasByMsaId’ | 1 | 1 |
| Get All Granted Delegations by MSA ID | Get the list of all delegated providers with schema permission grants (if any) that exist in any delegation between the delegator and provider. | ‘getAllGrantedDelegationsByMsaId’ | 83 | 2 |
| Get Ethereum Address for MSA ID | Get the Ethereum address of the given MSA. | ‘getEthereumAddressForMsaId’ | 156 | 3 |
| Validate Ethereum Address for MSA ID | Validate if the given Ethereum address is associated with the given MSA. | ‘validateEthAddressForMsa’ | 156 | 3 |
| Get Provider Application Context | Get the provider or application context for a given provider and application ID. | ‘getProviderApplicationContext’ | 177 | 4 |
§Implementations
MsaLookup: Functions for accessing MSAs.MsaValidator: Functions for validating MSAs.ProviderLookup: Functions for accessing Provider info.DelegationValidator: Functions for validating delegations.SchemaGrantValidator: Functions for validating schema grants.
§Assumptions
- Total MSA keys should be less than the constant
Config::MSA::MaxPublicKeysPerMsa. - Maximum schemas, for which any single provider has publishing rights on behalf of a single user, must be less than
Config::MSA::MaxSchemaGrantsPerDelegation
Re-exports§
pub use types::AddKeyData;pub use types::AddProvider;pub use types::AuthorizedKeyData;pub use types::PermittedDelegationSchemas;pub use types::RecoveryCommitment;pub use types::RecoveryCommitmentPayload;pub use pallet::*;pub use weights::*;pub use offchain_storage::*;
Modules§
- migration
- Migrations
- offchain_
storage - Offchain storage for MSA pallet
- pallet
- The
palletmodule in each FRAME pallet hosts the most important items needed to construct this pallet. - types
- Types for the MSA Pallet
- weights
- Autogenerated weights for
pallet_msa
Structs§
- Check
Free Extrinsic Use - The TransactionExtension trait is implemented on CheckFreeExtrinsicUse to validate that a provider has not already been revoked if the calling extrinsic is revoking a provider to an MSA. The purpose of this is to ensure that the revoke_delegation_by_delegator extrinsic cannot be repeatedly called and flood the network.
Enums§
- Pre
- The info passed between the prepare and post-dispatch steps for the
CheckFreeExtrinsicUseextension. - Val
- The info passed between the validate and prepare steps for the
CheckFreeExtrinsicUseextension. - Validity
Error - Errors related to the validity of the CheckFreeExtrinsicUse signed extension.
Type Aliases§
- Application
Index - ApplicationIndex type