Skip to content

Conversation

hasufell
Copy link
Contributor

@hasufell hasufell commented Oct 5, 2020

Issue Number

#2200

Overview

  • Added Api types
  • Refactored some of the Transaction layer (still WIP)
  • Factored out certificate creation from joinStakePool
  • Added handler for joining stake pool
  • Add handler for quitting stake pool
  • serialization of certificates
  • lots of cleanup
  • fix jormungandr
  • fix tests
  • add tests

Comments

@hasufell hasufell self-assigned this Oct 5, 2020
@hasufell hasufell added the Feature Mark a PR as adding a new feature, for auto-generated CHANGELOG label Oct 5, 2020
@hasufell hasufell linked an issue Oct 5, 2020 that may be closed by this pull request
@hasufell hasufell marked this pull request as draft October 5, 2020 18:52
@hasufell hasufell force-pushed the hasufell/2200/unsigned-delegation-cert branch from 7aa3cc1 to 2798019 Compare October 5, 2020 19:03
@hasufell hasufell force-pushed the hasufell/2200/unsigned-delegation-cert branch 2 times, most recently from dec15ff to 4b91fea Compare October 9, 2020 15:40
@hasufell hasufell force-pushed the hasufell/2200/unsigned-delegation-cert branch from c50b8b1 to 4238bda Compare October 12, 2020 18:00
@hasufell hasufell changed the title [WIP] ADP-455: return unsigned delegation certificate ADP-455: return unsigned delegation certificate Oct 12, 2020
@hasufell hasufell marked this pull request as ready for review October 12, 2020 18:01
@hasufell
Copy link
Contributor Author

bors try

iohk-bors bot added a commit that referenced this pull request Oct 12, 2020
@hasufell
Copy link
Contributor Author

hasufell commented Oct 12, 2020

This is ready for review, except for the missing integration tests... @piotr-iohk anything specific you want covered?

@hasufell hasufell requested a review from KtorZ October 12, 2020 18:20
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 12, 2020

try

Build failed:

@hasufell hasufell force-pushed the hasufell/2200/unsigned-delegation-cert branch from de668bb to 8dcf5af Compare October 12, 2020 19:04
@hasufell
Copy link
Contributor Author

bors try

iohk-bors bot added a commit that referenced this pull request Oct 12, 2020
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 12, 2020

try

Build failed:

@hasufell
Copy link
Contributor Author

bors try

iohk-bors bot added a commit that referenced this pull request Oct 12, 2020
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 12, 2020

try

Build failed:

@hasufell hasufell force-pushed the hasufell/2200/unsigned-delegation-cert branch from c17bedc to 881fab6 Compare October 12, 2020 21:39
@hasufell
Copy link
Contributor Author

bors try

iohk-bors bot added a commit that referenced this pull request Oct 12, 2020
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 12, 2020

try

Build failed:

@hasufell hasufell force-pushed the hasufell/2200/unsigned-delegation-cert branch from 881fab6 to b5f8caf Compare October 13, 2020 08:44
@hasufell
Copy link
Contributor Author

@piotr-iohk I added all integration tests and fixed the errors. But I'm still not 100% sure the output is what we want.

@hasufell
Copy link
Contributor Author

bors try

iohk-bors bot added a commit that referenced this pull request Oct 14, 2020
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 14, 2020

try

Build succeeded:

type: array
minItems: 1
items:
type: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this re-use the derivationIndex schema instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no such schema?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x-derivationSegment: &derivationSegment
  description: An individual segment within a derivation path.
  type: string
  example: 1852H

x-derivationPath: &derivationPath
  description: A path for deriving a child key from a parent key.
  type: array
  minItems: 1
  items: *derivationSegment

*derivationSegment / derivationPath.

@hasufell
Copy link
Contributor Author

@KtorZ could you reply to #2213 (comment) since we're still not sure the output is actually correct

@hasufell hasufell force-pushed the hasufell/2200/unsigned-delegation-cert branch from c4a154b to 9b379d2 Compare October 15, 2020 17:27
@hasufell hasufell force-pushed the hasufell/2200/unsigned-delegation-cert branch from df33084 to 16451e5 Compare October 16, 2020 11:27
@KtorZ
Copy link
Member

KtorZ commented Oct 16, 2020

The output looks quite correct to me. For a first registration, we would expect two certificates, and they are qualified as expected.

@piotr-iohk
Copy link
Contributor

Minor thing:
Screenshot from 2020-10-16 13-41-53

But trying with hex pool_id we're getting:

curl  -vX POST http://localhost:8090/v2/wallets/1ceb45b37a94c7022837b5ca14045f11a5927c65/coin-selections/random \
  -H "Content-Type: application/json; charset=utf-8" \
  -d '{
"delegation_action": 
{
	"action": "join",
	"pool":"9f36c4c67b76a8cea05a1684f8feaa64711f4c0053fe039978b203af"
} 
}' | jq

👇

{ "code": "bad_request",
  "message":
         "Error in $['delegation_action'].pool: Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'."}

@hasufell
Copy link
Contributor Author

The output looks quite correct to me. For a first registration, we would expect two certificates, and they are qualified as expected.

I was more worried about the amounts in input and output...

KtorZ and others added 3 commits October 16, 2020 15:31
  The code was becoming quite convoluted here with function names that
  were screaming for refactoring (when we start adding `'` to functions,
  it's usually a good sign that something can be simplified).

  The main change is actually in 'selectCoinsExternal' which is now
  parameterized over the selection to run. This way, the steps of
  assigning change addresses are factored out in this function and a lot
  of the duplication goes away.

  Another important change is that I've moved the signing and submission
  of join/quit outside of the body of the function. So that each step
  can be ran independently. This avoid the need for weird intermediate product
  types aggregating more and more information. Now, both functions are
  returning a 'DelegationAction' and merely checking that a join or quit
  is possible.
select coins for delegation simplifications
@KtorZ
Copy link
Member

KtorZ commented Oct 16, 2020

@hasufell there's one input selected, and a single change output. The delta is: 2 174 433, which corresponds I believe to 2Ada of key deposit, and ~0.17 Ada for fees which seems right for the Testnet.

@KtorZ
Copy link
Member

KtorZ commented Oct 16, 2020

bors merge

@piotr-iohk
Copy link
Contributor

Playing with the branch I observe that for the wallet that is already delegating to a pool, invoking a join action mostly results in:

{"code":"unable_to_assign_input_output"
,"message":"I'm unable to assign outputs from coin selection: inputs: - 1st eefa06df (~ 1000000 @ 00b69bf0...bca0a380) withdrawal: -0 reclaim: -0 outputs: [] change: [] deposit: -0 "}

Roughly 1 out of 5 is successful. The rest is this 👆 .

For the case when wallet is not delegating... all seems to be OK.

cc: @hasufell @KtorZ

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 16, 2020

Build succeeded:

@iohk-bors iohk-bors bot merged commit 05e59a0 into master Oct 16, 2020
@iohk-bors iohk-bors bot deleted the hasufell/2200/unsigned-delegation-cert branch October 16, 2020 16:16
@KtorZ
Copy link
Member

KtorZ commented Oct 18, 2020

@piotr-iohk on which commit did you do these tests 🤔 ?

@piotr-iohk
Copy link
Contributor

@KtorZ the last one from this branch. The same is actually now on master. -> 2020.10.13 (git revision: 05e59a0)

E.g.: I'm seeing this on testnet for the wallet: vacant cheap ghost elegant silly square offer vault announce turtle lesson doll key canyon romance which is delegating to pool1frevxe70aqw2ce58c0muyesnahl88nfjjsp25h85jwakzgd2g2l.

curl  -vX POST http://localhost:8090/v2/wallets/1b0aa24994b4181e79116c131510f2abf6cdaa4f/coin-selections/random \
  -H "Content-Type: application/json; charset=utf-8" \
  -d '{
"delegation_action": 
{
	"action": "join",
	"pool":"pool1numvf3nmw65vagz6z6z03l42v3c37nqq20lq8xtckgp67zzl7px"
} 
}' | jq

👇
most of the time:

{
  "code": "unable_to_assign_input_output",
  "message": "I'm unable to assign outputs from coin selection: inputs: - 1st eefa06df (~ 1000000 @ 00b69bf0...bca0a380) withdrawal: -0 reclaim: -0 outputs: [] change: [] deposit: -0 "
}

sometimes:

{
  "inputs": [
    {
      "amount": {
        "quantity": 497657470,
        "unit": "lovelace"
      },
      "address": "addr1qp5aaw59aaa5z82dgvmpn7xryejcn9j00plsv32y4gw6veqhpgwhzykzha0z6w27gxsps40gurvxjt2vxh26009q5wqqmy4ryk",
      "id": "601dd956ade7e3aefdb2618889c05508ced1515711b5ed8da1a8cd495033004b",
      "derivation_path": [
        "1852H",
        "1815H",
        "0H",
        "1",
        "1"
      ],
      "index": 0
    }
  ],
  "certificates": [
    {
      "certificate_type": "join_pool",
      "pool": "pool1numvf3nmw65vagz6z6z03l42v3c37nqq20lq8xtckgp67zzl7px",
      "reward_account_path": [
        "1852H",
        "1815H",
        "0H",
        "2",
        "0"
      ]
    }
  ],
  "outputs": [
    {
      "amount": {
        "quantity": 497484709,
        "unit": "lovelace"
      },
      "address": "addr1qpdunk6q5uw5uwnvptttn7htzqms0amj5ztv98npdekn7aghpgwhzykzha0z6w27gxsps40gurvxjt2vxh26009q5wqq7rgr20"
    }
  ]
}

iohk-bors bot added a commit that referenced this pull request Oct 19, 2020
2255: do not enforce non-empty outputs for unsigned tx r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#2200 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- c60c5a6
  📍 **do not enforce non-empty outputs for unsigned tx**
    Actually, there are many use-cases for empty outputs. This occurs in
  particular often when performing a selection for delegation: in this
  scenario, there are typically no outputs at all and, depending on the
  size of the selected input(s), there might be no change at all
  (because of the minUTxO value).


# Comments

<!-- Additional comments or screenshots to attach if any -->

Should fix: 

- #2213 (comment)
- #2213 (comment)

Thanks @piotr-iohk 🙏 


<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <[email protected]>
iohk-bors bot added a commit that referenced this pull request Oct 19, 2020
2255: do not enforce non-empty outputs for unsigned tx r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#2200 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- c60c5a6
  📍 **do not enforce non-empty outputs for unsigned tx**
    Actually, there are many use-cases for empty outputs. This occurs in
  particular often when performing a selection for delegation: in this
  scenario, there are typically no outputs at all and, depending on the
  size of the selected input(s), there might be no change at all
  (because of the minUTxO value).


# Comments

<!-- Additional comments or screenshots to attach if any -->

Should fix: 

- #2213 (comment)
- #2213 (comment)

Thanks @piotr-iohk 🙏 


<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Mark a PR as adding a new feature, for auto-generated CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return unsigned delegation certificate
3 participants