From 9ce0cdce0b04e0738f88bd6b082d035987058885 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?dj8yf0=CE=BCl?= <26653921+dj8yfo@users.noreply.github.com>
Date: Tue, 16 Jan 2024 21:54:58 +0200
Subject: [PATCH] chore!: update `nearcore` crates from `0.17` -> `0.20`
(#1130)
---
.github/workflows/test.yml | 11 +-
README.md | 4 +-
near-sdk/Cargo.toml | 14 +-
near-sdk/src/environment/env.rs | 4 +-
near-sdk/src/environment/mock/external.rs | 88 ----------
.../src/environment/mock/mocked_blockchain.rs | 141 +++++++---------
.../src/environment/mock/mocked_memory.rs | 2 +-
near-sdk/src/environment/mock/mod.rs | 6 +-
near-sdk/src/environment/mock/receipt.rs | 156 +++++++++++++++---
near-sdk/src/lib.rs | 4 +-
near-sdk/src/promise.rs | 20 ++-
near-sdk/src/test_utils/context.rs | 8 +-
near-sdk/src/test_utils/mod.rs | 14 +-
near-sdk/src/test_utils/test_env.rs | 8 +-
near-sdk/src/types/primitives.rs | 2 +-
near-sdk/src/types/public_key.rs | 34 ++++
near-sdk/src/types/vm_types.rs | 2 +-
17 files changed, 277 insertions(+), 241 deletions(-)
delete mode 100644 near-sdk/src/environment/mock/external.rs
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index eab7d4661..96063203c 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
- toolchain: [stable, 1.69.0]
+ toolchain: [stable, 1.72.1]
steps:
- uses: actions/checkout@v3
- name: "${{ matrix.toolchain }} with rustfmt, and wasm32"
@@ -23,15 +23,6 @@ jobs:
toolchain: ${{ matrix.toolchain }}
default: true
target: wasm32-unknown-unknown
- - name: downgrade `anstyle`,`anstyle-parse`,`anstyle-query`,`clap`,`clap_lex`, `home` crates to support older Rust toolchain
- if: matrix.toolchain == '1.69.0'
- run: |
- cargo update -p anstyle --precise 1.0.2
- cargo update -p anstyle-query --precise 1.0.0
- cargo update -p anstyle-parse --precise 0.2.1
- cargo update -p clap --precise 4.3.24
- cargo update -p clap_lex --precise 0.5.0
- cargo update -p home --precise 0.5.5
- uses: Swatinem/rust-cache@v1
- name: Test
run: cargo test --all --features unstable,legacy
diff --git a/README.md b/README.md
index 4e58b8e86..7cc43c6e6 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@
-
+
@@ -260,7 +260,7 @@ State breaking changes (low-level serialization format of any data type) will be
### MSRV
-The minimum supported Rust version is currently `1.69`. There are no guarantees that this will be upheld if a security patch release needs to come in that requires a Rust toolchain increase.
+The minimum supported Rust version is currently `1.72`. There are no guarantees that this will be upheld if a security patch release needs to come in that requires a Rust toolchain increase.
## Contributing
diff --git a/near-sdk/Cargo.toml b/near-sdk/Cargo.toml
index d7fc4c5a1..a0ad45499 100644
--- a/near-sdk/Cargo.toml
+++ b/near-sdk/Cargo.toml
@@ -34,15 +34,17 @@ wee_alloc = { version = "0.4.5", default-features = false, optional = true }
once_cell = { version = "1.17", default-features = false }
near-abi = { version = "0.4.0", features = ["__chunked-entries"], optional = true }
-near-account-id = { version="1.0.0-alpha.4", features = ["serde", "borsh"] }
+near-account-id = { version="1.0.0", features = ["serde", "borsh"] }
near-gas = { version = "0.2.3", features = ["serde", "borsh"] }
near-token = { version = "0.2.0", features = ["serde", "borsh"] }
+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-near-vm-logic = { version = "0.17", optional = true }
-near-primitives-core = { version = "0.17", optional = true }
-near-primitives = { version = "0.17", optional = true }
-near-crypto = { version = "0.17", optional = true }
+near-vm-runner = { version = "0.20", optional = true }
+near-primitives-core = { version = "0.20", optional = true }
+near-primitives = { version = "0.20", optional = true }
+near-crypto = { version = "0.20", optional = true }
+near-parameters = { version = "0.20", optional = true }
[dev-dependencies]
rand = "0.8.4"
@@ -63,7 +65,7 @@ expensive-debug = []
unstable = []
legacy = []
abi = ["borsh/unstable__schema", "near-abi", "schemars", "near-sdk-macros/abi", "near-account-id/abi", "near-gas/abi", "near-token/abi"]
-unit-testing = ["near-vm-logic", "near-primitives-core", "near-primitives", "near-crypto"]
+unit-testing = ["near-vm-runner", "near-primitives-core", "near-primitives", "near-crypto", "near-parameters"]
__abi-embed = ["near-sdk-macros/__abi-embed"]
__abi-generate = ["abi", "near-sdk-macros/__abi-generate"]
diff --git a/near-sdk/src/environment/env.rs b/near-sdk/src/environment/env.rs
index ea1e236a4..1e89fe9ad 100644
--- a/near-sdk/src/environment/env.rs
+++ b/near-sdk/src/environment/env.rs
@@ -79,9 +79,9 @@ pub(crate) unsafe fn read_register_fixed_64(register_id: u64) -> [u8; 64] {
/// low-level blockchain interfacr that implements `BlockchainInterface` trait. In most cases you
/// want to use `testing_env!` macro to set it.
///
-/// ```no_run
+/// ```
/// # let context = near_sdk::test_utils::VMContextBuilder::new().build();
-/// # let vm_config = near_sdk::VMConfig::test();
+/// # let vm_config = near_sdk::test_vm_config();
/// # let fees_config = near_sdk::RuntimeFeesConfig::test();
/// # let storage = Default::default();
/// # let validators = Default::default();
diff --git a/near-sdk/src/environment/mock/external.rs b/near-sdk/src/environment/mock/external.rs
deleted file mode 100644
index 79a8802ce..000000000
--- a/near-sdk/src/environment/mock/external.rs
+++ /dev/null
@@ -1,88 +0,0 @@
-use near_primitives::types::TrieNodesCount;
-use near_primitives_core::hash::{hash, CryptoHash};
-use near_primitives_core::types::{AccountId, Balance};
-use near_vm_logic::{External, StorageGetMode, ValuePtr};
-use std::collections::HashMap;
-
-type Result = ::core::result::Result;
-
-#[derive(Default, Clone)]
-/// Emulates the trie and the mock handling code for the SDK. This is a modified version of
-/// `MockedExternal` from `near_vm_logic`.
-pub(crate) struct SdkExternal {
- pub fake_trie: HashMap, Vec>,
- pub validators: HashMap,
- data_count: u64,
-}
-
-pub struct MockedValuePtr {
- value: Vec,
-}
-
-impl ValuePtr for MockedValuePtr {
- fn len(&self) -> u32 {
- self.value.len() as u32
- }
-
- fn deref(&self) -> Result> {
- Ok(self.value.clone())
- }
-}
-
-impl SdkExternal {
- pub fn new() -> Self {
- Self::default()
- }
-}
-
-impl External for SdkExternal {
- fn storage_set(&mut self, key: &[u8], value: &[u8]) -> Result<()> {
- self.fake_trie.insert(key.to_vec(), value.to_vec());
- Ok(())
- }
-
- fn storage_get(
- &self,
- key: &[u8],
- _storage_get_mode: StorageGetMode,
- ) -> Result