Created
May 16, 2019 14:02
-
-
Save brenzi/936ceab317e350507ae4cb7d6ec4434f to your computer and use it in GitHub Desktop.
raw Externalities HashMap write
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub type SgxExternalities = HashMap<Vec<u8>, Vec<u8>>; | |
... | |
let mut ext = SgxExternalities::new(); | |
... | |
//custom struct | |
let key = runtime_io::twox_128("Contract Schedule".to_vec()); | |
let value = Schedule::<Gas>::default().encode() | |
ext.insert(key.to_vec(), value) | |
... | |
// primitive Type | |
let key = runtime_io::twox_128("Contract BlockGasLimit".to_vec()); | |
let value = 10_000_000u64.encode() | |
ext.insert(key.to_vec(), value) |
// key "Contract BlockGasLimit" is
twox_128 of [43, 6f, 6e, 74, 72, 61, 63, 74, 20, 42, 6c, 6f, 63, 6b, 47, 61, 73, 4c, 69, 6d, 69, 74]
// writing 0u64.encode() to that key results in raw:
[0, 0, 0, 0, 0, 0, 0, 0]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scenario: I'm writing a replacement for sr-io which can run in an SGX enclave. Therefore I have to manage state storage myself.
I manually enter all the needed genesis config() values.
However, the value BlockGasLimit seems not to be understood by srml-contract. The Runtime panics at:
https://github.com/paritytech/substrate/blob/563096ee8ec2dd73144a9b600ef085ace30e6c49/srml/contract/src/gas.rs#L208
I guess there's an issue with deserializing the value into the right format. Not sure.