Skip to content

Commit

Permalink
fix: gas price (#3067)
Browse files Browse the repository at this point in the history
I made a typo in #3028 and updated gas price to 1B yotcoNEAR instead of 100M yotcoNEAR.

Test plan
---------
`upgradable.py`
  • Loading branch information
bowenwang1996 committed Aug 6, 2020
1 parent 830c214 commit 040cb15
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
24 changes: 17 additions & 7 deletions chain/chain/src/types.rs
Expand Up @@ -20,7 +20,8 @@ use near_primitives::types::{
NumBlocks, ShardId, StateRoot, StateRootNode, ValidatorStake,
};
use near_primitives::version::{
ProtocolVersion, MIN_GAS_PRICE_NEP_92, MIN_PROTOCOL_VERSION_NEP_92,
ProtocolVersion, MIN_GAS_PRICE_NEP_92, MIN_GAS_PRICE_NEP_92_FIX, MIN_PROTOCOL_VERSION_NEP_92,
MIN_PROTOCOL_VERSION_NEP_92_FIX,
};
use near_primitives::views::{EpochValidatorInfo, QueryRequest, QueryResponse};
use near_store::{PartialStorage, ShardTries, Store, Trie, WrappedTrieChanges};
Expand Down Expand Up @@ -141,13 +142,22 @@ pub struct BlockEconomicsConfig {
}

impl BlockEconomicsConfig {
/// Compute min gas price according to protocol version and chain id. We only upgrade gas price
/// for betanet, testnet and mainnet.
/// Compute min gas price according to protocol version and genesis protocol version.
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
if self.genesis_protocol_version < MIN_PROTOCOL_VERSION_NEP_92 {
if protocol_version >= MIN_PROTOCOL_VERSION_NEP_92_FIX {
MIN_GAS_PRICE_NEP_92_FIX
} else if protocol_version >= MIN_PROTOCOL_VERSION_NEP_92 {
MIN_GAS_PRICE_NEP_92
} else {
self.min_gas_price
}
} else if self.genesis_protocol_version < MIN_PROTOCOL_VERSION_NEP_92_FIX {
if protocol_version >= MIN_PROTOCOL_VERSION_NEP_92_FIX {
MIN_GAS_PRICE_NEP_92_FIX
} else {
MIN_GAS_PRICE_NEP_92
}
} else {
self.min_gas_price
}
Expand Down
6 changes: 5 additions & 1 deletion core/primitives/src/version.rs
Expand Up @@ -18,10 +18,14 @@ pub const DB_VERSION: DbVersion = 5;
pub type ProtocolVersion = u32;

/// Current latest version of the protocol.
pub const PROTOCOL_VERSION: ProtocolVersion = 31;
pub const PROTOCOL_VERSION: ProtocolVersion = 32;

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;

/// Minimum gas price proposed in NEP 92 (fixed) and the associated protocol version
pub const MIN_GAS_PRICE_NEP_92_FIX: Balance = 100_000_000;
pub const MIN_PROTOCOL_VERSION_NEP_92_FIX: ProtocolVersion = 32;
2 changes: 1 addition & 1 deletion neard/res/genesis_config.json
@@ -1,5 +1,5 @@
{
"protocol_version": 31,
"protocol_version": 32,
"genesis_time": "1970-01-01T00:00:00.000000000Z",
"chain_id": "sample",
"genesis_height": 0,
Expand Down
4 changes: 3 additions & 1 deletion pytest/tests/sanity/upgradable.py
Expand Up @@ -88,7 +88,9 @@ def main():
"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
gas_price = int(gas_price['result']['gas_price'])
assert gas_price < 1000000000, gas_price
assert gas_price > 100000000, gas_price


if __name__ == "__main__":
Expand Down

0 comments on commit 040cb15

Please sign in to comment.