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

Authorized Spend Not Returned To Grantee On Deployment Closure #88

Closed
chainzero opened this issue Apr 11, 2023 · 2 comments · Fixed by akash-network/node#1944
Closed
Assignees
Labels
P1 repo/node Akash node repo issues

Comments

@chainzero
Copy link
Contributor

Example Scenario:

Authorized spend is made from a grantor to a grantee of 10AKT. Grantee creates deployment using grant with 5AKT and closes deployment immediately,. When authz grant balance is queried 5AKT (approx) is available. The important point here is that when authz funds are used for a deployment - remaining funds left in escrow on close are not returned to the grant allocation.

###Authorization created

provider-services tx deployment authz grant akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc 10000000uakt --from akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7

###State after initial authorization

provider-services query authz grants akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7 akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc
grants:
- authorization:
    '@type': /akash.deployment.v1beta2.DepositDeploymentAuthorization
    spend_limit:
      amount: "10000000"
      denom: uakt
  expiration: "2023-11-26T14:28:36Z"
pagination:
  next_key: null
  total: "0"

  ###Deployment created using authorization and then immediately closed

  provider-services tx deployment create --depositor-account akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7 --from akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc deploy.yml -y 

provider-services tx deployment close --from $AKASH_KEY_NAME

###Balance of authorization after closure (as we can see the auth is now 5AKT in balance

root@ip-172-31-41-158:~# provider-services query authz grants akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7 akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc
grants:
- authorization:
    '@type': /akash.deployment.v1beta2.DepositDeploymentAuthorization
    spend_limit:
      amount: "5000000"
      denom: uakt
  expiration: "2023-11-26T14:28:36Z"
@chainzero chainzero added the support Akash support tickets label Apr 11, 2023
@andy108369
Copy link
Contributor

andy108369 commented Apr 12, 2023

@chainzero the unused funds (5 AKT) have returned to the granter wallet (not to the granters authz deposit wallet, but to its normal wallet)

dseq: 8647334
owner: akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc
granter: akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7
  1. 8647288: DepositDeploymentAuthorization: grant (10 AKT)

https://www.mintscan.io/akash/txs/39ED7FAEF9DB2102A52044369395B971EB5BC246FBDB017E3595807991BCBBC5

$ provider-services --height 8647288 query authz grants akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7 akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc
grants:
- authorization:
    '@type': /akash.deployment.v1beta2.DepositDeploymentAuthorization
    spend_limit:
      amount: "10000000"
      denom: uakt
  expiration: "2023-11-26T14:28:36Z"
pagination:
  next_key: null
  total: "0"
  1. 8647335: MsgCreateDeployment

https://www.mintscan.io/akash/txs/895BB9EC2E43EC922E70D2B69F4D24499486DDF20BCC1E32C7F614DA174FDE87

$ provider-services --height 8647335 query authz grants akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7 akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc
grants:
- authorization:
    '@type': /akash.deployment.v1beta2.DepositDeploymentAuthorization
    spend_limit:
      amount: "5000000"
      denom: uakt
  expiration: "2023-11-26T14:28:36Z"
pagination:
  next_key: null
  total: "0"

None of 26 bids were selected, i.e. lease has never been created:

$ provider-services query market bid list --dseq 8647334 --owner akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc  | grep state | uniq -c
     26     state: closed

$ provider-services query market lease list --dseq 8647334 --owner akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc 
leases: []
pagination:
  next_key: null
  total: "0"
  1. 8647343: MsgCloseDeployment

https://www.mintscan.io/akash/txs/6EB79060FFE23D8A00A862BCDB955BE839DB88E5BC56CD06C588069175287CC9

Right at that height 8647343 the granter received his 5000000uakt (or 5 AKT) back:

$ akash --height 8647342 query bank balances akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7 -o json | jq -r '.balances[].amount|tonumber / pow(10;6)'
8.245243

$ akash --height 8647343 query bank balances akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7 -o json | jq -r '.balances[].amount|tonumber / pow(10;6)'
13.245243

Since these funds have been used (read: authorized), they did not return back to the authz grants authorization wallet but to his normal wallet:

$ provider-services --height 8647343 query authz grants akash1f53fp8kk470f7k26yr5gztd9npzpczqv4ufud7 akash12nwd3ezmfkux589wu47vsr3wd05kt9wn09ymgc
grants:
- authorization:
    '@type': /akash.deployment.v1beta2.DepositDeploymentAuthorization
    spend_limit:
      amount: "5000000"
      denom: uakt
  expiration: "2023-11-26T14:28:36Z"
pagination:
  next_key: null
  total: "0"

Not sure whether this is the intended behavior though.

@andy108369 andy108369 added the P2 label Apr 12, 2023
@andy108369
Copy link
Contributor

as per @boz - this behavior can be changed, below are the entry points:

  • here is where the authorization amount is decremented when depositing.
  • this is the implementation in the authorization.
  • here is where we'd need to do the inverse of Accept(). It's not trivial - some calculations need to be made and it needs to only be done when closing - but I think it's not too bad.

@troian troian added repo/node Akash node repo issues and removed support Akash support tickets labels Apr 12, 2023
@troian troian added P1 and removed P2 labels Sep 13, 2023
@troian troian self-assigned this Sep 13, 2023
troian added a commit to akash-network/node that referenced this issue Apr 18, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 18, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 20, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 20, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 20, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 21, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 22, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 22, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 22, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
@troian troian mentioned this issue Apr 22, 2024
2 tasks
troian added a commit to akash-network/node that referenced this issue Apr 22, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 22, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 22, 2024
fixes akash-network/support#88

Signed-off-by: Artur Troian <troian.ap@gmail.com>
troian added a commit to akash-network/node that referenced this issue Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 repo/node Akash node repo issues
Projects
Status: Released (in Prod)
Development

Successfully merging a pull request may close this issue.

3 participants