aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Aptos Framework] Add a module for creating staking contracts between stakers and operators

Open movekevin opened this issue 2 years ago • 4 comments

Description

This creates a separate StakePool per delegation (from a delegator to an operator) and does not allow pooling funds from multiple delegators at all.

Test Plan

Unit + e2e tests


This change is Reviewable

movekevin avatar Aug 28 '22 20:08 movekevin

Hi @movekevin , wanted to understand the status of user stake delegations on aptos a bit more. As far as i understand apart from this PR, there is no way for a user/contract to delegate their aptos to a validator currently. would i be right in saying that?

bharath-123 avatar Aug 29 '22 06:08 bharath-123

Hi @movekevin , wanted to understand the status of user stake delegations on aptos a bit more. As far as i understand apart from this PR, there is no way for a user/contract to delegate their aptos to a validator currently. would i be right in saying that?

Technically speaking, a user/module can always delegate to any operator they want by maintaining themselves as an owner (via signer or OwnerCap). The thing that's missing is an easy commission sharing feature that this simplistic delegations module provides. Without this, the commission sharing would have to be done in an off-chain agreement.

movekevin avatar Aug 30 '22 15:08 movekevin

Hi @movekevin , wanted to understand the status of user stake delegations on aptos a bit more. As far as i understand apart from this PR, there is no way for a user/contract to delegate their aptos to a validator currently. would i be right in saying that?

Technically speaking, a user/module can always delegate to any operator they want by maintaining themselves as an owner (via signer or OwnerCap). The thing that's missing is an easy commission sharing feature that this simplistic delegations module provides. Without this, the commission sharing would have to be done in an off-chain agreement.

Hey @movekevin , thank you for your kind reply. I see that we can only have 1 stake pool for a validator. So If i want to stake to a validator, i would have to get owner capability on the validator if i m right?

bharath-123 avatar Sep 01 '22 17:09 bharath-123

discussed offliine....

just add the vesting contract to this one and land both, please.

davidiw avatar Sep 16 '22 07:09 davidiw

Forge is running with 552f2eb8e634f573767a79ec7c890abbd914af85

:white_check_mark: Forge test success on 552f2eb8e634f573767a79ec7c890abbd914af85

performance benchmark with full nodes : 7073 TPS, 4219 ms latency, 6000 ms p99 latency,no expired txns
Test Ok

Forge is running with 5086fd60279ecc7560d0bee82dc6487008fcabec

:white_check_mark: Forge test success on 5086fd60279ecc7560d0bee82dc6487008fcabec

performance benchmark with full nodes : 7016 TPS, 4253 ms latency, 6000 ms p99 latency,no expired txns
Test Ok

Forge is running with 731368be66beac66d07c15b463fca52ecefa2d59

:x: Forge test perf regression on 731368be66beac66d07c15b463fca52ecefa2d59

Forge test runner terminated:
Trailing Log Lines:
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:84"},"thread_name":"main","hostname":"forge-pr-3570-1662244171-731368be66beac66d07c15b463fca52ecefa2d","timestamp":"2022-09-03T22:32:26.829895Z","message":"Genesis done"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:314"},"thread_name":"main","hostname":"forge-pr-3570-1662244171-731368be66beac66d07c15b463fca52ecefa2d","timestamp":"2022-09-03T22:32:26.829938Z","message":"[\"upgrade\", \"--install\", \"--create-namespace\", \"--namespace\", \"forge-pr-3570\", \"aptos-node\", \"terraform/helm/aptos-node\", \"--reuse-values\", \"--history-max\", \"2\", \"-f\", \"/tmp/.tmplXvpSp/aptos-node_status.json\", \"-f\", \"/tmp/.tmplXvpSp/aptos-node-values.yaml\", \"--set\", \"podSecurityPolicy=false\"]"}
Release "aptos-node" does not exist. Installing it now.
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:260"},"thread_name":"main","hostname":"forge-pr-3570-1662244171-731368be66beac66d07c15b463fca52ecefa2d","timestamp":"2022-09-03T22:32:28.076609Z","message":"Deleting namespace forge-pr-3570: Some(NamespaceStatus { phase: Some(\"Terminating\") })"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:368"},"thread_name":"main","hostname":"forge-pr-3570-1662244171-731368be66beac66d07c15b463fca52ecefa2d","timestamp":"2022-09-03T22:32:28.076636Z","message":"aptos-node resources for Forge removed in namespace: forge-pr-3570"}
Failed to run tests:
Upgrade not completed: Error: persistentvolumeclaims "aptos-node-17-validator-eforge245" is forbidden: rpc error: code = ResourceExhausted desc = etcdserver: throttle: too many requests

Error: Upgrade not completed: Error: persistentvolumeclaims "aptos-node-17-validator-eforge245" is forbidden: rpc error: code = ResourceExhausted desc = etcdserver: throttle: too many requests

Debugging output:
NAME                                    READY   STATUS      RESTARTS   AGE
genesis-aptos-genesis-eforge245-gmzfg   0/1     Completed   0          2m16s

Forge is running with 69351fc412b31ae358c596861a85a723bbddf2ce

:white_check_mark: Forge test success on 69351fc412b31ae358c596861a85a723bbddf2ce

performance benchmark with full nodes : 7132 TPS, 4190 ms latency, 6000 ms p99 latency,no expired txns
Test Ok

Forge is running with failpoints_453f3c8cc2797c5aa3ea0a9c47e2170beea4cca1

:white_check_mark: Forge test success on failpoints_453f3c8cc2797c5aa3ea0a9c47e2170beea4cca1

performance benchmark with full nodes : 6951 TPS, 4295 ms latency, 6000 ms p99 latency,no expired txns
Test Ok

Forge is running with failpoints_1de85ca7a9b1c0474b4f7f1fa21c5d06521baffc

:white_check_mark: Forge test success on failpoints_1de85ca7a9b1c0474b4f7f1fa21c5d06521baffc

performance benchmark with full nodes : 7014 TPS, 4260 ms latency, 6050 ms p99 latency,no expired txns
Test Ok

Forge is running with 6574ac73addbfcfae9d49f7d32e211dd1d55fa2a

:white_check_mark: Forge test success on 6574ac73addbfcfae9d49f7d32e211dd1d55fa2a

performance benchmark with full nodes : 6874 TPS, 4347 ms latency, 6000 ms p99 latency,no expired txns
Test Ok

Forge is running suite land_blocking on fcf095a4951cabfc54ce1326833bde578bd80a84

Forge is running suite compat on testnet ==> fcf095a4951cabfc54ce1326833bde578bd80a84

:white_check_mark: Forge suite land_blocking success on fcf095a4951cabfc54ce1326833bde578bd80a84

performance benchmark with full nodes : 7550 TPS, 3925 ms latency, 6300 ms p99 latency,no expired txns
Test Ok

:white_check_mark: Forge suite compat success on testnet ==> fcf095a4951cabfc54ce1326833bde578bd80a84

Compatibility test results for testnet ==> fcf095a4951cabfc54ce1326833bde578bd80a84 (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 7320 TPS, 3781 ms latency, 4900 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: fcf095a4951cabfc54ce1326833bde578bd80a84
compatibility::simple-validator-upgrade::single-validator-upgrade : 5208 TPS, 5162 ms latency, 7700 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: fcf095a4951cabfc54ce1326833bde578bd80a84
compatibility::simple-validator-upgrade::half-validator-upgrade : 5407 TPS, 5088 ms latency, 7100 ms p99 latency,no expired txns
4. upgrading second batch to new version: fcf095a4951cabfc54ce1326833bde578bd80a84
compatibility::simple-validator-upgrade::rest-validator-upgrade : 6085 TPS, 4028 ms latency, 6400 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> fcf095a4951cabfc54ce1326833bde578bd80a84 passed
Test Ok

Forge is running suite compat on testnet ==> 75c00a786976ff564a239fcc48d78f043b2f3066

Forge is running suite land_blocking on 75c00a786976ff564a239fcc48d78f043b2f3066

:white_check_mark: Forge suite land_blocking success on 75c00a786976ff564a239fcc48d78f043b2f3066

performance benchmark with full nodes : 7658 TPS, 3869 ms latency, 5400 ms p99 latency,no expired txns
Test Ok

:white_check_mark: Forge suite compat success on testnet ==> 75c00a786976ff564a239fcc48d78f043b2f3066

Compatibility test results for testnet ==> 75c00a786976ff564a239fcc48d78f043b2f3066 (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 7158 TPS, 3765 ms latency, 5200 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 75c00a786976ff564a239fcc48d78f043b2f3066
compatibility::simple-validator-upgrade::single-validator-upgrade : 5100 TPS, 5285 ms latency, 8900 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 75c00a786976ff564a239fcc48d78f043b2f3066
compatibility::simple-validator-upgrade::half-validator-upgrade : 5524 TPS, 4956 ms latency, 7700 ms p99 latency,no expired txns
4. upgrading second batch to new version: 75c00a786976ff564a239fcc48d78f043b2f3066
compatibility::simple-validator-upgrade::rest-validator-upgrade : 6046 TPS, 4365 ms latency, 7400 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> 75c00a786976ff564a239fcc48d78f043b2f3066 passed
Test Ok

Forge is running suite land_blocking on 5d4f0bfac18854eacb527f7f598d1211119fda22

Forge is running suite compat on testnet ==> 5d4f0bfac18854eacb527f7f598d1211119fda22

:white_check_mark: Forge suite land_blocking success on 5d4f0bfac18854eacb527f7f598d1211119fda22

performance benchmark with full nodes : 7556 TPS, 3926 ms latency, 6000 ms p99 latency,no expired txns
Test Ok

:white_check_mark: Forge suite compat success on testnet ==> 5d4f0bfac18854eacb527f7f598d1211119fda22

Compatibility test results for testnet ==> 5d4f0bfac18854eacb527f7f598d1211119fda22 (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 7196 TPS, 4026 ms latency, 6300 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 5d4f0bfac18854eacb527f7f598d1211119fda22
compatibility::simple-validator-upgrade::single-validator-upgrade : 6094 TPS, 4516 ms latency, 5800 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 5d4f0bfac18854eacb527f7f598d1211119fda22
compatibility::simple-validator-upgrade::half-validator-upgrade : 6074 TPS, 4407 ms latency, 5800 ms p99 latency,no expired txns
4. upgrading second batch to new version: 5d4f0bfac18854eacb527f7f598d1211119fda22
compatibility::simple-validator-upgrade::rest-validator-upgrade : 6364 TPS, 4125 ms latency, 7200 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> 5d4f0bfac18854eacb527f7f598d1211119fda22 passed
Test Ok

Forge is running suite land_blocking on 8b2786260633fa474d2e8f644344a1ccbcb3babe

Forge is running suite compat on testnet ==> 8b2786260633fa474d2e8f644344a1ccbcb3babe

:white_check_mark: Forge suite land_blocking success on 8b2786260633fa474d2e8f644344a1ccbcb3babe

performance benchmark with full nodes : 7846 TPS, 5052 ms latency, 6600 ms p99 latency,no expired txns
Test Ok

:white_check_mark: Forge suite compat success on testnet ==> 8b2786260633fa474d2e8f644344a1ccbcb3babe

Compatibility test results for testnet ==> 8b2786260633fa474d2e8f644344a1ccbcb3babe (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 7738 TPS, 4824 ms latency, 7500 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 8b2786260633fa474d2e8f644344a1ccbcb3babe
compatibility::simple-validator-upgrade::single-validator-upgrade : 4970 TPS, 7351 ms latency, 12000 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 8b2786260633fa474d2e8f644344a1ccbcb3babe
compatibility::simple-validator-upgrade::half-validator-upgrade : 5638 TPS, 6516 ms latency, 11500 ms p99 latency,no expired txns
4. upgrading second batch to new version: 8b2786260633fa474d2e8f644344a1ccbcb3babe
compatibility::simple-validator-upgrade::rest-validator-upgrade : 7414 TPS, 4609 ms latency, 6700 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> 8b2786260633fa474d2e8f644344a1ccbcb3babe passed
Test Ok

Forge is running suite land_blocking on 1d431f3fb339b2e2386c31598a5370ebb7e38f89

Forge is running suite compat on testnet ==> 1d431f3fb339b2e2386c31598a5370ebb7e38f89

:white_check_mark: Forge suite compat success on testnet ==> 1d431f3fb339b2e2386c31598a5370ebb7e38f89

Compatibility test results for testnet ==> 1d431f3fb339b2e2386c31598a5370ebb7e38f89 (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 7802 TPS, 4829 ms latency, 7800 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 1d431f3fb339b2e2386c31598a5370ebb7e38f89
compatibility::simple-validator-upgrade::single-validator-upgrade : 5842 TPS, 6475 ms latency, 8600 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 1d431f3fb339b2e2386c31598a5370ebb7e38f89
compatibility::simple-validator-upgrade::half-validator-upgrade : 5626 TPS, 6548 ms latency, 9500 ms p99 latency,no expired txns
4. upgrading second batch to new version: 1d431f3fb339b2e2386c31598a5370ebb7e38f89
compatibility::simple-validator-upgrade::rest-validator-upgrade : 7882 TPS, 4700 ms latency, 8600 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> 1d431f3fb339b2e2386c31598a5370ebb7e38f89 passed
Test Ok

:white_check_mark: Forge suite land_blocking success on 1d431f3fb339b2e2386c31598a5370ebb7e38f89

performance benchmark with full nodes : 7831 TPS, 5073 ms latency, 6900 ms p99 latency,no expired txns
Test Ok

Forge is running suite compat on testnet ==> 7887edcf2946f23d90ae3333fc126cbfd9272a3a

Forge is running suite land_blocking on 7887edcf2946f23d90ae3333fc126cbfd9272a3a

:white_check_mark: Forge suite land_blocking success on 7887edcf2946f23d90ae3333fc126cbfd9272a3a

performance benchmark with full nodes : 7912 TPS, 5021 ms latency, 7700 ms p99 latency,no expired txns
Test Ok

:white_check_mark: Forge suite compat success on testnet ==> 7887edcf2946f23d90ae3333fc126cbfd9272a3a

Compatibility test results for testnet ==> 7887edcf2946f23d90ae3333fc126cbfd9272a3a (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 8074 TPS, 4746 ms latency, 6800 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 7887edcf2946f23d90ae3333fc126cbfd9272a3a
compatibility::simple-validator-upgrade::single-validator-upgrade : 6213 TPS, 6210 ms latency, 8700 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 7887edcf2946f23d90ae3333fc126cbfd9272a3a
compatibility::simple-validator-upgrade::half-validator-upgrade : 5362 TPS, 6879 ms latency, 9500 ms p99 latency,no expired txns
4. upgrading second batch to new version: 7887edcf2946f23d90ae3333fc126cbfd9272a3a
compatibility::simple-validator-upgrade::rest-validator-upgrade : 7054 TPS, 5114 ms latency, 8100 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> 7887edcf2946f23d90ae3333fc126cbfd9272a3a passed
Test Ok

Forge is running suite compat on testnet ==> 3f7c2a054cb42965ae5484dac46813d887b4f4bb

Forge is running suite land_blocking on 3f7c2a054cb42965ae5484dac46813d887b4f4bb

:white_check_mark: Forge suite land_blocking success on 3f7c2a054cb42965ae5484dac46813d887b4f4bb

performance benchmark with full nodes : 7811 TPS, 5065 ms latency, 8100 ms p99 latency,(!) expired 660 out of 3375440 txns
Test Ok

:white_check_mark: Forge suite compat success on testnet ==> 3f7c2a054cb42965ae5484dac46813d887b4f4bb

Compatibility test results for testnet ==> 3f7c2a054cb42965ae5484dac46813d887b4f4bb (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 8160 TPS, 4523 ms latency, 6800 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 3f7c2a054cb42965ae5484dac46813d887b4f4bb
compatibility::simple-validator-upgrade::single-validator-upgrade : 5758 TPS, 6631 ms latency, 9800 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 3f7c2a054cb42965ae5484dac46813d887b4f4bb
compatibility::simple-validator-upgrade::half-validator-upgrade : 5796 TPS, 6789 ms latency, 9000 ms p99 latency,no expired txns
4. upgrading second batch to new version: 3f7c2a054cb42965ae5484dac46813d887b4f4bb
compatibility::simple-validator-upgrade::rest-validator-upgrade : 7504 TPS, 4613 ms latency, 7800 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> 3f7c2a054cb42965ae5484dac46813d887b4f4bb passed
Test Ok

Forge is running suite compat on testnet ==> b410981e64457dc24906e4257d9875fa61b94448

Forge is running suite land_blocking on b410981e64457dc24906e4257d9875fa61b94448

:white_check_mark: Forge suite land_blocking success on b410981e64457dc24906e4257d9875fa61b94448

performance benchmark with full nodes : 7998 TPS, 4958 ms latency, 8100 ms p99 latency,no expired txns
Test Ok

:white_check_mark: Forge suite compat success on testnet ==> b410981e64457dc24906e4257d9875fa61b94448

Compatibility test results for testnet ==> b410981e64457dc24906e4257d9875fa61b94448 (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 8669 TPS, 4132 ms latency, 6300 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: b410981e64457dc24906e4257d9875fa61b94448
compatibility::simple-validator-upgrade::single-validator-upgrade : 5874 TPS, 6318 ms latency, 8100 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: b410981e64457dc24906e4257d9875fa61b94448
compatibility::simple-validator-upgrade::half-validator-upgrade : 5796 TPS, 6201 ms latency, 8100 ms p99 latency,no expired txns
4. upgrading second batch to new version: b410981e64457dc24906e4257d9875fa61b94448
compatibility::simple-validator-upgrade::rest-validator-upgrade : 7669 TPS, 4785 ms latency, 8200 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> b410981e64457dc24906e4257d9875fa61b94448 passed
Test Ok

Forge is running suite compat on testnet ==> 2cd5f98a69bd47703e1255ff1356a59eda9b2666

Forge is running suite land_blocking on 2cd5f98a69bd47703e1255ff1356a59eda9b2666

:white_check_mark: Forge suite land_blocking success on 2cd5f98a69bd47703e1255ff1356a59eda9b2666

performance benchmark with full nodes : 8106 TPS, 4869 ms latency, 8100 ms p99 latency,(!) expired 1340 out of 3503560 txns
Test Ok

:white_check_mark: Forge suite compat success on testnet ==> 2cd5f98a69bd47703e1255ff1356a59eda9b2666

Compatibility test results for testnet ==> 2cd5f98a69bd47703e1255ff1356a59eda9b2666 (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 7671 TPS, 4853 ms latency, 7500 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 2cd5f98a69bd47703e1255ff1356a59eda9b2666
compatibility::simple-validator-upgrade::single-validator-upgrade : 5678 TPS, 6663 ms latency, 9300 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 2cd5f98a69bd47703e1255ff1356a59eda9b2666
compatibility::simple-validator-upgrade::half-validator-upgrade : 5622 TPS, 6566 ms latency, 9000 ms p99 latency,no expired txns
4. upgrading second batch to new version: 2cd5f98a69bd47703e1255ff1356a59eda9b2666
compatibility::simple-validator-upgrade::rest-validator-upgrade : 7838 TPS, 4641 ms latency, 9000 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> 2cd5f98a69bd47703e1255ff1356a59eda9b2666 passed
Test Ok

Forge is running suite compat on testnet ==> 2ccad5ab67966020b5217b9df90fec305174267d

Forge is running suite land_blocking on 2ccad5ab67966020b5217b9df90fec305174267d

:white_check_mark: Forge suite compat success on testnet ==> 2ccad5ab67966020b5217b9df90fec305174267d

Compatibility test results for testnet ==> 2ccad5ab67966020b5217b9df90fec305174267d (PR)
1. Check liveness of validators at old version: testnet
compatibility::simple-validator-upgrade::liveness-check : 7866 TPS, 4671 ms latency, 6900 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 2ccad5ab67966020b5217b9df90fec305174267d
compatibility::simple-validator-upgrade::single-validator-upgrade : 5415 TPS, 6898 ms latency, 9800 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 2ccad5ab67966020b5217b9df90fec305174267d
compatibility::simple-validator-upgrade::half-validator-upgrade : 5454 TPS, 7039 ms latency, 9800 ms p99 latency,no expired txns
4. upgrading second batch to new version: 2ccad5ab67966020b5217b9df90fec305174267d
compatibility::simple-validator-upgrade::rest-validator-upgrade : 7894 TPS, 4674 ms latency, 7700 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet ==> 2ccad5ab67966020b5217b9df90fec305174267d passed
Test Ok

:white_check_mark: Forge suite land_blocking success on 2ccad5ab67966020b5217b9df90fec305174267d

performance benchmark with full nodes : 8056 TPS, 4921 ms latency, 8100 ms p99 latency,(!) expired 400 out of 3480960 txns
Test Ok

github-actions[bot] avatar Sep 16 '22 16:09 github-actions[bot]