Skip to content
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: staking #145

Merged
merged 123 commits into from
May 21, 2021
Merged

feat: staking #145

merged 123 commits into from
May 21, 2021

Conversation

wischli
Copy link
Contributor

@wischli wischli commented Apr 22, 2021

fixes KILTProtocol/ticket#1253

  • Adds parachain staking
  • adds shell runtime execution
  • spiritnet runtime
  • specify which runtime should be used with --runtime {spiritnet,mashnet}

How to test:

cargo test -p parachain-staking

custom types

This PR introduces new custom JS-types which are required for compatibility with our SDK and the Polkadot Apps.

Companion Types PR

Please use the following types to test the code with the Polkadot Apps:

JS-Types
{
"AccountInfo": "AccountInfoWithTripleRefCount"
"Address": "MultiAddress",
"AmountOf": "i128",
"Balance": "u128",
"BlockNumber": "u64",
"Index": "u64",
"LookupSource": "MultiAddress",
"CtypeCreatorOf": "DidIdentifierOf",
"CtypeHashOf": "Hash",
"ClaimHashOf": "Hash",
"AttesterOf": "DidIdentifierOf",
"AttestationDetails": {
  "ctypeHash": "CtypeHashOf",
  "attester": "AttesterOf",
  "delegationId": "Option<DelegationNodeIdOf>",
  "revoked": "bool"
},
"Permissions": "u32",
"DelegationNodeIdOf": "Hash",
"DelegatorIdOf": "DidIdentifierOf",
"DelegationSignature": "DidSignature",
"DelegationRoot": {
  "ctypeHash": "CtypeHashOf",
  "owner": "DelegatorIdOf",
  "revoked": "bool"
},
"DelegationNode": {
  "rootId": "DelegationNodeIdOf",
  "parent": "Option<DelegationNodeIdOf>",
  "owner": "DelegatorIdOf",
  "permissions": "Permissions",
  "revoked": "bool"
},
"KeyIdOf": "Hash",
"DidIdentifierOf": "AccountId",
"AccountIdentifierOf": "AccountId",
"BlockNumberOf": "BlockNumber",
"DidCallableOf": "Call",
"DidVerificationKey": {
  "_enum": {
    "Ed25519": "[u8; 32]",
    "Sr25519": "[u8; 32]"
  }
},
"DidEncryptionKey": {
  "_enum": {
    "X25519": "[u8; 32]"
  }
},
"DidPublicKey": {
  "_enum": {
    "PublicVerificationKey": "DidVerificationKey",
    "PublicEncryptionKey": "DidEncryptionKey"
  }
},
"DidVerificationKeyRelationship": {
  "_enum": [
    "Authentication",
    "CapabilityDelegation",
    "CapabilityInvocation",
    "AssertionMethod"
  ]
},
"DidSignature": {
  "_enum": {
    "Ed25519": "Ed25519Signature",
    "Sr25519": "Sr25519Signature"
  }
},
"DidError": {
  "_enum": {
    "StorageError": "StorageError",
    "SignatureError": "SignatureError",
    "UrlError": "UrlError",
    "InternalError": "Null"
  }
},
"StorageError": {
  "_enum": {
    "DidAlreadyPresent": "Null",
    "DidNotPresent": "Null",
    "DidKeyNotPresent": "DidVerificationKeyRelationship",
    "VerificationKeyNotPresent": "Null",
    "CurrentlyActiveKey": "Null",
    "MaxTxCounterValue": "Null"
  }
},
"SignatureError": {
  "_enum": [
    "InvalidSignatureFormat",
    "InvalidSignature",
    "InvalidNonce"
  ]
},
"KeyError": {
  "_enum": [
    "InvalidVerificationKeyFormat",
    "InvalidEncryptionKeyFormat"
  ]
},
"UrlError": {
  "_enum": [
    "InvalidUrlEncoding",
    "InvalidUrlScheme"
  ]
},
"DidPublicKeyDetails": {
  "key": "DidPublicKey",
  "blockNumber": "BlockNumberOf"
},
"DidDetails": {
  "authenticationKey": "KeyIdOf",
  "keyAgreementKeys": "BTreeSet<KeyIdOf>",
  "delegationKey": "Option<KeyIdOf>",
  "attestationKey": "Option<KeyIdOf>",
  "publicKeys": "BTreeMap<KeyIdOf, DidPublicKeyDetails>",
  "endpointUrl": "Option<Url>",
  "lastTxCounter": "u64"
},
"DidCreationOperation": {
  "did": "DidIdentifierOf",
  "newAuthenticationKey": "DidVerificationKey",
  "newKeyAgreementKeys": "BTreeSet<DidEncryptionKey>",
  "newAttestationKey": "Option<DidVerificationKey>",
  "newDelegationKey": "Option<DidVerificationKey>",
  "newEndpointUrl": "Option<Url>"
},
"DidUpdateOperation": {
  "did": "DidIdentifierOf",
  "newAuthenticationKey": "Option<DidVerificationKey>",
  "newKeyAgreementKeys": "BTreeSet<DidEncryptionKey>",
  "attestationKeyUpdate": "DidVerificationKeyUpdateAction",
  "delegationKeyUpdate": "DidVerificationKeyUpdateAction",
  "publicKeysToRemove": "BTreeSet<KeyIdOf>",
  "newEndpointUrl": "Option<Url>",
  "txCounter": "u64"
},
"DidVerificationKeyUpdateAction": {
  "_enum": {
    "Ignore": "Null",
    "Change": "DidVerificationKey",
    "Delete": "Null"
  }
},
"DidDeletionOperation": {
  "did": "DidIdentifierOf",
  "txCounter": "u64"
},
"DidAuthorizedCallOperation": {
  "did": "DidIdentifierOf",
  "txCounter": "u64",
  "call": "DidCallableOf"
},
"HttpUrl": {
  "payload": "Text"
},
"FtpUrl": {
  "payload": "Text"
},
"IpfsUrl": {
  "payload": "Text"
},
"Url": {
  "_enum": {
    "Http": "HttpUrl",
    "Ftp": "FtpUrl",
    "Ipfs": "IpfsUrl"
  }
},
"LockedBalance": {
  "block": "BlockNumber",
  "amount": "Balance"
},
"RoundIndex": "u32",
"RoundInfo": {
  "current": "RoundIndex",
  "first": "BlockNumber",
  "length": "BlockNumber"
},
"OrderedSet": "Vec<Stake>",
"Stake": {
  "owner": "AccountId",
  "amount": "Balance"
},
"TotalStake": {
  "collators": "Balance",
  "delegators": "Balance"
},
"InflationInfo": {
  "collator": "StakingInfo",
  "delegator": "StakingInfo"
},
"StakingInfo": {
  "maxRate": "Perquintill",
  "rewardRate": "RewardRate"
},
"RewardRate": {
  "annual": "Perquintill",
  "perBlock": "Perquintill"
},
"Delegator": {
  "delegations": "Vec<Stake>",
  "total": "Balance"
},
"CollatorSnapshot": {
  "stake": "Balance",
  "delegators": "Vec<Stake>",
  "total": "Balance"
},
"Collator": {
  "id": "AccountId",
  "stake": "Balance",
  "delegators": "Vec<Stake>",
  "total": "Balance",
  "state": "CollatorStatus"
},
"CollatorStatus": {
  "_enum": {
    "Active": "Null",
    "Idle": "Null",
    "Leaving": "SessionIndex"
  }
}
}
## Checklist:
  • I have verified that the code works
  • I have verified that the code is easy to understand
    • If not, I have left a well-balanced amount of inline comments
  • I have left the code in a better state
  • I have documented the changes (where applicable)

@wischli wischli self-assigned this Apr 22, 2021
@wischli wischli added Breaking JS Types This PR will break the JS types. ✨ new feature feature: new feature labels Apr 22, 2021
@wischli wischli marked this pull request as ready for review May 21, 2021 15:13
@weichweich weichweich merged commit 45f9137 into develop May 21, 2021
@weichweich weichweich deleted the wf-1253-dpos branch May 21, 2021 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking JS Types This PR will break the JS types. ✨ new feature feature: new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants