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

Remove register operator proof of ownership #183

Merged

Conversation

marc-aurele-besner
Copy link
Collaborator

@marc-aurele-besner marc-aurele-besner commented Nov 27, 2024

User description

Remove register operator proof of ownership

Removing proof of ownership and simplifying the logic and input parameters for staking registerOperator()


PR Type

enhancement, dependencies


Description

  • Removed proof of ownership (signature) from the registerOperator function to simplify its logic and input parameters.
  • Updated RegisterOperatorParams type definition by removing unnecessary fields and adding signingKey.
  • Updated dependencies in package.json files to newer versions for @polkadot/extension-dapp and @polkadot/types-codec.

Changes walkthrough 📝

Relevant files
Enhancement
staking.ts
Simplify registerOperator by removing proof of ownership 

packages/auto-consensus/src/staking.ts

  • Removed proof of ownership (signature) from registerOperator.
  • Simplified input parameters for registerOperator.
  • Updated logic to use signingKey directly.
  • +8/-23   
    staking.ts
    Update RegisterOperatorParams type definition                       

    packages/auto-consensus/src/types/staking.ts

  • Removed senderAddress and Operator from RegisterOperatorParams.
  • Added signingKey to RegisterOperatorParams.
  • +1/-2     
    Dependencies
    package.json
    Update dependency version for @polkadot/extension-dapp     

    packages/auto-utils/package.json

    • Updated @polkadot/extension-dapp dependency version.
    +1/-1     
    package.json
    Update dependency version for @polkadot/types-codec           

    packages/auto-xdm/package.json

    • Updated @polkadot/types-codec dependency version.
    +1/-1     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Simplification Impact
    The removal of proof of ownership and other parameters in the registerOperator function simplifies the logic but could impact the security or functionality of the system. This change should be thoroughly tested to ensure that it does not introduce any regressions or security vulnerabilities.

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Convert stake amounts and taxes to numbers to ensure type compatibility with blockchain transactions

    Ensure that the amountToStake, minimumNominatorStake, and nominationTax are
    converted to the appropriate types before passing them to registerOperator.
    Currently, they are parsed as strings which might not be compatible with the
    expected types in the blockchain transaction.

    packages/auto-consensus/src/staking.ts [76-80]

    -return api.tx.domains.registerOperator(parseString(domainId), parseString(amountToStake), {
    +return api.tx.domains.registerOperator(parseString(domainId), parseNumber(amountToStake), {
       signingKey,
    -  minimumNominatorStake: parseString(minimumNominatorStake),
    -  nominationTax: parseString(nominationTax),
    +  minimumNominatorStake: parseNumber(minimumNominatorStake),
    +  nominationTax: parseNumber(nominationTax),
     })
    Suggestion importance[1-10]: 7

    Why: The suggestion correctly identifies a potential type mismatch issue in the blockchain transaction function. Converting these values to numbers ensures compatibility and prevents runtime errors, thus enhancing the robustness of the code.

    7

    @marc-aurele-besner
    Copy link
    Collaborator Author

    The changes are ready @jfrank-summit

    @marc-aurele-besner marc-aurele-besner merged commit 8ca0dec into main Nov 27, 2024
    1 check passed
    @marc-aurele-besner marc-aurele-besner deleted the feat/remove-register-operator-proof-of-ownership branch November 27, 2024 20:38
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    Remove proof of ownership in registerOperator()
    2 participants