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

Delegations REST endpoint require name and password when generate_only is passed #3020

Closed
4 tasks
joe-bowman opened this issue Dec 6, 2018 · 6 comments · Fixed by #3069
Closed
4 tasks
Assignees
Labels

Comments

@joe-bowman
Copy link
Contributor

joe-bowman commented Dec 6, 2018

Summary of Bug

When POSTing to the /stake/delegators/{delegatorAddr}/delegations endpoint, with the query string ?generate_only=true, I am returned an error:

name required but not specified

and adding a (dummy) name returns:
password required but not specified

and adding a password then causes (unsurprisingly) the name and password to be checked against the local keystore.

This shouldn't happen for generate_only transactions.

Steps to Reproduce

#!/usr/bin/env python3

import requests

LCD_URL='<lcd url>'
ACCOUNT_ADDRESS = '<acc addr>'
VALIDATOR_ADDRESS = '<val addr>'
payload = {
    "base_req": {
        "chain_id": gaia-9002,
        "account_number": "0",
        "sequence": "0",
        "gas": "200000",
        "gas_adjustment": "1.2"
    },
    "delegations": [
        {
            "delegator_addr": ACCOUNT_ADDRESS,
            "validator_addr": VALIDATOR_ADDRESS,
            "delegation": {
                "denom": "STAKE",
                "amount": "1000"
            }
        }
    ]
}

response = requests.post('{}/stake/delegators/{}/delegations?simulate=false&generate_only=true'.format(LCD_URL, ACCOUNT_ADDRESS), json=payload, verify=VERIFY)
print(response.text)

Version tested: 0.27.0

ref: #2191


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@alexanderbez
Copy link
Contributor

alexanderbez commented Dec 6, 2018

Thanks @joe-bowman! I'll look into this ⚡️

I also doubt this is particular to this specific endpoint, but I'll double check anyway.

@alexanderbez
Copy link
Contributor

alexanderbez commented Dec 6, 2018

Ok, took a further look into it. It seems this is the only endpoint that uses the generate_only flag.

In addition, I find the handler to be very confusing in that it creates and broadcasts multiple txs (multiple messages). This is super confusing. In addition, if you provide generate_only it short-circuits after just a single message!

I think we need to finally refactor this entire handler (as the godoc states) once and for all. @fedekunze would you want to tackle this or should I?

@joe-bowman
Copy link
Contributor Author

joe-bowman commented Dec 6, 2018

I believe there is a ticket to refactor this into multiple endpoints anyway?

Update:
Ref: #2191
Ref: #2182

@alexanderbez
Copy link
Contributor

Indeed! I'll look into reviewing the PR #2997 and making sure it covers this case.

@Onefox
Copy link

Onefox commented Dec 7, 2018

I think this would also be the case for https://cosmos.network/rpc/#/ICS20/post_bank_accounts__address__transfers

At least from the doc you could use generate_only
here the password is not check at least but you have to have the field...

fedekunze pushed a commit that referenced this issue Dec 10, 2018
@alexanderbez
Copy link
Contributor

@joe-bowman can you test the latest develop again please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants