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
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9e52b8b
feature(runtime): switch to state staking
ilblackdragon Mar 16, 2020
0d0351a
Merge remote-tracking branch 'origin/master' into state-stake
ilblackdragon Mar 18, 2020
84a805e
Fix test_validate_transaction_invalid_low_balance test; update rpc sc…
ilblackdragon Mar 18, 2020
aabb6bc
Fix challenge change after account binary representation switch
ilblackdragon Mar 19, 2020
a5e7b5c
Merge remote-tracking branch 'origin/master' into state-stake
ilblackdragon Mar 20, 2020
1af31a6
Addressing comments
ilblackdragon Mar 20, 2020
63e334d
Merge remote-tracking branch 'origin/master' into state-stake
ilblackdragon Mar 23, 2020
56b4669
Added migration for state staking
ilblackdragon Mar 23, 2020
28a40b4
Merge remote-tracking branch 'origin/master' into state-stake
ilblackdragon Mar 23, 2020
e9471e8
Merge remote-tracking branch 'origin/master' into state-stake
ilblackdragon Mar 27, 2020
099fbc4
Adding couple more tests to show case the logic
ilblackdragon Mar 27, 2020
7211ff3
Remove account name pricing
ilblackdragon Mar 27, 2020
f972b3d
Put back errors for backward compatability
ilblackdragon Mar 27, 2020
4bbd6b1
Revert previous commit
ilblackdragon Mar 27, 2020
e9af34c
Fix migration scripts and migration test
ilblackdragon Mar 30, 2020
88d2fc4
Merge remote-tracking branch 'origin/master' into state-stake
ilblackdragon Mar 30, 2020
86b520c
Merge branch 'master' into state-stake
ilblackdragon Mar 30, 2020
6962337
Fix migration script
ilblackdragon Mar 30, 2020
8a08241
NEP #55: remove account deletion in state staking. Addressing comments
ilblackdragon Mar 30, 2020
6960fc6
Move Account::new to test_utils
ilblackdragon Mar 30, 2020
d4765f2
Merge remote-tracking branch 'origin/master' into state-stake
ilblackdragon Mar 30, 2020
03bcf04
Address comments
ilblackdragon Mar 30, 2020
1d775c2
Merge refs/heads/master into state-stake
nearprotocol-bulldozer[bot] Mar 30, 2020
7da1047
Addressing comments
ilblackdragon Mar 30, 2020
2608be4
Merge refs/heads/master into state-stake
nearprotocol-bulldozer[bot] Mar 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ impl Chain {
vec![],
vec![],
0,
0,
chain_genesis.total_supply,
)?;
store_update.save_block_header(genesis.header.clone());
Expand All @@ -343,7 +342,6 @@ impl Chain {
chain_genesis.gas_limit,
0,
0,
0,
),
);
}
Expand Down Expand Up @@ -728,7 +726,6 @@ impl Chain {
header.inner_rest.validator_proposals.clone(),
vec![],
header.inner_rest.chunk_mask.clone(),
header.inner_rest.rent_paid,
header.inner_rest.validator_reward,
header.inner_rest.total_supply,
)?;
Expand Down Expand Up @@ -2442,7 +2439,6 @@ impl<'a> ChainUpdate<'a> {
apply_result.validator_proposals,
apply_result.total_gas_burnt,
gas_limit,
apply_result.total_rent_paid,
apply_result.total_validator_reward,
apply_result.total_balance_burnt,
),
Expand Down Expand Up @@ -2671,7 +2667,6 @@ impl<'a> ChainUpdate<'a> {
block.header.inner_rest.validator_proposals.clone(),
block.header.inner_rest.challenges_result.clone(),
block.header.inner_rest.chunk_mask.clone(),
block.header.inner_rest.rent_paid,
block.header.inner_rest.validator_reward,
block.header.inner_rest.total_supply,
)?;
Expand Down Expand Up @@ -3148,7 +3143,6 @@ impl<'a> ChainUpdate<'a> {
apply_result.validator_proposals,
apply_result.total_gas_burnt,
gas_limit,
apply_result.total_rent_paid,
apply_result.total_validator_reward,
apply_result.total_balance_burnt,
);
Expand Down
4 changes: 0 additions & 4 deletions chain/chain/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ pub enum ErrorKind {
/// Invalid Gas Used
#[fail(display = "Invalid Gas Used")]
InvalidGasUsed,
/// Invalid Rent Paid
#[fail(display = "Invalid Rent Paid")]
InvalidRent,
ilblackdragon marked this conversation as resolved.
Show resolved Hide resolved
/// Invalid Validator Reward
#[fail(display = "Invalid Validator Reward")]
InvalidReward,
Expand Down Expand Up @@ -250,7 +247,6 @@ impl Error {
| ErrorKind::InvalidGasUsed
| ErrorKind::InvalidReward
| ErrorKind::InvalidBalanceBurnt
| ErrorKind::InvalidRent
| ErrorKind::InvalidShardId(_)
| ErrorKind::InvalidStateRequest(_)
| ErrorKind::InvalidRandomnessBeaconOutput
Expand Down
3 changes: 0 additions & 3 deletions chain/chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ impl RuntimeAdapter for KeyValueRuntime {
_proposals: Vec<ValidatorStake>,
_slashed_validators: Vec<SlashedValidator>,
_validator_mask: Vec<bool>,
_rent_paid: Balance,
_validator_reward: Balance,
_total_supply: Balance,
) -> Result<(), Error> {
Expand Down Expand Up @@ -648,7 +647,6 @@ impl RuntimeAdapter for KeyValueRuntime {
receipt_result: new_receipts,
validator_proposals: vec![],
total_gas_burnt: 0,
total_rent_paid: 0,
total_validator_reward: 0,
total_balance_burnt: 0,
proof: None,
Expand Down Expand Up @@ -694,7 +692,6 @@ impl RuntimeAdapter for KeyValueRuntime {
locked: 0,
code_hash: CryptoHash::default(),
storage_usage: 0,
storage_paid_at: 0,
}
.into(),
),
Expand Down
2 changes: 0 additions & 2 deletions chain/chain/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub struct ApplyTransactionResult {
pub receipt_result: ReceiptResult,
pub validator_proposals: Vec<ValidatorStake>,
pub total_gas_burnt: Gas,
pub total_rent_paid: Balance,
pub total_validator_reward: Balance,
pub total_balance_burnt: Balance,
pub proof: Option<PartialStorage>,
Expand Down Expand Up @@ -318,7 +317,6 @@ pub trait RuntimeAdapter: Send + Sync {
proposals: Vec<ValidatorStake>,
slashed_validators: Vec<SlashedValidator>,
validator_mask: Vec<bool>,
rent_paid: Balance,
validator_reward: Balance,
total_supply: Balance,
) -> Result<(), Error>;
Expand Down
5 changes: 0 additions & 5 deletions chain/chain/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ pub fn validate_chunk_with_chunk_extra(
return Err(ErrorKind::InvalidGasUsed.into());
}

if prev_chunk_extra.rent_paid != chunk_header.inner.rent_paid {
return Err(ErrorKind::InvalidRent.into());
}

if prev_chunk_extra.validator_reward != chunk_header.inner.validator_reward {
return Err(ErrorKind::InvalidReward.into());
}
Expand Down Expand Up @@ -328,7 +324,6 @@ fn validate_chunk_state_challenge(
|| outcome_root != chunk_state.chunk_header.inner.outcome_root
|| result.validator_proposals != chunk_state.chunk_header.inner.validator_proposals
|| result.total_gas_burnt != chunk_state.chunk_header.inner.gas_used
|| result.total_rent_paid != chunk_state.chunk_header.inner.rent_paid
{
Ok((block_header.hash(), vec![chunk_producer]))
} else {
Expand Down
1 change: 0 additions & 1 deletion chain/chunks/src/chunk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ mod tests {
0,
0,
0,
0,
CryptoHash::default(),
CryptoHash::default(),
vec![],
Expand Down
2 changes: 0 additions & 2 deletions chain/chunks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ impl ShardsManager {
shard_id: ShardId,
gas_used: Gas,
gas_limit: Gas,
rent_paid: Balance,
validator_reward: Balance,
balance_burnt: Balance,
validator_proposals: Vec<ValidatorStake>,
Expand All @@ -1016,7 +1015,6 @@ impl ShardsManager {
rs,
gas_used,
gas_limit,
rent_paid,
validator_reward,
balance_burnt,
tx_root,
Expand Down
1 change: 0 additions & 1 deletion chain/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ impl Client {
shard_id,
chunk_extra.gas_used,
chunk_extra.gas_limit,
chunk_extra.rent_paid,
chunk_extra.validator_reward,
chunk_extra.balance_burnt,
chunk_extra.validator_proposals.clone(),
Expand Down
18 changes: 8 additions & 10 deletions chain/client/tests/challenges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ fn create_chunk(
&mut rs,
chunk.header.inner.gas_used,
chunk.header.inner.gas_limit,
chunk.header.inner.rent_paid,
chunk.header.inner.validator_reward,
chunk.header.inner.balance_burnt,
tx_root,
Expand Down Expand Up @@ -404,7 +403,6 @@ fn test_verify_chunk_invalid_state_challenge() {
1_000,
0,
0,
0,
vec![],
vec![],
&vec![],
Expand Down Expand Up @@ -479,16 +477,16 @@ fn test_verify_chunk_invalid_state_challenge() {
challenge_body.partial_state.0,
vec![
vec![
1, 5, 0, 195, 214, 6, 46, 119, 169, 1, 3, 121, 138, 244, 191, 143, 67, 22, 114,
135, 198, 178, 165, 31, 28, 170, 137, 37, 101, 144, 65, 83, 21, 211, 67, 171,
30, 7, 228, 175, 99, 17, 113, 5, 94, 136, 200, 39, 136, 37, 110, 166, 241, 148,
128, 55, 131, 173, 97, 98, 201, 68, 82, 244, 223, 70, 86, 185, 5, 0, 0, 0, 0,
0, 0
1, 5, 0, 10, 178, 228, 151, 124, 13, 70, 6, 146, 31, 193, 111, 108, 60, 102,
227, 106, 220, 133, 45, 144, 104, 255, 30, 155, 129, 215, 15, 43, 202, 26, 122,
171, 30, 7, 228, 175, 99, 17, 113, 5, 94, 136, 200, 39, 136, 37, 110, 166, 241,
148, 128, 55, 131, 173, 97, 98, 201, 68, 82, 244, 223, 70, 86, 161, 5, 0, 0, 0,
0, 0, 0
],
vec![
3, 1, 0, 0, 0, 16, 89, 163, 102, 187, 221, 241, 76, 89, 115, 107, 96, 179, 220,
198, 2, 101, 186, 51, 10, 127, 106, 82, 61, 92, 36, 164, 125, 1, 231, 68, 208,
8, 237, 5, 0, 0, 0, 0, 0, 0
3, 1, 0, 0, 0, 16, 49, 233, 115, 11, 86, 10, 193, 50, 45, 253, 137, 126, 230,
236, 254, 86, 230, 148, 94, 141, 44, 46, 130, 154, 189, 73, 179, 223, 178, 17,
133, 232, 213, 5, 0, 0, 0, 0, 0, 0
]
],
);
Expand Down
3 changes: 0 additions & 3 deletions chain/client/tests/chunks_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ fn store_partial_encoded_chunk_sanity() {
0,
0,
0,
0,
CryptoHash::default(),
CryptoHash::default(),
vec![],
Expand Down Expand Up @@ -339,7 +338,6 @@ fn store_partial_encoded_chunk_sanity() {
0,
0,
0,
0,
CryptoHash::default(),
CryptoHash::default(),
vec![],
Expand Down Expand Up @@ -375,7 +373,6 @@ fn store_partial_encoded_chunk_sanity() {
0,
0,
0,
0,
CryptoHash::default(),
CryptoHash::default(),
vec![],
Expand Down
Loading