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

rosetta delegator address balances #8421

Merged
merged 5 commits into from
Jun 3, 2023
Merged

Conversation

defnotzed
Copy link
Contributor

@defnotzed defnotzed commented May 30, 2023

Description

Implement the delegator address balances rosetta endpoint.

The rosetta client should manage its own delegator and pool address relationship when fetching relevant data.
The request payload should look like this (added the metadata field under sub_account_identifier):

"account_identifier": {
    "address": "0x899d44dca988af7895cdc9828ae0e7f6c5c42d74fa1610e693fb5f613cb8c09a", // owner/delegator address
    "sub_account": {
        "address": "active_stake", // string active
        # this is the new field added
        "metadata": {
            "pool_address": "0xbd50bb20e1972747db365c3a6e31255d78867c6b8df9877ea6054bb335dd6031" // pool_address
        }
    }
}

About balance fetching:
Using delegator address 0x65b1e4d62e803d7e3a5c715baa33391757ae530c9fef287bf2d7d15c1ea6e3e6 and its validator address 0x2ded75e99c6efbe143a9648a3e88ebf9d0cf249b2af44d510bdd0287e8adcc79 as an example

The response should be similar to native staking:
Variables that should be fetched from the delegator address:

  1. Sequence number from its 0x1::account::Account resource
  2. Balances from delegation_pool.move get_stake() function

Variables should be fetched from the pool address:
1. Operator from 0x1::stake::StakePool resource
2. Lockup until secs from 0x1::stake::StakePool resource

Test Plan

Tested with remote online node from e2e
delegated staking balance
Screenshot 2023-06-01 at 4 15 45 PM

native staking balance
Screenshot 2023-06-01 at 4 16 37 PM

direct balance
Screenshot 2023-06-01 at 4 17 25 PM

@defnotzed defnotzed requested a review from gregnazario as a code owner May 30, 2023 08:18
@defnotzed defnotzed force-pushed the zed/balance branch 2 times, most recently from 1d0927b to a0e867f Compare May 30, 2023 16:58
crates/aptos-rosetta/src/types/misc.rs Outdated Show resolved Hide resolved
crates/aptos-rosetta/src/types/misc.rs Outdated Show resolved Hide resolved
crates/aptos-rosetta/src/types/misc.rs Outdated Show resolved Hide resolved
crates/aptos-rosetta/src/types/misc.rs Outdated Show resolved Hide resolved
crates/aptos-rosetta/src/types/misc.rs Outdated Show resolved Hide resolved
crates/aptos-rosetta/src/types/identifiers.rs Show resolved Hide resolved
@defnotzed defnotzed force-pushed the zed/balance branch 2 times, most recently from 4a5fc24 to 8958349 Compare May 31, 2023 22:54
@defnotzed defnotzed requested a review from xindingw May 31, 2023 22:56
requested_balance = balances_result.get(1).and_then(|v| v.as_str().map(|s| s.to_owned()));
} else if account_identifier.is_delegator_pending_inactive_stake() {
requested_balance = balances_result.get(2).and_then(|v| v.as_str().map(|s| s.to_owned()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe throw "Unable to construct BalanceResult instance" error here?

Copy link
Contributor

@xindingw xindingw left a comment

Choose a reason for hiding this comment

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

LGTM! Let me know if you need me to find another approver.

@xindingw xindingw requested review from banool and 0xmaayan June 2, 2023 21:21
@davidiw davidiw enabled auto-merge (squash) June 2, 2023 23:03
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2023

✅ Forge suite compat success on testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 515f1381d6af5c8a44bddfa004ff15931db513d9

Compatibility test results for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 515f1381d6af5c8a44bddfa004ff15931db513d9 (PR)
1. Check liveness of validators at old version: testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b
compatibility::simple-validator-upgrade::liveness-check : 10100 TPS, 3700 ms latency, 6400 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 515f1381d6af5c8a44bddfa004ff15931db513d9
compatibility::simple-validator-upgrade::single-validator-upgrade : 6044 TPS, 6843 ms latency, 11000 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 515f1381d6af5c8a44bddfa004ff15931db513d9
compatibility::simple-validator-upgrade::half-validator-upgrade : 5630 TPS, 7003 ms latency, 9200 ms p99 latency,no expired txns
4. upgrading second batch to new version: 515f1381d6af5c8a44bddfa004ff15931db513d9
compatibility::simple-validator-upgrade::rest-validator-upgrade : 8085 TPS, 4696 ms latency, 8900 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 515f1381d6af5c8a44bddfa004ff15931db513d9 passed
Test Ok

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2023

✅ Forge suite land_blocking success on 515f1381d6af5c8a44bddfa004ff15931db513d9

performance benchmark : 5827 TPS, 6800 ms latency, 26400 ms p99 latency,(!) expired 383 out of 2488640 txns
Test Ok

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2023

✅ Forge suite framework_upgrade success on aptos-node-v1.3.0_3fc3d42b6cfe27460004f9a0326451bcda840a60 ==> 515f1381d6af5c8a44bddfa004ff15931db513d9

Compatibility test results for aptos-node-v1.3.0_3fc3d42b6cfe27460004f9a0326451bcda840a60 ==> 515f1381d6af5c8a44bddfa004ff15931db513d9 (PR)
Upgrade the nodes to version: 515f1381d6af5c8a44bddfa004ff15931db513d9
framework_upgrade::framework-upgrade::full-framework-upgrade : 6042 TPS, 6487 ms latency, 11100 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for aptos-node-v1.3.0_3fc3d42b6cfe27460004f9a0326451bcda840a60 ==> 515f1381d6af5c8a44bddfa004ff15931db513d9 passed
Test Ok

@davidiw davidiw disabled auto-merge June 3, 2023 00:46
@davidiw davidiw merged commit 97b6dd3 into aptos-labs:main Jun 3, 2023
gedigi pushed a commit that referenced this pull request Jun 6, 2023
* rosetta delegator address balances

* address comments

* e2e test fix

* cargo xclippy

* run rust lint script

---------

Co-authored-by: Zizheng Jiang <zizheng.jiang@coinbase.com>
banool pushed a commit that referenced this pull request Jul 7, 2023
* rosetta delegator address balances

* address comments

* e2e test fix

* cargo xclippy

* run rust lint script

---------

Co-authored-by: Zizheng Jiang <zizheng.jiang@coinbase.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants