From 9bdc06527451f54d2fbdbd9ea6e8904556513928 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Mon, 22 Jun 2020 07:35:22 -0700 Subject: [PATCH 1/6] fix: persist chunk tail (#2875) Garbage collection is slow because we do not persist chunk tail and therefore `clear_chunk_data` iterates from 0 to min_chunk_height every time it is called. Fixes #2806. --- chain/chain/src/store.rs | 46 +++++++++++---------- chain/chain/src/store_validator/validate.rs | 22 ++++++---- chain/client/tests/process_blocks.rs | 1 + 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/chain/chain/src/store.rs b/chain/chain/src/store.rs index b7e8dc2d3dd..b0451409edc 100644 --- a/chain/chain/src/store.rs +++ b/chain/chain/src/store.rs @@ -1870,6 +1870,10 @@ impl<'a> ChainStoreUpdate<'a> { pub fn update_tail(&mut self, height: BlockHeight) { self.tail = Some(height); + if self.chunk_tail.is_none() { + // For consistency, Chunk Tail should be set if Tail is set + self.chunk_tail = Some(self.get_genesis_height()); + } } pub fn update_chunk_tail(&mut self, height: BlockHeight) { @@ -2226,29 +2230,29 @@ impl<'a> ChainStoreUpdate<'a> { self.store_updates.push(store_update); } + fn write_col_misc( + store_update: &mut StoreUpdate, + key: &[u8], + value: &mut Option, + ) -> Result<(), Error> { + if let Some(t) = value.take() { + store_update.set_ser(ColBlockMisc, key, &t)?; + } + Ok(()) + } + fn finalize(&mut self) -> Result { let mut store_update = self.store().store_update(); - if let Some(t) = self.head.take() { - store_update.set_ser(ColBlockMisc, HEAD_KEY, &t).map_err::(|e| e.into())?; - } - if let Some(t) = self.tail.take() { - store_update.set_ser(ColBlockMisc, TAIL_KEY, &t)? - } - if let Some(t) = self.header_head.take() { - store_update - .set_ser(ColBlockMisc, HEADER_HEAD_KEY, &t) - .map_err::(|e| e.into())?; - } - if let Some(t) = self.sync_head.take() { - store_update - .set_ser(ColBlockMisc, SYNC_HEAD_KEY, &t) - .map_err::(|e| e.into())?; - } - if let Some(t) = self.largest_target_height { - store_update - .set_ser(ColBlockMisc, LARGEST_TARGET_HEIGHT_KEY, &t) - .map_err::(|e| e.into())?; - } + Self::write_col_misc(&mut store_update, HEAD_KEY, &mut self.head)?; + Self::write_col_misc(&mut store_update, TAIL_KEY, &mut self.tail)?; + Self::write_col_misc(&mut store_update, CHUNK_TAIL_KEY, &mut self.chunk_tail)?; + Self::write_col_misc(&mut store_update, SYNC_HEAD_KEY, &mut self.sync_head)?; + Self::write_col_misc(&mut store_update, HEADER_HEAD_KEY, &mut self.header_head)?; + Self::write_col_misc( + &mut store_update, + LARGEST_TARGET_HEIGHT_KEY, + &mut self.largest_target_height, + )?; for (hash, block) in self.chain_store_cache_update.blocks.iter() { let mut map = match self.chain_store.get_all_block_hashes_by_height(block.header().height()) { diff --git a/chain/chain/src/store_validator/validate.rs b/chain/chain/src/store_validator/validate.rs index 3efcca336b9..9af8024b162 100644 --- a/chain/chain/src/store_validator/validate.rs +++ b/chain/chain/src/store_validator/validate.rs @@ -111,16 +111,24 @@ macro_rules! unwrap_or_err_db { // All validations start here pub(crate) fn head_tail_validity(sv: &mut StoreValidator) -> Result<(), StoreValidatorError> { - let tail = unwrap_or_err!( + let mut tail = sv.config.genesis_height; + let mut chunk_tail = sv.config.genesis_height; + let tail_db = unwrap_or_err!( sv.store.get_ser::(ColBlockMisc, TAIL_KEY), "Can't get Tail from storage" - ) - .unwrap_or(sv.config.genesis_height); - let chunk_tail = unwrap_or_err!( + ); + let chunk_tail_db = unwrap_or_err!( sv.store.get_ser::(ColBlockMisc, CHUNK_TAIL_KEY), "Can't get Chunk Tail from storage" - ) - .unwrap_or(sv.config.genesis_height); + ); + if tail_db.is_none() && chunk_tail_db.is_some() || tail_db.is_some() && chunk_tail_db.is_none() + { + err!("Tail is {:?} and Chunk Tail is {:?}", tail_db, chunk_tail_db); + } + if tail_db.is_some() && chunk_tail_db.is_some() { + tail = tail_db.unwrap(); + chunk_tail = chunk_tail_db.unwrap(); + } let head = unwrap_or_err_db!( sv.store.get_ser::(ColBlockMisc, HEAD_KEY), "Can't get Head from storage" @@ -256,7 +264,7 @@ pub(crate) fn chunk_tail_validity( check_cached!(sv.inner.is_misc_set, "misc"); let chunk_tail = sv.inner.chunk_tail; let height = shard_chunk.header.inner.height_created; - if height < chunk_tail { + if height != sv.config.genesis_height && height < chunk_tail { err!( "Invalid ShardChunk stored, chunk_tail = {:?}, ShardChunk = {:?}", chunk_tail, diff --git a/chain/client/tests/process_blocks.rs b/chain/client/tests/process_blocks.rs index 892c60b1758..644a9e4592a 100644 --- a/chain/client/tests/process_blocks.rs +++ b/chain/client/tests/process_blocks.rs @@ -788,6 +788,7 @@ fn test_gc_with_epoch_length_common(epoch_length: NumBlocks) { .is_ok()); } } + assert_eq!(env.clients[0].chain.store().chunk_tail().unwrap(), epoch_length - 1); assert!(check_refcount_map(&mut env.clients[0].chain).is_ok()); } From d7a097ce97c01d105c686ad0881eb4ca8ef3d72e Mon Sep 17 00:00:00 2001 From: Marcelo Fornet Date: Mon, 22 Jun 2020 11:09:17 -0400 Subject: [PATCH 2/6] feat(thread): Run PeerManager in separate thread. (#2869) Spawn PeerManagerActor in its own thread since it can run concurrently with other actor in the system without any problem. Test Plan ======= - Check there is no regression --- neard/src/lib.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/neard/src/lib.rs b/neard/src/lib.rs index 24248075bbd..b672e01c428 100644 --- a/neard/src/lib.rs +++ b/neard/src/lib.rs @@ -2,7 +2,7 @@ use std::fs; use std::path::Path; use std::sync::Arc; -use actix::{Actor, Addr}; +use actix::{Actor, Addr, Arbiter}; use log::{error, info}; use tracing::trace; @@ -135,14 +135,15 @@ pub fn start_with_config( config.network_config.verify(); - let network_actor = PeerManagerActor::new( - store, - config.network_config, - client_actor.clone().recipient(), - view_client.clone().recipient(), - ) - .unwrap() - .start(); + let arbiter = Arbiter::new(); + + let client_actor1 = client_actor.clone().recipient(); + let view_client1 = view_client.clone().recipient(); + let network_config = config.network_config; + + let network_actor = PeerManagerActor::start_in_arbiter(&arbiter, move |_ctx| { + PeerManagerActor::new(store, network_config, client_actor1, view_client1).unwrap() + }); network_adapter.set_recipient(network_actor.recipient()); From 66fe422f6741c285ddfc611a1f807fd0dfec8aa2 Mon Sep 17 00:00:00 2001 From: Marcelo Fornet Date: Mon, 22 Jun 2020 11:27:52 -0400 Subject: [PATCH 3/6] refactor: Remove warnings (#2870) Remove warning about unused code because some `uses` were only used behind feature flag `expensive_test`. Test plan ======= - `cargo check --all --tests --benches` pass with no warnings. - `cargo check --all --tests --benches --features expensive_tests` pass with no warnings. --- chain/chain/src/store.rs | 5 +++-- chain/chunks/src/lib.rs | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/chain/chain/src/store.rs b/chain/chain/src/store.rs index b0451409edc..1ea5fe6edb8 100644 --- a/chain/chain/src/store.rs +++ b/chain/chain/src/store.rs @@ -2631,7 +2631,6 @@ mod tests { use cached::Cached; use strum::IntoEnumIterator; - use near_chain_configs::GenesisConfig; use near_crypto::KeyType; use near_primitives::block::{Block, Tip}; use near_primitives::errors::InvalidTxError; @@ -2643,11 +2642,12 @@ mod tests { use crate::chain::check_refcount_map; use crate::store::{ChainStoreAccess, GCMode}; - use crate::store_validator::StoreValidator; use crate::test_utils::KeyValueRuntime; use crate::{Chain, ChainGenesis, DoomslugThresholdMode}; use near_store::DBCol; + #[cfg(feature = "expensive_tests")] + use {crate::store_validator::StoreValidator, near_chain_configs::GenesisConfig}; fn get_chain() -> Chain { get_chain_with_epoch_length(10) @@ -3016,6 +3016,7 @@ mod tests { test_clear_old_data_too_many_heights_common(87); } + #[cfg(feature = "expensive_tests")] fn test_clear_old_data_too_many_heights_common(gc_blocks_limit: NumBlocks) { let mut chain = get_chain_with_epoch_length(1); let genesis = chain.get_block_by_height(0).unwrap().clone(); diff --git a/chain/chunks/src/lib.rs b/chain/chunks/src/lib.rs index 27686d96ffe..43db61d0963 100644 --- a/chain/chunks/src/lib.rs +++ b/chain/chunks/src/lib.rs @@ -1412,22 +1412,26 @@ impl ShardsManager { mod test { use crate::test_utils::SealsManagerTestFixture; use crate::{ - ChunkRequestInfo, Seal, SealsManager, ShardsManager, ACCEPTING_SEAL_PERIOD_MS, - CHUNK_REQUEST_RETRY_MS, NUM_PARTS_REQUESTED_IN_SEAL, PAST_SEAL_HEIGHT_HORIZON, + ChunkRequestInfo, Seal, SealsManager, ShardsManager, CHUNK_REQUEST_RETRY_MS, + NUM_PARTS_REQUESTED_IN_SEAL, PAST_SEAL_HEIGHT_HORIZON, }; use near_chain::test_utils::KeyValueRuntime; - use near_chain::{ChainStore, RuntimeAdapter}; - use near_crypto::KeyType; - use near_logger_utils::init_test_logger; use near_network::test_utils::MockNetworkAdapter; - use near_primitives::hash::{hash, CryptoHash}; - use near_primitives::merkle::merklize; - use near_primitives::sharding::{ChunkHash, ReedSolomonWrapper}; - use near_primitives::validator_signer::InMemoryValidatorSigner; + use near_primitives::hash::hash; + use near_primitives::sharding::ChunkHash; use near_store::test_utils::create_test_store; use std::sync::Arc; use std::time::{Duration, Instant}; + #[cfg(feature = "expensive_tests")] + use { + crate::ACCEPTING_SEAL_PERIOD_MS, near_chain::ChainStore, near_chain::RuntimeAdapter, + near_crypto::KeyType, near_logger_utils::init_test_logger, + near_primitives::hash::CryptoHash, near_primitives::merkle::merklize, + near_primitives::sharding::ReedSolomonWrapper, + near_primitives::validator_signer::InMemoryValidatorSigner, + }; + /// should not request partial encoded chunk from self #[test] fn test_request_partial_encoded_chunk_from_self() { From 97e0143c181e143b2987430365fbf020390384a9 Mon Sep 17 00:00:00 2001 From: Alex Kouprin Date: Mon, 22 Jun 2020 18:49:55 +0300 Subject: [PATCH 4/6] fix(catchup tests): increasing block_prod_time (#2871) Fixes #2866. According to https://github.com/nearprotocol/nearcore/issues/2866#issuecomment-646727726, it should be enough to increase `block_prod_time`. The issue of incorrect [PASSED] test marks in Nightly should be resolved separately. --- chain/client/tests/catching_up.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chain/client/tests/catching_up.rs b/chain/client/tests/catching_up.rs index 10b42c5be92..51c05629517 100644 --- a/chain/client/tests/catching_up.rs +++ b/chain/client/tests/catching_up.rs @@ -437,7 +437,7 @@ mod tests { key_pairs.clone(), validator_groups, true, - 1800, + 3500, false, false, 5, @@ -600,7 +600,7 @@ mod tests { ); *connectors.write().unwrap() = conn; - near_network::test_utils::wait_or_panic(240000); + near_network::test_utils::wait_or_panic(480000); }) .unwrap(); } From 5148a0d5a18aa3c74817318bc0a17284f17c2876 Mon Sep 17 00:00:00 2001 From: Evgeny Kuzyakov Date: Mon, 22 Jun 2020 09:43:01 -0700 Subject: [PATCH 5/6] feat(RPC): Add burnt amount to ExecutionOutcome (#2872) Because of the variable gas pricing during the execution the `gas_burnt` is not enough anymore to determine the amount of fees that was used for the given transaction execution. We need to expose the `tokens_burnt` which returns the actual amount that was used for the TX/receipt execution fees. Bumping protocol version, because it changes the spec. # Test plan: - CI --- chain/chain/src/test_utils.rs | 1 + chain/chain/src/types.rs | 2 ++ core/primitives/src/transaction.rs | 14 ++++++++++++-- core/primitives/src/version.rs | 2 +- core/primitives/src/views.rs | 6 ++++++ neard/res/genesis_config.json | 2 +- neard/tests/rpc_nodes.rs | 2 +- ...pc_light_client_execution_outcome_proof.py | 4 +++- pytest/tests/sanity/rpc_state_changes.py | 4 ++-- runtime/runtime/src/lib.rs | 5 +++++ ...7-add-amount-burnt-to-execution-outcome.py | 19 +++++++++++++++++++ 11 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 scripts/migrations/27-add-amount-burnt-to-execution-outcome.py diff --git a/chain/chain/src/test_utils.rs b/chain/chain/src/test_utils.rs index 65b18792291..b228dcc5380 100644 --- a/chain/chain/src/test_utils.rs +++ b/chain/chain/src/test_utils.rs @@ -629,6 +629,7 @@ impl RuntimeAdapter for KeyValueRuntime { logs: vec![], receipt_ids: new_receipt_hashes, gas_burnt: 0, + tokens_burnt: 0, }, }); } diff --git a/chain/chain/src/types.rs b/chain/chain/src/types.rs index 4cd393830d3..3bd91cae367 100644 --- a/chain/chain/src/types.rs +++ b/chain/chain/src/types.rs @@ -580,6 +580,7 @@ mod tests { logs: vec!["outcome1".to_string()], receipt_ids: vec![hash(&[1])], gas_burnt: 100, + tokens_burnt: 10000, }, }; let outcome2 = ExecutionOutcomeWithId { @@ -589,6 +590,7 @@ mod tests { logs: vec!["outcome2".to_string()], receipt_ids: vec![], gas_burnt: 0, + tokens_burnt: 0, }, }; let outcomes = vec![outcome1, outcome2]; diff --git a/core/primitives/src/transaction.rs b/core/primitives/src/transaction.rs index d44499d12c6..effa75b04ef 100644 --- a/core/primitives/src/transaction.rs +++ b/core/primitives/src/transaction.rs @@ -12,7 +12,7 @@ use crate::errors::TxExecutionError; use crate::hash::{hash, CryptoHash}; use crate::logging; use crate::merkle::MerklePath; -use crate::serialize::{base64_format, u128_dec_format_compatible}; +use crate::serialize::{base64_format, u128_dec_format, u128_dec_format_compatible}; use crate::types::{AccountId, Balance, Gas, Nonce}; pub type LogEntry = String; @@ -233,6 +233,8 @@ impl Default for ExecutionStatus { struct PartialExecutionOutcome { pub receipt_ids: Vec, pub gas_burnt: Gas, + #[serde(with = "u128_dec_format")] + pub tokens_burnt: Balance, pub status: PartialExecutionStatus, } @@ -265,8 +267,13 @@ pub struct ExecutionOutcome { pub receipt_ids: Vec, /// The amount of the gas burnt by the given transaction or receipt. pub gas_burnt: Gas, + /// The amount of tokens burnt corresponding to the burnt gas amount. + /// This value doesn't always equal to the `gas_burnt` multiplied by the gas price, because + /// the prepaid gas price might be lower than the actual gas price and it creates a deficit. + pub tokens_burnt: Balance, /// Execution status. Contains the result in case of successful execution. - /// Should be the latest field since contains unparsable by light client ExecutionStatus::Failure + /// NOTE: Should be the latest field since it contains unparsable by light client + /// ExecutionStatus::Failure pub status: ExecutionStatus, } @@ -276,6 +283,7 @@ impl ExecutionOutcome { &PartialExecutionOutcome { receipt_ids: self.receipt_ids.clone(), gas_burnt: self.gas_burnt, + tokens_burnt: self.tokens_burnt, status: self.status.clone().into(), } .try_to_vec() @@ -294,6 +302,7 @@ impl fmt::Debug for ExecutionOutcome { .field("logs", &format_args!("{}", logging::pretty_vec(&self.logs))) .field("receipt_ids", &format_args!("{}", logging::pretty_vec(&self.receipt_ids))) .field("burnt_gas", &self.gas_burnt) + .field("tokens_burnt", &self.tokens_burnt) .field("status", &self.status) .finish() } @@ -434,6 +443,7 @@ mod tests { logs: vec!["123".to_string(), "321".to_string()], receipt_ids: vec![], gas_burnt: 123, + tokens_burnt: 1234000, }; let hashes = outcome.to_hashes(); assert_eq!(hashes.len(), 3); diff --git a/core/primitives/src/version.rs b/core/primitives/src/version.rs index 213928a281d..7ef58e70a15 100644 --- a/core/primitives/src/version.rs +++ b/core/primitives/src/version.rs @@ -17,6 +17,6 @@ pub const DB_VERSION: DbVersion = 2; pub type ProtocolVersion = u32; /// Current latest version of the protocol. -pub const PROTOCOL_VERSION: ProtocolVersion = 26; +pub const PROTOCOL_VERSION: ProtocolVersion = 27; pub const FIRST_BACKWARD_COMPATIBLE_PROTOCOL_VERSION: ProtocolVersion = PROTOCOL_VERSION; diff --git a/core/primitives/src/views.rs b/core/primitives/src/views.rs index 037534b78b8..66812ea8e5e 100644 --- a/core/primitives/src/views.rs +++ b/core/primitives/src/views.rs @@ -800,6 +800,11 @@ pub struct ExecutionOutcomeView { pub receipt_ids: Vec, /// The amount of the gas burnt by the given transaction or receipt. pub gas_burnt: Gas, + /// The amount of tokens burnt corresponding to the burnt gas amount. + /// This value doesn't always equal to the `gas_burnt` multiplied by the gas price, because + /// the prepaid gas price might be lower than the actual gas price and it creates a deficit. + #[serde(with = "u128_dec_format")] + pub tokens_burnt: Balance, /// Execution status. Contains the result in case of successful execution. pub status: ExecutionStatusView, } @@ -810,6 +815,7 @@ impl From for ExecutionOutcomeView { logs: outcome.logs, receipt_ids: outcome.receipt_ids, gas_burnt: outcome.gas_burnt, + tokens_burnt: outcome.tokens_burnt, status: outcome.status.into(), } } diff --git a/neard/res/genesis_config.json b/neard/res/genesis_config.json index d736759b72c..b0c5406937a 100644 --- a/neard/res/genesis_config.json +++ b/neard/res/genesis_config.json @@ -1,5 +1,5 @@ { - "protocol_version": 26, + "protocol_version": 27, "genesis_time": "1970-01-01T00:00:00.000000000Z", "chain_id": "sample", "genesis_height": 0, diff --git a/neard/tests/rpc_nodes.rs b/neard/tests/rpc_nodes.rs index 5cce64727a7..b29d0e23c44 100644 --- a/neard/tests/rpc_nodes.rs +++ b/neard/tests/rpc_nodes.rs @@ -465,7 +465,7 @@ fn outcome_view_to_hashes(outcome: &ExecutionOutcomeView) -> Vec { ExecutionStatusView::SuccessReceiptId(id) => PartialExecutionStatus::SuccessReceiptId(*id), }; let mut result = vec![hash( - &(outcome.receipt_ids.clone(), outcome.gas_burnt, status) + &(outcome.receipt_ids.clone(), outcome.gas_burnt, outcome.tokens_burnt, status) .try_to_vec() .expect("Failed to serialize"), )]; diff --git a/pytest/tests/sanity/rpc_light_client_execution_outcome_proof.py b/pytest/tests/sanity/rpc_light_client_execution_outcome_proof.py index 0130aa5982e..673e78a60d0 100644 --- a/pytest/tests/sanity/rpc_light_client_execution_outcome_proof.py +++ b/pytest/tests/sanity/rpc_light_client_execution_outcome_proof.py @@ -41,6 +41,7 @@ class Failure: 'fields': [ ['receipt_ids', [[32]]], ['gas_burnt', 'u64'], + ['tokens_burnt', 'u128'], ['status', PartialExecutionStatus], ] }, @@ -76,6 +77,7 @@ def serialize_execution_outcome_with_id(outcome, id): partial_outcome = PartialExecutionOutcome() partial_outcome.receipt_ids = [base58.b58decode(x) for x in outcome['receipt_ids']] partial_outcome.gas_burnt = outcome['gas_burnt'] + partial_outcome.tokens_burnt = int(outcome['tokens_burnt']) execution_status = PartialExecutionStatus() if 'SuccessValue' in outcome['status']: execution_status.enum = 'successValue' @@ -131,7 +133,7 @@ def check_transaction_outcome_proof(should_succeed, nonce): status = nodes[1].get_status() latest_block_hash = status['sync_info']['latest_block_hash'] function_caller_key = nodes[0].signer_key - gas = 10000000000000000 if should_succeed else 1000 + gas = 300000000000000 if should_succeed else 1000 function_call_1_tx = transaction.sign_function_call_tx( function_caller_key, contract_key.account_id, 'setKeyValue', diff --git a/pytest/tests/sanity/rpc_state_changes.py b/pytest/tests/sanity/rpc_state_changes.py index 856abf67e83..48aba91a38d 100644 --- a/pytest/tests/sanity/rpc_state_changes.py +++ b/pytest/tests/sanity/rpc_state_changes.py @@ -430,7 +430,7 @@ def set_value_1(): json.dumps({ "key": "my_key", "value": "my_value_1" - }).encode('utf-8'), 10000000000000000, 100000000000, 20, + }).encode('utf-8'), 300000000000000, 100000000000, 20, base58.b58decode(latest_block_hash.encode('utf8'))) nodes[1].send_tx_and_wait(function_call_1_tx, 10) @@ -442,7 +442,7 @@ def set_value_1(): json.dumps({ "key": "my_key", "value": "my_value_2" - }).encode('utf-8'), 10000000000000000, 100000000000, 30, + }).encode('utf-8'), 300000000000000, 100000000000, 30, base58.b58decode(latest_block_hash.encode('utf8'))) function_call_2_response = nodes[1].send_tx_and_wait(function_call_2_tx, 10) assert function_call_2_response['result']['receipts_outcome'][0]['outcome']['status'] == {'SuccessValue': ''}, \ diff --git a/runtime/runtime/src/lib.rs b/runtime/runtime/src/lib.rs index 677fc745529..a0b71ece81c 100644 --- a/runtime/runtime/src/lib.rs +++ b/runtime/runtime/src/lib.rs @@ -259,6 +259,7 @@ impl Runtime { logs: vec![], receipt_ids: vec![receipt.receipt_id], gas_burnt: verification_result.gas_burnt, + tokens_burnt: verification_result.burnt_amount, }, }; Ok((receipt, outcome)) @@ -549,6 +550,9 @@ impl Runtime { // `gas_deficit_amount` is strictly less than `gas_price * gas_burnt`. let mut tx_burnt_amount = safe_gas_to_balance(apply_state.gas_price, result.gas_burnt)? - gas_deficit_amount; + // The amount of tokens burnt for the execution of this receipt. It's used in the execution + // outcome. + let tokens_burnt = tx_burnt_amount; // Adding burnt gas reward for function calls if the account exists. let receiver_gas_reward = result.gas_burnt_for_function_call @@ -655,6 +659,7 @@ impl Runtime { logs: result.logs, receipt_ids, gas_burnt: result.gas_burnt, + tokens_burnt, }, }) } diff --git a/scripts/migrations/27-add-amount-burnt-to-execution-outcome.py b/scripts/migrations/27-add-amount-burnt-to-execution-outcome.py new file mode 100644 index 00000000000..473a1b0fa08 --- /dev/null +++ b/scripts/migrations/27-add-amount-burnt-to-execution-outcome.py @@ -0,0 +1,19 @@ +""" +Adding `burnt_amount` to `ExecutionOutcome`, `PartialExecutionOutcome`, `FinalExecutionOutcome` and views. +""" + +import sys +import os +import json +from collections import OrderedDict + +home = sys.argv[1] +output_home = sys.argv[2] + +config = json.load(open(os.path.join(home, 'output.json')), object_pairs_hook=OrderedDict) + +assert config['protocol_version'] == 26 + +config['protocol_version'] = 27 + +json.dump(config, open(os.path.join(output_home, 'output.json'), 'w'), indent=2) From 045be6fe861149acb75540dfdb9496f074074f45 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Mon, 22 Jun 2020 16:17:53 -0700 Subject: [PATCH 6/6] Fix(test): fix path error in backward compatible (#2879) backward compatible was failing because binary not build Test Plan --------- backward compatible test should pass. Note, backward_compatible with beta currently still fails, because it's not backward compatible, backward_compatible with master is passing as expected --- pytest/tests/sanity/backward_compatible.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pytest/tests/sanity/backward_compatible.py b/pytest/tests/sanity/backward_compatible.py index b7175087294..a717d73ac8f 100755 --- a/pytest/tests/sanity/backward_compatible.py +++ b/pytest/tests/sanity/backward_compatible.py @@ -22,9 +22,8 @@ def main(): shutil.rmtree(node_root) subprocess.check_output('mkdir -p /tmp/near', shell=True) - # near_root, (stable_branch, - # current_branch) = branches.prepare_ab_test("beta") - (near_root, (stable_branch, current_branch)) = ('../target/debug', ('beta', 'upgradability')) + near_root, (stable_branch, + current_branch) = branches.prepare_ab_test("beta") # Setup local network. subprocess.call([