diff --git a/Cargo.lock b/Cargo.lock index 2f0bdc593..683fb8df0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1704,7 +1704,7 @@ dependencies = [ [[package]] name = "near-sdk-sim" -version = "3.1.1" +version = "3.2.0" dependencies = [ "fungible-token", "funty", diff --git a/examples/fungible-token/Cargo.lock b/examples/fungible-token/Cargo.lock index 6dd045ee5..4da92d2dd 100644 --- a/examples/fungible-token/Cargo.lock +++ b/examples/fungible-token/Cargo.lock @@ -1717,7 +1717,7 @@ dependencies = [ [[package]] name = "near-sdk-sim" -version = "3.1.1" +version = "3.2.0" dependencies = [ "funty", "lazy-static-include", diff --git a/examples/fungible-token/tests/sim/utils.rs b/examples/fungible-token/tests/sim/utils.rs index f207e1eef..b15aa7f95 100644 --- a/examples/fungible-token/tests/sim/utils.rs +++ b/examples/fungible-token/tests/sim/utils.rs @@ -35,7 +35,7 @@ pub fn register_user(user: &near_sdk_sim::UserAccount) { pub fn init_no_macros(initial_balance: u128) -> (UserAccount, UserAccount, UserAccount) { let root = init_simulator(None); - let ft = root.deploy(&FT_WASM_BYTES, FT_ID.into(), STORAGE_AMOUNT); + let ft = root.deploy(&FT_WASM_BYTES, FT_ID.into(), to_yocto("5")); ft.call( FT_ID.into(), diff --git a/near-sdk-sim/Cargo.toml b/near-sdk-sim/Cargo.toml index dfb5da02c..c202f1933 100644 --- a/near-sdk-sim/Cargo.toml +++ b/near-sdk-sim/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "near-sdk-sim" -version = "3.1.1" +version = "3.2.0" authors = ["Near Inc "] edition = "2018" license = "GPL-3.0" diff --git a/near-sdk-sim/README.md b/near-sdk-sim/README.md index 7c96b5245..7c6d6912f 100644 --- a/near-sdk-sim/README.md +++ b/near-sdk-sim/README.md @@ -14,9 +14,12 @@ To view this documentation locally, clone this repo and from this folder run `ca ## Changelog -### `3.1.1` +### `3.2.0` -* Fixed stack overflow for deep chain [PR #385](https://github.com/near/near-sdk-rs/pull/385). +* Introduce `block_prod_time` duration in nanoseconds to `GenesisConfig` that defines the duration between produced blocks. +* Expose `cur_block` and `genesis_config` from `RuntimeStandalone`. This allows to manipulate block time. +* Use `RuntimeConfig::from_protocol_version` that fixes storage costs issue. +* Set root account balance to one billion tokens. # Getting started @@ -28,7 +31,7 @@ Currently this crate depends on a the GitHub repo of [nearcore](https://github.c ```toml [dev-dependencies] -near-sdk-sim = "3.1.1" +near-sdk-sim = "3.2.0" ``` @@ -36,7 +39,7 @@ And update `near-sdk` too: ```toml [dependencies] -near-sdk = "3.1.1" +near-sdk = "3.1.0" ``` @@ -61,8 +64,8 @@ Now in the root of the project (`contract-wrap`), create a new `Cargo.toml`. You ```toml [dev-dependencies] -near-sdk = "3.1.1" -near-sdk-sim = "3.1.1" +near-sdk = "3.1.0" +near-sdk-sim = "3.2.0" contract = { path = "./contract" } [workspace] diff --git a/near-sdk-sim/src/runtime.rs b/near-sdk-sim/src/runtime.rs index 4138cc959..ac690d183 100644 --- a/near-sdk-sim/src/runtime.rs +++ b/near-sdk-sim/src/runtime.rs @@ -56,7 +56,12 @@ pub struct GenesisConfig { impl Default for GenesisConfig { fn default() -> Self { - let runtime_config = RuntimeConfig::default(); + let runtime_config = RuntimeConfig::from_protocol_version( + &Arc::new(RuntimeConfig::default()), + PROTOCOL_VERSION, + ) + .as_ref() + .clone(); Self { genesis_time: 0, gas_price: 100_000_000, @@ -74,7 +79,7 @@ impl Default for GenesisConfig { impl GenesisConfig { pub fn init_root_signer(&mut self, account_id: &str) -> InMemorySigner { let signer = InMemorySigner::from_seed(account_id, KeyType::ED25519, "test"); - let root_account = account_new(std::u128::MAX, CryptoHash::default()); + let root_account = account_new(10u128.pow(33), CryptoHash::default()); self.state_records.push(StateRecord::Account { account_id: account_id.to_string(), @@ -146,12 +151,12 @@ impl Block { } pub struct RuntimeStandalone { - genesis: GenesisConfig, + pub genesis: GenesisConfig, tx_pool: TransactionPool, transactions: HashMap, outcomes: HashMap, profile: HashMap, - cur_block: Block, + pub cur_block: Block, runtime: Runtime, tries: ShardTries, pending_receipts: Vec, @@ -268,7 +273,7 @@ impl RuntimeStandalone { random_seed: Default::default(), epoch_id: EpochId::default(), current_protocol_version: PROTOCOL_VERSION, - config: Arc::from(self.genesis.runtime_config.clone()), + config: Arc::new(self.genesis.runtime_config.clone()), #[cfg(feature = "no_contract_cache")] cache: None, #[cfg(not(feature = "no_contract_cache"))]