From d0326b61a956abe84b0a1e96ee61ad8c1216c1bf Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Thu, 2 Mar 2023 12:15:04 +0000 Subject: [PATCH 01/12] Add `set_code_hash` to `EnvAccess` --- crates/env/src/api.rs | 9 ++++-- crates/ink/src/env_access.rs | 31 +++++++++++++++++++ .../set-code-hash/updated-incrementer/lib.rs | 2 +- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 1449e707388..ff10ee435d0 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -697,8 +697,13 @@ where /// Please refer to the /// [Open Zeppelin docs](https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#modifying-your-contracts) /// for more details and examples. -pub fn set_code_hash(code_hash: &[u8; 32]) -> Result<()> { - ::on_instance(|instance| instance.set_code_hash(code_hash)) +pub fn set_code_hash(code_hash: &E::Hash) -> Result<()> +where + E: Environment, +{ + ::on_instance(|instance| { + instance.set_code_hash(code_hash.as_ref()) + }) } /// Tries to trigger a runtime dispatchable, i.e. an extrinsic from a pallet. diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index 46c94dc2497..251b2ea71d1 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -970,6 +970,37 @@ where ink_env::own_code_hash::() } + /// Replace the contract code at the specified address with new code. + /// + /// # Example + /// + /// ``` + /// # #[ink::contract] + /// # pub mod my_contract { + /// # #[ink(storage)] + /// # pub struct MyContract { } + /// # + /// # impl MyContract { + /// # #[ink(constructor)] + /// # pub fn new() -> Self { + /// # Self {} + /// # } + /// # + /// #[ink(message)] + /// pub fn set_code_hash(&mut self, code_hash: Hash) { + /// self.env().set_code_hash(&code_hash).unwrap_or_else(|err| panic!("failed to set code hash: {:?}", err)) + /// } + /// # } + /// # } + /// ``` + /// + /// # Note + /// + /// For more details visit: [`ink_env::set_code_hash`] + pub fn set_code_hash(self, code_hash: &E::Hash) -> Result<()> { + ink_env::set_code_hash::(code_hash) + } + #[cfg(feature = "call-runtime")] pub fn call_runtime(self, call: &Call) -> Result<()> { ink_env::call_runtime::(call) diff --git a/integration-tests/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs b/integration-tests/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs index de2b517c98e..b7001ccab60 100644 --- a/integration-tests/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs +++ b/integration-tests/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs @@ -49,7 +49,7 @@ pub mod incrementer { /// can execute this method. In a production contract you would do some authorization here. #[ink(message)] pub fn set_code(&mut self, code_hash: [u8; 32]) { - ink::env::set_code_hash(&code_hash).unwrap_or_else(|err| { + self.env().set_code_hash(&code_hash).unwrap_or_else(|err| { panic!("Failed to `set_code_hash` to {code_hash:?} due to {err:?}") }); ink::env::debug_println!("Switched code hash to {:?}.", code_hash); From afe53a497cd48842cc4176cc3da340b1a21bd5c4 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Thu, 2 Mar 2023 12:15:45 +0000 Subject: [PATCH 02/12] Update example --- integration-tests/upgradeable-contracts/set-code-hash/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/upgradeable-contracts/set-code-hash/lib.rs b/integration-tests/upgradeable-contracts/set-code-hash/lib.rs index ce36570a740..26e7cec8e88 100644 --- a/integration-tests/upgradeable-contracts/set-code-hash/lib.rs +++ b/integration-tests/upgradeable-contracts/set-code-hash/lib.rs @@ -45,7 +45,7 @@ pub mod incrementer { /// can execute this method. In a production contract you would do some authorization here. #[ink(message)] pub fn set_code(&mut self, code_hash: [u8; 32]) { - ink::env::set_code_hash(&code_hash).unwrap_or_else(|err| { + self.env().set_code_hash(&code_hash).unwrap_or_else(|err| { panic!("Failed to `set_code_hash` to {code_hash:?} due to {err:?}") }); ink::env::debug_println!("Switched code hash to {:?}.", code_hash); From 669b567cc863aa55a4406f6496a52f59c05b3ed6 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Thu, 2 Mar 2023 12:17:45 +0000 Subject: [PATCH 03/12] Update examples to use Hash type --- integration-tests/upgradeable-contracts/set-code-hash/lib.rs | 2 +- .../set-code-hash/updated-incrementer/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/upgradeable-contracts/set-code-hash/lib.rs b/integration-tests/upgradeable-contracts/set-code-hash/lib.rs index 26e7cec8e88..74ae48abce0 100644 --- a/integration-tests/upgradeable-contracts/set-code-hash/lib.rs +++ b/integration-tests/upgradeable-contracts/set-code-hash/lib.rs @@ -44,7 +44,7 @@ pub mod incrementer { /// We use this to upgrade the contract logic. We don't do any authorization here, any caller /// can execute this method. In a production contract you would do some authorization here. #[ink(message)] - pub fn set_code(&mut self, code_hash: [u8; 32]) { + pub fn set_code(&mut self, code_hash: Hash) { self.env().set_code_hash(&code_hash).unwrap_or_else(|err| { panic!("Failed to `set_code_hash` to {code_hash:?} due to {err:?}") }); diff --git a/integration-tests/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs b/integration-tests/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs index b7001ccab60..55f971a7e1f 100644 --- a/integration-tests/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs +++ b/integration-tests/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs @@ -48,7 +48,7 @@ pub mod incrementer { /// We use this to upgrade the contract logic. We don't do any authorization here, any caller /// can execute this method. In a production contract you would do some authorization here. #[ink(message)] - pub fn set_code(&mut self, code_hash: [u8; 32]) { + pub fn set_code(&mut self, code_hash: Hash) { self.env().set_code_hash(&code_hash).unwrap_or_else(|err| { panic!("Failed to `set_code_hash` to {code_hash:?} due to {err:?}") }); From 3628ee64e910ddeb8cf8c62428537bbee2f749c2 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 3 Mar 2023 09:09:55 +0000 Subject: [PATCH 04/12] Make it a non breaking change --- crates/env/src/api.rs | 5 +---- crates/ink/src/env_access.rs | 7 +++++-- crates/primitives/src/types.rs | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index ff10ee435d0..93a30f3d92a 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -697,10 +697,7 @@ where /// Please refer to the /// [Open Zeppelin docs](https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#modifying-your-contracts) /// for more details and examples. -pub fn set_code_hash(code_hash: &E::Hash) -> Result<()> -where - E: Environment, -{ +pub fn set_code_hash(code_hash: &[u8; 32]) -> Result<()> { ::on_instance(|instance| { instance.set_code_hash(code_hash.as_ref()) }) diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index 251b2ea71d1..d255140bdd1 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -997,8 +997,11 @@ where /// # Note /// /// For more details visit: [`ink_env::set_code_hash`] - pub fn set_code_hash(self, code_hash: &E::Hash) -> Result<()> { - ink_env::set_code_hash::(code_hash) + pub fn set_code_hash(self, code_hash: &E::Hash) -> Result<()> + where + E::Hash: AsRef<[u8; 32]>, + { + ink_env::set_code_hash(code_hash.as_ref()) } #[cfg(feature = "call-runtime")] diff --git a/crates/primitives/src/types.rs b/crates/primitives/src/types.rs index bd369290a80..b473e4acf25 100644 --- a/crates/primitives/src/types.rs +++ b/crates/primitives/src/types.rs @@ -108,6 +108,12 @@ impl AsRef<[u8]> for Hash { } } +impl AsRef<[u8; 32]> for Hash { + fn as_ref(&self) -> &[u8; 32] { + &self.0 + } +} + impl AsMut<[u8]> for Hash { fn as_mut(&mut self) -> &mut [u8] { &mut self.0[..] From 314ae67eaa3c403f2682475ed0e3f8d1fc008330 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 3 Mar 2023 11:35:45 +0000 Subject: [PATCH 05/12] revert --- crates/env/src/api.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 93a30f3d92a..1449e707388 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -698,9 +698,7 @@ where /// [Open Zeppelin docs](https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#modifying-your-contracts) /// for more details and examples. pub fn set_code_hash(code_hash: &[u8; 32]) -> Result<()> { - ::on_instance(|instance| { - instance.set_code_hash(code_hash.as_ref()) - }) + ::on_instance(|instance| instance.set_code_hash(code_hash)) } /// Tries to trigger a runtime dispatchable, i.e. an extrinsic from a pallet. From 7d4670a9eddcdc440f4e7ff594f392695e3b5f54 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 3 Mar 2023 12:02:25 +0000 Subject: [PATCH 06/12] Remove `AsRef`, add set_code_hash2 --- crates/env/src/api.rs | 100 +++++++++++++++++++++++++++++++++ crates/ink/src/env_access.rs | 7 +-- crates/primitives/src/types.rs | 6 -- 3 files changed, 102 insertions(+), 11 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 1449e707388..997be2c0ca4 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -701,6 +701,106 @@ pub fn set_code_hash(code_hash: &[u8; 32]) -> Result<()> { ::on_instance(|instance| instance.set_code_hash(code_hash)) } +/// **New version of this function which will replace [`set_code_hash`] in `v5.0`** +/// +/// Replace the contract code at the specified address with new code. +/// +/// # Note +/// +/// There are a couple of important considerations which must be taken into account when +/// using this API: +/// +/// 1. The storage at the code hash will remain untouched. This means that contract developers +/// must ensure that the storage layout of the new code is compatible with that of the old code. +/// +/// 2. Contracts using this API can't be assumed as having deterministic addresses. Said another way, +/// when using this API you lose the guarantee that an address always identifies a specific code hash. +/// +/// 3. If a contract calls into itself after changing its code the new call would use +/// the new code. However, if the original caller panics after returning from the sub call it +/// would revert the changes made by `set_code_hash` and the next caller would use +/// the old code. +/// +/// # Errors +/// +/// `ReturnCode::CodeNotFound` in case the supplied `code_hash` cannot be found on-chain. +/// +/// # Storage Compatibility +/// +/// When the smart contract code is modified, +/// it is important to observe an additional virtual restriction +/// that is imposed on this procedure: +/// you should not change the order in which the contract state variables +/// are declared, nor their type. +/// +/// Violating the restriction will not prevent a successful compilation, +/// but will result in the mix-up of values or failure to read the storage correctly. +/// This can result in severe errors in the application utilizing the contract. +/// +/// If the storage of your contract looks like this: +/// +/// ```ignore +/// #[ink(storage)] +/// pub struct YourContract { +/// x: u32, +/// y: bool, +/// } +/// ``` +/// +/// The procedures listed below will make it invalid: +/// +/// Changing the order of variables: +/// +/// ```ignore +/// #[ink(storage)] +/// pub struct YourContract { +/// y: bool, +/// x: u32, +/// } +/// ``` +/// +/// Removing existing variable: +/// +/// ```ignore +/// #[ink(storage)] +/// pub struct YourContract { +/// x: u32, +/// } +/// ``` +/// +/// Changing type of a variable: +/// +/// ```ignore +/// #[ink(storage)] +/// pub struct YourContract { +/// x: u64, +/// y: bool, +/// } +/// ``` +/// +/// Introducing a new variable before any of the existing ones: +/// +/// ```ignore +/// #[ink(storage)] +/// pub struct YourContract { +/// z: Vec, +/// x: u32, +/// y: bool, +/// } +/// ``` +/// +/// Please refer to the +/// [Open Zeppelin docs](https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#modifying-your-contracts) +/// for more details and examples. +pub fn set_code_hash2(code_hash: &E::Hash) -> Result<()> +where + E: Environment, +{ + ::on_instance(|instance| { + instance.set_code_hash(code_hash.as_ref()) + }) +} + /// Tries to trigger a runtime dispatchable, i.e. an extrinsic from a pallet. /// /// `call` (after SCALE encoding) should be decodable to a valid instance of `RuntimeCall` enum. diff --git a/crates/ink/src/env_access.rs b/crates/ink/src/env_access.rs index d255140bdd1..8c97bd94e2a 100644 --- a/crates/ink/src/env_access.rs +++ b/crates/ink/src/env_access.rs @@ -997,11 +997,8 @@ where /// # Note /// /// For more details visit: [`ink_env::set_code_hash`] - pub fn set_code_hash(self, code_hash: &E::Hash) -> Result<()> - where - E::Hash: AsRef<[u8; 32]>, - { - ink_env::set_code_hash(code_hash.as_ref()) + pub fn set_code_hash(self, code_hash: &E::Hash) -> Result<()> { + ink_env::set_code_hash2::(code_hash) } #[cfg(feature = "call-runtime")] diff --git a/crates/primitives/src/types.rs b/crates/primitives/src/types.rs index b473e4acf25..bd369290a80 100644 --- a/crates/primitives/src/types.rs +++ b/crates/primitives/src/types.rs @@ -108,12 +108,6 @@ impl AsRef<[u8]> for Hash { } } -impl AsRef<[u8; 32]> for Hash { - fn as_ref(&self) -> &[u8; 32] { - &self.0 - } -} - impl AsMut<[u8]> for Hash { fn as_mut(&mut self) -> &mut [u8] { &mut self.0[..] From 540e5a9b2e2d358fd36f94bb6e0f01b35a83d8bf Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 3 Mar 2023 12:36:09 +0000 Subject: [PATCH 07/12] CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37c6ce04323..97933b1bdf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - Basic support for `dyn Trait` to allow cross-contract calls only with trait - [#1673](https://github.com/paritytech/ink/pull/1673) +- Add `set_code_hash` to `EnvAccess` - [#1698](https://github.com/paritytech/ink/pull/1698) ## Version 4.0.1 From dbf619a8321767dd63447e491cb6eb1bff1e98f7 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 3 Mar 2023 13:09:52 +0000 Subject: [PATCH 08/12] Deduplicate comment --- crates/env/src/api.rs | 90 +------------------------------------------ 1 file changed, 2 insertions(+), 88 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 997be2c0ca4..27f820c4227 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -701,97 +701,11 @@ pub fn set_code_hash(code_hash: &[u8; 32]) -> Result<()> { ::on_instance(|instance| instance.set_code_hash(code_hash)) } -/// **New version of this function which will replace [`set_code_hash`] in `v5.0`** +/// **New version of this function which will replace [`set_code_hash`] in the next MAJOR release** /// /// Replace the contract code at the specified address with new code. /// -/// # Note -/// -/// There are a couple of important considerations which must be taken into account when -/// using this API: -/// -/// 1. The storage at the code hash will remain untouched. This means that contract developers -/// must ensure that the storage layout of the new code is compatible with that of the old code. -/// -/// 2. Contracts using this API can't be assumed as having deterministic addresses. Said another way, -/// when using this API you lose the guarantee that an address always identifies a specific code hash. -/// -/// 3. If a contract calls into itself after changing its code the new call would use -/// the new code. However, if the original caller panics after returning from the sub call it -/// would revert the changes made by `set_code_hash` and the next caller would use -/// the old code. -/// -/// # Errors -/// -/// `ReturnCode::CodeNotFound` in case the supplied `code_hash` cannot be found on-chain. -/// -/// # Storage Compatibility -/// -/// When the smart contract code is modified, -/// it is important to observe an additional virtual restriction -/// that is imposed on this procedure: -/// you should not change the order in which the contract state variables -/// are declared, nor their type. -/// -/// Violating the restriction will not prevent a successful compilation, -/// but will result in the mix-up of values or failure to read the storage correctly. -/// This can result in severe errors in the application utilizing the contract. -/// -/// If the storage of your contract looks like this: -/// -/// ```ignore -/// #[ink(storage)] -/// pub struct YourContract { -/// x: u32, -/// y: bool, -/// } -/// ``` -/// -/// The procedures listed below will make it invalid: -/// -/// Changing the order of variables: -/// -/// ```ignore -/// #[ink(storage)] -/// pub struct YourContract { -/// y: bool, -/// x: u32, -/// } -/// ``` -/// -/// Removing existing variable: -/// -/// ```ignore -/// #[ink(storage)] -/// pub struct YourContract { -/// x: u32, -/// } -/// ``` -/// -/// Changing type of a variable: -/// -/// ```ignore -/// #[ink(storage)] -/// pub struct YourContract { -/// x: u64, -/// y: bool, -/// } -/// ``` -/// -/// Introducing a new variable before any of the existing ones: -/// -/// ```ignore -/// #[ink(storage)] -/// pub struct YourContract { -/// z: Vec, -/// x: u32, -/// y: bool, -/// } -/// ``` -/// -/// Please refer to the -/// [Open Zeppelin docs](https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#modifying-your-contracts) -/// for more details and examples. +/// See the original [`set_code_hash`] function for full details. pub fn set_code_hash2(code_hash: &E::Hash) -> Result<()> where E: Environment, From a13ed999237770f22e3dda374f7d2593303bf495 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 3 Mar 2023 13:13:33 +0000 Subject: [PATCH 09/12] Remove deleted file --- integration-tests/upgradeable-contracts/set-code-hash/lib.rs | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 integration-tests/upgradeable-contracts/set-code-hash/lib.rs diff --git a/integration-tests/upgradeable-contracts/set-code-hash/lib.rs b/integration-tests/upgradeable-contracts/set-code-hash/lib.rs deleted file mode 100644 index e69de29bb2d..00000000000 From fb27b968d10bd51a76fc5458b2415e6b255733ce Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 3 Mar 2023 16:19:22 +0000 Subject: [PATCH 10/12] Attempt update at comment --- crates/env/src/api.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 27f820c4227..2e6a1bc49f7 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -612,14 +612,17 @@ where /// /// # Note /// -/// There are a couple of important considerations which must be taken into account when +/// There are a few important considerations which must be taken into account when /// using this API: /// /// 1. The storage at the code hash will remain untouched. This means that contract developers /// must ensure that the storage layout of the new code is compatible with that of the old code. /// -/// 2. Contracts using this API can't be assumed as having deterministic addresses. Said another way, -/// when using this API you lose the guarantee that an address always identifies a specific code hash. +/// 2. Contract addresses are initially derived from `hash(deploying_address ++ code_hash ++ salt)`. +/// This makes it possible to determine a contracts address using the `code_hash` of the *initial* +/// code used to instantiate the contract. However, because `set_code_hash` can modify the +/// underlying `code_hash` of a contract, it should not be relied upon that a contracts address can +/// always be derived from its stored `code_hash`. /// /// 3. If a contract calls into itself after changing its code the new call would use /// the new code. However, if the original caller panics after returning from the sub call it From 88bfe66a6997780f997b55bb968927399d23c2b4 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 3 Mar 2023 17:30:42 -0800 Subject: [PATCH 11/12] Improve some of the doc comments --- crates/env/src/api.rs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 2e6a1bc49f7..85f1fb19d70 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -615,19 +615,25 @@ where /// There are a few important considerations which must be taken into account when /// using this API: /// -/// 1. The storage at the code hash will remain untouched. This means that contract developers -/// must ensure that the storage layout of the new code is compatible with that of the old code. +/// 1. The storage at the code hash will remain untouched. /// -/// 2. Contract addresses are initially derived from `hash(deploying_address ++ code_hash ++ salt)`. -/// This makes it possible to determine a contracts address using the `code_hash` of the *initial* -/// code used to instantiate the contract. However, because `set_code_hash` can modify the -/// underlying `code_hash` of a contract, it should not be relied upon that a contracts address can -/// always be derived from its stored `code_hash`. +/// Contract developers **must ensure** that the storage layout of the new code is compatible with +/// that of the old code. /// -/// 3. If a contract calls into itself after changing its code the new call would use -/// the new code. However, if the original caller panics after returning from the sub call it -/// would revert the changes made by `set_code_hash` and the next caller would use -/// the old code. +/// 2. The contract address (`AccountId`) remains the same, while the `code_hash` changes. +/// +/// Contract addresses are initially derived from `hash(deploying_address ++ code_hash ++ salt)`. +/// This makes it possible to determine a contracts address (`AccountId`) using the `code_hash` of +/// the *initial* code used to instantiate the contract. +/// +/// However, because `set_code_hash` can modify the underlying `code_hash` of a contract, it should +/// not be relied upon that a contracts address can always be derived from its stored `code_hash`. +/// +/// 3. Re-entrant calls use new `code_hash`. +/// +/// If a contract calls into itself after changing its code the new call would use the new code. +/// However, if the original caller panics after returning from the sub call it would revert the +/// changes made by `set_code_hash` and the next caller would use the old code. /// /// # Errors /// @@ -704,10 +710,13 @@ pub fn set_code_hash(code_hash: &[u8; 32]) -> Result<()> { ::on_instance(|instance| instance.set_code_hash(code_hash)) } -/// **New version of this function which will replace [`set_code_hash`] in the next MAJOR release** -/// /// Replace the contract code at the specified address with new code. /// +/// # Compatibility +/// +/// This ia new version of the existing [`set_code_hash`] function. We plan to place the old +/// function with this in the next `MAJOR` release. +/// /// See the original [`set_code_hash`] function for full details. pub fn set_code_hash2(code_hash: &E::Hash) -> Result<()> where From 0508e26bf231c39bcd268c9cc221d38d4adbc85d Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 3 Mar 2023 17:33:28 -0800 Subject: [PATCH 12/12] Fix typo --- crates/env/src/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/env/src/api.rs b/crates/env/src/api.rs index 85f1fb19d70..bfe98eee4a6 100644 --- a/crates/env/src/api.rs +++ b/crates/env/src/api.rs @@ -714,7 +714,7 @@ pub fn set_code_hash(code_hash: &[u8; 32]) -> Result<()> { /// /// # Compatibility /// -/// This ia new version of the existing [`set_code_hash`] function. We plan to place the old +/// This is new version of the existing [`set_code_hash`] function. We plan to place the old /// function with this in the next `MAJOR` release. /// /// See the original [`set_code_hash`] function for full details.