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

Restaking service + validator RPC improvement #1962

Merged
merged 4 commits into from
Jan 18, 2020
Merged

Conversation

ilblackdragon
Copy link
Member

(Previous PR #1894 was based of master, redone)

This implements a separate service that run in parallel with nearcore and re-stakes if it sees that given validator might be kicked out or already kicked out.

Usage:

cargo build -p restaked --release
./target/release/restaked \
    --home=/path/to/validator_key.json \
    --rpc-url=http://url.to.your.node.or.any.node \
    --wait-period=<how often to check in seconds> \
    --stake-amount=<amount to stake, if 0 will restake the last seen amount>

Note, right now uses validator_key.json to sign transactions as well. It's TODO to add option for a different signing key.

Additionally:

http post http://localhost:3030 jsonrpc=2.0 method=validators id=123 params:='[null]'
{
    "id": "123",
    "jsonrpc": "2.0",
    "result": {
        "current_fishermen": [],
        "current_proposals": [],
        "current_validators": [
            {
                "account_id": "test.near",
                "is_slashed": false,
                "num_expected_blocks": 38,
                "num_produced_blocks": 38,
                "public_key": "ed25519:22skMptHjFWNyuEWY22ftn2AbLPSYpmYwGJRGwpNHbTV",
                "shards": [
                    0
                ],
                "stake": "50445149127868051176979985"
            }
        ],
        "next_fishermen": [],
        "next_validators": [
            {
                "account_id": "test.near",
                "public_key": "ed25519:22skMptHjFWNyuEWY22ftn2AbLPSYpmYwGJRGwpNHbTV",
                "shards": [
                    0
                ],
                "stake": "50445324683980935237733345"
            }
        ]
    }
}
  • Network info additionally shows PeerId for known_producers.

CC @frol about RPC changes and @amgando for documentation changes of RPC and Restaking itself.

…ected. Added author to Chunk and Block

Validators RPC shows shards/pk, network info RPC shows peer ids for known validators. Make stake naming consistent

Print which test is runned before run it (#1889)

* Print which test is runned before run it

* adding a timeout

Add transaction to tx rpc (#1865)

* Add transaction to tx rpc

* address comments

* fix

Run test as non root in docker and check binary exist before mount to docker (#1891)

* Run test as non root in docker, check is file before mount to docker

Fix stake return for double sign slashing (#1877)

Addressing comments & fixing fmt

Improve naming for stats in the epoch manager. Fix some comments in restaking service

Add test for restaked
@codecov
Copy link

codecov bot commented Jan 15, 2020

Codecov Report

Merging #1962 into staging will increase coverage by 0.05%.
The diff coverage is 77.98%.

Impacted file tree graph

@@             Coverage Diff             @@
##           staging    #1962      +/-   ##
===========================================
+ Coverage    86.36%   86.41%   +0.05%     
===========================================
  Files          167      167              
  Lines        31742    31677      -65     
===========================================
- Hits         27414    27374      -40     
+ Misses        4328     4303      -25
Impacted Files Coverage Δ
chain/client/tests/challenges.rs 95.62% <ø> (-0.11%) ⬇️
chain/pool/src/types.rs 71.42% <ø> (ø) ⬆️
chain/client/src/test_utils.rs 77.86% <0%> (-2.64%) ⬇️
chain/chunks/src/lib.rs 93.6% <100%> (-0.02%) ⬇️
runtime/runtime/src/state_viewer.rs 92.56% <91.66%> (-0.24%) ⬇️
chain/pool/src/lib.rs 99.23% <97.33%> (+0.14%) ⬆️
chain/network/src/lib.rs 0% <0%> (-100%) ⬇️
near/tests/run_nodes.rs 93.18% <0%> (-4.6%) ⬇️
chain/client/src/client_actor.rs 85.99% <0%> (-1.47%) ⬇️
chain/client/tests/cross_shard_tx.rs 17.07% <0%> (-1.25%) ⬇️
... and 60 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae1645d...e5187e0. Read the comment docs.

chain/client/src/view_client.rs Outdated Show resolved Hide resolved
chain/client/src/view_client.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@MaksymZavershynskyi MaksymZavershynskyi left a comment

Choose a reason for hiding this comment

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

LGTM for middleware code.

@amgando
Copy link
Contributor

amgando commented Jan 22, 2020

appended re-staking service to validator section

image

@amgando
Copy link
Contributor

amgando commented Jan 22, 2020

appended new validator RPC call to RPC API section

image

@amgando
Copy link
Contributor

amgando commented Jan 23, 2020

not sure why i'm getting a different response from TestNet

expected: see example above (#1962 (comment))

actual:

http post https://rpc.nearprotocol.com jsonrpc=2.0 method=validators params:='["8ehA3NYL5uSF8zefbnqnz66twYJ45rfst6SrqBNv7oka"]' id=dontcare
{
    "id": "dontcare",
    "jsonrpc": "2.0",
    "result": {
        "current_fishermen": [],
        "current_proposals": [],
        "current_validators": [
            {
                "account_id": "far",
                "is_slashed": false,
                "num_missing_blocks": 0,
                "stake": "200663637577332478904026936259"
            }
        ],
        "next_fishermen": [],
        "next_validators": [
            {
                "account_id": "far",
                "amount": "200665040940372677611389132209",
                "public_key": "ed25519:7rNEmDbkn8grQREdTt3PWhR1phNtsqJdgfV26XdR35QL"
            }
        ]
    }
}

@bowenwang1996
Copy link
Collaborator

well there is a difference between localhost and testnet.

@ilblackdragon
Copy link
Member Author

@amgando because TestNet is running older version of the code.

SkidanovAlex pushed a commit that referenced this pull request Jan 29, 2020
* Adding restaking tool. Modify RPC for validators to show produced/expected. Added author to Chunk and Block

Validators RPC shows shards/pk, network info RPC shows peer ids for known validators. Make stake naming consistent

Print which test is runned before run it (#1889)

* Print which test is runned before run it

* adding a timeout

Add transaction to tx rpc (#1865)

* Add transaction to tx rpc

* address comments

* fix

Run test as non root in docker and check binary exist before mount to docker (#1891)

* Run test as non root in docker, check is file before mount to docker

Fix stake return for double sign slashing (#1877)

Addressing comments & fixing fmt

Improve naming for stats in the epoch manager. Fix some comments in restaking service

Add test for restaked

* Fixes
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.

5 participants