-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Verify the storage root and tx trie root in runtime #52
Conversation
Also refactor `TestExternalities` into a single place.
Also refactor wasm exports to be stricter on invalid mem references.
| ext_enumerated_trie_root(values_data: *const u8, values_len: u32, lens_data: *const u32, lens_len: u32, result: *mut u8) => { | ||
| let values = (0..lens_len) | ||
| .map(|i| this.memory.read_primitive(lens_data + i * 4)) | ||
| .collect::<::std::result::Result<Vec<u32>, DummyUserError>>()? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyone know of any better way of shortcircuiting a Result than .collect()?.into_iter()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is unstable though
| } | ||
| })() | ||
| let mut sig = [0u8; 64]; | ||
| this.memory.get_into(sig_data, &mut sig[..]).map_err(|_| DummyUserError)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous version preserved error code here. Is it intentionally discarded now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup - any attempt to read out of bounds memory is now a strict runtime error.
This API only works with our in-memory stuff, but that's fine for PoC-1. We'll need to rethink this for PoC-2 when we have a more serious backend.
Closes #37
Closes #39