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

feat(runtime): switch to state staking #2272

Merged
merged 25 commits into from
Mar 30, 2020
Merged

Conversation

ilblackdragon
Copy link
Member

@ilblackdragon ilblackdragon commented Mar 18, 2020

Addresses spec change near/NEPs#41

Associated PR to change nearlib errors - near/near-api-js#270

Test plan

All runtime tests pass (removing ones that don't make sense)
Tests that remove account when it's under funded still work as expected.
TODO: add test for creation w/o funds + transfer and deletion of under funded account.

Addresses spec change near/NEPs#41

Test plan
---------
All runtime tests pass (removing ones that don't make sense)
Tests that remove account when it's under funded still work as expected.
@gitpod-io
Copy link

gitpod-io bot commented Mar 18, 2020

@ilblackdragon ilblackdragon added this to the MainNet milestone Mar 18, 2020
@ilblackdragon ilblackdragon requested a review from frol as a code owner March 18, 2020 15:44
@MaksymZavershynskyi
Copy link
Contributor

Let's wait with the implementation until we agree with the design here: near/NEPs#40 .

core/primitives/src/account.rs Outdated Show resolved Hide resolved
core/primitives/src/errors.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
runtime/runtime/src/verifier.rs Outdated Show resolved Hide resolved
@frol frol mentioned this pull request Mar 19, 2020
3 tasks
chain/chain/src/error.rs Show resolved Hide resolved
core/primitives/src/errors.rs Outdated Show resolved Hide resolved
runtime/runtime/src/verifier.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
@ilblackdragon
Copy link
Member Author

@nearmax Generally, I think spec changes should come with associated code changes after initial discussion - because if the change is dramatic or has huge risk, it's valuable to see that at the spec discussion state. It also clear after even initial implementation what are edge cases that should be added to the spec.

@MaksymZavershynskyi
Copy link
Contributor

@nearmax Generally, I think spec changes should come with associated code changes after initial discussion - because if the change is dramatic or has huge risk, it's valuable to see that at the spec discussion state. It also clear after even initial implementation what are edge cases that should be added to the spec.

Okay, do you want to submit spec changes PR or create an issue?

@ilblackdragon ilblackdragon removed this from the MainNet milestone Mar 24, 2020
@ilblackdragon
Copy link
Member Author

@nearmax Submitted spec change.

Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

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

Except for the obviously broken migration, LGTM.

storage_paid_at and rent_paid getting default 0 values for RPC responses should not break AppLayer, in my opinion, so we can deprecate the fields when we have a plan of how we do that (tracking issue: #2271)

scripts/migrations/5-preserve-height.py Show resolved Hide resolved
scripts/migrations/6-state-stake.py Outdated Show resolved Hide resolved
core/primitives/src/errors.rs Outdated Show resolved Hide resolved
core/runtime-configs/src/lib.rs Outdated Show resolved Hide resolved
core/runtime-configs/src/lib.rs Show resolved Hide resolved
runtime/runtime-params-estimator/src/cases.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
runtime/runtime/src/actions.rs Outdated Show resolved Hide resolved
scripts/migrations/6-state-stake.py Outdated Show resolved Hide resolved
runtime/near-runtime-fees/src/lib.rs Outdated Show resolved Hide resolved
runtime/runtime/src/lib.rs Outdated Show resolved Hide resolved
test-utils/testlib/src/standard_test_cases.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@evgenykuzyakov evgenykuzyakov left a comment

Choose a reason for hiding this comment

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

Also, it's possible that we might need to bump balance on all accounts that have code deployed. Otherwise they might be out of balance in the testnet. But it's probably not as bad, because this state is not enforced actually. Which we should do

runtime/near-runtime-fees/src/lib.rs Outdated Show resolved Hide resolved
@ilblackdragon
Copy link
Member Author

@evgenykuzyakov Returned back to 100 and made sure in migration that every account has enough balance to cover storage.

RentUnpaid {
/// An account which is required to pay the rent
/// Signer account doesn't have enough balance after transaction.
LackBalanceForState {
Copy link
Contributor

Choose a reason for hiding this comment

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

InsufficientBalanceForState would be a better name.

/// - Err(StorageError::StorageInconsistentState) if account has invalid storage usage or amount/locked.
///
/// Read details of state staking https://nomicon.io/Economics/README.html#state-stake
pub(crate) fn get_insufficient_storage_stake(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename it to check_sufficient_storage_stake.

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.

Approving, assuming the comments are addressed.

@nearprotocol-bulldozer nearprotocol-bulldozer bot merged commit 050396a into master Mar 30, 2020
@nearprotocol-bulldozer nearprotocol-bulldozer bot deleted the state-stake branch March 30, 2020 23:18
nearprotocol-bulldozer bot pushed a commit that referenced this pull request Apr 2, 2020
…nce it is invalid (#2376)

This fixes a broken `pytest/tests/sanity/rpc_state_changes.py`.

The test got into a broken state after #2272

## Test Plan

* [x] Make sure that the `pytest/tests/sanity/rpc_state_changes.py` test passes locally
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.

8 participants