From 9d7aaf5969694ce8229f5cc47e17b29501defe0e Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Fri, 24 Jul 2020 17:03:37 -0700 Subject: [PATCH] feat: update gas price (#3028) Update gas price to 1_000_000_000 according to https://github.com/nearprotocol/NEPs/issues/92. Test plan --------- * `upgradable.py` with transactions. * spin up a node with this change and verify that it can sync to testnet and process blocks without any issue. --- chain/chain/src/chain.rs | 109 ++++-------------------------- chain/chain/src/lib.rs | 6 +- chain/chain/src/test_utils.rs | 54 +++++++-------- chain/chain/src/types.rs | 90 +++++++++++++++++++++++- chain/chain/tests/gc.rs | 4 +- chain/client/src/client.rs | 9 +-- chain/client/src/test_utils.rs | 22 +++--- chain/client/tests/challenges.rs | 13 ++-- chain/network/tests/runner/mod.rs | 26 +++---- core/primitives/src/block.rs | 2 +- core/primitives/src/version.rs | 7 +- neard/res/genesis_config.json | 4 +- neard/src/config.rs | 2 +- pytest/tests/sanity/upgradable.py | 21 +++++- 14 files changed, 197 insertions(+), 172 deletions(-) diff --git a/chain/chain/src/chain.rs b/chain/chain/src/chain.rs index 2927b7b5477..43d24a0b474 100644 --- a/chain/chain/src/chain.rs +++ b/chain/chain/src/chain.rs @@ -3,15 +3,13 @@ use std::sync::Arc; use std::time::{Duration as TimeDuration, Instant}; use borsh::BorshSerialize; -use chrono::prelude::{DateTime, Utc}; use chrono::Duration; +use chrono::Utc; use log::{debug, error, info}; -use num_rational::Rational; use rand::rngs::StdRng; use rand::seq::SliceRandom; use rand::SeedableRng; -use near_chain_configs::GenesisConfig; use near_primitives::block::{genesis_chunks, Tip}; use near_primitives::challenge::{ BlockDoubleSign, Challenge, ChallengeBody, ChallengesResult, ChunkProofs, ChunkState, @@ -32,11 +30,10 @@ use near_primitives::syncing::{ }; use near_primitives::transaction::ExecutionOutcomeWithIdAndProof; use near_primitives::types::{ - AccountId, Balance, BlockExtra, BlockHeight, BlockHeightDelta, ChunkExtra, EpochId, Gas, - MerkleHash, NumBlocks, ShardId, ValidatorStake, + AccountId, Balance, BlockExtra, BlockHeight, BlockHeightDelta, ChunkExtra, EpochId, MerkleHash, + NumBlocks, ShardId, ValidatorStake, }; use near_primitives::unwrap_or_return; -use near_primitives::version::ProtocolVersion; use near_primitives::views::{ ExecutionOutcomeWithIdView, ExecutionStatusView, FinalExecutionOutcomeView, FinalExecutionStatus, LightClientBlockView, @@ -47,8 +44,9 @@ use crate::error::{Error, ErrorKind, LogTransientStorageError}; use crate::lightclient::get_epoch_block_producers_view; use crate::store::{ChainStore, ChainStoreAccess, ChainStoreUpdate, GCMode}; use crate::types::{ - AcceptedBlock, ApplyTransactionResult, Block, BlockHeader, BlockHeaderInfo, BlockStatus, - BlockSyncResponse, Provenance, ReceiptList, RuntimeAdapter, + AcceptedBlock, ApplyTransactionResult, Block, BlockEconomicsConfig, BlockHeader, + BlockHeaderInfo, BlockStatus, BlockSyncResponse, ChainGenesis, Provenance, ReceiptList, + RuntimeAdapter, }; use crate::validate::{ validate_challenge, validate_chunk_proofs, validate_chunk_with_chunk_extra, @@ -75,13 +73,6 @@ const NEAR_BASE: Balance = 1_000_000_000_000_000_000_000_000; /// Number of epochs for which we keep store data pub const NUM_EPOCHS_TO_KEEP_STORE_DATA: u64 = 5; -/// Block economics config taken from genesis config -pub struct BlockEconomicsConfig { - pub gas_price_adjustment_rate: Rational, - pub min_gas_price: Balance, - pub max_gas_price: Balance, -} - enum ApplyChunksMode { ThisEpoch, NextEpoch, @@ -176,74 +167,6 @@ impl OrphanBlockPool { } } -/// Chain genesis configuration. -#[derive(Clone)] -pub struct ChainGenesis { - pub time: DateTime, - pub height: BlockHeight, - pub gas_limit: Gas, - pub min_gas_price: Balance, - pub max_gas_price: Balance, - pub total_supply: Balance, - pub max_inflation_rate: Rational, - pub gas_price_adjustment_rate: Rational, - pub transaction_validity_period: NumBlocks, - pub epoch_length: BlockHeightDelta, - pub protocol_version: ProtocolVersion, -} - -impl ChainGenesis { - pub fn new( - time: DateTime, - height: BlockHeight, - gas_limit: Gas, - min_gas_price: Balance, - max_gas_price: Balance, - total_supply: Balance, - max_inflation_rate: Rational, - gas_price_adjustment_rate: Rational, - transaction_validity_period: NumBlocks, - epoch_length: BlockHeightDelta, - protocol_version: ProtocolVersion, - ) -> Self { - Self { - time, - height, - gas_limit, - min_gas_price, - max_gas_price, - total_supply, - max_inflation_rate, - gas_price_adjustment_rate, - transaction_validity_period, - epoch_length, - protocol_version, - } - } -} - -impl From for ChainGenesis -where - T: AsRef, -{ - fn from(genesis_config: T) -> Self { - let genesis_config = genesis_config.as_ref(); - ChainGenesis::new( - genesis_config.genesis_time, - genesis_config.genesis_height, - genesis_config.gas_limit, - genesis_config.min_gas_price, - genesis_config.max_gas_price, - genesis_config.total_supply, - genesis_config.max_inflation_rate, - genesis_config.gas_price_adjustment_rate, - genesis_config.transaction_validity_period, - genesis_config.epoch_length, - genesis_config.protocol_version, - ) - } -} - /// Facade to the blockchain block processing and storage. /// Provides current view on the state according to the chain state. pub struct Chain { @@ -290,11 +213,7 @@ impl Chain { genesis: genesis.header().clone(), transaction_validity_period: chain_genesis.transaction_validity_period, epoch_length: chain_genesis.epoch_length, - block_economics_config: BlockEconomicsConfig { - gas_price_adjustment_rate: chain_genesis.gas_price_adjustment_rate, - min_gas_price: chain_genesis.min_gas_price, - max_gas_price: chain_genesis.max_gas_price, - }, + block_economics_config: BlockEconomicsConfig::from(chain_genesis), doomslug_threshold_mode, }) } @@ -411,11 +330,7 @@ impl Chain { genesis: genesis.header().clone(), transaction_validity_period: chain_genesis.transaction_validity_period, epoch_length: chain_genesis.epoch_length, - block_economics_config: BlockEconomicsConfig { - gas_price_adjustment_rate: chain_genesis.gas_price_adjustment_rate, - min_gas_price: chain_genesis.min_gas_price, - max_gas_price: chain_genesis.max_gas_price, - }, + block_economics_config: BlockEconomicsConfig::from(chain_genesis), doomslug_threshold_mode, }) } @@ -2976,11 +2891,13 @@ impl<'a> ChainUpdate<'a> { return Err(ErrorKind::Other("Invalid block".into()).into()); } + let protocol_version = + self.runtime_adapter.get_epoch_protocol_version(&block.header().epoch_id())?; if !block.verify_gas_price( prev_gas_price, - self.block_economics_config.min_gas_price, - self.block_economics_config.max_gas_price, - self.block_economics_config.gas_price_adjustment_rate, + self.block_economics_config.min_gas_price(protocol_version), + self.block_economics_config.max_gas_price(protocol_version), + self.block_economics_config.gas_price_adjustment_rate(protocol_version), ) { byzantine_assert!(false); return Err(ErrorKind::InvalidGasPrice.into()); diff --git a/chain/chain/src/lib.rs b/chain/chain/src/lib.rs index a557667440b..6f7f4283d2f 100644 --- a/chain/chain/src/lib.rs +++ b/chain/chain/src/lib.rs @@ -1,13 +1,15 @@ #[macro_use] extern crate lazy_static; -pub use chain::{collect_receipts, Chain, ChainGenesis, MAX_ORPHAN_SIZE}; +pub use chain::{collect_receipts, Chain, MAX_ORPHAN_SIZE}; pub use doomslug::{Doomslug, DoomslugBlockProductionReadiness, DoomslugThresholdMode}; pub use error::{Error, ErrorKind}; pub use lightclient::create_light_client_block_view; pub use store::{ChainStore, ChainStoreAccess, ChainStoreUpdate}; pub use store_validator::{ErrorMessage, StoreValidator}; -pub use types::{Block, BlockHeader, BlockStatus, Provenance, ReceiptResult, RuntimeAdapter}; +pub use types::{ + Block, BlockHeader, BlockStatus, ChainGenesis, Provenance, ReceiptResult, RuntimeAdapter, +}; pub mod chain; mod doomslug; diff --git a/chain/chain/src/test_utils.rs b/chain/chain/src/test_utils.rs index 500f32906fc..eba133aeb8e 100644 --- a/chain/chain/src/test_utils.rs +++ b/chain/chain/src/test_utils.rs @@ -38,10 +38,10 @@ use near_store::{ WrappedTrieChanges, }; -use crate::chain::{Chain, ChainGenesis, NUM_EPOCHS_TO_KEEP_STORE_DATA}; +use crate::chain::{Chain, NUM_EPOCHS_TO_KEEP_STORE_DATA}; use crate::error::{Error, ErrorKind}; use crate::store::ChainStoreAccess; -use crate::types::{ApplyTransactionResult, BlockHeaderInfo}; +use crate::types::{ApplyTransactionResult, BlockHeaderInfo, ChainGenesis}; use crate::{BlockHeader, DoomslugThresholdMode, RuntimeAdapter}; #[derive( @@ -957,19 +957,19 @@ pub fn setup_with_tx_validity_period( let runtime = Arc::new(KeyValueRuntime::new(store)); let chain = Chain::new( runtime.clone(), - &ChainGenesis::new( - Utc::now(), - 0, - 1_000_000, - 100, - 1_000_000_000, - 1_000_000_000, - Rational::from_integer(0), - Rational::from_integer(0), - tx_validity_period, - 10, - PROTOCOL_VERSION, - ), + &ChainGenesis { + time: Utc::now(), + height: 0, + gas_limit: 1_000_000, + min_gas_price: 100, + max_gas_price: 1_000_000_000, + total_supply: 1_000_000_000, + max_inflation_rate: Rational::from_integer(0), + gas_price_adjustment_rate: Rational::from_integer(0), + transaction_validity_period: tx_validity_period, + epoch_length: 10, + protocol_version: PROTOCOL_VERSION, + }, DoomslugThresholdMode::NoApprovals, ) .unwrap(); @@ -998,19 +998,19 @@ pub fn setup_with_validators( )); let chain = Chain::new( runtime.clone(), - &ChainGenesis::new( - Utc::now(), - 0, - 1_000_000, - 100, - 1_000_000_000, - 1_000_000_000, - Rational::from_integer(0), - Rational::from_integer(0), - tx_validity_period, + &ChainGenesis { + time: Utc::now(), + height: 0, + gas_limit: 1_000_000, + min_gas_price: 100, + max_gas_price: 1_000_000_000, + total_supply: 1_000_000_000, + max_inflation_rate: Rational::from_integer(0), + gas_price_adjustment_rate: Rational::from_integer(0), + transaction_validity_period: tx_validity_period, epoch_length, - PROTOCOL_VERSION, - ), + protocol_version: PROTOCOL_VERSION, + }, DoomslugThresholdMode::NoApprovals, ) .unwrap(); diff --git a/chain/chain/src/types.rs b/chain/chain/src/types.rs index ceae518c68f..aaaa1e71964 100644 --- a/chain/chain/src/types.rs +++ b/chain/chain/src/types.rs @@ -16,14 +16,19 @@ use near_primitives::receipt::Receipt; use near_primitives::sharding::ShardChunkHeader; use near_primitives::transaction::{ExecutionOutcomeWithId, SignedTransaction}; use near_primitives::types::{ - AccountId, ApprovalStake, Balance, BlockHeight, EpochId, Gas, MerkleHash, ShardId, StateRoot, - StateRootNode, ValidatorStake, + AccountId, ApprovalStake, Balance, BlockHeight, BlockHeightDelta, EpochId, Gas, MerkleHash, + NumBlocks, ShardId, StateRoot, StateRootNode, ValidatorStake, +}; +use near_primitives::version::{ + ProtocolVersion, MIN_GAS_PRICE_NEP_92, MIN_PROTOCOL_VERSION_NEP_92, }; -use near_primitives::version::ProtocolVersion; use near_primitives::views::{EpochValidatorInfo, QueryRequest, QueryResponse}; use near_store::{PartialStorage, ShardTries, Store, StoreUpdate, Trie, WrappedTrieChanges}; use crate::error::Error; +use chrono::{DateTime, Utc}; +use near_chain_configs::GenesisConfig; +use num_rational::Rational; #[derive(Eq, PartialEq, Debug, Clone)] pub enum BlockStatus { @@ -127,6 +132,85 @@ impl BlockHeaderInfo { } } +/// Block economics config taken from genesis config +pub struct BlockEconomicsConfig { + gas_price_adjustment_rate: Rational, + min_gas_price: Balance, + max_gas_price: Balance, + genesis_protocol_version: ProtocolVersion, +} + +impl BlockEconomicsConfig { + /// Compute min gas price according to protocol version and chain id. We only upgrade gas price + /// for betanet, testnet and mainnet. + pub fn min_gas_price(&self, protocol_version: ProtocolVersion) -> Balance { + if self.genesis_protocol_version < MIN_PROTOCOL_VERSION_NEP_92 + && protocol_version >= MIN_PROTOCOL_VERSION_NEP_92 + { + MIN_GAS_PRICE_NEP_92 + } else { + self.min_gas_price + } + } + + pub fn max_gas_price(&self, _protocol_version: ProtocolVersion) -> Balance { + self.max_gas_price + } + + pub fn gas_price_adjustment_rate(&self, _protocol_version: ProtocolVersion) -> Rational { + self.gas_price_adjustment_rate + } +} + +impl From<&ChainGenesis> for BlockEconomicsConfig { + fn from(chain_genesis: &ChainGenesis) -> Self { + BlockEconomicsConfig { + gas_price_adjustment_rate: chain_genesis.gas_price_adjustment_rate, + min_gas_price: chain_genesis.min_gas_price, + max_gas_price: chain_genesis.max_gas_price, + genesis_protocol_version: chain_genesis.protocol_version, + } + } +} + +/// Chain genesis configuration. +#[derive(Clone)] +pub struct ChainGenesis { + pub time: DateTime, + pub height: BlockHeight, + pub gas_limit: Gas, + pub min_gas_price: Balance, + pub max_gas_price: Balance, + pub total_supply: Balance, + pub max_inflation_rate: Rational, + pub gas_price_adjustment_rate: Rational, + pub transaction_validity_period: NumBlocks, + pub epoch_length: BlockHeightDelta, + pub protocol_version: ProtocolVersion, +} + +impl From for ChainGenesis +where + T: AsRef, +{ + fn from(genesis_config: T) -> Self { + let genesis_config = genesis_config.as_ref(); + Self { + time: genesis_config.genesis_time, + height: genesis_config.genesis_height, + gas_limit: genesis_config.gas_limit, + min_gas_price: genesis_config.min_gas_price, + max_gas_price: genesis_config.max_gas_price, + total_supply: genesis_config.total_supply, + max_inflation_rate: genesis_config.max_inflation_rate, + gas_price_adjustment_rate: genesis_config.gas_price_adjustment_rate, + transaction_validity_period: genesis_config.transaction_validity_period, + epoch_length: genesis_config.epoch_length, + protocol_version: genesis_config.protocol_version, + } + } +} + /// Bridge between the chain and the runtime. /// Main function is to update state given transactions. /// Additionally handles validators. diff --git a/chain/chain/tests/gc.rs b/chain/chain/tests/gc.rs index 7c74ecc76f7..eeab1a4eab7 100644 --- a/chain/chain/tests/gc.rs +++ b/chain/chain/tests/gc.rs @@ -2,9 +2,9 @@ mod tests { use std::sync::Arc; - use near_chain::chain::{Chain, ChainGenesis}; + use near_chain::chain::Chain; use near_chain::test_utils::KeyValueRuntime; - use near_chain::types::Tip; + use near_chain::types::{ChainGenesis, Tip}; use near_chain::DoomslugThresholdMode; use near_crypto::KeyType; use near_primitives::block::Block; diff --git a/chain/client/src/client.rs b/chain/client/src/client.rs index 774af665c9d..d7688f20180 100644 --- a/chain/client/src/client.rs +++ b/chain/client/src/client.rs @@ -354,9 +354,11 @@ impl Client { .get_next_epoch_id_from_prev_block(&head.last_block_hash) .expect("Epoch hash should exist at this point"); - let gas_price_adjustment_rate = self.chain.block_economics_config.gas_price_adjustment_rate; - let min_gas_price = self.chain.block_economics_config.min_gas_price; - let max_gas_price = self.chain.block_economics_config.max_gas_price; + let protocol_version = self.runtime_adapter.get_epoch_protocol_version(&epoch_id)?; + let gas_price_adjustment_rate = + self.chain.block_economics_config.gas_price_adjustment_rate(protocol_version); + let min_gas_price = self.chain.block_economics_config.min_gas_price(protocol_version); + let max_gas_price = self.chain.block_economics_config.max_gas_price(protocol_version); let next_bp_hash = if prev_epoch_id != epoch_id { Chain::compute_bp_hash(&*self.runtime_adapter, next_epoch_id.clone(), &prev_hash)? @@ -394,7 +396,6 @@ impl Client { // Get all the current challenges. // TODO(2445): Enable challenges when they are working correctly. // let challenges = self.challenges.drain().map(|(_, challenge)| challenge).collect(); - let protocol_version = self.runtime_adapter.get_epoch_protocol_version(&next_epoch_id)?; let block = Block::produce( diff --git a/chain/client/src/test_utils.rs b/chain/client/src/test_utils.rs index fe10a366255..0d0e362be27 100644 --- a/chain/client/src/test_utils.rs +++ b/chain/client/src/test_utils.rs @@ -68,19 +68,19 @@ pub fn setup( num_shards, epoch_length, )); - let chain_genesis = ChainGenesis::new( - genesis_time, - 0, - 1_000_000, - 100, - 1_000_000_000, - 3_000_000_000_000_000_000_000_000_000_000_000, - Rational::from_integer(0), - Rational::from_integer(0), + let chain_genesis = ChainGenesis { + time: genesis_time, + height: 0, + gas_limit: 1_000_000, + min_gas_price: 100, + max_gas_price: 1_000_000_000, + total_supply: 3_000_000_000_000_000_000_000_000_000_000_000, + max_inflation_rate: Rational::from_integer(0), + gas_price_adjustment_rate: Rational::from_integer(0), transaction_validity_period, epoch_length, - PROTOCOL_VERSION, - ); + protocol_version: PROTOCOL_VERSION, + }; let doomslug_threshold_mode = if enable_doomslug { DoomslugThresholdMode::TwoThirds } else { diff --git a/chain/client/tests/challenges.rs b/chain/client/tests/challenges.rs index 92c25fb30b8..b65165ed88c 100644 --- a/chain/client/tests/challenges.rs +++ b/chain/client/tests/challenges.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use borsh::BorshSerialize; -use near_chain::chain::BlockEconomicsConfig; +use near_chain::types::BlockEconomicsConfig; use near_chain::validate::validate_challenge; use near_chain::{ Block, ChainGenesis, ChainStoreAccess, DoomslugThresholdMode, Error, ErrorKind, Provenance, @@ -365,11 +365,11 @@ fn challenge( #[test] fn test_verify_chunk_invalid_state_challenge() { let store1 = create_test_store(); - let genesis = Genesis::test(vec!["test0", "test1"], 1); + let genesis = Arc::new(Genesis::test(vec!["test0", "test1"], 1)); let runtimes: Vec> = vec![Arc::new(neard::NightshadeRuntime::new( Path::new("."), store1, - Arc::new(genesis), + Arc::clone(&genesis), vec![], vec![], ))]; @@ -462,11 +462,8 @@ fn test_verify_chunk_invalid_state_challenge() { let adapter = chain.runtime_adapter.clone(); let epoch_length = chain.epoch_length; let empty_block_pool = OrphanBlockPool::new(); - let economics_config = BlockEconomicsConfig { - gas_price_adjustment_rate: Rational::from_integer(0), - min_gas_price: 0, - max_gas_price: 100, - }; + let chain_genesis = ChainGenesis::from(&genesis); + let economics_config = BlockEconomicsConfig::from(&chain_genesis); let mut chain_update = ChainUpdate::new( chain.mut_store(), diff --git a/chain/network/tests/runner/mod.rs b/chain/network/tests/runner/mod.rs index 28f1e30bd32..df53daa75d5 100644 --- a/chain/network/tests/runner/mod.rs +++ b/chain/network/tests/runner/mod.rs @@ -59,19 +59,19 @@ pub fn setup_network_node( account_id.as_str(), )); let telemetry_actor = TelemetryActor::new(TelemetryConfig::default()).start(); - let chain_genesis = ChainGenesis::new( - genesis_time, - 0, - 1_000_000, - 100, - 1_000_000_000, - 1_000_000_000, - Rational::from_integer(0), - Rational::from_integer(0), - 1000, - 5, - PROTOCOL_VERSION, - ); + let chain_genesis = ChainGenesis { + time: genesis_time, + height: 0, + gas_limit: 1_000_000, + min_gas_price: 100, + max_gas_price: 1_000_000_000, + total_supply: 1_000_000_000, + max_inflation_rate: Rational::from_integer(0), + gas_price_adjustment_rate: Rational::from_integer(0), + transaction_validity_period: 1000, + epoch_length: 5, + protocol_version: PROTOCOL_VERSION, + }; let peer_manager = PeerManagerActor::create(move |ctx| { let mut client_config = ClientConfig::test(false, 100, 200, num_validators, false); diff --git a/core/primitives/src/block.rs b/core/primitives/src/block.rs index 1b9dcb3c3fd..d86d753b960 100644 --- a/core/primitives/src/block.rs +++ b/core/primitives/src/block.rs @@ -233,7 +233,7 @@ impl Block { min_gas_price, max_gas_price, ); - self.header().gas_price() == expected_price + self.header().gas_price() == max(expected_price, min_gas_price) } pub fn compute_new_gas_price( diff --git a/core/primitives/src/version.rs b/core/primitives/src/version.rs index 0705ddf28cb..e5a139fd4f4 100644 --- a/core/primitives/src/version.rs +++ b/core/primitives/src/version.rs @@ -1,3 +1,4 @@ +use crate::types::Balance; use serde::{Deserialize, Serialize}; /// Data structure for semver version and github tag or commit. @@ -17,6 +18,10 @@ pub const DB_VERSION: DbVersion = 4; pub type ProtocolVersion = u32; /// Current latest version of the protocol. -pub const PROTOCOL_VERSION: ProtocolVersion = 30; +pub const PROTOCOL_VERSION: ProtocolVersion = 31; pub const FIRST_BACKWARD_COMPATIBLE_PROTOCOL_VERSION: ProtocolVersion = 29; + +/// Minimum gas price proposed in NEP 92 and the associated protocol version +pub const MIN_GAS_PRICE_NEP_92: Balance = 1_000_000_000; +pub const MIN_PROTOCOL_VERSION_NEP_92: ProtocolVersion = 31; diff --git a/neard/res/genesis_config.json b/neard/res/genesis_config.json index a2128d2cc02..f91e413dd03 100644 --- a/neard/res/genesis_config.json +++ b/neard/res/genesis_config.json @@ -1,5 +1,5 @@ { - "protocol_version": 30, + "protocol_version": 31, "genesis_time": "1970-01-01T00:00:00.000000000Z", "chain_id": "sample", "genesis_height": 0, @@ -18,7 +18,7 @@ "protocol_upgrade_num_epochs": 2, "epoch_length": 500, "gas_limit": 1000000000000000, - "min_gas_price": "5000", + "min_gas_price": "1000000000", "max_gas_price": "10000000000000000000000", "block_producer_kickout_threshold": 90, "chunk_producer_kickout_threshold": 90, diff --git a/neard/src/config.rs b/neard/src/config.rs index 55c6007483d..d2b6e61ce67 100644 --- a/neard/src/config.rs +++ b/neard/src/config.rs @@ -104,7 +104,7 @@ pub const NUM_BLOCKS_PER_YEAR: u64 = 365 * 24 * 60 * 60; pub const INITIAL_GAS_LIMIT: Gas = 1_000_000_000_000_000; /// Initial gas price. -pub const MIN_GAS_PRICE: Balance = 5000; +pub const MIN_GAS_PRICE: Balance = 1_000_000_000; /// Protocol treasury account pub const PROTOCOL_TREASURY_ACCOUNT: &str = "near"; diff --git a/pytest/tests/sanity/upgradable.py b/pytest/tests/sanity/upgradable.py index b9d96dfb665..abc03101d18 100644 --- a/pytest/tests/sanity/upgradable.py +++ b/pytest/tests/sanity/upgradable.py @@ -9,12 +9,15 @@ import subprocess import shutil import sys +import time +import base58 sys.path.append('lib') import branches import cluster from utils import wait_for_blocks_or_timeout +from transaction import sign_payment_tx def main(): @@ -35,7 +38,11 @@ def main(): "%snear-%s" % (near_root, stable_branch), "--home=%s" % node_root, "testnet", "--v", "4", "--prefix", "test" ]) - genesis_config_changes = [("epoch_length", 20), ("num_block_producer_seats", 10), ("num_block_producer_seats_per_shard", [10]), ("block_producer_kickout_threshold", 80), ("chunk_producer_kickout_threshold", 80)] + genesis_config_changes = [ + ("epoch_length", 20), ("num_block_producer_seats", 10), + ("num_block_producer_seats_per_shard", [10]), ("block_producer_kickout_threshold", 80), + ("chunk_producer_kickout_threshold", 80), ("chain_id", "testnet") + ] node_dirs = [os.path.join(node_root, 'test%d' % i) for i in range(4)] for i, node_dir in enumerate(node_dirs): cluster.apply_genesis_changes(node_dir, genesis_config_changes) @@ -55,6 +62,15 @@ def main(): nodes.append(cluster.spin_up_node( config, near_root, node_dirs[3], 3, nodes[0].node_key.pk, nodes[0].addr())) + time.sleep(2) + + # send a transaction to make sure that the execution result is consistent across nodes. + status = nodes[0].get_status() + tx = sign_payment_tx(nodes[0].signer_key, 'test1', 100, 1, + base58.b58decode(status['sync_info']['latest_block_hash'].encode('utf8'))) + res = nodes[0].send_tx_and_wait(tx, timeout=20) + assert 'error' not in res, res + wait_for_blocks_or_timeout(nodes[0], 20, 120) # Restart stable nodes into new version. @@ -71,6 +87,9 @@ def main(): assert protocol_version == latest_protocol_version,\ "Latest protocol version %d should match active protocol version %d" % (latest_protocol_version, protocol_version) + gas_price = nodes[0].json_rpc('gas_price', [None]) + assert gas_price['result']['gas_price'] == '1000000000', gas_price + if __name__ == "__main__": main()