-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core,model] Add ext_random_seed
runtime call bindings
#54
[core,model] Add ext_random_seed
runtime call bindings
#54
Conversation
Adding the ability for contracts to get the random seed of the block. Returning the value as a Vec<u8>, although within substrate it is treated as a `Hash`... should/how do I use the `Hash` type?
I see that So I think we should really first base pDSL upon |
core/src/env/test_env.rs
Outdated
@@ -190,6 +198,11 @@ impl TestEnvData { | |||
pub fn set_input(&mut self, input_bytes: &[u8]) { | |||
self.input = input_bytes.to_vec(); | |||
} | |||
|
|||
/// Sets the random seed for the next contract invocation. | |||
pub fn set_random_seed(&mut self, random_seed_bytes: &[u8]) { |
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.
I guess in Substrate we are missing a way to mirror setting a random seed, right?
Not sure about this interface but it should be fine for 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.
I only added it cause I have no idea how the random seed would be generated otherwise...
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.
Looks a lot better now.
Also will be easier to convert to node-runtime
once that's done.
core/src/env/srml/types.rs
Outdated
pub struct Address([u8; 32]); | ||
|
||
impl Address { | ||
pub fn new(address: [u8; 32]) -> Address { |
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.
For implementations like these it is recommended to just implement From<[u8;32]>
.
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.
Same for Hash
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.
LGTM
Sorry, didn't mean to close the PR ... |
ext_random_seed
runtime call bindingsext_random_seed
runtime call bindings
I only see formatting issues in the CI not related to this PR so I will merge this now. |
Adding the ability for contracts to get the random seed of the block.
Returning the value as a Vec, although within substrate it is treated as a
Hash
... should/how do I use theHash
type?Fixes #53