-
Notifications
You must be signed in to change notification settings - Fork 14
Conversation
* Implemented `getters` & `setters` for primitives
…ress` (a thin wrapper around `*const u8`).
…d for `MockHost`.
…ng anymore `RefCell` for `MockHost`).
crates/svm-sdk/alloc/src/lib.rs
Outdated
|
||
#[derive(Debug, PartialEq, Copy, Clone, Hash)] | ||
#[repr(transparent)] | ||
pub struct Ptr(pub usize); |
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.
What's the usage of this? Was it supposed to be used in alloc
func?
unsafe { | ||
INIT.call_once(|| { | ||
HOST = MaybeUninit::new(InnerHost::new()); | ||
}); |
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.
If INIT
is ought to be initialized only once, why not using lazy_static!
like previously?
Also, you previously applied a mutex lock - isn't it needed? Are you now relying on the client to protect against concurrent read/write?
#![allow(dead_code)] | ||
#![allow(unreachable_code)] | ||
|
||
extern crate alloc; |
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.
Perhaps calling it memory
like previously is preferred - both so you could add additional functionality, and also to give better context to the alloc
func.
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 prefer to keep the current name for now.
I don't expect it to change in the future.
crates/svm-sdk/alloc/src/lib.rs
Outdated
|
||
use alloc::alloc::{alloc_zeroed, Layout}; | ||
|
||
pub fn alloc(n: usize) -> usize { |
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.
Perhaps specify what's the benefit of using alloc
over something else.
Is it just because it provides zero-initialized bytes? Or also because of the allocator it is using?
|
||
f(); | ||
|
||
drop(guard) |
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.
Isn't guard
going to be dropped here anyway?
@@ -0,0 +1,271 @@ | |||
// use cfg_if::cfg_if; | |||
|
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.
Why commented?
@@ -173,7 +173,7 @@ fn storage() -> MutexGuard<'static, InnerStorage> { | |||
mod tests { | |||
use super::*; | |||
|
|||
use crate::memory::alloc; | |||
use svm_sdk_alloc::alloc; |
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.
STORAGE
instance init/access pattern is different than HOST
- If there's no reason for that, it should be unified.
Motivation
Adding
[endpoint]
proc-macro attribute. It should ease the implementation of apps' endpoints.This macro implements:
Auto-parsing of the input calldata to Rust native types (see PR: CallData Decode API #181)
Will generate in a future PR the API schema in a JSON format (will be consumed by
smapp
). For now, it will gather the required data in compile-time.